/home/dko/projects/mobilec/trunk/src/mtp_http.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "include/connection.h"
#include "include/mtp_http.h"
#include "include/macros.h"
#include "include/mc_error.h"
#include "include/message.h"
#include "include/dynstring.h"

Go to the source code of this file.

Defines

#define SOCKET_INPUT_SIZE   4096
#define SAFE_FREE(elem)
#define HTTP_PARSE_EXPR(parse_name, struct_name)
#define SAFE_FREE(object)

Functions

int mtp_http_Destroy (mtp_http_p http)
mtp_http_p mtp_http_New (void)
int mtp_http_InitializeFromConnection (mtp_http_p http, connection_p connection)
const char * http_GetExpression (const char *string, char **expr)
 Parse an html expression.
int http_ParseExpression (const char *expression_string, char **name, char **value)
 Parse an expression into its name and value.
int mtp_http_Parse (struct mtp_http_s *http, const char *string)
const char * http_ParseHeader (mtp_http_p http, const char *string)
const char * http_GetToken (const char *string, char **token)
int mtp_http_ComposeMessage (message_p message)
struct message_smtp_http_CreateMessage (mtp_http_t *mtp_http, char *hostname, int port)


Define Documentation

#define HTTP_PARSE_EXPR ( parse_name,
struct_name   ) 

Value:

if ( !strcmp(name, parse_name) ) { \
      http->struct_name = (char*)malloc \
      ( \
        sizeof(char) * \
        (strlen(value)+1) \
      ); \
      strcpy(http->struct_name, value); \
    } else

Referenced by mtp_http_Parse().

#define SAFE_FREE ( object   ) 

Value:

if(object) free(object); \
    object = NULL

#define SAFE_FREE ( elem   ) 

Value:

if(elem) \
    free(elem)

Referenced by mtp_http_Destroy(), and mtp_http_Parse().

#define SOCKET_INPUT_SIZE   4096

Definition at line 47 of file mtp_http.c.


Function Documentation

const char* http_GetExpression ( const char *  string,
char **  expr 
)

Parse an html expression.

Parameters:
string (input) The html block of text: Will parse the first expression pointed to by 'string'.
expr (output) The allocated expression
Returns:
A pointer to the next expression segment of the string block, or NULL.

Definition at line 187 of file mtp_http.c.

Referenced by mtp_http_Parse().

const char* http_GetToken ( const char *  string,
char **  token 
)

Definition at line 585 of file mtp_http.c.

Referenced by http_ParseHeader().

int http_ParseExpression ( const char *  expression_string,
char **  name,
char **  value 
)

Parse an expression into its name and value.

Parameters:
expression_string (input) The expression
name (output) An allocated name string or NULL
value (output) An allocated value string or NULL
Returns:
error_code_t type
Note:
an http expression is something like 'Date: Mon, 23 May 2005 22:38:34 GMT
' where 'Date' is the name and the remainder of the string is the value

Definition at line 246 of file mtp_http.c.

References CHECK_NULL, MC_ERR_PARSE, and MC_SUCCESS.

Referenced by mtp_http_Parse().

const char* http_ParseHeader ( mtp_http_p  http,
const char *  string 
)

Definition at line 513 of file mtp_http.c.

References HTTP_CONNECT, HTTP_DELETE, HTTP_GET, http_GetToken(), HTTP_HEAD, HTTP_OPTIONS, mtp_http_s::http_performative, HTTP_PERFORMATIVE_UNDEF, HTTP_POST, HTTP_PUT, HTTP_TRACE, and mtp_http_s::target.

Referenced by mtp_http_Parse().

int mtp_http_ComposeMessage ( message_p  message  ) 

Definition at line 619 of file mtp_http.c.

References message_s::isHTTP, MC_SUCCESS, message_s::message_body, PACKAGE_VERSION, message_s::target, and message_s::to_address.

struct message_s* mtp_http_CreateMessage ( mtp_http_t mtp_http,
char *  hostname,
int  port 
) [read]

Definition at line 665 of file mtp_http.c.

References mtp_http_s::content, mtp_http_content_s::content_type, mtp_http_content_s::data, dynstring_Append(), dynstring_Destroy(), dynstring_New(), mtp_http_s::host, message_s::isHTTP, dynstring_s::len, dynstring_s::message, message_s::message_body, message_New(), mtp_http_s::message_parts, PACKAGE_VERSION, mtp_http_s::target, and message_s::to_address.

Referenced by MC_AclSend().

int mtp_http_Destroy ( mtp_http_p  http  ) 

Definition at line 49 of file mtp_http.c.

References mtp_http_s::accept_ranges, mtp_http_s::boundary, mtp_http_s::connection, mtp_http_s::content, mtp_http_s::content_length, mtp_http_content_s::content_type, mtp_http_s::content_type, mtp_http_content_s::data, mtp_http_s::date, mtp_http_s::host, mtp_http_s::http_version, mtp_http_s::message_parts, mtp_http_s::return_code, SAFE_FREE, mtp_http_s::server, mtp_http_s::target, and mtp_http_s::user_agent.

Referenced by acc_Thread(), and MC_AclSend().

int mtp_http_InitializeFromConnection ( mtp_http_p  http,
connection_p  connection 
)

Definition at line 93 of file mtp_http.c.

References CHECK_NULL, connection_s::clientfd, ERR, MC_ERR_CONNECT, mtp_http_Parse(), send, and SOCKET_INPUT_SIZE.

mtp_http_p mtp_http_New ( void   ) 

Definition at line 81 of file mtp_http.c.

References CHECK_NULL, and mtp_http_s::content.

Referenced by acc_Thread(), and MC_AclSend().

int mtp_http_Parse ( struct mtp_http_s http,
const char *  string 
)

Definition at line 306 of file mtp_http.c.

References mtp_http_s::boundary, mtp_http_s::content, mtp_http_content_s::content_type, mtp_http_s::content_type, mtp_http_content_s::data, http_GetExpression(), HTTP_PARSE_EXPR, http_ParseExpression(), http_ParseHeader(), mtp_http_s::http_performative, HTTP_POST, HTTP_PUT, MC_SUCCESS, mtp_http_s::message_parts, and SAFE_FREE.

Referenced by mtp_http_InitializeFromConnection().


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