/home/dko/projects/mobilec/tags/MobileC-v1.10.2/MobileC-v1.10.2/src/include/mtp_http.h

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

Generated on Fri Jul 11 17:59:45 2008 for Mobile-C by  doxygen 1.5.4