update http/https stack

add support for chunk transfer
update documentation
add support for generic options
This commit is contained in:
bossiel 2010-04-06 16:28:35 +00:00
parent ea4843ba06
commit 8706c2df80
77 changed files with 2108 additions and 669 deletions

View File

@ -51,19 +51,20 @@
* THTTP_STACK_SET_LOCAL_IP("192.168.0.15"),
* THTTP_STACK_SET_NULL());
* @endcode
* @sa @ref THTTP_STACK_SET_LOCAL_PORT, @ref thttp_stack_create, @ref thttp_stack_set.
*
* @sa @ref THTTP_STACK_SET_LOCAL_PORT<br>@ref thttp_stack_create<br>@ref thttp_stack_set
*/
/**@def THTTP_STACK_SET_LOCAL_PORT(PORT_INT)
* Sets local Port to bind to. By default, the stack will bind to a random port.
* This is a helper macro for @ref thttp_stack_create and @ref thttp_stack_set.
* @param PORT_INT The Port (int32_t).
*
* @code
* thttp_stack_create(callback,
* THTTP_STACK_SET_LOCAL_PORT(1234),
* THTTP_STACK_SET_NULL());
* @endcode
* @sa @ref THTTP_STACK_SET_LOCAL_IP, @ref thttp_stack_create, @ref thttp_stack_set.
* @sa @ref THTTP_STACK_SET_LOCAL_IP<br>@ref thttp_stack_create<br>@ref thttp_stack_set
*/
/**@def THTTP_STACK_SET_TLS_CERTS(CA_FILE_STR, PUB_FILE_STR, PRIV_FILE_STR)
@ -72,6 +73,7 @@
* @param CA_FILE_STR Path to the Certification Authority File.
* @param PUB_FILE_STR Path to the Public key file.
* @param PRIV_FILE_STR Path to the Private key file.
*
* @code
* thttp_stack_create(callback,
* THTTP_STACK_SET_TLS_CERTS("C:\\tls\\ca.pki-crt.pem", "C:\\tls\\pub-crt.pem", "C:\\tls\\pub-key.pem"),

View File

@ -65,6 +65,7 @@ typedef enum thttp_header_type_e
thttp_htype_Dummy,
thttp_htype_Proxy_Authenticate,
thttp_htype_Proxy_Authorization,
thttp_htype_Transfer_Encoding,
thttp_htype_WWW_Authenticate,
}
thttp_header_type_t;

View File

@ -69,7 +69,7 @@ thttp_header_Content_Type_t;
thttp_header_Content_Type_t *thttp_header_Content_Type_parse(const char *data, size_t size);
TINYHTTP_GEXTERN const void *thttp_header_Content_Type_def_t;
TINYHTTP_GEXTERN const tsk_object_def_t *thttp_header_Content_Type_def_t;
THTTP_END_DECLS

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
/**@file thttp_header_Transfer_Encoding.h
* @brief HTTP header 'Transfer-Encoding'.
*
* @author Mamadou Diop <diopmamadou(at)doubango.org>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _THTTP_HEADER_TRANSFER_ENCODING_H_
#define _THTTP_HEADER_TRANSFER_ENCODING_H_
#include "tinyHTTP_config.h"
#include "tinyHTTP/headers/thttp_header.h"
THTTP_BEGIN_DECLS
#define THTTP_HEADER_TRANSFER_ENCODING_VA_ARGS(encoding) thttp_header_Transfer_Encoding_def_t, (const char*)encoding
#define THTTP_HEADER_TRANSFER_ENCODING_CREATE(encoding) tsk_object_new(THTTP_HEADER_TRANSFER_ENCODING_VA_ARGS(encoding))
#define THTTP_HEADER_TRANSFER_ENCODING_CREATE_NULL() THTTP_HEADER_TRANSFER_ENCODING_CREATE(tsk_null)
////////////////////////////////////////////////////////////////////////////////////////////////////
/// HTTP header 'Transfer-Encoding'.
///
/// @par ABNF= Transfer-Encoding = "Transfer-Encoding" ":" transfer-coding *(COMMA transfer-coding)
///
/// transfer-coding = "chunked" / transfer-extension
/// transfer-extension = token *( ";" parameter )
/// parameter = attribute "=" value
/// attribute = token
/// value = token / quoted-string
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct thttp_header_Transfer_Encoding_s
{
THTTP_DECLARE_HEADER;
char* encoding;
}
thttp_header_Transfer_Encoding_t;
thttp_header_Transfer_Encoding_t *thttp_header_Transfer_Encoding_parse(const char *data, size_t size);
TINYHTTP_GEXTERN const tsk_object_def_t *thttp_header_Transfer_Encoding_def_t;
THTTP_END_DECLS
#endif /* _THTTP_HEADER_TRANSFER_ENCODING_H_ */

View File

@ -37,15 +37,28 @@
#include "tsk_buffer.h"
#include "tsk_list.h"
#include "tsk_params.h"
#include "tsk_options.h"
THTTP_BEGIN_DECLS
#define THTTP_ACTION_CREATE(type, url, method, app) tsk_object_new(thttp_action_def_t, (thttp_action_type_t)type, (const char*)url, (const char*)method, (va_list*)app)
#define THTTP_ACTION_CREATE(type, urlstring, method, app) tsk_object_new(thttp_action_def_t, (thttp_action_type_t)type, (const char*)urlstring, (const char*)method, (va_list*)app)
typedef uint64_t thttp_action_id_t;
#define THTTP_ACTION_INVALID_ID 0
#define THTTP_ACTION_INVALID_HANDLE tsk_null
/** List of all supported options.
* To pass an option to the sesion, use @ref THTTP_ACTION_SET_OPTION() macro.
*/
typedef enum thhtp_action_option_e
{
THTTP_ACTION_OPTION_TIMEOUT,
}
thhtp_action_option_t;
/** List of actions.
*/
typedef enum thttp_action_type_e
{
/* Outgoing GET, PUT, HEAD, DELETE, .... */
@ -65,13 +78,63 @@ typedef enum thttp_action_param_type_e
{
aptype_null = tsk_null,
aptype_param,
aptype_option,
aptype_header,
aptype_payload,
}
thttp_action_param_type_t;
#define THTTP_ACTION_SET_PARAM(NAME_STR, VALUE_STR) aptype_param, (const char*)NAME_STR, (const char*)VALUE_STR
/**@ingroup thttp_action_group
* @def THTTP_ACTION_SET_OPTION
* Adds or updates an option.
* This is a helper macro for @a thttp_action_*() functions.
* @param ID_INT The id of the option to add/update (@ref thhtp_action_option_t).
* @param VALUE_STR The new value of the parameter (<i>const char*</i>).
*
* @code
thttp_action_GET(session, "http://www.google.com",
THTTP_ACTION_SET_PARAM("timeout", "6000"),
THTTP_ACTION_SET_NULL());
* @endcode
*/
/**@ingroup thttp_action_group
* @def THTTP_ACTION_SET_HEADER
* Adds new HTTP headers to the request.
* This is a helper macro for @a thttp_action_*() functions.
* @param NAME_STR The name of the header (<i>const char*</i>).
* @param VALUE_STR The value of the header (<i>const char*</i>). Should not contains the trailing CRLF.
*
* @code
thttp_action_GET(session, "http://www.doubango.org"
THTTP_ACTION_SET_HEADER("Pragma", "No-Cache"),
THTTP_ACTION_SET_HEADER("Connection", "Keep-Alive"),
THTTP_ACTION_SET_NULL());
* @endcode
*/
/**@ingroup thttp_action_group
* @def THTTP_ACTION_SET_PAYLOAD
* Adds a content (or payload) to the request. You should also add a content-type header by using
* @ref THTTP_ACTION_SET_HEADER() macro. You should not add the content-length header.
* This is a helper macro for @a thttp_action_*() functions.
* @param PAY_PTR A pointer to the payload (<i>const void*</i>).
* @param PAY_SIZE The size of the payload (<i>size_t</i>).
*
* @code
thttp_action_PUT(session, "http://www.doubango.org"
THTTP_ACTION_SET_HEADER("Pragma", "No-Cache"),
THTTP_ACTION_SET_HEADER("Connection", "Keep-Alive"),
THTTP_ACTION_SET_HEADER("Content-length", "application/mytype"),
THTTP_ACTION_SET_PAYLOAD("Salut", 5),
THTTP_ACTION_SET_NULL());
* @endcode
*/
/**@ingroup thttp_action_group
* @def THTTP_ACTION_SET_NULL
* Ends action parameters. Must always be the last one.
*/
#define THTTP_ACTION_SET_OPTION(ID_INT, VALUE_STR) aptype_option, (thhtp_action_option_t)ID_INT, (const char*)VALUE_STR
#define THTTP_ACTION_SET_HEADER(NAME_STR, VALUE_STR) aptype_header, (const char*)NAME_STR, (const char*)VALUE_STR
#define THTTP_ACTION_SET_PAYLOAD(PAY_PTR, PAY_SIZE) aptype_payload, (const void*)PAY_PTR, (size_t)PAY_SIZE
#define THTTP_ACTION_SET_NULL() aptype_null
@ -84,7 +147,7 @@ typedef struct thttp_action_s
const char* url;
const char* method;
tsk_params_L_t *params;
tsk_options_L_t *options;
tsk_params_L_t *headers;
tsk_buffer_t* payload;
}
@ -92,16 +155,90 @@ thttp_action_t;
typedef void thttp_action_handle_t;
TINYHTTP_API int thttp_action_perform(thttp_session_handle_t *session, const char* url, const char* method, ...);
#define thttp_action_CONNECT(session, url, ...) thttp_action_perform((thttp_session_handle_t *)session, url, "CONNECT", __VA_ARGS__)
#define thttp_action_DELETE(session, url, ...) thttp_action_perform((thttp_session_handle_t *)session, url, "DELETE", __VA_ARGS__)
#define thttp_action_GET(session, url, ...) thttp_action_perform((thttp_session_handle_t *)session, url, "GET", __VA_ARGS__)
#define thttp_action_HEAD(session, url, ...) thttp_action_perform((thttp_session_handle_t *)session, url, "HEAD", __VA_ARGS__)
#define thttp_action_OPTIONS(session, url, ...) thttp_action_perform((thttp_session_handle_t *)session, url, "OPTIONS", __VA_ARGS__)
#define thttp_action_PATCH(session, url, ...) thttp_action_perform((thttp_session_handle_t *)session, url, "PATCH", __VA_ARGS__)
#define thttp_action_POST(session, url, ...) thttp_action_perform((thttp_session_handle_t *)session, url, "POST", __VA_ARGS__)
#define thttp_action_PUT(session, url, ...) thttp_action_perform((thttp_session_handle_t *)session, url, "PUT", __VA_ARGS__)
#define thttp_action_TRACE(session, url, ...) thttp_action_perform((thttp_session_handle_t *)session, url, "TRACE", __VA_ARGS__)
/**@ingroup thttp_action_group
* @def thttp_action_CONNECT
* Sends @a CONNECT method request. This function is non-blocking and the result will be posted to the callback function.
* @param session The @a session (or connection) to use.
* @param urlstring The Request-URI of the request.
* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
* @retval Zero if succeed and non-zero error code otherwise.
*/
/**@ingroup thttp_action_group
* @def thttp_action_DELETE
* Sends @a DELETE method request. This function is non-blocking and the result will be posted to the callback function.
* @param session The @a session (or connection) to use.
* @param urlstring The Request-URI of the request.
* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
* @retval Zero if succeed and non-zero error code otherwise.
*/
/**@ingroup thttp_action_group
* @def thttp_action_GET
* Sends @a GET method request. This function is non-blocking and the result will be posted to the callback function.
* @param session The @a session (or connection) to use.
* @param urlstring The Request-URI of the request.
* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
* @retval Zero if succeed and non-zero error code otherwise.
*/
/**@ingroup thttp_action_group
* @def thttp_action_HEAD
* Sends @a HEAD method request. This function is non-blocking and the result will be posted to the callback function.
* @param session The @a session (or connection) to use.
* @param urlstring The Request-URI of the request.
* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
* @retval Zero if succeed and non-zero error code otherwise.
*/
/**@ingroup thttp_action_group
* @def thttp_action_OPTIONS
* Sends @a OPTIONS method request. This function is non-blocking and the result will be posted to the callback function.
* @param session The @a session (or connection) to use.
* @param urlstring The Request-URI of the request.
* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
* @retval Zero if succeed and non-zero error code otherwise.
*/
/**@ingroup thttp_action_group
* @def thttp_action_PATCH
* Sends @a PATCH method request. This function is non-blocking and the result will be posted to the callback function.
* @param session The @a session (or connection) to use.
* @param urlstring The Request-URI of the request.
* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
* @retval Zero if succeed and non-zero error code otherwise.
*/
/**@ingroup thttp_action_group
* @def thttp_action_POST
* Sends @a POST method request. This function is non-blocking and the result will be posted to the callback function.
* @param session The @a session (or connection) to use.
* @param urlstring The Request-URI of the request.
* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
* @retval Zero if succeed and non-zero error code otherwise.
*/
/**@ingroup thttp_action_group
* @def thttp_action_PUT
* Sends @a PUT method request. This function is non-blocking and the result will be posted to the callback function.
* @param session The @a session (or connection) to use.
* @param urlstring The Request-URI of the request.
* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
* @retval Zero if succeed and non-zero error code otherwise.
*/
/**@ingroup thttp_action_group
* @def thttp_action_TRACE
* Sends @a TRACE method request. This function is non-blocking and the result will be posted to the callback function.
* @param session The @a session (or connection) to use.
* @param urlstring The Request-URI of the request.
* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
* @retval Zero if succeed and non-zero error code otherwise.
*/
TINYHTTP_API int thttp_action_perform(thttp_session_handle_t *session, const char* urlstring, const char* method, ...);
#define thttp_action_CONNECT(session, urlstring, ...) thttp_action_perform(session, urlstring, "CONNECT", __VA_ARGS__)
#define thttp_action_DELETE(session, urlstring, ...) thttp_action_perform(session, urlstring, "DELETE", __VA_ARGS__)
#define thttp_action_GET(session, urlstring, ...) thttp_action_perform(session, urlstring, "GET", __VA_ARGS__)
#define thttp_action_HEAD(session, urlstring, ...) thttp_action_perform(session, urlstring, "HEAD", __VA_ARGS__)
#define thttp_action_OPTIONS(session, urlstring, ...) thttp_action_perform(session, urlstring, "OPTIONS", __VA_ARGS__)
#define thttp_action_PATCH(session, urlstring, ...) thttp_action_perform(session, urlstring, "PATCH", __VA_ARGS__)
#define thttp_action_POST(session, urlstring, ...) thttp_action_perform(session, urlstring, "POST", __VA_ARGS__)
#define thttp_action_PUT(session, urlstring, ...) thttp_action_perform(session, urlstring, "PUT", __VA_ARGS__)
#define thttp_action_TRACE(session, urlstring, ...) thttp_action_perform(session, urlstring, "TRACE", __VA_ARGS__)
typedef tsk_list_t thttp_actions_L_t; /**< List of @ref thttp_action_handle_t elements. */
TINYHTTP_GEXTERN const tsk_object_def_t *thttp_action_def_t;

View File

@ -62,9 +62,8 @@ thttp_dialog_t;
typedef tsk_list_t thttp_dialogs_L_t;
int thttp_dialog_fsm_act(thttp_dialog_t* self, tsk_fsm_action_id , const struct thttp_message_s* , const struct thttp_action_s*);
//thttp_dialog_t* thttp_dialog_get_by_session(thttp_dialogs_L_t* dialogs, const struct thttp_session_s* session);
thttp_dialog_t* thttp_dialog_new(struct thttp_session_s* session);
thttp_dialog_t* thttp_dialog_get_by_age(thttp_dialogs_L_t* dialogs);
thttp_dialog_t* thttp_dialog_get_oldest(thttp_dialogs_L_t* dialogs);
TINYHTTP_GEXTERN const tsk_object_def_t *thttp_dialog_def_t;

View File

@ -43,7 +43,6 @@
//#include "tinyHTTP/headers/thttp_header_Expires.h"
//#include "tinyHTTP/headers/thttp_header_From.h"
//#include "tinyHTTP/headers/thttp_header_P_Access_Network_Info.h"
//#include "tinyHTTP/headers/thttp_header_To.h"
//#include "tinyHTTP/headers/thttp_header_Via.h"
#include "tsk_object.h"
@ -112,7 +111,7 @@ THTTP_BEGIN_DECLS
* @def THTTP_MESSAGE_CREATE
* Creates new HTTP message. Could be either a request or a response.
* @retval @ref thttp_message_t object.
* @sa @ref THTTP_REQUEST_CREATE, @ref THTTP_RESPONSE_CREATE.
* @sa @ref THTTP_REQUEST_CREATE<br>@ref THTTP_RESPONSE_CREATE
*/
/**@ingroup thttp_message_group
*@def THTTP_REQUEST_CREATE
@ -120,6 +119,7 @@ THTTP_BEGIN_DECLS
* @param method The method (const char*). e.g. GET, POST, HEAD ...
* @param url The url (@ref thttp_url_t).
* @retval @ref thttp_request_t object.
*
* @code
// example
thttp_url_t* url;
@ -139,6 +139,7 @@ if((url = thttp_url_parse("http://www.google.com", strlen("http://www.google.com
* @param status_code The status code (short).
* @param reason_phrase The reason phrase (const char*).
* @retval @ref thttp_response_t object.
*
* @code
// example
//thttp_request_t* request;
@ -274,6 +275,7 @@ typedef thttp_message_t thttp_response_t; /**< HTTP response message. */
TINYHTTP_API int thttp_message_add_header(thttp_message_t *self, const thttp_header_t *hdr);
TINYHTTP_API int thttp_message_add_headers(thttp_message_t *self, const thttp_headers_L_t *headers);
TINYHTTP_API int thttp_message_add_content(thttp_message_t *self, const char* content_type, const void* content, size_t size);
TINYHTTP_API int thttp_message_append_content(thttp_message_t *self, const void* content, size_t size);
#if !defined(_MSC_VER) || defined(__GNUC__)
static void THTTP_MESSAGE_ADD_HEADER(thttp_message_t *self, ...)

View File

