diff --git a/trunk/documentation/programmer-guide-1.0.doc b/trunk/documentation/programmer-guide-1.0.doc index 140e4e10..e814176f 100644 Binary files a/trunk/documentation/programmer-guide-1.0.doc and b/trunk/documentation/programmer-guide-1.0.doc differ diff --git a/trunk/tinyHTTP/include/thttp.h b/trunk/tinyHTTP/include/thttp.h index dbee1067..5bcf6c84 100644 --- a/trunk/tinyHTTP/include/thttp.h +++ b/trunk/tinyHTTP/include/thttp.h @@ -136,7 +136,7 @@ TINYHTTP_API int thttp_stack_start(thttp_stack_handle_t *self); TINYHTTP_API int thttp_stack_set(thttp_stack_handle_t *self, ...); TINYHTTP_API int thttp_stack_stop(thttp_stack_handle_t *self); -TINYHTTP_GEXTERN const void *thttp_stack_def_t; +TINYHTTP_GEXTERN const tsk_object_def_t *thttp_stack_def_t; THTTP_END_DECLS diff --git a/trunk/tinyHTTP/include/tinyHTTP/thttp_session.h b/trunk/tinyHTTP/include/tinyHTTP/thttp_session.h index 5cb06faf..3be8c00c 100644 --- a/trunk/tinyHTTP/include/tinyHTTP/thttp_session.h +++ b/trunk/tinyHTTP/include/tinyHTTP/thttp_session.h @@ -65,12 +65,12 @@ thhtp_session_option_t; typedef enum thttp_session_param_type_e { - sptype_null = tsk_null, + httpp_null = tsk_null, - sptype_option, - sptype_cred, - sptype_header, - sptype_context, + httpp_option, + httpp_cred, + httpp_header, + httpp_context, } thttp_session_param_type_t; @@ -134,11 +134,11 @@ thttp_session_set(session, * @def THTTP_SESSION_SET_NULL * Ends session parameters. Must always be the last one. */ -#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 -#define THTTP_SESSION_SET_NULL() sptype_null +#define THTTP_SESSION_SET_OPTION(ID_INT, VALUE_STR) httpp_option, (thhtp_session_option_t)ID_INT, (const char*)VALUE_STR +#define THTTP_SESSION_SET_CRED(USERNAME_STR, PASSWORD_STR) httpp_cred, (const char*)USERNAME_STR, (const char*)PASSWORD_STR +#define THTTP_SESSION_SET_HEADER(NAME_STR, VALUE_STR) httpp_header, (const char*)NAME_STR, (const char*)VALUE_STR +#define THTTP_SESSION_SET_CONTEXT(CTX_PTR) httpp_context, (const void*)CTX_PTR +#define THTTP_SESSION_SET_NULL() httpp_null typedef struct thttp_session_s { @@ -146,7 +146,7 @@ typedef struct thttp_session_s thttp_session_id_t id; const struct thttp_stack_s* stack; - const void* context; // usr context + const void* context; // user's context tsk_options_L_t *options; tsk_params_L_t *headers; diff --git a/trunk/tinyHTTP/include/tinyHTTP/thttp_url.h b/trunk/tinyHTTP/include/tinyHTTP/thttp_url.h index c63fd91d..23f3fdfc 100644 --- a/trunk/tinyHTTP/include/tinyHTTP/thttp_url.h +++ b/trunk/tinyHTTP/include/tinyHTTP/thttp_url.h @@ -94,6 +94,7 @@ thttp_url_t; TINYHTTP_API int thttp_url_serialize(const thttp_url_t *url, tsk_buffer_t *output); TINYHTTP_API char* thttp_url_tostring(const thttp_url_t *url); TINYHTTP_API thttp_url_t *thttp_url_clone(const thttp_url_t *url); +TINYHTTP_API tsk_bool_t thttp_url_isok(const char* urlstring); TINYHTTP_GEXTERN const void *thttp_url_def_t; diff --git a/trunk/tinyHTTP/src/thttp.c b/trunk/tinyHTTP/src/thttp.c index 7d75cf06..43949856 100644 --- a/trunk/tinyHTTP/src/thttp.c +++ b/trunk/tinyHTTP/src/thttp.c @@ -239,19 +239,20 @@ int __thttp_stack_set(thttp_stack_t *self, va_list values) }/* switch */ }/* while */ + return 0; bail: - return 0; + return -2; } /**@ingroup thttp_stack_group * Creates new HTTP/HTTPS stack. * @param callback Pointer to the callback function to call when new messages come to the transport layer. * Can be set to Null if you don't want to be alerted. -* @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.
+* @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 to pass to the stack.
* @retval A Pointer to the newly created stack if succeed and @a Null otherwise. -* A session is a well-defined object. +* A stack is a well-defined object. * * @code * thttp_stack_create(callback, @@ -284,7 +285,7 @@ thttp_stack_handle_t *thttp_stack_create(thttp_stack_callback callback, ...) /**@ingroup thttp_stack_group * Starts the stack. -* @param self A pointer to the stack to start. The stack must be create using @ref thttp_stack_create. +* @param self A pointer to the stack to start. The stack shall be created using @ref thttp_stack_create(). * @retval Zero if succeed and non-zero error code otherwise. * @sa @ref thttp_stack_stop */ @@ -341,8 +342,8 @@ int thttp_stack_set(thttp_stack_handle_t *self, ...) } /**@ingroup thttp_stack_group -* 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. +* Stops the stack. The stack must already be started. +* @param self A pointer to the stack to stop. The stack shall be created using @ref thttp_stack_create. * @retval Zero if succeed and non-zero error code otherwise. * @sa @ref thttp_stack_start */ @@ -399,7 +400,7 @@ int thttp_stack_alert(const thttp_stack_t *self, const thttp_event_t* e) //======================================================== // HTTP stack object definition // -static void* _thttp_stack_create(void * self, va_list * app) +static tsk_object_t* _thttp_stack_create(tsk_object_t * self, va_list * app) { thttp_stack_t *stack = self; if(stack){ @@ -410,7 +411,7 @@ static void* _thttp_stack_create(void * self, va_list * app) return self; } -static void* thttp_stack_destroy(void * self) +static tsk_object_t* thttp_stack_destroy(tsk_object_t * self) { thttp_stack_t *stack = self; if(stack){ @@ -438,6 +439,6 @@ static const tsk_object_def_t thttp_stack_def_s = sizeof(thttp_stack_t), _thttp_stack_create, thttp_stack_destroy, - 0, + tsk_null, }; -const void *thttp_stack_def_t = &thttp_stack_def_s; \ No newline at end of file +const tsk_object_def_t *thttp_stack_def_t = &thttp_stack_def_s; diff --git a/trunk/tinyHTTP/src/thttp_session.c b/trunk/tinyHTTP/src/thttp_session.c index fe56078c..6bdb070d 100644 --- a/trunk/tinyHTTP/src/thttp_session.c +++ b/trunk/tinyHTTP/src/thttp_session.c @@ -50,11 +50,9 @@ int __thttp_session_set(thttp_session_t *self, va_list* app) return -1; } - while((curr=va_arg(*app, thttp_session_param_type_t)) != sptype_null) - { - switch(curr) - { - case sptype_option: + while((curr=va_arg(*app, thttp_session_param_type_t)) != httpp_null){ + switch(curr){ + case httpp_option: { thhtp_session_option_t id = va_arg(*app, thhtp_session_option_t); const char* value = va_arg(*app, const char *); @@ -62,7 +60,7 @@ int __thttp_session_set(thttp_session_t *self, va_list* app) break; } - case sptype_header: + case httpp_header: { const char* name = va_arg(*app, const char *); const char* value = va_arg(*app, const char *); @@ -70,14 +68,14 @@ int __thttp_session_set(thttp_session_t *self, va_list* app) break; } - case sptype_cred: + case httpp_cred: { tsk_strupdate(&self->cred.usename, va_arg(*app, const char *)); tsk_strupdate(&self->cred.password, va_arg(*app, const char *)); break; } - case sptype_context: + case httpp_context: { self->context = va_arg(*app, const void *); break; @@ -88,8 +86,8 @@ int __thttp_session_set(thttp_session_t *self, va_list* app) TSK_DEBUG_ERROR("NOT SUPPORTED."); goto bail; } - } - } + } /* sxitch */ + } /* while */ return 0; bail: @@ -135,14 +133,14 @@ thttp_session_handle_t* thttp_session_create(const struct thttp_stack_s* stack, /**@ingroup thttp_session_group * Updates the session parameters. -* @param self The session to update. The session shall be created using @ref thttp_session_create. +* @param self The session to update. The session shall be created using @ref thttp_session_create(). * @param ... Any @b THTTP_SESSION_SET_*() macros. MUST ends with @ref THTTP_SESSION_SET_NULL(). * @retval Zero if succeed and non zero error code otherwise. * * @code int ret = thttp_session_set(session, // session-level parameters - THTTP_SESSION_SET_PARAM("timeout", "6000"), + THTTP_SESSION_SET_OPTION(THTTP_SESSION_OPTION_TIMEOUT, "6000"), // session-level headers THTTP_SESSION_SET_HEADER("Pragma", "No-Cache"), diff --git a/trunk/tinyHTTP/src/thttp_url.c b/trunk/tinyHTTP/src/thttp_url.c index b181e143..1eead7e3 100644 --- a/trunk/tinyHTTP/src/thttp_url.c +++ b/trunk/tinyHTTP/src/thttp_url.c @@ -90,7 +90,23 @@ thttp_url_t *thttp_url_clone(const thttp_url_t *url) return newurl; } - +/**@ingroup thttp_url_group +*/ +tsk_bool_t thttp_url_isok(const char* urlstring) +{ + thttp_url_t *url; + if(!urlstring){ + return tsk_false; + } + + if((url = thttp_url_parse(urlstring, strlen(urlstring)))){ + TSK_OBJECT_SAFE_FREE(url); + return tsk_true; + } + else{ + return tsk_false; + } +} diff --git a/trunk/tinyHTTP/tinyHTTP b/trunk/tinyHTTP/tinyHTTP index 147ffa95..3f2641aa 100644 --- a/trunk/tinyHTTP/tinyHTTP +++ b/trunk/tinyHTTP/tinyHTTP @@ -120,6 +120,8 @@ tinyHTTP_config.h tinyHTTP/thttp_event.h tinyHTTP/thttp_session.h + tinyHTTP/thttp_message.h + tinyHTTP/thttp_url.h thttp_auth.h @@ -325,6 +327,12 @@ ac740fe3f373d2a91913437e31e44d4b3a8ae250e4da5f57fca5eb36f227409c44 + + thttp_htype_Transfer_Encoding + thttp__header_8h.html + ac740fe3f373d2a91913437e31e44d4b3a396cb186e47c23c5e52be304b6a5bd47 + + thttp_htype_WWW_Authenticate thttp__header_8h.html @@ -503,10 +511,10 @@ (const char *data, size_t size) - TINYHTTP_GEXTERN const void * + TINYHTTP_GEXTERN const tsk_object_def_t * thttp_header_Content_Type_def_t thttp__header___content___type_8h.html - ae21fdcc8ed9d62d36bddfaee98d91d7b + aae2f5aaccb96719f11770748caa192b6 @@ -560,6 +568,56 @@ + + thttp_header_Transfer_Encoding.h + C:/doubango/tinyHTTP/include/tinyHTTP/headers/ + thttp__header___transfer___encoding_8h + tinyHTTP_config.h + tinyHTTP/headers/thttp_header.h + thttp_header_Transfer_Encoding_s + + #define + THTTP_HEADER_TRANSFER_ENCODING_VA_ARGS + thttp__header___transfer___encoding_8h.html + af3d45684db89cc6a76d82e56abf46bd6 + (encoding) + + + #define + THTTP_HEADER_TRANSFER_ENCODING_CREATE + thttp__header___transfer___encoding_8h.html + a8a99e4a81e5adfe47c4d027c0b8dde24 + (encoding) + + + #define + THTTP_HEADER_TRANSFER_ENCODING_CREATE_NULL + thttp__header___transfer___encoding_8h.html + a8141d205a6b88ddc0123b8bc7e2a6a16 + () + + + struct thttp_header_Transfer_Encoding_s + thttp_header_Transfer_Encoding_t + thttp__header___transfer___encoding_8h.html + a819c92eb51b3f91042057b99c1c33a78 + + + + thttp_header_Transfer_Encoding_t * + thttp_header_Transfer_Encoding_parse + group__thttp__header__group.html + ga3c59176f6b363090c3f89e5238cb3901 + (const char *data, size_t size) + + + TINYHTTP_GEXTERN const tsk_object_def_t * + thttp_header_Transfer_Encoding_def_t + thttp__header___transfer___encoding_8h.html + a8451162b13619940f0a0b438c840fe61 + + + thttp_header_WWW_Authenticate.h C:/doubango/tinyHTTP/include/tinyHTTP/headers/ @@ -682,10 +740,10 @@ #define - THTTP_ACTION_SET_PARAM + THTTP_ACTION_SET_OPTION group__thttp__action__group.html - gad93eb89d30c8892263037a222bcc5b67 - (NAME_STR, VALUE_STR) + gaad52574ad5dfd402db89f6d5f6367065 + (ID_INT, VALUE_STR) #define @@ -778,6 +836,13 @@ ab4937bdabb43b5de1885164160ab1a5b + + enum thhtp_action_option_e + thhtp_action_option_t + thttp__action_8h.html + a0cdf56c18ad08a6123a05bf2d9310286 + + enum thttp_action_type_e thttp_action_type_t @@ -813,6 +878,18 @@ a2daa7482248c60ac251b34539f206712 + + thhtp_action_option_e + thttp__action_8h.html + a82c6f0093fa0bf359c17ee07884206a8 + + + + THTTP_ACTION_OPTION_TIMEOUT + thttp__action_8h.html + a82c6f0093fa0bf359c17ee07884206a8ae29bc22ba4b0dbab91762df2498bec75 + + thttp_action_type_e thttp__action_8h.html @@ -862,9 +939,9 @@ - aptype_param + aptype_option thttp__action_8h.html - ad990d5d648fad6d0d72b341c47d69db1ad776e52763a756961ec25b34c7f13723 + ad990d5d648fad6d0d72b341c47d69db1aa407d88a84c1c7bf54c8890cea11122d @@ -944,9 +1021,9 @@ thttp_dialog_t * - thttp_dialog_get_by_age + thttp_dialog_get_oldest thttp__dialog_8h.html - ac89c8e01aa2b847a0831f06be81b49a7 + a11a7f172eec35d75c54445562db2733e (thttp_dialogs_L_t *dialogs) @@ -1309,6 +1386,13 @@ ga90d831ed5c6d29560ded8e688ac60242 (thttp_message_t *self, const char *content_type, const void *content, size_t size) + + TINYHTTP_API int + thttp_message_append_content + group__thttp__message__group.html + ga3b5a87db25bc5e2056d406b64154e348 + (thttp_message_t *self, const void *content, size_t size) + TINYHTTP_API const thttp_header_t * thttp_message_get_headerAt @@ -1391,10 +1475,10 @@ #define - THTTP_SESSION_SET_PARAM + THTTP_SESSION_SET_OPTION group__thttp__session__group.html - gaa3552649971c1d05d289c422cfbea33d - (NAME_STR, VALUE_STR) + gaf4aedae9e645145e611d849b31bfb989 + (ID_INT, VALUE_STR) #define @@ -1431,6 +1515,13 @@ aa6372f0a6a5f36d90f0b7e10958cfcb0 + + enum thhtp_session_option_e + thhtp_session_option_t + thttp__session_8h.html + aa76da6e651655851903b8ea5a7c154a7 + + enum thttp_session_param_type_e thttp_session_param_type_t @@ -1459,6 +1550,18 @@ a0697a651e7789539f8fa15c2ee3e8565 + + thhtp_session_option_e + thttp__session_8h.html + ab12b176916b17dcff5531c4834fc13d3 + + + + THTTP_SESSION_OPTION_TIMEOUT + thttp__session_8h.html + ab12b176916b17dcff5531c4834fc13d3a94cc57900b9735e4313e16c36cfb3416 + + thttp_session_param_type_e thttp__session_8h.html @@ -1472,9 +1575,9 @@ - sptype_param + sptype_option thttp__session_8h.html - ac60e1a2d905c79691f843b2ff333c7e3a715ca2bc9254a45be6b348648b7cc3de + ac60e1a2d905c79691f843b2ff333c7e3aa5801f22c8e7f0b21775ad29322e3b8a @@ -1945,10 +2048,10 @@ (const char *data, size_t size) - const void * + const tsk_object_def_t * thttp_header_Content_Type_def_t thttp__header___content___type_8c.html - a5ae679ccb04566d4a0cdd09967db0de8 + a911bb4b12f106ad2da6673169f6e37be @@ -1978,6 +2081,33 @@ + + thttp_header_Transfer_Encoding.c + C:/doubango/tinyHTTP/src/headers/ + thttp__header___transfer___encoding_8c + tinyHTTP/headers/thttp_header_Transfer_Encoding.h + + int + thttp_header_Transfer_Encoding_tostring + thttp__header___transfer___encoding_8c.html + ac1593a69da298d7fa2be1f4be559f982 + (const void *header, tsk_buffer_t *output) + + + thttp_header_Transfer_Encoding_t * + thttp_header_Transfer_Encoding_parse + group__thttp__header__group.html + ga3c59176f6b363090c3f89e5238cb3901 + (const char *data, size_t size) + + + const tsk_object_def_t * + thttp_header_Transfer_Encoding_def_t + thttp__header___transfer___encoding_8c.html + adefb146cda0858b796412ae5af31bb86 + + + thttp_header_WWW_Authenticate.c C:/doubango/tinyHTTP/src/headers/ @@ -2020,6 +2150,7 @@ tinyHTTP/parsers/thttp_parser_header.h tinyHTTP/headers/thttp_header_Authorization.h tinyHTTP/headers/thttp_header_Dummy.h + tinyHTTP/headers/thttp_header_Transfer_Encoding.h tinyHTTP/headers/thttp_header_WWW_Authenticate.h #define @@ -2080,6 +2211,7 @@ tinyHTTP/thttp_event.h tinyHTTP/thttp_message.h tinyHTTP/parsers/thttp_parser_message.h + tinyHTTP/headers/thttp_header_Transfer_Encoding.h tinyHTTP/thttp_dialog.h int @@ -2299,6 +2431,13 @@ a00ab51fe52cf9ff43607376dd9b2f663 (va_list *app) + + int + thttp_dialog_Transfering_2_Transfering_X_1xx + thttp__dialog_8c.html + ac58361d510dad68eed62a8ccf8e3ba75 + (va_list *app) + int thttp_dialog_Transfering_2_Terminated_X_message @@ -2329,9 +2468,9 @@ tsk_bool_t - _fsm_cond_i_n401_n407 + _fsm_cond_i_1xx thttp__dialog_8c.html - a28523b05f86797b90eeb14e0564761a1 + a900dbaa94550c911cf068916d7949b52 (thttp_dialog_t *self, thttp_message_t *message) @@ -2341,13 +2480,6 @@ a75bbcbd775498c9c768e4d3536c7cc3b (thttp_dialog_t *self, tsk_fsm_action_id action_id, const thttp_message_t *message, const thttp_action_t *action) - - thttp_dialog_t * - thttp_dialog_get_by_session - thttp__dialog_8c.html - ab0c0bada4df232b6a11b6c5559f1219c - (thttp_dialogs_L_t *dialogs, const struct thttp_session_s *session) - thttp_dialog_t * thttp_dialog_new @@ -2357,9 +2489,9 @@ thttp_dialog_t * - thttp_dialog_get_by_age + thttp_dialog_get_oldest thttp__dialog_8c.html - ac89c8e01aa2b847a0831f06be81b49a7 + a11a7f172eec35d75c54445562db2733e (thttp_dialogs_L_t *dialogs) @@ -2417,6 +2549,13 @@ ga90d831ed5c6d29560ded8e688ac60242 (thttp_message_t *self, const char *content_type, const void *content, size_t size) + + int + thttp_message_append_content + group__thttp__message__group.html + ga3b5a87db25bc5e2056d406b64154e348 + (thttp_message_t *self, const void *content, size_t size) + const thttp_header_t * thttp_message_get_headerAt @@ -2668,6 +2807,13 @@ ga66de413d435bb6a93ae9d7a2647f62bc (const char *data, size_t size) + + thttp_header_Transfer_Encoding_t * + thttp_header_Transfer_Encoding_parse + group__thttp__header__group.html + ga3c59176f6b363090c3f89e5238cb3901 + (const char *data, size_t size) + thttp_header_WWW_Authenticate_t * thttp_header_WWW_Authenticate_parse @@ -2715,10 +2861,10 @@ group__thttp__action__group.html #define - THTTP_ACTION_SET_PARAM + THTTP_ACTION_SET_OPTION group__thttp__action__group.html - gad93eb89d30c8892263037a222bcc5b67 - (NAME_STR, VALUE_STR) + gaad52574ad5dfd402db89f6d5f6367065 + (ID_INT, VALUE_STR) #define @@ -3009,6 +3155,13 @@ ga90d831ed5c6d29560ded8e688ac60242 (thttp_message_t *self, const char *content_type, const void *content, size_t size) + + int + thttp_message_append_content + group__thttp__message__group.html + ga3b5a87db25bc5e2056d406b64154e348 + (thttp_message_t *self, const void *content, size_t size) + const thttp_header_t * thttp_message_get_headerAt @@ -3058,10 +3211,10 @@ group__thttp__session__group.html #define - THTTP_SESSION_SET_PARAM + THTTP_SESSION_SET_OPTION group__thttp__session__group.html - gaa3552649971c1d05d289c422cfbea33d - (NAME_STR, VALUE_STR) + gaf4aedae9e645145e611d849b31bfb989 + (ID_INT, VALUE_STR) #define @@ -3192,10 +3345,10 @@ - tsk_params_L_t * - params + tsk_options_L_t * + options structthttp__action__s.html - a224e951a121249c4cd0d2356d3cce567 + af5b6cc93a0b124046788312d128c9754 @@ -3567,6 +3720,24 @@ + + thttp_header_Transfer_Encoding_s + structthttp__header___transfer___encoding__s.html + + + THTTP_DECLARE_HEADER + structthttp__header___transfer___encoding__s.html + a54cf1e6c501a1773be1a8cffaf0aa865 + + + + char * + encoding + structthttp__header___transfer___encoding__s.html + abfd0452ce0a5ba319ea4d624dc209250 + + + thttp_header_WWW_Authenticate_s structthttp__header___w_w_w___authenticate__s.html @@ -3768,10 +3939,10 @@ - tsk_params_L_t * - params + tsk_options_L_t * + options structthttp__session__s.html - a224e951a121249c4cd0d2356d3cce567 + af5b6cc93a0b124046788312d128c9754 @@ -3823,6 +3994,13 @@ a59460a3ff2c12443d1022e5cc0fba85c + + + TSK_DECLARE_SAFEOBJ + structthttp__session__s.html + a9818e976fd73889027b42c32d628169f + + thttp_stack_s diff --git a/trunk/tinySAK/src/tsk_options.c b/trunk/tinySAK/src/tsk_options.c index 5f3f3274..5e180a7c 100644 --- a/trunk/tinySAK/src/tsk_options.c +++ b/trunk/tinySAK/src/tsk_options.c @@ -37,7 +37,7 @@ /**@defgroup tsk_options_group Options. */ -/* Predicate function used to find an option by id. +/** 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) { diff --git a/trunk/tinyXCAP/include/tinyXCAP/txcap_auid.h b/trunk/tinyXCAP/include/tinyXCAP/txcap_auid.h index c2e7ea8f..f0370cd9 100644 --- a/trunk/tinyXCAP/include/tinyXCAP/txcap_auid.h +++ b/trunk/tinyXCAP/include/tinyXCAP/txcap_auid.h @@ -35,12 +35,15 @@ TXCAP_BEGIN_DECLS -#define TXCAP_AUID_CREATE(type, id, content_type, document_name) tsk_object_new(txcap_auid_def_t, (txcap_auid_type_t)type, (const char*)id, (const char*)content_type, (const char*)document_name) +#define TXCAP_AUID_CREATE(type, id, mime_type, ns, document_name, is_global)\ + tsk_object_new(txcap_auid_def_t, (txcap_auid_type_t)type, (const char*)id, (const char*)mime_type, (const char*)ns, (const char*)document_name, (tsk_bool_t)is_global) /** List of supported AUIDs. */ typedef enum txcap_auid_type_e { + tauid_dummy, /**< any auid */ + tauid_ietf_xcap_caps, /**< xcap-caps */ tauid_ietf_resource_lists, /**< resource-lists */ tauid_ietf_rls_services, /**< rls-services */ @@ -52,7 +55,7 @@ typedef enum txcap_auid_type_e tauid_oma_directory, /**< org.openmobilealliance.xcap-directory */ tauid_oma_deferred_list, /**< org.openmobilealliance.deferred-list */ tauid_oma_pres_content, /**< org.openmobilealliance.pres-content*/ - tauid_oma_shared_groups /**< org.openmobilealliance.groups */ + tauid_oma_shared_groups /**< org.openmobilealliance.group-usage-list */ } txcap_auid_type_t; @@ -64,13 +67,20 @@ typedef struct txcap_auid_s txcap_auid_type_t type; char* id; /**< The id of the AUID (e.g. 'xcap-caps' or 'rls-services' or 'resource-lists' or ...)*/ - char* content_type; /**< The default MIME-type of the document associated to this auid. */ + char* mime_type; /**< The default MIME-type of the document associated to this auid. */ + char* ns; /**< The namespace associated to this auid. */ char* document_name; /**< The default name of the document associated to this auid. */ + tsk_bool_t global; /**< Indicates the auid scope. */ } txcap_auid_t; typedef tsk_list_t txcap_auids_L_t; +int txcap_auid_register(txcap_auids_L_t* auids, const char* id, const char* mime_type, const char* ns, const char* document_name, tsk_bool_t is_global); +txcap_auid_t* txcap_auid_get_by_id(txcap_auids_L_t* auids, const char* id); +int txcap_auids_init(txcap_auids_L_t** auids); + + TINYXCAP_GEXTERN const tsk_object_def_t *txcap_auid_def_t; TXCAP_END_DECLS diff --git a/trunk/tinyXCAP/include/tinyXCAP/txcap_document.h b/trunk/tinyXCAP/include/tinyXCAP/txcap_document.h new file mode 100644 index 00000000..4b7851fe --- /dev/null +++ b/trunk/tinyXCAP/include/tinyXCAP/txcap_document.h @@ -0,0 +1,43 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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 txcap_document.h + * @brief XCAP documents. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYXCAP_TXCAP_DOCUMENT_H +#define TINYXCAP_TXCAP_DOCUMENT_H + +#include "tinyXCAP_config.h" + +#include "txcap.h" + +TXCAP_BEGIN_DECLS + +TINYXCAP_API char* txcap_selector_get_document(const txcap_stack_handle_t* stack, const char* auid_id); +TINYXCAP_API char* txcap_selector_get_document_2(const char* xcap_root, const char* auid_id, const char* xui, const char* doc_name); + +TXCAP_END_DECLS + +#endif /* TINYXCAP_TXCAP_DOCUMENT_H */ diff --git a/trunk/tinyXCAP/include/tinyXCAP/txcap_node.h b/trunk/tinyXCAP/include/tinyXCAP/txcap_node.h new file mode 100644 index 00000000..5a240ff8 --- /dev/null +++ b/trunk/tinyXCAP/include/tinyXCAP/txcap_node.h @@ -0,0 +1,99 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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 txcap_node.h + * @brief XCAP nodes. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYXCAP_TXCAP_NODE_H +#define TINYXCAP_TXCAP_NODE_H + +#include "tinyXCAP_config.h" + +#include "tsk_common.h" + +TXCAP_BEGIN_DECLS + +typedef enum txcap_selector_param_type_e +{ + xcapp_node_null = tsk_null, + + xcapp_node_name, + xcapp_node_pos, + xcapp_node_attribute, + xcapp_node_pos_n_attribute, + xcapp_node_namespace +} +txcap_selector_param_type_t; + +/**@ingroup txcap_selector_group +* @def TXCAP_SELECTOR_NODE_SET_NAME +* Node selection step. Selects by name as per RFC 4825 subclause 6.3. +* @param QNAME_STR The name of the node to select. The @a QName grammar is defined in the XML namespaces [3] specification (const char*). +*/ +/**@ingroup txcap_selector_group +* @def TXCAP_SELECTOR_NODE_SET_POS +* Node selection step. Selects by position as per RFC 4825 subclause 6.3. +* @param QNAME_STR The name of the node to select. The @a QName grammar is defined in the XML namespaces [3] specification. +* @param POS_UINT The position of the node to select (1*DIGIT) (unsigned int). +*/ +/**@ingroup txcap_selector_group +* @def TXCAP_SELECTOR_NODE_SET_ATTRIBUTE +* Node selection step. Selects by position and attribute as per RFC 4825 subclause 6.3. +* @param QNAME_STR The name of the node to select. The @a QName grammar is defined in the XML namespaces [3] specification (const char*). +* @param ATT_QNAME_STR The name of the attribute (const char*). +* @param ATT_VALUE_STR The value of the attribute. @a AttValue grammar is defined in the XML specification XML 1.0 [1] (const char*). +*/ +/**@ingroup txcap_selector_group +* @def TXCAP_SELECTOR_NODE_SET_POS_ATTRIBUTE +* Node selection step. Selects by position and attribute as per RFC 4825 subclause 6.3. +* @param QNAME_STR The name of the node to select. The @a QName grammar is defined in the XML namespaces [3] specification. +* @param POS_UINT The position of the node to select (1*DIGIT) (unsigned int). +* @param ATT_QNAME_STR The name of the attribute (const char*). +* @param ATT_VALUE_STR The value of the attribute. @a AttValue grammar is defined in the XML specification XML 1.0 [1] (const char*). +*/ +/**@ingroup txcap_selector_group +* @def TXCAP_SELECTOR_NODE_SET_NAMESPACE +* Node selection step. Appends XML namespace("namespace::*") as per RFC 4825 subclause 6.3. +* @param PREFIX_STR The prefix to use for this namespace (const char*). +* @param VALUE_STR The value of the namespace (const char*). +*/ +/**@ingroup txcap_selector_group +* @def TXCAP_SELECTOR_NODE_SET_NULL +* Ends node selection steps. Must always be present and should be the last one. +*/ +#define TXCAP_SELECTOR_NODE_SET_NAME(QNAME_STR) xcapp_node_name, (const char*)QNAME_STR +#define TXCAP_SELECTOR_NODE_SET_POS(QNAME_STR, POS_UINT) xcapp_node_pos, (const char*)QNAME_STR, (unsigned int)POS_INT +#define TXCAP_SELECTOR_NODE_SET_ATTRIBUTE(QNAME_STR, ATT_QNAME_STR, ATT_VALUE_STR) xcapp_node_attribute, (const char*)QNAME_STR, (const char*)ATT_QNAME_STR, (const char*)ATT_VALUE_STR +#define TXCAP_SELECTOR_NODE_SET_POS_ATTRIBUTE(QNAME_STR, POS_UINT, ATT_QNAME_STR, ATT_VALUE_STR) xcapp_node_pos_n_attribute, (const char*)QNAME_STR, (unsigned int)POS_UINT, (const char*)ATT_QNAME_STR, (const char*)ATT_VALUE_STR +#define TXCAP_SELECTOR_NODE_SET_NAMESPACE(PREFIX_STR, VALUE_STR) xcapp_node_namespace, (const char*)PREFIX_STR, (const char*)VALUE_STR + +#define TXCAP_SELECTOR_NODE_SET_NULL() xcapp_node_null + +TINYXCAP_API char* txcap_selector_get_node(const char* auid_id, ...); +TINYXCAP_API char* txcap_selector_get_node_2(const char* auid_id, va_list* app); + +TXCAP_END_DECLS + +#endif /* TINYXCAP_TXCAP_NODE_H */ diff --git a/trunk/tinyXCAP/include/tinyXCAP/txcap_selector.h b/trunk/tinyXCAP/include/tinyXCAP/txcap_selector.h new file mode 100644 index 00000000..34f8a008 --- /dev/null +++ b/trunk/tinyXCAP/include/tinyXCAP/txcap_selector.h @@ -0,0 +1,41 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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 txcap_selector.h + * @brief XCAP selector. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYXCAP_TXCAP_SELECTOR_H +#define TINYXCAP_TXCAP_SELECTOR_H + +#include "tinyXCAP_config.h" + +TXCAP_BEGIN_DECLS + +TINYXCAP_API char* txcap_selector_get_full(const txcap_stack_handle_t* stack, const char* auid_id, ...); +TINYXCAP_API char* txcap_selector_get_full_2(const char* xcap_root, const char* auid_id, const char* xui, const char* doc_name, ...); + +TXCAP_END_DECLS + +#endif /* TINYXCAP_TXCAP_SELECTOR_H */ diff --git a/trunk/tinyXCAP/include/tinyxcap.h b/trunk/tinyXCAP/include/tinyxcap.h index e69de29b..3963655f 100644 --- a/trunk/tinyXCAP/include/tinyxcap.h +++ b/trunk/tinyXCAP/include/tinyxcap.h @@ -0,0 +1,31 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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 tinyxcap.h + * @brief API functions. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#include "txcap.h" + +#include "tinyXCAP/txcap_document.h" \ No newline at end of file diff --git a/trunk/tinyXCAP/include/txcap.h b/trunk/tinyXCAP/include/txcap.h index a5d84d2f..b721bb24 100644 --- a/trunk/tinyXCAP/include/txcap.h +++ b/trunk/tinyXCAP/include/txcap.h @@ -31,8 +31,74 @@ #include "tinyXCAP_config.h" +#include "tinyXCAP/txcap_auid.h" + +#include "tsk_options.h" + +#include "tinyhttp.h" + TXCAP_BEGIN_DECLS +typedef enum txcap_stack_option_e +{ + TXCAP_STACK_OPTION_TIMEOUT, + TXCAP_STACK_OPTION_TTL, + + TXCAP_STACK_OPTION_PASSWORD, + TXCAP_STACK_OPTION_XUI, +} +txcap_stack_option_t; + +typedef enum txcap_stack_param_type_e +{ + xcapp_null = tsk_null, + + xcapp_option, + xcapp_header, + xcapp_context, + xcapp_auid, +} +txcap_stack_param_type_t; + + +#define TXCAP_STACK_SET_OPTION(ID_INT, VALUE_STR) xcapp_option, (txcap_stack_option_t)ID_INT, (const char*)VALUE_STR +#define TXCAP_STACK_SET_PASSWORD(PASSWORD_STR) TXCAP_STACK_SET_OPTION(TXCAP_STACK_OPTION_PASSWORD, PASSWORD_STR) +#define TXCAP_STACK_SET_XUI(XUI_STR) TXCAP_STACK_SET_OPTION(TXCAP_STACK_OPTION_XUI, XUI_STR) +#define TXCAP_STACK_SET_HEADER(NAME_STR, VALUE_STR) xcapp_header, (const char*)NAME_STR, (const char*)VALUE_STR +#define TXCAP_STACK_SET_CONTEXT(CTX_PTR) xcapp_context, (const void*)CTX_PTR +#define TXCAP_STACK_SET_AUID(ID_STR, MIME_TYPE_STR, NS_STR, DOC_NAME_STR, IS_GLOBAL_BOOL) xcapp_auid, (const char*)ID_STR, (const char*)MIME_TYPE_STR, (const char*)NS_STR, (const char*)DOC_NAME_STR, (tsk_bool_t)IS_GLOBAL_BOOL +#define TXCAP_STACK_SET_SELECTOR(...) + +#define TXCAP_STACK_SET_NULL() xcapp_null + + +typedef struct txcap_stack_s +{ + TSK_DECLARE_OBJECT; + + char* xui; /**< user's name as per RFC 4825 subclause 4.Also used to fill @b "X-3GPP-Intended-Identity" header.*/ + char* password; /**< user's password used to authenticate to the XDMS . */ + char* xcap_root; /**< xcap-root URI as per RFC 4825 subclause 6.1. MUST be a valid HTPP/HTTPS URL and will be used to build all request-uris. */ + + thttp_session_handle_t* http_session; + thttp_stack_handle_t* http_stack; /**< http/https stack */ + + tsk_options_L_t *options; /**< list of user options */ + const void* context; /**< user's context */ + txcap_auids_L_t* auids; /**< user's auids */ + + TSK_DECLARE_SAFEOBJ; +} +txcap_stack_t; +typedef void txcap_stack_handle_t; + +TINYXCAP_API txcap_stack_handle_t* txcap_stack_create(thttp_stack_callback callback, const char* xui, const char* password, const char* xcap_root, ...); +TINYXCAP_API int txcap_stack_start(txcap_stack_handle_t* self); +TINYXCAP_API int txcap_stack_set(txcap_stack_handle_t* self, ...); +TINYXCAP_API int txcap_stack_perform(txcap_stack_handle_t* self, const char* urlstring, ...); +TINYXCAP_API int txcap_stack_stop(txcap_stack_handle_t* self); + +TINYXCAP_GEXTERN const tsk_object_def_t *txcap_stack_def_t; TXCAP_END_DECLS diff --git a/trunk/tinyXCAP/src/txcap.c b/trunk/tinyXCAP/src/txcap.c index 6a4f32d4..6f2c1e80 100644 --- a/trunk/tinyXCAP/src/txcap.c +++ b/trunk/tinyXCAP/src/txcap.c @@ -26,4 +26,267 @@ * * @date Created: Sat Nov 8 16:54:58 2009 mdiop */ -#include "txcap.h" \ No newline at end of file +#include "txcap.h" + +#include "tinyHTTP/thttp_url.h" + +/**@defgroup txcap_stack_group XCAP stack +*/ + +/** Internal function used to set options. +*/ +int __txcap_stack_set(txcap_stack_t* self, va_list *app) +{ + txcap_stack_param_type_t curr; + + if(!self){ + return -1; + } + + while((curr = va_arg(*app, txcap_stack_param_type_t)) != xcapp_null){ + switch(curr){ + case xcapp_option: + { /* (txcap_stack_option_t)ID_INT, (const char*)VALUE_STR */ + txcap_stack_option_t ID_IN = va_arg(*app, txcap_stack_option_t); + const char* VALUE_STR = va_arg(*app, const char*); + + + + break; + } + + case xcapp_header: + { /* (const char*)NAME_STR, (const char*)VALUE_STR */ + const char* NAME_STR = va_arg(*app, const char*); + const char* VALUE_STR = va_arg(*app, const char*); + break; + } + + case xcapp_context: + { /* (const void*)CTX_PTR */ + const void* CTX_PTR = va_arg(*app, const void*); + break; + } + + case xcapp_auid: + { /* (const char*)ID_STR, (const char*)MIME_TYPE_STR, (const char*)NS_STR, (const char*)DOC_NAME_STR, (tsk_bool_t)IS_GLOBAL_BOOL */ + const char* ID_STR = va_arg(*app, const char*); + const char* MIME_TYPE_STR = va_arg(*app, const char*); + const char* NS_STR = va_arg(*app, const char*); + const char* DOC_NAME_STR = va_arg(*app, const char*); + tsk_bool_t IS_GLOBAL_BOOL = va_arg(*app, tsk_bool_t); + + if(txcap_auid_register(self->auids, ID_STR, MIME_TYPE_STR, NS_STR, DOC_NAME_STR, IS_GLOBAL_BOOL)){ + // do nothing + } + + break; + } + + default: + { + TSK_DEBUG_ERROR("NOT SUPPORTED."); + goto bail; + } + } /* switch */ + } /* while */ + return 0; + +bail: + return -2; +} + +/**@ingroup txcap_stack_group +* Creates new XCAP stack. +* @param callback Poiner to the callback function to call when new messages come to the transport layer. +* Can be set to Null if you don't want to be alerted. +* @param xui user's id as per RFC 4825 subclause 4. Also used to fill @b "X-3GPP-Intended-Identity" header. +* This paramter is mandatory and must not be null. If for any reason you'd like to update the user's id, then use @ref TXCAP_STACK_SET_XUI(). +* @param password user's password used to authenticate to the XDMS. +* This parameter is not mandatory. If for any reason you'd like to update the password, then use @ref TXCAP_STACK_SET_PASSWORD(). +* @param xcap_root xcap-root URI as per RFC 4825 subclause 6.1, used to build all request-uris. +* This parameter is not mandatory and must be a valid HTPP/HTTPS URL. +* @param ... User configuration. You must use @a TXCAP_STACK_SET_*() macros to set these options. +* The list of options must always and with @ref TXCAP_STACK_SET_NULL() even if these is no option to pass to the stack. +* @retval A Pointer to the newly created stack if succeed and @a Null otherwise. +* A stack is a well-defined object. +* +* @code +* +* @endcode +* +* @sa @ref txcap_stack_set +*/ +txcap_stack_handle_t* txcap_stack_create(thttp_stack_callback callback, const char* xui, const char* password, const char* xcap_root, ...) +{ + txcap_stack_handle_t* ret = tsk_null; + + if(!xui || !xcap_root){ + TSK_DEBUG_ERROR("Both xui and xcap_root are mandatory and should be non-null"); + goto bail; + } + + /* check url validity */ + if(!thttp_url_isok(xcap_root)){ + TSK_DEBUG_ERROR("%s is not a valid HTTP/HTTPS url", xcap_root); + goto bail; + } + + if(!(ret = tsk_object_new(txcap_stack_def_t, callback, xui, password, xcap_root))){ + TSK_DEBUG_FATAL("Failed to create the XCAP stack"); + goto bail; + } + +bail: + return ret; +} + +/**@ingroup txcap_stack_group +* Starts the stack. +* @param self A pointer to the stack to stark. The stack shall be created using @ref txcap_stack_create(). +* @retval Zero if succeed and non-zero error code otherwise. +* @sa @ref txcap_stack_stop +*/ +int txcap_stack_start(txcap_stack_handle_t* self) +{ + int ret = -1; + txcap_stack_t* stack = self; + + if(!stack){ + goto bail; + } + + ret = thttp_stack_start(stack->http_stack); + +bail: + return ret; +} + +/**@ingroup txcap_stack_group +* Updates the stack configuration. +* @param self The XCAP stack to update. The stack shall be created using @ref txcap_stack_create(). +* @param ... Any @a TXCAP_STACK_SET_*() macros. MUST ends with @ref TXCAP_STACK_SET_NULL(). +* @retval Zero if succeed and non-zero error code otherwise. +* +* @code +* +* @endcode +* +* @sa @ref txcap_stack_create +*/ +int txcap_stack_set(txcap_stack_handle_t* self, ...) +{ + int ret = -1; + va_list ap; + + if(!self){ + goto bail; + } + + va_start(ap, self); + ret = __txcap_stack_set(self, &ap); + va_end(ap); + +bail: + return ret; +} + +/**@ingroup txcap_stack_group +*/ +int txcap_stack_perform(txcap_stack_handle_t* self, const char* urlstring, ...) +{ + +} + +/**@ingroup txcap_stack_group +* Stops the stack. The stack must already be started. +* @param self A pointer to the stack to stop. The stack shall be created using @ref txcap_stack_create(). +* @retval Zero if succeed and non-zero error code otherwise. +* @sa @ref txcap_stack_create +*/ +int txcap_stack_stop(txcap_stack_handle_t* self) +{ + int ret = -1; + txcap_stack_t* stack = self; + + if(!stack){ + goto bail; + } + else{ + ret = thttp_stack_stop(stack->http_stack); + } + +bail: + return ret; +} + + + + + + + + + +//======================================================== +// XCAP stack object definition +// +static tsk_object_t* _txcap_stack_create(tsk_object_t * self, va_list * app) +{ + txcap_stack_t *stack = self; + if(stack){ + thttp_stack_callback callback; + tsk_safeobj_init(stack); + + callback = va_arg(*app, thttp_stack_callback); + stack->xui = tsk_strdup( va_arg(*app, const char*) ); + stack->password = tsk_strdup( va_arg(*app, const char*) ); + stack->xcap_root = tsk_strdup( va_arg(*app, const char*) ); + + /* HTTP/HTTPS resources */ + stack->http_stack = thttp_stack_create(callback, + THTTP_STACK_SET_NULL()); + stack->http_session = thttp_session_create(stack->http_stack , + THTTP_SESSION_SET_NULL()); + + /* Options */ + stack->options = TSK_LIST_CREATE(); + + /* AUIDs */ + txcap_auids_init(&stack->auids); + } + return self; +} + +static tsk_object_t* txcap_stack_destroy(tsk_object_t* self) +{ + txcap_stack_t *stack = self; + if(stack){ + /* vars */ + TSK_FREE(stack->xui); + TSK_FREE(stack->password); + TSK_FREE(stack->xcap_root); + + /* HTTP/HTTPS resources */ + TSK_OBJECT_SAFE_FREE(stack->http_session); + TSK_OBJECT_SAFE_FREE(stack->http_stack); + + /* Options */ + TSK_OBJECT_SAFE_FREE(stack->options); + + /* AUIDs */ + TSK_OBJECT_SAFE_FREE(stack->auids); + + tsk_safeobj_deinit(stack); + } + return self; +} + +static const tsk_object_def_t txcap_stack_def_s = +{ + sizeof(txcap_stack_t), + _txcap_stack_create, + txcap_stack_destroy, + tsk_null, +}; +const tsk_object_def_t *txcap_stack_def_t = &txcap_stack_def_s; diff --git a/trunk/tinyXCAP/src/txcap_auid.c b/trunk/tinyXCAP/src/txcap_auid.c index 42ff5fe7..28298954 100644 --- a/trunk/tinyXCAP/src/txcap_auid.c +++ b/trunk/tinyXCAP/src/txcap_auid.c @@ -28,14 +28,235 @@ */ #include "tinyXCAP/txcap_auid.h" +#include "tsk_string.h" +#include "tsk_memory.h" +#include "tsk_debug.h" + + +typedef struct auid_s +{ + txcap_auid_type_t type; + const char* id; + const char* mime_type; + const char* ns; + const char* document_name; + tsk_bool_t global; +} +auid_t; + +/** List of all default auids +*/ +static const auid_t __txcap_auids[] = +{ + /*== xcap-caps ==*/{ + tauid_ietf_xcap_caps, + "xcap-caps", + "application/xcap-caps+xml", + "urn:ietf:params:xml:ns:xcap-caps", + "index", + tsk_true + }, + + /*== resource-lists ==*/{ + tauid_ietf_resource_lists, + "resource-lists", + "application/resource-lists+xml", + "urn:ietf:params:xml:ns:resource-lists", + "index", + tsk_false + }, + + /*== rls-services ==*/{ + tauid_ietf_rls_services, + "rls-services", + "application/rls-services+xml", + "urn:ietf:params:xml:ns:resource-lists", + "index", + tsk_false + }, + + /*== pres-rules ==*/{ + tauid_ietf_pres_rules, + "pres-rules", + "application/auth-policy+xml", + "urn:ietf:params:xml:ns:pres-rules", + "index", + tsk_false + }, + + /*== org.openmobilealliance.pres-rules ==*/{ + tauid_oma_pres_rules, + "org.openmobilealliance.pres-rules", + "application/auth-policy+xml", + "urn:ietf:params:xml:ns:common-policy", + "pres-rules", + tsk_false + }, + + /*== directory ==*/{ + tauid_ietf_directory, + "directory", + "application/directory+xml", + "urn:ietf:params:xml:ns:xcap-directory", + "directory.xml", + tsk_false + }, + + /*== org.openmobilealliance.xcap-directory ==*/{ + tauid_oma_directory, + "org.openmobilealliance.xcap-directory", + "application/vnd.oma.xcap-directory+xml", + "urn:oma:xml:xdm:xcap-directory", + "directory.xml", + tsk_false + }, + + /*== org.openmobilealliance.pres-content ==*/{ + tauid_oma_pres_content, + "org.openmobilealliance.pres-content", + "application/vnd.oma.pres-content+xml", + "urn:oma:xml:prs:pres-content", + "oma_status-icon/rcs_status_icon", + tsk_false + }, + + /*== org.openmobilealliance.conv-history ==*/{ + tauid_oma_conv_history, + "org.openmobilealliance.conv-history", + "application/vnd.oma.im.history-list+xml", + "urn:oma:xml:im:history-list", + "conv-history", + tsk_false + }, + + /*== org.openmobilealliance.deferred-list ==*/{ + tauid_oma_deferred_list, + "org.openmobilealliance.deferred-list", + "application/vnd.oma.im.deferred-list+xml", + "urn:oma:xml:im:history-list", + "deferred-list", + tsk_false + }, + + /*== org.openmobilealliance.group-usage-list ==*/{ + tauid_oma_shared_groups, + "org.openmobilealliance.group-usage-list", + "application/vnd.oma.group-usage-list+xml", + "rn:ietf:params:xml:ns:resource-lists", + "index", + tsk_false + }, +}; + +/** Predicate function used to find an option by id. +*/ +static int pred_find_auid_by_id(const tsk_list_item_t *item, const void *id) +{ + if(item && item->data){ + txcap_auid_t *auid = item->data; + return tsk_stricmp(auid->id, (const char*)id); + } + return -1; +} +/** Initialze the list of auids with default values from __txcap_auids +* auids must be null; +*/ +int txcap_auids_init(txcap_auids_L_t** auids) +{ + size_t i; + size_t count; + if(!auids){ + TSK_DEBUG_ERROR("invalid parameter."); + return -1; + } + else if(*auids){ + TSK_DEBUG_WARN("auids already initialized."); + } + else{ + *auids = TSK_LIST_CREATE(); + } + + count = sizeof(__txcap_auids)/sizeof(auid_t); + for(i = 0; idata)->mime_type, mime_type); + tsk_strupdate(&((txcap_auid_t*)item->data)->ns, ns); + tsk_strupdate(&((txcap_auid_t*)item->data)->document_name, document_name); + ((txcap_auid_t*)item->data)->global = is_global; + ret = 0; + } + else{ + txcap_auid_t* auid; + if((auid = TXCAP_AUID_CREATE(tauid_dummy, id, mime_type, ns, document_name, is_global))){ + tsk_list_push_back_data(auids, (void**)&auid); + ret = 0; + }else{ + ret = -2; + } + } + return ret; +} + +/** +* Finds an AUID by id (case-insensitive). +* @param auids List of AUIDs from which to find the AUID. +* @param id The @a id of the AUID to find. +* @retval An AUID with the matching id or null if does not exist. +* It's up to you to free the returned object. +*/ +txcap_auid_t* txcap_auid_get_by_id(txcap_auids_L_t* auids, const char* id) +{ + const txcap_auid_t* ret = tsk_null; + const tsk_list_item_t* item; + + if(!auids){ + return tsk_null; + } + + if((item = tsk_list_find_item_by_pred(auids, pred_find_auid_by_id, id))){ + return tsk_object_ref((void*)item->data); + } + else{ + return tsk_null; + } + +} //================================================================================================= // AUID object definition @@ -44,31 +265,40 @@ static tsk_object_t* txcap_auid_create(tsk_object_t * self, va_list * app) { txcap_auid_t *auid = self; if(auid){ - string->value = tsk_strdup(value); + auid->type = va_arg(*app, txcap_auid_type_t); + auid->id = tsk_strdup( va_arg(*app, const char*) ); + auid->mime_type = tsk_strdup( va_arg(*app, const char*) ); + auid->ns = tsk_strdup( va_arg(*app, const char*) ); + auid->document_name = tsk_strdup( va_arg(*app, const char*) ); + auid->global = va_arg(*app, tsk_bool_t); } return self; } static tsk_object_t* txcap_auid_destroy(tsk_object_t * self) { - txcap_auid_t *string = self; - if(string){ - TSK_FREE(string->value); + txcap_auid_t *auid = self; + if(auid){ + TSK_FREE(auid->id); + TSK_FREE(auid->mime_type); + TSK_FREE(auid->ns); + TSK_FREE(auid->document_name); } - + return self; } -static int txcap_auid_cmp(const tsk_object_t *_s1, const tsk_object_t *_s2) +static int txcap_auid_cmp(const tsk_object_t *_a1, const tsk_object_t *_a2) { - const txcap_auid_t *s1 = _s1; - const txcap_auid_t *s2 = _s2; + const txcap_auid_t *a1 = _a1; + const txcap_auid_t *a2 = _a2; - if(s1 && s2){ - return tsk_stricmp(s1->value, s2->value); + if(a1 && a2){ + return tsk_stricmp(a1->id, a2->id); + } + else{ + return -1; } - else if(!s1 && !s2) return 0; - else return -1; } static const tsk_object_def_t txcap_auid_def_s = diff --git a/trunk/tinyXCAP/src/txcap_document.c b/trunk/tinyXCAP/src/txcap_document.c new file mode 100644 index 00000000..21ec6d6c --- /dev/null +++ b/trunk/tinyXCAP/src/txcap_document.c @@ -0,0 +1,137 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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 txcap_document.c + * @brief XCAP documents. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#include "tinyXCAP/txcap_document.h" + +#include "tinyXCAP/txcap_auid.h" + +/**@ingroup txcap_selector_group +* Create a custom XCAP document selector URI as per RFC 4825 subclause 6.2. +* @param stack The XCAP stack from which to load the user's preference (xcap-root, AUIDs, XUI, name of the document, ...). +* Should be created using @ref txcap_stack_create(). +* @param auid_id The Application Unique ID. Unique identifier within the namespace of application unique IDs created by this specification (RFC 4825) +* that differentiates XCAP resources accessed by one application from XCAP resources accessed by another. +* For more information see RFC 4825 subclause 4. +* @retval The HTTP/HTTPS URI containing the XCAP root and document selector, resulting in the selection of a specific document. As a +* result, performing a GET against the document URI would retrieve the document. +* If supplied parameters are not valid this method will return NULL. +* You must free the returned string. +* +* @code +* // resource-lists document +* char* urlstring; +* if((urlstring = txcap_selector_get_document(stack, "resource-lists"))){ +* TSK_FREE(urlstring); +* } +* @endcode +* +* @code +* // xcap-caps document +* char* urlstring; +* if((urlstring = txcap_selector_get_document(stack, "xcap-caps"))){ +* TSK_FREE(urlstring); +* } +* @endcode +* +* @sa @ref txcap_selector_get_document_2
@ref txcap_selector_get_full
@ref txcap_selector_get_full_2 +*/ +char* txcap_selector_get_document(const txcap_stack_handle_t* stack, const char* auid_id) +{ + char* ret = tsk_null; + txcap_auid_t* auid; + + const txcap_stack_t* xcap_stack = stack; + if(xcap_stack && xcap_stack->auids && auid_id){ + if((auid = txcap_auid_get_by_id(xcap_stack->auids, auid_id))){ + ret = txcap_selector_get_document_2(xcap_stack->xcap_root, auid->id, auid->global? tsk_null: xcap_stack->xui, auid->document_name); + TSK_OBJECT_SAFE_FREE(auid); + } + else{ + TSK_DEBUG_ERROR("Fail to find AUID with id %s.", auid_id); + } + } + else{ + TSK_DEBUG_ERROR("Invalid parameter."); + } + return ret; +} + +/**@ingroup txcap_selector_group +* Create a custom XCAP document selector URI as per RFC 4825 subclause 6.2. +* @param xcap_root The XCAP Root URI (valid HTTP/HTTPS URL). A context that contains all the documents across all +* application usages and users that are managed by the server. For more information see RFC 4825 subclause 4. +* @param auid_id The Application Unique ID. Unique identifier within the namespace of application unique IDs created by this specification (RFC 4825) +* that differentiates XCAP resources accessed by one application from XCAP resources accessed by another. +* For more information see RFC 4825 subclause 4. +* @param xui The XCAP User Identifier. The XUI is a string, valid as a path element in an HTTP URI, that is associated with each user served +* by the XCAP server. For more information see RFC 4825 subclause 4. +* For global document, this parameter should be NULL or equal to "global". +* @param doc_name The name of the document (e.g. index). +* @retval The HTTP/HTTPS URI containing the XCAP root and document selector, resulting in the selection of a specific document. As a + result, performing a GET against the document URI would retrieve the document. +* If supplied parameters are not valid this method will return NULL. +* You must free the returned string. +* +* @code +* // resource-lists document +* char* urlstring; +* if((urlstring = txcap_selector_get_document("http://doubango.org:8080/services", "resource-lists", "sip:mamadou@doubango.org", "index"))){ +* TSK_FREE(urlstring); +* } +* @endcode +* +* @code +* // xcap-caps document +* char* urlstring; +* if((urlstring = txcap_selector_get_document("http://doubango.org:8080/services", "xcap-caps", "global", "index"))){ +* TSK_FREE(urlstring); +* } +* @endcode +* +* @sa @ref txcap_selector_get_document
@ref txcap_selector_get_full
@ref txcap_selector_get_full_2 +*/ +char* txcap_selector_get_document_2(const char* xcap_root, const char* auid_id, const char* xui, const char* doc_name) +{ + char* ret = tsk_null; + + if(!xcap_root || !auid_id || !doc_name){ + TSK_DEBUG_ERROR("Invalid parameter"); + return tsk_null; + } + + if(!xui || tsk_striequals("global", xui)){ + /* xdm-root/auid-name/global/doc-name */ + tsk_sprintf(&ret, "%s/%s/global/%s", xcap_root, auid_id, doc_name); + } + else{ + /* xdm-root/auid-name/users/xui/doc-name */ + tsk_sprintf(&ret, "%s/%s/users/%s/%s", xcap_root, auid_id, xui, doc_name); + } + + return ret; +} \ No newline at end of file diff --git a/trunk/tinyXCAP/src/txcap_node.c b/trunk/tinyXCAP/src/txcap_node.c new file mode 100644 index 00000000..a63f11a1 --- /dev/null +++ b/trunk/tinyXCAP/src/txcap_node.c @@ -0,0 +1,149 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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 txcap_node.c + * @brief XCAP nodes. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#include "tinyXCAP/txcap_node.h" + +#include "tsk_string.h" +#include "tsk_buffer.h" +#include "tsk_memory.h" +#include "tsk_debug.h" + +#include /* strlen() */ + +/**@ingroup txcap_selector_group +* Gets the Node Url. +* @param The id of the AUID (e.g 'resource-lists'). +* @param ... Node selection steps. You must use @a TXCAP_SELECTOR_NODE_SET*() macros to set these steps. +* The list of parameters must end with @ref TXCAP_SELECTOR_NODE_SET_NULL() even if there is no step.
+* @retval The Url of the node (e.g. 'resource-lists/list[2]'). +* +* @code +* @endcode +* +* @sa @ref txcap_selector_get_node_2
@ref txcap_selector_get_document
@ref txcap_selector_get_document_2
@ref txcap_selector_get_full
@ref txcap_selector_get_full_2 +*/ +char* txcap_selector_get_node(const char* auid_id, ...) +{ + char* ret = tsk_null; + va_list ap; + + va_start(ap, auid_id); + ret = txcap_selector_get_node_2(auid_id, &ap); + va_end(ap); + + return ret; +} + +/**@ingroup txcap_selector_group +* Gets the Node Url. +* @param The id of the AUID (e.g 'resource-lists'). +* @param app Node selection steps. You must use @a TXCAP_SELECTOR_NODE_SET*() macros to set these steps. +* The list of parameters must end with @ref TXCAP_SELECTOR_NODE_SET_NULL() even if there is no step.
+* @retval The Url of the node (e.g. 'resource-lists/list[2]'). +* +* @code +* @endcode +* +* @sa @ref txcap_selector_get_node
@ref txcap_selector_get_document
@ref txcap_selector_get_document_2
@ref txcap_selector_get_full
@ref txcap_selector_get_full_2 +*/ +char* txcap_selector_get_node_2(const char* auid_id, va_list* app) +{ + char* ret = tsk_null; + char* namespace = tsk_null; + tsk_buffer_t* buffer = TSK_BUFFER_CREATE_NULL(); + txcap_selector_param_type_t step; + + while((step = va_arg(*app, txcap_selector_param_type_t)) != xcapp_node_null){ + switch(step){ + case xcapp_node_name: + { /* (const char*)QNAME_STR */ + const char* QNAME_STR = va_arg(*app, const char*); + if(tsk_buffer_appendEx(buffer, "/%s", QNAME_STR)){ + goto bail; + } + break; + } + case xcapp_node_pos: + { /* (const char*)QNAME_STR, (unsigned int)POS_INT */ + const char* QNAME_STR = va_arg(*app, const char*); + unsigned int POS_INT = va_arg(*app, unsigned int); + tsk_buffer_appendEx(buffer, "/%s%%5B%u%%5D", + QNAME_STR, POS_INT); + break; + } + case xcapp_node_attribute: + { /* (const char*)QNAME_STR, (const char*)ATT_QNAME_STR, (const char*)ATT_VALUE_STR */ + const char* QNAME_STR = va_arg(*app, const char*); + const char* ATT_QNAME_STR = va_arg(*app, const char*); + const char* ATT_VALUE_STR = va_arg(*app, const char*); + tsk_buffer_appendEx(buffer, "/%s%%5B@%s=%%22%s%%22%%5D", + QNAME_STR, ATT_QNAME_STR, ATT_VALUE_STR); + break; + } + case xcapp_node_pos_n_attribute: + { /* (const char*)QNAME_STR, (unsigned int)POS_UINT, (const char*)ATT_QNAME_STR, (const char*)ATT_VALUE_STR */ + const char* QNAME_STR = va_arg(*app, const char*); + unsigned int POS_UINT = va_arg(*app, unsigned int); + const char* ATT_QNAME_STR = va_arg(*app, const char*); + const char* ATT_VALUE_STR = va_arg(*app, const char*); + tsk_buffer_appendEx(buffer, "/%s%%5B%u%%5D%%5B@%s=%%22%s%%22%%5D", + QNAME_STR, POS_UINT, ATT_QNAME_STR, ATT_VALUE_STR); + break; + } + case xcapp_node_namespace: + { /* (const char*)PREFIX_STR, (const char*)VALUE_STR */ + const char* PREFIX_STR = va_arg(*app, const char*); + const char* VALUE_STR = va_arg(*app, const char*); + char* temp = tsk_null; + tsk_sprintf(&temp, "%sxmlns(%s=%%22%s%%22)", + namespace?"":"%3F",PREFIX_STR, VALUE_STR); + tsk_strcat(&namespace, temp); + TSK_FREE(temp); + break; + } + default: + { + TSK_DEBUG_ERROR("NOT SUPPORTED."); + goto bail; + } + } /* switch */ + } /* while */ + + /* append the namespace */ + if(namespace){ + tsk_buffer_append(buffer, namespace, strlen(namespace)); + TSK_FREE(namespace); + } + +bail: + if(TSK_BUFFER_DATA(buffer) && TSK_BUFFER_SIZE(buffer)){ + ret = tsk_strndup(TSK_BUFFER_DATA(buffer), TSK_BUFFER_SIZE(buffer)); + } + TSK_OBJECT_SAFE_FREE(buffer); + return ret; +} diff --git a/trunk/tinyXCAP/src/txcap_selector.c b/trunk/tinyXCAP/src/txcap_selector.c new file mode 100644 index 00000000..c00f86bc --- /dev/null +++ b/trunk/tinyXCAP/src/txcap_selector.c @@ -0,0 +1,77 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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 txcap_selector.c + * @brief XCAP selector. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#include "tinyXCAP/txcap_selector.h" + + +/**@defgroup txcap_selector_group XCAP URL selector +*/ + +/**@ingroup txcap_selector_group +* Gets the full XCAP URL with both the document and node selector parts. +* @param stack The XCAP stack from which to load the user's preference (xcap-root, AUIDs, XUI, name of the document, ...). +* Should be created using @ref txcap_stack_create(). +* @param auid_id The Application Unique ID. Unique identifier within the namespace of application unique IDs created by this specification (RFC 4825) +* that differentiates XCAP resources accessed by one application from XCAP resources accessed by another. +* For more information see RFC 4825 subclause 4. +* @retval A well-formed HTTP/HTTPS URL which can be used as Request-Uri (e.g. GET, PUT or DELETE). As a +* result, performing a GET against the return URL would retrieve a document, element or attribute. +* +* @code +* @endcode +* +* @sa @ref txcap_selector_get_full_2
@ref txcap_selector_get_node
@ref txcap_selector_get_document
@ref txcap_selector_get_document_2 +*/ +char* txcap_selector_get_full(const txcap_stack_handle_t* stack, const char* auid_id, ...) +{ + +} + +/**@ingroup txcap_selector_group +* Gets the full XCAP URL with both the document and node selector parts. +* @param xcap_root The XCAP Root URI (valid HTTP/HTTPS URL). A context that contains all the documents across all +* application usages and users that are managed by the server. For more information see RFC 4825 subclause 4. +* @param auid_id The Application Unique ID. Unique identifier within the namespace of application unique IDs created by this specification (RFC 4825) +* that differentiates XCAP resources accessed by one application from XCAP resources accessed by another. +* For more information see RFC 4825 subclause 4. +* @param xui The XCAP User Identifier. The XUI is a string, valid as a path element in an HTTP URI, that is associated with each user served +* by the XCAP server. For more information see RFC 4825 subclause 4. +* For global document, this parameter should be NULL or equal to "global". +* @param doc_name The name of the document (e.g. index). +* @retval A well-formed HTTP/HTTPS URL which can be used as Request-Uri (e.g. GET, PUT or DELETE). As a +* result, performing a GET against the return URL would retrieve a document, element or attribute. +* @code +* @endcode +* +* @sa @ref txcap_selector_get_full
@ref txcap_selector_get_node
@ref txcap_selector_get_document
@ref txcap_selector_get_document_2 +*/ +*/ +char* txcap_selector_get_full_2(const char* xcap_root, const char* auid_id, const char* xui, const char* doc_name, ...) +{ + +} diff --git a/trunk/tinyXCAP/test/stdafx.c b/trunk/tinyXCAP/test/stdafx.c new file mode 100644 index 00000000..df71e1b8 --- /dev/null +++ b/trunk/tinyXCAP/test/stdafx.c @@ -0,0 +1,26 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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 Lesser General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/trunk/tinyXCAP/test/stdafx.h b/trunk/tinyXCAP/test/stdafx.h new file mode 100644 index 00000000..ff9ec24f --- /dev/null +++ b/trunk/tinyXCAP/test/stdafx.h @@ -0,0 +1,37 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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 Lesser General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ +#ifndef TEST_TINYXCAP_STDAFX_H +#define TEST_TINYXCAP_STDAFX_H + +#include "targetver.h" + +#include +//#if (defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE)) && !defined(__SYMBIAN32__) +#include +//#endif + +#define TINYSAK_IMPORTS +#define TINYXCAP_IMPORTS + +// TODO: reference additional headers your program requires here + +#endif /* TEST_TINYXCAP_STDAFX_H */ diff --git a/trunk/tinyXCAP/test/targetver.h b/trunk/tinyXCAP/test/targetver.h new file mode 100644 index 00000000..574245d3 --- /dev/null +++ b/trunk/tinyXCAP/test/targetver.h @@ -0,0 +1,18 @@ +#ifndef _TEST_TINYXCAP_VER +#define _TEST_TINYXCAP_VER + +#if (defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE)) && !defined(__SYMBIAN32__) +// The following macros define the minimum required platform. The minimum required platform +// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run +// your application. The macros work by enabling all features available on platform versions up to and +// including the version specified. + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. +#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. +#endif + +#endif + +#endif /*_TEST_TINYXCAP_VER*/ diff --git a/trunk/tinyXCAP/test/test.c b/trunk/tinyXCAP/test/test.c new file mode 100644 index 00000000..7a02937d --- /dev/null +++ b/trunk/tinyXCAP/test/test.c @@ -0,0 +1,78 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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 Lesser General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ +#include "stdafx.h" + +#include "tinyxcap.h" + +#define LOOP 1 + +#define RUN_TEST_ALL 0 +#define RUN_TEST_SELECTOR 1 +#define RUN_TEST_STACK 0 + + +#define XUI "sip:mamadou@micromethod.com" +#define PASSWORD "mysecret" +#define XCAP_ROOT "http://192.168.16.104:8080/services" + +#if RUN_TEST_SELECTOR || RUN_TEST_ALL +#include "test_selector.h" +#endif + +#if RUN_TEST_STACK || RUN_TEST_ALL +#include "test_stack.h" +#endif + + +#ifdef _WIN32_WCE +int _tmain(int argc, _TCHAR* argv[]) +#else +int main() +#endif +{ + tnet_startup(); + + /* Print copyright information */ + printf("Doubango Project\nCopyright (C) 2009 Mamadou Diop \n\n"); + +#if LOOP + while(1) +#endif + { + /* XCAP document/node selector */ +#if RUN_TEST_SELECTOR || RUN_TEST_ALL + test_selector(); +#endif + + /* XCAP stack */ +#if RUN_TEST_STACK || RUN_TEST_ALL + test_stack(); +#endif + + + } + + tnet_cleanup(); + + return 0; +} + diff --git a/trunk/tinyXCAP/test/test.vcproj b/trunk/tinyXCAP/test/test.vcproj new file mode 100644 index 00000000..5c2d7fc4 --- /dev/null +++ b/trunk/tinyXCAP/test/test.vcproj @@ -0,0 +1,419 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/trunk/tinyXCAP/test/test_selector.h b/trunk/tinyXCAP/test/test_selector.h new file mode 100644 index 00000000..974ffd83 --- /dev/null +++ b/trunk/tinyXCAP/test/test_selector.h @@ -0,0 +1,69 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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 Lesser General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ +#ifndef _TEST_SELECTOR_H +#define _TEST_SELECTOR_H + +void test_selector() +{ + txcap_stack_handle_t* stack = tsk_null; + char* urlstring; + + stack = txcap_stack_create(tsk_null, XUI, PASSWORD, XCAP_ROOT, + TXCAP_STACK_SET_NULL()); + + /* add user auids */ + txcap_stack_set(stack, + TXCAP_STACK_SET_AUID("xcap-caps2", "application/xcap-caps2+xml", "urn:ietf:params:xml:ns:xcap-caps2", "index2", tsk_true), + TXCAP_STACK_SET_AUID("resource-lists2", "application/resource-lists+xml2", "urn:ietf:params:xml:ns:resource-lists2", "index2", tsk_false), + + TXCAP_STACK_SET_NULL()); /* mandatory */ + + /* IETF server capabilities */ + urlstring = txcap_selector_get_document(stack, "xcap-caps"); + TSK_DEBUG_INFO("Document('xcap-caps') = %s\n", urlstring); + TSK_FREE(urlstring); + + /* My custom xcap-caps */ + urlstring = txcap_selector_get_document(stack, "xcap-caps2"); + TSK_DEBUG_INFO("Document('xcap-caps2') = %s\n", urlstring); + TSK_FREE(urlstring); + + /* IETF resource-lists */ + urlstring = txcap_selector_get_document(stack, "resource-lists"); + TSK_DEBUG_INFO("Document('resource-lists') = %s\n", urlstring); + TSK_FREE(urlstring); + + /* My custom resource-lists */ + urlstring = txcap_selector_get_document(stack, "resource-lists2"); + TSK_DEBUG_INFO("Document('resource-lists2') = %s\n", urlstring); + TSK_FREE(urlstring); + + /* Full custom resource-lists */ + urlstring = txcap_selector_get_document_2(XCAP_ROOT, "resource-lists3", XUI, "index3"); + TSK_DEBUG_INFO("Document('resource-lists2') = %s\n", urlstring); + TSK_FREE(urlstring); + + + TSK_OBJECT_SAFE_FREE(stack); +} + +#endif /* _TEST_SELECTOR_H */ diff --git a/trunk/tinyXCAP/test/test_stack.h b/trunk/tinyXCAP/test/test_stack.h new file mode 100644 index 00000000..3344f8d3 --- /dev/null +++ b/trunk/tinyXCAP/test/test_stack.h @@ -0,0 +1,62 @@ +/* +* Copyright (C) 2009 Mamadou Diop. +* +* Contact: Mamadou Diop +* +* 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 Lesser General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ +#ifndef _TEST_STACK_H +#define _TEST_STACK_H + +int test_stack_callback(const thttp_event_t *httpevent) +{ + return 0; +} + +void test_stack() +{ + txcap_stack_handle_t* stack = tsk_null; + int ret; + + stack = txcap_stack_create(test_stack_callback, "sip:mamadou@micromethod.com", "mysecret", "http://192.168.16.104:8080/services", + + // options + TXCAP_STACK_SET_OPTION(TXCAP_STACK_OPTION_TIMEOUT, "6000"), + + // stack-level headers + TXCAP_STACK_SET_HEADER("Pragma", "No-Cache"), + TXCAP_STACK_SET_HEADER("Connection", "Keep-Alive"), + TXCAP_STACK_SET_HEADER("User-Agent", "XDM-client/OMA1.1"), + + TXCAP_STACK_SET_NULL()); + + if((ret = txcap_stack_start(stack))){ + goto bail; + } + + /* add user auids */ + txcap_stack_set(stack, + TXCAP_STACK_SET_AUID("xcap-caps2", "application/xcap-caps2+xml", "urn:ietf:params:xml:ns:xcap-caps2", "index2", tsk_true), + TXCAP_STACK_SET_AUID("resource-lists2", "application/resource-lists+xml2", "urn:ietf:params:xml:ns:resource-lists2", "index2", tsk_false), + + TXCAP_STACK_SET_NULL()); /* mandatory */ + +bail: + TSK_OBJECT_SAFE_FREE(stack); +} + +#endif /* _TEST_STACK_H */ diff --git a/trunk/tinyXCAP2/test/test.vcproj b/trunk/tinyXCAP2/test/test.vcproj index e8d333a4..5c2d7fc4 100644 --- a/trunk/tinyXCAP2/test/test.vcproj +++ b/trunk/tinyXCAP2/test/test.vcproj @@ -1,7 +1,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/trunk/vs_2005/tinyXCAP/tinyXCAP.sln b/trunk/vs_2005/tinyXCAP/tinyXCAP.sln new file mode 100644 index 00000000..5cf2fec3 --- /dev/null +++ b/trunk/vs_2005/tinyXCAP/tinyXCAP.sln @@ -0,0 +1,72 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyXCAP", "tinyXCAP.vcproj", "{570CF33D-E65F-448F-8AC2-F9AE2F23152F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcproj", "{2A476CAA-BA45-4379-AFEC-088645840527}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySAK", "..\tinySAK\tinySAK.vcproj", "{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyHTTP", "..\tinyHTTP\tinyHTTP.vcproj", "{B3E45009-C7C3-4090-837C-2D30C9058443}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyNET", "..\tinyNET\tinyNET.vcproj", "{7522A458-92F4-4259-B906-E84C2A65D9F1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + Release|Win32 = Release|Win32 + Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {570CF33D-E65F-448F-8AC2-F9AE2F23152F}.Debug|Win32.ActiveCfg = Debug|Win32 + {570CF33D-E65F-448F-8AC2-F9AE2F23152F}.Debug|Win32.Build.0 = Debug|Win32 + {570CF33D-E65F-448F-8AC2-F9AE2F23152F}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32 + {570CF33D-E65F-448F-8AC2-F9AE2F23152F}.Release|Win32.ActiveCfg = Release|Win32 + {570CF33D-E65F-448F-8AC2-F9AE2F23152F}.Release|Win32.Build.0 = Release|Win32 + {570CF33D-E65F-448F-8AC2-F9AE2F23152F}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32 + {2A476CAA-BA45-4379-AFEC-088645840527}.Debug|Win32.ActiveCfg = Debug|Win32 + {2A476CAA-BA45-4379-AFEC-088645840527}.Debug|Win32.Build.0 = Debug|Win32 + {2A476CAA-BA45-4379-AFEC-088645840527}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {2A476CAA-BA45-4379-AFEC-088645840527}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {2A476CAA-BA45-4379-AFEC-088645840527}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {2A476CAA-BA45-4379-AFEC-088645840527}.Release|Win32.ActiveCfg = Release|Win32 + {2A476CAA-BA45-4379-AFEC-088645840527}.Release|Win32.Build.0 = Release|Win32 + {2A476CAA-BA45-4379-AFEC-088645840527}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {2A476CAA-BA45-4379-AFEC-088645840527}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {2A476CAA-BA45-4379-AFEC-088645840527}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Win32.ActiveCfg = Debug|Win32 + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Win32.Build.0 = Debug|Win32 + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Win32.ActiveCfg = Release|Win32 + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Win32.Build.0 = Release|Win32 + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {B3E45009-C7C3-4090-837C-2D30C9058443}.Debug|Win32.ActiveCfg = Debug|Win32 + {B3E45009-C7C3-4090-837C-2D30C9058443}.Debug|Win32.Build.0 = Debug|Win32 + {B3E45009-C7C3-4090-837C-2D30C9058443}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {B3E45009-C7C3-4090-837C-2D30C9058443}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {B3E45009-C7C3-4090-837C-2D30C9058443}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {B3E45009-C7C3-4090-837C-2D30C9058443}.Release|Win32.ActiveCfg = Release|Win32 + {B3E45009-C7C3-4090-837C-2D30C9058443}.Release|Win32.Build.0 = Release|Win32 + {B3E45009-C7C3-4090-837C-2D30C9058443}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {B3E45009-C7C3-4090-837C-2D30C9058443}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {B3E45009-C7C3-4090-837C-2D30C9058443}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Debug|Win32.ActiveCfg = Debug|Win32 + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Debug|Win32.Build.0 = Debug|Win32 + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Release|Win32.ActiveCfg = Release|Win32 + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Release|Win32.Build.0 = Release|Win32 + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + {7522A458-92F4-4259-B906-E84C2A65D9F1}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/trunk/vs_2005/tinyXCAP/tinyXCAP.vcproj b/trunk/vs_2005/tinyXCAP/tinyXCAP.vcproj new file mode 100644 index 00000000..c563cd71 --- /dev/null +++ b/trunk/vs_2005/tinyXCAP/tinyXCAP.vcproj @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +