From: <svn...@op...> - 2009-07-03 13:03:40
|
Author: bellmich Date: Fri Jul 3 15:03:14 2009 New Revision: 1147 URL: http://libsyncml.opensync.org/changeset/1147 Log: migrated sml_parse from SmlError to GError Modified: trunk/libsyncml/parser/sml_wbxml.h trunk/libsyncml/parser/sml_xml_assm.h trunk/libsyncml/parser/sml_xml_parse.h trunk/libsyncml/sml_parse.c trunk/libsyncml/sml_parse.h trunk/libsyncml/sml_parse_internals.h Modified: trunk/libsyncml/parser/sml_wbxml.h ============================================================================== --- trunk/libsyncml/parser/sml_wbxml.h Fri Jul 3 11:31:01 2009 (r1146) +++ trunk/libsyncml/parser/sml_wbxml.h Fri Jul 3 15:03:14 2009 (r1147) @@ -29,8 +29,8 @@ #ifndef _SML_WBXML_H_ #define _SML_WBXML_H_ -SmlXmlParser *smlWbxmlParserNew(SmlParserFunctions *functions, SmlError **error); -SmlXmlAssembler *smlWbxmlAssemblerNew(SmlAssembler *assembler, SmlAssemblerFunctions *functions, SmlError **error); +SmlXmlParser *smlWbxmlParserNew(SmlParserFunctions *functions, GError **error); +SmlXmlAssembler *smlWbxmlAssemblerNew(SmlAssembler *assembler, SmlAssemblerFunctions *functions, GError **error); #endif //_SML_WBXML_H_ /*@}*/ Modified: trunk/libsyncml/parser/sml_xml_assm.h ============================================================================== --- trunk/libsyncml/parser/sml_xml_assm.h Fri Jul 3 11:31:01 2009 (r1146) +++ trunk/libsyncml/parser/sml_xml_assm.h Fri Jul 3 15:03:14 2009 (r1147) @@ -32,7 +32,7 @@ typedef struct SmlXmlAssembler SmlXmlAssembler; -SmlXmlAssembler *smlXmlAssemblerNew(SmlAssembler *assembler, SmlAssemblerFunctions *functions, SmlError **error); +SmlXmlAssembler *smlXmlAssemblerNew(SmlAssembler *assembler, SmlAssemblerFunctions *functions, GError **error); SmlBool smlXmlAssemblerAddHeader(SmlXmlAssembler *assembler, SmlSession *session, SmlError **error); // FIXME: not yet implemented Modified: trunk/libsyncml/parser/sml_xml_parse.h ============================================================================== --- trunk/libsyncml/parser/sml_xml_parse.h Fri Jul 3 11:31:01 2009 (r1146) +++ trunk/libsyncml/parser/sml_xml_parse.h Fri Jul 3 15:03:14 2009 (r1147) @@ -43,14 +43,14 @@ typedef struct SmlXmlParser SmlXmlParser; -SmlXmlParser *smlXmlParserNew(SmlParserFunctions *functions, SmlError **error); +SmlXmlParser *smlXmlParserNew(SmlParserFunctions *functions, GError **error); -SmlBool smlXmlParserStart(SmlXmlParser *parser, const char *data, unsigned int size, SmlError **error); -SmlBool smlXmlParserEnd(SmlXmlParser *parser, SmlBool *final, SmlBool *end, SmlError **error); +SmlBool smlXmlParserStart(SmlXmlParser *parser, const char *data, unsigned int size, GError **error); +SmlBool smlXmlParserEnd(SmlXmlParser *parser, SmlBool *final, SmlBool *end, GError **error); void smlXmlParserFree(SmlXmlParser *parser); -SmlBool smlXmlParserGetHeader(SmlXmlParser *parser, SmlHeader **header, SmlCred **cred, SmlError **error); -SmlBool smlXmlParserGetStatus(SmlXmlParser *parser, SmlStatus **status, SmlError **error); -SmlParserResult smlXmlParserGetCommand(SmlXmlParser *parser, SmlCommand **cmd, SmlError **error); +SmlBool smlXmlParserGetHeader(SmlXmlParser *parser, SmlHeader **header, SmlCred **cred, GError **error); +SmlBool smlXmlParserGetStatus(SmlXmlParser *parser, SmlStatus **status, GError **error); +SmlParserResult smlXmlParserGetCommand(SmlXmlParser *parser, SmlCommand **cmd, GError **error); SmlDevInf *smlXmlDevInfParse(const char *data, unsigned int size, GError **error); Modified: trunk/libsyncml/sml_parse.c ============================================================================== --- trunk/libsyncml/sml_parse.c Fri Jul 3 11:31:01 2009 (r1146) +++ trunk/libsyncml/sml_parse.c Fri Jul 3 15:03:14 2009 (r1147) @@ -1,7 +1,7 @@ /* * libsyncml - A syncml protocol implementation * Copyright (C) 2005 Armin Bauer <arm...@op...> - * Copyright (C) 2008 Michael Bell <mic...@op...> + * Copyright (C) 2008-2009 Michael Bell <mic...@op...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -48,7 +48,10 @@ * @return The new parser or NULL in the case of an error * */ -SmlParser *smlParserNew(SmlMimeType type, unsigned int limit, SmlError **error) +SmlParser* +smlParserNew (SmlMimeType type, + gsize limit, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%i, %i, %p)", __func__, type, limit, error); CHECK_ERROR_REF @@ -63,38 +66,39 @@ switch (type) { case SML_MIMETYPE_XML: if (!(parser->parser_userdata = smlXmlParserNew(&(parser->functions), error))) - goto error_free_parser; + goto error; break; case SML_MIMETYPE_SAN: /* SANs will be converted to normal SyncML 1.1 notifications */ if (!(parser->parser_userdata = smlXmlParserNew(&(parser->functions), error))) - goto error_free_parser; + goto error; break; case SML_MIMETYPE_WBXML: #ifdef ENABLE_WBXML if (!(parser->parser_userdata = smlWbxmlParserNew(&(parser->functions), error))) - goto error_free_parser; + goto error; break; #else - smlErrorSet(error, SML_ERROR_GENERIC, "Wbxml not enabled in this build"); - goto error_free_parser; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Wbxml not enabled in this build"); + goto error; #endif default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown parser type"); - goto error_free_parser; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown parser type"); + goto error; } smlTrace(TRACE_EXIT, "%s: %p", __func__, parser); return parser; - -error_free_parser: - smlSafeFree((gpointer *)&parser); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (parser) + smlSafeFree((gpointer *)&parser); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -void smlParserSetManager(SmlParser *parser, SmlManager *manager) +void +smlParserSetManager (SmlParser *parser, + SmlManager *manager) { smlAssert(parser); smlAssert(manager); @@ -106,7 +110,8 @@ * @param parser The parser to free * */ -void smlParserFree(SmlParser *parser) +void +smlParserFree (SmlParser *parser) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, parser); smlAssert(parser); @@ -130,11 +135,14 @@ * @returns TRUE if the parser started successfully, FALSE otherwise * */ -SmlBool smlParserStart(SmlParser *parser, const char *data, unsigned int size, SmlError **error) +gboolean +smlParserStart (SmlParser *parser, + const gchar *data, + gsize size, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, parser, data, size, error); CHECK_ERROR_REF - GError *gerror = NULL; smlAssert(parser); smlAssert(data); smlAssert(size); @@ -143,7 +151,7 @@ "If an OMA DS 1.2 SAN must be parsed then the manager must be present."); if (parser->limit && size > parser->limit) { - smlErrorSet(error, SML_ERROR_GENERIC, "Input data too large"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Input data too large"); goto error; } @@ -160,7 +168,7 @@ smlNotificationSetManager(san, parser->manager); san->type = SML_MIMETYPE_XML; san->sessionType = SML_SESSION_TYPE_CLIENT; - san->target = sml_location_new_with_options("/", NULL, &gerror); + san->target = sml_location_new_with_options("/", NULL, error); if (!san->target) goto error; @@ -194,10 +202,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - GERROR_TO_SML_ERROR(gerror, error); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -216,7 +222,11 @@ * @returns TRUE if the parser retrieved the header successfully, FALSE otherwise * */ -SmlBool smlParserGetHeader(SmlParser *parser, SmlHeader **header, SmlCred **cred, SmlError **error) +gboolean +smlParserGetHeader (SmlParser *parser, + SmlHeader **header, + SmlCred **cred, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, parser, header, cred, error); CHECK_ERROR_REF @@ -230,9 +240,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -250,7 +259,10 @@ * commands available (in which case *cmd is NULL). FALSE in the case of an error * */ -SmlParserResult smlParserGetCommand(SmlParser *parser, SmlCommand **cmd, SmlError **error) +SmlParserResult +smlParserGetCommand (SmlParser *parser, + SmlCommand **cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, parser, cmd, error); CHECK_ERROR_REF @@ -264,9 +276,8 @@ smlTrace(TRACE_EXIT, "%s: %i", __func__, result); return result; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return SML_PARSER_RESULT_ERROR; } @@ -284,7 +295,10 @@ * statuses available (in which case *status is NULL). FALSE in the case of an error * */ -SmlBool smlParserGetStatus(SmlParser *parser, SmlStatus **status, SmlError **error) +gboolean +smlParserGetStatus (SmlParser *parser, + SmlStatus **status, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, parser, status, error); CHECK_ERROR_REF @@ -297,9 +311,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -314,7 +327,11 @@ * @returns TRUE if the parser ended successfully, FALSE otherwise * */ -SmlBool smlParserEnd(SmlParser *parser, SmlBool *final, SmlBool *end, SmlError **error) +gboolean +smlParserEnd (SmlParser *parser, + gboolean *final, + gboolean *end, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, parser, final, end, error); CHECK_ERROR_REF @@ -328,9 +345,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -352,7 +368,10 @@ * @return The new assembler or NULL in the case of an error * */ -SmlAssembler *smlAssemblerNew(SmlMimeType type, unsigned int limit, SmlError **error) +SmlAssembler* +smlAssemblerNew (SmlMimeType type, + gsize limit, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%i, %i, %p)", __func__, type, limit, error); CHECK_ERROR_REF @@ -369,31 +388,30 @@ switch (type) { case SML_MIMETYPE_XML: if (!(assm->assm_userdata = smlXmlAssemblerNew(assm, &(assm->functions), error))) - goto error_free_assm; + goto error; break; case SML_MIMETYPE_WBXML: #ifdef ENABLE_WBXML if (!(assm->assm_userdata = smlWbxmlAssemblerNew(assm, &(assm->functions), error))) - goto error_free_assm; + goto error; break; #else - smlErrorSet(error, SML_ERROR_GENERIC, "Wbxml not enabled in this build"); - goto error_free_assm; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Wbxml not enabled in this build"); + goto error; #endif default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown assembler type"); - goto error_free_assm; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown assembler type"); + goto error; } assm->options = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); smlTrace(TRACE_EXIT, "%s: %p", __func__, assm); return assm; - -error_free_assm: - smlSafeFree((gpointer *)&assm); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (assm) + smlSafeFree((gpointer *)&assm); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } @@ -402,7 +420,8 @@ * @param assm The assembler to free * */ -void smlAssemblerFree(SmlAssembler *assm) +void +smlAssemblerFree (SmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); smlAssert(assm); @@ -428,7 +447,10 @@ * @returns TRUE if the package container was assembled successfully, FALSE otherwise * */ -SmlBool smlAssemblerStart(SmlAssembler *assm, SmlSession *session, SmlError **error) +gboolean +smlAssemblerStart (SmlAssembler *assm, + SmlSession *session, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, session, error); CHECK_ERROR_REF @@ -441,9 +463,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -456,7 +477,13 @@ * @returns TRUE if the package container was assembled successfully, FALSE otherwise * */ -SmlBool smlAssemblerRun(SmlAssembler *assm, char **data, unsigned int *size, SmlBool *end, SmlBool final, SmlError **error) +gboolean +smlAssemblerRun (SmlAssembler *assm, + gchar **data, + gsize *size, + gboolean *end, + gboolean final, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %i, %p)", __func__, assm, data, size, end, final, error); CHECK_ERROR_REF @@ -470,9 +497,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -485,22 +511,24 @@ * @returns TRUE if the package container was assembled successfully, FALSE otherwise * */ -unsigned int smlAssemblerCheckSize(SmlAssembler *assm, SmlBool headeronly, SmlError **error) +gsize +smlAssemblerCheckSize (SmlAssembler *assm, + gboolean headeronly, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, assm, headeronly, error); CHECK_ERROR_REF smlAssert(assm); smlAssert(assm->functions.check_size); - unsigned int size = 0; + gsize size = 0; if (!(size = assm->functions.check_size(assm->assm_userdata, headeronly, error))) goto error; smlTrace(TRACE_EXIT, "%s: %i", __func__, size); return size; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return 0; } @@ -514,7 +542,8 @@ * @returns TRUE if the flushing was successful, FALSE otherwise * */ -unsigned int smlAssemblerFlush(SmlAssembler *assm) +gsize +smlAssemblerFlush (SmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); smlAssert(assm); @@ -527,7 +556,8 @@ return ret; } -void smlAssemblerRestoreCommands(SmlAssembler *assm) +void +smlAssemblerRestoreCommands (SmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); smlAssert(assm); @@ -545,7 +575,12 @@ * item data. Then it returns how big the item data could be without violating * the limits. If there is not limit set, -1 is returned. This command only * makes sense for change commands */ -SmlBool smlAssemblerGetSpace(SmlAssembler *assm, int *space, SmlCommand *parent, SmlCommand *cmd, SmlError **error) +gboolean +smlAssemblerGetSpace (SmlAssembler *assm, + gsize *space, + SmlCommand *parent, + SmlCommand *cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p)", __func__, assm, space, parent, cmd, error); CHECK_ERROR_REF @@ -567,7 +602,7 @@ /* Add the command */ if (parent) { if (!parent->cmdID) { - smlErrorSet(error, SML_ERROR_GENERIC, "Parent has to be added before"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Parent has to be added before"); goto error; } parentID = parent->cmdID; @@ -641,7 +676,7 @@ if (noCmdID) cmd->cmdID = 0; error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -659,7 +694,11 @@ * if the parent command did not fit, SML_ASSEMBLER_RESULT_ERROR if some error occured. * */ -SmlAssemblerResult smlAssemblerStartCommand(SmlAssembler *assm, SmlCommand *parent, SmlCommand *cmd, SmlError **error) +SmlAssemblerResult +smlAssemblerStartCommand (SmlAssembler *assm, + SmlCommand *parent, + SmlCommand *cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, assm, parent, cmd, error); CHECK_ERROR_REF @@ -672,7 +711,7 @@ /* Add the command */ if (parent) { if (!parent->cmdID) { - smlErrorSet(error, SML_ERROR_GENERIC, "Parent has to be added before"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Parent has to be added before"); goto error; } parentID = parent->cmdID; @@ -705,9 +744,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); return SML_ASSEMBLER_RESULT_OK; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return SML_ASSEMBLER_RESULT_ERROR; } @@ -722,7 +760,10 @@ * @returns TRUE if the command was added successfully, FALSE otherwise * */ -SmlBool smlAssemblerEndCommand(SmlAssembler *assm, SmlCommand *parent, SmlError **error) +gboolean +smlAssemblerEndCommand (SmlAssembler *assm, + SmlCommand *parent, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, parent, error); CHECK_ERROR_REF @@ -734,7 +775,7 @@ /* Add the command */ if (parent) { if (!parent->cmdID) { - smlErrorSet(error, SML_ERROR_GENERIC, "Parent has to be added before"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Parent has to be added before"); goto error; } parentID = parent->cmdID; @@ -746,9 +787,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -762,7 +802,10 @@ * @returns TRUE if the header was added ok, FALSE if some error occured. * */ -SmlBool smlAssemblerAddHeader(SmlAssembler *assm, SmlSession *session, SmlError **error) +gboolean +smlAssemblerAddHeader (SmlAssembler *assm, + SmlSession *session, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, session, error); CHECK_ERROR_REF @@ -781,15 +824,14 @@ /* Lets see if the new buffer is small enough */ if (smlAssemblerGetRemoteMaxMsgSize(assm) && size > smlAssemblerGetRemoteMaxMsgSize(assm)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Limit to small. Unable to fit a the header"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Limit to small. Unable to fit a the header"); goto error; } smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -806,7 +848,12 @@ * @returns TRUE if successful, FALSE otherwise * */ -SmlAssemblerResult smlAssemblerReserveStatus(SmlAssembler *assm, unsigned int cmdRef, unsigned int msgRef, unsigned int cmdID, SmlError **error) +SmlAssemblerResult +smlAssemblerReserveStatus (SmlAssembler *assm, + guint cmdRef, + guint msgRef, + guint cmdID, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %i, %i, %p)", __func__, assm, cmdRef, msgRef, cmdID, error); CHECK_ERROR_REF @@ -819,9 +866,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -839,7 +885,11 @@ * if the status did not fit, SML_ASSEMBLER_RESULT_ERROR if some error occured. * */ -SmlAssemblerResult smlAssemblerAddStatusFull(SmlAssembler *assm, SmlStatus *status, SmlBool force, SmlError **error) +SmlAssemblerResult +smlAssemblerAddStatusFull (SmlAssembler *assm, + SmlStatus *status, + gboolean force, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, assm, status, force, error); CHECK_ERROR_REF @@ -877,13 +927,15 @@ smlTrace(TRACE_EXIT, "%s", __func__); return SML_ASSEMBLER_RESULT_OK; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return SML_ASSEMBLER_RESULT_ERROR; } -SmlAssemblerResult smlAssemblerAddStatus(SmlAssembler *assm, SmlStatus *status, SmlError **error) +SmlAssemblerResult +smlAssemblerAddStatus (SmlAssembler *assm, + SmlStatus *status, + GError **error) { CHECK_ERROR_REF return smlAssemblerAddStatusFull(assm, status, FALSE, error); @@ -896,7 +948,10 @@ * @param value The new value * */ -void smlAssemblerSetOption(SmlAssembler *assm, const char *optionname, const char *value) +void +smlAssemblerSetOption (SmlAssembler *assm, + const gchar *optionname, + const gchar *value) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %s)", __func__, assm, VA_STRING(optionname), VA_STRING(value)); smlAssert(assm); @@ -914,7 +969,9 @@ * @returns The value * */ -const char *smlAssemblerGetOption(SmlAssembler *assm, const char *optionname) +const gchar* +smlAssemblerGetOption (SmlAssembler *assm, + const gchar *optionname) { smlTrace(TRACE_ENTRY, "%s(%p, %s)", __func__, assm, VA_STRING(optionname)); smlAssert(assm); @@ -926,13 +983,8 @@ return ret; } -/* FIXME: DEPRECATED */ -unsigned int smlAssemblerGetLimit(SmlAssembler *assm) -{ - return smlAssemblerGetRemoteMaxMsgSize(assm); -} - -unsigned int smlAssemblerGetRemoteMaxMsgSize(SmlAssembler *assm) +gsize +smlAssemblerGetRemoteMaxMsgSize (SmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); smlAssert(assm); @@ -941,19 +993,8 @@ return assm->remoteMaxMsgSize; } -/* FIXME: DEPRECATED */ -void smlAssemblerSetRequestedLimit(SmlAssembler *assm, unsigned int limit) -{ - smlAssemblerSetRemoteMaxMsgSize(assm, limit); -} - -/* FIXME: DEPRECATED */ -void smlAssemblerSetLimit(SmlAssembler *assm, unsigned int limit) -{ - smlAssemblerSetRemoteMaxMsgSize(assm, limit); -} - -unsigned int smlAssemblerSetRemoteMaxMsgSize(SmlAssembler *assm, unsigned int limit) +gsize smlAssemblerSetRemoteMaxMsgSize (SmlAssembler *assm, + gsize limit) { smlTrace(TRACE_ENTRY, "%s(%p, %i)", __func__, assm, limit); smlAssert(assm); @@ -978,20 +1019,8 @@ return assm->remoteMaxMsgSize; } -/* FIXME: DEPRECATED */ -int smlAssemblerGetSendingMaxObjSize(SmlAssembler *assm) -{ - return smlAssemblerGetRemoteMaxObjSize(assm); -} - -/* FIXME: DEPRECATED */ -int smlAssemblerGetRequestedMaxObjSize(SmlAssembler *assm) -{ - return smlAssemblerGetRemoteMaxObjSize(assm); -} - - -unsigned int smlAssemblerGetRemoteMaxObjSize(SmlAssembler *assm) +gsize +smlAssemblerGetRemoteMaxObjSize (SmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); smlAssert(assm); @@ -1000,19 +1029,9 @@ return assm->remoteMaxObjSize; } -/* FIXME: DEPRECATED */ -void smlAssemblerSetRequestedMaxObjSize(SmlAssembler *assm, int limit) -{ - smlAssemblerSetRemoteMaxObjSize(assm, limit); -} - -/* FIXME: DEPRECATED */ -void smlAssemblerSetSendingMaxObjSize(SmlAssembler *assm, int limit) -{ - smlAssemblerSetRemoteMaxObjSize(assm, limit); -} - -unsigned int smlAssemblerSetRemoteMaxObjSize(SmlAssembler *assm, unsigned int limit) +gsize +smlAssemblerSetRemoteMaxObjSize (SmlAssembler *assm, + gsize limit) { smlTrace(TRACE_ENTRY, "%s(%p, %i)", __func__, assm, limit); smlAssert(assm); @@ -1037,7 +1056,8 @@ return assm->remoteMaxObjSize; } -SmlBool smlAssemblerIsEmpty(SmlAssembler *assm) +gboolean +smlAssemblerIsEmpty (SmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); smlAssert(assm); @@ -1053,7 +1073,8 @@ * @param assm The assembler to check * @returns TRUE if statuses are missing, FALSE if all statuses had been added */ -SmlBool smlAssemblerIsStatusMissing(SmlAssembler *assm) +gboolean +smlAssemblerIsStatusMissing (SmlAssembler *assm) { smlAssert(assm); smlAssert(assm->functions.missing_status); @@ -1063,7 +1084,10 @@ return ret; } -SmlBool smlAssemblerGetNextCmdRef(SmlAssembler *assm, unsigned int *cmdRef, unsigned int *msgRef) +gboolean +smlAssemblerGetNextCmdRef (SmlAssembler *assm, + guint *cmdRef, + guint *msgRef) { smlAssert(assm); smlAssert(cmdRef); Modified: trunk/libsyncml/sml_parse.h ============================================================================== --- trunk/libsyncml/sml_parse.h Fri Jul 3 11:31:01 2009 (r1146) +++ trunk/libsyncml/sml_parse.h Fri Jul 3 15:03:14 2009 (r1147) @@ -1,7 +1,7 @@ /* * libsyncml - A syncml protocol implementation * Copyright (C) 2005 Armin Bauer <arm...@op...> - * Copyright (C) 2008 Michael Bell <mic...@op...> + * Copyright (C) 2008-2009 Michael Bell <mic...@op...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -31,11 +31,11 @@ SML_PARSER_RESULT_OTHER = 5 } SmlParserResult; -typedef void (* SmlParserFreeFunction) (void *userdata); -typedef SmlBool (* SmlParserStartFunction) (void *userdata, const char *data, unsigned int size, GError **error); -typedef SmlBool (* SmlParserEndFunction) (void *userdata, SmlBool *final, SmlBool *end, GError **error); -typedef SmlBool (* SmlParserHeaderFunction) (void *userdata, SmlHeader **header, SmlCred **cred, GError **error); -typedef SmlBool (* SmlParserStatusFunction) (void *userdata, SmlStatus **status, GError **error); +typedef void (* SmlParserFreeFunction) (void *userdata); +typedef gboolean (* SmlParserStartFunction) (void *userdata, const gchar *data, gsize size, GError **error); +typedef gboolean (* SmlParserEndFunction) (void *userdata, gboolean *final, gboolean *end, GError **error); +typedef gboolean (* SmlParserHeaderFunction) (void *userdata, SmlHeader **header, SmlCred **cred, GError **error); +typedef gboolean (* SmlParserStatusFunction) (void *userdata, SmlStatus **status, GError **error); typedef SmlParserResult (* SmlParserCommandFunction) (void *userdata, SmlCommand **cmd, GError **error); typedef struct SmlParserFunctions { @@ -47,22 +47,22 @@ SmlParserCommandFunction get_cmd; } SmlParserFunctions; -typedef void (* SmlAssemblerFreeFunction) (void *userdata); -typedef SmlBool (* SmlAssemblerStartFunction) (void *userdata, SmlSession *session, GError **error); -typedef SmlBool (* SmlAssemblerEndFunction) (void *userdata, GError **error); -typedef SmlBool (* SmlAssemblerRunFunction) (void *userdata, char **data, unsigned int *size, SmlBool *end, SmlBool final, unsigned int maxsize, GError **error); -typedef unsigned int (* SmlAssemblerFlushFunction) (void *userdata); -typedef SmlBool (* SmlAssemblerStatusFunction) (void *userdata, SmlStatus *status, GError **error); -typedef SmlBool (* SmlAssemblerRemStatusFunction) (void *userdata, GError **error); -typedef SmlBool (* SmlAssemblerReserveStatusFunction) (void *userdata, unsigned int cmdRef, unsigned int msgRef, unsigned int cmdID, GError **error); -typedef SmlBool (* SmlAssemblerStatusMissingFunction) (void *userdata); -typedef SmlBool (* SmlAssemblerStartCommandFunction) (void *userdata, unsigned int parentID, SmlCommand *cmd, GError **error); -typedef SmlBool (* SmlAssemblerEndCommandFunction) (void *userdata, unsigned int parentID, GError **error); -typedef SmlBool (* SmlAssemblerRemCommandFunction) (void *userdata, unsigned int parentID, GError **error); -typedef SmlBool (* SmlAssemblerHeaderFunction) (void *userdata, SmlSession *session, GError **error); -typedef unsigned int (* SmlAssemblerCheckFunction) (void *userdata, SmlBool headeronly, GError **error); -typedef SmlBool (* SmlAssemblerNextCmdRefFunction) (void *userdata, unsigned int *cmdRef, unsigned int *msgRef); -typedef void (* SmlAssemblerRestoreCommandsFunction) (void *userdata); +typedef void (* SmlAssemblerFreeFunction) (void *userdata); +typedef gboolean (* SmlAssemblerStartFunction) (void *userdata, SmlSession *session, GError **error); +typedef gboolean (* SmlAssemblerEndFunction) (void *userdata, GError **error); +typedef gboolean (* SmlAssemblerRunFunction) (void *userdata, gchar **data, gsize *size, gboolean *end, gboolean final, gsize maxsize, GError **error); +typedef gsize (* SmlAssemblerFlushFunction) (void *userdata); +typedef gboolean (* SmlAssemblerStatusFunction) (void *userdata, SmlStatus *status, GError **error); +typedef gboolean (* SmlAssemblerRemStatusFunction) (void *userdata, GError **error); +typedef gboolean (* SmlAssemblerReserveStatusFunction) (void *userdata, guint cmdRef, guint msgRef, guint cmdID, GError **error); +typedef gboolean (* SmlAssemblerStatusMissingFunction) (void *userdata); +typedef gboolean (* SmlAssemblerStartCommandFunction) (void *userdata, guint parentID, SmlCommand *cmd, GError **error); +typedef gboolean (* SmlAssemblerEndCommandFunction) (void *userdata, guint parentID, GError **error); +typedef gboolean (* SmlAssemblerRemCommandFunction) (void *userdata, guint parentID, GError **error); +typedef gboolean (* SmlAssemblerHeaderFunction) (void *userdata, SmlSession *session, GError **error); +typedef gsize (* SmlAssemblerCheckFunction) (void *userdata, gboolean headeronly, GError **error); +typedef gboolean (* SmlAssemblerNextCmdRefFunction) (void *userdata, guint *cmdRef, guint *msgRef); +typedef void (* SmlAssemblerRestoreCommandsFunction) (void *userdata); typedef struct SmlAssemblerFunctions { SmlAssemblerFreeFunction free; @@ -89,51 +89,42 @@ SML_ASSEMBLER_RESULT_MISMATCH =2 } SmlAssemblerResult; -SmlParser *smlParserNew(SmlMimeType type, unsigned int limit, GError **error); -void smlParserFree(SmlParser *parser); -SmlBool smlParserStart(SmlParser *parser, const char *data, unsigned int size, GError **error); -SmlBool smlParserGetHeader(SmlParser *parser, SmlHeader **header, SmlCred **cred, GError **error); -SmlParserResult smlParserGetCommand(SmlParser *parser, SmlCommand **cmd, SmlError **error); -SmlBool smlParserGetStatus(SmlParser *parser, SmlStatus **status, SmlError **error); -SmlBool smlParserEnd(SmlParser *parser, SmlBool *final, SmlBool *end, SmlError **error); - -SmlAssembler *smlAssemblerNew(SmlMimeType type, unsigned int limit, GError **error); -void smlAssemblerFree(SmlAssembler *assm); -SmlBool smlAssemblerStart(SmlAssembler *assm, SmlSession *session, GError **error); -unsigned int smlAssemblerFlush(SmlAssembler *assm); -void smlAssemblerRestoreCommands(SmlAssembler *assm); -SmlBool smlAssemblerRun(SmlAssembler *assm, char **data, unsigned int *size, SmlBool *end, SmlBool final, GError **error); -SmlAssemblerResult smlAssemblerAddStatus(SmlAssembler *assm, SmlStatus *status, GError **error); -SmlAssemblerResult smlAssemblerAddStatusFull(SmlAssembler *assm, SmlStatus *status, SmlBool force, GError **error); -SmlAssemblerResult smlAssemblerReserveStatus(SmlAssembler *assm, unsigned int cmdRef, unsigned int msgRef, unsigned int cmdID, GError **error); -SmlBool smlAssemblerAddHeader(SmlAssembler *assm, SmlSession *session, GError **error); -SmlAssemblerResult smlAssemblerStartCommand(SmlAssembler *assm, SmlCommand *parent, SmlCommand *cmd, GError **error); -SmlBool smlAssemblerEndCommand(SmlAssembler *assm, SmlCommand *parent, GError **error); -unsigned int smlAssemblerCheckSize(SmlAssembler *assm, SmlBool headeronly, GError **error); -void smlAssemblerSetOption(SmlAssembler *assm, const char *optionname, const char *value); -const char *smlAssemblerGetOption(SmlAssembler *assm, const char *optionname); - -unsigned int smlAssemblerSetRemoteMaxMsgSize(SmlAssembler *assm, unsigned int limit); -unsigned int smlAssemblerGetRemoteMaxMsgSize(SmlAssembler *assm); -SmlBool smlAssemblerGetSpace(SmlAssembler *assm, int *space, SmlCommand *parent, SmlCommand *cmd, GError **error); - -unsigned int smlAssemblerGetRemoteMaxObjSize(SmlAssembler *assm); -unsigned int smlAssemblerSetRemoteMaxObjSize(SmlAssembler *assm, unsigned int limit); - -SmlBool smlAssemblerIsEmpty(SmlAssembler *assm); -SmlBool smlAssemblerIsStatusMissing(SmlAssembler *assm); -SmlBool smlAssemblerGetNextCmdRef(SmlAssembler *assm, unsigned int *cmdRef, unsigned int *msgRef); - -/* expire date: 20090626 */ -void smlAssemblerSetRequestedLimit(SmlAssembler *assm, unsigned int limit) LIBSYNCML_DEPRECATED; -void smlAssemblerSetLimit(SmlAssembler *assm, unsigned int limit) LIBSYNCML_DEPRECATED; -unsigned int smlAssemblerGetLimit(SmlAssembler *assm) LIBSYNCML_DEPRECATED; -void smlAssemblerSetRequestedMaxObjSize(SmlAssembler *assm, int limit) LIBSYNCML_DEPRECATED; -void smlAssemblerSetSendingMaxObjSize(SmlAssembler *assm, int limit) LIBSYNCML_DEPRECATED; -int smlAssemblerGetSendingMaxObjSize(SmlAssembler *assm) LIBSYNCML_DEPRECATED; -int smlAssemblerGetRequestedMaxObjSize(SmlAssembler *assm) LIBSYNCML_DEPRECATED; +SmlParser* smlParserNew (SmlMimeType type, gsize limit, GError **error); +void smlParserFree (SmlParser *parser); +gboolean smlParserStart (SmlParser *parser, const gchar *data, gsize size, GError **error); +gboolean smlParserGetHeader (SmlParser *parser, SmlHeader **header, SmlCred **cred, GError **error); +SmlParserResult smlParserGetCommand (SmlParser *parser, SmlCommand **cmd, GError **error); +gboolean smlParserGetStatus (SmlParser *parser, SmlStatus **status, GError **error); +gboolean smlParserEnd (SmlParser *parser, gboolean *final, gboolean *end, GError **error); + +SmlAssembler* smlAssemblerNew (SmlMimeType type, gsize limit, GError **error); +void smlAssemblerFree (SmlAssembler *assm); +gboolean smlAssemblerStart (SmlAssembler *assm, SmlSession *session, GError **error); +gsize smlAssemblerFlush (SmlAssembler *assm); +void smlAssemblerRestoreCommands (SmlAssembler *assm); +gboolean smlAssemblerRun (SmlAssembler *assm, gchar **data, gsize *size, gboolean *end, gboolean final, GError **error); +SmlAssemblerResult smlAssemblerAddStatus (SmlAssembler *assm, SmlStatus *status, GError **error); +SmlAssemblerResult smlAssemblerAddStatusFull (SmlAssembler *assm, SmlStatus *status, gboolean force, GError **error); +SmlAssemblerResult smlAssemblerReserveStatus (SmlAssembler *assm, guint cmdRef, guint msgRef, guint cmdID, GError **error); +gboolean smlAssemblerAddHeader (SmlAssembler *assm, SmlSession *session, GError **error); +SmlAssemblerResult smlAssemblerStartCommand (SmlAssembler *assm, SmlCommand *parent, SmlCommand *cmd, GError **error); +gboolean smlAssemblerEndCommand (SmlAssembler *assm, SmlCommand *parent, GError **error); +gsize smlAssemblerCheckSize (SmlAssembler *assm, gboolean headeronly, GError **error); +void smlAssemblerSetOption (SmlAssembler *assm, const gchar *optionname, const gchar *value); +const gchar* smlAssemblerGetOption (SmlAssembler *assm, const gchar *optionname); + +gsize smlAssemblerSetRemoteMaxMsgSize (SmlAssembler *assm, gsize limit); +gsize smlAssemblerGetRemoteMaxMsgSize (SmlAssembler *assm); +gboolean smlAssemblerGetSpace (SmlAssembler *assm, gsize *space, SmlCommand *parent, SmlCommand *cmd, GError **error); + +gsize smlAssemblerGetRemoteMaxObjSize (SmlAssembler *assm); +gsize smlAssemblerSetRemoteMaxObjSize (SmlAssembler *assm, gsize limit); + +SmlBool smlAssemblerIsEmpty (SmlAssembler *assm); +SmlBool smlAssemblerIsStatusMissing (SmlAssembler *assm); +SmlBool smlAssemblerGetNextCmdRef (SmlAssembler *assm, guint *cmdRef, guint *msgRef); /* If you want to parse OMA DS 1.2 SANs then the manager is required. */ -void smlParserSetManager(SmlParser *parser, SmlManager *manager); +void smlParserSetManager (SmlParser *parser, SmlManager *manager); #endif //_SML_PARSE_H_ Modified: trunk/libsyncml/sml_parse_internals.h ============================================================================== --- trunk/libsyncml/sml_parse_internals.h Fri Jul 3 11:31:01 2009 (r1146) +++ trunk/libsyncml/sml_parse_internals.h Fri Jul 3 15:03:14 2009 (r1147) @@ -1,7 +1,7 @@ /* * libsyncml - A syncml protocol implementation * Copyright (C) 2005 Armin Bauer <arm...@op...> - * Copyright (C) 2008 Michael Bell <mic...@op...> + * Copyright (C) 2008-2009 Michael Bell <mic...@op...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,7 +26,7 @@ SmlParserFunctions functions; void *parser_userdata; SmlMimeType type; - unsigned int limit; + gsize limit; SmlManager *manager; }; @@ -35,10 +35,10 @@ void *assm_userdata; SmlMimeType type; GHashTable *options; - SmlBool empty; + gboolean empty; - unsigned int remoteMaxMsgSize; - unsigned int remoteMaxObjSize; + gsize remoteMaxMsgSize; + gsize remoteMaxObjSize; }; #endif //_SML_PARSE_INTERNALS_H_ |