@ -42,6 +42,7 @@
#include "tsk_object.h"
#include "tsk_list.h"
#include "tsk_params.h"
#include "tsk_options.h"
THTTP_BEGIN_DECLS
@ -52,11 +53,21 @@ typedef uint64_t thttp_session_id_t;
#define THTTP_SESSION_INVALID_ID 0
#define THTTP_SESSION_INVALID_HANDLE tsk_null
/** List of all supported options.
* To pass an option to the sesion, use @ref THTTP_SESSION_SET_OPTION() macro.
*/
typedef enum thhtp_session_option_e
{
THTTP_SESSION_OPTION_TIMEOUT,
}
thhtp_session_option_t;
typedef enum thttp_session_param_type_e
{
sptype_null = tsk_null,
sptype_param,
sptype_option,
sptype_cred,
sptype_header,
sptype_context,
@ -64,15 +75,16 @@ typedef enum thttp_session_param_type_e
thttp_session_param_type_t;
/**@ingroup thttp_session_group
* @def THTTP_SESSION_SET_PARAM
* Adds or updates a parameter.
* @def THTTP_SESSION_SET_OPTION
* Adds or updates an option.
* This is a helper macro for @ref thttp_session_create and @ref thttp_session_set.
* @param NAME_STR The name of the parameter to add/update (const char*).
* @param VALUE_STR The new value of the parameter (const char*).
* @param ID_INT The id of the option to add/update (@ref thhtp_session_option_t).
* @param VALUE_STR The new value of the parameter (<i>const char*</i>).
*
* @code
// session = thttp_session_create(stack,
thttp_session_set(session,
THTTP_SESSION_SET_PARAM("timeout", "6000"),
THTTP_SESSION_SET_PARAM(THTTP_SESSION_OPTION_TIMEOUT, "6000"),
THTTP_SESSION_SET_NULL());
* @endcode
*/
@ -82,10 +94,11 @@ thttp_session_set(session,
* This is a helper macro for @ref thttp_session_create and @ref thttp_session_set.
* @param USERNAME_STR The username (const char*).
* @param PASSWORD_STR The password(const char*).
*
* @code
// session = thttp_session_create(stack,
thttp_session_set(session,
THTTP_SESSION_SET_CRED("sip:bob@example.com", "mysecret"),
THTTP_SESSION_SET_CRED("ali baba", "open sesame"),
THTTP_SESSION_SET_NULL());
* @endcode
*/
@ -93,8 +106,9 @@ thttp_session_set(session,
* @def THTTP_SESSION_SET_HEADER
* Adds new HTTP headers to the session.
* This is a helper macro for @ref thttp_session_create and @ref thttp_session_set.
* @param NAME_STR The name of the header (const char*).
* @param VALUE_STR The value of the header (const char*).
* @param NAME_STR The name of the header (<i>const char*</i>).
* @param VALUE_STR The value of the header (<i>const char*</i>). Should not contains the trailing CRLF.
*
* @code
// session = thttp_session_create(stack,
thttp_session_set(session,
@ -108,6 +122,7 @@ thttp_session_set(session,
* Sets user data (context). Will be return to the application layer each time the callback function is called.
* This is a helper macro for @ref thttp_session_create and @ref thttp_session_set.
* @param CTX_PTR A pointer to the data(const void*).
*
* @code
// session = thttp_session_create(stack,
thttp_session_set(session,
@ -119,7 +134,7 @@ thttp_session_set(session,
* @def THTTP_SESSION_SET_NULL
* Ends session parameters. Must always be the last one.
*/
#define THTTP_SESSION_SET_PARAM(NAME_STR, VALUE_STR) sptype_param, (const char*)NAME_STR, (const char*)VALUE_STR
#define THTTP_SESSION_SET_OPTION(ID_INT, VALUE_STR) sptype_option, (thhtp_session_option_t)ID_INT, (const char*)VALUE_STR
#define THTTP_SESSION_SET_CRED(USERNAME_STR, PASSWORD_STR) sptype_cred, (const char*)USERNAME_STR, (const char*)PASSWORD_STR
#define THTTP_SESSION_SET_HEADER(NAME_STR, VALUE_STR) sptype_header, (const char*)NAME_STR, (const char*)VALUE_STR
#define THTTP_SESSION_SET_CONTEXT(CTX_PTR) sptype_context, (const void*)CTX_PTR
@ -132,7 +147,7 @@ typedef struct thttp_session_s
thttp_session_id_t id;
const struct thttp_stack_s* stack;
const void* context; // usr context
tsk_params_L_t *params;
tsk_options_L_t *options;
tsk_params_L_t *headers;
tnet_fd_t fd;
@ -144,6 +159,8 @@ typedef struct thttp_session_s
char* usename;
char* password;
}cred;
TSK_DECLARE_SAFEOBJ;
}
thttp_session_t;

View File

@ -27,6 +27,13 @@
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "thttp.h"
#include "tinyHTTP/thttp_action.h"
#include "tinyHTTP/parsers/thttp_parser_message.h"
#include "tinyHTTP/parsers/thttp_parser_url.h"
#include "tinyHTTP/parsers/thttp_parser_header.h"
#include "tnet.h"
#include "tsk.h"

View File

@ -5,28 +5,31 @@ export OPTIONS="-C -L -T0"
#export OPTIONS="-C -L -G2"
# HTTP/HTTPS URL parser
ragel.exe $OPTIONS -o ../src/parsers/thttp_parser_url.c thttp_parser_url.rl
ragel.exe $OPTIONS -o ./src/parsers/thttp_parser_url.c ./ragel/thttp_parser_url.rl
# HTTP message (both requests an responses) parser.
ragel.exe $OPTIONS -o ../src/parsers/thttp_parser_message.c thttp_parser_message.rl
ragel.exe $OPTIONS -o ./src/parsers/thttp_parser_message.c ./ragel/thttp_parser_message.rl
# HTTP headers parser
ragel.exe $OPTIONS -o ../src/parsers/thttp_parser_header.c thttp_parser_header.rl
ragel.exe $OPTIONS -o ./src/parsers/thttp_parser_header.c ./ragel/thttp_parser_header.rl
# ==Authorization
ragel.exe $OPTIONS -o ../src/headers/thttp_header_Authorization.c thttp_parser_header_Authorization.rl
ragel.exe $OPTIONS -o ./src/headers/thttp_header_Authorization.c ./ragel/thttp_parser_header_Authorization.rl
# ==Content-Length
ragel.exe $OPTIONS -o ../src/headers/thttp_header_Content_Length.c thttp_parser_header_Content_Length.rl
ragel.exe $OPTIONS -o ./src/headers/thttp_header_Content_Length.c ./ragel/thttp_parser_header_Content_Length.rl
# ==Dummy
ragel.exe $OPTIONS -o ../src/headers/thttp_header_Dummy.c thttp_parser_header_Dummy.rl
ragel.exe $OPTIONS -o ./src/headers/thttp_header_Dummy.c ./ragel/thttp_parser_header_Dummy.rl
# ==Content-Type
ragel.exe $OPTIONS -o ../src/headers/thttp_header_Content_Type.c thttp_parser_header_Content_Type.rl
ragel.exe $OPTIONS -o ./src/headers/thttp_header_Content_Type.c ./ragel/thttp_parser_header_Content_Type.rl
# == Transfer-Encoding
ragel.exe $OPTIONS -o ./src/headers/thttp_header_Transfer_Encoding.c ./ragel/thttp_parser_header_Transfer_Encoding.rl
# ==WWW-Authenticate
ragel.exe $OPTIONS -o ../src/headers/thttp_header_WWW_Authenticate.c thttp_parser_header_WWW_Authenticate.rl
ragel.exe $OPTIONS -o ./src/headers/thttp_header_WWW_Authenticate.c ./ragel/thttp_parser_header_WWW_Authenticate.rl

View File

@ -51,7 +51,7 @@
//#include "tinyHTTP/headers/thttp_header_Route.h"
//#include "tinyHTTP/headers/thttp_header_Service_Route.h"
//#include "tinyHTTP/headers/thttp_header_Supported.h"
//#include "tinyHTTP/headers/thttp_header_To.h"
#include "tinyHTTP/headers/thttp_header_Transfer_Encoding.h"
//#include "tinyHTTP/headers/thttp_header_User_Agent.h"
//#include "tinyHTTP/headers/thttp_header_Via.h"
#include "tinyHTTP/headers/thttp_header_WWW_Authenticate.h"
@ -374,16 +374,7 @@
ADD_HEADER(header);
//TSK_DEBUG_WARN("parse_header_Referer NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Transfer_Encoding: ==*/
action parse_header_Transfer_Encoding
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
//TSK_DEBUG_WARN("parse_header_Transfer_Encoding NOT IMPLEMENTED. Will be added as Dummy header.");
}
}
# /*== TE: ==*/
action parse_header_TE
@ -403,6 +394,15 @@
//TSK_DEBUG_WARN("parse_header_Trailer NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Transfer_Encoding: ==*/
action parse_header_Transfer_Encoding
{
thttp_header_Transfer_Encoding_t *header = thttp_header_Transfer_Encoding_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
//TSK_DEBUG_WARN("parse_header_Trailer NOT IMPLEMENTED. Will be added as Dummy header.");
}
# /*== Upgrade: ==*/
action parse_header_Upgrade
{
@ -457,8 +457,8 @@
# Includes
include thttp_machine_utils "./thttp_machine_utils.rl";
include thttp_machine_header "./thttp_machine_header.rl";
include thttp_machine_utils "./ragel/thttp_machine_utils.rl";
include thttp_machine_header "./ragel/thttp_machine_header.rl";
# Entry point
main := HEADER;

View File

@ -44,7 +44,7 @@
machine thttp_machine_parser_header_Authorization;
# Includes
include thttp_machine_utils "./thttp_machine_utils.rl";
include thttp_machine_utils "./ragel/thttp_machine_utils.rl";
action tag
{
@ -228,8 +228,8 @@ thttp_header_Authorization_t *thttp_header_Authorization_parse(const char *data,
%%write init;
%%write exec;
if( cs < %%{ write first_final; }%% )
{
if( cs < %%{ write first_final; }%% ){
TSK_DEBUG_ERROR("Failed to parse Authorization header.");
TSK_OBJECT_SAFE_FREE(hdr_Authorization);
}

View File

@ -39,7 +39,7 @@
machine thttp_machine_parser_header_Content_Length;
# Includes
include thttp_machine_utils "./thttp_machine_utils.rl";
include thttp_machine_utils "./ragel/thttp_machine_utils.rl";
action tag
{

View File

@ -41,25 +41,21 @@
machine thttp_machine_parser_header_Content_Type;
# Includes
include thttp_machine_utils "./thttp_machine_utils.rl";
include thttp_machine_utils "./ragel/thttp_machine_utils.rl";
action tag
{
action tag{
tag_start = p;
}
action parse_content_type
{
action parse_content_type{
TSK_PARSER_SET_STRING(hdr_ctype->type);
}
action parse_param
{
action parse_param{
TSK_PARSER_ADD_PARAM(THTTP_HEADER_PARAMS(hdr_ctype));
}
action eob
{
action eob{
}
extension_token = ietf_token | x_token;
@ -84,8 +80,7 @@
int thttp_header_Content_Type_tostring(const void* header, tsk_buffer_t* output)
{
if(header)
{
if(header){
const thttp_header_Content_Type_t *Content_Type = header;
return tsk_buffer_append(output, Content_Type->type, strlen(Content_Type->type));
}
@ -109,8 +104,8 @@ thttp_header_Content_Type_t *thttp_header_Content_Type_parse(const char *data, s
%%write init;
%%write exec;
if( cs < %%{ write first_final; }%% )
{
if( cs < %%{ write first_final; }%% ){
TSK_DEBUG_ERROR("Failed to parse Content-Type header.");
TSK_OBJECT_SAFE_FREE(hdr_ctype);
}
@ -129,18 +124,16 @@ thttp_header_Content_Type_t *thttp_header_Content_Type_parse(const char *data, s
/**@ingroup thttp_header_Content_Type_group
*/
static void* thttp_header_Content_Type_create(void *self, va_list * app)
static tsk_object_t* thttp_header_Content_Type_create(tsk_object_t *self, va_list * app)
{
thttp_header_Content_Type_t *Content_Type = self;
if(Content_Type)
{
if(Content_Type){
THTTP_HEADER(Content_Type)->type = thttp_htype_Content_Type;
THTTP_HEADER(Content_Type)->tostring = thttp_header_Content_Type_tostring;
Content_Type->type = tsk_strdup( va_arg(*app, const char*) );
}
else
{
else{
TSK_DEBUG_ERROR("Failed to create new Content_Type header.");
}
return self;
@ -148,15 +141,16 @@ static void* thttp_header_Content_Type_create(void *self, va_list * app)
/**@ingroup thttp_header_Content_Type_group
*/
static void* thttp_header_Content_Type_destroy(void *self)
static tsk_object_t* thttp_header_Content_Type_destroy(tsk_object_t *self)
{
thttp_header_Content_Type_t *Content_Type = self;
if(Content_Type)
{
if(Content_Type){
TSK_FREE(Content_Type->type);
TSK_OBJECT_SAFE_FREE(THTTP_HEADER_PARAMS(Content_Type));
}
else TSK_DEBUG_ERROR("Null Content_Type header.");
else{
TSK_DEBUG_ERROR("Null Content_Type header.");
}
return self;
}
@ -166,6 +160,6 @@ static const tsk_object_def_t thttp_header_Content_Type_def_s =
sizeof(thttp_header_Content_Type_t),
thttp_header_Content_Type_create,
thttp_header_Content_Type_destroy,
0
tsk_null
};
const void *thttp_header_Content_Type_def_t = &thttp_header_Content_Type_def_s;
const tsk_object_def_t *thttp_header_Content_Type_def_t = &thttp_header_Content_Type_def_s;

View File

@ -43,7 +43,7 @@
machine thttp_machine_parser_header_Dummy;
# Includes
include thttp_machine_utils "./thttp_machine_utils.rl";
include thttp_machine_utils "./ragel/thttp_machine_utils.rl";
action tag
{

View File

@ -0,0 +1,152 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
/**@file thttp_header_Transfer_Encoding.c
* @brief HTTP Transfer-Encoding header.
*
* @author Mamadou Diop <diopmamadou(at)doubango.org>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tinyHTTP/headers/thttp_header_Transfer_Encoding.h"
#include "tsk_debug.h"
#include "tsk_memory.h"
#include <string.h>
/***********************************
* Ragel state machine.
*/
%%{
machine thttp_machine_parser_header_Transfer_Encoding;
# Includes
include thttp_machine_utils "./ragel/thttp_machine_utils.rl";
action tag{
tag_start = p;
}
action parse_encoding{
TSK_PARSER_SET_STRING(hdr_tencoding->encoding);
}
action parse_param{
TSK_PARSER_ADD_PARAM(THTTP_HEADER_PARAMS(hdr_tencoding));
}
action eob{
}
Transfer_Encoding = ( "Transfer-Encoding"i ) HCOLON token>tag %parse_encoding :>( ";" (pname("=" pvalue )?)>tag %parse_param )*;
# Entry point
main := Transfer_Encoding :>CRLF @eob;
}%%
int thttp_header_Transfer_Encoding_tostring(const void* header, tsk_buffer_t* output)
{
if(header){
const thttp_header_Transfer_Encoding_t *Transfer_Encoding = header;
return tsk_buffer_append(output, Transfer_Encoding->encoding, strlen(Transfer_Encoding->encoding));
}
return -1;
}
/**@ingroup thttp_header_group
*/
thttp_header_Transfer_Encoding_t *thttp_header_Transfer_Encoding_parse(const char *data, size_t size)
{
int cs = 0;
const char *p = data;
const char *pe = p + size;
const char *eof = pe;
thttp_header_Transfer_Encoding_t *hdr_tencoding = THTTP_HEADER_TRANSFER_ENCODING_CREATE_NULL();
const char *tag_start;
%%write data;
%%write init;
%%write exec;
if( cs < %%{ write first_final; }%% ){
TSK_DEBUG_ERROR("Failed to parse Tansfer-Encoding header.");
TSK_OBJECT_SAFE_FREE(hdr_tencoding);
}
return hdr_tencoding;
}
//========================================================
// Transfer_Encoding header object definition
//
/**@ingroup thttp_header_Transfer_Encoding_group
*/
static tsk_object_t* thttp_header_Transfer_Encoding_create(tsk_object_t *self, va_list * app)
{
thttp_header_Transfer_Encoding_t *Transfer_Encoding = self;
if(Transfer_Encoding){
THTTP_HEADER(Transfer_Encoding)->type = thttp_htype_Transfer_Encoding;
THTTP_HEADER(Transfer_Encoding)->tostring = thttp_header_Transfer_Encoding_tostring;
Transfer_Encoding->encoding = tsk_strdup( va_arg(*app, const char*) );
}
else{
TSK_DEBUG_ERROR("Failed to create new Transfer_Encoding header.");
}
return self;
}
/**@ingroup thttp_header_Transfer_Encoding_group
*/
static tsk_object_t* thttp_header_Transfer_Encoding_destroy(tsk_object_t* self)
{
thttp_header_Transfer_Encoding_t *Transfer_Encoding = self;
if(Transfer_Encoding){
TSK_FREE(Transfer_Encoding->encoding);
TSK_OBJECT_SAFE_FREE(THTTP_HEADER_PARAMS(Transfer_Encoding));
}
else{
TSK_DEBUG_ERROR("Null Transfer_Encoding header.");
}
return self;
}
static const tsk_object_def_t thttp_header_Transfer_Encoding_def_s =
{
sizeof(thttp_header_Transfer_Encoding_t),
thttp_header_Transfer_Encoding_create,
thttp_header_Transfer_Encoding_destroy,
tsk_null
};
const tsk_object_def_t *thttp_header_Transfer_Encoding_def_t = &thttp_header_Transfer_Encoding_def_s;

View File

@ -45,7 +45,7 @@
machine thttp_machine_parser_header_WWW_Authenticate;
# Includes
include thttp_machine_utils "./thttp_machine_utils.rl";
include thttp_machine_utils "./ragel/thttp_machine_utils.rl";
action tag
{
@ -193,8 +193,8 @@ thttp_header_WWW_Authenticate_t *thttp_header_WWW_Authenticate_parse(const char
%%write init;
%%write exec;
if( cs < %%{ write first_final; }%% )
{
if( cs < %%{ write first_final; }%% ){
TSK_DEBUG_ERROR("Failed to parse WWW-Authenticate header.");
TSK_OBJECT_SAFE_FREE(hdr_WWW_Authenticate);
}

View File

@ -168,8 +168,8 @@ static void thttp_message_parser_eoh(tsk_ragel_state_t *state, thttp_message_t *
}
# Includes
include thttp_machine_utils "./thttp_machine_utils.rl";
include thttp_machine_message "./thttp_machine_message.rl";
include thttp_machine_utils "./ragel/thttp_machine_utils.rl";
include thttp_machine_message "./ragel/thttp_machine_message.rl";
# Entry point
main := HTTP_message;

View File

@ -40,7 +40,7 @@
machine thttp_machine_parser_url;
# Includes
include thttp_machine_utils "./thttp_machine_utils.rl";
include thttp_machine_utils "./ragel/thttp_machine_utils.rl";
action tag
{
@ -89,13 +89,24 @@
}%%
/**@ingroup thttp_url_group
* Parses a HTTP/HTTPS url.
* @param urlstring A pointer to a valid url string. If the port is missing, then it's default value will be 443 if
* the scheme is 'https' and 80 otherwise.<br>
* @param length The length of the url string.
* @retval A well-defined object representing the url string.
*
* @code
* thttp_url_t* url = thttp_url_parse("http://www.google.com", strlen("http://www.google.com"));
* @endcode
*
* @sa @ref thttp_url_tostring<br>@ref thttp_url_serialize
**/
thttp_url_t *thttp_url_parse(const char *data, size_t size)
thttp_url_t *thttp_url_parse(const char *urlstring, size_t length)
{
int have_port = 0;
tsk_bool_t have_port = tsk_false;
int cs = 0;
const char *p = data;
const char *pe = p + size;
const char *p = urlstring;
const char *pe = p + length;
const char *eof = pe;
const char *ts = 0, *te = 0;

View File

@ -35,7 +35,7 @@
#include <string.h>
/**@defgroup thttp_auth_group HTTP basic/digest authentication (RFC 2617).
/**@defgroup thttp_auth_group HTTP basic/digest authentication (RFC 2617)
*/
/**@ingroup thttp_auth_group

View File

@ -31,7 +31,7 @@
#include "tinyHTTP/headers/thttp_header_Dummy.h"
/**@defgroup thttp_header_group HTTP Headers.
/**@defgroup thttp_header_group HTTP Headers
*/
const char *thttp_header_get_name(thttp_header_type_t type)
@ -43,6 +43,7 @@ const char *thttp_header_get_name(thttp_header_type_t type)
case thttp_htype_Content_Type: return "Content-Type";
case thttp_htype_Proxy_Authenticate: return "Proxy-Authenticate";
case thttp_htype_Proxy_Authorization: return "Proxy-Authorization";
case thttp_htype_Transfer_Encoding: return "Transfer-Encoding";
case thttp_htype_WWW_Authenticate: return "WWW-Authenticate";
default: return "unknown-header";

View File

@ -1,5 +1,5 @@
/* #line 1 "thttp_parser_header_Authorization.rl" */
/* #line 1 "./ragel/thttp_parser_header_Authorization.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
@ -43,7 +43,7 @@
* Ragel state machine.
*/
/* #line 161 "thttp_parser_header_Authorization.rl" */
/* #line 161 "./ragel/thttp_parser_header_Authorization.rl" */
int thttp_header_Authorization_tostring(const void* header, tsk_buffer_t* output)
@ -111,7 +111,7 @@ thttp_header_Authorization_t *thttp_header_Authorization_parse(const char *data,
const char *tag_start;
/* #line 115 "../src/headers/thttp_header_Authorization.c" */
/* #line 115 "./src/headers/thttp_header_Authorization.c" */
static const char _thttp_machine_parser_header_Authorization_actions[] = {
0, 1, 0, 1, 1, 1, 2, 1,
3, 1, 4, 1, 5, 1, 6, 1,
@ -9490,16 +9490,16 @@ static const int thttp_machine_parser_header_Authorization_error = 0;
static const int thttp_machine_parser_header_Authorization_en_main = 1;
/* #line 228 "thttp_parser_header_Authorization.rl" */
/* #line 228 "./ragel/thttp_parser_header_Authorization.rl" */
/* #line 9496 "../src/headers/thttp_header_Authorization.c" */
/* #line 9496 "./src/headers/thttp_header_Authorization.c" */
{
cs = thttp_machine_parser_header_Authorization_start;
}
/* #line 229 "thttp_parser_header_Authorization.rl" */
/* #line 229 "./ragel/thttp_parser_header_Authorization.rl" */
/* #line 9503 "../src/headers/thttp_header_Authorization.c" */
/* #line 9503 "./src/headers/thttp_header_Authorization.c" */
{
int _klen;
unsigned int _trans;
@ -9574,109 +9574,109 @@ _match:
switch ( *_acts++ )
{
case 0:
/* #line 50 "thttp_parser_header_Authorization.rl" */
/* #line 50 "./ragel/thttp_parser_header_Authorization.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 55 "thttp_parser_header_Authorization.rl" */
/* #line 55 "./ragel/thttp_parser_header_Authorization.rl" */
{
#//FIXME: Only Digest is supported
hdr_Authorization->scheme = tsk_strdup("Digest");
}
break;
case 2:
/* #line 61 "thttp_parser_header_Authorization.rl" */
/* #line 61 "./ragel/thttp_parser_header_Authorization.rl" */
{
THTTP_HEADER(hdr_Authorization)->type = thttp_htype_Authorization;
}
break;
case 3:
/* #line 66 "thttp_parser_header_Authorization.rl" */
/* #line 66 "./ragel/thttp_parser_header_Authorization.rl" */
{
THTTP_HEADER(hdr_Authorization)->type = thttp_htype_Proxy_Authorization;
}
break;
case 4:
/* #line 71 "thttp_parser_header_Authorization.rl" */
/* #line 71 "./ragel/thttp_parser_header_Authorization.rl" */
{
TSK_PARSER_SET_STRING(hdr_Authorization->username);
tsk_strunquote(&hdr_Authorization->username);
}
break;
case 5:
/* #line 77 "thttp_parser_header_Authorization.rl" */
/* #line 77 "./ragel/thttp_parser_header_Authorization.rl" */
{
TSK_PARSER_SET_STRING(hdr_Authorization->realm);
tsk_strunquote(&hdr_Authorization->realm);
}
break;
case 6:
/* #line 83 "thttp_parser_header_Authorization.rl" */
/* #line 83 "./ragel/thttp_parser_header_Authorization.rl" */
{
TSK_PARSER_SET_STRING(hdr_Authorization->nonce);
tsk_strunquote(&hdr_Authorization->nonce);
}
break;
case 7:
/* #line 89 "thttp_parser_header_Authorization.rl" */
/* #line 89 "./ragel/thttp_parser_header_Authorization.rl" */
{
TSK_PARSER_SET_STRING(hdr_Authorization->uri);
}
break;
case 8:
/* #line 94 "thttp_parser_header_Authorization.rl" */
/* #line 94 "./ragel/thttp_parser_header_Authorization.rl" */
{
TSK_PARSER_SET_STRING(hdr_Authorization->response);
tsk_strunquote(&hdr_Authorization->response);
}
break;
case 9:
/* #line 100 "thttp_parser_header_Authorization.rl" */
/* #line 100 "./ragel/thttp_parser_header_Authorization.rl" */
{
TSK_PARSER_SET_STRING(hdr_Authorization->algorithm);
}
break;
case 10:
/* #line 105 "thttp_parser_header_Authorization.rl" */
/* #line 105 "./ragel/thttp_parser_header_Authorization.rl" */
{
TSK_PARSER_SET_STRING(hdr_Authorization->cnonce);
tsk_strunquote(&hdr_Authorization->cnonce);
}
break;
case 11:
/* #line 111 "thttp_parser_header_Authorization.rl" */
/* #line 111 "./ragel/thttp_parser_header_Authorization.rl" */
{
TSK_PARSER_SET_STRING(hdr_Authorization->opaque);
tsk_strunquote(&hdr_Authorization->opaque);
}
break;
case 12:
/* #line 117 "thttp_parser_header_Authorization.rl" */
/* #line 117 "./ragel/thttp_parser_header_Authorization.rl" */
{
TSK_PARSER_SET_STRING(hdr_Authorization->qop);
//tsk_strunquote(&hdr_Authorization->qop);
}
break;
case 13:
/* #line 123 "thttp_parser_header_Authorization.rl" */
/* #line 123 "./ragel/thttp_parser_header_Authorization.rl" */
{
TSK_PARSER_SET_STRING(hdr_Authorization->nc);
}
break;
case 14:
/* #line 128 "thttp_parser_header_Authorization.rl" */
/* #line 128 "./ragel/thttp_parser_header_Authorization.rl" */
{
TSK_PARSER_ADD_PARAM(THTTP_HEADER_PARAMS(hdr_Authorization));
}
break;
case 15:
/* #line 133 "thttp_parser_header_Authorization.rl" */
/* #line 133 "./ragel/thttp_parser_header_Authorization.rl" */
{
}
break;
/* #line 9680 "../src/headers/thttp_header_Authorization.c" */
/* #line 9680 "./src/headers/thttp_header_Authorization.c" */
}
}
@ -9689,14 +9689,14 @@ _again:
_out: {}
}
/* #line 230 "thttp_parser_header_Authorization.rl" */
/* #line 230 "./ragel/thttp_parser_header_Authorization.rl" */
if( cs <
/* #line 9696 "../src/headers/thttp_header_Authorization.c" */
/* #line 9696 "./src/headers/thttp_header_Authorization.c" */
1391
/* #line 231 "thttp_parser_header_Authorization.rl" */
)
{
/* #line 231 "./ragel/thttp_parser_header_Authorization.rl" */
){
TSK_DEBUG_ERROR("Failed to parse Authorization header.");
TSK_OBJECT_SAFE_FREE(hdr_Authorization);
}

View File

@ -1,5 +1,5 @@
/* #line 1 "thttp_parser_header_Content_Length.rl" */
/* #line 1 "./ragel/thttp_parser_header_Content_Length.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
@ -38,7 +38,7 @@
* Ragel state machine.
*/
/* #line 63 "thttp_parser_header_Content_Length.rl" */
/* #line 63 "./ragel/thttp_parser_header_Content_Length.rl" */
int thttp_header_Content_Length_tostring(const void* header, tsk_buffer_t* output)
@ -65,7 +65,7 @@ thttp_header_Content_Length_t *thttp_header_Content_Length_parse(const char *dat
const char *tag_start;
/* #line 69 "../src/headers/thttp_header_Content_Length.c" */
/* #line 69 "./src/headers/thttp_header_Content_Length.c" */
static const char _thttp_machine_parser_header_Content_Length_actions[] = {
0, 1, 0, 1, 1, 1, 2
};
@ -134,16 +134,16 @@ static const int thttp_machine_parser_header_Content_Length_error = 0;
static const int thttp_machine_parser_header_Content_Length_en_main = 1;
/* #line 89 "thttp_parser_header_Content_Length.rl" */
/* #line 89 "./ragel/thttp_parser_header_Content_Length.rl" */
/* #line 140 "../src/headers/thttp_header_Content_Length.c" */
/* #line 140 "./src/headers/thttp_header_Content_Length.c" */
{
cs = thttp_machine_parser_header_Content_Length_start;
}
/* #line 90 "thttp_parser_header_Content_Length.rl" */
/* #line 90 "./ragel/thttp_parser_header_Content_Length.rl" */
/* #line 147 "../src/headers/thttp_header_Content_Length.c" */
/* #line 147 "./src/headers/thttp_header_Content_Length.c" */
{
int _klen;
unsigned int _trans;
@ -218,23 +218,23 @@ _match:
switch ( *_acts++ )
{
case 0:
/* #line 45 "thttp_parser_header_Content_Length.rl" */
/* #line 45 "./ragel/thttp_parser_header_Content_Length.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 50 "thttp_parser_header_Content_Length.rl" */
/* #line 50 "./ragel/thttp_parser_header_Content_Length.rl" */
{
TSK_PARSER_SET_INTEGER(hdr_clength->length);
}
break;
case 2:
/* #line 55 "thttp_parser_header_Content_Length.rl" */
/* #line 55 "./ragel/thttp_parser_header_Content_Length.rl" */
{
}
break;
/* #line 238 "../src/headers/thttp_header_Content_Length.c" */
/* #line 238 "./src/headers/thttp_header_Content_Length.c" */
}
}
@ -247,12 +247,12 @@ _again:
_out: {}
}
/* #line 91 "thttp_parser_header_Content_Length.rl" */
/* #line 91 "./ragel/thttp_parser_header_Content_Length.rl" */
if( cs <
/* #line 254 "../src/headers/thttp_header_Content_Length.c" */
/* #line 254 "./src/headers/thttp_header_Content_Length.c" */
22
/* #line 92 "thttp_parser_header_Content_Length.rl" */
/* #line 92 "./ragel/thttp_parser_header_Content_Length.rl" */
)
{
TSK_OBJECT_SAFE_FREE(hdr_clength);

View File

@ -1,5 +1,5 @@
/* #line 1 "thttp_parser_header_Content_Type.rl" */
/* #line 1 "./ragel/thttp_parser_header_Content_Type.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
@ -40,13 +40,12 @@
* Ragel state machine.
*/
/* #line 83 "thttp_parser_header_Content_Type.rl" */
/* #line 79 "./ragel/thttp_parser_header_Content_Type.rl" */
int thttp_header_Content_Type_tostring(const void* header, tsk_buffer_t* output)
{
if(header)
{
if(header){
const thttp_header_Content_Type_t *Content_Type = header;
return tsk_buffer_append(output, Content_Type->type, strlen(Content_Type->type));
}
@ -67,7 +66,7 @@ thttp_header_Content_Type_t *thttp_header_Content_Type_parse(const char *data, s
const char *tag_start;
/* #line 71 "../src/headers/thttp_header_Content_Type.c" */
/* #line 70 "./src/headers/thttp_header_Content_Type.c" */
static const char _thttp_machine_parser_header_Content_Type_actions[] = {
0, 1, 0, 1, 1, 1, 2, 1,
3
@ -233,16 +232,16 @@ static const int thttp_machine_parser_header_Content_Type_error = 0;
static const int thttp_machine_parser_header_Content_Type_en_main = 1;
/* #line 109 "thttp_parser_header_Content_Type.rl" */
/* #line 104 "./ragel/thttp_parser_header_Content_Type.rl" */
/* #line 239 "../src/headers/thttp_header_Content_Type.c" */
/* #line 238 "./src/headers/thttp_header_Content_Type.c" */
{
cs = thttp_machine_parser_header_Content_Type_start;
}
/* #line 110 "thttp_parser_header_Content_Type.rl" */
/* #line 105 "./ragel/thttp_parser_header_Content_Type.rl" */
/* #line 246 "../src/headers/thttp_header_Content_Type.c" */
/* #line 245 "./src/headers/thttp_header_Content_Type.c" */
{
int _klen;
unsigned int _trans;
@ -317,29 +316,29 @@ _match:
switch ( *_acts++ )
{
case 0:
/* #line 47 "thttp_parser_header_Content_Type.rl" */
/* #line 46 "./ragel/thttp_parser_header_Content_Type.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 52 "thttp_parser_header_Content_Type.rl" */
/* #line 50 "./ragel/thttp_parser_header_Content_Type.rl" */
{
TSK_PARSER_SET_STRING(hdr_ctype->type);
}
break;
case 2:
/* #line 57 "thttp_parser_header_Content_Type.rl" */
/* #line 54 "./ragel/thttp_parser_header_Content_Type.rl" */
{
TSK_PARSER_ADD_PARAM(THTTP_HEADER_PARAMS(hdr_ctype));
}
break;
case 3:
/* #line 62 "thttp_parser_header_Content_Type.rl" */
/* #line 58 "./ragel/thttp_parser_header_Content_Type.rl" */
{
}
break;
/* #line 343 "../src/headers/thttp_header_Content_Type.c" */
/* #line 342 "./src/headers/thttp_header_Content_Type.c" */
}
}
@ -352,14 +351,14 @@ _again:
_out: {}
}
/* #line 111 "thttp_parser_header_Content_Type.rl" */
/* #line 106 "./ragel/thttp_parser_header_Content_Type.rl" */
if( cs <
/* #line 359 "../src/headers/thttp_header_Content_Type.c" */
/* #line 358 "./src/headers/thttp_header_Content_Type.c" */
60
/* #line 112 "thttp_parser_header_Content_Type.rl" */
)
{
/* #line 107 "./ragel/thttp_parser_header_Content_Type.rl" */
){
TSK_DEBUG_ERROR("Failed to parse Content-Type header.");
TSK_OBJECT_SAFE_FREE(hdr_ctype);
}
@ -378,18 +377,16 @@ _again:
/**@ingroup thttp_header_Content_Type_group
*/
static void* thttp_header_Content_Type_create(void *self, va_list * app)
static tsk_object_t* thttp_header_Content_Type_create(tsk_object_t *self, va_list * app)
{
thttp_header_Content_Type_t *Content_Type = self;
if(Content_Type)
{
if(Content_Type){
THTTP_HEADER(Content_Type)->type = thttp_htype_Content_Type;
THTTP_HEADER(Content_Type)->tostring = thttp_header_Content_Type_tostring;
Content_Type->type = tsk_strdup( va_arg(*app, const char*) );
}
else
{
else{
TSK_DEBUG_ERROR("Failed to create new Content_Type header.");
}
return self;
@ -397,15 +394,16 @@ static void* thttp_header_Content_Type_create(void *self, va_list * app)
/**@ingroup thttp_header_Content_Type_group
*/
static void* thttp_header_Content_Type_destroy(void *self)
static tsk_object_t* thttp_header_Content_Type_destroy(tsk_object_t *self)
{
thttp_header_Content_Type_t *Content_Type = self;
if(Content_Type)
{
if(Content_Type){
TSK_FREE(Content_Type->type);
TSK_OBJECT_SAFE_FREE(THTTP_HEADER_PARAMS(Content_Type));
}
else TSK_DEBUG_ERROR("Null Content_Type header.");
else{
TSK_DEBUG_ERROR("Null Content_Type header.");
}
return self;
}
@ -415,6 +413,6 @@ static const tsk_object_def_t thttp_header_Content_Type_def_s =
sizeof(thttp_header_Content_Type_t),
thttp_header_Content_Type_create,
thttp_header_Content_Type_destroy,
0
tsk_null
};
const void *thttp_header_Content_Type_def_t = &thttp_header_Content_Type_def_s;
const tsk_object_def_t *thttp_header_Content_Type_def_t = &thttp_header_Content_Type_def_s;

View File

@ -1,5 +1,5 @@
/* #line 1 "thttp_parser_header_Dummy.rl" */
/* #line 1 "./ragel/thttp_parser_header_Dummy.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
@ -42,7 +42,7 @@
* Ragel state machine.
*/
/* #line 72 "thttp_parser_header_Dummy.rl" */
/* #line 72 "./ragel/thttp_parser_header_Dummy.rl" */
int thttp_header_Dummy_tostring(const void* header, tsk_buffer_t* output)
@ -73,7 +73,7 @@ thttp_header_Dummy_t *thttp_header_Dummy_parse(const char *data, size_t size)
const char *tag_start;
/* #line 77 "../src/headers/thttp_header_Dummy.c" */
/* #line 77 "./src/headers/thttp_header_Dummy.c" */
static const char _thttp_machine_parser_header_Dummy_actions[] = {
0, 1, 0, 1, 1, 1, 2, 1,
3, 2, 0, 2
@ -134,16 +134,16 @@ static const int thttp_machine_parser_header_Dummy_error = 0;
static const int thttp_machine_parser_header_Dummy_en_main = 1;
/* #line 102 "thttp_parser_header_Dummy.rl" */
/* #line 102 "./ragel/thttp_parser_header_Dummy.rl" */
/* #line 140 "../src/headers/thttp_header_Dummy.c" */
/* #line 140 "./src/headers/thttp_header_Dummy.c" */
{
cs = thttp_machine_parser_header_Dummy_start;
}
/* #line 103 "thttp_parser_header_Dummy.rl" */
/* #line 103 "./ragel/thttp_parser_header_Dummy.rl" */
/* #line 147 "../src/headers/thttp_header_Dummy.c" */
/* #line 147 "./src/headers/thttp_header_Dummy.c" */
{
int _klen;
unsigned int _trans;
@ -218,29 +218,29 @@ _match:
switch ( *_acts++ )
{
case 0:
/* #line 49 "thttp_parser_header_Dummy.rl" */
/* #line 49 "./ragel/thttp_parser_header_Dummy.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 54 "thttp_parser_header_Dummy.rl" */
/* #line 54 "./ragel/thttp_parser_header_Dummy.rl" */
{
TSK_PARSER_SET_STRING(hdr_Dummy->name);
}
break;
case 2:
/* #line 59 "thttp_parser_header_Dummy.rl" */
/* #line 59 "./ragel/thttp_parser_header_Dummy.rl" */
{
TSK_PARSER_SET_STRING(hdr_Dummy->value);
}
break;
case 3:
/* #line 64 "thttp_parser_header_Dummy.rl" */
/* #line 64 "./ragel/thttp_parser_header_Dummy.rl" */
{
}
break;
/* #line 244 "../src/headers/thttp_header_Dummy.c" */
/* #line 244 "./src/headers/thttp_header_Dummy.c" */
}
}
@ -253,12 +253,12 @@ _again:
_out: {}
}
/* #line 104 "thttp_parser_header_Dummy.rl" */
/* #line 104 "./ragel/thttp_parser_header_Dummy.rl" */
if( cs <
/* #line 260 "../src/headers/thttp_header_Dummy.c" */
/* #line 260 "./src/headers/thttp_header_Dummy.c" */
10
/* #line 105 "thttp_parser_header_Dummy.rl" */
/* #line 105 "./ragel/thttp_parser_header_Dummy.rl" */
)
{
TSK_OBJECT_SAFE_FREE(hdr_Dummy);

View File

@ -0,0 +1,362 @@
/* #line 1 "./ragel/thttp_parser_header_Transfer_Encoding.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
/**@file thttp_header_Transfer_Encoding.c
* @brief HTTP Transfer-Encoding header.
*
* @author Mamadou Diop <diopmamadou(at)doubango.org>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tinyHTTP/headers/thttp_header_Transfer_Encoding.h"
#include "tsk_debug.h"
#include "tsk_memory.h"
#include <string.h>
/***********************************
* Ragel state machine.
*/
/* #line 66 "./ragel/thttp_parser_header_Transfer_Encoding.rl" */
int thttp_header_Transfer_Encoding_tostring(const void* header, tsk_buffer_t* output)
{
if(header){
const thttp_header_Transfer_Encoding_t *Transfer_Encoding = header;
return tsk_buffer_append(output, Transfer_Encoding->encoding, strlen(Transfer_Encoding->encoding));
}
return -1;
}
/**@ingroup thttp_header_group
*/
thttp_header_Transfer_Encoding_t *thttp_header_Transfer_Encoding_parse(const char *data, size_t size)
{
int cs = 0;
const char *p = data;
const char *pe = p + size;
const char *eof = pe;
thttp_header_Transfer_Encoding_t *hdr_tencoding = THTTP_HEADER_TRANSFER_ENCODING_CREATE_NULL();
const char *tag_start;
/* #line 70 "./src/headers/thttp_header_Transfer_Encoding.c" */
static const char _thttp_machine_parser_header_Transfer_Encoding_actions[] = {
0, 1, 0, 1, 1, 1, 2, 1,
3
};
static const unsigned char _thttp_machine_parser_header_Transfer_Encoding_key_offsets[] = {
0, 0, 2, 4, 6, 8, 10, 12,
14, 16, 17, 19, 21, 23, 25, 27,
29, 31, 33, 36, 53, 54, 56, 72,
88, 89, 102, 118, 124, 130, 143, 158,
164, 170
};
static const char _thttp_machine_parser_header_Transfer_Encoding_trans_keys[] = {
84, 116, 82, 114, 65, 97, 78, 110,
83, 115, 70, 102, 69, 101, 82, 114,
45, 69, 101, 78, 110, 67, 99, 79,
111, 68, 100, 73, 105, 78, 110, 71,
103, 9, 32, 58, 9, 13, 32, 33,
37, 39, 126, 42, 43, 45, 46, 48,
57, 65, 90, 95, 122, 10, 9, 32,
9, 32, 33, 37, 39, 126, 42, 43,
45, 46, 48, 57, 65, 90, 95, 122,
13, 33, 37, 39, 59, 126, 42, 43,
45, 46, 48, 57, 65, 90, 95, 122,
10, 33, 37, 93, 95, 126, 36, 43,
45, 58, 65, 91, 97, 122, 13, 33,
37, 59, 61, 93, 95, 126, 36, 43,
45, 58, 65, 91, 97, 122, 48, 57,
65, 70, 97, 102, 48, 57, 65, 70,
97, 102, 33, 37, 93, 95, 126, 36,
43, 45, 58, 65, 91, 97, 122, 13,
33, 37, 59, 93, 95, 126, 36, 43,
45, 58, 65, 91, 97, 122, 48, 57,
65, 70, 97, 102, 48, 57, 65, 70,
97, 102, 0
};
static const char _thttp_machine_parser_header_Transfer_Encoding_single_lengths[] = {
0, 2, 2, 2, 2, 2, 2, 2,
2, 1, 2, 2, 2, 2, 2, 2,
2, 2, 3, 7, 1, 2, 6, 6,
1, 5, 8, 0, 0, 5, 7, 0,
0, 0
};
static const char _thttp_machine_parser_header_Transfer_Encoding_range_lengths[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 5, 0, 0, 5, 5,
0, 4, 4, 3, 3, 4, 4, 3,
3, 0
};
static const unsigned char _thttp_machine_parser_header_Transfer_Encoding_index_offsets[] = {
0, 0, 3, 6, 9, 12, 15, 18,
21, 24, 26, 29, 32, 35, 38, 41,
44, 47, 50, 54, 67, 69, 72, 84,
96, 98, 108, 121, 125, 129, 139, 151,
155, 159
};
static const char _thttp_machine_parser_header_Transfer_Encoding_indicies[] = {
0, 0, 1, 2, 2, 1, 3, 3,
1, 4, 4, 1, 5, 5, 1, 6,
6, 1, 7, 7, 1, 8, 8, 1,
9, 1, 10, 10, 1, 11, 11, 1,
12, 12, 1, 13, 13, 1, 14, 14,
1, 15, 15, 1, 16, 16, 1, 17,
17, 1, 17, 17, 18, 1, 18, 19,
18, 20, 20, 20, 20, 20, 20, 20,
20, 20, 1, 21, 1, 22, 22, 1,
22, 22, 20, 20, 20, 20, 20, 20,
20, 20, 20, 1, 23, 24, 24, 24,
25, 24, 24, 24, 24, 24, 24, 1,
26, 1, 27, 28, 27, 27, 27, 27,
27, 27, 27, 1, 29, 30, 31, 32,
33, 30, 30, 30, 30, 30, 30, 30,
1, 34, 34, 34, 1, 30, 30, 30,
1, 35, 36, 35, 35, 35, 35, 35,
35, 35, 1, 29, 35, 36, 32, 35,
35, 35, 35, 35, 35, 35, 1, 37,
37, 37, 1, 35, 35, 35, 1, 1,
0
};
static const char _thttp_machine_parser_header_Transfer_Encoding_trans_targs[] = {
2, 0, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 23, 21, 22, 24,
23, 25, 33, 26, 27, 24, 26, 27,
25, 29, 28, 30, 31, 32
};
static const char _thttp_machine_parser_header_Transfer_Encoding_trans_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 3,
0, 3, 7, 1, 1, 5, 0, 0,
5, 0, 0, 0, 0, 0
};
static const int thttp_machine_parser_header_Transfer_Encoding_start = 1;
static const int thttp_machine_parser_header_Transfer_Encoding_first_final = 33;
static const int thttp_machine_parser_header_Transfer_Encoding_error = 0;
static const int thttp_machine_parser_header_Transfer_Encoding_en_main = 1;
/* #line 91 "./ragel/thttp_parser_header_Transfer_Encoding.rl" */
/* #line 182 "./src/headers/thttp_header_Transfer_Encoding.c" */
{
cs = thttp_machine_parser_header_Transfer_Encoding_start;
}
/* #line 92 "./ragel/thttp_parser_header_Transfer_Encoding.rl" */
/* #line 189 "./src/headers/thttp_header_Transfer_Encoding.c" */
{
int _klen;
unsigned int _trans;
const char *_acts;
unsigned int _nacts;
const char *_keys;
if ( p == pe )
goto _test_eof;
if ( cs == 0 )
goto _out;
_resume:
_keys = _thttp_machine_parser_header_Transfer_Encoding_trans_keys + _thttp_machine_parser_header_Transfer_Encoding_key_offsets[cs];
_trans = _thttp_machine_parser_header_Transfer_Encoding_index_offsets[cs];
_klen = _thttp_machine_parser_header_Transfer_Encoding_single_lengths[cs];
if ( _klen > 0 ) {
const char *_lower = _keys;
const char *_mid;
const char *_upper = _keys + _klen - 1;
while (1) {
if ( _upper < _lower )
break;
_mid = _lower + ((_upper-_lower) >> 1);
if ( (*p) < *_mid )
_upper = _mid - 1;
else if ( (*p) > *_mid )
_lower = _mid + 1;
else {
_trans += (_mid - _keys);
goto _match;
}
}
_keys += _klen;
_trans += _klen;
}
_klen = _thttp_machine_parser_header_Transfer_Encoding_range_lengths[cs];
if ( _klen > 0 ) {
const char *_lower = _keys;
const char *_mid;
const char *_upper = _keys + (_klen<<1) - 2;
while (1) {
if ( _upper < _lower )
break;
_mid = _lower + (((_upper-_lower) >> 1) & ~1);
if ( (*p) < _mid[0] )
_upper = _mid - 2;
else if ( (*p) > _mid[1] )
_lower = _mid + 2;
else {
_trans += ((_mid - _keys)>>1);
goto _match;
}
}
_trans += _klen;
}
_match:
_trans = _thttp_machine_parser_header_Transfer_Encoding_indicies[_trans];
cs = _thttp_machine_parser_header_Transfer_Encoding_trans_targs[_trans];
if ( _thttp_machine_parser_header_Transfer_Encoding_trans_actions[_trans] == 0 )
goto _again;
_acts = _thttp_machine_parser_header_Transfer_Encoding_actions + _thttp_machine_parser_header_Transfer_Encoding_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
/* #line 46 "./ragel/thttp_parser_header_Transfer_Encoding.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 50 "./ragel/thttp_parser_header_Transfer_Encoding.rl" */
{
TSK_PARSER_SET_STRING(hdr_tencoding->encoding);
}
break;
case 2:
/* #line 54 "./ragel/thttp_parser_header_Transfer_Encoding.rl" */
{
TSK_PARSER_ADD_PARAM(THTTP_HEADER_PARAMS(hdr_tencoding));
}
break;
case 3:
/* #line 58 "./ragel/thttp_parser_header_Transfer_Encoding.rl" */
{
}
break;
/* #line 286 "./src/headers/thttp_header_Transfer_Encoding.c" */
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
_out: {}
}
/* #line 93 "./ragel/thttp_parser_header_Transfer_Encoding.rl" */
if( cs <
/* #line 302 "./src/headers/thttp_header_Transfer_Encoding.c" */
33
/* #line 94 "./ragel/thttp_parser_header_Transfer_Encoding.rl" */
){
TSK_DEBUG_ERROR("Failed to parse Tansfer-Encoding header.");
TSK_OBJECT_SAFE_FREE(hdr_tencoding);
}
return hdr_tencoding;
}
//========================================================
// Transfer_Encoding header object definition
//
/**@ingroup thttp_header_Transfer_Encoding_group
*/
static tsk_object_t* thttp_header_Transfer_Encoding_create(tsk_object_t *self, va_list * app)
{
thttp_header_Transfer_Encoding_t *Transfer_Encoding = self;
if(Transfer_Encoding){
THTTP_HEADER(Transfer_Encoding)->type = thttp_htype_Transfer_Encoding;
THTTP_HEADER(Transfer_Encoding)->tostring = thttp_header_Transfer_Encoding_tostring;
Transfer_Encoding->encoding = tsk_strdup( va_arg(*app, const char*) );
}
else{
TSK_DEBUG_ERROR("Failed to create new Transfer_Encoding header.");
}
return self;
}
/**@ingroup thttp_header_Transfer_Encoding_group
*/
static tsk_object_t* thttp_header_Transfer_Encoding_destroy(tsk_object_t* self)
{
thttp_header_Transfer_Encoding_t *Transfer_Encoding = self;
if(Transfer_Encoding){
TSK_FREE(Transfer_Encoding->encoding);
TSK_OBJECT_SAFE_FREE(THTTP_HEADER_PARAMS(Transfer_Encoding));
}
else{
TSK_DEBUG_ERROR("Null Transfer_Encoding header.");
}
return self;
}
static const tsk_object_def_t thttp_header_Transfer_Encoding_def_s =
{
sizeof(thttp_header_Transfer_Encoding_t),
thttp_header_Transfer_Encoding_create,
thttp_header_Transfer_Encoding_destroy,
tsk_null
};
const tsk_object_def_t *thttp_header_Transfer_Encoding_def_t = &thttp_header_Transfer_Encoding_def_s;

View File

@ -1,5 +1,5 @@
/* #line 1 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 1 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
@ -44,7 +44,7 @@
* Ragel state machine.
*/
/* #line 139 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 139 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
int thttp_header_WWW_Authenticate_tostring(const void* header, tsk_buffer_t* output)
@ -99,7 +99,7 @@ thttp_header_WWW_Authenticate_t *thttp_header_WWW_Authenticate_parse(const char
const char *tag_start;
/* #line 103 "../src/headers/thttp_header_WWW_Authenticate.c" */
/* #line 103 "./src/headers/thttp_header_WWW_Authenticate.c" */
static const char _thttp_machine_parser_header_WWW_Authenticate_actions[] = {
0, 1, 0, 1, 1, 1, 2, 1,
3, 1, 4, 1, 5, 1, 6, 1,
@ -6242,16 +6242,16 @@ static const int thttp_machine_parser_header_WWW_Authenticate_error = 0;
static const int thttp_machine_parser_header_WWW_Authenticate_en_main = 1;
/* #line 193 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 193 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
/* #line 6248 "../src/headers/thttp_header_WWW_Authenticate.c" */
/* #line 6248 "./src/headers/thttp_header_WWW_Authenticate.c" */
{
cs = thttp_machine_parser_header_WWW_Authenticate_start;
}
/* #line 194 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 194 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
/* #line 6255 "../src/headers/thttp_header_WWW_Authenticate.c" */
/* #line 6255 "./src/headers/thttp_header_WWW_Authenticate.c" */
{
int _klen;
unsigned int _trans;
@ -6326,89 +6326,89 @@ _match:
switch ( *_acts++ )
{
case 0:
/* #line 51 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 51 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 56 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 56 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
{
#//FIXME: Only Digest is supported
hdr_WWW_Authenticate->scheme = tsk_strdup("Digest");
}
break;
case 2:
/* #line 62 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 62 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
{
THTTP_HEADER(hdr_WWW_Authenticate)->type = thttp_htype_WWW_Authenticate;
}
break;
case 3:
/* #line 67 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 67 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
{
THTTP_HEADER(hdr_WWW_Authenticate)->type = thttp_htype_Proxy_Authenticate;
}
break;
case 4:
/* #line 72 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 72 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
{
TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->realm);
tsk_strunquote(&hdr_WWW_Authenticate->realm);
}
break;
case 5:
/* #line 78 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 78 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
{
TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->domain);
//tsk_strunquote(&hdr_WWW_Authenticate->domain);
}
break;
case 6:
/* #line 84 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 84 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
{
TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->nonce);
tsk_strunquote(&hdr_WWW_Authenticate->nonce);
}
break;
case 7:
/* #line 90 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 90 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
{
TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->opaque);
tsk_strunquote(&hdr_WWW_Authenticate->opaque);
}
break;
case 8:
/* #line 96 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 96 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
{
hdr_WWW_Authenticate->stale = tsk_strniequals(tag_start, "true", 4);
}
break;
case 9:
/* #line 101 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 101 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
{
TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->algorithm);
}
break;
case 10:
/* #line 106 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 106 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
{
TSK_PARSER_SET_STRING(hdr_WWW_Authenticate->qop);
//tsk_strunquote(&hdr_WWW_Authenticate->qop);
}
break;
case 11:
/* #line 112 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 112 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
{
TSK_PARSER_ADD_PARAM(THTTP_HEADER_PARAMS(hdr_WWW_Authenticate));
}
break;
case 12:
/* #line 117 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 117 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
{
}
break;
/* #line 6412 "../src/headers/thttp_header_WWW_Authenticate.c" */
/* #line 6412 "./src/headers/thttp_header_WWW_Authenticate.c" */
}
}
@ -6421,14 +6421,14 @@ _again:
_out: {}
}
/* #line 195 "thttp_parser_header_WWW_Authenticate.rl" */
/* #line 195 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
if( cs <
/* #line 6428 "../src/headers/thttp_header_WWW_Authenticate.c" */
/* #line 6428 "./src/headers/thttp_header_WWW_Authenticate.c" */
961
/* #line 196 "thttp_parser_header_WWW_Authenticate.rl" */
)
{
/* #line 196 "./ragel/thttp_parser_header_WWW_Authenticate.rl" */
){
TSK_DEBUG_ERROR("Failed to parse WWW-Authenticate header.");
TSK_OBJECT_SAFE_FREE(hdr_WWW_Authenticate);
}

View File

@ -1,5 +1,5 @@
/* #line 1 "thttp_parser_header.rl" */
/* #line 1 "./ragel/thttp_parser_header.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
@ -53,7 +53,7 @@
//#include "tinyHTTP/headers/thttp_header_Route.h"
//#include "tinyHTTP/headers/thttp_header_Service_Route.h"
//#include "tinyHTTP/headers/thttp_header_Supported.h"
//#include "tinyHTTP/headers/thttp_header_To.h"
#include "tinyHTTP/headers/thttp_header_Transfer_Encoding.h"
//#include "tinyHTTP/headers/thttp_header_User_Agent.h"
//#include "tinyHTTP/headers/thttp_header_Via.h"
#include "tinyHTTP/headers/thttp_header_WWW_Authenticate.h"
@ -85,7 +85,7 @@
* Ragel state machine.
*/
/* #line 465 "thttp_parser_header.rl" */
/* #line 465 "./ragel/thttp_parser_header.rl" */
int thttp_header_parse(tsk_ragel_state_t *state, thttp_message_t *message)
@ -96,7 +96,7 @@ int thttp_header_parse(tsk_ragel_state_t *state, thttp_message_t *message)
const char *eof = pe;
/* #line 100 "../src/parsers/thttp_parser_header.c" */
/* #line 100 "./src/parsers/thttp_parser_header.c" */
static const char _thttp_machine_parser_headers_actions[] = {
0, 1, 0, 1, 1, 1, 2, 1,
3, 1, 4, 1, 5, 1, 6, 1,
@ -2061,11 +2061,11 @@ static const char _thttp_machine_parser_headers_trans_actions[] = {
0, 0, 0, 0, 0, 0, 0, 61,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 63, 0, 0, 0, 0,
0, 0, 0, 0, 67, 0, 0, 0,
0, 0, 0, 0, 65, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 69, 0, 0, 0, 0, 0, 0,
0, 67, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 65, 0, 0,
0, 0, 0, 0, 0, 69, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 71, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@ -2084,16 +2084,16 @@ static const int thttp_machine_parser_headers_error = 0;
static const int thttp_machine_parser_headers_en_main = 1;
/* #line 475 "thttp_parser_header.rl" */
/* #line 475 "./ragel/thttp_parser_header.rl" */
/* #line 2090 "../src/parsers/thttp_parser_header.c" */
/* #line 2090 "./src/parsers/thttp_parser_header.c" */
{
cs = thttp_machine_parser_headers_start;
}
/* #line 476 "thttp_parser_header.rl" */
/* #line 476 "./ragel/thttp_parser_header.rl" */
/* #line 2097 "../src/parsers/thttp_parser_header.c" */
/* #line 2097 "./src/parsers/thttp_parser_header.c" */
{
int _klen;
unsigned int _trans;
@ -2168,7 +2168,7 @@ _match:
switch ( *_acts++ )
{
case 0:
/* #line 91 "thttp_parser_header.rl" */
/* #line 91 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2177,7 +2177,7 @@ _match:
}
break;
case 1:
/* #line 100 "thttp_parser_header.rl" */
/* #line 100 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2186,7 +2186,7 @@ _match:
}
break;
case 2:
/* #line 109 "thttp_parser_header.rl" */
/* #line 109 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2195,7 +2195,7 @@ _match:
}
break;
case 3:
/* #line 118 "thttp_parser_header.rl" */
/* #line 118 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2204,7 +2204,7 @@ _match:
}
break;
case 4:
/* #line 127 "thttp_parser_header.rl" */
/* #line 127 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2213,14 +2213,14 @@ _match:
}
break;
case 5:
/* #line 136 "thttp_parser_header.rl" */
/* #line 136 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Authorization_t *header = thttp_header_Authorization_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
}
break;
case 6:
/* #line 143 "thttp_parser_header.rl" */
/* #line 143 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2229,7 +2229,7 @@ _match:
}
break;
case 7:
/* #line 152 "thttp_parser_header.rl" */
/* #line 152 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2238,7 +2238,7 @@ _match:
}
break;
case 8:
/* #line 161 "thttp_parser_header.rl" */
/* #line 161 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2247,7 +2247,7 @@ _match:
}
break;
case 9:
/* #line 170 "thttp_parser_header.rl" */
/* #line 170 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2256,7 +2256,7 @@ _match:
}
break;
case 10:
/* #line 179 "thttp_parser_header.rl" */
/* #line 179 "./ragel/thttp_parser_header.rl" */
{
if(!message->Content_Length){
message->Content_Length = thttp_header_Content_Length_parse(state->tag_start, (state->tag_end-state->tag_start));
@ -2269,7 +2269,7 @@ _match:
}
break;
case 11:
/* #line 192 "thttp_parser_header.rl" */
/* #line 192 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2278,7 +2278,7 @@ _match:
}
break;
case 12:
/* #line 201 "thttp_parser_header.rl" */
/* #line 201 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2287,7 +2287,7 @@ _match:
}
break;
case 13:
/* #line 210 "thttp_parser_header.rl" */
/* #line 210 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2296,7 +2296,7 @@ _match:
}
break;
case 14:
/* #line 219 "thttp_parser_header.rl" */
/* #line 219 "./ragel/thttp_parser_header.rl" */
{
if(!message->Content_Type){
message->Content_Type = thttp_header_Content_Type_parse(state->tag_start, (state->tag_end-state->tag_start));
@ -2309,7 +2309,7 @@ _match:
}
break;
case 15:
/* #line 232 "thttp_parser_header.rl" */
/* #line 232 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2318,7 +2318,7 @@ _match:
}
break;
case 16:
/* #line 241 "thttp_parser_header.rl" */
/* #line 241 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2327,7 +2327,7 @@ _match:
}
break;
case 17:
/* #line 250 "thttp_parser_header.rl" */
/* #line 250 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2336,7 +2336,7 @@ _match:
}
break;
case 18:
/* #line 259 "thttp_parser_header.rl" */
/* #line 259 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2345,7 +2345,7 @@ _match:
}
break;
case 19:
/* #line 268 "thttp_parser_header.rl" */
/* #line 268 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2354,7 +2354,7 @@ _match:
}
break;
case 20:
/* #line 277 "thttp_parser_header.rl" */
/* #line 277 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2363,7 +2363,7 @@ _match:
}
break;
case 21:
/* #line 286 "thttp_parser_header.rl" */
/* #line 286 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2372,7 +2372,7 @@ _match:
}
break;
case 22:
/* #line 295 "thttp_parser_header.rl" */
/* #line 295 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2381,7 +2381,7 @@ _match:
}
break;
case 23:
/* #line 304 "thttp_parser_header.rl" */
/* #line 304 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2390,7 +2390,7 @@ _match:
}
break;
case 24:
/* #line 313 "thttp_parser_header.rl" */
/* #line 313 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2399,7 +2399,7 @@ _match:
}
break;
case 25:
/* #line 322 "thttp_parser_header.rl" */
/* #line 322 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2408,7 +2408,7 @@ _match:
}
break;
case 26:
/* #line 331 "thttp_parser_header.rl" */
/* #line 331 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2417,7 +2417,7 @@ _match:
}
break;
case 27:
/* #line 340 "thttp_parser_header.rl" */
/* #line 340 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2426,21 +2426,21 @@ _match:
}
break;
case 28:
/* #line 349 "thttp_parser_header.rl" */
/* #line 349 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Proxy_Authenticate_t *header = thttp_header_Proxy_Authenticate_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
}
break;
case 29:
/* #line 356 "thttp_parser_header.rl" */
/* #line 356 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Proxy_Authorization_t *header = thttp_header_Proxy_Authorization_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
}
break;
case 30:
/* #line 363 "thttp_parser_header.rl" */
/* #line 363 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2449,7 +2449,7 @@ _match:
}
break;
case 31:
/* #line 372 "thttp_parser_header.rl" */
/* #line 372 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2458,16 +2458,7 @@ _match:
}
break;
case 32:
/* #line 381 "thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
//TSK_DEBUG_WARN("parse_header_Transfer_Encoding NOT IMPLEMENTED. Will be added as Dummy header.");
}
break;
case 33:
/* #line 390 "thttp_parser_header.rl" */
/* #line 381 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2475,8 +2466,8 @@ _match:
//TSK_DEBUG_WARN("parse_header_TE NOT IMPLEMENTED. Will be added as Dummy header.");
}
break;
case 34:
/* #line 399 "thttp_parser_header.rl" */
case 33:
/* #line 390 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2484,8 +2475,17 @@ _match:
//TSK_DEBUG_WARN("parse_header_Trailer NOT IMPLEMENTED. Will be added as Dummy header.");
}
break;
case 34:
/* #line 399 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Transfer_Encoding_t *header = thttp_header_Transfer_Encoding_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
//TSK_DEBUG_WARN("parse_header_Trailer NOT IMPLEMENTED. Will be added as Dummy header.");
}
break;
case 35:
/* #line 408 "thttp_parser_header.rl" */
/* #line 408 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2494,7 +2494,7 @@ _match:
}
break;
case 36:
/* #line 417 "thttp_parser_header.rl" */
/* #line 417 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2503,7 +2503,7 @@ _match:
}
break;
case 37:
/* #line 426 "thttp_parser_header.rl" */
/* #line 426 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2512,7 +2512,7 @@ _match:
}
break;
case 38:
/* #line 435 "thttp_parser_header.rl" */
/* #line 435 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2521,14 +2521,14 @@ _match:
}
break;
case 39:
/* #line 444 "thttp_parser_header.rl" */
/* #line 444 "./ragel/thttp_parser_header.rl" */
{
thttp_header_WWW_Authenticate_t *header = thttp_header_WWW_Authenticate_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
}
break;
case 40:
/* #line 451 "thttp_parser_header.rl" */
/* #line 451 "./ragel/thttp_parser_header.rl" */
{
thttp_header_Dummy_t *header = thttp_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
ADD_HEADER(header);
@ -2536,7 +2536,7 @@ _match:
//TSK_DEBUG_WARN("parse_header_extension_header NOT IMPLEMENTED. Will be added as Dummy header.");
}
break;
/* #line 2540 "../src/parsers/thttp_parser_header.c" */
/* #line 2540 "./src/parsers/thttp_parser_header.c" */
}
}
@ -2549,11 +2549,11 @@ _again:
_out: {}
}
/* #line 477 "thttp_parser_header.rl" */
/* #line 477 "./ragel/thttp_parser_header.rl" */
return ( cs >=
/* #line 2556 "../src/parsers/thttp_parser_header.c" */
/* #line 2556 "./src/parsers/thttp_parser_header.c" */
568
/* #line 478 "thttp_parser_header.rl" */
/* #line 478 "./ragel/thttp_parser_header.rl" */
) ? 0 : -1;
}

View File

@ -1,5 +1,5 @@
/* #line 1 "thttp_parser_message.rl" */
/* #line 1 "./ragel/thttp_parser_message.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
@ -45,13 +45,13 @@ static void thttp_message_parser_eoh(tsk_ragel_state_t *state, thttp_message_t *
* Ragel state machine.
*/
/* #line 176 "thttp_parser_message.rl" */
/* #line 176 "./ragel/thttp_parser_message.rl" */
/* Regel data */
/* #line 55 "../src/parsers/thttp_parser_message.c" */
/* #line 55 "./src/parsers/thttp_parser_message.c" */
static const char _thttp_machine_parser_message_actions[] = {
0, 1, 0, 1, 1, 1, 2, 1,
3, 1, 4, 1, 5, 1, 6, 1,
@ -184,7 +184,7 @@ static const int thttp_machine_parser_message_error = 0;
static const int thttp_machine_parser_message_en_main = 1;
/* #line 181 "thttp_parser_message.rl" */
/* #line 181 "./ragel/thttp_parser_message.rl" */
/** Parses raw HTTP buffer.
*
@ -216,9 +216,9 @@ int thttp_message_parse(tsk_ragel_state_t *state, thttp_message_t **result, tsk_
/* Check result */
if( state->cs <
/* #line 220 "../src/parsers/thttp_parser_message.c" */
/* #line 220 "./src/parsers/thttp_parser_message.c" */
44
/* #line 211 "thttp_parser_message.rl" */
/* #line 211 "./ragel/thttp_parser_message.rl" */
)
{
TSK_DEBUG_ERROR("Failed to parse HTTP message.");
@ -235,12 +235,12 @@ static void thttp_message_parser_init(tsk_ragel_state_t *state)
/* Regel machine initialization. */
/* #line 239 "../src/parsers/thttp_parser_message.c" */
/* #line 239 "./src/parsers/thttp_parser_message.c" */
{
cs = thttp_machine_parser_message_start;
}
/* #line 227 "thttp_parser_message.rl" */
/* #line 227 "./ragel/thttp_parser_message.rl" */
state->cs = cs;
}
@ -253,7 +253,7 @@ static void thttp_message_parser_execute(tsk_ragel_state_t *state, thttp_message
const char *eof = state->eof;
/* #line 257 "../src/parsers/thttp_parser_message.c" */
/* #line 257 "./src/parsers/thttp_parser_message.c" */
{
int _klen;
unsigned int _trans;
@ -328,13 +328,13 @@ _match:
switch ( *_acts++ )
{
case 0:
/* #line 50 "thttp_parser_message.rl" */
/* #line 50 "./ragel/thttp_parser_message.rl" */
{
state->tag_start = p;
}
break;
case 1:
/* #line 56 "thttp_parser_message.rl" */
/* #line 56 "./ragel/thttp_parser_message.rl" */
{
int len;
state->tag_end = p;
@ -356,7 +356,7 @@ _match:
}
break;
case 2:
/* #line 78 "thttp_parser_message.rl" */
/* #line 78 "./ragel/thttp_parser_message.rl" */
{
int len;
state->tag_end = p;
@ -368,7 +368,7 @@ _match:
}
break;
case 3:
/* #line 90 "thttp_parser_message.rl" */
/* #line 90 "./ragel/thttp_parser_message.rl" */
{
int len;
state->tag_end = p;
@ -381,7 +381,7 @@ _match:
}
break;
case 4:
/* #line 103 "thttp_parser_message.rl" */
/* #line 103 "./ragel/thttp_parser_message.rl" */
{
int len;
state->tag_end = p;
@ -397,7 +397,7 @@ _match:
}
break;
case 5:
/* #line 119 "thttp_parser_message.rl" */
/* #line 119 "./ragel/thttp_parser_message.rl" */
{
int len;
state->tag_end = p;
@ -410,7 +410,7 @@ _match:
}
break;
case 6:
/* #line 132 "thttp_parser_message.rl" */
/* #line 132 "./ragel/thttp_parser_message.rl" */
{
int len;
state->tag_end = p;
@ -425,7 +425,7 @@ _match:
}
break;
case 7:
/* #line 156 "thttp_parser_message.rl" */
/* #line 156 "./ragel/thttp_parser_message.rl" */
{
state->cs = cs;
state->p = p;
@ -440,7 +440,7 @@ _match:
eof = state->eof;
}
break;
/* #line 444 "../src/parsers/thttp_parser_message.c" */
/* #line 444 "./src/parsers/thttp_parser_message.c" */
}
}
@ -453,7 +453,7 @@ _again:
_out: {}
}
/* #line 239 "thttp_parser_message.rl" */
/* #line 239 "./ragel/thttp_parser_message.rl" */
state->cs = cs;
state->p = p;

View File

@ -1,5 +1,5 @@
/* #line 1 "thttp_parser_url.rl" */
/* #line 1 "./ragel/thttp_parser_url.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
@ -39,17 +39,28 @@
* Ragel state machine.
*/
/* #line 89 "thttp_parser_url.rl" */
/* #line 89 "./ragel/thttp_parser_url.rl" */
/**@ingroup thttp_url_group
* Parses a HTTP/HTTPS url.
* @param urlstring A pointer to a valid url string. If the port is missing, then it's default value will be 443 if
* the scheme is 'https' and 80 otherwise.<br>
* @param length The length of the url string.
* @retval A well-defined object representing the url string.
*
* @code
* thttp_url_t* url = thttp_url_parse("http://www.google.com", strlen("http://www.google.com"));
* @endcode
*
* @sa @ref thttp_url_tostring<br>@ref thttp_url_serialize
**/
thttp_url_t *thttp_url_parse(const char *data, size_t size)
thttp_url_t *thttp_url_parse(const char *urlstring, size_t length)
{
int have_port = 0;
tsk_bool_t have_port = tsk_false;
int cs = 0;
const char *p = data;
const char *pe = p + size;
const char *p = urlstring;
const char *pe = p + length;
const char *eof = pe;
const char *ts = 0, *te = 0;
@ -60,7 +71,7 @@ thttp_url_t *thttp_url_parse(const char *data, size_t size)
const char *tag_start = 0;
/* #line 64 "../src/parsers/thttp_parser_url.c" */
/* #line 75 "./src/parsers/thttp_parser_url.c" */
static const char _thttp_machine_parser_url_actions[] = {
0, 1, 0, 1, 1, 1, 2, 1,
6, 1, 7, 1, 8, 1, 9, 1,
@ -262,16 +273,16 @@ static const int thttp_machine_parser_url_error = 0;
static const int thttp_machine_parser_url_en_main = 1;
/* #line 109 "thttp_parser_url.rl" */
/* #line 120 "./ragel/thttp_parser_url.rl" */
/* #line 268 "../src/parsers/thttp_parser_url.c" */
/* #line 279 "./src/parsers/thttp_parser_url.c" */
{
cs = thttp_machine_parser_url_start;
}
/* #line 110 "thttp_parser_url.rl" */
/* #line 121 "./ragel/thttp_parser_url.rl" */
/* #line 275 "../src/parsers/thttp_parser_url.c" */
/* #line 286 "./src/parsers/thttp_parser_url.c" */
{
int _klen;
unsigned int _trans;
@ -346,56 +357,56 @@ _match:
switch ( *_acts++ )
{
case 0:
/* #line 46 "thttp_parser_url.rl" */
/* #line 46 "./ragel/thttp_parser_url.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 51 "thttp_parser_url.rl" */
/* #line 51 "./ragel/thttp_parser_url.rl" */
{ url->scheme = tsk_strdup("http"), url->type = url_http; }
break;
case 2:
/* #line 52 "thttp_parser_url.rl" */
/* #line 52 "./ragel/thttp_parser_url.rl" */
{ url->scheme = tsk_strdup("https"), url->type = url_https; }
break;
case 3:
/* #line 55 "thttp_parser_url.rl" */
/* #line 55 "./ragel/thttp_parser_url.rl" */
{ url->host_type = url->host_type = host_ipv4; }
break;
case 4:
/* #line 56 "thttp_parser_url.rl" */
/* #line 56 "./ragel/thttp_parser_url.rl" */
{ url->host_type = url->host_type = host_ipv6; }
break;
case 5:
/* #line 57 "thttp_parser_url.rl" */
/* #line 57 "./ragel/thttp_parser_url.rl" */
{ url->host_type = url->host_type = host_hostname; }
break;
case 6:
/* #line 59 "thttp_parser_url.rl" */
/* #line 59 "./ragel/thttp_parser_url.rl" */
{
TSK_PARSER_SET_STRING(url->host);
}
break;
case 7:
/* #line 63 "thttp_parser_url.rl" */
/* #line 63 "./ragel/thttp_parser_url.rl" */
{
have_port = 1;
TSK_PARSER_SET_INT(url->port);
}
break;
case 8:
/* #line 68 "thttp_parser_url.rl" */
/* #line 68 "./ragel/thttp_parser_url.rl" */
{
TSK_PARSER_SET_STRING(url->hpath);
}
break;
case 10:
/* #line 76 "thttp_parser_url.rl" */
/* #line 76 "./ragel/thttp_parser_url.rl" */
{
}
break;
/* #line 399 "../src/parsers/thttp_parser_url.c" */
/* #line 410 "./src/parsers/thttp_parser_url.c" */
}
}
@ -412,37 +423,37 @@ _again:
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 0:
/* #line 46 "thttp_parser_url.rl" */
/* #line 46 "./ragel/thttp_parser_url.rl" */
{
tag_start = p;
}
break;
case 6:
/* #line 59 "thttp_parser_url.rl" */
/* #line 59 "./ragel/thttp_parser_url.rl" */
{
TSK_PARSER_SET_STRING(url->host);
}
break;
case 7:
/* #line 63 "thttp_parser_url.rl" */
/* #line 63 "./ragel/thttp_parser_url.rl" */
{
have_port = 1;
TSK_PARSER_SET_INT(url->port);
}
break;
case 8:
/* #line 68 "thttp_parser_url.rl" */
/* #line 68 "./ragel/thttp_parser_url.rl" */
{
TSK_PARSER_SET_STRING(url->hpath);
}
break;
case 9:
/* #line 72 "thttp_parser_url.rl" */
/* #line 72 "./ragel/thttp_parser_url.rl" */
{
TSK_PARSER_SET_STRING(url->search);
}
break;
/* #line 446 "../src/parsers/thttp_parser_url.c" */
/* #line 457 "./src/parsers/thttp_parser_url.c" */
}
}
}
@ -450,12 +461,12 @@ _again:
_out: {}
}
/* #line 111 "thttp_parser_url.rl" */
/* #line 122 "./ragel/thttp_parser_url.rl" */
if( cs <
/* #line 457 "../src/parsers/thttp_parser_url.c" */
/* #line 468 "./src/parsers/thttp_parser_url.c" */
63
/* #line 112 "thttp_parser_url.rl" */
/* #line 123 "./ragel/thttp_parser_url.rl" */
){
TSK_DEBUG_ERROR("Failed to parse HTTP/HTTPS URL.");
TSK_OBJECT_SAFE_FREE(url);

View File

@ -30,8 +30,12 @@
#include "tinyHTTP/thttp_action.h"
#include "tinyHTTP/thttp_event.h"
#include "tinyHTTP/thttp_message.h"
#include "tinyHTTP/parsers/thttp_parser_message.h"
#include "tinyHTTP/headers/thttp_header_Transfer_Encoding.h"
#include "tinyHTTP/thttp_dialog.h"
#include "tnet.h"
@ -53,7 +57,7 @@
// KeepAlive : http://www.io.com/~maus/HttpKeepAlive.html
/**@defgroup thttp_stack_group HTTP/HTTPS stack.
/**@defgroup thttp_stack_group HTTP/HTTPS stack
*/
/** Callback function used by the transport layer to alert the stack when new messages come.
@ -67,7 +71,10 @@ static int thttp_transport_layer_stream_cb(const tnet_transport_event_t* e)
const thttp_stack_t *stack = e->callback_data;
thttp_dialog_t* dialog = tsk_null;
thttp_session_t* session = tsk_null;
tsk_bool_t have_all_content = tsk_false;
tsk_safeobj_lock(stack);
switch(e->type){
case event_data: {
break;
@ -84,12 +91,10 @@ static int thttp_transport_layer_stream_cb(const tnet_transport_event_t* e)
return 0;
}
}
tsk_safeobj_lock(stack);
/* Gets the associated dialog */
if((session = thttp_session_get_by_fd(stack->sessions, e->fd))){
if(!(dialog = thttp_dialog_get_by_age(session->dialogs))){
if(!(dialog = thttp_dialog_get_oldest(session->dialogs))){
TSK_DEBUG_ERROR("Failed to found associated dialog.");
ret = -5;
goto bail;
@ -121,27 +126,63 @@ static int thttp_transport_layer_stream_cb(const tnet_transport_event_t* e)
tsk_ragel_state_init(&state, TSK_BUFFER_DATA(dialog->buf), endOfheaders + 4/*2CRLF*/);
if(!(ret = thttp_message_parse(&state, &message, tsk_false/* do not extract the content */)))
{
size_t clen = THTTP_MESSAGE_CONTENT_LENGTH(message); /* MUST have content-length header. */
if(clen == 0){ /* No content */
tsk_buffer_remove(dialog->buf, 0, (endOfheaders + 4/*2CRLF*/)); /* Remove HTTP headers and CRLF ==> must never happen */
}
else{ /* There is a content */
if((endOfheaders + 4/*2CRLF*/ + clen) > TSK_BUFFER_SIZE(dialog->buf)){ /* There is content but not all the content. */
TSK_DEBUG_INFO("No all HTTP content in the TCP buffer.");
goto bail;
const thttp_header_Transfer_Encoding_t* transfer_Encoding;
/* chunked? */
if((transfer_Encoding = (const thttp_header_Transfer_Encoding_t*)thttp_message_get_header(message, thttp_htype_Transfer_Encoding)) && tsk_striequals(transfer_Encoding->encoding, "chunked")){
const char* start = TSK_BUFFER_TO_U8(dialog->buf) + (endOfheaders + 4/*2CRLF*/);
const char* end = TSK_BUFFER_TO_U8(dialog->buf) + TSK_BUFFER_SIZE(dialog->buf);
int index;
TSK_DEBUG_INFO("CHUNKED transfer.");
while(start < end){
/* RFC 2616 - 19.4.6 Introduction of Transfer-Encoding */
// read chunk-size, chunk-extension (if any) and CRLF
size_t chunk_size = atoi(start);
if((index = tsk_strindexOf(start, (end-start), "\r\n")) >=0){
start += index + 2/*CRLF*/;
}
else{
TSK_DEBUG_INFO("Parsing chunked data has failed.");
break;
}
if(chunk_size == 0 && ((start + 2) <= end) && *start == '\r' && *(start+ 1) == '\n'){
have_all_content = tsk_true;
break;
}
thttp_message_append_content(message, start, chunk_size);
start += chunk_size + 2/*CRLF*/;
}
else{
/* Add the content to the message. */
thttp_message_add_content(message, tsk_null, TSK_BUFFER_TO_U8(dialog->buf) + endOfheaders + 4/*2CRLF*/, clen);
/* Remove HTTP headers, CRLF and the content. */
tsk_buffer_remove(dialog->buf, 0, (endOfheaders + 4/*2CRLF*/ + clen));
}
else{
size_t clen = THTTP_MESSAGE_CONTENT_LENGTH(message); /* MUST have content-length header. */
if(clen == 0){ /* No content */
tsk_buffer_remove(dialog->buf, 0, (endOfheaders + 4/*2CRLF*/)); /* Remove HTTP headers and CRLF ==> must never happen */
have_all_content = tsk_true;
}
else{ /* There is a content */
if((endOfheaders + 4/*2CRLF*/ + clen) > TSK_BUFFER_SIZE(dialog->buf)){ /* There is content but not all the content. */
TSK_DEBUG_INFO("No all HTTP content in the TCP buffer.");
goto bail;
}
else{
/* Add the content to the message. */
thttp_message_add_content(message, tsk_null, TSK_BUFFER_TO_U8(dialog->buf) + endOfheaders + 4/*2CRLF*/, clen);
/* Remove HTTP headers, CRLF and the content. */
tsk_buffer_remove(dialog->buf, 0, (endOfheaders + 4/*2CRLF*/ + clen));
have_all_content = tsk_true;
}
}
}
}
/* Alert the operation (FSM) */
if(message){
ret = thttp_dialog_fsm_act(dialog, atype_i_message, message, tsk_null);
if(have_all_content){ /* only if we have all data */
ret = thttp_dialog_fsm_act(dialog, atype_i_message, message, tsk_null);
}
}
bail:
@ -211,12 +252,14 @@ bail:
* The list of parameters must end with @ref THTTP_STACK_SET_NULL() even if there is no parameter.<br>
* @retval A Pointer to the newly created stack if succeed and @a Null otherwise.
* A session is a well-defined object.
*
* @code
* thttp_stack_create(callback,
* THTTP_STACK_SET_*(),
* THTTP_STACK_SET_NULL());
* @endcode
* @sa @ref thttp_stack_set.
*
* @sa @ref thttp_stack_set
*/
thttp_stack_handle_t *thttp_stack_create(thttp_stack_callback callback, ...)
{
@ -243,7 +286,7 @@ thttp_stack_handle_t *thttp_stack_create(thttp_stack_callback callback, ...)
* Starts the stack.
* @param self A pointer to the stack to start. The stack must be create using @ref thttp_stack_create.
* @retval Zero if succeed and non-zero error code otherwise.
* @sa @ref thttp_stack_stop.
* @sa @ref thttp_stack_stop
*/
int thttp_stack_start(thttp_stack_handle_t *self)
{
@ -274,6 +317,7 @@ int thttp_stack_start(thttp_stack_handle_t *self)
* @param ... Configuration parameters. You must use @a THTTP_STACK_SET_* macros to set these parameters.
* The list of parameters must end with @ref THTTP_STACK_SET_NULL() even if there is no parameter.<br>
* @retval A Pointer to the newly created stack if succeed and @a Null otherwise.
*
* @code
* thttp_stack_set(stack,
* THTTP_STACK_SET_*(),
@ -285,7 +329,7 @@ int thttp_stack_set(thttp_stack_handle_t *self, ...)
if(self){
int ret;
thttp_stack_t *stack = self;
va_list params;
va_start(params, self);
ret = __thttp_stack_set(stack, params);
@ -300,7 +344,7 @@ int thttp_stack_set(thttp_stack_handle_t *self, ...)
* Stops the stack. The stack must be already started.
* @param self A pointer to the stack to stop. The stack must be create using @ref thttp_stack_create.
* @retval Zero if succeed and non-zero error code otherwise.
* @sa @ref thttp_stack_start.
* @sa @ref thttp_stack_start
*/
int thttp_stack_stop(thttp_stack_handle_t *self)
{

View File

@ -33,9 +33,32 @@
#include "tsk_debug.h"
/**@defgroup thttp_action_group Sending Requests
*/
int thttp_action_perform(thttp_session_handle_t *session, const char* url, const char* method, ...)
/**@ingroup thttp_action_group
* Sends a custom HTTP/HTTPS request.
* @param session The @a session (or connection) to use.
* @param urlstring The Request-URI. If the url scheme is 'https', then the default port will be 443, otherwise the port value will be 80.
* @param method The method to use for the HTTP request (e.g. GET, PUT, DELETE, POST ...).
* @retval Zero if succeed and non-zero error code otherwise.
*
* @code
thttp_action_perform(session, "http://www.google.com", "GET"
// request-level parameters
THTTP_ACTION_SET_PARAM("timeout", "6000"),
// request-level headers
THTTP_ACTION_SET_HEADER("Pragma", "No-Cache"),
THTTP_ACTION_SET_HEADER("Connection", "Keep-Alive"),
// close parameters
THTTP_ACTION_SET_NULL());
* @endcode
* @sa @ref thttp_action_CONNECT<br>@ref thttp_action_DELETE<br>@ref thttp_action_GET<br>@ref thttp_action_HEAD<br>@ref thttp_action_OPTIONS<br>
* @ref thttp_action_PATCH<br>@ref thttp_action_POST<br>@ref thttp_action_PUT<br>@ref thttp_action_TRACE
*/
int thttp_action_perform(thttp_session_handle_t *session, const char* urlstring, const char* method, ...)
{
thttp_session_t* sess = session;
va_list ap;
@ -43,12 +66,12 @@ int thttp_action_perform(thttp_session_handle_t *session, const char* url, const
thttp_dialog_t* dialog;
int ret = -1;
if(!sess || !sess->stack || !url || !method){
if(!sess || !sess->stack || !urlstring || !method){
return ret;
}
va_start(ap, method);
if((action = THTTP_ACTION_CREATE(atype_o_request, url, method, &ap))){
if((action = THTTP_ACTION_CREATE(atype_o_request, urlstring, method, &ap))){
if((dialog = thttp_dialog_new(sess))){
ret = thttp_dialog_fsm_act(dialog, action->type, tsk_null, action);
@ -83,24 +106,26 @@ static tsk_object_t* thttp_action_create(tsk_object_t * self, va_list * app)
action->method = tsk_strdup(va_arg(*app, const char*));
app_2 = va_arg(*app, va_list*);
action->params = TSK_LIST_CREATE();
action->options = TSK_LIST_CREATE();
action->headers = TSK_LIST_CREATE();
while((curr=va_arg(*app_2, thttp_action_param_type_t)) != aptype_null)
{
switch(curr)
{
case aptype_param:
case aptype_option:
{
thhtp_action_option_t id = va_arg(*app_2, thhtp_action_option_t);
const char* value = va_arg(*app_2, const char *);
tsk_options_add_option(&action->options, id, value);
break;
}
case aptype_header:
{
const char* name = va_arg(*app_2, const char *);
const char* value = va_arg(*app_2, const char *);
if(curr == aptype_param){
tsk_params_add_param(&action->params, name, value);
}else{
tsk_params_add_param(&action->headers, name, value);
}
tsk_params_add_param(&action->headers, name, value);
break;
}
@ -134,7 +159,7 @@ static tsk_object_t* thttp_action_destroy(tsk_object_t * self)
TSK_FREE(action->url);
TSK_FREE(action->method);
TSK_OBJECT_SAFE_FREE(action->params);
TSK_OBJECT_SAFE_FREE(action->options);
TSK_OBJECT_SAFE_FREE(action->headers);
TSK_OBJECT_SAFE_FREE(action->payload);
}

View File

@ -57,6 +57,7 @@ extern int thttp_stack_alert(const thttp_stack_t *self, const thttp_event_t* e);
/* ======================== transitions ======================== */
int thttp_dialog_Started_2_Transfering_X_request(va_list *app);
int thttp_dialog_Transfering_2_Transfering_X_401_407(va_list *app);
int thttp_dialog_Transfering_2_Transfering_X_1xx(va_list *app);
int thttp_dialog_Transfering_2_Terminated_X_message(va_list *app); /* Any other HTTP message except 401/407 */
int thttp_dialog_Any_2_Terminated_X_closed(va_list *app);
int thttp_dialog_Any_2_Terminated_X_Error(va_list *app);
@ -64,14 +65,12 @@ int thttp_dialog_Any_2_Terminated_X_Error(va_list *app);
/* ======================== conds ======================== */
tsk_bool_t _fsm_cond_i_401_407(thttp_dialog_t* self, thttp_message_t* message)
{
return THTTP_MESSAGE_IS_RESPONSE(message)
&& (THTTP_RESPONSE_CODE(message) == 401 || THTTP_RESPONSE_CODE(message) == 407);
return (THTTP_RESPONSE_CODE(message) == 401 || THTTP_RESPONSE_CODE(message) == 407);
}
tsk_bool_t _fsm_cond_i_n401_n407(thttp_dialog_t* self, thttp_message_t* message)
tsk_bool_t _fsm_cond_i_1xx(thttp_dialog_t* self, thttp_message_t* message)
{
return !_fsm_cond_i_401_407(self, message);
return THTTP_RESPONSE_IS_1XX(message);
}
/* ======================== actions ======================== */
typedef enum _fsm_action_e
{
@ -151,6 +150,13 @@ int thttp_dialog_Transfering_2_Transfering_X_401_407(va_list *app)
return thttp_dialog_send_request(self);
}
/* Transfering -> (1xx) -> Transfering */
int thttp_dialog_Transfering_2_Transfering_X_1xx(va_list *app)
{
// reset timer?
return 0;
}
/* Transfering -> (message) -> Terminated */
int thttp_dialog_Transfering_2_Terminated_X_message(va_list *app)
{
@ -196,6 +202,8 @@ int thttp_dialog_Any_2_Terminated_X_Error(va_list *app)
// == STATE MACHINE END ==
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/** Execute action (moves the FSM).
*/
int thttp_dialog_fsm_act(thttp_dialog_t* self, tsk_fsm_action_id action_id, const thttp_message_t* message, const thttp_action_t* action)
{
if(!self || !self->fsm){
@ -204,27 +212,6 @@ int thttp_dialog_fsm_act(thttp_dialog_t* self, tsk_fsm_action_id action_id, cons
return tsk_fsm_act(self->fsm, action_id, self, message, self, message, action);
}
thttp_dialog_t* thttp_dialog_get_by_session(thttp_dialogs_L_t* dialogs, const struct thttp_session_s* session)
{
thttp_dialog_t* ret = tsk_null;
const tsk_list_item_t *item;
if(!dialogs){
goto bail;
}
tsk_list_foreach(item, dialogs)
{
if(!tsk_object_cmp(((thttp_dialog_t*)item->data)->session, session)){
ret = tsk_object_ref(item->data);
goto bail;
}
}
bail:
return ret;
}
// create new dialog and add it to the stack's list of dialogs
// you must free the returned object
thttp_dialog_t* thttp_dialog_new(thttp_session_t* session)
@ -240,7 +227,9 @@ thttp_dialog_t* thttp_dialog_new(thttp_session_t* session)
return ret;
}
thttp_dialog_t* thttp_dialog_get_by_age(thttp_dialogs_L_t* dialogs)
/** Returns the oldest dialog.
*/
thttp_dialog_t* thttp_dialog_get_oldest(thttp_dialogs_L_t* dialogs)
{
thttp_dialog_t* ret = tsk_null;
thttp_dialog_t* dialog = tsk_null;
@ -256,6 +245,8 @@ thttp_dialog_t* thttp_dialog_get_by_age(thttp_dialogs_L_t* dialogs)
return ret;
}
/** Sends a request.
*/
int thttp_dialog_send_request(thttp_dialog_t *self)
{
int ret = -1;
@ -288,12 +279,15 @@ int thttp_dialog_send_request(thttp_dialog_t *self)
THTTP_MESSAGE_ADD_HEADER(request, THTTP_HEADER_DUMMY_VA_ARGS(TSK_PARAM(item->data)->name, TSK_PARAM(item->data)->value));
}
/* ==Add headers associated to the action== */
/* ==Add headers and content associated to the action== */
if(self->action){
if(self->action->payload){
thttp_message_add_content(request, tsk_null, self->action->payload->data, self->action->payload->size);
}
tsk_list_foreach(item, self->action->headers){
THTTP_MESSAGE_ADD_HEADER(request, THTTP_HEADER_DUMMY_VA_ARGS(TSK_PARAM(item->data)->name, TSK_PARAM(item->data)->value));
}
}
}
/* ==Add creadentials== */
if(!TSK_LIST_IS_EMPTY(self->session->challenges))
@ -361,6 +355,8 @@ bail:
return ret;
}
/** Update timestamp (used to match requests with responses)
*/
int thttp_dialog_update_timestamp(thttp_dialog_t *self)
{
static uint64_t timestamp = 0;
@ -371,26 +367,18 @@ int thttp_dialog_update_timestamp(thttp_dialog_t *self)
return -1;
}
/** Called by the FSM manager when the dialog enters in the terminal state.
*/
int thttp_dialog_OnTerminated(thttp_dialog_t *self)
{
// thttp_stack_t* stack;
int ret = -1;
TSK_DEBUG_INFO("=== HTTP/HTTPS Dialog terminated ===");
/* removes the dialog from the session */
if(self->session){
tsk_list_remove_item_by_data(self->session->dialogs, self);
return 0;
}
//if(self && self->session && self->session->stack){
// /* Remove from the dialog layer. */
// stack = (thttp_stack_t*)self->session->stack;
// tsk_safeobj_lock(stack);
// tsk_list_remove_item_by_data(stack->dialogs, self);
// tsk_safeobj_unlock(stack);
// return 0;
//}
return -1;
}
@ -436,8 +424,10 @@ static tsk_object_t* thttp_dialog_create(tsk_object_t * self, va_list * app)
*/
// Transfering -> (401/407) -> Transfering
TSK_FSM_ADD(_fsm_state_Transfering, _fsm_action_message, _fsm_cond_i_401_407, _fsm_state_Transfering, thttp_dialog_Transfering_2_Transfering_X_401_407, "thttp_dialog_Transfering_2_Transfering_X_401_407"),
// Transfering -> (message-non 401/407-) -> Terminated
TSK_FSM_ADD(_fsm_state_Transfering, _fsm_action_message, _fsm_cond_i_n401_n407, _fsm_state_Terminated, thttp_dialog_Transfering_2_Terminated_X_message, "thttp_dialog_Transfering_2_Terminated_X_message"),
// Transfering -> (1xx) -> Transfering
TSK_FSM_ADD(_fsm_state_Transfering, _fsm_action_message, _fsm_cond_i_1xx, _fsm_state_Transfering, thttp_dialog_Transfering_2_Transfering_X_1xx, "thttp_dialog_Transfering_2_Transfering_X_1xx"),
// Transfering -> (any other response) -> Terminated
TSK_FSM_ADD_ALWAYS(_fsm_state_Transfering, _fsm_action_message, _fsm_state_Terminated, thttp_dialog_Transfering_2_Terminated_X_message, "thttp_dialog_Transfering_2_Terminated_X_message"),
/*=======================
* === Any ===
*/

View File

@ -32,7 +32,7 @@
#include "tsk_debug.h"
/**@defgroup thttp_message_group HTTP Message.
/**@defgroup thttp_message_group HTTP Message
*/
static int pred_find_string_by_value(const tsk_list_item_t *item, const void *stringVal)
@ -121,7 +121,7 @@ int thttp_message_add_headers(thttp_message_t *self, const thttp_headers_L_t *he
*/
int thttp_message_add_content(thttp_message_t *self, const char* content_type, const void* content, size_t size)
{
if(self)
if(self && content && size)
{
if(content_type){
TSK_OBJECT_SAFE_FREE(self->Content_Type);
@ -140,6 +140,30 @@ int thttp_message_add_content(thttp_message_t *self, const char* content_type, c
return -1;
}
/**@ingroup thttp_message_group
*/
int thttp_message_append_content(thttp_message_t *self, const void* content, size_t size)
{
if(self && content && size){
if(!self->Content){
self->Content = TSK_BUFFER_CREATE(content, size);
}
else{
tsk_buffer_append(self->Content, content, size);
}
if(!self->Content_Length){
THTTP_MESSAGE_ADD_HEADER(self, THTTP_HEADER_CONTENT_LENGTH_VA_ARGS(size));
}
else{
self->Content_Length->length += size;
}
return 0;
}
return -1;
}
/**@ingroup thttp_message_group
*/
const thttp_header_t *thttp_message_get_headerAt(const thttp_message_t *self, thttp_header_type_t type, size_t index)
@ -209,7 +233,7 @@ int thttp_message_serialize(const thttp_message_t *self, tsk_buffer_t *output)
self->url->search ? self->url->search : ""
);
/* HTTP VERSION */
tsk_buffer_appendEx(output, " %s\r\n", THTTP_MESSAGE_VERSION_DEFAULT);
tsk_buffer_appendEx(output, "%s\r\n", THTTP_MESSAGE_VERSION_DEFAULT);
/* HOST */
tsk_buffer_appendEx(output, "Host: %s:%u\r\n", self->url->host, self->url->port);
}

View File

@ -37,7 +37,7 @@
#include "tsk_debug.h"
/**@defgroup thttp_session_group HTTP Session.
/**@defgroup thttp_session_group HTTP Session
*/
/**Sets parameters.
@ -54,17 +54,19 @@ int __thttp_session_set(thttp_session_t *self, va_list* app)
{
switch(curr)
{
case sptype_param:
case sptype_option:
{
thhtp_session_option_t id = va_arg(*app, thhtp_session_option_t);
const char* value = va_arg(*app, const char *);
tsk_options_add_option(&self->options, id, value);
break;
}
case sptype_header:
{
const char* name = va_arg(*app, const char *);
const char* value = va_arg(*app, const char *);
if(curr == sptype_param){
tsk_params_add_param(&self->params, name, value);
} else if(curr == sptype_header){
tsk_params_add_param(&self->headers, name, value);
}
tsk_params_add_param(&self->headers, name, value);
break;
}
@ -113,7 +115,8 @@ thttp_session_handle_t * session = thttp_session_create(stack,
THTTP_SESSION_SET_NULL());
* @endcode
* @sa @ref thttp_session_set.
*
* @sa @ref thttp_session_set
*/
thttp_session_handle_t* thttp_session_create(const struct thttp_stack_s* stack, ...)
{
@ -148,7 +151,8 @@ int ret = thttp_session_set(session,
THTTP_SESSION_SET_NULL());
* @endcode
* @sa @ref thttp_session_create.
*
* @sa @ref thttp_session_create
*/
int thttp_session_set(thttp_session_handle_t *self, ...)
{
@ -189,7 +193,7 @@ thttp_session_id_t thttp_session_get_id(const thttp_session_handle_t *self)
* Gets the user context (user/application data).
* @param self A pointer to the session from which to get the context.
* @retval A pointer to the context. Previously defined by using @ref THTTP_SESSION_SET_CONTEXT() macro.
* @sa @ref THTTP_SESSION_SET_CONTEXT.
* @sa @ref THTTP_SESSION_SET_CONTEXT
*/
const void* thttp_session_get_context(const thttp_session_handle_t *self)
{
@ -203,7 +207,7 @@ const void* thttp_session_get_context(const thttp_session_handle_t *self)
*/
int thttp_session_update_challenges(thttp_session_t *self, const thttp_response_t* response, tsk_bool_t first)
{
int ret = -1;
int ret = 0;
size_t i;
tsk_list_item_t *item;
@ -213,6 +217,8 @@ int thttp_session_update_challenges(thttp_session_t *self, const thttp_response_
const thttp_header_WWW_Authenticate_t *WWW_Authenticate;
const thttp_header_Proxy_Authenticate_t *Proxy_Authenticate;
tsk_safeobj_lock(self);
/* RFC 2617 - Digest Operation
* (A) The client response to a WWW-Authenticate challenge for a protection
@ -257,7 +263,8 @@ int thttp_session_update_challenges(thttp_session_t *self, const thttp_response_
}
}
else{
return -1;
ret = -1;
goto bail;
}
}
@ -272,7 +279,8 @@ int thttp_session_update_challenges(thttp_session_t *self, const thttp_response_
tsk_list_push_back_data(self->challenges, (void**)&challenge);
}
else{
return -1;
ret = -1;
goto bail;
}
}
}
@ -295,14 +303,17 @@ int thttp_session_update_challenges(thttp_session_t *self, const thttp_response_
Proxy_Authenticate->algorithm,
Proxy_Authenticate->qop)))
{
return ret;
goto bail;
}
else{
isnew = tsk_false;
continue;
}
}
else return -1;
else{
ret = -1;
goto bail;
}
}
if(isnew){
@ -317,11 +328,15 @@ int thttp_session_update_challenges(thttp_session_t *self, const thttp_response_
tsk_list_push_back_data(self->challenges, (void**)&challenge);
}
else{
return -1;
ret = -1;
goto bail;
}
}
}
return 0;
}
bail:
tsk_safeobj_unlock(self);
return ret;
}
@ -335,10 +350,16 @@ int thttp_session_signal_closed(thttp_session_t *self)
return -1;
}
tsk_safeobj_lock(self);
tsk_list_foreach(item, self->dialogs){
thttp_dialog_fsm_act((thttp_dialog_t*)item->data, atype_closed, tsk_null, tsk_null);
// FIXME: not thread-safe
//--thttp_dialog_fsm_act((thttp_dialog_t*)item->data, atype_closed, tsk_null, tsk_null);
}
self->fd = TNET_INVALID_FD;
tsk_safeobj_unlock(self);
return 0;
}
@ -352,7 +373,7 @@ thttp_session_t* thttp_session_get_by_fd(thttp_sessions_L_t* sessions, tnet_fd_t
if(!sessions){
goto bail;
}
tsk_list_foreach(item, sessions){
if(((thttp_session_t*)item->data)->fd == fd){
ret = tsk_object_ref(item->data);
@ -375,8 +396,10 @@ static tsk_object_t* _thttp_session_create(tsk_object_t * self, va_list * app)
thttp_session_t *session = self;
static thttp_session_id_t unique_id = 0;
if(session){
tsk_safeobj_init(session);
session->stack = va_arg(*app, const thttp_stack_handle_t*);
session->params = TSK_LIST_CREATE();
session->options = TSK_LIST_CREATE();
session->headers = TSK_LIST_CREATE();
session->challenges = TSK_LIST_CREATE();
session->dialogs = TSK_LIST_CREATE();
@ -404,7 +427,7 @@ static tsk_object_t* thttp_session_destroy(tsk_object_t * self)
tsk_list_remove_item_by_data(session->stack->sessions, session);
}
TSK_OBJECT_SAFE_FREE(session->params);
TSK_OBJECT_SAFE_FREE(session->options);
TSK_OBJECT_SAFE_FREE(session->headers);
TSK_OBJECT_SAFE_FREE(session->challenges);
TSK_OBJECT_SAFE_FREE(session->dialogs);
@ -419,6 +442,8 @@ static tsk_object_t* thttp_session_destroy(tsk_object_t * self)
tnet_sockfd_close(&session->fd);
}
}
tsk_safeobj_deinit(session);
}
return self;
}

View File

@ -37,7 +37,7 @@
#include <string.h>
/**@defgroup thttp_url_group HTTP/HTTPS URL.
/**@defgroup thttp_url_group HTTP/HTTPS URL
*/
/**@ingroup thttp_url_group

View File

@ -24,12 +24,14 @@
#include <stdlib.h>
#include <assert.h>
#include "tsk.h"
#include "tnet.h"
//#include "tsk.h"
//#include "tnet.h"
#include "thttp.h"
#include "tinyHTTP/thttp_message.h"
#include "tinyHTTP/auth/thttp_auth.h"
#include "tinyhttp.h"
//#include "thttp.h"
//#include "tinyHTTP/thttp_message.h"
//#include "tinyHTTP/auth/thttp_auth.h"
#define LOOP 1

View File

@ -32,7 +32,7 @@ struct auth_basic_msg
struct auth_basic_msg auth_basic_msgs[] =
{
{ "Aladdin", "open sesame", "QWxhZGRpbjpvcGVuIHNlc2FtZQ==" },
{ "Aladdin"/*Ali baba*/, "open sesame", "QWxhZGRpbjpvcGVuIHNlc2FtZQ==" },
};
void test_basic_auth()

View File

@ -22,8 +22,6 @@
#ifndef _TEST_MESSAGES_H_
#define _TEST_MESSAGES_H_
#include "tinyHTTP/parsers/thttp_parser_message.h"
#define TEST_MSG_200 \
"HTTP/1.1 200 OK\r\n" \
"Date: Wed, 10 Mar 2010 13:37:13 GMT\r\n" \
@ -43,7 +41,7 @@
"HTTP/1.1 401 Unauthorized\r\n" \
"Server: Apache-Coyote/1.1\r\n" \
"WWW-Authenticate: Digest realm=\"example.com\", qop=\"auth\", nonce=\"f39d20a4dbfbd32d943de9b285d59a30\", opaque=\"c5ad02feb52eb050e464cec3740c0f2e\"\r\n" \
"Content-Length: 0\r\n" \
"Transfer-Encoding: chunked;test=21;tes7\r\n" \
"Date: Wed, 10 Mar 2010 14:20:47 GMT\r\n" \
"\r\n"
@ -62,7 +60,7 @@ void test_messages()
tsk_buffer_t *buffer = TSK_BUFFER_CREATE_NULL();
/* serialize the message */
thttp_message_tostring(message, buffer);
thttp_message_serialize(message, buffer);
TSK_DEBUG_INFO("HTTP Message=\n%s", TSK_BUFFER_TO_STRING(buffer));
TSK_OBJECT_SAFE_FREE(buffer);

View File

@ -22,8 +22,6 @@
#ifndef _TEST_STACK_H_
#define _TEST_STACK_H_
#include "tinyhttp.h"
int test_stack_callback(const thttp_event_t *httpevent)
{
thttp_session_id_t id = thttp_session_get_id(httpevent->session);
@ -57,6 +55,10 @@ int test_stack_callback(const thttp_event_t *httpevent)
return 0;
}
#define PAYLOAD "<entry uri=\"sip:samba@micromethod.com\" xmlns=\"urn:ietf:params:xml:ns:resource-lists\">" \
"<display-name>samba</display-name>" \
"</entry>"
void test_stack()
{
thttp_session_handle_t *session = tsk_null;
@ -87,14 +89,14 @@ void test_stack()
/* creates session */
session = thttp_session_create(stack,
// session-level parameters
THTTP_SESSION_SET_PARAM("timeout", "6000"),
// session-level options
THTTP_SESSION_SET_OPTION(THTTP_SESSION_OPTION_TIMEOUT, "6000"),
// session-level headers
THTTP_SESSION_SET_HEADER("Pragma", "No-Cache"),
THTTP_SESSION_SET_HEADER("Connection", "Keep-Alive"),
THTTP_SESSION_SET_HEADER("User-Agent", "XDM-client/OMA1.1"),
THTTP_SESSION_SET_HEADER("X-3GPP-Intended-Identity", "sip:mercuro1@colibria.com"),
THTTP_SESSION_SET_HEADER("X-3GPP-Intended-Identity", "sip:mamadou@micromethod.com"),
THTTP_SESSION_SET_NULL()); /* MUST always be present */
@ -103,11 +105,42 @@ void test_stack()
THTTP_SESSION_SET_CRED("sip:mercuro1@colibria.com", "mercuro13"),
THTTP_SESSION_SET_NULL());
//thttp_action_GET(session, "http://ipv6.google.com",
// THTTP_ACTION_SET_HEADER("Content-Type", "application/resource-lists+xml"),
/*
thttp_action_GET(session, "http://ipv6.google.com",
// action-level options
THTTP_ACTION_SET_OPTION(THTTP_ACTION_OPTION_TIMEOUT, "2500"),
// THTTP_ACTION_SET_NULL());
// action-level headers
THTTP_ACTION_SET_HEADER("User-Agent", "XDM-client/OMA1.1"),
THTTP_ACTION_SET_HEADER("Connection", "Keep-Alive"),
THTTP_ACTION_SET_NULL());
*/
/*
ret = thttp_action_GET(session, "http://192.168.16.104:8080/services/xcap-caps/global/index",
// action-level options
THTTP_ACTION_SET_OPTION(THTTP_ACTION_OPTION_TIMEOUT, "2500"),
// action-level headers
THTTP_ACTION_SET_HEADER("Content-Type", "application/xcap-caps+xml"),
THTTP_ACTION_SET_NULL());
*/
ret = thttp_action_PUT(session, "http://192.168.16.104:8080/services/resource-lists/users/sip:mamadou@micromethod.com/index/~~/resource-lists/list%5B@name=%22rcs%22%5D/entry%5B@uri=%22sip%3Asamba%40micromethod.com%22%5D",
// action-level options
THTTP_ACTION_SET_OPTION(THTTP_ACTION_OPTION_TIMEOUT, "2500"),
// Payload
THTTP_ACTION_SET_PAYLOAD(PAYLOAD, strlen(PAYLOAD)),
// action-level headers
THTTP_ACTION_SET_HEADER("Content-Type", " application/xcap-el+xml"),
THTTP_ACTION_SET_HEADER("Expect", "100-continue"),
THTTP_ACTION_SET_NULL());
getchar();
//thttp_action_GET(session, "http://www.google.com",
//THTTP_ACTION_SET_HEADER("Content-Type", "application/resource-lists+xml"),

View File

@ -7,10 +7,12 @@
</compound>
<compound kind="file">
<name>thttp.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/</path>
<path>C:/doubango/tinyHTTP/include/</path>
<filename>thttp_8h</filename>
<includes id="thttp_8h" name="thttp.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="thttp__event_8h" name="thttp_event.h" local="yes" imported="no">tinyHTTP/thttp_event.h</includes>
<includes id="thttp__header_8h" name="thttp_header.h" local="yes" imported="no">tinyHTTP/headers/thttp_header.h</includes>
<includes id="thttp__message_8h" name="thttp_message.h" local="yes" imported="no">tinyHTTP/thttp_message.h</includes>
<includes id="thttp__session_8h" name="thttp_session.h" local="yes" imported="no">tinyHTTP/thttp_session.h</includes>
<class kind="struct">thttp_stack_s</class>
<member kind="define">
@ -112,14 +114,16 @@
</compound>
<compound kind="file">
<name>tinyhttp.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/</path>
<path>C:/doubango/tinyHTTP/include/</path>
<filename>tinyhttp_8h</filename>
<includes id="thttp_8h" name="thttp.h" local="yes" imported="no">thttp.h</includes>
<includes id="thttp__action_8h" name="thttp_action.h" local="yes" imported="no">tinyHTTP/thttp_action.h</includes>
<includes id="tinyhttp_8h" name="tinyhttp.h" local="yes" imported="no">thttp.h</includes>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="thttp__event_8h" name="thttp_event.h" local="yes" imported="no">tinyHTTP/thttp_event.h</includes>
<includes id="thttp__session_8h" name="thttp_session.h" local="yes" imported="no">tinyHTTP/thttp_session.h</includes>
</compound>
<compound kind="file">
<name>thttp_auth.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/auth/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/auth/</path>
<filename>thttp__auth_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<member kind="define">
@ -174,7 +178,7 @@
</compound>
<compound kind="file">
<name>thttp_challenge.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/auth/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/auth/</path>
<filename>thttp__challenge_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="thttp__message_8h" name="thttp_message.h" local="yes" imported="no">tinyHTTP/thttp_message.h</includes>
@ -226,7 +230,7 @@
</compound>
<compound kind="file">
<name>thttp_header.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/headers/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/headers/</path>
<filename>thttp__header_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<class kind="struct">thttp_header_s</class>
@ -365,7 +369,7 @@
</compound>
<compound kind="file">
<name>thttp_header_Authorization.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/headers/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/headers/</path>
<filename>thttp__header___authorization_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="thttp__header_8h" name="thttp_header.h" local="yes" imported="no">tinyHTTP/headers/thttp_header.h</includes>
@ -415,7 +419,7 @@
</compound>
<compound kind="file">
<name>thttp_header_Content_Length.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/headers/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/headers/</path>
<filename>thttp__header___content___length_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="thttp__header_8h" name="thttp_header.h" local="yes" imported="no">tinyHTTP/headers/thttp_header.h</includes>
@ -458,7 +462,7 @@
</compound>
<compound kind="file">
<name>thttp_header_Content_Type.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/headers/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/headers/</path>
<filename>thttp__header___content___type_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="thttp__header_8h" name="thttp_header.h" local="yes" imported="no">tinyHTTP/headers/thttp_header.h</includes>
@ -508,7 +512,7 @@
</compound>
<compound kind="file">
<name>thttp_header_Dummy.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/headers/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/headers/</path>
<filename>thttp__header___dummy_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="thttp__header_8h" name="thttp_header.h" local="yes" imported="no">tinyHTTP/headers/thttp_header.h</includes>
@ -558,7 +562,7 @@
</compound>
<compound kind="file">
<name>thttp_header_WWW_Authenticate.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/headers/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/headers/</path>
<filename>thttp__header___w_w_w___authenticate_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="thttp__header_8h" name="thttp_header.h" local="yes" imported="no">tinyHTTP/headers/thttp_header.h</includes>
@ -608,7 +612,7 @@
</compound>
<compound kind="file">
<name>thttp_parser_header.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/parsers/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/parsers/</path>
<filename>thttp__parser__header_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="thttp__message_8h" name="thttp_message.h" local="yes" imported="no">tinyHTTP/thttp_message.h</includes>
@ -622,7 +626,7 @@
</compound>
<compound kind="file">
<name>thttp_parser_message.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/parsers/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/parsers/</path>
<filename>thttp__parser__message_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="thttp__message_8h" name="thttp_message.h" local="yes" imported="no">tinyHTTP/thttp_message.h</includes>
@ -636,7 +640,7 @@
</compound>
<compound kind="file">
<name>thttp_parser_url.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/parsers/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/parsers/</path>
<filename>thttp__parser__url_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="thttp__url_8h" name="thttp_url.h" local="yes" imported="no">tinyHTTP/thttp_url.h</includes>
@ -644,13 +648,13 @@
<type>THTTP_BEGIN_DECLS TINYHTTP_API thttp_url_t *</type>
<name>thttp_url_parse</name>
<anchorfile>group__thttp__url__group.html</anchorfile>
<anchor>ga0b2cf9c8367c5af17d76a0a29018eda5</anchor>
<anchor>ga1acfdcf4d31969aa3de457b88f8178bb</anchor>
<arglist>(const char *data, size_t size)</arglist>
</member>
</compound>
<compound kind="file">
<name>thttp_action.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/</path>
<filename>thttp__action_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="thttp__session_8h" name="thttp_session.h" local="yes" imported="no">tinyHTTP/thttp_session.h</includes>
@ -659,8 +663,8 @@
<type>#define</type>
<name>THTTP_ACTION_CREATE</name>
<anchorfile>thttp__action_8h.html</anchorfile>
<anchor>a8ec6c3e1392adb475b10a938422ea3ed</anchor>
<arglist>(type, url, method, app)</arglist>
<anchor>a2a994783691c6b5ead24f1ac7db21c58</anchor>
<arglist>(type, urlstring, method, app)</arglist>
</member>
<member kind="define">
<type>#define</type>
@ -679,93 +683,93 @@
<member kind="define">
<type>#define</type>
<name>THTTP_ACTION_SET_PARAM</name>
<anchorfile>thttp__action_8h.html</anchorfile>
<anchor>ad93eb89d30c8892263037a222bcc5b67</anchor>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>gad93eb89d30c8892263037a222bcc5b67</anchor>
<arglist>(NAME_STR, VALUE_STR)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>THTTP_ACTION_SET_HEADER</name>
<anchorfile>thttp__action_8h.html</anchorfile>
<anchor>a276d6118d0038e4bdab2a02027c53c4e</anchor>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga276d6118d0038e4bdab2a02027c53c4e</anchor>
<arglist>(NAME_STR, VALUE_STR)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>THTTP_ACTION_SET_PAYLOAD</name>
<anchorfile>thttp__action_8h.html</anchorfile>
<anchor>ab54688c397a0df38f72e19d3e761513c</anchor>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>gab54688c397a0df38f72e19d3e761513c</anchor>
<arglist>(PAY_PTR, PAY_SIZE)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>THTTP_ACTION_SET_NULL</name>
<anchorfile>thttp__action_8h.html</anchorfile>
<anchor>a168e5e2a98540e218c15868f86cf494f</anchor>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga168e5e2a98540e218c15868f86cf494f</anchor>
<arglist>()</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_CONNECT</name>
<anchorfile>thttp__action_8h.html</anchorfile>
<anchor>a6ee1904c9170460c4339f5c458912f58</anchor>
<arglist>(session, url,...)</arglist>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>gad1a804068d4f970d35b62506405bb1b9</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_DELETE</name>
<anchorfile>thttp__action_8h.html</anchorfile>
<anchor>a8215a1fc2bf58c43abddfd12dc9b5181</anchor>
<arglist>(session, url,...)</arglist>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>gae4dc4de16832e1756213d8f2a60c286d</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_GET</name>
<anchorfile>thttp__action_8h.html</anchorfile>
<anchor>aa1ff25c6cb821f33392a9e3e0509bd65</anchor>
<arglist>(session, url,...)</arglist>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga25a8af4242b64342c590ef5ee8db56b4</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_HEAD</name>
<anchorfile>thttp__action_8h.html</anchorfile>
<anchor>a0f7b282ad742b9ecbc427ce608a9c47c</anchor>
<arglist>(session, url,...)</arglist>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga659e821e8419c3046b89480cdd3cdaec</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_OPTIONS</name>
<anchorfile>thttp__action_8h.html</anchorfile>
<anchor>af1e96fa1e316f338274732741847c5e0</anchor>
<arglist>(session, url,...)</arglist>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga6b5adbcce3f8d0bd215ff75f1c9f59cf</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_PATCH</name>
<anchorfile>thttp__action_8h.html</anchorfile>
<anchor>a71ad7cce017d3e3dcb9b28007a3d618f</anchor>
<arglist>(session, url,...)</arglist>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga95836da9e16ff5bb6ad7e7cea186d760</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_POST</name>
<anchorfile>thttp__action_8h.html</anchorfile>
<anchor>aca1ffd8bea8dea15373760e6c47cdc4d</anchor>
<arglist>(session, url,...)</arglist>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga34c6edcf5b07069d79ced7d2a99b3a2f</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_PUT</name>
<anchorfile>thttp__action_8h.html</anchorfile>
<anchor>a1be8637835119b9a1a7dd0c5b6a5cf7b</anchor>
<arglist>(session, url,...)</arglist>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>gaa0ebc1d07393d144d54319044d33911a</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_TRACE</name>
<anchorfile>thttp__action_8h.html</anchorfile>
<anchor>ad9f06792588a9a4991cc2847bcff1565</anchor>
<arglist>(session, url,...)</arglist>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga99cf9ae9b1e646d8d54dc07f841ae52a</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="typedef">
<type>uint64_t</type>
@ -878,9 +882,9 @@
<member kind="function">
<type>TINYHTTP_API int</type>
<name>thttp_action_perform</name>
<anchorfile>thttp__action_8h.html</anchorfile>
<anchor>a204a9fd37fb050c638dbb804cab2bccc</anchor>
<arglist>(thttp_session_handle_t *session, const char *url, const char *method,...)</arglist>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga36b1aa78a24305f56973f370f356236d</anchor>
<arglist>(thttp_session_handle_t *session, const char *urlstring, const char *method,...)</arglist>
</member>
<member kind="variable">
<type>TINYHTTP_GEXTERN const tsk_object_def_t *</type>
@ -892,7 +896,7 @@
</compound>
<compound kind="file">
<name>thttp_dialog.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/</path>
<filename>thttp__dialog_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<class kind="struct">thttp_dialog_s</class>
@ -955,7 +959,7 @@
</compound>
<compound kind="file">
<name>thttp_event.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/</path>
<filename>thttp__event_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="thttp__session_8h" name="thttp_session.h" local="yes" imported="no">tinyHTTP/thttp_session.h</includes>
@ -1029,7 +1033,7 @@
</compound>
<compound kind="file">
<name>thttp_message.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/</path>
<filename>thttp__message_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="thttp__url_8h" name="thttp_url.h" local="yes" imported="no">tinyHTTP/thttp_url.h</includes>
@ -1364,7 +1368,7 @@
</compound>
<compound kind="file">
<name>thttp_session.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/</path>
<filename>thttp__session_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<includes id="thttp__challenge_8h" name="thttp_challenge.h" local="yes" imported="no">tinyHTTP/auth/thttp_challenge.h</includes>
@ -1550,7 +1554,7 @@
</compound>
<compound kind="file">
<name>thttp_url.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/tinyHTTP/</path>
<path>C:/doubango/tinyHTTP/include/tinyHTTP/</path>
<filename>thttp__url_8h</filename>
<includes id="tinyhttp__config_8h" name="tinyhttp_config.h" local="yes" imported="no">tinyHTTP_config.h</includes>
<class kind="struct">thttp_url_s</class>
@ -1674,7 +1678,7 @@
</compound>
<compound kind="file">
<name>tinyhttp_config.h</name>
<path>C:/Projects/Doubango/tinyHTTP/include/</path>
<path>C:/doubango/tinyHTTP/include/</path>
<filename>tinyhttp__config_8h</filename>
<member kind="define">
<type>#define</type>
@ -1707,7 +1711,7 @@
</compound>
<compound kind="file">
<name>thttp_auth.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/auth/</path>
<path>C:/doubango/tinyHTTP/src/auth/</path>
<filename>thttp__auth_8c</filename>
<includes id="thttp__auth_8h" name="thttp_auth.h" local="yes" imported="no">tinyHTTP/auth/thttp_auth.h</includes>
<member kind="function">
@ -1748,7 +1752,7 @@
</compound>
<compound kind="file">
<name>thttp_challenge.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/auth/</path>
<path>C:/doubango/tinyHTTP/src/auth/</path>
<filename>thttp__challenge_8c</filename>
<includes id="thttp__challenge_8h" name="thttp_challenge.h" local="yes" imported="no">tinyHTTP/auth/thttp_challenge.h</includes>
<includes id="thttp_8h" name="thttp.h" local="yes" imported="no">thttp.h</includes>
@ -1819,7 +1823,7 @@
</compound>
<compound kind="file">
<name>thttp_header.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/headers/</path>
<path>C:/doubango/tinyHTTP/src/headers/</path>
<filename>thttp__header_8c</filename>
<includes id="thttp__header_8h" name="thttp_header.h" local="yes" imported="no">tinyHTTP/headers/thttp_header.h</includes>
<includes id="thttp__header___dummy_8h" name="thttp_header_Dummy.h" local="yes" imported="no">tinyHTTP/headers/thttp_header_Dummy.h</includes>
@ -1861,7 +1865,7 @@
</compound>
<compound kind="file">
<name>thttp_header_Authorization.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/headers/</path>
<path>C:/doubango/tinyHTTP/src/headers/</path>
<filename>thttp__header___authorization_8c</filename>
<includes id="thttp__header___authorization_8h" name="thttp_header_Authorization.h" local="yes" imported="no">tinyHTTP/headers/thttp_header_Authorization.h</includes>
<includes id="thttp__parser__url_8h" name="thttp_parser_url.h" local="yes" imported="no">tinyHTTP/parsers/thttp_parser_url.h</includes>
@ -1896,7 +1900,7 @@
</compound>
<compound kind="file">
<name>thttp_header_Content_Length.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/headers/</path>
<path>C:/doubango/tinyHTTP/src/headers/</path>
<filename>thttp__header___content___length_8c</filename>
<includes id="thttp__header___content___length_8h" name="thttp_header_Content_Length.h" local="yes" imported="no">tinyHTTP/headers/thttp_header_Content_Length.h</includes>
<member kind="function">
@ -1923,7 +1927,7 @@
</compound>
<compound kind="file">
<name>thttp_header_Content_Type.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/headers/</path>
<path>C:/doubango/tinyHTTP/src/headers/</path>
<filename>thttp__header___content___type_8c</filename>
<includes id="thttp__header___content___type_8h" name="thttp_header_Content_Type.h" local="yes" imported="no">tinyHTTP/headers/thttp_header_Content_Type.h</includes>
<member kind="function">
@ -1950,7 +1954,7 @@
</compound>
<compound kind="file">
<name>thttp_header_Dummy.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/headers/</path>
<path>C:/doubango/tinyHTTP/src/headers/</path>
<filename>thttp__header___dummy_8c</filename>
<member kind="function">
<type>int</type>
@ -1976,7 +1980,7 @@
</compound>
<compound kind="file">
<name>thttp_header_WWW_Authenticate.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/headers/</path>
<path>C:/doubango/tinyHTTP/src/headers/</path>
<filename>thttp__header___w_w_w___authenticate_8c</filename>
<includes id="thttp__header___w_w_w___authenticate_8h" name="thttp_header_WWW_Authenticate.h" local="yes" imported="no">tinyHTTP/headers/thttp_header_WWW_Authenticate.h</includes>
<includes id="thttp__parser__url_8h" name="thttp_parser_url.h" local="yes" imported="no">tinyHTTP/parsers/thttp_parser_url.h</includes>
@ -2011,7 +2015,7 @@
</compound>
<compound kind="file">
<name>thttp_parser_header.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/parsers/</path>
<path>C:/doubango/tinyHTTP/src/parsers/</path>
<filename>thttp__parser__header_8c</filename>
<includes id="thttp__parser__header_8h" name="thttp_parser_header.h" local="yes" imported="no">tinyHTTP/parsers/thttp_parser_header.h</includes>
<includes id="thttp__header___authorization_8h" name="thttp_header_Authorization.h" local="yes" imported="no">tinyHTTP/headers/thttp_header_Authorization.h</includes>
@ -2041,7 +2045,7 @@
</compound>
<compound kind="file">
<name>thttp_parser_message.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/parsers/</path>
<path>C:/doubango/tinyHTTP/src/parsers/</path>
<filename>thttp__parser__message_8c</filename>
<includes id="thttp__parser__message_8h" name="thttp_parser_message.h" local="yes" imported="no">tinyHTTP/parsers/thttp_parser_message.h</includes>
<includes id="thttp__parser__header_8h" name="thttp_parser_header.h" local="yes" imported="no">tinyHTTP/parsers/thttp_parser_header.h</includes>
@ -2056,20 +2060,20 @@
</compound>
<compound kind="file">
<name>thttp_parser_url.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/parsers/</path>
<path>C:/doubango/tinyHTTP/src/parsers/</path>
<filename>thttp__parser__url_8c</filename>
<includes id="thttp__parser__url_8h" name="thttp_parser_url.h" local="yes" imported="no">tinyHTTP/parsers/thttp_parser_url.h</includes>
<member kind="function">
<type>thttp_url_t *</type>
<name>thttp_url_parse</name>
<anchorfile>group__thttp__url__group.html</anchorfile>
<anchor>ga0b2cf9c8367c5af17d76a0a29018eda5</anchor>
<arglist>(const char *data, size_t size)</arglist>
<anchor>ga1acfdcf4d31969aa3de457b88f8178bb</anchor>
<arglist>(const char *urlstring, size_t length)</arglist>
</member>
</compound>
<compound kind="file">
<name>thttp.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/</path>
<path>C:/doubango/tinyHTTP/src/</path>
<filename>thttp_8c</filename>
<includes id="thttp_8h" name="thttp.h" local="yes" imported="no">thttp.h</includes>
<includes id="thttp__action_8h" name="thttp_action.h" local="yes" imported="no">tinyHTTP/thttp_action.h</includes>
@ -2129,16 +2133,16 @@
</compound>
<compound kind="file">
<name>thttp_action.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/</path>
<path>C:/doubango/tinyHTTP/src/</path>
<filename>thttp__action_8c</filename>
<includes id="thttp__action_8h" name="thttp_action.h" local="yes" imported="no">tinyHTTP/thttp_action.h</includes>
<includes id="thttp_8h" name="thttp.h" local="yes" imported="no">thttp.h</includes>
<member kind="function">
<type>int</type>
<name>thttp_action_perform</name>
<anchorfile>thttp__action_8c.html</anchorfile>
<anchor>adf3e845ae6587eb3d23e4b450d687aea</anchor>
<arglist>(thttp_session_handle_t *session, const char *url, const char *method,...)</arglist>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga36b1aa78a24305f56973f370f356236d</anchor>
<arglist>(thttp_session_handle_t *session, const char *urlstring, const char *method,...)</arglist>
</member>
<member kind="variable">
<type>const tsk_object_def_t *</type>
@ -2150,7 +2154,7 @@
</compound>
<compound kind="file">
<name>thttp_dialog.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/</path>
<path>C:/doubango/tinyHTTP/src/</path>
<filename>thttp__dialog_8c</filename>
<includes id="thttp__dialog_8h" name="thttp_dialog.h" local="yes" imported="no">tinyHTTP/thttp_dialog.h</includes>
<includes id="thttp_8h" name="thttp.h" local="yes" imported="no">thttp.h</includes>
@ -2368,7 +2372,7 @@
</compound>
<compound kind="file">
<name>thttp_event.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/</path>
<path>C:/doubango/tinyHTTP/src/</path>
<filename>thttp__event_8c</filename>
<includes id="thttp__event_8h" name="thttp_event.h" local="yes" imported="no">tinyHTTP/thttp_event.h</includes>
<includes id="thttp__message_8h" name="thttp_message.h" local="yes" imported="no">tinyHTTP/thttp_message.h</includes>
@ -2382,7 +2386,7 @@
</compound>
<compound kind="file">
<name>thttp_message.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/</path>
<path>C:/doubango/tinyHTTP/src/</path>
<filename>thttp__message_8c</filename>
<includes id="thttp__message_8h" name="thttp_message.h" local="yes" imported="no">tinyHTTP/thttp_message.h</includes>
<member kind="define">
@ -2465,7 +2469,7 @@
</compound>
<compound kind="file">
<name>thttp_session.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/</path>
<path>C:/doubango/tinyHTTP/src/</path>
<filename>thttp__session_8c</filename>
<includes id="thttp__session_8h" name="thttp_session.h" local="yes" imported="no">tinyHTTP/thttp_session.h</includes>
<includes id="thttp_8h" name="thttp.h" local="yes" imported="no">thttp.h</includes>
@ -2538,7 +2542,7 @@
</compound>
<compound kind="file">
<name>thttp_url.c</name>
<path>C:/Projects/Doubango/tinyHTTP/src/</path>
<path>C:/doubango/tinyHTTP/src/</path>
<filename>thttp__url_8c</filename>
<includes id="thttp__url_8h" name="thttp_url.h" local="yes" imported="no">tinyHTTP/thttp_url.h</includes>
<includes id="thttp__parser__url_8h" name="thttp_parser_url.h" local="yes" imported="no">tinyHTTP/parsers/thttp_parser_url.h</includes>
@ -2573,7 +2577,7 @@
</compound>
<compound kind="group">
<name>thttp_auth_group</name>
<title>HTTP basic/digest authentication (RFC 2617).</title>
<title>HTTP basic/digest authentication (RFC 2617)</title>
<filename>group__thttp__auth__group.html</filename>
<member kind="function">
<type>size_t</type>
@ -2613,7 +2617,7 @@
</compound>
<compound kind="group">
<name>thttp_header_group</name>
<title>HTTP Headers.</title>
<title>HTTP Headers</title>
<filename>group__thttp__header__group.html</filename>
<member kind="function">
<type>int</type>
@ -2674,7 +2678,7 @@
</compound>
<compound kind="group">
<name>thttp_stack_group</name>
<title>HTTP/HTTPS stack.</title>
<title>HTTP/HTTPS stack</title>
<filename>group__thttp__stack__group.html</filename>
<member kind="function">
<type>thttp_stack_handle_t *</type>
@ -2705,9 +2709,112 @@
<arglist>(thttp_stack_handle_t *self)</arglist>
</member>
</compound>
<compound kind="group">
<name>thttp_action_group</name>
<title>Sending Requests</title>
<filename>group__thttp__action__group.html</filename>
<member kind="define">
<type>#define</type>
<name>THTTP_ACTION_SET_PARAM</name>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>gad93eb89d30c8892263037a222bcc5b67</anchor>
<arglist>(NAME_STR, VALUE_STR)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>THTTP_ACTION_SET_HEADER</name>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga276d6118d0038e4bdab2a02027c53c4e</anchor>
<arglist>(NAME_STR, VALUE_STR)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>THTTP_ACTION_SET_PAYLOAD</name>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>gab54688c397a0df38f72e19d3e761513c</anchor>
<arglist>(PAY_PTR, PAY_SIZE)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>THTTP_ACTION_SET_NULL</name>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga168e5e2a98540e218c15868f86cf494f</anchor>
<arglist>()</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_CONNECT</name>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>gad1a804068d4f970d35b62506405bb1b9</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_DELETE</name>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>gae4dc4de16832e1756213d8f2a60c286d</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_GET</name>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga25a8af4242b64342c590ef5ee8db56b4</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_HEAD</name>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga659e821e8419c3046b89480cdd3cdaec</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_OPTIONS</name>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga6b5adbcce3f8d0bd215ff75f1c9f59cf</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_PATCH</name>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga95836da9e16ff5bb6ad7e7cea186d760</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_POST</name>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga34c6edcf5b07069d79ced7d2a99b3a2f</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_PUT</name>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>gaa0ebc1d07393d144d54319044d33911a</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>thttp_action_TRACE</name>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga99cf9ae9b1e646d8d54dc07f841ae52a</anchor>
<arglist>(session, urlstring,...)</arglist>
</member>
<member kind="function">
<type>int</type>
<name>thttp_action_perform</name>
<anchorfile>group__thttp__action__group.html</anchorfile>
<anchor>ga36b1aa78a24305f56973f370f356236d</anchor>
<arglist>(thttp_session_handle_t *session, const char *urlstring, const char *method,...)</arglist>
</member>
</compound>
<compound kind="group">
<name>thttp_message_group</name>
<title>HTTP Message.</title>
<title>HTTP Message</title>
<filename>group__thttp__message__group.html</filename>
<class kind="struct">thttp_message_s</class>
<member kind="define">
@ -2947,7 +3054,7 @@
</compound>
<compound kind="group">
<name>thttp_session_group</name>
<title>HTTP Session.</title>
<title>HTTP Session</title>
<filename>group__thttp__session__group.html</filename>
<member kind="define">
<type>#define</type>
@ -3015,7 +3122,7 @@
</compound>
<compound kind="group">
<name>thttp_url_group</name>
<title>HTTP/HTTPS URL.</title>
<title>HTTP/HTTPS URL</title>
<filename>group__thttp__url__group.html</filename>
<member kind="define">
<type>#define</type>
@ -3028,8 +3135,8 @@
<type>thttp_url_t *</type>
<name>thttp_url_parse</name>
<anchorfile>group__thttp__url__group.html</anchorfile>
<anchor>ga0b2cf9c8367c5af17d76a0a29018eda5</anchor>
<arglist>(const char *data, size_t size)</arglist>
<anchor>ga1acfdcf4d31969aa3de457b88f8178bb</anchor>
<arglist>(const char *urlstring, size_t length)</arglist>
</member>
<member kind="function">
<type>int</type>

View File

@ -452,7 +452,9 @@ void *tnet_transport_mainthread(void *param)
/* Get active event and socket */
index = (evt - WSA_WAIT_EVENT_0);
active_event = context->events[index];
active_socket = context->sockets[index];
if(!(active_socket = context->sockets[index])){
goto done;
}
/* Get the network events flags */
if (WSAEnumNetworkEvents(active_socket->fd, active_event, &networkEvents) == SOCKET_ERROR){

View File

@ -41,6 +41,7 @@ TSK_BEGIN_DECLS
#include "tsk_memory.h"
#include "tsk_url.h"
#include "tsk_params.h"
#include "tsk_options.h"
#include "tsk_fsm.h"
#include "tsk_time.h"

View File

@ -185,7 +185,7 @@ tsk_bool_t tsk_fsm_terminated(tsk_fsm_t* self)
//=================================================================================================
// fsm object definition
//
static void* tsk_fsm_create(void * self, va_list * app)
static tsk_object_t* tsk_fsm_create(tsk_object_t * self, va_list * app)
{
tsk_fsm_t *fsm = self;
if(fsm)
@ -204,11 +204,18 @@ static void* tsk_fsm_create(void * self, va_list * app)
return self;
}
static void* tsk_fsm_destroy(void * self)
static tsk_object_t* tsk_fsm_destroy(tsk_object_t * self)
{
tsk_fsm_t *fsm = self;
if(fsm)
{
if(fsm){
/* If not in the terminal state ==>do it */
if(fsm->current != fsm->term){
tsk_safeobj_lock(fsm);
if(fsm->callback_term){
fsm->callback_term(fsm->callback_data);
}
tsk_safeobj_unlock(fsm);
}
tsk_safeobj_deinit(fsm);
TSK_OBJECT_SAFE_FREE(fsm->entries);
@ -222,34 +229,32 @@ static const tsk_object_def_t tsk_fsm_def_s =
sizeof(tsk_fsm_t),
tsk_fsm_create,
tsk_fsm_destroy,
0,
tsk_null,
};
const void *tsk_fsm_def_t = &tsk_fsm_def_s;
const tsk_object_def_t *tsk_fsm_def_t = &tsk_fsm_def_s;
//=================================================================================================
// fsm entry object definition
//
static void* tsk_fsm_entry_create(void * self, va_list * app)
static tsk_object_t* tsk_fsm_entry_create(tsk_object_t * self, va_list * app)
{
tsk_fsm_entry_t *fsm_entry = self;
if(fsm_entry)
{
if(fsm_entry){
}
return self;
}
static void* tsk_fsm_entry_destroy(void * self)
static tsk_object_t* tsk_fsm_entry_destroy(tsk_object_t * self)
{
tsk_fsm_entry_t *fsm_entry = self;
if(fsm_entry)
{
if(fsm_entry){
//TSK_FREE(fsm_entry->desc);
}
return self;
}
static int tsk_fsm_entry_cmp(const void *obj1, const void *obj2)
static int tsk_fsm_entry_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
const tsk_fsm_entry_t* entry1 = obj1;
const tsk_fsm_entry_t* entry2 = obj2;
@ -281,4 +286,4 @@ static const tsk_object_def_t tsk_fsm_entry_def_s =
tsk_fsm_entry_destroy,
tsk_fsm_entry_cmp,
};
const void *tsk_fsm_entry_def_t = &tsk_fsm_entry_def_s;
const tsk_object_def_t *tsk_fsm_entry_def_t = &tsk_fsm_entry_def_s;

View File

@ -176,8 +176,8 @@ TINYSAK_API int tsk_fsm_set_callback_terminated(tsk_fsm_t* self, tsk_fsm_ontermi
TINYSAK_API int tsk_fsm_act(tsk_fsm_t* self, tsk_fsm_action_id action, const void* cond_data1, const void* cond_data2, ...);
TINYSAK_API tsk_bool_t tsk_fsm_terminated(tsk_fsm_t* self);
TINYSAK_GEXTERN const void *tsk_fsm_def_t;
TINYSAK_GEXTERN const void *tsk_fsm_entry_def_t;
TINYSAK_GEXTERN const tsk_object_def_t *tsk_fsm_def_t;
TINYSAK_GEXTERN const tsk_object_def_t *tsk_fsm_entry_def_t;
TSK_END_DECLS

View File

@ -112,19 +112,16 @@ int tsk_mutex_unlock(tsk_mutex_handle_t* handle)
if(handle)
{
#if TSK_UNDER_WINDOWS
if((ret = ReleaseMutex((MUTEX_T)handle) ? 0 : -1))
{
if((ret = ReleaseMutex((MUTEX_T)handle) ? 0 : -1)){
ret = GetLastError();
#else
if(ret = pthread_mutex_unlock((MUTEX_T)handle))
{
#endif
if(ret == TSK_ERROR_NOT_OWNER)
{
if(ret == TSK_ERROR_NOT_OWNER){
TSK_DEBUG_WARN("The calling thread does not own the mutex: %d", ret);
}
else
{
else{
TSK_DEBUG_ERROR("Failed to unlock the mutex: %d", ret);
}
}
@ -139,8 +136,7 @@ int tsk_mutex_unlock(tsk_mutex_handle_t* handle)
*/
void tsk_mutex_destroy(tsk_mutex_handle_t** handle)
{
if(handle && *handle)
{
if(handle && *handle){
#if TSK_UNDER_WINDOWS
CloseHandle((MUTEX_T)*handle);
*handle = 0;
@ -149,8 +145,7 @@ void tsk_mutex_destroy(tsk_mutex_handle_t** handle)
tsk_free(handle);
#endif
}
else
{
else{
TSK_DEBUG_WARN("Cannot free an uninitialized mutex");
}
}

View File

@ -37,7 +37,7 @@
*/
#if defined (_DEBUG) || defined (DEBUG)
# define TSK_DEBUG_OBJECTS 1
# define TSK_DEBUG_OBJECTS 0
static int tsk_objects_count = 0;
#else
# define TSK_DEBUG_OBJECTS 0

View File

@ -0,0 +1,229 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
/**@file tsk_options.c
* @brief Options.
*
* @author Mamadou Diop <diopmamadou(at)doubango.org>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tsk_options.h"
#include "tsk_memory.h"
#include "tsk_string.h"
#include "tsk_common.h"
#include <string.h>
/**@defgroup tsk_options_group Options.
*/
/* Predicate function used to find an option by id.
*/
static int pred_find_option_by_id(const tsk_list_item_t *item, const void *id)
{
if(item && item->data){
tsk_option_t *option = item->data;
return (option->id - *((int*)id));
}
return -1;
}
/**@ingroup tsk_options_group
* Checks if the supplied list of options contains an option with this @a id.
* @param self The list of options into which to search.
* @param id The id of the option to search.
* @retval @ref tsk_true if the parameter exist and @ref tsk_false otherwise.
*/
tsk_bool_t tsk_options_have_option(const tsk_options_L_t *self, int id)
{
if(self){
if(tsk_list_find_item_by_pred(self, pred_find_option_by_id, &id)){
return tsk_true;
}
}
return tsk_false;
}
/**@ingroup tsk_options_group
* Adds an option to the list of options. If the option already exist(same id), then it's value will be updated.
* @param self The destination list.
* @param name The name of the option to add.
* @param value The value of the option to add.
* @retval Zero if succeed and -1 otherwise.
*/
int tsk_options_add_option(tsk_options_L_t **self, int id, const char* value)
{
tsk_option_t *option;
if(!self) {
return -1;
}
if(!*self){
*self = TSK_LIST_CREATE();
}
if((option = (tsk_option_t*)tsk_options_get_option_by_id(*self, id))){
tsk_strupdate(&option->value, value); /* Already exist ==> update the value. */
}
else{
option = TSK_OPTION_CREATE(id, value);
tsk_list_push_back_data(*self, (void**)&option);
}
return 0;
}
int tsk_options_add_option_2(tsk_options_L_t **self, const tsk_option_t* option)
{
int ret = -1;
if(!self || !option || !option){
return ret;
}
ret = tsk_options_add_option(self, option->id, option->value);
return ret;
}
/**@ingroup tsk_options_group
* Removes an option from the list of options.
* @param self The source list.
* @param id The id of the option to remove.
* @retval Zero if succeed and -1 otherwise.
*/
int tsk_options_remove_option(tsk_options_L_t *self, int id)
{
if(self){
tsk_list_remove_item_by_pred(self, pred_find_option_by_id, &id);
return 0;
}
return -1;
}
/**@ingroup tsk_options_group
* Gets an option from the list of options by id.
* @param self The source list.
* @param id The id of the option to retrieve.
* @retval @ref tsk_option_t if succeed and NULL otherwise.
*/
const tsk_option_t *tsk_options_get_option_by_id(const tsk_options_L_t *self, int id)
{
if(self)
{
const tsk_list_item_t *item_const = tsk_list_find_item_by_pred(self, pred_find_option_by_id, &id);
if(item_const){
return item_const->data;
}
}
return 0;
}
/**@ingroup tsk_options_group
* Gets the value of a option.
* @param self The source list.
* @param name The id of the option to retrieve.
* @retval The value of the option if succeed and @ref tsk_null otherwise.
*/
const char *tsk_options_get_option_value(const tsk_options_L_t *self, int id)
{
if(self){
const tsk_list_item_t *item_const = tsk_list_find_item_by_pred(self, pred_find_option_by_id, &id);
if(item_const && item_const->data){
return ((const tsk_option_t *)item_const->data)->value;
}
}
return tsk_null;
}
/**@ingroup tsk_options_group
* Gets the value of a option.
* @param self The source list.
* @param id The id of the option to retrieve.
* @retval The value of the option if succeed and -1 otherwise.
*/
int tsk_options_get_option_value_as_int(const tsk_options_L_t *self, int id)
{
const char *value = tsk_options_get_option_value(self, id);
return value ? atoi(value) : -1;
}
//=================================================================================================
// option object definition
//
static tsk_object_t* tsk_option_create(tsk_object_t * self, va_list * app)
{
tsk_option_t *option = self;
if(option){
int id = va_arg(*app, int);
const char* value = va_arg(*app, const char *);
option->id = id;
if(value && !tsk_strempty(value)) {
option->value = tsk_strdup(value);
}
}
return self;
}
static tsk_object_t* tsk_option_destroy(tsk_object_t * self)
{
tsk_option_t *option = self;
if(option){
TSK_FREE(option->value);
}
return self;
}
static const tsk_object_def_t tsk_option_def_s =
{
sizeof(tsk_option_t),
tsk_option_create,
tsk_option_destroy,
tsk_null,
};
const tsk_object_def_t* tsk_option_def_t = &tsk_option_def_s;

View File

@ -0,0 +1,83 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
/**@file tsk_options.h
* @brief Options.
*
* @author Mamadou Diop <diopmamadou(at)doubango.org>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TINYSAK_OPTIONS_H_
#define _TINYSAK_OPTIONS_H_
#include "tinySAK_config.h"
#include "tsk_object.h"
#include "tsk_list.h"
#include "tsk_buffer.h"
/**@ingroup tsk_options_group
* @def TSK_OPTION_CREATE
* Creates new @ref tsk_option_t object.
*/
/**@ingroup tsk_options_group
* @def TSK_OPTION_CREATE
* Creates new @ref tsk_option_t object.
*/
TSK_BEGIN_DECLS
#define TSK_OPTION_VA_ARGS(id, value) tsk_option_def_t, (int)id, (const char*)value
#define TSK_OPTION_CREATE(id, value) tsk_object_new(TSK_OPTION_VA_ARGS(id, value))
#define TSK_OPTION_CREATE_NULL() TSK_OPTION_CREATE(0, tsk_null)
#define TSK_OPTION(self) ((tsk_option_t*)(self))
/**@ingroup tsk_options_group
* Parameter.
*/
typedef struct tsk_option_s
{
TSK_DECLARE_OBJECT;
int id;
char* value;
tsk_bool_t tag;
}
tsk_option_t;
typedef tsk_list_t tsk_options_L_t; /**< List of @ref tsk_option_t elements. */
TINYSAK_API int tsk_options_have_option(const tsk_options_L_t *self, int id);
TINYSAK_API int tsk_options_add_option(tsk_options_L_t **self, int id, const char* value);
TINYSAK_API int tsk_options_add_option_2(tsk_options_L_t **self, const tsk_option_t* option);
TINYSAK_API int tsk_options_remove_option(tsk_options_L_t *self, int id);
TINYSAK_API const tsk_option_t *tsk_options_get_option_by_id(const tsk_options_L_t *self, int id);
TINYSAK_API const char *tsk_options_get_option_value(const tsk_options_L_t *self, int id);
TINYSAK_API int tsk_options_get_option_value_as_int(const tsk_options_L_t *self, int id);
TINYSAK_GEXTERN const tsk_object_def_t *tsk_option_def_t;
TSK_END_DECLS
#endif /* _TINYSAK_OPTIONS_H_ */

View File

@ -45,7 +45,7 @@ static int pred_find_param_by_name(const tsk_list_item_t *item, const void *name
tsk_param_t *param = item->data;
return tsk_stricmp(param->name, name);
}
return 0;
return -1;
}
/**@ingroup tsk_params_group
@ -88,15 +88,16 @@ tsk_param_t *tsk_params_parse_param(const char* line, size_t size)
* Checks if the supplied list of parameters contains a parameter named @a name (case-insensitive).
* @param self The list of parameters into which to search.
* @param name The name of the parameter to search.
* @retval 1 if the parameter exist and zero otherwise.
* @retval @ref tsk_true if the parameter exist and @ref tsk_false otherwise.
*/
int tsk_params_have_param(const tsk_params_L_t *self, const char* name)
tsk_bool_t tsk_params_have_param(const tsk_params_L_t *self, const char* name)
{
if(self){
const tsk_list_item_t *item_const = tsk_list_find_item_by_pred(self, pred_find_param_by_name, name);
return item_const ? 1 : 0;
if(tsk_list_find_item_by_pred(self, pred_find_param_by_name, name)){
return tsk_true;
}
}
return 0;
return tsk_false;
}
/**@ingroup tsk_params_group
@ -159,7 +160,7 @@ int tsk_params_remove_param(tsk_params_L_t *self, const char* name)
* Gets a parameter from the list of parameters by name.
* @param self The source list.
* @param name The name(case-insensitive) of the parameter to retrieve.
* @retval @ref tsk_param_t if succeed and NULL otherwise.
* @retval @ref tsk_param_t if succeed and @ref tsk_null otherwise.
*/
const tsk_param_t *tsk_params_get_param_by_name(const tsk_params_L_t *self, const char* name)
{
@ -170,7 +171,7 @@ const tsk_param_t *tsk_params_get_param_by_name(const tsk_params_L_t *self, cons
return item_const->data;
}
}
return 0;
return tsk_null;
}
/**@ingroup tsk_params_group
@ -279,7 +280,7 @@ bail:
//=================================================================================================
// param object definition
//
static void* tsk_param_create(void * self, va_list * app)
static tsk_object_t* tsk_param_create(tsk_object_t* self, va_list * app)
{
tsk_param_t *param = self;
if(param)
@ -299,11 +300,10 @@ static void* tsk_param_create(void * self, va_list * app)
return self;
}
static void* tsk_param_destroy(void * self)
static tsk_object_t* tsk_param_destroy(tsk_object_t* self)
{
tsk_param_t *param = self;
if(param)
{
if(param){
TSK_FREE(param->name);
TSK_FREE(param->value);
}
@ -316,7 +316,7 @@ static const tsk_object_def_t tsk_param_def_s =
sizeof(tsk_param_t),
tsk_param_create,
tsk_param_destroy,
0,
tsk_null,
};
const void *tsk_param_def_t = &tsk_param_def_s;
const tsk_object_def_t *tsk_param_def_t = &tsk_param_def_s;

View File

@ -61,7 +61,7 @@ typedef struct tsk_param_s
char *name;/**< The name of the parameter. */
char *value;/**< The value of the parameter. */
tsk_bool_t tag;/**< tag to be used for any use case (e.g. validity of the parameter, whether to ignore the param., ...). Default value: 0.*/
tsk_bool_t tag;/**< tag to be used for any use case (e.g. validity of the parameter, whether to ignore the param., ...). Default value: @ref tsk_false.*/
}
tsk_param_t;
@ -69,7 +69,7 @@ typedef tsk_list_t tsk_params_L_t; /**< List of @ref tsk_param_t elements. */
TINYSAK_API tsk_param_t *tsk_params_parse_param(const char* line, size_t size);
TINYSAK_API int tsk_params_have_param(const tsk_params_L_t *self, const char* name);
TINYSAK_API tsk_bool_t tsk_params_have_param(const tsk_params_L_t *self, const char* name);
TINYSAK_API int tsk_params_add_param(tsk_params_L_t **self, const char* name, const char* value);
TINYSAK_API int tsk_params_add_param_2(tsk_params_L_t **self, const tsk_param_t* param);
TINYSAK_API int tsk_params_remove_param(tsk_params_L_t *self, const char* name);
@ -80,7 +80,7 @@ TINYSAK_API int tsk_params_get_param_value_as_int(const tsk_params_L_t *self, co
TINYSAK_API int tsk_params_param_tostring(const tsk_param_t *param, tsk_buffer_t* output);
TINYSAK_API int tsk_params_tostring(const tsk_params_L_t *self, const char separator, tsk_buffer_t* output);
TINYSAK_GEXTERN const void *tsk_param_def_t;
TINYSAK_GEXTERN const tsk_object_def_t *tsk_param_def_t;
TSK_END_DECLS

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*
@ -38,13 +38,14 @@
#define RUN_TEST_HEAP 0
#define RUN_TEST_STRINGS 0
#define RUN_TEST_URL 0
#define RUN_TEST_THREADS 1
#define RUN_TEST_THREADS 0
#define RUN_TEST_MUTEX 0
#define RUN_TEST_CONDWAIT 0
#define RUN_TEST_SEMAPHORE 0 /* FIXME: android */
#define RUN_TEST_SAFEOBJECT 0
#define RUN_TEST_OBJECT 0
#define RUN_TEST_PARAMS 0
#define RUN_TEST_OPTIONS 1
#define RUN_TEST_TIMER 0
#define RUN_TEST_RUNNABLE 0
#define RUN_TEST_BUFFER 0
@ -98,6 +99,10 @@
#include "test_params.h"
#endif
#if RUN_TEST_OPTIONS || RUN_TEST_ALL
#include "test_options.h"
#endif
#if RUN_TEST_TIMER || RUN_TEST_ALL
#include "test_timer.h"
#endif
@ -214,6 +219,12 @@ int main()
printf("\n\n");
#endif
#if RUN_TEST_OPTIONS || RUN_TEST_ALL
/* options */
test_options();
printf("\n\n");
#endif
#if RUN_TEST_TIMER || RUN_TEST_ALL
/* timer */
test_timer();

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*
@ -43,7 +43,7 @@ struct b64_msg b64_msgs[] =
{
"* Copyright (C) 2009 Mamadou Diop."
"*"
"* Contact: Mamadou Diop <diopmamadou@yahoo.fr>"
"* Contact: Mamadou Diop <diopmamadou(at)doubango.org>"
"*"
"* This file is part of Open Source Doubango Framework."
"*"

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*
@ -45,53 +45,53 @@ student_t;
// constructor
static tsk_object_t* person_create(tsk_object_t * self, va_list * app)
{
person_t *person = self;
if(person){
person->name = tsk_strdup(va_arg(*app, const char *));
}
return self;
}
// destructor
static tsk_object_t* person_destroy(tsk_object_t * self)
{
person_t *person = self;
if(person){
TSK_FREE(person->name);
tsk_object_unref(person->girlfriend);
}
return self; // return
}
// comparator
static int person_cmp(const tsk_object_t *_p1, const tsk_object_t *_p2)
{
const person_t *p1 = _p1;
const person_t *p1 = _p2;
int ret;
// do they have the same name?
if((ret = tsk_stricmp(p1->name, p2->name))){
return ret;
}
// do they have the same girlfriend?
if((ret = tsk_object_cmp(p1->girlfriend, p2->girlfriend))){
return ret;
}
// they are the same
return 0;
}
//(Object defnition)
static const tsk_object_def_t person_def_t =
{
sizeof(person_t),
person_create,
person_destroy,
person_cmp
static tsk_object_t* person_create(tsk_object_t * self, va_list * app)
{
person_t *person = self;
if(person){
person->name = tsk_strdup(va_arg(*app, const char *));
}
return self;
}
// destructor
static tsk_object_t* person_destroy(tsk_object_t * self)
{
person_t *person = self;
if(person){
TSK_FREE(person->name);
tsk_object_unref(person->girlfriend);
}
return self; // return
}
// comparator
static int person_cmp(const tsk_object_t *_p1, const tsk_object_t *_p2)
{
const person_t *p1 = _p1;
const person_t *p1 = _p2;
int ret;
// do they have the same name?
if((ret = tsk_stricmp(p1->name, p2->name))){
return ret;
}
// do they have the same girlfriend?
if((ret = tsk_object_cmp(p1->girlfriend, p2->girlfriend))){
return ret;
}
// they are the same
return 0;
}
//(Object defnition)
static const tsk_object_def_t person_def_t =
{
sizeof(person_t),
person_create,
person_destroy,
person_cmp
};
// create a person

View File

@ -0,0 +1,61 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
#ifndef _TEST_OPTIONS_H_
#define _TEST_OPTIONS_H_
typedef enum options_e
{
o_project,
o_license,
o_contact,
o_version,
o_date
}
options_t;
void test_options()
{
tsk_options_L_t *options = TSK_LIST_CREATE();
tsk_bool_t b;
int i;
const char* string;
const tsk_option_t* o;
tsk_options_add_option(&options, o_project, "doubango");
tsk_options_add_option(&options, o_project, "doubangooo");
tsk_options_add_option(&options, o_license, "GPLv3");
tsk_options_add_option(&options, o_contact, "Mamadou Diop <diopmamadou(at)doubango.org>");
tsk_options_add_option(&options, o_version, "10");
b = tsk_options_have_option(options, o_project);
b = tsk_options_have_option(options, o_date);
tsk_options_remove_option(options, o_project);
b = tsk_options_have_option(options, o_project);
i = tsk_options_get_option_value_as_int(options, o_version);
string = tsk_options_get_option_value(options, o_version);
o = tsk_options_get_option_by_id(options, o_contact);
TSK_OBJECT_SAFE_FREE(options);
}
#endif /*_TEST_OPTIONS_H_ */

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*
* This file is part of Open Source Doubango Framework.
*

View File

@ -62,7 +62,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinyHTTP.lib"
AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinyHTTP.lib $(OutDir)\tinyNET.lib"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"

View File

@ -344,6 +344,14 @@
RelativePath="..\..\tinyHTTP\src\thttp.c"
>
</File>
<File
RelativePath="..\..\tinyHTTP\src\thttp_action.c"
>
</File>
<File
RelativePath="..\..\tinyHTTP\src\thttp_dialog.c"
>
</File>
<File
RelativePath="..\..\tinyHTTP\src\thttp_event.c"
>
@ -353,11 +361,7 @@
>
</File>
<File
RelativePath="..\..\tinyHTTP\src\thttp_operation.c"
>
</File>
<File
RelativePath="..\..\tinyHTTP\src\thttp_transport.c"
RelativePath="..\..\tinyHTTP\src\thttp_session.c"
>
</File>
<File
@ -399,6 +403,10 @@
RelativePath="..\..\tinyHTTP\src\headers\thttp_header_Dummy.c"
>
</File>
<File
RelativePath="..\..\tinyHTTP\src\headers\thttp_header_Transfer_Encoding.c"
>
</File>
<File
RelativePath="..\..\tinyHTTP\src\headers\thttp_header_WWW_Authenticate.c"
>
@ -428,6 +436,14 @@
RelativePath="..\..\tinyHTTP\include\thttp.h"
>
</File>
<File
RelativePath="..\..\tinyHTTP\include\tinyHTTP\thttp_action.h"
>
</File>
<File
RelativePath="..\..\tinyHTTP\include\tinyHTTP\thttp_dialog.h"
>
</File>
<File
RelativePath="..\..\tinyHTTP\include\tinyHTTP\thttp_event.h"
>
@ -437,17 +453,17 @@
>
</File>
<File
RelativePath="..\..\tinyHTTP\include\tinyHTTP\thttp_operation.h"
>
</File>
<File
RelativePath="..\..\tinyHTTP\include\tinyHTTP\thttp_transport.h"
RelativePath="..\..\tinyHTTP\include\tinyHTTP\thttp_session.h"
>
</File>
<File
RelativePath="..\..\tinyHTTP\include\tinyHTTP\thttp_url.h"
>
</File>
<File
RelativePath="..\..\tinyHTTP\include\tinyhttp.h"
>
</File>
<File
RelativePath="..\..\tinyHTTP\include\tinyhttp_config.h"
>
@ -487,6 +503,10 @@
RelativePath="..\..\tinyHTTP\include\tinyHTTP\headers\thttp_header_Dummy.h"
>
</File>
<File
RelativePath="..\..\tinyHTTP\include\tinyHTTP\headers\thttp_header_Transfer_Encoding.h"
>
</File>
<File
RelativePath="..\..\tinyHTTP\include\tinyHTTP\headers\thttp_header_WWW_Authenticate.h"
>
@ -560,6 +580,10 @@
RelativePath="..\..\tinyHTTP\ragel\thttp_parser_header_Dummy.rl"
>
</File>
<File
RelativePath="..\..\tinyHTTP\ragel\thttp_parser_header_Transfer_Encoding.rl"
>
</File>
<File
RelativePath="..\..\tinyHTTP\ragel\thttp_parser_header_WWW_Authenticate.rl"
>

View File

@ -402,6 +402,10 @@
RelativePath="..\..\tinySAK\test\test_object.h"
>
</File>
<File
RelativePath="..\..\tinySAK\test\test_options.h"
>
</File>
<File
RelativePath="..\..\tinySAK\test\test_params.h"
>

View File

@ -413,6 +413,10 @@
RelativePath="..\..\tinySAK\src\tsk_object.h"
>
</File>
<File
RelativePath="..\..\tinySAK\src\tsk_options.h"
>
</File>
<File
RelativePath="..\..\tinySAK\src\tsk_params.h"
>
@ -527,6 +531,10 @@
RelativePath="..\..\tinySAK\src\tsk_object.c"
>
</File>
<File
RelativePath="..\..\tinySAK\src\tsk_options.c"
>
</File>
<File
RelativePath="..\..\tinySAK\src\tsk_params.c"
>