/home/dko/projects/mobilec/trunk/src/include/mtp_http.h

Go to the documentation of this file.
00001 /*[
00002  * Copyright (c) 2007 Integration Engineering Laboratory
00003                       University of California, Davis
00004  *
00005  * Permission to use, copy, and distribute this software and its
00006  * documentation for any purpose with or without fee is hereby granted,
00007  * provided that the above copyright notice appear in all copies and
00008  * that both that copyright notice and this permission notice appear
00009  * in supporting documentation.
00010  *
00011  * Permission to modify the software is granted, but not the right to
00012  * distribute the complete modified source code.  Modifications are to
00013  * be distributed as patches to the released version.  Permission to
00014  * distribute binaries produced by compiling modified sources is granted,
00015  * provided you
00016  *   1. distribute the corresponding source modifications from the
00017  *    released version in the form of a patch file along with the binaries,
00018  *   2. add special version identification to distinguish your version
00019  *    in addition to the base release version number,
00020  *   3. provide your name and address as the primary contact for the
00021  *    support of your modified version, and
00022  *   4. retain our contact information in regard to use of the base
00023  *    software.
00024  * Permission to distribute the released version of the source code along
00025  * with corresponding source modifications in the form of a patch file is
00026  * granted with same provisions 2 through 4 for binary distributions.
00027  *
00028  * This software is provided "as is" without express or implied warranty
00029  * to the extent permitted by applicable law.
00030 ]*/
00031 
00032 /* The MobileC http parser.
00033  *
00034  * We should probably switch to libwww someday, but not today. */
00035 
00036 #ifndef _MTP_HTTP_H_
00037 #define _MTP_HTTP_H_
00038 
00042 enum http_status_code_e
00043 {
00044   /*Informational*/
00045   CONTINUE=100,
00046   SWITCHING_PROTOCOLS,
00047   PROCESSING,
00048   /*Success*/
00049   OK=200,
00050   CREATED,
00051   ACCEPTED,
00052   NON_AUTHORITATIVE_INFORMATION,
00053   NO_CONTENT,
00054   RESET_CONTENT,
00055   PARTIAL_CONTENT,
00056   MULTI_STATUS,
00057   /*Error codes*/
00058   BAD_REQUEST=400,
00059   UNAUTHORIZED,
00060   PAYMENT_REQUIRED,
00061   FORBIDDEN,
00062   NOT_FOUND,
00063   METHOD_NOT_ALLOWED,
00064   NOT_ACCEPTABLE,
00065   PROXY_AUTHENTICATION_REQUIRED,
00066   REQUEST_TIMEOUT,
00067   CONFLICT,
00068   GONE,
00069   LENGTH_REQUIRED,
00070   PRECONDITION_FAILED,
00071   REQUST_ENTITY_TOO_LARGE,
00072   REQUEST_URI_TOO_LONG,
00073   UNSUPPORTED_MEDIA_TYPE,
00074   REQUESTED_RANGE_NOT_SATISFIABLE,
00075   EXPECTATION_FAILED,
00076   UNPROCESSABLE_ENTITY,
00077   LOCKED,
00078   FAILED_DEPENDANCY,
00079   UNORDERED_COLLECTION,
00080   UPGRADE_REQUIRED,
00081   RETRY_WITH
00082 };
00083 
00087 enum http_performative_e
00088 {
00089   HTTP_PERFORMATIVE_UNDEF=-1,
00090   HTTP_PERFORMATIVE_ZERO=0,
00091   HTTP_HEAD,
00092   HTTP_GET,
00093   HTTP_POST,
00094   HTTP_PUT,
00095   HTTP_DELETE,
00096   HTTP_TRACE,
00097   HTTP_OPTIONS,
00098   HTTP_CONNECT,
00099   HTTP_NUM_PERFORMATIVES
00100 };
00101 
00102 typedef struct mtp_http_content_s
00103 {
00104   char* content_type;
00105   void* data;
00106 } mtp_http_content_t;
00107 
00108 typedef struct mtp_http_s
00109 {
00110   enum http_status_code_e http_status_code;
00111   enum http_performative_e http_performative;
00112   char* http_version;
00113   char* host;
00114   char* return_code;
00115   char* target;       /*Target location for post/put/get etc */
00116 
00117   char* date;
00118   char* server;
00119   char* accept_ranges;
00120   char* content_length;
00121   char* connection;
00122   char* content_type;
00123   char* user_agent;
00124 
00125   char* cache_control;
00126   char* mime_version;
00127 
00128   /* The message may be a multi-part message */
00129   /* FIXME: We don't support nested multi-part messages for now */
00130   int message_parts;
00131   char* boundary;
00132   struct mtp_http_content_s* content;
00133 } mtp_http_t;
00134 typedef mtp_http_t* mtp_http_p;
00135 
00145 const char* http_GetExpression(const char* string, char** expr);
00146 
00160 int http_ParseExpression(
00161     const char* expression_string,
00162     char** name,
00163     char** value
00164     );
00165 
00166 const char* http_ParseHeader(
00167     mtp_http_p http,
00168     const char* string
00169     );
00170 
00171 const char*
00172 http_GetToken(const char* string, char** token);
00173 
00174 int
00175 mtp_http_Destroy(mtp_http_p http);
00176 
00177 struct connection_s;
00178 int
00179 mtp_http_InitializeFromConnection(struct mtp_http_s *http, struct connection_s *connection);
00180 
00181 mtp_http_p 
00182 mtp_http_New(void);
00183 
00184 struct connection;
00185 int 
00186 mtp_http_Parse(struct mtp_http_s* http, const char* string);
00187 
00188 struct message_s;
00189 int 
00190 mtp_http_ComposeMessage(struct message_s* message);
00191 
00192 struct message_s* 
00193 mtp_http_CreateMessage(
00194     mtp_http_t* mtp_http,
00195     char* hostname,
00196     int port );
00197 #endif

Generated on Fri May 16 14:49:54 2008 for Mobile-C by  doxygen 1.5.4