You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
(56) |
Apr
(109) |
May
(15) |
Jun
(3) |
Jul
(37) |
Aug
(96) |
Sep
(40) |
Oct
(4) |
Nov
(54) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(47) |
Feb
(30) |
Mar
(102) |
Apr
(120) |
May
(68) |
Jun
(54) |
Jul
(53) |
Aug
(122) |
Sep
(190) |
Oct
(71) |
Nov
(85) |
Dec
(108) |
2007 |
Jan
(72) |
Feb
(190) |
Mar
(53) |
Apr
(101) |
May
(145) |
Jun
(148) |
Jul
(167) |
Aug
(143) |
Sep
(23) |
Oct
(198) |
Nov
(223) |
Dec
(195) |
2008 |
Jan
(100) |
Feb
(129) |
Mar
(79) |
Apr
(77) |
May
(34) |
Jun
(95) |
Jul
(112) |
Aug
(160) |
Sep
(82) |
Oct
(124) |
Nov
(199) |
Dec
(355) |
2009 |
Jan
(436) |
Feb
(89) |
Mar
(298) |
Apr
(189) |
May
(33) |
Jun
(88) |
Jul
(105) |
Aug
(44) |
Sep
(181) |
Oct
(87) |
Nov
(75) |
Dec
(1) |
2010 |
Jan
(63) |
Feb
(21) |
Mar
(3) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(26) |
Aug
(37) |
Sep
(26) |
Oct
(15) |
Nov
(13) |
Dec
|
From: <svn...@op...> - 2009-04-11 18:29:42
|
Author: scriptor Date: Sat Apr 11 20:29:35 2009 New Revision: 5579 URL: http://www.opensync.org/changeset/5579 Log: Fixed bug in ldap_format_print_format1(). Fixed some error messages and other issues. Modified: plugins/ldap-sync/src/ldap_format.c plugins/ldap-sync/src/ldap_format.h Modified: plugins/ldap-sync/src/ldap_format.c ============================================================================== --- plugins/ldap-sync/src/ldap_format.c Sat Apr 11 20:29:13 2009 (r5578) +++ plugins/ldap-sync/src/ldap_format.c Sat Apr 11 20:29:35 2009 (r5579) @@ -1965,12 +1965,12 @@ if (!strcmp((char *)root_element->name, "contact")) { if (strcmp(stylesheet_file, STYLESHEET_XMLFORMAT_CONTACT2LDAP_EVOLUTIONPERSON) && (strcmp(stylesheet_file, STYLESHEET_XMLFORMAT_CONTACT2LDAP_INETORGPERSON))) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s() is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __FILE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s is not prepared to convert this.\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __FILE__); #ifdef CALL_ABORT - osync_trace(TRACE_ERROR, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s() is not prepared to convert this. Calling abort().\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __FILE__); - ldap_plugin_printf("%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s() is not prepared to convert this. Calling abort().\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __FILE__); - fprintf(stderr, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s() is not prepared to convert this. Calling abort().\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __FILE__); + osync_trace(TRACE_ERROR, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s is not prepared to convert this. Calling abort().\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __FILE__); + ldap_plugin_printf("%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s is not prepared to convert this. Calling abort().\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __FILE__); + fprintf(stderr, "%s:%i: ERROR: For this root_element \"%s\" is \"%s\" the wrong style sheet file. %s is not prepared to convert this. Calling abort().\n", __FILE__, __LINE__, root_element->name, stylesheet_file, __FILE__); fflush(stderr); abort(); @@ -2230,10 +2230,13 @@ xmlSubstituteEntitiesDefault(1); xmlLoadExtDtdDefaultValue = 1; + + // First off, try and find out what type of data has been casted to char *: if (inpsize >= 6 && !strncmp(input, "<?xml ", 6)) { // Convert an xmlChar string of the input into an xmlDoc struct: input_doc = xmlParseMemory(input, inpsize); + } else { osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input does not seem to be a human readable xml string.\n", __FILE__, __LINE__); @@ -2241,12 +2244,16 @@ if (inpsize == osync_xmlformat_size()) { osync_trace(TRACE_ERROR, "%s:%i: ERROR: Looks like opensync specific xmlformat.\n", __FILE__, __LINE__); + } else if (inpsize == 0) { osync_trace(TRACE_ERROR, "%s:%i: ERROR: inpsize = 0.\n", __FILE__, __LINE__); - } else if (inpsize == sizeof(GList)) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR: Looks like a GList.", __FILE__, __LINE__); + } else if (inpsize == sizeof(glist_container)) { osync_trace(TRACE_ERROR, "%s:%i: ERROR: Looks like a glist_container.", __FILE__, __LINE__); + + } else if (inpsize == sizeof(GList)) { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: Looks like a GList.", __FILE__, __LINE__); + } else { osync_trace(TRACE_ERROR, "%s:%i: ERROR: Could be xmlinternal?\n", __FILE__, __LINE__); } @@ -4718,19 +4725,20 @@ } + // First off, try and find out what type of data has been casted to char *: if (inpsize != sizeof(glist_container)) { - // osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input is NOT a glist_container.\n", __FILE__, __LINE__); - osync_trace(TRACE_ERROR, "%s:%i: What is input? inpsize = %i", __FILE__, __LINE__, inpsize); + osync_trace(TRACE_INTERNAL, "%s:%i: What is input? inpsize = %i", __FILE__, __LINE__, inpsize); if (inpsize == sizeof(GList)) { - osync_trace(TRACE_ERROR, "%s:%i: input looks like a GList.", __FILE__, __LINE__); + osync_trace(TRACE_INTERNAL, "%s:%i: input looks like a GList.", __FILE__, __LINE__); } else if (inpsize == sizeof(ldap_entry)) { - osync_trace(TRACE_ERROR, "%s:%i: input looks like an ldap_entry.", __FILE__, __LINE__); + osync_trace(TRACE_INTERNAL, "%s:%i: input looks like an ldap_entry.", __FILE__, __LINE__); + } else if (inpsize == osync_xmlformat_size()) { - osync_trace(TRACE_ERROR, "%s:%i: input looks like an OsyncXMLFormat.\n", __FILE__, __LINE__); + osync_trace(TRACE_INTERNAL, "%s:%i: input looks like an OsyncXMLFormat.\n", __FILE__, __LINE__); #ifdef CALL_ABORT @@ -4748,20 +4756,20 @@ if (!osync_xmlformat_assemble((OSyncXMLFormat *)input, (char **) &xmlbuff, (unsigned int *)&size)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input is NOT a glist_container. Looks like an OSyncXMLFormat.\n", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input is NOT a glist_container. Looks like an OSyncXMLFormat. But osync_xmlformat_assemble() has failed for an unknown reason. Giving up.", __FILE__, __LINE__); osync_trace(TRACE_ERROR, "%s:%i: ERROR: osync_xmlformat_assemble() has failed for an unknown reason. Giving up.\n", __FILE__, __LINE__); goto error; } if (xmlbuff == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input is NOT a glist_container. Looks like an OSyncXMLFormat.\n", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input is NOT a glist_container. Looks like an OSyncXMLFormat. But xmlbuff = NULL. osync_xmlformat_assemble() must have failed for an unknown reason. Giving up.\n", __FILE__, __LINE__); osync_trace(TRACE_ERROR, "%s:%i: ERROR: xmlbuff = NULL. osync_xmlformat_assemble() must have failed for an unknown reason. Giving up.\n", __FILE__, __LINE__); goto error; } if (size < 6) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input is NOT a glist_container. Looks like an OSyncXMLFormat.\n", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input is NOT a glist_container. Looks like an OSyncXMLFormat. But size = %i. osync_xmlformat_assemble() must have failed for an unknown reason. Giving up.\n", __FILE__, __LINE__, size); osync_trace(TRACE_ERROR, "%s:%i: ERROR: size = %i. osync_xmlformat_assemble() must have failed for an unknown reason. Giving up.\n", __FILE__, __LINE__, size); goto error; @@ -4774,6 +4782,13 @@ #endif + } else if (inpsize > 6 && ldap_format_check_xml((char *)input, (int)inpsize, error)) { + osync_trace(TRACE_INTERNAL, "%s:%i: This is a string with a human readable XML document.", __FILE__, __LINE__); + xmlbuff = (xmlChar *)g_strdup(input); + size = inpsize; + goto applying_stylesheet; + + } else { osync_trace(TRACE_ERROR, "%s:%i: Don't know. inpsize = %u\n", __FILE__, __LINE__, inpsize); } @@ -4782,7 +4797,8 @@ } - // Check the magic string + // Assuming it is a glist_container struct: + // Check the magic string and extract the included GList. if (!ldap_plugin_get_glist(input, &list, error)) { osync_trace(TRACE_ERROR, "%s:%i: ERROR: ldap_plugin_get_glist() has failed.\n", __FILE__, __LINE__); @@ -4818,9 +4834,7 @@ } -#ifndef CALL_ABORT applying_stylesheet: -#endif // Apply stylesheet @@ -5005,6 +5019,10 @@ * 2. From this plugin-internal XML format into ldap_entry structs * which can libldap be fed with. * + * This is one of two locations in the LDAP plugin, where a + * glist_container is generated. + * See also ldap_plugin_report_change() in ldap_plugin.c. + * * @param input The input: The XML document in a format as used by libopensync. * @param inpsize: Its size. * @param output The resulting list of LDAP entries. @@ -5040,7 +5058,7 @@ char *xmlformat = NULL; unsigned int xmlformat_size = 0; GList *ldap_entries = NULL; - glist_container *container = NULL; + glist_container *container = NULL; osync_trace(TRACE_ENTRY, "%s(%p, %u, %p, %p, %p, %p, %p, %p, %p, %p, %p, %p)", __func__, input, inpsize, output, outpsize, free_input, xmlformat_name, ldap_format_name, stylesheet_name, objtype, config, userdata, error); @@ -5142,6 +5160,7 @@ container = (glist_container *)g_malloc0(sizeof(glist_container) + 1); osync_assert(container); container->magic = "glist_container"; + container->format_name = ldap_format_name; container->list = ldap_entries; osync_assert(output); @@ -5719,6 +5738,7 @@ osync_trace(TRACE_INTERNAL, "%s:%i:%s():\n\n\ndestroy function has been called for input = %p\n\n\n", __FILE__, __LINE__, __func__, input); + // First off, try and find out what type of data has been casted to char * osync_trace(TRACE_INTERNAL, "%s:%i: What is input? inpsize = %i", __FILE__, __LINE__, inpsize); @@ -5742,21 +5762,24 @@ if (inpsize == osync_xmlformat_size()) { osync_trace(TRACE_INTERNAL, "Looks like the opensync specific xmlformat.\n"); + } else if (inpsize == sizeof(ldap_entry)) { osync_trace(TRACE_INTERNAL, "Looks like an ldap_entry struct."); + } else if (inpsize == sizeof(xmlDoc)) { osync_trace(TRACE_INTERNAL, "Looks like an xmlDoc."); + } else if (inpsize == sizeof(glist_container)) { osync_trace(TRACE_INTERNAL, "Looks like a glist_container."); + } else if (inpsize == sizeof(GList)) { unsigned int length = 0; GList *list = (GList *)input; osync_trace(TRACE_INTERNAL, "Looks like a GList."); - length = g_list_length(list); - osync_trace(TRACE_INTERNAL, "With %u elements.", length); + } else { osync_trace(TRACE_INTERNAL, "Don't know."); } @@ -5834,41 +5857,138 @@ unsigned int i = 0, j = 0; ldap_entry *entry = NULL; GString *str = NULL; + xmlChar *xmlbuff = NULL; + unsigned int xmlbuff_size = 0; + OSyncError *error = NULL; + + osync_trace(TRACE_ENTRY, "%s(%p, %d, %p) ", __func__, data, size, user_data); - osync_trace(TRACE_ENTRY, "%s(%p, %d, %p) ", __func__, data, size, user_data); if (data == NULL) { osync_trace(TRACE_ERROR, "%s:%i: ERROR: data = NULL. Returning NULL.\n", __FILE__, __LINE__); goto error; } - if (size != sizeof(GList)) { - osync_trace(TRACE_ERROR, "%s:%i:%s(): WARNING: size = %u bytes. Ignoring.\n", __FILE__, __LINE__, __func__, size); + + + if (size < sizeof(glist_container)) { + +#ifdef CALL_ABORT + osync_trace(TRACE_ERROR, "%s:%i: ERROR: size = %i. Calling abort()\n", __FILE__, __LINE__, size); + ldap_plugin_printf("%s:%i: ERROR: size = %i. Calling abort()\n", __FILE__, __LINE__, size); + abort(); +#else + osync_trace(TRACE_ERROR, "%s:%i: ERROR: size = %i.\n", __FILE__, __LINE__, size); + goto error; +#endif + + } + + + // First off, try and find out what type of data has been casted to char *: + if (size == sizeof(glist_container) && ((glist_container *)data)->magic && !strcmp(((glist_container *)data)->magic, "glist_container")) { + if (!ldap_plugin_get_glist(data, &list, &error)) { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: ldap_plugin_get_glist() has failed.\n", __FILE__, __LINE__); + + if (!osync_error_is_set(&error)) + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ldap_plugin_get_glist() has failed.\n", __FILE__, __LINE__); + + goto error; + } + } else { + osync_trace(TRACE_INTERNAL, "%s:%i: What is data? size = %i", __FILE__, __LINE__, size); + + + if (size == sizeof(GList)) { + osync_trace(TRACE_ERROR, "%s:%i: data looks like a GList.", __FILE__, __LINE__); + list = (GList *)data; + + } else if (size == sizeof(ldap_entry)) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: data looks like an ldap_entry. This is completely wrong.", __FILE__, __LINE__); + goto error; + + } else if (size == osync_xmlformat_size()) { + osync_trace(TRACE_ERROR, "%s:%i: data looks like an OsyncXMLFormat.\n", __FILE__, __LINE__); + + +#ifdef CALL_ABORT + osync_trace(TRACE_ERROR, "%s:%i: ERROR: data is NOT a glist_container. Looks like an OSyncXMLFormat.\n", __FILE__, __LINE__); + osync_trace(TRACE_ERROR, "%s:%i: Where does that come from? Calling abort().", __FILE__, __LINE__); + ldap_plugin_printf("%s:%i: Where does that come from? Calling abort().", __FILE__, __LINE__); + fprintf(stderr, "%s:%i: Where does that come from? Calling abort().\n\n", __FILE__, __LINE__); + fflush(stderr); + abort(); + +#else + osync_assert(data); + osync_trace(TRACE_INTERNAL, "%s:%i: We can handle this. If you prefer getting a core dump, define CALL_ABORT in ldap_plugin.h and recompile the LDAP format plugin.", __FILE__, __LINE__); + + + + if (!osync_xmlformat_assemble((OSyncXMLFormat *)data, (char **) &xmlbuff, &xmlbuff_size)) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: data is NOT a glist_container. Looks like an OSyncXMLFormat. But osync_xmlformat_assemble() has failed for an unknown reason. Giving up.\n", __FILE__, __LINE__); + goto error; + } + + if (xmlbuff == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: data is NOT a glist_container. Looks like an OSyncXMLFormat. But xmlbuff = NULL. osync_xmlformat_assemble() must have failed for an unknown reason. Giving up.\n", __FILE__, __LINE__); + goto error; + } + + + if (xmlbuff_size < 6) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: data is NOT a glist_container. Looks like an OSyncXMLFormat. But xmlbuff_size = %i. sync_xmlformat_assemble() must have failed for an unknown reason. Giving up. size = %i.", __FILE__, __LINE__, xmlbuff_size, size); + goto error; + } + + + osync_trace(TRACE_INTERNAL, "%s:%i: This is the content of the OSyncXMLFormat:\n\"%.*s\"", __FILE__, __LINE__, xmlbuff_size, xmlbuff); + + osync_trace(TRACE_EXIT, "%s(): str = %p", __func__, xmlbuff); + return (char *)xmlbuff; + +#endif + + + } else { + osync_trace(TRACE_INTERNAL, "%s:%i: Don't know what that is: size = %u. We print it literally no matter what...\n", __FILE__, __LINE__, size); + osync_trace(TRACE_EXIT, "%s(): Returning data = %p", __func__, data); + return (char *)data; + } + + + // unreachable + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Don't know what that is. Bailing out."); + goto error; } - list = (GList *)data; + if (list == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: list = NULL.", __FILE__, __LINE__); + goto error; + } + if (g_list_length(list) < 1) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR: list has %u elements. Returning NULL.", __FILE__, __LINE__, g_list_length(list)); + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: list has %u elements. Returning NULL.", __FILE__, __LINE__, g_list_length(list)); goto error; } str = g_string_new((const gchar *)"----- <list> -----\n"); if (str == NULL) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR: str = NULL. Returning NULL.\n", __FILE__, __LINE__); + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: str = NULL. Returning NULL.\n", __FILE__, __LINE__); goto error; } for (i = 0; i < g_list_length(list); i++) { - g_string_append_printf(str, "---------\n"); + g_string_append_printf(str, "\n"); entry = (ldap_entry *)g_list_nth_data(list, i); if (entry == NULL) { osync_trace(TRACE_ERROR, "%s:%i: ERROR: entry = NULL with i = %u. Ignoring this LDAP entry.\n", __FILE__, __LINE__, i); - g_string_append_printf(str, "---------\n"); + g_string_append_printf(str, "\n"); continue; } @@ -5884,7 +6004,7 @@ if (entry->mods == NULL) { osync_trace(TRACE_ERROR, "%s:%i: ERROR: entry->mods = NULL with i = %u\n", __FILE__, __LINE__, i); g_string_append_printf(str, "NULL.\n"); - g_string_append_printf(str, "---------\n"); + g_string_append_printf(str, "\n"); continue; } @@ -5893,7 +6013,7 @@ LDAPMod *mod = entry->mods[j]; if (mod) { if (mod->mod_type) { - g_string_append_printf(str, "%s: \t", mod->mod_type); + g_string_append_printf(str, "%s: ", mod->mod_type); if (mod->mod_bvalues) { if (mod->mod_bvalues[0]) { if (mod->mod_bvalues[0]->bv_val) { @@ -5916,21 +6036,25 @@ } } // for (j = 0; entry->mods[j]; j++) - g_string_append_printf(str, "---------\n"); + g_string_append_printf(str, "\n"); } // for (i = 0; i < g_list_length(list); i++) g_string_append_printf(str, "----- </list> -----\n"); - if (str && str->len) { - osync_trace(TRACE_INTERNAL, "%s:%i:%s():\nstr = \"%s\"\n", __FILE__, __LINE__, __func__, str); + if (str && str->len && str->str) { + osync_trace(TRACE_INTERNAL, "%s:%i:%s():\nstr->str = \"%s\"\n", __FILE__, __LINE__, __func__, str->str); } - osync_trace(TRACE_EXIT, "%s(): str = %p", __func__, str); - return (char *)str; + osync_trace(TRACE_EXIT, "%s(): str = %p, str->str = %p", __func__, str, str->str); + return (char *)str->str; error: - osync_trace(TRACE_EXIT_ERROR, "%s: Returning NULL.", __func__); + if (!osync_error_is_set(&error)) + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); + + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); + osync_error_unref(&error); return NULL; } @@ -5961,111 +6085,80 @@ - - - /** - * @brief Main function to set up the different functions required - * for converting from and to the ldap related formats - * offered by this plugin. - * @param env The format environment. - * @param error libopensync error pointer. - * @returns TRUE on success, FALSE on error + * @brief This function performs some rudimentary check whether the byte + * sequence pointed to by data is a human readable XML document. + * This is a helper function for the detector functions and for the + * validator function. + * + * @param data This is the byte sequence to be checked. + * @param size This is the length of the byte sequence. + * @param error The libopensync error pointer. + * + * @returns TRUE if it IS an XML doc, FALSE, if not and in case of any error. + * */ -osync_bool get_format_info(OSyncFormatEnv *env, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, env, error); - +osync_bool ldap_format_check_xml(const char *data, int size, OSyncError **error) +{ + GRegex* regex = NULL; + osync_bool rv = FALSE; + GError *gerror = NULL; - OSyncObjFormat *contact1_format = osync_objformat_new(FORMAT_LDAP_EVOLUTIONPERSON, OBJECTTYPE_CONTACT, error); - OSyncObjFormat *contact2_format = osync_objformat_new(FORMAT_LDAP_INETORGPERSON, OBJECTTYPE_CONTACT, error); + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, size, error); - OSyncObjFormat *event_format = osync_objformat_new(FORMAT_LDAP_EVENT, OBJECTTYPE_EVENT, error); - - OSyncObjFormat *todo_format = osync_objformat_new(FORMAT_LDAP_TODO, OBJECTTYPE_TODO, error); - - OSyncObjFormat *note_format = osync_objformat_new(FORMAT_LDAP_NOTE, OBJECTTYPE_NOTE, error); - - if (!contact1_format) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: contact_format = NULL.\n", __FILE__, __LINE__); + if (data == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: data = NULL."); goto error; - } + } - if (!event_format) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: event_format = NULL.\n", __FILE__, __LINE__); - goto error; - } - if (!todo_format) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: todo_format = NULL.\n", __FILE__, __LINE__); + // Note: ? is a quantifier rather than a question mark. + // ? after another quantifier means that the preceding quantifier + // is "ungreedy". + regex = g_regex_new("\\s*?<\?\\s*?xml\\sversion\\s*=\\s*\"1\\.0\"\\s*[^?]*?\\?\\s*?>.?", 0, 0, &gerror); + + if (gerror) { + if (gerror->message) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: g_regex_new() has failed. The pattern must be wrong: %s", __FILE__, __LINE__, gerror->message); + } else { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: g_regex_new() has failed. The pattern must be wrong.", __FILE__, __LINE__); + } + goto error; } - if (!note_format) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: note_format = NULL.\n", __FILE__, __LINE__); + if (regex == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: regex = NULL. g_regex_new() must have failed.", __FILE__, __LINE__); goto error; } + + if (g_regex_match(regex, data, 0, NULL)) { +#ifdef DEBUG_detection + osync_trace(TRACE_INTERNAL, "%s:%i: It IS an XML document.\n", __FILE__, __LINE__); +#endif - osync_objformat_set_compare_func(contact1_format, ldap_format_compare_format1); - osync_objformat_set_destroy_func(contact1_format, ldap_format_destroy_format1); - osync_objformat_set_duplicate_func(contact1_format, ldap_format_duplicate_format1); - osync_objformat_set_print_func(contact1_format, ldap_format_print_format1); - osync_objformat_set_validate_func(contact1_format, ldap_format_validate); - - - - osync_objformat_set_compare_func(contact2_format, ldap_format_compare_format1); - osync_objformat_set_destroy_func(contact2_format, ldap_format_destroy_format1); - osync_objformat_set_duplicate_func(contact2_format, ldap_format_duplicate_format1); - osync_objformat_set_print_func(contact2_format, ldap_format_print_format1); - osync_objformat_set_validate_func(contact2_format, ldap_format_validate); - - - osync_objformat_set_compare_func(event_format, ldap_format_compare_format1); - osync_objformat_set_destroy_func(event_format, ldap_format_destroy_format1); - osync_objformat_set_duplicate_func(event_format, ldap_format_duplicate_format1); - osync_objformat_set_print_func(event_format, ldap_format_print_format1); - osync_objformat_set_validate_func(event_format, ldap_format_validate); - - - osync_objformat_set_compare_func(todo_format, ldap_format_compare_format1); - osync_objformat_set_destroy_func(todo_format, ldap_format_destroy_format1); - osync_objformat_set_duplicate_func(todo_format, ldap_format_duplicate_format1); - osync_objformat_set_print_func(todo_format, ldap_format_print_format1); - osync_objformat_set_validate_func(todo_format, ldap_format_validate); - - - osync_objformat_set_compare_func(note_format, ldap_format_compare_format1); - osync_objformat_set_destroy_func(note_format, ldap_format_destroy_format1); - osync_objformat_set_duplicate_func(note_format, ldap_format_duplicate_format1); - osync_objformat_set_print_func(note_format, ldap_format_print_format1); - osync_objformat_set_validate_func(note_format, ldap_format_validate); - - + rv = TRUE; - - osync_format_env_register_objformat(env, contact1_format); - osync_format_env_register_objformat(env, contact2_format); - osync_format_env_register_objformat(env, event_format); - osync_format_env_register_objformat(env, todo_format); - osync_format_env_register_objformat(env, note_format); + } else { +#ifdef DEBUG_detection + osync_trace(TRACE_INTERNAL, "%s(): It is NOT an XML document.", __func__); +#endif + rv = FALSE; + } - osync_objformat_unref(contact1_format); - osync_objformat_unref(contact2_format); - osync_objformat_unref(event_format); - osync_objformat_unref(todo_format); - osync_objformat_unref(note_format); + if (regex) + g_regex_unref(regex); - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; + osync_trace(TRACE_EXIT, "%s(): rv = %s", __func__, rv ? "TRUE" : "FALSE"); + return rv; error: if (!osync_error_is_set(error)) @@ -6076,105 +6169,846 @@ } -/** - * \typedef (* fn_ptr) - * @brief typedef for a function pointer to be used as parameter in - * ldap_format_do_get_conversion_info() - * @param input The data you need to convert - * @param inpsize The size of the input data - * - * @param output This will contain the result of the conversion - * @param outpsize The will contain the size of the output - * - * @param free_input - * "You need to set this to TRUE if opensync - * can free the input after the conversion (so you don't - * use any reference from or to the input). An example where - * *free_input = FALSE; needs to be done would be an encapsulator - * that stores the input reference somewhere in its struct." - * - * @param config ??? - * @param userdata ??? - * @param error if something bad happens and you cannot convert, set the error! - * - * @returns TRUE on success, FALSE on error - */ -typedef osync_bool (* fn_ptr) (char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error); - - - - - - /** - * @brief Helper function for setting up the converter functions. - * - * @param env Format specific environment. - * @param format_name Name of the first format. - * @param other_format_name of the second format. - * @param objtype Object type, such as "contact", "event", "todo", "note". - * @param converter1 Function pointer to a converter function. - * @param converter2 Function pointer to a converter function for the opposite direction. - * @param error libopensync error pointer. + * @brief This function performs the check of a byte sequence whether + * or not it is of the type of format the calling function + * expects. The caller tells this function about its expectation + * by stating the format_name, and the opening and closing tag + * of a potential XML document. + * + * Problem: + * + * At least three different kinds of data are washed ashore, here: + * + * - Real strings, char *, i.e. human readable forms of XML documents. + * - OSyncXMLFormat structs, + * - glist_container structs. This is the only type that is caused + * by the LDAP plugin. The LDAP plugin does not proliferate other + * kinds of data. + * + * Similar problems does ldap_format_do_apply_stylesheet() + * face from time to time. + * + * + * @param data The byte sequence to be checked. + * @param size The length of the byte sequence. + * @param format_name The name of the format to be checked. + * @param opening_tag How would the opening tag of an XML document look like, + * if it were of the expected format. + * @param closing_tag How would the closing tag of an XML document look like, + * if it were of the expected format. + * @param userdata ??????? + * @param error The libopensync error pointer. * - * @returns TRUE on success, FALSE on failure. + * @returns TRUE if it IS the type of format, the caller want to check by + * telling the format_name, the opening_tag and the closing_tag. + * FALSE if it is NOT the type of format the caller would have + * expected, and also in case of any error. + * */ -static osync_bool ldap_format_do_get_conversion_info(OSyncFormatEnv *env, const char *format_name, const char *other_format_name, const char *objtype, fn_ptr converter1, fn_ptr converter2, OSyncError **error) +osync_bool ldap_format_do_detect_plain_as_ldap_format(const char *data, const int size, const char *format_name, const char *opening_tag, const char *closing_tag, const void *userdata, OSyncError **error) { - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p, %p, %p)", __func__, env, format_name, other_format_name, objtype, converter1, converter2, error); + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p, %p, %p)", __func__, data, size, format_name, opening_tag, closing_tag, userdata, error); - if (env == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: env = NULL.\n", __FILE__, __LINE__); + if (data == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: data = NULL."); goto error; } - + if (format_name == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: format_name = NULL.\n", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: format_name = NULL."); goto error; } - if (other_format_name == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: other_format_name = NULL.\n", __FILE__, __LINE__); + if (format_name[0] == 0) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: format_name[0] = 0."); goto error; } - if (format_name == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: format_name = NULL.\n", __FILE__, __LINE__); + if (opening_tag == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: opening_tag = NULL."); goto error; } - if (objtype == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: objtype = NULL.\n", __FILE__, __LINE__); + if (opening_tag[0] == 0) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: opening_tag[0] = 0."); goto error; } - OSyncObjFormat *format1 = osync_format_env_find_objformat(env, format_name); - if (!format1) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find \"%s\" format", format_name); + + if (closing_tag == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: closing_tag = NULL."); goto error; } + if (closing_tag[0] == 0) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: closing_tag[0] = 0."); + goto error; + } + + + + +#ifdef DEBUG_detection + fprintf(stderr, "%s:%i: Input:\n", __FILE__, __LINE__); + GString *buffer = NULL; + + ldap_plugin_dump_bytes((unsigned char *)data, size < 64 ? size : 64, &buffer, error); + + if (buffer && buffer->str) { + fprintf(stderr, "%s\n\n", buffer->str); + } +#endif + + + // First off, try and find out what type of data has been casted to + // char *. The following possibilities have already been seen here: + // + // 1. A real string of a human readable XML document. I.e. a char *, + // that has NOT been casted, at all. An easy case. + // + // 2. A glist_container struct: This is the type of data used by the + // LDAP format plugin itself. It can clearly be identified by means + // of a magic string. Also an easy and, moreover, an unambigous case. + // + // 3. An OSyncXMLFormat. Who knows, where that comes from. The pointers + // in it seem all to be invalid. Any try to call osync_xmlformat_assemble() + // lead to SIGSEGV. Therefore this function call can be commented out + // by undefining HANDLE_OSYNC_XMLFORMAT in ldap_plugin.h. + // + if (size == sizeof(glist_container)) { + glist_container *container = (glist_container *)data; + if (container->magic) { + if (!strcmp(container->magic, "glist_container")) { + + osync_trace(TRACE_INTERNAL, "%s:%i: data looks like a glist_container.", __FILE__, __LINE__); + + if (container->format_name == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: container->format_name = NULL.", __FILE__, __LINE__); + goto error; + } + + if (container->format_name[0] == 0) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: container->format_name[0] = 0.", __FILE__, __LINE__); + goto error; + } + + +#ifdef DEBUG_detection + ldap_plugin_printf("%s:%i: \n" + "container->format_name = \"%s\", \n" + "format_name = \"%s\".", + __FILE__, __LINE__, container->format_name, format_name); +#endif + + if (!strcmp(container->format_name, format_name)) { + + osync_trace(TRACE_EXIT, "%s(): Returning TRUE.", __func__); + return TRUE; + } else { + osync_trace(TRACE_EXIT, "%s(): Returning FALSE.", __func__); + return FALSE; + } + + + osync_trace(TRACE_EXIT, "%s(): Unreachable Code! Returning FALSE.", __func__); + return FALSE; + + + } else { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: data happened to have the same size as a glist_container struct. But its magic is different. So this is NOT a glist_container.", __FILE__, __LINE__); + goto regular_way; + } + } else { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: data happened to have the same size as a glist_container struct. But its magic is NULL. So this is NOT a glist_container.", __FILE__, __LINE__); + goto regular_way; + } + + } else if ((unsigned int)size == osync_xmlformat_size()) { +#ifdef HANDLE_OSYNC_XMLFORMAT + char *xmlbuff = NULL; + unsigned int xmlbuff_size = 0; +#endif + + osync_trace(TRACE_INTERNAL, "%s:%i: data looks like an OSyncXMLFormat. This is most probably NOT an LDAP specific format.", __FILE__, __LINE__); + + + +#ifdef CALL_ABORT + osync_trace(TRACE_ERROR, "%s:%i: Where does that come from? Calling abort().", __FILE__, __LINE__); + ldap_plugin_printf("%s:%i: Where does that come from? Calling abort().", __FILE__, __LINE__); + printf(stderr, "%s:%i: Where does that come from? Calling abort().\n\n", __FILE__, __LINE__); + fflush(stderr); + abort(); +#endif + + + + +#ifdef HANDLE_OSYNC_XMLFORMAT + osync_assert(data); + if (!osync_xmlformat_assemble((OSyncXMLFormat *)data, &xmlbuff, &xmlbuff_size)) { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: osync_xmlformat_assemble() has failed for an unknown reason. Giving up.\n", __FILE__, __LINE__); + goto error; + } + + if (xmlbuff == NULL) { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: xmlbuff = NULL. osync_xmlformat_assemble() must have failed for an unknown reason. Giving up.\n", __FILE__, __LINE__); + goto error; + } + + + if (xmlbuff_size < 6) { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: xmlbuff_size = %i. osync_xmlformat_assemble() must have failed for an unknown reason. Giving up.\n", __FILE__, __LINE__, xmlbuff_size); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: xmlbuff_size = %i. osync_xmlformat_assemble() must have failed for an unknown reason. Giving up.\n", __FILE__, __LINE__, xmlbuff_size); + GString *str = NULL; + ldap_plugin_dump_bytes((unsigned char *)xmlbuff, (int)xmlbuff_size, &str, error); + if (str && str->str) { + ldap_plugin_printf("%s", str->str); + } + + goto error; + } + + + osync_trace(TRACE_INTERNAL, "%s:%i: This is the content of the OSyncXMLFormat:\n\n\n\"%.*s\"\n\n\n", __FILE__, __LINE__, xmlbuff_size, xmlbuff); + +#endif + + + osync_trace(TRACE_EXIT, "%s(): Returning FALSE.", __func__); + return FALSE; + + } else if (size == sizeof(ldap_entry)) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: data looks like an ldap_entry struct. This is totally wrong. How could that even happen?", __FILE__, __LINE__); + goto error; + + } else if (size == sizeof(xmlDoc)) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: data looks like an xmlDoc.", __FILE__, __LINE__); + goto error; + + } else if (size == sizeof(GList)) { + unsigned int i = 0; + + + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: data looks like a GList.", __FILE__, __LINE__); + + osync_trace(TRACE_ERROR, "ERROR: data looks like a GList with %u elements.", g_list_length((GList *)data)); + + for (i = 0; i < g_list_length((GList *)data); i++) { + ldap_entry *entry = g_list_nth_data((GList *)data, i); + if (entry == NULL) { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: entry = NULL with i = %u.\n", __FILE__, __LINE__, i); + continue; + } + + if (entry->dn) { + ldap_plugin_printf("entry->dn = \"%s\"", entry->dn); + } + } + + + goto error; + } + + + + +regular_way: + + if (!ldap_format_check_xml(data, size, error)) { + osync_trace(TRACE_INTERNAL, "%s:%i: ldap_format_check_xml() has NOT recognized input as an XML document.", __FILE__, __LINE__); + osync_trace(TRACE_EXIT, "%s(): Returning FALSE.", __func__); + return FALSE; + } + + + if (g_strstr_len(data, size, opening_tag) && g_strstr_len(data, size, closing_tag)) { + osync_trace(TRACE_EXIT, "%s(): Returning TRUE.", __func__); + return TRUE; + } else { + osync_trace(TRACE_EXIT, "%s(): Returning FALSE.", __func__); + return FALSE; + } + + + osync_trace(TRACE_EXIT, "%s(): Unreachable code! Returning FALSE.", __func__); + return FALSE; + + +error: + if (!osync_error_is_set(error)) + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); + + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; +} + + + + +/** + * @brief This function checks whether a byte sequence contains an + * ldap-evolutionperson format. + * + * @param data The byte sequence to be checked. + * @param size The length of the byte sequence. + * @param userdata ??????????????? + * + * @returns TRUE if the byte sequence is of the ldap-evolution format. + * FALSE if not, and in case of any errors. + * + */ + +osync_bool ldap_format_detect_plain_as_ldap_evolutionperson(const char *data, const int size, void *userdata) +{ + OSyncError *error = NULL; + + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, data, size, userdata); + + + if (data == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: data = NULL."); + goto error; + } + + + if (ldap_format_do_detect_plain_as_ldap_format(data, size, "ldap-evolutionperson", "<ldap-evolutionperson>", "</ldap-evolutionperson>", userdata, &error)) { +#ifdef DEBUG_detection + osync_trace(TRACE_INTERNAL, "%s:%i: It IS an ldap-evolutionperson format.\n", __FILE__, __LINE__); +#endif + + if (osync_error_is_set(&error)) { + goto error; + } + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; + + } else { +#ifdef DEBUG_detection + osync_trace(TRACE_INTERNAL, "%s:%i: It is NOT an ldap-evolutionperson format.\n", __FILE__, __LINE__); +#endif + + if (osync_error_is_set(&error)) { + goto error; + } + + osync_trace(TRACE_EXIT, "%s", __func__); + return FALSE; + } + + + osync_trace(TRACE_EXIT, "%s", __func__); + return FALSE; + +error: + if (!osync_error_is_set(&error)) + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); + + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); + return FALSE; +} + + + + + + +/** + * @brief This function checks whether a byte sequence contains an + * ldap-inetorgperson format. + * + * @param data The byte sequence to be checked. + * @param size The length of the byte sequence. + * @param userdata ??????????????? + * + * @returns TRUE if the byte sequence is of the ldap-inetorgperson format. + * FALSE if not, and in case of any errors. + * + */ + +osync_bool ldap_format_detect_plain_as_ldap_inetorgperson(const char *data, int size, void *userdata) +{ + OSyncError *error = NULL; + + + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, data, size, userdata); + + + if (data == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: data = NULL."); + goto error; + } + + + if (ldap_format_do_detect_plain_as_ldap_format(data, size, "ldap-inetorgperson", "<ldap-inetorgperson>", "</ldap-inetorgperson>", userdata, &error)) { +#ifdef DEBUG_detection + ldap_plugin_printf("%s:%i: It IS an ldap-inetorgperson format.\n", __FILE__, __LINE__); +#endif + + if (osync_error_is_set(&error)) { + goto error; + } + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; + + } else { +#ifdef DEBUG_detection + osync_trace(TRACE_INTERNAL, "%s:%i: It is NOT an ldap-inetorgperson format.\n", __FILE__, __LINE__); +#endif + + if (osync_error_is_set(&error)) { + goto error; + } + + osync_trace(TRACE_EXIT, "%s", __func__); + return FALSE; + } + + + osync_trace(TRACE_EXIT, "%s", __func__); + return FALSE; + +error: + if (!osync_error_is_set(&error)) + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); + + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); + return FALSE; +} + + + + +/** + * @brief This function checks whether a byte sequence contains an + * ldap-event format. + * + * @param data The byte sequence to be checked. + * @param size The length of the byte sequence. + * @param userdata ??????????????? + * + * @returns TRUE if the byte sequence is of the ldap-event format. + * FALSE if not, and in case of any errors. + * + */ + +osync_bool ldap_format_detect_plain_as_ldap_event(const char *data, int size, void *userdata) +{ + OSyncError *error = NULL; + + + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, data, size, userdata); + + + if (data == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: data = NULL."); + goto error; + } + + + if (ldap_format_do_detect_plain_as_ldap_format(data, size, "ldap-event", "<ldap-event>", "</ldap-event>", userdata, &error)) { +#ifdef DEBUG_detection + ldap_plugin_printf("%s:%i: It IS an ldap-event format.\n", __FILE__, __LINE__); +#endif + + if (osync_error_is_set(&error)) { + goto error; + } + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; + + } else { +#ifdef DEBUG_detection + osync_trace(TRACE_INTERNAL, "%s:%i: It is NOT an ldap-event format.\n", __FILE__, __LINE__); +#endif + + if (osync_error_is_set(&error)) { + goto error; + } + + osync_trace(TRACE_EXIT, "%s", __func__); + return FALSE; + } + + + osync_trace(TRACE_EXIT, "%s", __func__); + return FALSE; + +error: + if (!osync_error_is_set(&error)) + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); + + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); + return FALSE; +} + + + +/** + * @brief This function checks whether a byte sequence contains an + * ldap-todo format. + * + * @param data The byte sequence to be checked. + * @param size The length of the byte sequence. + * @param userdata ??????????????? + * + * @returns TRUE if the byte sequence is of the ldap-todo format. + * FALSE if not, and in case of any errors. + * + */ + +osync_bool ldap_format_detect_plain_as_ldap_todo(const char *data, int size, void *userdata) +{ + OSyncError *error = NULL; + + + + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, data, size, userdata); + + + if (data == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: data = NULL."); + goto error; + } + + + + if (ldap_format_do_detect_plain_as_ldap_format(data, size, "ldap-todo", "<ldap-todo>", "</ldap-todo>", userdata, &error)) { +#ifdef DEBUG_detection + ldap_plugin_printf("%s:%i: It IS an ldap-todo format.\n", __FILE__, __LINE__); +#endif + + if (osync_error_is_set(&error)) { + goto error; + } + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; + + } else { +#ifdef DEBUG_detection + osync_trace(TRACE_INTERNAL, "%s:%i: It is NOT an ldap-todo.\n", __FILE__, __LINE__); +#endif + + if (osync_error_is_set(&error)) { + goto error; + } + + osync_trace(TRACE_EXIT, "%s", __func__); + return FALSE; + } + + + + osync_trace(TRACE_EXIT, "%s", __func__); + return FALSE; + +error: + if (!osync_error_is_set(&error)) + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); + + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); + return FALSE; +} + + + + + + +/** + * @brief This function checks whether a byte sequence contains an + * ldap-note format. + * + * @param data The byte sequence to be checked. + * @param size The length of the byte sequence. + * @param userdata ??????????????? + * + * @returns TRUE if the byte sequence is of the ldap-note format. + * FALSE if not, and in case of any errors. + * + */ + +osync_bool ldap_format_detect_plain_as_ldap_note(const char *data, int size, void *userdata) +{ + OSyncError *error = NULL; + + + + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, data, size, userdata); + + if (data == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: data = NULL."); + goto error; + } + + + if (ldap_format_do_detect_plain_as_ldap_format(data, size, "ldap-note", "<ldap-note>", "</ldap-note>", userdata, &error)) { +#ifdef DEBUG_detection + ldap_plugin_printf("%s:%i: It IS an ldap-note format.\n", __FILE__, __LINE__); +#endif + + if (osync_error_is_set(&error)) { + goto error; + } + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; + + } else { +#ifdef DEBUG_detection + osync_trace(TRACE_INTERNAL, "%s:%i: It is NOT an ldap-note format.\n", __FILE__, __LINE__); +#endif + + if (osync_error_is_set(&error)) { + goto error; + } + + osync_trace(TRACE_EXIT, "%s", __func__); + return FALSE; + } + + + osync_trace(TRACE_EXIT, "%s", __func__); + return FALSE; + +error: + if (!osync_error_is_set(&error)) + osync_error_set(&error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); + + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); + return FALSE; +} + + + + + + +/** + * @brief Main function to set up the different functions required + * for converting from and to the ldap related formats + * offered by this plugin. + * @param env The format environment. + * @param error libopensync error pointer. + * @returns TRUE on success, FALSE on error + */ +osync_bool get_format_info(OSyncFormatEnv *env, OSyncError **error) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, env, error); + + + + OSyncObjFormat *contact1_format = osync_objformat_new(FORMAT_LDAP_EVOLUTIONPERSON, OBJECTTYPE_CONTACT, error); + + OSyncObjFormat *contact2_format = osync_objformat_new(FORMAT_LDAP_INETORGPERSON, OBJECTTYPE_CONTACT, error); + + OSyncObjFormat *event_format = osync_objformat_new(FORMAT_LDAP_EVENT, OBJECTTYPE_EVENT, error); + + OSyncObjFormat *todo_format = osync_objformat_new(FORMAT_LDAP_TODO, OBJECTTYPE_TODO, error); + + OSyncObjFormat *note_format = osync_objformat_new(FORMAT_LDAP_NOTE, OBJECTTYPE_NOTE, error); + + + + if (!contact1_format) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: contact_format = NULL.\n", __FILE__, __LINE__); + goto error; + } + + if (!event_format) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: event_format = NULL.\n", __FILE__, __LINE__); + goto error; + } + + if (!todo_format) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: todo_format = NULL.\n", __FILE__, __LINE__); + goto error; + } + + if (!note_format) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: note_format = NULL.\n", __FILE__, __LINE__); + goto error; + } + + + + osync_objformat_set_compare_func(contact1_format, ldap_format_compare_format1); + osync_objformat_set_destroy_func(contact1_format, ldap_format_destroy_format1); + osync_objformat_set_duplicate_func(contact1_format, ldap_format_duplicate_format1); + osync_objformat_set_print_func(contact1_format, ldap_format_print_format1); + osync_objformat_set_validate_func(contact1_format, ldap_format_validate); + + + + osync_objformat_set_compare_func(contact2_format, ldap_format_compare_format1); + osync_objformat_set_destroy_func(contact2_format, ldap_format_destroy_format1); + osync_objformat_set_duplicate_func(contact2_format, ldap_format_duplicate_format1); + osync_objformat_set_print_func(contact2_format, ldap_format_print_format1); + osync_objformat_set_validate_func(contact2_format, ldap_format_validate); + + + osync_objformat_set_compare_func(event_format, ldap_format_compare_format1); + osync_objformat_set_destroy_func(event_format, ldap_format_destroy_format1); + osync_objformat_set_duplicate_func(event_format, ldap_format_duplicate_format1); + osync_objformat_set_print_func(event_format, ldap_format_print_format1); + osync_objformat_set_validate_func(event_format, ldap_format_validate); + + + osync_objformat_set_compare_func(todo_format, ldap_format_compare_format1); + osync_objformat_set_destroy_func(todo_format, ldap_format_destroy_format1); + osync_objformat_set_duplicate_func(todo_format, ldap_format_duplicate_format1); + osync_objformat_set_print_func(todo_format, ldap_format_print_format1); + osync_objformat_set_validate_func(todo_format, ldap_format_validate); + + + osync_objformat_set_compare_func(note_format, ldap_format_compare_format1); + osync_objformat_set_destroy_func(note_format, ldap_format_destroy_format1); + osync_objformat_set_duplicate_func(note_format, ldap_format_duplicate_format1); + osync_objformat_set_print_func(note_format, ldap_format_print_format1); + osync_objformat_set_validate_func(note_format, ldap_format_validate); + + + + + osync_format_env_register_objformat(env, contact1_format); + osync_format_env_register_objformat(env, contact2_format); + osync_format_env_register_objformat(env, event_format); + osync_format_env_register_objformat(env, todo_format); + osync_format_env_register_objformat(env, note_format); + + + osync_objformat_unref(contact1_format); + osync_objformat_unref(contact2_format); + osync_objformat_unref(event_format); + osync_objformat_unref(todo_format); + osync_objformat_unref(note_format); + + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; + +error: + if (!osync_error_is_set(error)) + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); + + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; +} + + + + + +/** + * @brief Helper function for setting up the converter functions. + * + * @param env Format specific environment. + * @param format_name Name of the first format. + * @param other_format_name of the second format. + * @param objtype Object type, such as "contact", "event", "todo", "note". + * @param converter1 Function pointer to a converter function. + * @param converter2 Function pointer to a converter function for the opposite direction. + * @param detector_function Function pointer to a detector function. + * @param error libopensync error pointer. + * + * @returns TRUE on success, FALSE on failure. + */ + +static osync_bool ldap_format_do_get_conversion_info(OSyncFormatEnv *env, const char *format_name, const char *other_format_name, const char *objtype, OSyncFormatConvertFunc converter1, OSyncFormatConvertFunc converter2, OSyncFormatDetectFunc detector_function, OSyncError **error) +{ + OSyncFormatConverter *conv = NULL; + OSyncObjFormat *plain = NULL; + OSyncObjFormat *format1 = NULL; + + + + + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p, %p, %p, %p)", __func__, env, format_name, other_format_name, objtype, converter1, converter2, detector_function, error); + + + if (env == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: env = NULL.\n", __FILE__, __LINE__); + goto error; + } + + if (format_name == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: format_name = NULL.\n", __FILE__, __LINE__); + goto error; + } + + if (other_format_name == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: other_format_name = NULL.\n", __FILE__, __LINE__); + goto error; + } + + if (format_name == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: format_name = NULL.\n", __FILE__, __LINE__); + goto error; + } + + if (objtype == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: objtype = NULL.\n", __FILE__, __LINE__); + goto error; + } + + + + format1 = osync_format_env_find_objformat(env, format_name); + if (!format1) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to find \"%s\" format", __FILE__, __LINE__, format_name); + goto error; + } + + + + if (detector_function) { + osync_trace(TRACE_INTERNAL, "%s:%i: Setting detector_function for format \"%s\" against \"plain\". detector_function = %p.", __FILE__, __LINE__, format_name, detector_function); + + plain = osync_format_env_find_objformat(env, "plain"); + if (!plain) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to find \"plain\" format", __FILE__, __LINE__); + goto error; + } + + conv = osync_converter_new_detector(plain, format1, detector_function, error); + + if (!conv) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Could not set detector_function for the \"%s\" format", __FILE__, __LINE__, format_name); + goto error; + } + +#ifdef ENABLE_DETECTOR_FUNCTIONS + osync_format_env_register_converter(env, conv); +#endif + + osync_converter_unref(conv); + } OSyncObjFormat *format2 = osync_format_env_find_objformat(env, other_format_name); if (!format2) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find \"%s\" format", other_format_name); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to find \"%s\" format", __FILE__, __LINE__, other_format_name); goto error; } if (converter1 == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find converter1 function."); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to find converter1 function.", __FILE__, __LINE__); goto error; } if (converter2 == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find converter2 function."); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to find converter2 function.", __FILE__, __LINE__); goto error; } @@ -6183,7 +7017,7 @@ // Converter functions: - OSyncFormatConverter *conv = osync_converter_new(OSYNC_CONVERTER_CONV, format1, format2, converter1, error); + conv = osync_converter_new(OSYNC_CONVERTER_CONV, format1, format2, converter1, error); if (!conv) { if (!osync_error_is_set(error)) @@ -6268,6 +7102,7 @@ OBJECTTYPE_CONTACT, ldap_format_conv_ldap_evolutionperson_to_xmlformat_contact, ldap_format_conv_xmlformat_contact_to_ldap_evolution_person, + ldap_format_detect_plain_as_ldap_evolutionperson, error) ) { @@ -6296,6 +7131,7 @@ OBJECTTYPE_CONTACT, ldap_format_conv_ldap_inetorgperson_to_xmlformat_contact, ldap_format_conv_xmlformat_contact_to_ldap_inetorg_person, + ldap_format_detect_plain_as_ldap_inetorgperson, error) ) { @@ -6330,6 +7166,7 @@ OBJECTTYPE_EVENT, ldap_format_conv_ldap_event_to_xmlformat_event, ldap_format_conv_xmlformat_event_to_ldap_event, + ldap_format_detect_plain_as_ldap_event, error) ) { @@ -6356,6 +7193,7 @@ OBJECTTYPE_TODO, ldap_format_conv_ldap_todo_to_xmlformat_todo, ldap_format_conv_xmlformat_todo_to_ldap_todo, + ldap_format_detect_plain_as_ldap_todo, error) ) { @@ -6384,6 +7222,7 @@ OBJECTTYPE_NOTE, ldap_format_conv_ldap_note_to_xmlformat_note, ldap_format_conv_xmlformat_note_to_ldap_note, + ldap_format_detect_plain_as_ldap_note, error) ) { Modified: plugins/ldap-sync/src/ldap_format.h ============================================================================== --- plugins/ldap-sync/src/ldap_format.h Sat Apr 11 20:29:13 2009 (r5578) +++ plugins/ldap-sync/src/ldap_format.h Sat Apr 11 20:29:35 2009 (r5579) @@ -51,6 +51,7 @@ static int ldap_format_avoid_duplicate_attribute(GList *ldapmods, const char *name); static osync_bool ldap_format_check_adequate_stylesheet(xmlNode *root_element, const char *stylesheet_file, OSyncError **error); static osync_bool ldap_format_check_root_element(const xmlDoc *xmldata, const char *objtype, const char *ldap_format_name, const gchar *dn, xmlNode **root, OSyncError **error); +osync_bool ldap_format_check_xml(const char *data, int size, OSyncError **error); static OSyncConvCmpResult ldap_format_compare_format1(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *user_data); static osync_bool ldap_format_conv_ldap_event_to_xmlformat_event(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error); static osync_bool ldap_format_conv_ldap_evolutionperson_to_xmlformat_contact(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error); @@ -63,9 +64,16 @@ static osync_bool ldap_format_convert_xmlinternal2ldap (const xmlDoc *xmldata, const char *objtype, const char *ldap_format_name, const gchar *dn, GList **potential_subentries, GList **ldap_entries, OSyncError **error); static osync_bool ldap_format_create_ldap_entries_list_from_ldapmods(const char *dn, GList *ldapmods, GList **potential_subentries, GList **ldap_entries, OSyncError **error); static ldap_entry *ldap_format_create_ldap_entry_from_ldapmods(GList *ldapmods); + +osync_bool ldap_format_detect_plain_as_ldap_evolutionperson(const char *data, int size, void *userdata); +osync_bool ldap_format_detect_plain_as_ldap_inetorgperson(const char *data, int size, void *userdata); +osync_bool ldap_format_detect_plain_as_ldap_event(const char *data, int size, void *userdata); +osync_bool ldap_format_detect_plain_as_ldap_todo(const char *data, int size, void *userdata); +osync_bool ldap_format_detect_plain_as_ldap_note(const char *data, int size, void *userdata); static osync_bool ldap_format_do_apply_stylesheet(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, const char *config, void *userdata, const char *stylesheet_file, OSyncError **error); static osync_bool ldap_format_do_conv_ldap_to_xmlformat(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *ldap_format_name, const char *xmlformat_name, const char *stylesheet_name, const char *objtype, const char *config, void *userdata, OSyncError **error); static osync_bool ldap_format_do_conv_xmlformat_to_ldap(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *xmlformat_name, const char *ldap_format_name, const char *stylesheet_name, const char *objtype, const char *config, void *userdata, OSyncError **error); +osync_bool ldap_format_do_detect_plain_as_ldap_format(const char *data, const int size, const char *format_name, const char *opening_tag, const char *closing_tag, const void *userdata, OSyncError **error); void ldap_format_free_complex_element_lists(GList **list); static void ldap_format_free_ldap_entry (ldap_entry *entry); static void ldap_format_free_ldap_entries (GList **entrylist); |
From: <svn...@op...> - 2009-04-11 18:29:23
|
Author: scriptor Date: Sat Apr 11 20:29:13 2009 New Revision: 5578 URL: http://www.opensync.org/changeset/5578 Log: Added a "const". Modified: plugins/ldap-sync/src/ldap_debug.c Modified: plugins/ldap-sync/src/ldap_debug.c ============================================================================== --- plugins/ldap-sync/src/ldap_debug.c Sat Apr 11 20:29:02 2009 (r5577) +++ plugins/ldap-sync/src/ldap_debug.c Sat Apr 11 20:29:13 2009 (r5578) @@ -204,7 +204,7 @@ * @returns TRUE on success, FALSE in case of any error. */ -osync_bool ldap_plugin_get_glist(char *unknown, GList **list, OSyncError **error) +osync_bool ldap_plugin_get_glist(const char *unknown, GList **list, OSyncError **error) { glist_container *container = NULL; |
From: <svn...@op...> - 2009-04-11 18:29:06
|
Author: scriptor Date: Sat Apr 11 20:29:02 2009 New Revision: 5577 URL: http://www.opensync.org/changeset/5577 Log: Fixed some error messages. The glist_container struct has a new member: format_name. To be used in the detector functions of the format plugin. Modified: plugins/ldap-sync/src/ldap_plugin.c Modified: plugins/ldap-sync/src/ldap_plugin.c ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.c Sat Apr 11 20:28:51 2009 (r5576) +++ plugins/ldap-sync/src/ldap_plugin.c Sat Apr 11 20:29:02 2009 (r5577) @@ -251,22 +251,22 @@ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p)", __func__, ctx, sink, userdata, sinkenv, error); if (ctx == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "ERROR: ctx = NULL.", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: ctx = NULL.", __FILE__, __LINE__); goto error; } if (sink == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "ERROR: sink = NULL.", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sink = NULL.", __FILE__, __LINE__); goto error; } if (userdata == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "ERROR: userdata = NULL.", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: userdata = NULL.", __FILE__, __LINE__); goto error; } if (sinkenv == NULL) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "ERROR: sinkenv = NULL.", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sinkenv = NULL.", __FILE__, __LINE__); goto error; } @@ -1248,7 +1248,9 @@ /** * @brief This function formally reports a single change that is to be performed - * by any peer to the libopensync framework. + * by any peer to the libopensync framework. This is one of two + * locations in the LDAP plugin where a glist_container is generated. + * See also ldap_format_do_conv_xmlformat_to_ldap() in ldap_format.c. * * * @param ctx The libopensync context. @@ -1453,6 +1455,7 @@ } to_be_reported->magic = "glist_container"; + to_be_reported->format_name = osync_objformat_get_name(format_type); to_be_reported->list = list_to_be_reported; char *ptr = (char *)to_be_reported; ptr[sizeof(glist_container)] = 0; |
From: <svn...@op...> - 2009-04-11 18:28:56
|
Author: scriptor Date: Sat Apr 11 20:28:51 2009 New Revision: 5576 URL: http://www.opensync.org/changeset/5576 Log: Added detector functions for the LDAP specific formats. It does not matter whether the input data is in form of a human readable XML document (that is a real string), or in form of a glist_container struct (used by the LDAP plugin). Even an OSyncXMLFormat could theoretically be analyzed, but currently it is commented out (depending of HANDLE_OSYNC_XMLFORMAT in ldap_plugin.h), because of bugs in libopensync: Whenever the detector functions face an OSyncXMLFormat, it seems to be an invalid struct which causes memory faults. This is probably linked to the issue, that I have faced for quite some time now: The libopensync framework calls the converter functions of the LDAP format plugin with wrong kinds of data. For example, for an "xmlformat-event" libopensync calls the converter function for converting from "ldap-event" to "xmlformat-event". Which is right the opposite and therefore wrong direction. If HANDLE_OSYNC_XMLFORMAT is defined, then this problem has a different face: A probably invalid OSyncXMLformat struct is passed, leading to SigSegV in osync_xmlformat_assemble(). For debugging purposes the registration of the detector functions can be commented out by undefining ENABLE_DETECTOR_FUNCTIONS in ldap_plugin.h. And CALL_ABORT will lead to an abort, whenever an OSyncXMLFormat() is provided to the detector functions. Also fixed some error messages in ldap_format.c. Modified: plugins/ldap-sync/src/ldap_plugin.h Modified: plugins/ldap-sync/src/ldap_plugin.h ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.h Sat Apr 11 20:28:25 2009 (r5575) +++ plugins/ldap-sync/src/ldap_plugin.h Sat Apr 11 20:28:51 2009 (r5576) @@ -104,8 +104,17 @@ ///< conditions in libopensync. So they are almost ///< scheduled for debugging. +#define ENABLE_DETECTOR_FUNCTIONS 1 ///< Let the detector functions register + ///< and thus take into effect. + +// define HANDLE_OSYNC_XMLFORMAT 1 ///< Include some lines about trying to detect + ///< what kind of format is inside an + ///< OSyncXMLFormat in + ///< ldap_format_do_detect_plain_as_ldap_format(). + #define DEBUG_auth 1 #define DEBUG_configuration 1 +#define DEBUG_detection 1 #define DEBUG_ldapdata_from_server 1 #define DEBUG_convert_ldap2xmlinternal 1 #define DEBUG_do_apply_stylesheet 1 @@ -124,6 +133,7 @@ #undef DEBUG_auth #undef DEBUG_configuration +#undef DEBUG_detection #undef DEBUG_ldapdata_from_server #undef DEBUG_convert_ldap2xmlinternal #undef DEBUG_do_apply_stylesheet @@ -271,6 +281,14 @@ const char *magic; ///< Here is stored the name of the struct, in ///< order to make it recognizable when passed ///< as a char * pointer. + const char *format_name; ///< This is the name of the LDAP specific + ///< format, like "ldap-evolutionperson" or + ///< "ldap-note". This variable is necessary, + ///< because the detector functions do not + ///< have any other possibility to recognize + ///< the format: For the object types event, + ///< todo and note the LDAP objectClass is + ///< is always "document". GList *list; ///< This is the GList that holds various ///< ldap_entry structs. } glist_container; @@ -468,7 +486,7 @@ void ldap_plugin_free_env(plugin_environment *env); void ldap_plugin_get_changes(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, osync_bool slow_sync_requested, void *userdata); osync_bool ldap_plugin_get_ldap_entries_from_change(OSyncContext *ctx, OSyncChange *change, sink_environment *sinkenv, GList **ldap_entries, OSyncError **error); -osync_bool ldap_plugin_get_glist(char *unknown, GList **list, OSyncError **error); +osync_bool ldap_plugin_get_glist(const char *unknown, GList **list, OSyncError **error); void *ldap_plugin_initialize(OSyncPlugin *plugin, OSyncPluginInfo *info, OSyncError **error); osync_bool ldap_plugin_initialize_anchor(sink_environment *sinkenv, OSyncError **error); int ldap_plugin_initialize_format(OSyncPluginInfo *info, sink_environment *sinkenv, OSyncPluginConfig *configdata, const char *objtype, const char *format, OSyncError **error); |
From: <svn...@op...> - 2009-04-11 18:28:38
|
Author: scriptor Date: Sat Apr 11 20:28:25 2009 New Revision: 5575 URL: http://www.opensync.org/changeset/5575 Log: Some remarks about RUN_LONG_TESTS. These are tests that run under valgrind. Therefore they can take quite some time. Timeouts for those tests can be set in CTestConfig.cmake and in tests/CMakeLists.txt. Modified: plugins/ldap-sync/INSTALL plugins/ldap-sync/README.lyx Modified: plugins/ldap-sync/INSTALL ============================================================================== --- plugins/ldap-sync/INSTALL Sat Apr 11 20:28:16 2009 (r5574) +++ plugins/ldap-sync/INSTALL Sat Apr 11 20:28:25 2009 (r5575) @@ -78,10 +78,33 @@ II. Running the tests: -cd build +mkdir build_debug +cd build_debug + +PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DUPDATE_TYPE=svn -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON -DRUN_LONG_TESTS=off /home/user1/libopensync-0.39/libopensync-plugin-ldap-0.39 + +or: + +PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DUPDATE_TYPE=svn -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON -DRUN_LONG_TESTS=on /home/user1/libopensync-0.39/libopensync-plugin-ldap-0.39 + +make make test +Tests with valgrind take quite some time: They are run only when cmake +is run with "-DRUN_LONG_TESTS=on". + +reset; time make test +(...) +100% tests passed, 0 tests failed out of 162 + +real 277m22.568s +user 217m33.966s +sys 24m59.372s + + + + III. Display a list of tests: cd build Modified: plugins/ldap-sync/README.lyx ============================================================================== --- plugins/ldap-sync/README.lyx Sat Apr 11 20:28:16 2009 (r5574) +++ plugins/ldap-sync/README.lyx Sat Apr 11 20:28:25 2009 (r5575) @@ -278,13 +278,74 @@ \end_layout \begin_layout LyX-Code -cd build +mkdir build_debug +\end_layout + +\begin_layout LyX-Code +cd build_debug +\end_layout + +\begin_layout LyX-Code +PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" cmake -DCMAKE_INSTALL_PREFIX=/usr/lo +cal -DUPDATE_TYPE=svn -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON + -DRUN_LONG_TESTS=off /home/user1/libopensync-0.39/libopensync-plugin-ldap-0.39 +\end_layout + +\begin_layout Standard +or: +\end_layout + +\begin_layout LyX-Code +PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" cmake -DCMAKE_INSTALL_PREFIX=/usr/lo +cal -DUPDATE_TYPE=svn -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON + -DRUN_LONG_TESTS=on /home/user1/libopensync-0.39/libopensync-plugin-ldap-0.39 +\end_layout + +\begin_layout Standard +and then: +\end_layout + +\begin_layout LyX-Code +make \end_layout \begin_layout LyX-Code make test \end_layout +\begin_layout Standard +Tests with valgrind take quite some time: They are run only when cmake is + run with "-DRUN_LONG_TESTS=on". +\end_layout + +\begin_layout LyX-Code +reset; time make test +\end_layout + +\begin_layout LyX-Code +(...) +\end_layout + +\begin_layout LyX-Code +100% tests passed, 0 tests failed out of 162 +\end_layout + +\begin_layout LyX-Code +real 277m22.568s +\end_layout + +\begin_layout LyX-Code +user 217m33.966s +\end_layout + +\begin_layout LyX-Code +sys 24m59.372s +\end_layout + +\begin_layout LyX-Code + +\end_layout + \begin_layout Subsection Display a list of tests \end_layout |
From: <svn...@op...> - 2009-04-11 18:28:22
|
Author: scriptor Date: Sat Apr 11 20:28:16 2009 New Revision: 5574 URL: http://www.opensync.org/changeset/5574 Log: Commented out debug output. Modified: plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_ldifs_and_sync plugins/ldap-sync/tests/check_osynctool_common.inc Modified: plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_ldifs_and_sync ============================================================================== --- plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_ldifs_and_sync Sat Apr 11 20:28:01 2009 (r5573) +++ plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_ldifs_and_sync Sat Apr 11 20:28:16 2009 (r5574) @@ -1,6 +1,6 @@ #!/bin/bash -set -x +# set -x FILE=$0 test_name="$1" Modified: plugins/ldap-sync/tests/check_osynctool_common.inc ============================================================================== --- plugins/ldap-sync/tests/check_osynctool_common.inc Sat Apr 11 20:28:01 2009 (r5573) +++ plugins/ldap-sync/tests/check_osynctool_common.inc Sat Apr 11 20:28:16 2009 (r5574) @@ -36,8 +36,8 @@ rm -f ${syncml_trace_dir}${PATH_SEPARATOR}Thread* fi - a=$(ls -alR $osync_trace_dir) - echo -e "$a" + # a=$(ls -alR $osync_trace_dir) + # echo -e "$a" echo -e "\n\n\n${FUNCNAME}(): Enabling trace files (OSYNC_TRACE and SYNCML_TRACE) for \"${test_name}\":\n$osync_trace_dir\n$syncml_trace_dir\n\n\n" @@ -113,8 +113,8 @@ - a=$(ls -alR ${osync_trace_dir}) - echo -e "$a" + # a=$(ls -alR ${osync_trace_dir}) + # echo -e "$a" @@ -1042,8 +1042,8 @@ rm -f ${CONTACT2_FILE}* fi - output=$(ls -al /tmp/file_contact) - echo -e "$output\n" + # output=$(ls -al /tmp/file_contact) + # echo -e "$output\n" } @@ -1055,8 +1055,8 @@ rm -f ${EVENT1_FILE}* fi - output=$(ls -al /tmp/file_event) - echo -e "$output\n" + # output=$(ls -al /tmp/file_event) + # echo -e "$output\n" } @@ -1068,8 +1068,8 @@ rm -f ${TODO1_FILE}* fi - output=$(ls -al /tmp/file_todo) - echo -e "$output\n" + # output=$(ls -al /tmp/file_todo) + # echo -e "$output\n" } @@ -1087,8 +1087,8 @@ rm -f ${NOTE2_FILE}* fi - output=$(ls -al /tmp/file_note) - echo -e "$output\n" + # output=$(ls -al /tmp/file_note) + # echo -e "$output\n" } |
From: <svn...@op...> - 2009-04-11 18:28:10
|
Author: scriptor Date: Sat Apr 11 20:28:01 2009 New Revision: 5573 URL: http://www.opensync.org/changeset/5573 Log: Added some tests about the detector functions. Added: plugins/ldap-sync/tests/check_convert_from_to (contents, props changed) plugins/ldap-sync/tests/check_detector1.c plugins/ldap-sync/tests/check_do_convert_from_to.c plugins/ldap-sync/tests/vcards/ plugins/ldap-sync/tests/vcards/README plugins/ldap-sync/tests/vcards/evo2-full1.vcf plugins/ldap-sync/tests/vcards/evo2-full2.vcf plugins/ldap-sync/tests/vcards/evo2-multiline.vcf plugins/ldap-sync/tests/vcards/evo2-photo.vcf plugins/ldap-sync/tests/vcards/evo2-special.vcf plugins/ldap-sync/tests/vcards/evo2-umlaute.vcf plugins/ldap-sync/tests/vcards/kdepim-full1-2.1.vcf plugins/ldap-sync/tests/vcards/kdepim-full1-3.0.vcf plugins/ldap-sync/tests/vcards/kdepim-full2-2.1.vcf plugins/ldap-sync/tests/vcards/kdepim-full2-3.0.vcf plugins/ldap-sync/tests/vcards/kdepim-multiline-2.1.vcf plugins/ldap-sync/tests/vcards/kdepim-multiline-3.0.vcf plugins/ldap-sync/tests/vcards/kdepim-nonuid-2.1.vcf plugins/ldap-sync/tests/vcards/kdepim-photo1-2.1.vcf plugins/ldap-sync/tests/vcards/kdepim-photo1-3.0.vcf plugins/ldap-sync/tests/vcards/kdepim-photo2-2.1.vcf plugins/ldap-sync/tests/vcards/kdepim-photo2-3.0.vcf plugins/ldap-sync/tests/vcards/kdepim-sound1-2.1.vcf plugins/ldap-sync/tests/vcards/kdepim-sound1-3.0.vcf plugins/ldap-sync/tests/vcards/kdepim-sound2-2.1.vcf plugins/ldap-sync/tests/vcards/kdepim-sound2-3.0.vcf plugins/ldap-sync/tests/vcards/kdepim-special-2.1.vcf plugins/ldap-sync/tests/vcards/kdepim-special-3.0.vcf plugins/ldap-sync/tests/vcards/kdepim-umlaute-2.1.vcf plugins/ldap-sync/tests/vcards/kdepim-umlaute-3.0.vcf plugins/ldap-sync/tests/vevents/ plugins/ldap-sync/tests/vevents/README plugins/ldap-sync/tests/vevents/evolution2-1-hour-alarm.vcf plugins/ldap-sync/tests/vevents/evolution2-1-hour-alarm2.vcf plugins/ldap-sync/tests/vevents/evolution2-1-hour.vcf plugins/ldap-sync/tests/vevents/evolution2-all-day.vcf plugins/ldap-sync/tests/vevents/evolution2-all-day2.vcf plugins/ldap-sync/tests/vevents/evolution2-evo2-recur-until.vcf plugins/ldap-sync/tests/vevents/evolution2-free-busy.vcf plugins/ldap-sync/tests/vevents/evolution2-full-special.vcf plugins/ldap-sync/tests/vevents/evolution2-rec-every-year.vcf plugins/ldap-sync/tests/vevents/evolution2-rec-except.vcf plugins/ldap-sync/tests/vevents/evolution2-rec-for.vcf plugins/ldap-sync/tests/vevents/evolution2-rec-forever.vcf plugins/ldap-sync/tests/vevents/evolution2-rec-until.vcf plugins/ldap-sync/tests/vevents/kdepim-1-hour-1.0.vcs plugins/ldap-sync/tests/vevents/kdepim-1-hour-2.0.ics plugins/ldap-sync/tests/vnotes/ plugins/ldap-sync/tests/vnotes/README plugins/ldap-sync/tests/vnotes/vnote-minimal.vnt plugins/ldap-sync/tests/vnotes/vnote1-same.vnt plugins/ldap-sync/tests/vnotes/vnote1-similar.vnt plugins/ldap-sync/tests/vnotes/vnote1.vnt plugins/ldap-sync/tests/vnotes/vnote2.vnt plugins/ldap-sync/tests/vnotes/vnote3.vnt plugins/ldap-sync/tests/vtodos/ plugins/ldap-sync/tests/vtodos/README plugins/ldap-sync/tests/vtodos/evolution2-todo-full1.vcf plugins/ldap-sync/tests/vtodos/evolution2-todo-full2.vcf plugins/ldap-sync/tests/vtodos/evolution2-todo-full3.vcf plugins/ldap-sync/tests/vtodos/evolution2-todo-full4.vcf plugins/ldap-sync/tests/vtodos/evolution2-todo-full5.vcf plugins/ldap-sync/tests/vtodos/evolution2-todo-full6.vcf plugins/ldap-sync/tests/vtodos/evolution2-todo-full7.vcf plugins/ldap-sync/tests/vtodos/evolution2-todo-simple.vcf plugins/ldap-sync/tests/vtodos/kdepim-todoful1.vcs plugins/ldap-sync/tests/xmlformats/ plugins/ldap-sync/tests/xmlformats/README plugins/ldap-sync/tests/xmlformats/contact.xml plugins/ldap-sync/tests/xmlformats/contact1.xml plugins/ldap-sync/tests/xmlformats/contact2.xml plugins/ldap-sync/tests/xmlformats/contact3.xml plugins/ldap-sync/tests/xmlformats/contact3_unique.xml plugins/ldap-sync/tests/xmlformats/contact4.xml plugins/ldap-sync/tests/xmlformats/contact4_unique.xml plugins/ldap-sync/tests/xmlformats/event.xml Modified: plugins/ldap-sync/tests/CMakeLists.txt Modified: plugins/ldap-sync/tests/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/tests/CMakeLists.txt Sat Apr 11 20:27:17 2009 (r5572) +++ plugins/ldap-sync/tests/CMakeLists.txt Sat Apr 11 20:28:01 2009 (r5573) @@ -4,7 +4,7 @@ # So I have simply commented out those tests, where some data is missing # or where the errors are known to me. -OPTION ( RUN_LONG_TESTS "Should the tests with osynctool running under valgrind be run? They take quite some time.") +OPTION ( RUN_LONG_TESTS "Should the tests with osynctool running under valgrind be run? They take quite some time." off) SET ( TESTDIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE STRING "Path where the test scripts are located.") SET ( XSLDIR "${CMAKE_SOURCE_DIR}/src/xslt" CACHE STRING "Path where the stylesheeets are located.") @@ -284,6 +284,56 @@ ADD_TEST( plugin4 ${TESTDIR}/check_osynctool_file1 "plugin4" ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ) + +############################################### +# Check the detector functions: +ADD_EXECUTABLE( check_detector1 check_detector1.c ) + +LINK_DIRECTORIES( ${OPENSYNC_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} ${LIBXML2_LIBRARY_DIRS} ${LIBXSLT_LIBRARY_DIRS} ) +INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${OPENSYNC_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIRS} ${LIBXSLT_INCLUDE_DIRS} ) +TARGET_LINK_LIBRARIES( check_detector1 ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ${LIBXML2_LIBRARY_DIRS} ${LIBXSLT_LIBRARIES} ) + +ADD_TEST( detect1 check_detector1 ${TESTDIR}/contact1.xml ) + +ADD_TEST( detect2 check_detector1 ${TESTDIR}/contact2.xml ) + +ADD_TEST( detect3 check_detector1 ${TESTDIR}/event1.xml ) + +ADD_TEST( detect4 check_detector1 ${TESTDIR}/todo1.xml ) + +ADD_TEST( detect5 check_detector1 ${TESTDIR}/note1.xml ) + +ADD_TEST( detect6 check_detector1 ${TESTDIR}/note2.xml ) + +# This would be a "correct negative", if I may say so: +# We expect the script to fail. And this failing would be OK. +#ADD_TEST( false_result check_detector1 ${TESTDIR}/check_detector1.c ) + + + + + +######################################################### +# Check the converter functions: +ADD_EXECUTABLE( check_do_convert_from_to check_do_convert_from_to.c ) + +LINK_DIRECTORIES( ${OPENSYNC_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} ${LIBXML2_LIBRARY_DIRS} ${LIBXSLT_LIBRARY_DIRS} ) +INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${OPENSYNC_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIRS} ${LIBXSLT_INCLUDE_DIRS} ) +TARGET_LINK_LIBRARIES( check_do_convert_from_to ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ${LIBXML2_LIBRARY_DIRS} ${LIBXSLT_LIBRARIES} ) + +ADD_TEST( convert_vcards1 ${TESTDIR}/check_convert_from_to ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/tests/vcards/*.vcf" "--to-ldap-evolutionperson" ) +ADD_TEST( convert_vcards2 ${TESTDIR}/check_convert_from_to ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/tests/vcards/*.vcf" "--to-ldap-inetorgperson" ) +ADD_TEST( convert_vevents1 ${TESTDIR}/check_convert_from_to ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/tests/vevents/*.?c?" "--to-ldap-event" ) +ADD_TEST( convert_vtodos1 ${TESTDIR}/check_convert_from_to ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/tests/vtodos/*.vc?" "--to-ldap-todo" ) +ADD_TEST( convert_vnotes1 ${TESTDIR}/check_convert_from_to ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/tests/vnotes/*.vnt" "--to-ldap-note" ) +ADD_TEST( convert_xmlformat_contacts1 ${TESTDIR}/check_convert_from_to ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/tests/xmlformats/contact*.xml" "--to-ldap-evolutionperson" ) +ADD_TEST( convert_xmlformat_contacts2 ${TESTDIR}/check_convert_from_to ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/tests/xmlformats/contact*.xml" "--to-ldap-inetorgperson" ) +ADD_TEST( convert_xmlformat_event ${TESTDIR}/check_convert_from_to ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/tests/xmlformats/event*.xml" "--to-ldap-event" ) + + + + + ########################################################## # Interact with the LDAP server using external tools only... # This set of tests checks whether the LDAP server is sufficiently Added: plugins/ldap-sync/tests/check_convert_from_to ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_convert_from_to Sat Apr 11 20:28:01 2009 (r5573) @@ -0,0 +1,113 @@ +#!/bin/bash + +set -x + +FILE=$0 +PLUGINNAME="ldap-sync" +PLUGINPATH="$1/src" +BUILDDIR=$1 +SOURCEFORMAT_EXPRESSION="$3" +TARGETFORMAT="$4" + + + +if test -z "$SOURCEFORMAT_EXPRESSION"; then + echo "$FILE:$LINENO: ERROR: \$TARGETFORMAT is empty. Exiting." + exit 1; +fi + + +if test -z "$TARGETFORMAT"; then + echo "$FILE:$LINENO: ERROR: \$TARGETFORMAT is empty. Exiting." + exit 1; +fi + + + +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/check_osynctool_common.inc"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +CHECK_DO_CONVERT_FROM_TO=$(which check_do_convert_from_to 2> /dev/null) +if test -z "$CHECK_DO_CONVERT_FROM_TO"; then + if test -f "./check_do_convert_from_to"; then + CHECK_DO_CONVERT_FROM_TO="./check_do_convert_from_to" + else + dir=$(dirname $FILE) + if test -d "$dir"; then + if test -f "${dir}/check_do_convert_from_to"; then + CHECK_DO_CONVERT_FROM_TO="${dir}/check_do_convert_from_to" + else + if test -d "$BUILDDIR"; then + CHECK_DO_CONVERT_FROM_TO="${BUILDDIR}/tests/check_do_convert_from_to" + fi + fi + fi + fi +fi + + + +if test -z "$CHECK_DO_CONVERT_FROM_TO"; then + echo "$FILE:$LINENO: ERROR: \$CHECK_DO_CONVERT_FROM_TO is empty. Exiting." + exit 1; +fi + +if test ! -f "$CHECK_DO_CONVERT_FROM_TO"; then + echo "$FILE:$LINENO: ERROR: $CHECK_DO_CONVERT_FROM_TO could not be found. Exiting." + exit 1; +fi + +if test ! -x "$CHECK_DO_CONVERT_FROM_TO"; then + echo "$FILE:$LINENO: ERROR: $CHECK_DO_CONVERT_FROM_TO could be found, but is not executable. Exiting." + exit 1; +fi + + +source "$SOURCE_DIR/test.conf" +TMPDIR=`mktemp -d /tmp/ldap_sync_test.XXXXXX` || exit 1 +echo "TMPDIR = \"$TMPDIR\"" + + +echo -e "\n\n\nAbout to convert to $TARGETFORMAT:" +for f in $SOURCEFORMAT_EXPRESSION; do + echo "$f" +done +echo -e "\n\n\n" + + + +rv=1 +for f in $SOURCEFORMAT_EXPRESSION; do + $CHECK_DO_CONVERT_FROM_TO $f $TARGETFORMAT + rv=$? + if test $rv -ne 0; then + if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" + fi + exit 1 + fi +done + + + + + +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + +exit $rv + Added: plugins/ldap-sync/tests/check_detector1.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_detector1.c Sat Apr 11 20:28:01 2009 (r5573) @@ -0,0 +1,190 @@ +/* + * $Id: check_detector1.c 5382 2009-03-28 18:09:31Z scriptor $ + * + * ldap-sync - A plugin for the opensync framework + * + * Copyright (C) 2009 Juergen Leising <jle...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + + + +#include <errno.h> +#include <opensync/opensync.h> +#include <opensync/opensync-data.h> +#include <opensync/opensync-format.h> +#include <opensync/opensync-helper.h> +#include <opensync/opensync-plugin.h> +#include <stdio.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + + + +int usage(char *name); + + +int usage(char *name) +{ + if (name == NULL) { + name = (char *)__FILE__; + } + + fprintf (stderr, "Usage: %s <inputfile> <options>\n\n", name); + fprintf (stderr, "--help\t\tShow this help message\n"); + fprintf (stderr, "--out <file>\tStore the output into this file. Leaving out this option means, print it to stdout.\n"); + return 1; +} + + + +int main (int argc, char *argv[]) +{ + OSyncData *data = NULL; + OSyncError *error = NULL; + OSyncFormatEnv *format_env = NULL; + OSyncObjFormat *sourceformat = NULL; + OSyncFormatConverterPath *converter_path = NULL; + char *input_filename = NULL; + char *buffer = NULL; + struct stat stat_buffer; + unsigned int size; + + + + if (argc < 2) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Not enough arguments. You must state the name of the input file to be converted.", __FILE__, __LINE__); + goto error; + } + + + if (!strcmp(argv[0], "-h") || !strcmp(argv[0], "--help")) { + usage(argv[0]); + return 0; + } + + + + + input_filename = argv[1]; + + if (input_filename == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input_filename = NULL. input_filename has not been set.", __FILE__, __LINE__); + + goto error; + } + + errno = 0; + if (stat(input_filename, &stat_buffer)) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Could not load \"%s\": %s", __FILE__, __LINE__, input_filename, strerror(errno)); + goto error; + } + + + // Load the contents of the input file into buffer + if (!osync_file_read(input_filename, &buffer, &size, &error)) { + if (!osync_error_is_set(&error)) + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: osync_file_read() has failed.", __FILE__, __LINE__); + + goto error; + } + + // The size returned by osync_file_read() does NOT include the + // terminating 0. But we need a size that does include it. + size++; + + + // Allocate a new format environment + format_env = osync_format_env_new(&error); + if (format_env == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: format_env = NULL. ", __FILE__, __LINE__); + goto error; + } + + + // Let the format environment load all kinds of plugins + if (!osync_format_env_load_plugins(format_env, NULL, &error)) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Could not load any format plugin.", __FILE__, __LINE__); + goto error; + } + + + // Alloacate a format object specifically intended for the input file. + // At first, we create an OSyncData object with "plain" as sort of a + // general object format. Just to have something to begin with. + sourceformat = osync_format_env_find_objformat(format_env, "plain"); + if (sourceformat == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sourceformat = NULL. Objformat object could not be generated.", __FILE__, __LINE__); + goto error; + } + + + // Allocate a new data object with the contents of the input file + data = osync_data_new(buffer, size, sourceformat, &error); + if (data == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: data = NULL.", __FILE__, __LINE__); + goto error; + } + + + // Analyze the source format and redefine the format object. + sourceformat = osync_format_env_detect_objformat(format_env, data); + if (sourceformat == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sourceformat = NULL. Source format could NOT be recognized.", __FILE__, __LINE__); + goto error; + } + + + // Tell the data object what kind of source format we have just found. + osync_data_set_objformat(data, sourceformat); + if (osync_error_is_set(&error)) { + goto error; + } + + + + if (data) + osync_data_unref(data); + + if (converter_path) + osync_converter_path_unref(converter_path); + + if (format_env) + osync_format_env_unref(format_env); + + return 0; + + +error: + if (data) + osync_data_unref(data); + + if (converter_path) + osync_converter_path_unref(converter_path); + + if (format_env) + osync_format_env_unref(format_env); + + if (osync_error_is_set(&error)) { + fprintf(stderr, "%s\n", osync_error_print(&error)); + osync_error_unref(&error); + } + + return 1; +} Added: plugins/ldap-sync/tests/check_do_convert_from_to.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_do_convert_from_to.c Sat Apr 11 20:28:01 2009 (r5573) @@ -0,0 +1,933 @@ +/* + * $Id$ + * + * ldap-sync - A plugin for the opensync framework + * + * Copyright (C) 2009 Juergen Leising <jle...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + + + +#include <errno.h> +#include <opensync/opensync.h> +#include <opensync/opensync-data.h> +#include <opensync/opensync-format.h> +#include <opensync/opensync-helper.h> +#include <opensync/opensync-plugin.h> +#include <stdio.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +#undef DEBUG + + + + +typedef enum conv_detection { + TARGET_AUTO = 0, + TARGET_VCARD_21, + TARGET_VCARD_30, + TARGET_LDAP_EVOLUTIONPERSON, + TARGET_LDAP_INETORGPERSON, + TARGET_VEVENT_10, + TARGET_VEVENT_20, + TARGET_LDAP_EVENT, + TARGET_VTODO_10, + TARGET_VTODO_20, + TARGET_LDAP_TODO, + TARGET_VNOTE_11, + TARGET_VJOURNAL, + TARGET_LDAP_NOTE, + TARGET_XMLFORMAT +} conv_detection; + + + + +OSyncObjFormat *conv_run_detection(OSyncFormatEnv *env, const char *sfname, conv_detection type, OSyncError **error); +int usage(char *name); + + + + + + + + + + + + + + + +OSyncObjFormat *conv_run_detection(OSyncFormatEnv *env, const char *sfname, conv_detection type, OSyncError **error) +{ + OSyncObjFormat *targetformat = NULL; + + + if (env == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: env = NULL. ", __FILE__, __LINE__); + goto error; + } + + if (sfname == NULL) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sfname = NULL. ", __FILE__, __LINE__); + goto error; + } + + + + fprintf(stderr, "Type of the source format: \"%s\".\n", sfname); + + + + if (!strcmp(sfname, "vcard21")) { + switch (type) { + case TARGET_AUTO: + case TARGET_VCARD_30: + targetformat = osync_format_env_find_objformat(env, "vcard30"); + break; + + case TARGET_LDAP_EVOLUTIONPERSON: + targetformat = osync_format_env_find_objformat(env, "ldap-evolutionperson"); + break; + + case TARGET_LDAP_INETORGPERSON: + targetformat = osync_format_env_find_objformat(env, "ldap-inetorgperson"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-contact"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vcard21 into this format. Supported formats: xmlformat, ldap-evolutionperson, ldap-inetorgperson, vcard30.", __FILE__, __LINE__); + goto error; + } + + + + } else if (!strcmp(sfname, "vcard30")) { + switch (type) { + case TARGET_AUTO: + case TARGET_VCARD_21: + targetformat = osync_format_env_find_objformat(env, "vcard21"); + break; + + case TARGET_LDAP_EVOLUTIONPERSON: + targetformat = osync_format_env_find_objformat(env, "ldap-evolutionperson"); + break; + + case TARGET_LDAP_INETORGPERSON: + targetformat = osync_format_env_find_objformat(env, "ldap-inetorgperson"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-contact"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vcard30 into this format. Supported formats: xmlformat, ldap-evolutionperson, ldap-inetorgperson, vcard21.", __FILE__, __LINE__); + goto error; + } + + + + } else if (!strcmp(sfname, "vevent10")) { + switch (type) { + case TARGET_AUTO: + case TARGET_VEVENT_20: + targetformat = osync_format_env_find_objformat(env, "vevent20"); + break; + + case TARGET_LDAP_EVENT: + targetformat = osync_format_env_find_objformat(env, "ldap-event"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-event"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vevent10 into this format. Supported formats: xmlformat, ldap-event, vevent20.", __FILE__, __LINE__); + goto error; + } + + + + } else if (!strcmp(sfname, "vevent20")) { + switch (type) { + case TARGET_AUTO: + case TARGET_VEVENT_10: + targetformat = osync_format_env_find_objformat(env, "vevent10"); + break; + + case TARGET_LDAP_EVENT: + targetformat = osync_format_env_find_objformat(env, "ldap-event"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-event"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vevent20 into this format. Supported formats: xmlformat, ldap-event, vevent10.", __FILE__, __LINE__); + goto error; + } + + + + } else if (!strcmp(sfname, "vtodo10")) { + switch (type) { + case TARGET_AUTO: + case TARGET_VTODO_20: + targetformat = osync_format_env_find_objformat(env, "vtodo20"); + break; + + case TARGET_LDAP_TODO: + targetformat = osync_format_env_find_objformat(env, "ldap-todo"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-todo"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vtodo10 into this format. Supported formats: xmlformat, ldap-todo, vtodo20.", __FILE__, __LINE__); + goto error; + } + + + + } else if (!strcmp(sfname, "vtodo20")) { + switch (type) { + case TARGET_AUTO: + case TARGET_VTODO_10: + targetformat = osync_format_env_find_objformat(env, "vtodo10"); + break; + + case TARGET_LDAP_TODO: + targetformat = osync_format_env_find_objformat(env, "ldap-todo"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-todo"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vtodo20 into this format. Supported formats: xmlformat, ldap-todo, vtodo10\n", __FILE__, __LINE__); + goto error; + } + + + + } else if (!strcmp(sfname, "vnote11")) { + switch (type) { + case TARGET_AUTO: + case TARGET_VJOURNAL: + targetformat = osync_format_env_find_objformat(env, "vjournal"); + break; + + case TARGET_LDAP_NOTE: + targetformat = osync_format_env_find_objformat(env, "ldap-note"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-note"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vnote11 into this format. Supported formats: xmlformat, ldap-note, vjournal.", __FILE__, __LINE__); + goto error; + } + + + + } else if (!strcmp(sfname, "vjournal")) { + switch (type) { + case TARGET_AUTO: + case TARGET_VNOTE_11: + targetformat = osync_format_env_find_objformat(env, "vnote11"); + break; + + case TARGET_LDAP_NOTE: + targetformat = osync_format_env_find_objformat(env, "ldap-event"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-note"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vjournal into this format. Supported formats: xmlformat, ldap-note, vnote11.", __FILE__, __LINE__); + goto error; + } + + + + } else if (!strcmp(sfname, "xmlformat-contact-doc") || !strcmp(sfname, "xmlformat-contact")) { + switch (type) { + case TARGET_LDAP_EVOLUTIONPERSON: + targetformat = osync_format_env_find_objformat(env, "ldap-evolutionperson"); + break; + + case TARGET_LDAP_INETORGPERSON: + targetformat = osync_format_env_find_objformat(env, "ldap-inetorgperson"); + break; + + case TARGET_VCARD_21: + targetformat = osync_format_env_find_objformat(env, "vcard21"); + break; + + case TARGET_AUTO: + case TARGET_VCARD_30: + targetformat = osync_format_env_find_objformat(env, "vcard30"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-contact"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert xmlformat-contact-doc into this format. Supported formats: vcard21, vcard30, ldap-evolutionperson, ldap-inetorgperson, xmlformat-contact.", __FILE__, __LINE__); + goto error; + } + + + + } else if (!strcmp(sfname, "xmlformat-event-doc") || !strcmp(sfname, "xmlformat-event")) { + switch (type) { + case TARGET_VEVENT_10: + targetformat = osync_format_env_find_objformat(env, "vevent10"); + break; + + case TARGET_LDAP_EVENT: + targetformat = osync_format_env_find_objformat(env, "ldap-event"); + break; + + case TARGET_AUTO: + case TARGET_VEVENT_20: + targetformat = osync_format_env_find_objformat(env, "vevent20"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-event"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert xmlformat-event-doc into this format. Supported formats: vevent10, vevent20, ldap-event, xmlformat-event.", __FILE__, __LINE__); + goto error; + } + + + } else if (!strcmp(sfname, "xmlformat-todo-doc") || !strcmp(sfname, "xmlformat-todo")) { + switch (type) { + case TARGET_VTODO_10: + targetformat = osync_format_env_find_objformat(env, "vtodo10"); + break; + + case TARGET_LDAP_TODO: + targetformat = osync_format_env_find_objformat(env, "ldap-todo"); + break; + + case TARGET_AUTO: + case TARGET_VTODO_20: + targetformat = osync_format_env_find_objformat(env, "vtodo20"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-todo"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert xmlformat-todo-doc into this format. Supported formats: vtodo10, vtodo20, ldap-todo, xmlformat-todo.", __FILE__, __LINE__); + goto error; + } + + + + } else if (!strcmp(sfname, "xmlformat-note-doc") || !strcmp(sfname, "xmlformat-note")) { + switch (type) { + case TARGET_AUTO: + case TARGET_VNOTE_11: + targetformat = osync_format_env_find_objformat(env, "vnote11"); + break; + + case TARGET_LDAP_NOTE: + targetformat = osync_format_env_find_objformat(env, "ldap-note"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-note"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert xmlformat-note-doc into this format. Supported formats: vnote11, ldap-note, xmlformat-note.", __FILE__, __LINE__); + goto error; + } + + + + } else if (!strcmp(sfname, "xmlformat-journal-doc")) { + switch (type) { + case TARGET_AUTO: + case TARGET_VJOURNAL: + targetformat = osync_format_env_find_objformat(env, "vjournal"); + break; + + case TARGET_LDAP_NOTE: + targetformat = osync_format_env_find_objformat(env, "ldap-note"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-journal"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert xmlformat-journal-doc into this format. Supported formats: vjournal, ldap-note, xmlformat-journal.", __FILE__, __LINE__); + goto error; + } + + + + + + } else if (!strcmp(sfname, "ldap-evolutionperson")) { + switch(type) { + case TARGET_AUTO: + case TARGET_VCARD_30: + targetformat = osync_format_env_find_objformat(env, "vcard30"); + break; + + case TARGET_VCARD_21: + targetformat = osync_format_env_find_objformat(env, "vcard21"); + break; + + case TARGET_LDAP_INETORGPERSON: + targetformat = osync_format_env_find_objformat(env, "ldap-inetorgperson"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-contact"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert ldap-evolutionperson into this format. Supported formats: xmlformat, vcard21, vcard30, ldap-inetorgperson.", __FILE__, __LINE__); + goto error; + } + + + + } else if (!strcmp(sfname, "ldap-inetorgperson")) { + switch(type) { + case TARGET_AUTO: + case TARGET_VCARD_30: + targetformat = osync_format_env_find_objformat(env, "vcard30"); + break; + + case TARGET_VCARD_21: + targetformat = osync_format_env_find_objformat(env, "vcard21"); + break; + + case TARGET_LDAP_EVOLUTIONPERSON: + targetformat = osync_format_env_find_objformat(env, "ldap-evolutionperson"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-contact"); + break; + + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert ldap-inetorgperson into this format. Supported formats: xmlformat, vcard21, vcard30, ldap-evolutionperson.", __FILE__, __LINE__); + goto error; + } + + + + } else if (!strcmp(sfname, "ldap-event")) { + switch(type) { + case TARGET_AUTO: + case TARGET_VEVENT_20: + targetformat = osync_format_env_find_objformat(env, "vevent20"); + break; + + case TARGET_VEVENT_10: + targetformat = osync_format_env_find_objformat(env, "vevent10"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-event"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert ldap-event into this format. Supported formats: xmlformat, vevent10, vevent20", __FILE__, __LINE__); + goto error; + } + + + + } else if (!strcmp(sfname, "ldap-todo")) { + switch(type) { + case TARGET_AUTO: + case TARGET_VTODO_20: + targetformat = osync_format_env_find_objformat(env, "vtodo20"); + break; + + case TARGET_VTODO_10: + targetformat = osync_format_env_find_objformat(env, "vtodo10"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-todo"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert ldap-todo into this format. Supported formats: xmlformat, vtodo10, vtodo20.", __FILE__, __LINE__); + goto error; + } + + + + } else if (!strcmp(sfname, "ldap-note")) { + switch(type) { + case TARGET_AUTO: + case TARGET_VJOURNAL: + targetformat = osync_format_env_find_objformat(env, "vjournal"); + break; + + case TARGET_VNOTE_11: + targetformat = osync_format_env_find_objformat(env, "vnote11"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-note"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert ldap-note into this format. Supported formats: xmlformat, vjournal, vnote11.", __FILE__, __LINE__); + goto error; + } + + + + } else { + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Cannot convert format \"%s\" to anything, at all. Unable to find any suitable converter.", __FILE__, __LINE__, sfname); + goto error; + } + + + fprintf(stderr, "Type of the target format: \"%s\".\n", (char *)osync_objformat_get_name(targetformat)); + + + return targetformat; + +error: + if (osync_error_is_set(error)) { + fprintf(stderr, "%s:%i: ERROR: %s\n", __FILE__, __LINE__, osync_error_print(error)); + } else { + fprintf(stderr, "%s:%i: ERROR: Unknown reason.\n", __FILE__, __LINE__); + } + + return NULL; +} + + +int usage(char *name) +{ + if (name == NULL) { + name = (char *)__FILE__; + } + + fprintf(stderr, "Usage: %s <inputfile> <options>\n\n", name); + fprintf(stderr, "--help\t\tShow this help message\n"); + fprintf(stderr, "--out <file>\tStore the output into this file. Leaving out this option means, print it to stdout.\n"); + fprintf(stderr, "--to-vcard21\tConvert to vcard 2.1\n"); + fprintf(stderr, "--to-vcard30\tConvert to vcard 3.0\n"); + fprintf(stderr, "--to-ldap-evolutionperson\tConvert to LDAP evolutionperson\n"); + fprintf(stderr, "--to-ldap-inetorgperson\tConvert to LDAP inetorgperson\n"); + fprintf(stderr, "--to-vevent10\tConvert to vevent 1.0\n"); + fprintf(stderr, "--to-vevent20\tConvert to vevent 2.0\n"); + fprintf(stderr, "--to-ldap-event\tConvert to LDAP event\n"); + fprintf(stderr, "--to-vtodo10\tConvert to vtodo 1.0\n"); + fprintf(stderr, "--to-vtodo20\tConvert to vtodo 2.0\n"); + fprintf(stderr, "--to-ldap-todo\tConvert to LDAP todo\n"); + fprintf(stderr, "--to-vnote11\tConvert to vnote 1.1\n"); + fprintf(stderr, "--to-vjournal\tConvert to vjournal\n"); + fprintf(stderr, "--to-ldap-note\tConvert to LDAP note\n"); + fprintf(stderr, "--to-xmlformat\tConvert to xmlformat\n"); + + return 1; +} + + + +int main (int argc, char *argv[]) +{ + OSyncData *data = NULL; + OSyncError *error = NULL; + OSyncFormatEnv *format_env = NULL; + OSyncObjFormat *sourceformat = NULL; + OSyncObjFormat *targetformat = NULL; + OSyncFormatConverterPath *converter_path = NULL; + OSyncList *l = NULL, *list = NULL; + conv_detection detection_type = TARGET_AUTO; + char *program = NULL; + char *format_config = NULL; + char *input_filename = NULL; + char *output_filename = NULL; + char *buffer = NULL; + char *result = NULL; + struct stat stat_buffer; + unsigned int size; + int i = 0; + + + + if (argc < 2) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Not enough arguments. You must state the name of the input file to be converted.", __FILE__, __LINE__); + goto error; + } + + + if (!strcmp(argv[0], "-h") || !strcmp(argv[0], "--help")) { + usage(argv[0]); + return 0; + } + + + program = argv[0]; + + input_filename = argv[1]; + + for (i = 2; i < argc; i++) { + char *arg = argv[i]; + + + if (!strcmp(arg, "--help") || !strcmp(arg, "-h")) { + usage(program); + return 0; + + } else if (!strcmp(arg, "--to-vcard21")) { + detection_type = TARGET_VCARD_21; + + } else if (!strcmp(arg, "--to-vcard30")) { + detection_type = TARGET_VCARD_30; + + } else if (!strcmp (arg, "--to-vevent10")) { + detection_type = TARGET_VEVENT_10; + + } else if (!strcmp (arg, "--to-vevent20")) { + detection_type = TARGET_VEVENT_20; + + } else if (!strcmp (arg, "--to-vtodo10")) { + detection_type = TARGET_VTODO_10; + + } else if (!strcmp (arg, "--to-vtodo20")) { + detection_type = TARGET_VTODO_20; + + } else if (!strcmp (arg, "--to-vnote11")) { + detection_type = TARGET_VNOTE_11; + + } else if (!strcmp (arg, "--to-vjournal")) { + detection_type = TARGET_VJOURNAL; + + } else if (!strcmp (arg, "--to-xmlformat")) { + detection_type = TARGET_XMLFORMAT; + + } else if (!strcmp (arg, "--to-ldap-evolutionperson")) { + detection_type = TARGET_LDAP_EVOLUTIONPERSON; + + } else if (!strcmp (arg, "--to-ldap-inetorgperson")) { + detection_type = TARGET_LDAP_INETORGPERSON; + + } else if (!strcmp (arg, "--to-ldap-event")) { + detection_type = TARGET_LDAP_EVENT; + + } else if (!strcmp (arg, "--to-ldap-todo")) { + detection_type = TARGET_LDAP_TODO; + + } else if (!strcmp (arg, "--to-ldap-note")) { + detection_type = TARGET_LDAP_NOTE; + } else if (!strcmp (arg, "--out")) { + if (!strncmp(argv[i + 1], "--", 2)) { + fprintf(stderr, "ERROR: Output filename MUST NOT begin with \'--\'. Use --help, if necessary."); + continue; + + } else if (!strncmp(argv[i + 1], "-", 1)) { + fprintf(stderr, "ERROR: Output filename MUST NOT begin with \'-\'. Use --help, if necessary."); + continue; + + } else if (argv[i + 1] == 0) { + fprintf(stderr, "ERROR: --out must be followed by a name of a file where the output can be written to. Use --help, if necessary."); + continue; + + } else { + output_filename = argv[i + 1]; + i++; + } + + } else if (!strcmp (arg, "--")) { + break; + + } else if (arg[0] == '-') { + fprintf(stderr, "%s:%i: ERROR: \"-\" is an invalid option. Use --help, if necessary.\n", __FILE__, __LINE__); + goto error; + + } else { + fprintf(stderr, "%s:%i: ERROR: Unknown option.\n", __FILE__, __LINE__); + goto error; + + } + } + + + + if (input_filename == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input_filename = NULL. input_filename has not been set.", __FILE__, __LINE__); + + goto error; + } + + if (input_filename[0] == 0) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: input_filename[0] = 0. input_filename has not been set.", __FILE__, __LINE__); + + goto error; + } + + + errno = 0; + if (stat(input_filename, &stat_buffer)) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Could not load \"%s\": %s", __FILE__, __LINE__, input_filename, strerror(errno)); + goto error; + } + + + // Load the contents of the input file into buffer + if (!osync_file_read(input_filename, &buffer, &size, &error)) { + if (!osync_error_is_set(&error)) + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: osync_file_read() has failed.", __FILE__, __LINE__); + + goto error; + } + + // The size returned by osync_file_read does NOT include the + // terminating 0. But we need a size that does include it. + size++; + + + // Allocate a new format environment + format_env = osync_format_env_new(&error); + if (format_env == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: format_env = NULL. ", __FILE__, __LINE__); + goto error; + } + + + // Let the format environment load all kinds of plugins + if (!osync_format_env_load_plugins(format_env, NULL, &error)) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Could not load any format plugin.", __FILE__, __LINE__); + goto error; + } + + + // Alloacate a format object specifically intended for the input file. + // At first, we create an OSyncData object with "plain" as sort of a + // general object format. Just to have something to begin with. + sourceformat = osync_format_env_find_objformat(format_env, "plain"); + if (sourceformat == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sourceformat = NULL. Objformat object could not be generated.", __FILE__, __LINE__); + goto error; + } + + + // Allocate a new data object with the contents of the input file + data = osync_data_new(buffer, size, sourceformat, &error); + if (data == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: data = NULL.", __FILE__, __LINE__); + goto error; + } + + + // Analyze the source format + + sourceformat = osync_format_env_detect_objformat(format_env, data); + if (sourceformat == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sourceformat = NULL. Source format could not be recognized.", __FILE__, __LINE__); + goto error; + } + + +/* + if (!osync_format_env_detect_objformat_full(format_env, data, &sourceformat, &error)) { + if (!osync_error_is_set(&error)) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: osync_format_env_detect_objformat_full() has failed.", __FILE__, __LINE__); + } + + goto error; + } +*/ + + + if (sourceformat == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: sourceformat = NULL. Source format could not be recognized.", __FILE__, __LINE__); + goto error; + } + + + char *sourceformat_name = (char *)osync_objformat_get_name(sourceformat); + +#if 0 + // Workaround + if (!strcmp(sourceformat_name, "xmlformat-contact-doc")) { + sourceformat_name = (char *)"xmlformat-contact"; + sourceformat = osync_objformat_new(sourceformat_name, "contact", &error); + } +#endif + + + // Tell the data object what kind of source format we have just found. + osync_data_set_objformat(data, sourceformat); + if (osync_error_is_set(&error)) { + goto error; + } + + + + + // Try and get the target format + targetformat = conv_run_detection(format_env, sourceformat_name, detection_type, &error); + if (targetformat == NULL) { + if (!osync_error_is_set(&error)) + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: targetformat could not be recognized.", __FILE__, __LINE__); + + goto error; + } + + + + // Try and find the converter path for a particular source format and + // target format + converter_path = osync_format_env_find_path(format_env, sourceformat, targetformat, &error); + if (converter_path == NULL) { + if (!osync_error_is_set(&error)) + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: converter_pathcould not be found for sourceformat = \"%s\" and targetformat = \"%s\".", __FILE__, __LINE__, sourceformat, targetformat); + + goto error; + } + + + if (format_config) { + osync_converter_path_set_config(converter_path, format_config); + fprintf(stderr, "%s:%i: config of converter path: \"%s\"\n", __FILE__, __LINE__, osync_converter_path_get_config (converter_path)); +#ifdef DEBUG + } else { + fprintf(stderr, "%s:%i: WARNING: format_config = NULL.\n", __FILE__, __LINE__); +#endif + } + + + + + + + + + // Dump the converters involved in the conversion path, + // but only the ones which reside at the edges. + l = NULL; + list = osync_converter_path_get_edges(converter_path); + if (list) { + for (l = list; l; l = l->next) { + if (l->data) { + fprintf(stderr, "Edge converter: \"%s\"\n", osync_objformat_get_name(osync_converter_get_targetformat(l->data))); + } + } + } else { + osync_trace(TRACE_ERROR, "%s:%i: WARNING: list = NULL.", __FILE__, __LINE__); + } + + + + // Now, convert the data from sourceformat to targetformat + if (!osync_format_env_convert(format_env, converter_path, data, &error)) { + if (!osync_error_is_set(&error)) + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: conversion could not be performed for sourceformat = \"%s\" and targetformat = \"%s\".", __FILE__, __LINE__, sourceformat, targetformat); + + goto error; + } + + + if (data == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: output data = NULL. Conversion must have failed.", __FILE__, __LINE__); + goto error; + } + + + result = osync_data_get_printable(data); + if (result == NULL) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: result = NULL. Conversion must have failed.", __FILE__, __LINE__); + goto error; + } + + + + // Output to screen or file + if (output_filename) { + if (!osync_file_write(output_filename, result, strlen(result), 0644, &error)) { + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to write file %s.", __FILE__, __LINE__, output_filename); + goto error; + } + } else { + printf("%s\n", result); + } + + + + if (data) + osync_data_unref(data); + + if (converter_path) + osync_converter_path_unref(converter_path); + + if (format_env) + osync_format_env_unref(format_env); + + return 0; + + +error: + if (data) + osync_data_unref(data); + + if (converter_path) + osync_converter_path_unref(converter_path); + + if (format_env) + osync_format_env_unref(format_env); + + if (osync_error_is_set(&error)) { + fprintf(stderr, "%s\n", osync_error_print(&error)); + osync_error_unref(&error); + } + + return 1; +} Added: plugins/ldap-sync/tests/vcards/README ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/vcards/README Sat Apr 11 20:28:01 2009 (r5573) @@ -0,0 +1,3 @@ +*.vcf files copied from the opensync-plugin-vformat. +Thanks go to the authors of the opensync-plugin-vformat format plugin. + Added: plugins/ldap-sync/tests/vcards/evo2-full1.vcf ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/vcards/evo2-full1.vcf Sat Apr 11 20:28:01 2009 (r5573) @@ -0,0 +1,47 @@ +BEGIN:VCARD +VERSION:3.0 +FN:Title First Middle Last Suffix +N:Last;First;Middle;Title;Suffix +ORG:organization;department;office +REV:2005-02-26T10:41:24Z +ROLE:profession +TITLE:title +UID:pas-id-421A5F6100000014 +URL:homepage +X-EVOLUTION-FILE-AS:Last\, First +X-EVOLUTION-MANAGER:manager +X-EVOLUTION-ASSISTANT:assistant +NICKNAME:nickname +BDAY:2005-02-10 +X-EVOLUTION-ANNIVERSARY:2005-02-08 +X-EVOLUTION-SPOUSE:spouse +NOTE:This is a note! +CATEGORIES:Birthday,Business +X-EVOLUTION-BLOG-URL:weblog +CALURI:calendar +FBURL:freebusy +X-EVOLUTION-VIDEO-URL:video chat +X-MOZILLA-HTML:TRUE +EMAIL;TYPE=WORK;X-EVOLUTION-UI-SLOT=1:workemail +EMAIL;TYPE=HOME;X-EVOLUTION-UI-SLOT=2:homeemail +EMAIL;TYPE=OTHER;X-EVOLUTION-UI-SLOT=3:otheremail +EMAIL;TYPE=OTHER;X-EVOLUTION-UI-SLOT=4:otheremail2 +TEL;TYPE=WORK;TYPE=VOICE;X-EVOLUTION-UI-SLOT=1:bizphone +TEL;TYPE=HOME;TYPE=VOICE;X-EVOLUTION-UI-SLOT=2:homephone +TEL;TYPE=CELL;X-EVOLUTION-UI-SLOT=3:mobphone +TEL;TYPE=WORK;TYPE=FAX;X-EVOLUTION-UI-SLOT=4:biz fax +TEL;TYPE="X-EVOLUTION-ASSISTANT";X-EVOLUTION-UI-SLOT=5:assistantphone +TEL;TYPE="X-EVOLUTION-CALLBACK";X-EVOLUTION-UI-SLOT=6:callback +TEL;TYPE=CAR;X-EVOLUTION-UI-SLOT=7:car phone +TEL;TYPE=PREF;X-EVOLUTION-UI-SLOT=8:primary phone +X-AIM;TYPE=HOME;X-EVOLUTION-UI-SLOT=1:aim +X-YAHOO;TYPE=HOME;X-EVOLUTION-UI-SLOT=2:yahoo +X-ICQ;TYPE=HOME;X-EVOLUTION-UI-SLOT=3:icq +X-GROUPWISE;TYPE=HOME;X-EVOLUTION-UI-SLOT=4:groupwise +ADR;TYPE=WORK:PO-BOX2;;Address2;City2;State2;zip2;country2 +LABEL;TYPE=WORK:Address2\nCity2\, State2\nzip2\nPO-BOX2\ncountry2 +ADR;TYPE=HOME:PO-BOX1;;Address1;City1;State1;zip1;country1 +LABEL;TYPE=HOME:Address1\nCity1\, State1\nzip1\nPO-BOX1\ncountry1 +ADR;TYPE=OTHER:PO-BOX3;;Address3;City3;State3;zip3;country3 +LABEL;TYPE=OTHER:Address3\nCity3\, State3\nzip3\nPO-BOX3\ncountry3 +END:VCARD \ No newline at end of file Added: plugins/ldap-sync/tests/vcards/evo2-full2.vcf ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/vcards/evo2-full2.vcf Sat Apr 11 20:28:01 2009 (r5573) @@ -0,0 +1,47 @@ +BEGIN:VCARD +VERSION:3.0 +FN:Title First Middle Last Suffix +N:Last;First;Middle;Title;Suffix +ORG:organization;department;office +REV:2005-02-26 +ROLE:profession +TITLE:title +UID:pas-id-421A5F6100000014 +URL:homepage +X-EVOLUTION-FILE-AS:Last\, First +X-EVOLUTION-MANAGER:manager +X-EVOLUTION-ASSISTANT:assistant +NICKNAME:nickname +BDAY:2005-02-10 +X-EVOLUTION-ANNIVERSARY:2005-02-08 +X-EVOLUTION-SPOUSE:spouse +NOTE:This is a note! +CATEGORIES:Birthday,Business +X-EVOLUTION-BLOG-URL:weblog +CALURI:calendar +FBURL:freebusy +X-EVOLUTION-VIDEO-URL:video chat +X-MOZILLA-HTML:TRUE +ADR;TYPE=WORK:PO-BOX2;;Address2;City2;State2;zip2;country2 +LABEL;TYPE=WORK:Address2\nCity2\, State2\nzip2\nPO-BOX2\ncountry2 +ADR;TYPE=HOME:PO-BOX1;;Address1;City1;State1;zip1;country1 +LABEL;TYPE=HOME:Address1\nCity1\, State1\nzip1\nPO-BOX1\ncountry1 +ADR;TYPE=OTHER:PO-BOX3;;Address3;City3;State3;zip3;country3 +LABEL;TYPE=OTHER:Address3\nCity3\, State3\nzip3\nPO-BOX3\ncountry3 +EMAIL;TYPE=WORK;X-EVOLUTION-UI-SLOT=1:workemail +EMAIL;TYPE=HOME;X-EVOLUTION-UI-SLOT=2:homeemail +EMAIL;TYPE=OTHER;X-EVOLUTION-UI-SLOT=3:otheremail +EMAIL;TYPE=OTHER;X-EVOLUTION-UI-SLOT=4:otheremail2 +TEL;TYPE="X-EVOLUTION-COMPANY";X-EVOLUTION-UI-SLOT=1:company phone +TEL;TYPE=HOME;TYPE=FAX;X-EVOLUTION-UI-SLOT=2:homefax +TEL;TYPE=FAX;X-EVOLUTION-UI-SLOT=3:other fax +TEL;TYPE=PAGER;X-EVOLUTION-UI-SLOT=4:pager +TEL;TYPE=ISDN;X-EVOLUTION-UI-SLOT=5:ISDN +TEL;TYPE=VOICE;X-EVOLUTION-UI-SLOT=6:other phone +TEL;TYPE="X-EVOLUTION-RADIO";X-EVOLUTION-UI-SLOT=7:radio +TEL;TYPE="X-EVOLUTION-TELEX";X-EVOLUTION-UI-SLOT=8:telex +X-JABBER;TYPE=HOME;X-EVOLUTION-UI-SLOT=3:jabber +X-YAHOO;TYPE=HOME;X-EVOLUTION-UI-SLOT=2:yahoo +X-MSN;TYPE=HOME;X-EVOLUTION-UI-SLOT=1:msn +X-GROUPWISE;TYPE=HOME;X-EVOLUTION-UI-SLOT=4:groupwise +END:VCARD \ No newline at end of file Added: plugins/ldap-sync/tests/vcards/evo2-multiline.vcf ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/vcards/evo2-multiline.vcf Sat Apr 11 20:28:01 2009 (r5573) @@ -0,0 +1,53 @@ +BEGIN:VCARD +VERSION:3.0 +FN:Title First Middle Last Suffix +N:Last;First;Middle;Title;Suffix +ORG:organization;department;office +REV:20050226 +ROLE:profession +TITLE:title +UID:pas-id-421A5F6100000014 +URL:homepage +X-EVOLUTION-FILE-AS:Last\, First +X-EVOLUTION-MANAGER:manager +X-EVOLUTION-ASSISTANT:assistant +NICKNAME:nickname +BDAY:2005-02-10 +X-EVOLUTION-ANNIVERSARY:2005-02-08 +X-EVOLUTION-SPOUSE:spouse +NOTE:This is a multiline note!\nNote how there are multiple\nl\ni\nn\ne\ns +CATEGORIES:Birthday,Business +X-EVOLUTION-BLOG-URL:weblog +CALURI:calendar +FBURL:freebusy +X-EVOLUTION-VIDEO-URL:video chat +X-MOZILLA-HTML:TRUE +ADR;TYPE=WORK:PO-BOX2;Multiline street\nmultiline city;Address2;City2;State + 2;zip2;country2 +LABEL;TYPE=WORK:Address2\nMultiline street\nmultiline city\nCity2\, State2\ + nzip2\nPO-BOX2\ncountry2 +ADR;TYPE=HOME:PO-BOX1;Multiline street\nmultiline city\n;Address1;City1;Sta + te1;zip1;country1 +LABEL;TYPE=HOME:Address1\nMultiline street\nmultiline city\n\nCity1\, State + 1\nzip1\nPO-BOX1\ncountry1 +ADR;TYPE=OTHER:PO-BOX3;Multiline street\nmultiline city;Address3;City3;Stat + e3;zip3;country3 +LABEL;TYPE=OTHER:Address3\nMultiline street\nmultiline city\nCity3\, State3 + \nzip3\nPO-BOX3\ncountry3 +EMAIL;TYPE=WORK;X-EVOLUTION-UI-SLOT=1:workemail +EMAIL;TYPE=HOME;X-EVOLUTION-UI-SLOT=2:homeemail +EMAIL;TYPE=OTHER;X-EVOLUTION-UI-SLOT=3:otheremail +EMAIL;TYPE=OTHER;X-EVOLUTION-UI-SLOT=4:otheremail2 +TEL;TYPE="X-EVOLUTION-COMPANY";X-EVOLUTION-UI-SLOT=1:company phone +TEL;TYPE=HOME;TYPE=FAX;X-EVOLUTION-UI-SLOT=2:homefax +TEL;TYPE=FAX;X-EVOLUTION-UI-SLOT=3:other fax +TEL;TYPE=PAGER;X-EVOLUTION-UI-SLOT=4:pager +TEL;TYPE=ISDN;X-EVOLUTION-UI-SLOT=5:ISDN +TEL;TYPE=VOICE;X-EVOLUTION-UI-SLOT=6:other phone +TEL;TYPE="X-EVOLUTION-RADIO";X-EVOLUTION-UI-SLOT=7:radio +TEL;TYPE="X-EVOLUTION-TELEX";X-EVOLUTION-UI-SLOT=8:telex +X-JABBER;TYPE=HOME;X-EVOLUTION-UI-SLOT=3:jabber +X-YAHOO;TYPE=HOME;X-EVOLUTION-UI-SLOT=2:yahoo +X-MSN;TYPE=HOME;X-EVOLUTION-UI-SLOT=1:msn +X-GROUPWISE;TYPE=HOME;X-EVOLUTION-UI-SLOT=4:groupwise +END:VCARD \ No newline at end of file Added: plugins/ldap-sync/tests/vcards/evo2-photo.vcf ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/vcards/evo2-photo.vcf Sat Apr 11 20:28:01 2009 (r5573) @@ -0,0 +1,59 @@ +BEGIN:VCARD +VERSION:3.0 +FN:Title First Middle Last Suffix +N:Last;First;Middle;Title;Suffix +ORG:organization;department;office +REV:20050226T104124,2Z +ROLE:profession +TITLE:title +UID:pas-id-421A5F6100000014 +URL:homepage +X-EVOLUTION-FILE-AS:Last\, First +X-EVOLUTION-MANAGER:manager +X-EVOLUTION-ASSISTANT:assistant +NICKNAME:nickname +BDAY:2005-02-10 +X-EVOLUTION-ANNIVERSARY:2005-02-08 +X-EVOLUTION-SPOUSE:spouse +NOTE:This is a note! +CATEGORIES:Birthday,Business +X-EVOLUTION-BLOG-URL:weblog +CALURI:calendar +FBURL:freebusy +X-EVOLUTION-VIDEO-URL:video chat +X-MOZILLA-HTML:TRUE +ADR;TYPE=WORK:PO-BOX2;;Address2;City2;State2;zip2;country2 +LABEL;TYPE=WORK:Address2\nCity2\, State2\nzip2\nPO-BOX2\ncountry2 +ADR;TYPE=HOME:PO-BOX1;;Address1;City1;State1;zip1;country1 +LABEL;TYPE=HOME:Address1\nCity1\, State1\nzip1\nPO-BOX1\ncountry1 +ADR;TYPE=OTHER:PO-BOX3;;Address3;City3;State3;zip3;country3 +LABEL;TYPE=OTHER:Address3\nCity3\, State3\nzip3\nPO-BOX3\ncountry3 +PHOTO;ENCODING=b;TYPE=PNG:iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAIAAAADnC86AAAAC + XBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1QIaEQILc0Ox6gAAAB10RVh0Q29tbWVudABDc + mVhdGVkIHdpdGggVGhlIEdJTVDvZCVuAAAB7ElEQVRYw+2XTasxYRjH/8dwGpq8xEaajZeJU + BZoykL2ysbCTrGUfAZr2UtJKTtJ8QGUrWKhKOELjMKUtybO4q7ZnM7E88zT6am5Vnd3v7l+m + 7muf/fH8/nEb5QOv1SaWBNrYk2sif+pWJKkbrebyWRcLpfBYKBpmuO4QqEwmUze6PJ8s5bLZ + TgcJt/SNO12u10uF0VR5CaXy4mi+EofvGu12+0AvF5vr9e7Xq/kXhCEWq3GMAyARCJxuVzUF + N/v91AoBCAajR4Oh+/AdDq1WCwAKpWKmuJmswnAaDRuNpufmFarBUCv1+92O9XEPM8DKBaLC + owkSSzLAqhWq+qIRVHU6XQARqORMlkqlQAkk0ll7NVxWq/Xj8cDQCQSUSYJsFqt1Jnj/X5PD + g6HQ5kkgMz/t5uLjC8AQRCUSQLI/N+KfT4f+bnm87kySQC/36+OmGGYWCwGYDAYKGCPx2M4H + AJIpVKq7epGowHAZDJtt9ufmHa7TRaIAvP2ArndboFAAEA8Hj8ej9+B2WxmtVoBlMtllUNis + VjYbDYAHMf1+305JPb7fb1eN5vNAHieP5/PKouJOxgMyrHo8XhYlpVjMZvNnk4n9WNRjqlOp + 5NOp51OJ0VRn5+fHo8nn8+Px+PXm3xoz1RNrIk18Z/WF7ZpjC1N/OYqAAAAAElFTkSuQmCC +EMAIL;TYPE=WORK;X-EVOLUTION-UI-SLOT=1:workemail +EMAIL;TYPE=HOME;X-EVOLUTION-UI-SLOT=2:homeemail +EMAIL;TYPE=OTHER;X-EVOLUTION-UI-SLOT=3:otheremail +EMAIL;TYPE=OTHER;X-EVOLUTION-UI-SLOT=4:otheremail2 +TEL;TYPE="X-EVOLUTION-COMPANY";X-EVOLUTION-UI-SLOT=1:company phone +TEL;TYPE=HOME;TYPE=FAX;X-EVOLUTION-UI-SLOT=2:homefax +TEL;TYPE=FAX;X-EVOLUTION-UI-SLOT=3:other fax +TEL;TYPE=PAGER;X-EVOLUTION-UI-SLOT=4:pager +TEL;TYPE=ISDN;X-EVOLUTION-UI-SLOT=5:ISDN +TEL;TYPE=VOICE;X-EVOLUTION-UI-SLOT=6:other phone +TEL;TYPE="X-EVOLUTION-RADIO";X-EVOLUTION-UI-SLOT=7:radio +TEL;TYPE="X-EVOLUTION-TELEX";X-EVOLUTION-UI-SLOT=8:telex +X-JABBER;TYPE=HOME;X-EVOLUTION-UI-SLOT=3:jabber +X-YAHOO;TYPE=HOME;X-EVOLUTION-UI-SLOT=2:yahoo +X-MSN;TYPE=HOME;X-EVOLUTION-UI-SLOT=1:msn +X-GROUPWISE;TYPE=HOME;X-EVOLUTION-UI-SLOT=4:groupwise +END:VCARD \ No newline at end of file Added: plugins/ldap-sync/tests/vcards/evo2-special.vcf ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/vcards/evo2-special.vcf Sat Apr 11 20:28:01 2009 (r5573) @@ -0,0 +1,26 @@ +BEGIN:VCARD +VERSION:3.0 +FN:Titleö Firstä Middleü Lastß Suffixö +N:Lastß;Firstä;Middleü;Titleö;Suffixö +ORG:organization;department;office +REV:2005-02-26T10:41:24Z +ROLE:profession +TITLE:title +UID:pas-id-421A5F6100000014 +URL:homepage +X-EVOLUTION-FILE-AS:Lastß\, Firstä +X-EVOLUTION-MANAGER:manager +X-EVOLUTION-ASSISTANT:assistant +NICKNAME:nicknameü +BDAY:2005-02-10 +X-EVOLUTION-ANNIVERSARY:2005-02-08 +X-EVOLUTION-SPOUSE:spouse +NOTE:This is a multiline note with special chars\n!"§$%&/()=?`'*+~'#-_:.\; + \,^°@€¹²³¼½½¬{[[]}\\¸¨þø→←→€ł@æßðjđŋĸjħł + <-tab +X-EVOLUTION-BLOG-URL: +CALURI: +FBURL: +X-EVOLUTION-VIDEO-URL: +X-MOZILLA-HTML:FALSE +END:VCARD \ No newline at end of file Added: plugins/ldap-sync/tests/vcards/evo2-umlaute.vcf ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/vcards/evo2-umlaute.vcf Sat Apr 11 20:28:01 2009 (r5573) @@ -0,0 +1,54 @@ +BEGIN:VCARD +VERSION:3.0 +FN:Titleö Firstä Middleü Lastß Suffixö +N:Lastß;Firstä;Middleü;Titleö;Suffixö +ORG:organization;department;office +REV:2005-02-26T10:41:24Z +ROLE:profession +TITLE:title +UID:pas-id-421A5F6100000014 +URL:homepage +X-EVOLUTION-FILE-AS:Lastß\, Firstä +X-EVOLUTION-MANAGER:manager +X-EVOLUTION-ASSISTANT:assistant +NICKNAME:nicknameü +BDAY:2005-02-10 +X-EVOLUTION-ANNIVERSARY:2005-02-08 +X-EVOLUTION-SPOUSE:spouse +NOTE:This is a multiline note with special chars\nNote how there are multip + le\nl\ni\nn\ne\ns\nand special chars: öüööüöäüßßß asd +CATEGORIES:Birthday,Business +X-EVOLUTION-BLOG-URL:weblog +CALURI:calendar +FBURL:freebusy +X-EVOLUTION-VIDEO-URL:video chat +X-MOZILLA-HTML:TRUE +ADR;TYPE=WORK:PO-BOX2;Multiline street\nmultiline cityäüööüä;Address2 + ;City2;State2;zip2;country2 +LABEL;TYPE=WORK:Address2\nMultiline street\nmultiline cityäüööüä\nCit + y2\, State2\nzip2\nPO-BOX2\ncountry2 +ADR;TYPE=HOME:PO-BOX1;Multiline street\nmultiline city\nöüä;Address1;Cit + y1;State1;zip1;country1 +LABEL;TYPE=HOME:Address1\nMultiline street\nmultiline city\nöüä\nCity1\, + State1\nzip1\nPO-BOX1\ncountry1 +ADR;TYPE=OTHER:PO-BOX3;Multiline street\nmultiline cityä\nöü;Address3;Ci + ty3;State3;zip3;country3 +LABEL;TYPE=OTHER:Address3\nMultiline street\nmultiline cityä\nöü\nCity3\ + , State3\nzip3\nPO-BOX3\ncountry3 +EMAIL;TYPE=WORK;X-EVOLUTION-UI-SLOT=1:workemailö +EMAIL;TYPE=HOME;X-EVOLUTION-UI-SLOT=2:homeemailü +EMAIL;TYPE=OTHER;X-EVOLUTION-UI-SLOT=3:otheremailü +EMAIL;TYPE=OTHER;X-EVOLUTION-UI-SLOT=4:otheremail2ä +TEL;TYPE="X-EVOLUTION-COMPANY";X-EVOLUTION-UI-SLOT=1:company phoneöä +TEL;TYPE=HOME;TYPE=FAX;X-EVOLUTION-UI-SLOT=2:homefaxöä +TEL;TYPE=FAX;X-EVOLUTION-UI-SLOT=3:other fax +TEL;TYPE=PAGER;X-EVOLUTION-UI-SLOT=4:pagerß +TEL;TYPE=ISDN;X-EVOLUTION-UI-SLOT=5:ISDNä +TEL;TYPE=VOICE;X-EVOLUTION-UI-SLOT=6:other phoneö +TEL;TYPE="X-EVOLUTION-RADIO";X-EVOLUTION-UI-SLOT=7:radioü +TEL;TYPE="X-EVOLUTION-TELEX";X-EVOLUTION-UI-SLOT=8:telexä +X-JABBER;TYPE=HOME;X-EVOLUTION-UI-SLOT=3:jabberüä +X-YAHOO;TYPE=HOME;X-EVOLUTION-UI-SLOT=2:yahooä +X-MSN;TYPE=HOME;X-EVOLUTION-UI-SLOT=1:msnöä +X-GROUPWISE;TYPE=HOME;X-EVOLUTION-UI-SLOT=4:groupwiseä +END:VCARD \ No newline at end of file Added: plugins/ldap-sync/tests/vcards/kdepim-full1-2.1.vcf ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/vcards/kdepim-full1-2.1.vcf Sat Apr 11 20:28:01 2009 (r5573) @@ -0,0 +1,75 @@ +BEGIN:VCARD +ADR;CHARSET=UTF-8;ENCODING=8BIT;TYPE=work:pobox2;;Street1 work;locale2;regi + on2;postalcode2;Germany +ADR;CHARSET=UTF-8;ENCODING=8BIT;TYPE=home;TYPE=pref:pobox1;;HomeAddress1;lo + cal1;region1;postalcode1;Germany +BDAY:2005-02-26T00:00:00Z +EMAIL;CHARSET=UTF-8;ENCODING=8BIT;TYPE=PREF:email1 +EMAIL;CHARSET=UTF-8;ENCODING=8BIT:em...@te... +FN;CHARSET=UTF-8;ENCODING=8BIT:givenname familynames +GEO:52.500000;13.366667 +KEY;ENCODING=b;TYPE=PGP:mQGiBECXtzARBAC99Ll8ePW6FCzq8KUBwEYzo+J/u4EmkgCxgWm + Vzsvj2Uu7/OhwFaGJcv+fBSF+XtGhZeUk+Pcl4x0tMY5H07/k6ObF8+0O164J+Jg5bMlk2I6X1n + UhmAA4aIZCALHwcNZCq9b7HMKr3Sh1eMas2MQ2hL7mTrkfrcxqSNmTA1l/BwCgo+yOOozD6kohz + nRr+8jiYimho30EAJDN9YKkTh3kM1jrc9Q11N7zEnQUXtPC4GqQmW7BXgEmSBErEduk3N9NqnzG + xFruQrpXWisExv4z/t67uBou++m64J/Ad+T6wC19h72U15UVch/4bU7YqACjdlocUBfmnV3njko + Dhl6wmg7fxdCOJfkCXw+VKD9iiqXiSlqFh3IjA/4hdl3npIPKa0EeDnHDSUIbtZAd74i3Lzz1fJ + h5vip5N3alqSynJPmzPCWE7dMzOB/iPb+G50X046QT2OEypN9L5Trd5KJonlg+crN/aUZSjCmCC + foaBiISdox753MkVOipWH15F27KOqPHBNLrCnrYVCLMNpN/4aSbrn7AXzjbELQlQXJtaW4gQmF1 + ZXIgPGFybWluLmJhdWVyQGRlc3Njb24uY29tPoheBBMRAgAeBQJAl7cwAhsDBgsJCAcDAgMVAgM + DFgIBAh4BAheAAAoJEKvc+7/ZPVGpDNQAmwaN2121JO3i3AcRT5ns8KeQU2x2AJ9w5i2jQ5gZ4m + 3jVJPFohsL03i2hbQgQXJtaW4gQmF1ZXIgPGF6cmFlbEBkZXNzY29uLmNvbT6IXgQTEQIAHgUCQ + Je5JQIbAwYLCQgHAwIDFQIDAxYCAQIeAQIXgAAKCRCr3Pu/2T1RqfVrAJ9ANz3hB4TqVahybg8i + XJUfmOtjbACfSLJBPGBI84P/RIEe7FKCDC05ZT65AQ0EQJe3MBAEALFujyLPriDAyh0+u8KXoBf + SSrnyrDnjvhG0gGsyqSfE06JvKDK6q0ZUlRAj/1cbHS+Rb8t6mUN8HquVjPkWG6eNhcGNnRxjc+ + 7OqCiVhN7rt4c2HibVQWLy/8y04/Uqj2F9TwaiiuixIJiVA0tdqdgPxFFSCS6aRJhJ6EBw+rbXA + AMFBACtsn+fb3aQlaFiBurznAHmv/j2X3k2WXtaubPkNKEWf7HyLos0F5vSw0/hh0/YBabdpaK8 + LNNuP3Q0ABPjUzyK7cH5fxHPb8BWKIKvB5aX... [truncated message content] |
From: <svn...@op...> - 2009-04-11 18:27:24
|
Author: scriptor Date: Sat Apr 11 20:27:17 2009 New Revision: 5572 URL: http://www.opensync.org/changeset/5572 Log: New bugs outside of the LDAP plugin must be suppressed. Modified: plugins/ldap-sync/tests/opensync.suppr Modified: plugins/ldap-sync/tests/opensync.suppr ============================================================================== --- plugins/ldap-sync/tests/opensync.suppr Thu Apr 9 23:56:49 2009 (r5571) +++ plugins/ldap-sync/tests/opensync.suppr Sat Apr 11 20:27:17 2009 (r5572) @@ -3896,3 +3896,451 @@ } + +{ + <insert a suppression name here> + Memcheck:Addr1 + fun:strlen + fun:g_pattern_match_simple + fun:detect_plain_as_xmlformat + fun:detect_plain_as_xmlformat_contact + fun:osync_converter_detect + fun:osync_format_converter_path_vertice_validate_path_with_detector + fun:osync_format_converter_path_vertice_get_next_vertice_neighbour + fun:osync_format_env_find_path_fn + fun:osync_format_env_find_path_formats_with_detectors + fun:osync_entry_engine_convert + fun:osync_sink_engine_convert_to_dest + fun:osync_obj_engine_prepare_write + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_multiplied_event + fun:_osync_engine_generate_event + fun:_osync_engine_event_callback + fun:osync_obj_engine_event + fun:osync_obj_engine_command + fun:osync_engine_command + fun:_command_dispatch + fun:g_main_context_dispatch + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_main_loop_run +} + + + + +{ + <insert a suppression name here> + Memcheck:Addr1 + fun:strlen + fun:g_pattern_match_simple + fun:detect_plain_as_xmlformat + fun:detect_plain_as_xmlformat_event + fun:osync_converter_detect + fun:osync_format_converter_path_vertice_validate_path_with_detector + fun:osync_format_converter_path_vertice_get_next_vertice_neighbour + fun:osync_format_env_find_path_fn + fun:osync_format_env_find_path_formats_with_detectors + fun:osync_entry_engine_convert + fun:osync_sink_engine_convert_to_dest + fun:osync_obj_engine_prepare_write + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_multiplied_event + fun:_osync_engine_generate_event + fun:_osync_engine_event_callback + fun:osync_obj_engine_event + fun:osync_obj_engine_command + fun:osync_engine_command + fun:_command_dispatch + fun:g_main_context_dispatch + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_main_loop_run +} + + +{ + <insert a suppression name here> + Memcheck:Addr1 + fun:strlen + fun:g_pattern_match_simple + fun:detect_plain_as_xmlformat + fun:detect_plain_as_xmlformat_todo + fun:osync_converter_detect + fun:osync_format_converter_path_vertice_validate_path_with_detector + fun:osync_format_converter_path_vertice_get_next_vertice_neighbour + fun:osync_format_env_find_path_fn + fun:osync_format_env_find_path_formats_with_detectors + fun:osync_entry_engine_convert + fun:osync_sink_engine_convert_to_dest + fun:osync_obj_engine_prepare_write + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_multiplied_event + fun:_osync_engine_generate_event + fun:_osync_engine_event_callback + fun:osync_obj_engine_event + fun:osync_obj_engine_command + fun:osync_engine_command + fun:_command_dispatch + fun:g_main_context_dispatch + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_main_loop_run +} + + + + + +{ + <insert a suppression name here> + Memcheck:Addr1 + fun:strlen + fun:g_pattern_match_simple + fun:detect_plain_as_xmlformat + fun:detect_plain_as_xmlformat_note + fun:osync_converter_detect + fun:osync_format_converter_path_vertice_validate_path_with_detector + fun:osync_format_converter_path_vertice_get_next_vertice_neighbour + fun:osync_format_env_find_path_fn + fun:osync_format_env_find_path_formats_with_detectors + fun:osync_entry_engine_convert + fun:osync_sink_engine_convert_to_dest + fun:osync_obj_engine_prepare_write + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_multiplied_event + fun:_osync_engine_generate_event + fun:_osync_engine_event_callback + fun:osync_obj_engine_event + fun:osync_obj_engine_command + fun:osync_engine_command + fun:_command_dispatch + fun:g_main_context_dispatch + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_main_loop_run +} + + + + +{ + <insert a suppression name here> + Memcheck:Addr1 + fun:strlen + fun:g_pattern_match_simple + fun:detect_plain_as_vtodo10 + fun:osync_converter_detect + fun:osync_format_converter_path_vertice_validate_path_with_detector + fun:osync_format_converter_path_vertice_get_next_vertice_neighbour + fun:osync_format_env_find_path_fn + fun:osync_format_env_find_path_formats_with_detectors + fun:osync_entry_engine_convert + fun:osync_sink_engine_convert_to_dest + fun:osync_obj_engine_prepare_write + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_multiplied_event + fun:_osync_engine_generate_event + fun:_osync_engine_event_callback + fun:osync_obj_engine_event + fun:osync_obj_engine_command + fun:osync_engine_command + fun:_command_dispatch + fun:g_main_context_dispatch + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_main_loop_run + obj:/lib/libglib-2.0.so.0.1800.3 +} + + + +{ + <insert a suppression name here> + Memcheck:Addr1 + fun:strlen + fun:g_pattern_match_simple + fun:detect_plain_as_vtodo20 + fun:osync_converter_detect + fun:osync_format_converter_path_vertice_validate_path_with_detector + fun:osync_format_converter_path_vertice_get_next_vertice_neighbour + fun:osync_format_env_find_path_fn + fun:osync_format_env_find_path_formats_with_detectors + fun:osync_entry_engine_convert + fun:osync_sink_engine_convert_to_dest + fun:osync_obj_engine_prepare_write + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_multiplied_event + fun:_osync_engine_generate_event + fun:_osync_engine_event_callback + fun:osync_obj_engine_event + fun:osync_obj_engine_command + fun:osync_engine_command + fun:_command_dispatch + fun:g_main_context_dispatch + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_main_loop_run + obj:/lib/libglib-2.0.so.0.1800.3 +} + + + +{ + <insert a suppression name here> + Memcheck:Addr1 + fun:strlen + fun:g_pattern_match_simple + fun:detect_plain_as_vnote + fun:osync_converter_detect + fun:osync_format_converter_path_vertice_validate_path_with_detector + fun:osync_format_converter_path_vertice_get_next_vertice_neighbour + fun:osync_format_env_find_path_fn + fun:osync_format_env_find_path_formats_with_detectors + fun:osync_entry_engine_convert + fun:osync_sink_engine_convert_to_dest + fun:osync_obj_engine_prepare_write + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_multiplied_event + fun:_osync_engine_generate_event + fun:_osync_engine_event_callback + fun:osync_obj_engine_event + fun:osync_obj_engine_command + fun:osync_engine_command + fun:_command_dispatch + fun:g_main_context_dispatch + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_main_loop_run + obj:/lib/libglib-2.0.so.0.1800.3 +} + + + + +{ + <insert a suppression name here> + Memcheck:Addr1 + fun:strlen + fun:g_pattern_match_simple + fun:detect_plain_as_vcard21 + fun:osync_converter_detect + fun:osync_format_converter_path_vertice_validate_path_with_detector + fun:osync_format_converter_path_vertice_get_next_vertice_neighbour + fun:osync_format_env_find_path_fn + fun:osync_format_env_find_path_formats_with_detectors + fun:osync_entry_engine_convert + fun:osync_sink_engine_convert_to_dest + fun:osync_obj_engine_prepare_write + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_multiplied_event + fun:_osync_engine_generate_event + fun:_osync_engine_event_callback + fun:osync_obj_engine_event + fun:osync_obj_engine_command + fun:osync_engine_command + fun:_command_dispatch + fun:g_main_context_dispatch + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_main_loop_run + obj:/lib/libglib-2.0.so.0.1800.3 +} + + + + + +{ + <insert a suppression name here> + Memcheck:Addr1 + fun:strlen + fun:g_pattern_match_simple + fun:detect_plain_as_vcard30 + fun:osync_converter_detect + fun:osync_format_converter_path_vertice_validate_path_with_detector + fun:osync_format_converter_path_vertice_get_next_vertice_neighbour + fun:osync_format_env_find_path_fn + fun:osync_format_env_find_path_formats_with_detectors + fun:osync_entry_engine_convert + fun:osync_sink_engine_convert_to_dest + fun:osync_obj_engine_prepare_write + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_multiplied_event + fun:_osync_engine_generate_event + fun:_osync_engine_event_callback + fun:osync_obj_engine_event + fun:osync_obj_engine_command + fun:osync_engine_command + fun:_command_dispatch + fun:g_main_context_dispatch + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_main_loop_run + obj:/lib/libglib-2.0.so.0.1800.3 +} + + + + + +{ + <insert a suppression name here> + Memcheck:Addr1 + fun:strlen + fun:g_pattern_match_simple + fun:detect_plain_as_vevent10 + fun:osync_converter_detect + fun:osync_format_converter_path_vertice_validate_path_with_detector + fun:osync_format_converter_path_vertice_get_next_vertice_neighbour + fun:osync_format_env_find_path_fn + fun:osync_format_env_find_path_formats_with_detectors + fun:osync_entry_engine_convert + fun:osync_sink_engine_convert_to_dest + fun:osync_obj_engine_prepare_write + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_multiplied_event + fun:_osync_engine_generate_event + fun:_osync_engine_event_callback + fun:osync_obj_engine_event + fun:osync_obj_engine_command + fun:osync_engine_command + fun:_command_dispatch + fun:g_main_context_dispatch + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_main_loop_run + obj:/lib/libglib-2.0.so.0.1800.3 +} + + + + +{ + <insert a suppression name here> + Memcheck:Addr1 + fun:strlen + fun:g_pattern_match_simple + fun:detect_plain_as_vevent20 + fun:osync_converter_detect + fun:osync_format_converter_path_vertice_validate_path_with_detector + fun:osync_format_converter_path_vertice_get_next_vertice_neighbour + fun:osync_format_env_find_path_fn + fun:osync_format_env_find_path_formats_with_detectors + fun:osync_entry_engine_convert + fun:osync_sink_engine_convert_to_dest + fun:osync_obj_engine_prepare_write + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_multiplied_event + fun:_osync_engine_generate_event + fun:_osync_engine_event_callback + fun:osync_obj_engine_event + fun:osync_obj_engine_command + fun:osync_engine_command + fun:_command_dispatch + fun:g_main_context_dispatch + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_main_loop_run + obj:/lib/libglib-2.0.so.0.1800.3 +} + + + + + + +{ + <insert a suppression name here> + Memcheck:Addr1 + fun:strlen + fun:g_pattern_match_simple + fun:detect_plain_as_vjournal + fun:osync_converter_detect + fun:osync_format_converter_path_vertice_validate_path_with_detector + fun:osync_format_converter_path_vertice_get_next_vertice_neighbour + fun:osync_format_env_find_path_fn + fun:osync_format_env_find_path_formats_with_detectors + fun:osync_entry_engine_convert + fun:osync_sink_engine_convert_to_dest + fun:osync_obj_engine_prepare_write + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_multiplied_event + fun:_osync_engine_generate_event + fun:_osync_engine_event_callback + fun:osync_obj_engine_event + fun:osync_obj_engine_command + fun:osync_engine_command + fun:_command_dispatch + fun:g_main_context_dispatch + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_main_loop_run + obj:/lib/libglib-2.0.so.0.1800.3 +} + + +{ + <insert a suppression name here> + Memcheck:Addr1 + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_pattern_match + fun:g_pattern_match_simple + fun:detect_plain_as_vjournal + fun:osync_converter_detect + fun:osync_format_converter_path_vertice_validate_path_with_detector + fun:osync_format_converter_path_vertice_get_next_vertice_neighbour + fun:osync_format_env_find_path_fn + fun:osync_format_env_find_path_formats_with_detectors + fun:osync_entry_engine_convert + fun:osync_sink_engine_convert_to_dest + fun:osync_obj_engine_prepare_write + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_multiplied_event + fun:_osync_engine_generate_event + fun:_osync_engine_event_callback + fun:osync_obj_engine_event + fun:osync_obj_engine_command + fun:osync_engine_command + fun:_command_dispatch + fun:g_main_context_dispatch + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_main_loop_run +} + + + +{ + <insert a suppression name here> + Memcheck:Addr1 + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_pattern_match + fun:g_pattern_match_simple + fun:detect_plain_as_vjournal + fun:osync_converter_detect + fun:osync_format_converter_path_vertice_validate_path_with_detector + fun:osync_format_converter_path_vertice_get_next_vertice_neighbour + fun:osync_format_env_find_path_fn + fun:osync_format_env_find_path_formats_with_detectors + fun:osync_entry_engine_convert + fun:osync_sink_engine_convert_to_dest + fun:osync_obj_engine_prepare_write + fun:osync_obj_engine_command + fun:osync_engine_event + fun:_osync_engine_generate_multiplied_event + fun:_osync_engine_generate_event + fun:_osync_engine_event_callback + fun:osync_obj_engine_event + fun:osync_obj_engine_command + fun:osync_engine_command + fun:_command_dispatch + fun:g_main_context_dispatch + obj:/lib/libglib-2.0.so.0.1800.3 + fun:g_main_loop_run +} + + + + + |
From: <svn...@op...> - 2009-04-09 21:56:53
|
Author: cdfrey Date: Thu Apr 9 23:56:49 2009 New Revision: 5571 URL: http://www.opensync.org/changeset/5571 Log: Fixed inverted error check in sample plugin code when doing a hashtable slowsync Modified: trunk/docs/examples/plugins/src/plugin.c Modified: trunk/docs/examples/plugins/src/plugin.c ============================================================================== --- trunk/docs/examples/plugins/src/plugin.c Thu Apr 9 23:11:41 2009 (r5570) +++ trunk/docs/examples/plugins/src/plugin.c Thu Apr 9 23:56:49 2009 (r5571) @@ -76,7 +76,7 @@ if (slow_sync) { osync_trace(TRACE_INTERNAL, "Slow sync requested"); - if (osync_hashtable_slowsync(hashtable, &error)) { + if (!osync_hashtable_slowsync(hashtable, &error)) { osync_context_report_osyncerror(ctx, error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); osync_error_unref(&error); |
From: <svn...@op...> - 2009-04-09 21:11:45
|
Author: henrik Date: Thu Apr 9 23:11:41 2009 New Revision: 5570 URL: http://www.opensync.org/changeset/5570 Log: Add error checking for NS_NewNativeLocalFile Modified: plugins/mozilla-sync/trunk/src/mozilla-xpcom.cpp Modified: plugins/mozilla-sync/trunk/src/mozilla-xpcom.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-xpcom.cpp Thu Apr 9 22:41:48 2009 (r5569) +++ plugins/mozilla-sync/trunk/src/mozilla-xpcom.cpp Thu Apr 9 23:11:41 2009 (r5570) @@ -232,6 +232,7 @@ nsCOMPtr<nsILocalFile> localFileGreComponents; rv = NS_NewNativeLocalFile(csGreComponents, PR_TRUE, getter_AddRefs(localFileGreComponents)); + if (NS_FAILED(rv)) LOG(0, "Could not get NewNativeLocalFile for GRE components"); rv=registrar->AutoRegister(localFileGreComponents); //MOZ_ERROR_CHECK_FALSE(rv, "AutoRegister"); if (NS_FAILED(rv)) LOG(0, "AutoRegister failed. Continuing anyway..."); |
From: <svn...@op...> - 2009-04-09 20:42:06
|
Author: henrik Date: Thu Apr 9 22:41:48 2009 New Revision: 5569 URL: http://www.opensync.org/changeset/5569 Log: Removed batchcommit_timeout which was not used and now removed from OpenSync API Modified: plugins/mozilla-sync/trunk/src/mozilla-sync.cpp Modified: plugins/mozilla-sync/trunk/src/mozilla-sync.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-sync.cpp Thu Apr 9 10:43:39 2009 (r5568) +++ plugins/mozilla-sync/trunk/src/mozilla-sync.cpp Thu Apr 9 22:41:48 2009 (r5569) @@ -801,7 +801,6 @@ // TODO: Check the exact meaning of each timeout, and ajust accordingly osync_objtype_sink_set_getchanges_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes osync_objtype_sink_set_commit_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes - osync_objtype_sink_set_batchcommit_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes osync_objtype_sink_set_committedall_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes osync_objtype_sink_set_syncdone_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes osync_objtype_sink_set_read_timeout(pOSyncObjTypeSink, 4*60); // 4 minutes @@ -1059,7 +1058,6 @@ osync_objtype_sink_set_disconnect_timeout(sink, 5*60); // 4 minutes osync_objtype_sink_set_getchanges_timeout(sink, 5*60); // 4 minutes osync_objtype_sink_set_commit_timeout(sink, 5*60); // 4 minutes - osync_objtype_sink_set_batchcommit_timeout(sink, 5*60); // 4 minutes osync_objtype_sink_set_committedall_timeout(sink, 5*60); // 4 minutes osync_objtype_sink_set_syncdone_timeout(sink, 5*60); // 4 minutes osync_objtype_sink_set_read_timeout(sink, 5*60); // 4 minutes |
From: <svn...@op...> - 2009-04-09 13:42:25
|
Author: bellmich Date: Thu Apr 9 15:42:16 2009 New Revision: 1038 URL: http://libsyncml.opensync.org/changeset/1038 Log: implemented dynamic test generation controlled by cmake Modified: trunk/tests/CMakeLists.txt trunk/tests/check_base64.c trunk/tests/check_data_sync_api.c trunk/tests/check_devinf.c trunk/tests/check_ds.c trunk/tests/check_elements.c trunk/tests/check_http.c trunk/tests/check_libsoup.c trunk/tests/check_manager.c trunk/tests/check_md5.c trunk/tests/check_obex.c trunk/tests/check_san.c trunk/tests/check_session.c trunk/tests/check_sync.c trunk/tests/check_wbxml_assembler.c trunk/tests/check_wbxml_parser.c trunk/tests/check_xml_assembler.c trunk/tests/check_xml_fix_broken_item_data.c trunk/tests/check_xml_parser.c Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/CMakeLists.txt Thu Apr 9 15:42:16 2009 (r1038) @@ -69,32 +69,302 @@ SML_ADD_TESTCASE( error_class ) SML_END_TEST() - ADD_CHECK_TEST( elements check_elements.c ${TEST_TARGET_LIBRARIES} ) - ADD_CHECK_TEST( xml-fix-broken-item-data check_xml_fix_broken_item_data.c ${TEST_TARGET_LIBRARIES} ) - ADD_CHECK_TEST( xmlparser check_xml_parser.c ${TEST_TARGET_LIBRARIES} ) - ADD_CHECK_TEST( xmlassembler check_xml_assembler.c ${TEST_TARGET_LIBRARIES} ) - ADD_CHECK_TEST( session check_session.c ${TEST_TARGET_LIBRARIES} ) - ADD_CHECK_TEST( md5 check_md5.c ${TEST_TARGET_LIBRARIES} ) - ADD_CHECK_TEST( datasync check_ds.c ${TEST_TARGET_LIBRARIES} ) - ADD_CHECK_TEST( san check_san.c ${TEST_TARGET_LIBRARIES} ) - ADD_CHECK_TEST( devinf check_devinf.c ${TEST_TARGET_LIBRARIES} ) - ADD_CHECK_TEST( sync check_sync.c ${TEST_TARGET_LIBRARIES} ) + SML_START_TEST( "Elements" elements check_elements.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( location_new ) + SML_ADD_TESTCASE( location_new2 ) + SML_ADD_TESTCASE( location_new3 ) + SML_ADD_TESTCASE( location_compare_rel ) + SML_ADD_TESTCASE( location_compare_rel1 ) + SML_ADD_TESTCASE( location_compare_rel2 ) + SML_ADD_TESTCASE( location_compare_abs ) + SML_ADD_TESTCASE( location_compare_abs2 ) + SML_ADD_TESTCASE( location_compare_combined ) + SML_ADD_TESTCASE( location_compare_combined2 ) + SML_ADD_TESTCASE( location_compare_combined3 ) + SML_ADD_TESTCASE( location_compare_combined4 ) + SML_ADD_TESTCASE( location_compare_combined5 ) + SML_ADD_TESTCASE( location_compare_combined6 ) + SML_END_TEST() + + SML_START_TEST( "XML fix broken Item Data" xml-fix-broken-item-data check_xml_fix_broken_item_data.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( xml_fix_broken_item_data_no_item ) + SML_ADD_TESTCASE( xml_fix_broken_item_data_no_item_data ) + SML_ADD_TESTCASE( xml_fix_broken_item_data_no_broken_item_data ) + SML_ADD_TESTCASE( xml_fix_broken_item_data_one_broken_item_data ) + SML_ADD_TESTCASE( xml_fix_broken_item_data_multi_broken_item_data ) + SML_ADD_TESTCASE( xml_fix_broken_item_data_mixed_broken_item_data ) + SML_ADD_TESTCASE( xml_fix_broken_item_data_utf16_conversion ) + SML_END_TEST() + + SML_START_TEST( "XML Parser" xmlparser check_xml_parser.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( xml_parser_empty ) + SML_ADD_TESTCASE( xml_parser_syncml_empty ) + SML_ADD_TESTCASE( xml_parser_syncml_wrong_case ) + SML_ADD_TESTCASE( xml_parser_syncml_additional ) + SML_ADD_TESTCASE( xml_parser_no_syncbody ) + SML_ADD_TESTCASE( xml_parser_no_synchdr ) + SML_ADD_TESTCASE( xml_parser_synchdr_empty ) + SML_ADD_TESTCASE( xml_parser_synchdr_verproto ) + SML_ADD_TESTCASE( xml_parser_synchdr_verdtd ) + SML_ADD_TESTCASE( xml_parser_synchdr_msgid ) + SML_ADD_TESTCASE( xml_parser_synchdr_sessionid ) + SML_ADD_TESTCASE( xml_parser_synchdr_additional ) + SML_ADD_TESTCASE( xml_parser_synchdr_target ) + SML_ADD_TESTCASE( xml_parser_synchdr_source ) + SML_ADD_TESTCASE( xml_parser_synchdr_source2 ) + SML_ADD_TESTCASE( xml_parser_status_empty ) + SML_ADD_TESTCASE( xml_parser_status_cmdid ) + SML_ADD_TESTCASE( xml_parser_status_msgref ) + SML_ADD_TESTCASE( xml_parser_status_cmdref ) + SML_ADD_TESTCASE( xml_parser_status ) + SML_ADD_TESTCASE( xml_parser_status2 ) + SML_ADD_TESTCASE( xml_parser_status3 ) + SML_ADD_TESTCASE( xml_parser_final ) + SML_ADD_TESTCASE( xml_parser_final2 ) + SML_ADD_TESTCASE( xml_parser_cmd ) + SML_ADD_TESTCASE( xml_parser_cmd_final ) + SML_ADD_TESTCASE( xml_parser_sync_subcommand ) + SML_ADD_TESTCASE( xml_parser_doctype ) + SML_ADD_TESTCASE( xml_parser_emi ) + SML_ADD_TESTCASE( xml_parser_large_obj ) + SML_ADD_TESTCASE( xml_parser_large_obj2 ) + SML_ADD_TESTCASE( xml_parser_large_obj_error ) + SML_ADD_TESTCASE( xml_parser_large_obj_mangled ) + SML_ADD_TESTCASE( xml_parser_devinf ) + SML_ADD_TESTCASE( xml_parser_devinf_ctcap ) + SML_ADD_TESTCASE( xml_parser_devinf12 ) + SML_ADD_TESTCASE( xml_parser_empty_data_element ) + SML_ADD_TESTCASE( xml_parser_msgref_zero ) + SML_ADD_TESTCASE( xml_parser_ctcap_property_size ) + SML_ADD_TESTCASE( xml_parser_ctcap11_size ) + SML_ADD_TESTCASE( xml_parser_item_with_meta_in_status ) + SML_END_TEST() + + SML_START_TEST( "XML Assembler" xmlassembler check_xml_assembler.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( xml_assembler_message_empty ) + SML_ADD_TESTCASE( xml_assembler_message_only_header ) + SML_ADD_TESTCASE( xml_assembler_message_status ) + SML_ADD_TESTCASE( xml_assembler_message_cmd ) + SML_ADD_TESTCASE( xml_assembler_message_subcmd ) + SML_ADD_TESTCASE( xml_assembler_message_several_subcmd ) + SML_ADD_TESTCASE( xml_assembler_message_flush_open ) + SML_ADD_TESTCASE( xml_assembler_out_of_order ) + SML_ADD_TESTCASE( xml_assembler_limit1 ) + SML_ADD_TESTCASE( xml_assembler_limit2 ) + SML_ADD_TESTCASE( xml_assembler_limit3 ) + SML_ADD_TESTCASE( xml_assembler_limit4 ) + SML_ADD_TESTCASE( xml_assembler_limit5 ) + SML_ADD_TESTCASE( xml_assembler_devinf ) + SML_ADD_TESTCASE( xml_assembler_devinf12 ) + SML_ADD_TESTCASE( xml_assembler_order ) + SML_ADD_TESTCASE( xml_assembler_reuse ) + SML_ADD_TESTCASE( xml_assembler_leak ) + SML_ADD_TESTCASE( xml_assembler_stress ) + SML_ADD_TESTCASE( xml_assembler_stress_limit ) + SML_ADD_TESTCASE( xml_assembler_stress_large_limit ) + SML_ADD_TESTCASE( xml_assembler_large_obj ) + SML_END_TEST() + + SML_START_TEST( "Session" session check_session.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( session_new ) + SML_ADD_TESTCASE( session_send ) + SML_ADD_TESTCASE( session_flush ) + SML_ADD_TESTCASE( session_flush_final ) + SML_ADD_TESTCASE( session_recv ) + SML_ADD_TESTCASE( session_transmit ) + SML_ADD_TESTCASE( session_reply ) + SML_ADD_TESTCASE( session_talk ) + SML_ADD_TESTCASE( session_talk_alot ) + SML_ADD_TESTCASE( session_talk_alot_limit ) + SML_ADD_TESTCASE( session_limit_remote ) + SML_ADD_TESTCASE( session_split_child ) + SML_ADD_TESTCASE( session_recv_large_obj ) + SML_ADD_TESTCASE( session_recv_large_obj2 ) + SML_ADD_TESTCASE( session_recv_wrong_order ) + SML_ADD_TESTCASE( session_large_obj_10 ) + SML_ADD_TESTCASE( session_large_obj_open ) + SML_ADD_TESTCASE( session_large_obj_no_size ) + SML_ADD_TESTCASE( session_large_obj_several_size ) + SML_ADD_TESTCASE( session_recv_large_wrong_size ) + SML_ADD_TESTCASE( session_recv_large_wrong_size2 ) + SML_ADD_TESTCASE( session_send_large_obj ) + SML_ADD_TESTCASE( session_send_large_obj2 ) + SML_ADD_TESTCASE( session_send_multi_large_obj ) + SML_ADD_TESTCASE( session_send_multi_large_obj_alter ) + IF ( ENABLE_HTTP ) + SML_ADD_TESTCASE( session_san ) + ENDIF ( ENABLE_HTTP ) + SML_END_TEST() + + SML_START_TEST( "MD5" md5 check_md5.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( md5_1 ) + SML_ADD_TESTCASE( md5_2 ) + SML_ADD_TESTCASE( md5_3 ) + SML_ADD_TESTCASE( md5_4 ) + SML_ADD_TESTCASE( md5_5 ) + SML_ADD_TESTCASE( md5_6 ) + SML_ADD_TESTCASE( md5_7 ) + SML_END_TEST() + + SML_START_TEST( "DataSync" datasync check_ds.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( ds_server_new ) + SML_ADD_TESTCASE( ds_client_new ) + SML_ADD_TESTCASE( ds_send_alert ) + SML_ADD_TESTCASE( ds_send_alert2 ) + SML_ADD_TESTCASE( ds_send_empty_sync ) + SML_ADD_TESTCASE( ds_reply_empty_sync ) + SML_ADD_TESTCASE( ds_add ) + SML_ADD_TESTCASE( ds_add2 ) + SML_ADD_TESTCASE( ds_delete ) + SML_ADD_TESTCASE( ds_map_full ) + SML_ADD_TESTCASE( ds_add_large ) + SML_ADD_TESTCASE( ds_limit ) + SML_END_TEST() + + SML_START_TEST( "SAN" san check_san.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( san_new ) + SML_ADD_TESTCASE( san_empty ) + SML_ADD_TESTCASE( san_empty2 ) + SML_ADD_TESTCASE( san_alert ) + SML_ADD_TESTCASE( san_alert2 ) + SML_ADD_TESTCASE( san_alert_auth ) + SML_ADD_TESTCASE( san_parse ) + SML_ADD_TESTCASE( san_parse2 ) + IF ( ENABLE_HTTP ) + SML_ADD_TESTCASE( san_11_assemble_parse ) + ENDIF ( ENABLE_HTTP ) + SML_ADD_TESTCASE( san_parse_error ) + SML_ADD_TESTCASE( san_parse_error2 ) + SML_ADD_TESTCASE( san_parse_error3 ) + SML_ADD_TESTCASE( san_parse_error4 ) + SML_ADD_TESTCASE( san_parse_error5 ) + SML_ADD_TESTCASE( san_parse_error6 ) + SML_ADD_TESTCASE( san_parse_error7 ) + SML_END_TEST() + + SML_START_TEST( "DevInf" devinf check_devinf.c ${TEST_TARGET_LIBRARIES} ) + IF( ENABLE_HTTP ) + SML_ADD_TESTCASE( devinf_crash ) + SML_ADD_TESTCASE( devinf_result ) + ENDIF( ENABLE_HTTP ) + SML_ADD_TESTCASE( devinf_max_size_element ) + SML_END_TEST() + + SML_START_TEST( "Sync" sync check_sync.c ${TEST_TARGET_LIBRARIES} ) + IF ( ENABLE_HTTP ) + SML_ADD_TESTCASE( sync_multi_start ) + SML_ADD_TESTCASE( sync_multi_stress ) + SML_ADD_TESTCASE( sync_multi_stress2 ) + SML_ADD_TESTCASE( sync_multi_conf_from_devinf ) + ENDIF ( ENABLE_HTTP ) + IF ( ENABLE_OBEX AND ENABLE_OPENOBEX_TCP ) + SML_ADD_TESTCASE( sync_send_san ) + SML_ADD_TESTCASE( sync_send_san12 ) + ENDIF ( ENABLE_OBEX AND ENABLE_OPENOBEX_TCP ) + SML_END_TEST() # dependent tests IF( ENABLE_OBEX AND ENABLE_OPENOBEX_TCP ) - ADD_CHECK_TEST( obex check_obex.c ${TEST_TARGET_LIBRARIES} ) + SML_START_TEST( "OBEX" obex check_obex.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( obex_get_result_macro ) + SML_ADD_TESTCASE( obex_client_new ) + SML_ADD_TESTCASE( obex_client_init ) + SML_ADD_TESTCASE( obex_server_new ) + SML_ADD_TESTCASE( obex_server_init ) + SML_ADD_TESTCASE( obex_connect ) + SML_ADD_TESTCASE( obex_send ) + SML_ADD_TESTCASE( obex_reply ) + SML_ADD_TESTCASE( obex_talk ) + SML_ADD_TESTCASE( obex_multi_connect ) + SML_ADD_TESTCASE( obex_multi_stress ) + SML_ADD_TESTCASE( obex_connect_error ) + SML_ADD_TESTCASE( obex_reject ) + SML_ADD_TESTCASE( obex_multi_partial_error ) + SML_END_TEST() ENDIF( ENABLE_OBEX AND ENABLE_OPENOBEX_TCP ) IF ( ENABLE_HTTP ) - ADD_CHECK_TEST( libsoup check_libsoup.c ${TEST_TARGET_LIBRARIES} ) - ADD_CHECK_TEST( http check_http.c ${TEST_TARGET_LIBRARIES} ) - ADD_CHECK_TEST( manager check_manager.c ${TEST_TARGET_LIBRARIES} ) + SML_START_TEST( "libsoup" libsoup check_libsoup.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( libsoup_async ) + SML_ADD_TESTCASE( libsoup_http_client ) + SML_ADD_TESTCASE( libsoup_http_server ) + SML_END_TEST() + + SML_START_TEST( "HTTP" http check_http.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( http_client_new ) + SML_ADD_TESTCASE( http_client_init ) + # TODO: Review testcase. Obsolate? + # SML_ADD_TESTCASE( http_client_wrong_port ) + SML_ADD_TESTCASE( http_client_init_no_url ) + SML_ADD_TESTCASE( http_server_new ) + SML_ADD_TESTCASE( http_server_init ) + SML_ADD_TESTCASE( http_server_wrong_port ) + SML_ADD_TESTCASE( http_connect ) + SML_ADD_TESTCASE( http_send ) + SML_ADD_TESTCASE( http_receive ) + SML_ADD_TESTCASE( http_reply ) + SML_ADD_TESTCASE( http_talk ) + SML_ADD_TESTCASE( http_connect_error ) + SML_ADD_TESTCASE( http_reject ) + SML_ADD_TESTCASE( http_multi_connect ) + SML_ADD_TESTCASE( http_multi_partial_error ) + SML_ADD_TESTCASE( http_multi_stress ) + SML_END_TEST() + + SML_START_TEST( "Manager" manager check_manager.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( manager_new ) + SML_ADD_TESTCASE( manager_run ) + SML_ADD_TESTCASE( manager_receive ) + SML_ADD_TESTCASE( manager_receive_session ) + SML_ADD_TESTCASE( manager_end_session ) + SML_ADD_TESTCASE( manager_register ) + SML_ADD_TESTCASE( manager_start_session ) + SML_END_TEST() ENDIF ( ENABLE_HTTP ) IF ( ENABLE_WBXML ) - ADD_CHECK_TEST( wbxmlparser check_wbxml_parser.c ${TEST_TARGET_LIBRARIES} ) - ADD_CHECK_TEST( wbxmlassembler check_wbxml_assembler.c ${TEST_TARGET_LIBRARIES} ) + SML_START_TEST( "WBXML Parser" wbxmlparser check_wbxml_parser.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( wbxml_parser_syncml_empty ) + SML_ADD_TESTCASE( wbxml_parser_no_syncbody ) + SML_ADD_TESTCASE( wbxml_parser_no_synchdr ) + SML_ADD_TESTCASE( wbxml_parser_synchdr_empty ) + SML_ADD_TESTCASE( wbxml_parser_synchdr_verproto ) + SML_ADD_TESTCASE( wbxml_parser_synchdr_verdtd ) + SML_ADD_TESTCASE( wbxml_parser_synchdr_msgid ) + SML_ADD_TESTCASE( wbxml_parser_synchdr_sessionid ) + SML_ADD_TESTCASE( wbxml_parser_synchdr_additional ) + SML_ADD_TESTCASE( wbxml_parser_synchdr_target ) + SML_ADD_TESTCASE( wbxml_parser_synchdr_source ) + SML_ADD_TESTCASE( wbxml_parser_synchdr_source2 ) + SML_ADD_TESTCASE( wbxml_parser_status_empty ) + SML_ADD_TESTCASE( wbxml_parser_status_cmdid ) + SML_ADD_TESTCASE( wbxml_parser_status_msgref ) + SML_ADD_TESTCASE( wbxml_parser_status_cmdref ) + SML_ADD_TESTCASE( wbxml_parser_status ) + SML_ADD_TESTCASE( wbxml_parser_status2 ) + SML_ADD_TESTCASE( wbxml_parser_final ) + SML_ADD_TESTCASE( wbxml_parser_final2 ) + SML_ADD_TESTCASE( wbxml_parser_cmd ) + SML_ADD_TESTCASE( wbxml_parser_cmd_final ) + SML_END_TEST() + + SML_START_TEST( "WBXML Assembler" wbxmlassembler check_wbxml_assembler.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( wbxml_assembler_message_empty ) + SML_ADD_TESTCASE( wbxml_assembler_message_only_header ) + SML_ADD_TESTCASE( wbxml_assembler_message_status ) + SML_ADD_TESTCASE( wbxml_assembler_message_cmd ) + SML_ADD_TESTCASE( wbxml_assembler_message_subcmd ) + SML_ADD_TESTCASE( wbxml_assembler_message_several_subcmd ) + SML_ADD_TESTCASE( wbxml_assembler_message_flush_open ) + SML_ADD_TESTCASE( wbxml_assembler_out_of_order ) + SML_ADD_TESTCASE( wbxml_assembler_limit1 ) + SML_ADD_TESTCASE( wbxml_assembler_limit2 ) + SML_ADD_TESTCASE( wbxml_assembler_limit3 ) + SML_ADD_TESTCASE( wbxml_assembler_limit4 ) + SML_ADD_TESTCASE( wbxml_assembler_limit5 ) + SML_ADD_TESTCASE( wbxml_assembler_complex1 ) + SML_END_TEST() ENDIF( ENABLE_WBXML ) IF ( ENABLE_OBEX AND ENABLE_OPENOBEX_TCP AND ENABLE_WBXML AND ENABLE_GLIB2_GREGEX ) @@ -109,14 +379,35 @@ ENDIF ( ENABLE_OBEX AND ENABLE_OPENOBEX_TCP AND ENABLE_WBXML AND ENABLE_GLIB2_GREGEX ) IF ( ENABLE_OPENOBEX_TCP OR ENABLE_HTTP ) - ADD_CHECK_TEST( ds_api check_data_sync_api.c ${TEST_TARGET_LIBRARIES} ) + SML_START_TEST( "OMA DS API" ds_api check_data_sync_api.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( ds_api_text_vcard_21 ) + SML_ADD_TESTCASE( ds_api_image_jpeg ) + SML_ADD_TESTCASE( ds_api_unknown_ct ) + SML_ADD_TESTCASE( ds_api_multi_text_vcard_21 ) + SML_END_TEST() ENDIF ( ENABLE_OPENOBEX_TCP OR ENABLE_HTTP ) # tests of deprecated stuff # such tests produce compiler warnings IF ( ENABLE_BASE64_TEST ) - ADD_CHECK_TEST( base64 check_base64.c ${TEST_TARGET_LIBRARIES} ) + SML_START_TEST( "base64" base64 check_base64.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( base64_decode_null ) + SML_ADD_TESTCASE( base64_decode_null2 ) + SML_ADD_TESTCASE( base64_decode_test ) + SML_ADD_TESTCASE( base64_decode_size ) + SML_ADD_TESTCASE( base64_decode2 ) + SML_ADD_TESTCASE( base64_decode3 ) + SML_ADD_TESTCASE( base64_decode4 ) + SML_ADD_TESTCASE( base64_invalid1 ) + SML_ADD_TESTCASE( base64_empty ) + # SML_ADD_TESTCASE( base64_invalid2 ) + SML_ADD_TESTCASE( base64_encode_null ) + SML_ADD_TESTCASE( base64_encode_null2 ) + SML_ADD_TESTCASE( base64_encode_test ) + SML_ADD_TESTCASE( base64_encode_test2 ) + SML_ADD_TESTCASE( base64_encode_test3 ) + SML_END_TEST() ENDIF ( ENABLE_BASE64_TEST ) ENDIF( ENABLE_UNIT_TEST ) Modified: trunk/tests/check_base64.c ============================================================================== --- trunk/tests/check_base64.c Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/check_base64.c Thu Apr 9 15:42:16 2009 (r1038) @@ -18,7 +18,7 @@ * */ -#include "support.h" +#include "tests/support.h" START_TEST (check_base64_decode_null) { @@ -241,46 +241,5 @@ } END_TEST -Suite *base64_suite(void) -{ - Suite *s = suite_create("Base64"); - //Suite *s2 = suite_create("Base64"); - - create_case(s, "check_base64_decode_null", check_base64_decode_null); - create_case(s, "check_base64_decode_null2", check_base64_decode_null2); - create_case(s, "check_base64_decode_test", check_base64_decode_test); - create_case(s, "check_base64_decode_size", check_base64_decode_size); - create_case(s, "check_base64_decode2", check_base64_decode2); - create_case(s, "check_base64_decode3", check_base64_decode3); - create_case(s, "check_base64_decode4", check_base64_decode4); - create_case(s, "check_base64_invalid1", check_base64_invalid1); - create_case(s, "check_base64_empty", check_base64_empty); - // create_case(s, "check_base64_invalid2", check_base64_invalid2); - - create_case(s, "check_base64_encode_null", check_base64_encode_null); - create_case(s, "check_base64_encode_null2", check_base64_encode_null2); - create_case(s, "check_base64_encode_test", check_base64_encode_test); - create_case(s, "check_base64_encode_test2", check_base64_encode_test2); - create_case(s, "check_base64_encode_test3", check_base64_encode_test3); - - return s; -} - -int main(void) -{ - configure_environment(); - - int nf; - - Suite *s = base64_suite(); - - SRunner *sr; - sr = srunner_create(s); - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - - cleanup_environment(); +@SML_TESTCASE_CODE@ - return (nf == 0) ? 0 : 1; -} Modified: trunk/tests/check_data_sync_api.c ============================================================================== --- trunk/tests/check_data_sync_api.c Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/check_data_sync_api.c Thu Apr 9 15:42:16 2009 (r1038) @@ -18,7 +18,7 @@ * */ -#include "support.h" +#include "tests/support.h" #include <libsyncml/syncml.h> #include <libsyncml/syncml_internals.h> @@ -374,7 +374,7 @@ sml_fail_unless(FALSE, "%s", smlErrorPrint(&error)); } -START_TEST (check_text_vcard_21) +START_TEST (ds_api_text_vcard_21) { SmlError *error = NULL; init_testbed("HTTP", "17001"); @@ -410,7 +410,7 @@ } END_TEST -START_TEST (check_image_jpeg) +START_TEST (ds_api_image_jpeg) { SmlError *error = NULL; init_testbed("OBEX", "17002"); @@ -449,7 +449,7 @@ } END_TEST -START_TEST (check_unknown_ct) +START_TEST (ds_api_unknown_ct) { SmlError *error = NULL; init_testbed("HTTP", "17003"); @@ -485,7 +485,7 @@ } END_TEST -START_TEST (check_multi_text_vcard_21) +START_TEST (ds_api_multi_text_vcard_21) { SmlError *error = NULL; init_testbed("HTTP", "17004"); @@ -525,34 +525,5 @@ } END_TEST -Suite *ds_suite(void) -{ - Suite *s = suite_create("OMA DS API"); - //Suite *s2 = suite_create("OMA DS API"); - - create_case(s, "check_text_vcard_21", check_text_vcard_21); - create_case(s, "check_image_jpeg", check_image_jpeg); - create_case(s, "check_unknown_ct", check_unknown_ct); - create_case(s, "check_multi_text_vcard_21", check_multi_text_vcard_21); - - return s; -} - -int main(void) -{ - configure_environment(); +@SML_TESTCASE_CODE@ - int nf; - - Suite *s = ds_suite(); - - SRunner *sr; - sr = srunner_create(s); - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - - cleanup_environment(); - - return (nf == 0) ? 0 : 1; -} Modified: trunk/tests/check_devinf.c ============================================================================== --- trunk/tests/check_devinf.c Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/check_devinf.c Thu Apr 9 15:42:16 2009 (r1038) @@ -19,7 +19,7 @@ * */ -#include "support.h" +#include "tests/support.h" #include <libsyncml/objects/sml_auth.h> #include <libsyncml/objects/sml_devinf_obj.h> @@ -396,35 +396,5 @@ } END_TEST -Suite *devinf_suite(void) -{ - Suite *s = suite_create("Devinf"); - //Suite *s2 = suite_create("Devinf"); - -#ifdef ENABLE_HTTP - create_case(s, "devinf_crash", devinf_crash); - create_case(s, "devinf_result", devinf_result); -#endif - create_case(s, "devinf_max_size_element", devinf_max_size_element); - - return s; -} - -int main(void) -{ - configure_environment(); +@SML_TESTCASE_CODE@ - int nf; - - Suite *s = devinf_suite(); - - SRunner *sr; - sr = srunner_create(s); - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - - cleanup_environment(); - - return (nf == 0) ? 0 : 1; -} Modified: trunk/tests/check_ds.c ============================================================================== --- trunk/tests/check_ds.c Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/check_ds.c Thu Apr 9 15:42:16 2009 (r1038) @@ -19,7 +19,7 @@ * */ -#include "support.h" +#include "tests/support.h" #include <libsyncml/objects/sml_ds_server.h> @@ -389,7 +389,7 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -START_TEST (check_ds_server_new) +START_TEST (ds_server_new) { setup_testbed(NULL); @@ -405,7 +405,7 @@ } END_TEST -START_TEST (check_ds_client_new) +START_TEST (ds_client_new) { setup_testbed(NULL); @@ -505,7 +505,7 @@ /* Send Alert -> C -- Put, Alert --> S -> init_alert, get_alert, recv_alert * end session -> S -- Status --> C -> manager event (Session End) */ -START_TEST (check_ds_send_alert) +START_TEST (ds_send_alert) { /* General setup */ setup_testbed(NULL); @@ -596,7 +596,7 @@ * S -- Status, Put, Alert --> C * C -- Status --> S * S -- Status --> C */ -START_TEST (check_ds_send_alert2) +START_TEST (ds_send_alert2) { data_received = 0; init_alerts_received = 0; @@ -719,7 +719,7 @@ * S -- Status, Put, Alert --> C * C -- Status, Sync --> S * S -- Status --> S */ -START_TEST (check_ds_send_empty_sync) +START_TEST (ds_send_empty_sync) { data_received = 0; init_alerts_received = 0; @@ -865,7 +865,7 @@ * S -- Status, Sync --> S * C -- Status --> S * S -- Status --> C */ -START_TEST (check_ds_reply_empty_sync) +START_TEST (ds_reply_empty_sync) { data_received = 0; init_alerts_received = 0; @@ -1030,7 +1030,7 @@ * S -- Status, Sync --> S * C -- Status --> S * S -- Status --> C */ -START_TEST (check_ds_add) +START_TEST (ds_add) { data_received = 0; init_alerts_received = 0; @@ -1206,7 +1206,7 @@ * S -- Status, Sync, Add --> S * C -- Status, Map --> S * S -- Status --> C */ -START_TEST (check_ds_add2) +START_TEST (ds_add2) { data_received = 0; init_alerts_received = 0; @@ -1397,7 +1397,7 @@ * S -- Status, Sync, Delete --> S * C -- Status --> S * S -- Status --> C */ -START_TEST (check_ds_delete) +START_TEST (ds_delete) { data_received = 0; init_alerts_received = 0; @@ -1579,7 +1579,7 @@ * S -- Status, Sync, Add, Replace, Delete --> S * C -- Status, Map --> S * S -- Status --> C */ -START_TEST (check_ds_map_full) +START_TEST (ds_map_full) { data_received = 0; init_alerts_received = 0; @@ -1782,7 +1782,7 @@ * S -- Status, Sync, 500 * Add --> S * C -- Status, Map --> S * S -- Status --> C */ -START_TEST (check_ds_add_large) +START_TEST (ds_add_large) { data_received = 0; init_alerts_received = 0; @@ -1979,7 +1979,7 @@ * C -- Status, Map --> S * S -- Status --> C */ /* Limit the sending size of both sides */ -START_TEST (check_ds_limit) +START_TEST (ds_limit) { data_received = 0; init_alerts_received = 0; @@ -2172,7 +2172,7 @@ * C -- Status, Map --> S * S -- Status --> C */ /* Limit the sending size of both sides */ -START_TEST (check_ds_multi_server) +START_TEST (ds_multi_server) { data_received = 0; init_alerts_received = 0; @@ -2450,25 +2450,6 @@ END_TEST #endif -Suite *datasync_suite(void) -{ - Suite *s = suite_create("DataSync"); - //Suite *s2 = suite_create("DataSync"); - - create_case(s, "check_ds_server_new", check_ds_server_new); - create_case(s, "check_ds_client_new", check_ds_client_new); - create_case(s, "check_ds_send_alert", check_ds_send_alert); - create_case(s, "check_ds_send_alert2", check_ds_send_alert2); - create_case(s, "check_ds_send_empty_sync", check_ds_send_empty_sync); - create_case(s, "check_ds_reply_empty_sync", check_ds_reply_empty_sync); - create_case(s, "check_ds_add", check_ds_add); - create_case(s, "check_ds_add2", check_ds_add2); - create_case(s, "check_ds_delete", check_ds_delete); - create_case(s, "check_ds_map_full", check_ds_map_full); - create_case(s, "check_ds_add_large", check_ds_add_large); - create_case(s, "check_ds_limit", check_ds_limit); - - /* To test: * - Multiple ds servers * - error behavious @@ -2482,24 +2463,5 @@ * - SAN 1.2 */ - return s; -} - -int main(void) -{ - configure_environment(); - - int nf; - - Suite *s = datasync_suite(); - - SRunner *sr; - sr = srunner_create(s); - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - - cleanup_environment(); +@SML_TESTCASE_CODE@ - return (nf == 0) ? 0 : 1; -} Modified: trunk/tests/check_elements.c ============================================================================== --- trunk/tests/check_elements.c Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/check_elements.c Thu Apr 9 15:42:16 2009 (r1038) @@ -18,10 +18,10 @@ * */ -#include "support.h" +#include "tests/support.h" #include <fnmatch.h> -START_TEST (check_location_new) +START_TEST (location_new) { setup_testbed(NULL); @@ -37,7 +37,7 @@ } END_TEST -START_TEST (check_location_new2) +START_TEST (location_new2) { setup_testbed(NULL); @@ -53,7 +53,7 @@ } END_TEST -START_TEST (check_location_new3) +START_TEST (location_new3) { setup_testbed(NULL); @@ -66,7 +66,7 @@ } END_TEST -START_TEST (check_location_compare_rel) +START_TEST (location_compare_rel) { setup_testbed(NULL); @@ -81,7 +81,7 @@ } END_TEST -START_TEST (check_location_compare_rel1) +START_TEST (location_compare_rel1) { setup_testbed(NULL); @@ -96,7 +96,7 @@ } END_TEST -START_TEST (check_location_compare_rel2) +START_TEST (location_compare_rel2) { setup_testbed(NULL); @@ -115,7 +115,7 @@ } END_TEST -START_TEST (check_location_compare_abs) +START_TEST (location_compare_abs) { setup_testbed(NULL); @@ -130,7 +130,7 @@ } END_TEST -START_TEST (check_location_compare_abs2) +START_TEST (location_compare_abs2) { setup_testbed(NULL); @@ -149,7 +149,7 @@ } END_TEST -START_TEST (check_location_compare_combined) +START_TEST (location_compare_combined) { setup_testbed(NULL); @@ -177,7 +177,7 @@ } END_TEST -START_TEST (check_location_compare_combined2) +START_TEST (location_compare_combined2) { setup_testbed(NULL); @@ -205,7 +205,7 @@ } END_TEST -START_TEST (check_location_compare_combined3) +START_TEST (location_compare_combined3) { setup_testbed(NULL); @@ -233,7 +233,7 @@ } END_TEST -START_TEST (check_location_compare_combined4) +START_TEST (location_compare_combined4) { setup_testbed(NULL); @@ -261,7 +261,7 @@ } END_TEST -START_TEST (check_location_compare_combined5) +START_TEST (location_compare_combined5) { setup_testbed(NULL); @@ -289,7 +289,7 @@ } END_TEST -START_TEST (check_location_compare_combined6) +START_TEST (location_compare_combined6) { setup_testbed(NULL); @@ -317,44 +317,5 @@ } END_TEST -Suite *elements_suite(void) -{ - Suite *s = suite_create("Elements"); - //Suite *s2 = suite_create("Elements"); - - create_case(s, "check_location_new", check_location_new); - create_case(s, "check_location_new2", check_location_new2); - create_case(s, "check_location_new3", check_location_new3); - create_case(s, "check_location_compare_rel", check_location_compare_rel); - create_case(s, "check_location_compare_rel1", check_location_compare_rel1); - create_case(s, "check_location_compare_rel2", check_location_compare_rel2); - create_case(s, "check_location_compare_abs", check_location_compare_abs); - create_case(s, "check_location_compare_abs2", check_location_compare_abs2); - create_case(s, "check_location_compare_combined", check_location_compare_combined); - create_case(s, "check_location_compare_combined2", check_location_compare_combined2); - create_case(s, "check_location_compare_combined3", check_location_compare_combined3); - create_case(s, "check_location_compare_combined4", check_location_compare_combined4); - create_case(s, "check_location_compare_combined5", check_location_compare_combined5); - create_case(s, "check_location_compare_combined6", check_location_compare_combined6); - - return s; -} - -int main(void) -{ - configure_environment(); +@SML_TESTCASE_CODE@ - int nf; - - Suite *s = elements_suite(); - - SRunner *sr; - sr = srunner_create(s); - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - - cleanup_environment(); - - return (nf == 0) ? 0 : 1; -} Modified: trunk/tests/check_http.c ============================================================================== --- trunk/tests/check_http.c Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/check_http.c Thu Apr 9 15:42:16 2009 (r1038) @@ -19,7 +19,7 @@ * */ -#include "support.h" +#include "tests/support.h" #include <libsyncml/sml_transport_internals.h> @@ -932,49 +932,5 @@ } END_TEST -Suite *http_suite(void) -{ - Suite *s = suite_create("Http Transports"); - //Suite *s2 = suite_create("Http Transports"); - - create_case(s, "http_client_new", http_client_new); - create_case(s, "http_client_init", http_client_init); - //create_case(s, "http_client_wrong_port", http_client_wrong_port); // TODO: Review testcase. Obsolate? - create_case(s, "http_client_init_no_url", http_client_init_no_url); - - create_case(s, "http_server_new", http_server_new); - create_case(s, "http_server_init", http_server_init); - create_case(s, "http_server_wrong_port", http_server_wrong_port); - - create_case(s, "http_connect", http_connect); - create_case(s, "http_send", http_send); - create_case(s, "http_receive", http_receive); - create_case(s, "http_reply", http_reply); - create_case(s, "http_talk", http_talk); - create_case(s, "http_connect_error", http_connect_error); - create_case(s, "http_reject", http_reject); - create_case(s, "http_multi_connect", http_multi_connect); - create_case(s, "http_multi_partial_error", http_multi_partial_error); - create_case(s, "http_multi_stress", http_multi_stress); - - return s; -} +@SML_TESTCASE_CODE@ -int main(void) -{ - configure_environment(); - - int nf; - - Suite *s = http_suite(); - - SRunner *sr; - sr = srunner_create(s); - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - - cleanup_environment(); - - return (nf == 0) ? 0 : 1; -} Modified: trunk/tests/check_libsoup.c ============================================================================== --- trunk/tests/check_libsoup.c Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/check_libsoup.c Thu Apr 9 15:42:16 2009 (r1038) @@ -18,7 +18,7 @@ * */ -#include "support.h" +#include "tests/support.h" #include <libsyncml/sml_queue_internals.h> #include <libsyncml/sml_transport_internals.h> @@ -498,33 +498,5 @@ } END_TEST -Suite *http_suite(void) -{ - Suite *s = suite_create("libsoup validation"); - //Suite *s2 = suite_create("libsoup validation"); - - create_case(s, "libsoup_async", libsoup_async); - create_case(s, "libsoup_http_client", libsoup_http_client); - create_case(s, "libsoup_http_server", libsoup_http_server); - - return s; -} - -int main(void) -{ - configure_environment(); +@SML_TESTCASE_CODE@ - int nf; - - Suite *s = http_suite(); - - SRunner *sr; - sr = srunner_create(s); - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - - cleanup_environment(); - - return (nf == 0) ? 0 : 1; -} Modified: trunk/tests/check_manager.c ============================================================================== --- trunk/tests/check_manager.c Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/check_manager.c Thu Apr 9 15:42:16 2009 (r1038) @@ -19,7 +19,7 @@ * */ -#include "support.h" +#include "tests/support.h" #include <libsyncml/sml_session_internals.h> @@ -674,36 +674,5 @@ } END_TEST -Suite *manager_suite(void) -{ - Suite *s = suite_create("Manager"); - - create_case(s, "manager_new", manager_new); - create_case(s, "manager_run", manager_run); - create_case(s, "manager_receive", manager_receive); - create_case(s, "manager_receive_session", manager_receive_session); - create_case(s, "manager_end_session", manager_end_session); - create_case(s, "manager_register", manager_register); - create_case(s, "manager_start_session", manager_start_session); - - return s; -} - -int main(void) -{ - configure_environment(); +@SML_TESTCASE_CODE@ - int nf; - - Suite *s = manager_suite(); - - SRunner *sr; - sr = srunner_create(s); - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - - cleanup_environment(); - - return (nf == 0) ? 0 : 1; -} Modified: trunk/tests/check_md5.c ============================================================================== --- trunk/tests/check_md5.c Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/check_md5.c Thu Apr 9 15:42:16 2009 (r1038) @@ -19,9 +19,9 @@ * */ -#include "support.h" +#include "tests/support.h" -START_TEST (check_md5_1) +START_TEST (md5_1) { const char *data = ""; unsigned char digest[16]; @@ -35,7 +35,7 @@ } END_TEST -START_TEST (check_md5_2) +START_TEST (md5_2) { const char *data = "a"; unsigned char digest[16]; @@ -49,7 +49,7 @@ } END_TEST -START_TEST (check_md5_3) +START_TEST (md5_3) { const char *data = "abc"; unsigned char digest[16]; @@ -63,7 +63,7 @@ } END_TEST -START_TEST (check_md5_4) +START_TEST (md5_4) { const char *data = "message digest"; unsigned char digest[16]; @@ -77,7 +77,7 @@ } END_TEST -START_TEST (check_md5_5) +START_TEST (md5_5) { const char *data = "abcdefghijklmnopqrstuvwxyz"; unsigned char digest[16]; @@ -91,7 +91,7 @@ } END_TEST -START_TEST (check_md5_6) +START_TEST (md5_6) { const char *data = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; unsigned char digest[16]; @@ -105,7 +105,7 @@ } END_TEST -START_TEST (check_md5_7) +START_TEST (md5_7) { const char *data = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"; unsigned char digest[16]; @@ -119,37 +119,5 @@ } END_TEST -Suite *md5_suite(void) -{ - Suite *s = suite_create("MD5"); - //Suite *s2 = suite_create("MD5"); - - create_case(s, "check_md5_1", check_md5_1); - create_case(s, "check_md5_2", check_md5_2); - create_case(s, "check_md5_3", check_md5_3); - create_case(s, "check_md5_4", check_md5_4); - create_case(s, "check_md5_5", check_md5_5); - create_case(s, "check_md5_6", check_md5_6); - create_case(s, "check_md5_7", check_md5_7); - - return s; -} - -int main(void) -{ - configure_environment(); - - int nf; - - Suite *s = md5_suite(); - - SRunner *sr; - sr = srunner_create(s); - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - - cleanup_environment(); +@SML_TESTCASE_CODE@ - return (nf == 0) ? 0 : 1; -} Modified: trunk/tests/check_obex.c ============================================================================== --- trunk/tests/check_obex.c Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/check_obex.c Thu Apr 9 15:42:16 2009 (r1038) @@ -19,7 +19,7 @@ * */ -#include "support.h" +#include "tests/support.h" #include <libsyncml/sml_transport_internals.h> #include <libsyncml/transports/obex_internals.h> @@ -883,49 +883,5 @@ } END_TEST -Suite *obex_suite(void) -{ - Suite *s = suite_create("Obex Transport"); - //Suite *s2 = suite_create("Obex Transport"); - - create_case(s, "obex_get_result_macro", obex_get_result_macro); - - create_case(s, "obex_client_new", obex_client_new); - create_case(s, "obex_client_init", obex_client_init); - - create_case(s, "obex_server_new", obex_server_new); - create_case(s, "obex_server_init", obex_server_init); - - create_case(s, "obex_connect", obex_connect); - - create_case(s, "obex_send", obex_send); - create_case(s, "obex_reply", obex_reply); - create_case(s, "obex_talk", obex_talk); - create_case(s, "obex_multi_connect", obex_multi_connect); - create_case(s, "obex_multi_stress", obex_multi_stress); - - create_case(s, "obex_connect_error", obex_connect_error); - create_case(s, "obex_reject", obex_reject); - create_case(s, "obex_multi_partial_error", obex_multi_partial_error); - - return s; -} - -int main(void) -{ - configure_environment(); - - int nf; +@SML_TESTCASE_CODE@ - Suite *s = obex_suite(); - - SRunner *sr; - sr = srunner_create(s); - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - - cleanup_environment(); - - return (nf == 0) ? 0 : 1; -} Modified: trunk/tests/check_san.c ============================================================================== --- trunk/tests/check_san.c Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/check_san.c Thu Apr 9 15:42:16 2009 (r1038) @@ -19,7 +19,7 @@ * */ -#include "support.h" +#include "tests/support.h" /* If the notification is a normal SyncML message then a manager is * required. The easiest way are two function which create and destroy @@ -54,7 +54,7 @@ smlTransportFree(_tsp); } -START_TEST (check_san_new) +START_TEST (san_new) { setup_testbed(NULL); @@ -67,7 +67,7 @@ } END_TEST -START_TEST (check_san_empty) +START_TEST (san_empty) { setup_testbed(NULL); @@ -100,7 +100,7 @@ } END_TEST -START_TEST (check_san_empty2) +START_TEST (san_empty2) { setup_testbed(NULL); @@ -133,7 +133,7 @@ } END_TEST -START_TEST (check_san_alert) +START_TEST (san_alert) { setup_testbed(NULL); @@ -172,7 +172,7 @@ } END_TEST -START_TEST (check_san_alert2) +START_TEST (san_alert2) { setup_testbed(NULL); @@ -217,7 +217,7 @@ } END_TEST -START_TEST (check_san_alert_auth) +START_TEST (san_alert_auth) { setup_testbed(NULL); @@ -261,7 +261,7 @@ } END_TEST -START_TEST (check_san_11_assemble_parse) +START_TEST (san_11_assemble_parse) { setup_testbed(NULL); @@ -313,7 +313,7 @@ } END_TEST -START_TEST (check_san_parse) +START_TEST (san_parse) { setup_testbed(NULL); @@ -358,7 +358,7 @@ } END_TEST -START_TEST (check_san_parse2) +START_TEST (san_parse2) { setup_testbed(NULL); @@ -386,7 +386,7 @@ } END_TEST -START_TEST (check_san_parse_error) +START_TEST (san_parse_error) { setup_testbed(NULL); @@ -404,7 +404,7 @@ } END_TEST -START_TEST (check_san_parse_error2) +START_TEST (san_parse_error2) { setup_testbed(NULL); @@ -423,7 +423,7 @@ } END_TEST -START_TEST (check_san_parse_error3) +START_TEST (san_parse_error3) { setup_testbed(NULL); @@ -442,7 +442,7 @@ } END_TEST -START_TEST (check_san_parse_error4) +START_TEST (san_parse_error4) { setup_testbed(NULL); @@ -461,7 +461,7 @@ } END_TEST -START_TEST (check_san_parse_error5) +START_TEST (san_parse_error5) { setup_testbed(NULL); @@ -483,7 +483,7 @@ } END_TEST -START_TEST (check_san_parse_error6) +START_TEST (san_parse_error6) { setup_testbed(NULL); @@ -505,7 +505,7 @@ } END_TEST -START_TEST (check_san_parse_error7) +START_TEST (san_parse_error7) { setup_testbed(NULL); @@ -527,7 +527,7 @@ } END_TEST -/*START_TEST (check_san_send) +/*START_TEST (san_send) { setup_testbed(NULL); @@ -558,48 +558,5 @@ } END_TEST*/ -Suite *san_suite(void) -{ - Suite *s = suite_create("San"); - //Suite *s2 = suite_create("San"); - - create_case(s, "check_san_new", check_san_new); - create_case(s, "check_san_empty", check_san_empty); - create_case(s, "check_san_empty2", check_san_empty2); - create_case(s, "check_san_alert", check_san_alert); - create_case(s, "check_san_alert2", check_san_alert2); - create_case(s, "check_san_alert_auth", check_san_alert_auth); - create_case(s, "check_san_parse", check_san_parse); - create_case(s, "check_san_parse2", check_san_parse2); -#ifdef ENABLE_HTTP - create_case(s, "check_san_11_assemble_parse", check_san_11_assemble_parse); -#endif - create_case(s, "check_san_parse_error", check_san_parse_error); - create_case(s, "check_san_parse_error2", check_san_parse_error2); - create_case(s, "check_san_parse_error3", check_san_parse_error3); - create_case(s, "check_san_parse_error4", check_san_parse_error4); - create_case(s, "check_san_parse_error5", check_san_parse_error5); - create_case(s, "check_san_parse_error6", check_san_parse_error6); - create_case(s, "check_san_parse_error7", check_san_parse_error7); - - return s; -} - -int main(void) -{ - configure_environment(); - - int nf; - - Suite *s = san_suite(); - - SRunner *sr; - sr = srunner_create(s); - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); +@SML_TESTCASE_CODE@ - cleanup_environment(); - - return (nf == 0) ? 0 : 1; -} Modified: trunk/tests/check_session.c ============================================================================== --- trunk/tests/check_session.c Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/check_session.c Thu Apr 9 15:42:16 2009 (r1038) @@ -19,7 +19,7 @@ * */ -#include "support.h" +#include "tests/support.h" #include <libsyncml/sml_session_internals.h> #include <libsyncml/sml_elements_internals.h> @@ -311,7 +311,7 @@ } -START_TEST (check_session_new) +START_TEST (session_new) { init_testbed(); @@ -332,7 +332,7 @@ } END_TEST -START_TEST (check_session_send) +START_TEST (session_send) { init_testbed(); @@ -526,7 +526,7 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -START_TEST (check_session_flush) +START_TEST (session_flush) { init_testbed(); @@ -567,7 +567,7 @@ } END_TEST -START_TEST (check_session_flush_final) +START_TEST (session_flush_final) { init_testbed(); @@ -609,7 +609,7 @@ END_TEST /* Check that event callbacks are working */ -START_TEST (check_session_recv) +START_TEST (session_recv) { init_testbed(); @@ -661,7 +661,7 @@ END_TEST /* Check that a session can parse the output of another session */ -START_TEST (check_session_transmit) +START_TEST (session_transmit) { init_testbed(); @@ -740,7 +740,7 @@ /* session --- Alert --> session2 * session2 --- Status ---> Session */ -START_TEST (check_session_reply) +START_TEST (session_reply) { init_testbed(); @@ -817,7 +817,7 @@ * session --- Status ---> session2 * session2 --- ---> session */ -START_TEST (check_session_talk) +START_TEST (session_talk) { init_testbed(); @@ -911,7 +911,7 @@ * session --- num * Status ---> session2 * session2 --- ---> session */ -START_TEST (check_session_talk_alot) +START_TEST (session_talk_alot) { init_testbed(); @@ -1026,7 +1026,7 @@ * session --- num * Status ---> session2 * session2 --- ---> session */ -START_TEST (check_session_talk_alot_limit) +START_TEST (session_talk_alot_limit) { init_testbed(); @@ -1152,7 +1152,7 @@ * session2 -- y Alert (final) --> session * */ -START_TEST (check_session_limit_remote) +START_TEST (session_limit_remote) { init_testbed(); @@ -1250,7 +1250,7 @@ } END_TEST -START_TEST (check_session_split_child) +START_TEST (session_split_child) { init_testbed(); @@ -1374,7 +1374,7 @@ } END_TEST -START_TEST (check_session_recv_large_obj) +START_TEST (session_recv_large_obj) { init_testbed(); @@ -1456,7 +1456,7 @@ } END_TEST -START_TEST (check_session_recv_large_obj2) +START_TEST (session_recv_large_obj2) { init_testbed(); @@ -1647,7 +1647,7 @@ } END_TEST -START_TEST (check_session_recv_wrong_order) +START_TEST (session_recv_wrong_order) { init_testbed(); @@ -1696,7 +1696,7 @@ } END_TEST -START_TEST (check_session_large_obj_10) +START_TEST (session_large_obj_10) { init_testbed(); @@ -1792,7 +1792,7 @@ } END_TEST -START_TEST (check_session_large_obj_open) +START_TEST (session_large_obj_open) { init_testbed(); @@ -1852,7 +1852,7 @@ } END_TEST -START_TEST (check_session_large_obj_no_size) +START_TEST (session_large_obj_no_size) { init_testbed(); @@ -1906,7 +1906,7 @@ } END_TEST -START_TEST (check_session_large_obj_several_size) +START_TEST (session_large_obj_several_size) { init_testbed(); @@ -1990,7 +1990,7 @@ } END_TEST -START_TEST (check_session_recv_large_wrong_size) +START_TEST (session_recv_large_wrong_size) { init_testbed(); @@ -2074,7 +2074,7 @@ } END_TEST -START_TEST (check_session_recv_large_wrong_size2) +START_TEST (session_recv_large_wrong_size2) { init_testbed(); @@ -2158,7 +2158,7 @@ } END_TEST -START_TEST (check_session_send_large_obj) +START_TEST (session_send_large_obj) { init_testbed(); @@ -2241,7 +2241,7 @@ } END_TEST -START_TEST (check_session_send_large_obj2) +START_TEST (session_send_large_obj2) { init_testbed(); @@ -2315,7 +2315,7 @@ } END_TEST -START_TEST (check_session_send_multi_large_obj) +START_TEST (session_send_multi_large_obj) { init_testbed(); @@ -2393,7 +2393,7 @@ } END_TEST -START_TEST (check_session_send_multi_large_obj_alter) +START_TEST (session_send_multi_large_obj_alter) { init_testbed(); @@ -2479,7 +2479,7 @@ } END_TEST -START_TEST (check_session_san) +START_TEST (session_san) { init_testbed(); @@ -2596,71 +2596,5 @@ } END_TEST -Suite *session_suite(void) -{ - Suite *s = suite_create("Session"); - //Suite *s2 = suite_create("Session"); - - create_case(s, "check_session_new", check_session_new); - create_case(s, "check_session_send", check_session_send); - create_case(s, "check_session_flush", check_session_flush); - create_case(s, "check_session_flush_final", check_session_flush_final); - create_case(s, "check_session_recv", check_session_recv); - create_case(s, "check_session_transmit", check_session_transmit); - create_case(s, "check_session_reply", check_session_reply); - create_case(s, "check_session_talk", check_session_talk); - create_case(s, "check_session_talk_alot", check_session_talk_alot); - create_case(s, "check_session_talk_alot_limit", check_session_talk_alot_limit); - - create_case(s, "check_session_limit_remote", check_session_limit_remote); - create_case(s, "check_session_split_child", check_session_split_child); - - create_case(s, "check_session_recv_large_obj", check_session_recv_large_obj); - create_case(s, "check_session_recv_large_obj2", check_session_recv_large_obj2); - create_case(s, "check_session_recv_wrong_order", check_session_recv_wrong_order); - create_case(s, "check_session_large_obj_10", check_session_large_obj_10); - create_case(s, "check_session_large_obj_open", check_session_large_obj_open); - create_case(s, "check_session_large_obj_no_size", check_session_large_obj_no_size); - create_case(s, "check_session_large_obj_several_size", check_session_large_obj_several_size); - create_case(s, "check_session_recv_large_wrong_size", check_session_recv_large_wrong_size); - create_case(s, "check_session_recv_large_wrong_size2", check_session_recv_large_wrong_size2); - - create_case(s, "check_session_send_large_obj", check_session_send_large_obj); - create_case(s, "check_session_send_large_obj2", check_session_send_large_obj2); - create_case(s, "check_session_send_multi_large_obj", check_session_send_multi_large_obj); - create_case(s, "check_session_send_multi_large_obj_alter", check_session_send_multi_large_obj_alter); - -#ifdef ENABLE_HTTP - create_case(s, "check_session_san", check_session_san); -#endif - - //noresp - - /* Error checking - * - Wrong session id - * - Wrong header (url etc) - * - Wrong header (versions) - */ - - - return s; -} +@SML_TESTCASE_CODE@ -int main(void) -{ - configure_environment(); - - int nf; - - Suite *s = session_suite(); - - SRunner *sr; - sr = srunner_create(s); - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - - cleanup_environment(); - - return (nf == 0) ? 0 : 1; -} Modified: trunk/tests/check_sync.c ============================================================================== --- trunk/tests/check_sync.c Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/check_sync.c Thu Apr 9 15:42:16 2009 (r1038) @@ -19,7 +19,7 @@ * */ -#include "support.h" +#include "tests/support.h" #include <libsyncml/objects/sml_ds_server.h> #include <libsyncml/objects/sml_auth.h> @@ -2076,41 +2076,5 @@ #endif #endif -Suite *sync_suite(void) -{ - Suite *s = suite_create("Sync"); - -#ifdef ENABLE_HTTP - create_case(s, "sync_multi_start", sync_multi_start); - create_case(s, "sync_multi_stress", sync_multi_stress); - create_case(s, "sync_multi_stress2", sync_multi_stress2); - create_case(s, "sync_multi_conf_from_devinf", sync_multi_conf_from_devinf); -#endif -#ifdef ENABLE_OBEX -#ifdef ENABLE_OPENOBEX_TCP - create_case(s, "sync_send_san", sync_send_san); - create_case(s, "sync_send_san12", sync_send_san12); -#endif -#endif - - return s; -} - -int main(void) -{ - configure_environment(); - - int nf; +@SML_TESTCASE_CODE@ - Suite *s = sync_suite(); - - SRunner *sr; - sr = srunner_create(s); - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - - cleanup_environment(); - - return (nf == 0) ? 0 : 1; -} Modified: trunk/tests/check_wbxml_assembler.c ============================================================================== --- trunk/tests/check_wbxml_assembler.c Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/check_wbxml_assembler.c Thu Apr 9 15:42:16 2009 (r1038) @@ -19,9 +19,8 @@ * */ -#include "support.h" +#include "tests/support.h" -#ifdef ENABLE_WBXML #include <libsyncml/parser/sml_wbxml_internals.h> #include <libsyncml/sml_command_internals.h> @@ -45,7 +44,7 @@ return assm; } -START_TEST (check_assembler_message_empty) +START_TEST (wbxml_assembler_message_empty) { SmlError *error = NULL; @@ -80,7 +79,7 @@ } END_TEST -START_TEST (check_assembler_message_only_header) +START_TEST (wbxml_assembler_message_only_header) { SmlError *error = NULL; @@ -118,7 +117,7 @@ } END_TEST -START_TEST (check_assembler_message_status) +START_TEST (wbxml_assembler_message_status) { SmlError *error = NULL; @@ -170,7 +169,7 @@ } END_TEST -START_TEST (check_assembler_message_cmd) +START_TEST (wbxml_assembler_message_cmd) { SmlError *error = NULL; @@ -230,7 +229,7 @@ } END_TEST -START_TEST (check_assembler_message_subcmd) +START_TEST (wbxml_assembler_message_subcmd) { SmlError *error = NULL; @@ -294,7 +293,7 @@ } END_TEST -START_TEST (check_assembler_message_several_subcmd) +START_TEST (wbxml_assembler_message_several_subcmd) { SmlError *error = NULL; @@ -398,7 +397,7 @@ } END_TEST -START_TEST (check_assembler_message_flush_open) +START_TEST (wbxml_assembler_message_flush_open) { SmlError *error = NULL; @@ -479,7 +478,7 @@ } END_TEST -START_TEST (check_assembler_out_of_order) +START_TEST (wbxml_assembler_out_of_order) { SmlError *error = NULL; @@ -593,7 +592,7 @@ } END_TEST -START_TEST (check_assembler_limit1) +START_TEST (wbxml_assembler_limit1) { SmlError *error = NULL; @@ -624,7 +623,7 @@ } END_TEST -START_TEST (check_assembler_limit2) +START_TEST (wbxml_assembler_limit2) { SmlError *error = NULL; @@ -655,7 +654,7 @@ } END_TEST -START_TEST (check_assembler_limit3) +START_TEST (wbxml_assembler_limit3) { SmlError *error = NULL; @@ -697,7 +696,7 @@ } END_TEST -START_TEST (check_assembler_limit4) +START_TEST (wbxml_assembler_limit4) { SmlError *error = NULL; @@ -739,7 +738,7 @@ } END_TEST -START_TEST (check_assembler_limit5) +START_TEST (wbxml_assembler_limit5) { SmlError *error = NULL; @@ -809,7 +808,7 @@ } END_TEST -START_TEST (check_assembler_complex1) +START_TEST (wbxml_assembler_complex1) { SmlError *error = NULL; @@ -898,53 +897,5 @@ } END_TEST -Suite *assembler_suite(void) -{ - Suite *s = suite_create("Assembler"); - //Suite *s2 = suite_create("Assembler"); - - create_case(s, "check_assembler_message_empty", check_assembler_message_empty); - create_case(s, "check_assembler_message_only_header", check_assembler_message_only_header); - create_case(s, "check_assembler_message_status", check_assembler_message_status); - create_case(s, "check_assembler_message_cmd", check_assembler_message_cmd); - create_case(s, "check_assembler_message_subcmd", check_assembler_message_subcmd); - create_case(s, "check_assembler_message_several_subcmd", check_assembler_message_several_subcmd); - create_case(s, "check_assembler_message_flush_open", check_assembler_message_flush_open); - create_case(s, "check_assembler_out_of_order", check_assembler_out_of_order); - create_case(s, "check_assembler_limit1", check_assembler_limit1); - create_case(s, "check_assembler_limit2", check_assembler_limit2); - create_case(s, "check_assembler_limit3", check_assembler_limit3); - create_case(s, "check_assembler_limit4", check_assembler_limit4); - create_case(s, "check_assembler_limit5", check_assembler_limit5); - create_case(s, "check_assembler_complex1", check_assembler_complex1); - - return s; -} - -int main(void) -{ - configure_environment(); - - int nf; - - Suite *s = assembler_suite(); - - SRunner *sr; - sr = srunner_create(s); - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - - cleanup_environment(); - - return (nf == 0) ? 0 : 1; -} -#else - - -int main(void) -{ - return 1; -} +@SML_TESTCASE_CODE@ -#endif Modified: trunk/tests/check_wbxml_parser.c ============================================================================== --- trunk/tests/check_wbxml_parser.c Thu Apr 9 12:19:05 2009 (r1037) +++ trunk/tests/check_wbxml_parser.c Thu Apr 9 15:42:16 2009 (r1038) @@ -19,7 +19,7 @@ * */ -#include "support.h" +#include "tests/support.h" #ifdef ENABLE_WBXML #include <libsyncml/parser/sml_wbxml_internals.h> @@ -58,7 +58,7 @@ return parser; } -START_TEST (check_parser_syncml_empty) +START_TEST (wbxml_parser_syncml_empty) { const char *data = "<SyncML></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -66,7 +66,7 @@ } END_TEST -START_TEST (check_parser_no_syncbody) +START_TEST (wbxml_parser_no_syncbody) { const char *data = "<SyncML><SyncHdr></SyncHdr></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -90,7 +90,7 @@ } END_TEST -START_TEST (check_parser_no_synchdr) +START_TEST (wbxml_parser_no_synchdr) { const char *data = "<SyncML><SyncBody></SyncBody></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -98,7 +98,7 @@ } END_TEST -START_TEST (check_parser_synchdr_empty) +START_TEST (wbxml_parser_synchdr_empty) { const char *data = "<SyncML><SyncHdr></SyncHdr><SyncBody></SyncBody></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -124,7 +124,7 @@ } END_TEST -START_TEST (check_parser_synchdr_verproto) +START_TEST (wbxml_parser_synchdr_verproto) { const char *data = "<SyncML><SyncHdr><VerProto>SyncML/1.1</VerProto></SyncHdr><SyncBody></SyncBody></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -148,7 +148,7 @@ } END_TEST -START_TEST (check_parser_synchdr_verdtd) +START_TEST (wbxml_parser_synchdr_verdtd) { const char *data = "<SyncML><SyncHdr><VerProto>SyncML/1.1</VerProto><VerDTD>1.1</VerDTD></SyncHdr><SyncBody></SyncBody></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -172,7 +172,7 @@ } END_TEST -START_TEST (check_parser_synchdr_msgid) +START_TEST (wbxml_parser_synchdr_msgid) { const char *data = "<SyncML><SyncHdr><VerProto>SyncML/1.1</VerProto><VerDTD>1.1</VerDTD><MsgID>1</MsgID></SyncHdr><SyncBody></SyncBody></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -196,7 +196,7 @@ } END_TEST -START_TEST (check_parser_synchdr_sessionid) +START_TEST (wbxml_parser_synchdr_sessionid) { const char *data = "<SyncML><SyncHdr><VerProto>SyncML/1.1</VerProto><VerDTD>1.1</VerDTD><MsgID>1</MsgID><SessionID>1</SessionID></SyncHdr><SyncBody></SyncBody></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -220,7 +220,7 @@ } END_TEST -START_TEST (check_parser_synchdr_target) +START_TEST (wbxml_parser_synchdr_target) { const char *data = "<SyncML><SyncHdr><VerProto>SyncML/1.1</VerProto><VerDTD>1.1</VerDTD><MsgID>1</MsgID><SessionID>1</SessionID><Target><LocURI>test</LocURI></Target></SyncHdr><SyncBody></SyncBody></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -244,7 +244,7 @@ } END_TEST -START_TEST (check_parser_synchdr_source) +START_TEST (wbxml_parser_synchdr_source) { const char *data = "<SyncML><SyncHdr><VerProto>SyncML/1.1</VerProto><VerDTD>1.1</VerDTD><MsgID>1</MsgID><SessionID>1</SessionID><Target><LocURI>test</LocURI></Target><Source><LocURI>test</LocURI></Source></SyncHdr><SyncBody></SyncBody></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -284,7 +284,7 @@ } END_TEST -START_TEST (check_parser_synchdr_source2) +START_TEST (wbxml_parser_synchdr_source2) { const char *data = "<SyncML><SyncHdr><VerProto>SyncML/1.1</VerProto><VerDTD>1.1</VerDTD><MsgID>1</MsgID><SessionID>asd</SessionID><Target><LocURI>test</LocURI></Target><Source><LocURI>test</LocURI></Source></SyncHdr><SyncBody></SyncBody></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -324,7 +324,7 @@ } END_TEST -START_TEST (check_parser_synchdr_additional) +START_TEST (wbxml_parser_synchdr_additional) { const char *data = "<SyncML><SyncHdr><VerProto>SyncML/1.1</VerProto><VerDTD>1.1</VerDTD><MsgID>1</MsgID><SessionID>1</SessionID><Target><LocURI>test</LocURI></Target><Source><LocURI>test</LocURI></Source><test></test></SyncHdr><SyncBody></SyncBody></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -348,7 +348,7 @@ } END_TEST -START_TEST (check_parser_status_empty) +START_TEST (wbxml_parser_status_empty) { const char *data = "<SyncML><SyncHdr><VerProto>SyncML/1.1</VerProto><VerDTD>1.1</VerDTD><MsgID>1</MsgID><SessionID>1</SessionID><Target><LocURI>test</LocURI></Target><Source><LocURI>test</LocURI></Source></SyncHdr><SyncBody><Status></Status></SyncBody></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -384,7 +384,7 @@ } END_TEST -START_TEST (check_parser_status_cmdid) +START_TEST (wbxml_parser_status_cmdid) { const char *data = "<SyncML><SyncHdr><VerProto>SyncML/1.1</VerProto><VerDTD>1.1</VerDTD><MsgID>1</MsgID><SessionID>1</SessionID><Target><LocURI>test</LocURI></Target><Source><LocURI>test</LocURI></Source></SyncHdr><SyncBody><Status><CmdID>1</CmdID></Status></SyncBody></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -412,7 +412,7 @@ } END_TEST -START_TEST (check_parser_status_msgref) +START_TEST (wbxml_parser_status_msgref) { const char *data = "<SyncML><SyncHdr><VerProto>SyncML/1.1</VerProto><VerDTD>1.1</VerDTD><MsgID>1</MsgID><SessionID>1</SessionID><Target><LocURI>test</LocURI></Target><Source><LocURI>test</LocURI></Source></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef></Status></SyncBody></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -440,7 +440,7 @@ } END_TEST -START_TEST (check_parser_status_cmdref) +START_TEST (wbxml_parser_status_cmdref) { const char *data = "<SyncML><SyncHdr><VerProto>SyncML/1.1</VerProto><VerDTD>1.1</VerDTD><MsgID>1</MsgID><SessionID>1</SessionID><Target><LocURI>test</LocURI></Target><Source><LocURI>test</LocURI></Source></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef></Status></SyncBody></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -468,7 +468,7 @@ } END_TEST -START_TEST (check_parser_status) +START_TEST (wbxml_parser_status) { const char *data = "<SyncML><SyncHdr><VerProto>SyncML/1.1</VerProto><VerDTD>1.1</VerDTD><MsgID>1</MsgID><SessionID>1</SessionID><Target><LocURI>test</LocURI></Target><Source><LocURI>test</LocURI></Source></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>0</CmdRef><Cmd>Sync</Cmd></Status></SyncBody></SyncML>"; SmlParser *parser = start_wbxml_parser(data); @@ -508,7 +508,7 @@ } END_TEST -START_TEST (check_parser_status2) +START_TEST (wbxml_parser_status2) { const char *data = "<SyncML><SyncHdr><VerProto>SyncML/1.1</VerProto><VerDTD>1.1</VerDTD><MsgID>1</MsgID><SessionID>1</SessionID><Target>... [truncated message content] |
From: <svn...@op...> - 2009-04-09 10:19:13
|
Author: bellmich Date: Thu Apr 9 12:19:05 2009 New Revision: 1037 URL: http://libsyncml.opensync.org/changeset/1037 Log: first implementation of dynamic test generation controlled by cmake Modified: trunk/tests/CMakeLists.txt trunk/tests/check_error.c trunk/tests/support.c trunk/tests/support.h Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Mon Apr 6 14:54:12 2009 (r1036) +++ trunk/tests/CMakeLists.txt Thu Apr 9 12:19:05 2009 (r1037) @@ -4,6 +4,35 @@ ADD_TEST( ${_testName} ${CMAKE_CURRENT_BINARY_DIR}/${_testName} ${CMAKE_CURRENT_SOURCE_DIR}/mobiles/${_testName} ) ENDMACRO( ADD_MOBILE_TEST ) +## start test +MACRO( SML_START_TEST _testLabel _testName _testSource ) + + if(COMMAND cmake_policy) + cmake_policy(SET CMP0003 NEW) + ## The macro ADD_CHECK_TEST creates false warning. + cmake_policy(SET CMP0002 OLD) + endif(COMMAND cmake_policy) + + BUILD_CHECK_TEST( ${_testName} ${CMAKE_CURRENT_BINARY_DIR}/${_testSource} ${ARGN} ) + + SET( SML_TESTCASE_CODE "SML_TESTCASE_START(\"${_testLabel}\")\n" ) + SET( SML_TESTCASE_NAME ${_testName} ) + SET( SML_TESTCASE_SOURCE ${_testSource} ) + +ENDMACRO( SML_START_TEST ) + +## add testcase to test +MACRO( SML_ADD_TESTCASE _testcase ) + SET( SML_TESTCASE_CODE "${SML_TESTCASE_CODE}SML_TESTCASE_ADD(${_testcase})\n" ) + ADD_TEST( ${_testcase} ${CMAKE_CURRENT_BINARY_DIR}/${SML_TESTCASE_NAME} ${_testcase} ) +ENDMACRO( SML_ADD_TESTCASE ) + +## flush test to source file and build it +MACRO( SML_END_TEST ) + SET( SML_TESTCASE_CODE "${SML_TESTCASE_CODE}SML_TESTCASE_END\n\n" ) + CONFIGURE_FILE( ${SML_TESTCASE_SOURCE} ${CMAKE_CURRENT_BINARY_DIR}/${SML_TESTCASE_SOURCE} ) +ENDMACRO( SML_END_TEST ) + IF( ENABLE_UNIT_TEST ) LINK_DIRECTORIES( ${GLIB2_LIBRARY_DIRS} ${LIBXML2_LIBRARY_DIRS} ${OPENOBEX_LIBRARY_DIRS} ${LIBWBXML2_LIBRARY_DIRS} ${LIBSOUP2_LIBRARY_DIRS} ${BLUEZ_LIBRARY_DIRS} ${CHECK_LIBRARY_DIRS} ) if(COMMAND cmake_policy) @@ -18,7 +47,28 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${GLIB2_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIRS} ${LIBWBXML2_INCLUDE_DIRS} ${LIBSOUP2_INCLUDE_DIRS} ) # add tests SET( TEST_TARGET_LIBRARIES support ) - ADD_CHECK_TEST( error check_error.c ${TEST_TARGET_LIBRARIES} ) + + ## error tests + SML_START_TEST( "error" error check_error.c ${TEST_TARGET_LIBRARIES} ) + SML_ADD_TESTCASE( error_create ) + SML_ADD_TESTCASE( error_create_null ) + SML_ADD_TESTCASE( error_free_null ) + SML_ADD_TESTCASE( error_free_null2 ) + SML_ADD_TESTCASE( error_free ) + SML_ADD_TESTCASE( error_check_null ) + SML_ADD_TESTCASE( error_check_null2 ) + SML_ADD_TESTCASE( error_check ) + SML_ADD_TESTCASE( error_check2 ) + SML_ADD_TESTCASE( error_update_null ) + SML_ADD_TESTCASE( error_update_null2 ) + SML_ADD_TESTCASE( error_update ) + SML_ADD_TESTCASE( error_update2 ) + SML_ADD_TESTCASE( error_set_null ) + SML_ADD_TESTCASE( error_set_null2 ) + SML_ADD_TESTCASE( error_duplicate_null ) + SML_ADD_TESTCASE( error_class ) + SML_END_TEST() + ADD_CHECK_TEST( elements check_elements.c ${TEST_TARGET_LIBRARIES} ) ADD_CHECK_TEST( xml-fix-broken-item-data check_xml_fix_broken_item_data.c ${TEST_TARGET_LIBRARIES} ) ADD_CHECK_TEST( xmlparser check_xml_parser.c ${TEST_TARGET_LIBRARIES} ) Modified: trunk/tests/check_error.c ============================================================================== --- trunk/tests/check_error.c Mon Apr 6 14:54:12 2009 (r1036) +++ trunk/tests/check_error.c Thu Apr 9 12:19:05 2009 (r1037) @@ -18,7 +18,7 @@ * */ -#include "support.h" +#include "tests/support.h" #include <libsyncml/syncml.h> #include <libsyncml/sml_error_internals.h> @@ -210,48 +210,5 @@ } END_TEST -Suite *error_suite(void) -{ - Suite *s = suite_create("Error"); - //Suite *s2 = suite_create("Error"); - - create_case(s, "error_create", error_create); - create_case(s, "error_create_null", error_create_null); - create_case(s, "error_free_null", error_free_null); - create_case(s, "error_free_null2", error_free_null2); - create_case(s, "error_free", error_free); - create_case(s, "error_check_null", error_check_null); - create_case(s, "error_check_null2", error_check_null2); - create_case(s, "error_check", error_check); - create_case(s, "error_check2", error_check2); - create_case(s, "error_update_null", error_update_null); - create_case(s, "error_update_null2", error_update_null2); - create_case(s, "error_update", error_update); - create_case(s, "error_update2", error_update2); - create_case(s, "error_set_null", error_set_null); - create_case(s, "error_set_null2", error_set_null2); - create_case(s, "error_duplicate_null", error_duplicate_null); - create_case(s, "error_class", error_class); - - return s; -} - -int main(void) -{ - configure_environment(); +@SML_TESTCASE_CODE@ - int nf; - - Suite *s = error_suite(); - - SRunner *sr; - sr = srunner_create(s); - - srunner_run_all(sr, CK_VERBOSE); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - - cleanup_environment(); - - return (nf == 0) ? 0 : 1; -} Modified: trunk/tests/support.c ============================================================================== --- trunk/tests/support.c Mon Apr 6 14:54:12 2009 (r1036) +++ trunk/tests/support.c Thu Apr 9 12:19:05 2009 (r1037) @@ -160,3 +160,60 @@ timestr.tv_nsec = nanoseconds; return nanosleep(×tr, NULL); } + +/* create test case stuff */ + +static void sml_testsuite_all(Suite *s, struct sml_testcase_s *tc) +{ + unsigned int i; + for (i=0; tc[i].name; i++) + create_case(s, tc[i].name, tc[i].func); +} + +static unsigned int sml_testsuite_selected( + Suite *s, + int argc, char **argv, + struct sml_testcase_s *tc) +{ + int i, j, n=0; + /* Also argv[0]! for symlink-ed calls */ + for (i=0; argc > i; i++) { + for (j=0; tc[j].name; j++) { + if (strcmp(g_basename(argv[i]), tc[j].name)) + continue; + + create_case(s, tc[j].name, tc[j].func); + n++; + } + } + + return n; +} + +int sml_testsuite( + int argc, + char **argv, + const char *unittest, + struct sml_testcase_s *tc) +{ + configure_environment(); + + int nf; + Suite *s = suite_create(unittest); + SRunner *sr; + + /* check_env(); */ + + if (!sml_testsuite_selected(s, argc, argv, tc)) + sml_testsuite_all(s, tc); + + sr = srunner_create(s); + srunner_run_all(sr, CK_VERBOSE); + nf = srunner_ntests_failed(sr); + srunner_free(sr); + + cleanup_environment(); + + return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} + Modified: trunk/tests/support.h ============================================================================== --- trunk/tests/support.h Mon Apr 6 14:54:12 2009 (r1036) +++ trunk/tests/support.h Thu Apr 9 12:19:05 2009 (r1037) @@ -18,6 +18,9 @@ * */ +#ifndef _TESTS_SUPPORT_H +#define _TESTS_SUPPORT_H + #include <check.h> #include <libsyncml/syncml.h> #include <libsyncml/syncml_internals.h> @@ -58,3 +61,34 @@ #endif /* THREAD_SAFE_CHECK */ + +/* setup test cases */ + +#define SML_TESTCASE_START(x) \ + const char *_unittest = (#x); \ + struct sml_testcase_s sml_testcase[] = { + +#define SML_TESTCASE_ADD(x) { (#x), x }, + +#define SML_TESTCASE_END \ + { NULL, NULL } \ + }; \ + \ +int main(int argc, char **argv) \ +{ \ + return sml_testsuite(argc, argv, _unittest, sml_testcase); \ +} + +struct sml_testcase_s { + const char *name; + void *func; +}; + + +int sml_testsuite( + int argc, + char **argv, + const char *unittest, + struct sml_testcase_s *tc); + +#endif // _TESTS_SUPPORT_H |
From: <svn...@op...> - 2009-04-09 08:43:52
|
Author: bellmich Date: Thu Apr 9 10:43:39 2009 New Revision: 5568 URL: http://www.opensync.org/changeset/5568 Log: fixed the error handling of the ds_*_commit functions Modified: plugins/syncml/src/syncml_ds_client.c plugins/syncml/src/syncml_ds_server.c Modified: plugins/syncml/src/syncml_ds_client.c ============================================================================== --- plugins/syncml/src/syncml_ds_client.c Wed Apr 8 22:47:51 2009 (r5567) +++ plugins/syncml/src/syncml_ds_client.c Thu Apr 9 10:43:39 2009 (r5568) @@ -168,13 +168,17 @@ osync_trace(TRACE_EXIT, "%s", __func__); return; - /* FIXME: error handling must cleaned up - check context */ error: osync_error_set(&oserror, OSYNC_ERROR_GENERIC, "%s", smlErrorPrint(&error)); smlErrorDeref(&error); oserror: + if (tracer) { + osync_change_unref(change); + osync_context_unref(ctx); + safe_free((gpointer *) tracer); + } osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&oserror)); - /* report_error_on_context(&(database->commitCtx), &oserror, TRUE); */ + report_error_on_context(&ctx, &oserror, TRUE); } void ds_client_committed_all(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data) Modified: plugins/syncml/src/syncml_ds_server.c ============================================================================== --- plugins/syncml/src/syncml_ds_server.c Wed Apr 8 22:47:51 2009 (r5567) +++ plugins/syncml/src/syncml_ds_server.c Thu Apr 9 10:43:39 2009 (r5568) @@ -162,13 +162,17 @@ osync_trace(TRACE_EXIT, "%s", __func__); return; - /* the context handling in case of an error is wrong */ error: osync_error_set(&oserror, OSYNC_ERROR_GENERIC, "%s", smlErrorPrint(&error)); smlErrorDeref(&error); oserror: + if (tracer) { + osync_change_unref(change); + osync_context_unref(ctx); + safe_free((gpointer *) tracer); + } osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&oserror)); - /* report_error_on_context(&(database->commitCtx), &oserror, TRUE); */ + report_error_on_context(&ctx, &oserror, TRUE); } void ds_server_committed_all(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data) |
From: <svn...@op...> - 2009-04-08 20:47:58
|
Author: cdfrey Date: Wed Apr 8 22:47:51 2009 New Revision: 5567 URL: http://www.opensync.org/changeset/5567 Log: Define HANDLE_LIBICAL_MEMORY, with safeguards, to avoid compiler warning Modified: plugins/evolution2/src/evolution2_sync.h plugins/evolution2/tools/list_sources.c plugins/evolution2/tools/test_uri.c Modified: plugins/evolution2/src/evolution2_sync.h ============================================================================== --- plugins/evolution2/src/evolution2_sync.h Wed Apr 8 22:22:24 2009 (r5566) +++ plugins/evolution2/src/evolution2_sync.h Wed Apr 8 22:47:51 2009 (r5567) @@ -1,7 +1,26 @@ #ifndef EVO2_SYNC_H #define EVO2_SYNC_H -//#include "evo2_sync.h" +// +// Some versions of libical use a ring buffer for the following +// functions, for which the library manages memory. Somewhere along +// the line, this was fixed so that the application was responsible +// for freeing the strings returned by these functions. A warning +// was added to the header that would display if HANDLE_LIBICAL_MEMORY +// was not defined. +// +// Even newer versions of evolution-data-server, which this plugin +// depends on, get rid of some of these functions, while newer +// versions of libical add _r variants that implement the +// application-free functinality. +// +// Since this plugin does not use these functions, we disable the +// warning by defining HANDLE_LIBICAL_MEMORY, then include the +// headers, and then purposely break the troublesome functions +// so that if a programmer tries to use them later on, he'll know +// to handle them with care. +// +#define HANDLE_LIBICAL_MEMORY 1 #include <opensync/opensync.h> @@ -9,6 +28,18 @@ #include <libebook/e-book.h> #include <libedataserver/e-data-server-util.h> +#define icalreqstattype_as_string() See_evolution2_sync_h_for_note +#define icalproperty_as_ical_string() See_evolution2_sync_h_for_note +#define icalproperty_get_parameter_as_string() See_evolution2_sync_h_for_note +#define icalproperty_get_value_as_string() See_evolution2_sync_h_for_note +#define icallangbind_property_eval_string() See_evolution2_sync_h_for_note +#define icalperiodtype_as_ical_string() See_evolution2_sync_h_for_note +#define icaltime_as_ical_string() See_evolution2_sync_h_for_note +#define icalvalue_as_ical_string() See_evolution2_sync_h_for_note +#define icalcomponent_as_ical_string() See_evolution2_sync_h_for_note +#define e_cal_component_get_recurid_as_string() See_evolution2_sync_h_for_note + + typedef struct evo2_location { char *name; char *uri; Modified: plugins/evolution2/tools/list_sources.c ============================================================================== --- plugins/evolution2/tools/list_sources.c Wed Apr 8 22:22:24 2009 (r5566) +++ plugins/evolution2/tools/list_sources.c Wed Apr 8 22:47:51 2009 (r5567) @@ -1,3 +1,5 @@ +// see note in ../src/evolution2_sync.h +#define HANDLE_LIBICAL_MEMORY 1 #include <glib.h> #include <libecal/e-cal.h> #include <libebook/e-book.h> Modified: plugins/evolution2/tools/test_uri.c ============================================================================== --- plugins/evolution2/tools/test_uri.c Wed Apr 8 22:22:24 2009 (r5566) +++ plugins/evolution2/tools/test_uri.c Wed Apr 8 22:47:51 2009 (r5567) @@ -1,3 +1,5 @@ +// see note in ../src/evolution2_sync.h +#define HANDLE_LIBICAL_MEMORY 1 #include <string.h> #include <glib.h> #include <libecal/e-cal.h> |
From: <svn...@op...> - 2009-04-08 20:23:18
|
Author: cdfrey Date: Wed Apr 8 22:22:24 2009 New Revision: 5566 URL: http://www.opensync.org/changeset/5566 Log: Removed unused code and variables to clean up strict compiler warnings in plugin Modified: trunk/opensync/plugin/opensync_objtype_sink.c Modified: trunk/opensync/plugin/opensync_objtype_sink.c ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.c Wed Apr 8 21:47:54 2009 (r5565) +++ trunk/opensync/plugin/opensync_objtype_sink.c Wed Apr 8 22:22:24 2009 (r5566) @@ -406,13 +406,7 @@ void osync_objtype_sink_committed_all(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx) { OSyncObjTypeSinkFunctions functions; - int i = 0; - OSyncList *o = NULL; - OSyncList *c = NULL; - OSyncError *error = NULL; - OSyncChange *change = NULL; - OSyncContext *context = NULL; - + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, sink, info, ctx); osync_assert(sink); osync_assert(ctx); @@ -426,10 +420,6 @@ osync_trace(TRACE_EXIT, "%s", __func__); return; - error: - osync_context_report_osyncerror(ctx, error); - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); - osync_error_unref(&error); } osync_bool osync_objtype_sink_is_enabled(OSyncObjTypeSink *sink) |
From: <svn...@op...> - 2009-04-08 19:48:00
|
Author: scriptor Date: Wed Apr 8 21:47:54 2009 New Revision: 5565 URL: http://www.opensync.org/changeset/5565 Log: Update of the valgrind suppressions file. Modified: plugins/ldap-sync/tests/opensync.suppr Modified: plugins/ldap-sync/tests/opensync.suppr ============================================================================== --- plugins/ldap-sync/tests/opensync.suppr Wed Apr 8 21:47:45 2009 (r5564) +++ plugins/ldap-sync/tests/opensync.suppr Wed Apr 8 21:47:54 2009 (r5565) @@ -3416,183 +3416,8 @@ } -{ - <insert a suppression name here> - Memcheck:Addr4 - obj:/lib/libglib-2.0.so.0.1800.3 - fun:osync_hashtable_update_change - fun:ldap_plugin_commit_change - fun:osync_objtype_sink_commit_change - fun:_osync_client_handle_commit_change - fun:_osync_client_message_handler - fun:_incoming_dispatch - fun:g_main_context_dispatch - obj:/lib/libglib-2.0.so.0.1800.3 - fun:g_main_loop_run - obj:/lib/libglib-2.0.so.0.1800.3 - fun:start_thread - fun:clone - obj:* - obj:* - obj:* - obj:* -} - - -{ - <insert a suppression name here> - Memcheck:Addr4 - obj:/lib/libglib-2.0.so.0.1800.3 - fun:osync_hashtable_update_change - fun:ldap_plugin_commit_change - fun:osync_objtype_sink_commit_change - fun:_osync_client_handle_commit_change - fun:_osync_client_message_handler - fun:_incoming_dispatch - fun:g_main_context_dispatch - obj:/lib/libglib-2.0.so.0.1800.3 - fun:g_main_loop_run - obj:/lib/libglib-2.0.so.0.1800.3 - fun:start_thread - fun:clone - obj:* - obj:* - obj:* - obj:* -} - - -{ - <insert a suppression name here> - Memcheck:Addr4 - obj:/lib/libglib-2.0.so.0.1800.3 - fun:osync_hashtable_report - fun:osync_hashtable_update_change - fun:ldap_plugin_commit_change - fun:osync_objtype_sink_commit_change - fun:_osync_client_handle_commit_change - fun:_osync_client_message_handler - fun:_incoming_dispatch - fun:g_main_context_dispatch - obj:/lib/libglib-2.0.so.0.1800.3 - fun:g_main_loop_run - obj:/lib/libglib-2.0.so.0.1800.3 - fun:start_thread - fun:clone -} - - -{ - <insert a suppression name here> - Memcheck:Addr4 - obj:/lib/libglib-2.0.so.0.1800.3 - fun:osync_hashtable_report - fun:osync_hashtable_update_change - fun:ldap_plugin_commit_change - fun:osync_objtype_sink_commit_change - fun:_osync_client_handle_commit_change - fun:_osync_client_message_handler - fun:_incoming_dispatch - fun:g_main_context_dispatch - obj:/lib/libglib-2.0.so.0.1800.3 - fun:g_main_loop_run - obj:/lib/libglib-2.0.so.0.1800.3 - fun:start_thread - fun:clone -} - - -{ - <insert a suppression name here> - Memcheck:Addr4 - obj:/lib/libglib-2.0.so.0.1800.3 - fun:osync_hashtable_update_change - fun:ldap_plugin_commit_change - fun:osync_objtype_sink_commit_change - fun:_osync_client_handle_commit_change - fun:_osync_client_message_handler - fun:_incoming_dispatch - fun:g_main_context_dispatch - obj:/lib/libglib-2.0.so.0.1800.3 - fun:g_main_loop_run - obj:/lib/libglib-2.0.so.0.1800.3 - fun:start_thread - fun:clone - obj:* - obj:* - obj:* - obj:* -} - - -{ - <insert a suppression name here> - Memcheck:Addr4 - obj:/lib/libglib-2.0.so.0.1800.3 - fun:osync_hashtable_update_change - fun:ldap_plugin_commit_change - fun:osync_objtype_sink_commit_change - fun:_osync_client_handle_commit_change - fun:_osync_client_message_handler - fun:_incoming_dispatch - fun:g_main_context_dispatch - obj:/lib/libglib-2.0.so.0.1800.3 - fun:g_main_loop_run - obj:/lib/libglib-2.0.so.0.1800.3 - fun:start_thread - fun:clone - obj:* - obj:* - obj:* - obj:* -} -{ - <insert a suppression name here> - Memcheck:Addr4 - obj:/lib/libglib-2.0.so.0.1800.3 - fun:osync_hashtable_update_change - fun:ldap_plugin_commit_change - fun:osync_objtype_sink_commit_change - fun:_osync_client_handle_commit_change - fun:_osync_client_message_handler - fun:_incoming_dispatch - fun:g_main_context_dispatch - obj:/lib/libglib-2.0.so.0.1800.3 - fun:g_main_loop_run - obj:/lib/libglib-2.0.so.0.1800.3 - fun:start_thread - fun:clone - obj:* - obj:* - obj:* - obj:* -} - - -{ - <insert a suppression name here> - Memcheck:Addr4 - obj:/lib/libglib-2.0.so.0.1800.3 - fun:osync_hashtable_update_change - fun:ldap_plugin_commit_change - fun:osync_objtype_sink_commit_change - fun:_osync_client_handle_commit_change - fun:_osync_client_message_handler - fun:_incoming_dispatch - fun:g_main_context_dispatch - obj:/lib/libglib-2.0.so.0.1800.3 - fun:g_main_loop_run - obj:/lib/libglib-2.0.so.0.1800.3 - fun:start_thread - fun:clone - obj:* - obj:* - obj:* - obj:* -} - { @@ -3883,52 +3708,6 @@ } -{ - <insert a suppression name here> - Memcheck:Addr4 - obj:/lib/libglib-2.0.so.0.1800.3 - fun:osync_hashtable_update_change - fun:ldap_plugin_commit_change - fun:osync_objtype_sink_commit_change - fun:_osync_client_handle_commit_change - fun:_osync_client_message_handler - fun:_incoming_dispatch - fun:g_main_context_dispatch - obj:/lib/libglib-2.0.so.0.1800.3 - fun:g_main_loop_run - obj:/lib/libglib-2.0.so.0.1800.3 - fun:start_thread - fun:clone - obj:* - obj:* - obj:* - obj:* -} - - - -{ - <insert a suppression name here> - Memcheck:Addr4 - obj:/lib/libglib-2.0.so.0.1800.3 - fun:osync_hashtable_update_change - fun:ldap_plugin_commit_change - fun:osync_objtype_sink_commit_change - fun:_osync_client_handle_commit_change - fun:_osync_client_message_handler - fun:_incoming_dispatch - fun:g_main_context_dispatch - obj:/lib/libglib-2.0.so.0.1800.3 - fun:g_main_loop_run - obj:/lib/libglib-2.0.so.0.1800.3 - fun:start_thread - fun:clone - obj:* - obj:* - obj:* - obj:* -} - { @@ -4012,28 +3791,6 @@ { <insert a suppression name here> - Memcheck:Addr4 - obj:/lib/libglib-2.0.so.0.1800.3 - fun:osync_hashtable_update_change - fun:ldap_plugin_commit_change - fun:osync_objtype_sink_commit_change - fun:_osync_client_handle_commit_change - fun:_osync_client_message_handler - fun:_incoming_dispatch - fun:g_main_context_dispatch - obj:/lib/libglib-2.0.so.0.1800.3 - fun:g_main_loop_run - obj:/lib/libglib-2.0.so.0.1800.3 - fun:start_thread - fun:clone - obj:* - obj:* - obj:* - obj:* -} - -{ - <insert a suppression name here> Memcheck:Leak fun:malloc fun:xmlDictCreate |
From: <svn...@op...> - 2009-04-08 19:47:51
|
Author: scriptor Date: Wed Apr 8 21:47:45 2009 New Revision: 5564 URL: http://www.opensync.org/changeset/5564 Log: Removed several osync_error_unref() calls, so that the error keeps being set for the calling functions. Modified: plugins/ldap-sync/src/ldap_connect.c plugins/ldap-sync/src/ldap_plugin.c Modified: plugins/ldap-sync/src/ldap_connect.c ============================================================================== --- plugins/ldap-sync/src/ldap_connect.c Wed Apr 8 20:08:33 2009 (r5563) +++ plugins/ldap-sync/src/ldap_connect.c Wed Apr 8 21:47:45 2009 (r5564) @@ -571,8 +571,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); - return FALSE; } @@ -724,8 +722,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); - return FALSE; } @@ -1195,8 +1191,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); - return FALSE; } @@ -1568,7 +1562,6 @@ osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); return FALSE; } @@ -1750,8 +1743,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); - return NULL; } @@ -2154,8 +2145,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); - return FALSE; } @@ -2456,8 +2445,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); - return NULL; } @@ -2593,8 +2580,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); - return FALSE; } @@ -2735,8 +2720,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); - return FALSE; } @@ -2826,8 +2809,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); - return FALSE; } @@ -3246,7 +3227,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); /* String array contains the same values - no modify */ return FALSE; @@ -3340,8 +3320,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); - return NULL; } @@ -3807,8 +3785,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); - return; } @@ -3949,8 +3925,6 @@ osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); - return FALSE; } @@ -4152,8 +4126,6 @@ osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); - return FALSE; } @@ -4381,8 +4353,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); - return NULL; } Modified: plugins/ldap-sync/src/ldap_plugin.c ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.c Wed Apr 8 20:08:33 2009 (r5563) +++ plugins/ldap-sync/src/ldap_plugin.c Wed Apr 8 21:47:45 2009 (r5564) @@ -508,8 +508,6 @@ osync_context_report_osyncwarning(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - osync_error_unref(error); - return FALSE; } |
From: <svn...@op...> - 2009-04-08 18:08:40
|
Author: dgollub Date: Wed Apr 8 20:08:33 2009 New Revision: 5563 URL: http://www.opensync.org/changeset/5563 Log: Changed E-Mail contact. opensync.org is facing issues with MX record. Modified: trunk/AUTHORS Modified: trunk/AUTHORS ============================================================================== --- trunk/AUTHORS Wed Apr 8 17:38:14 2009 (r5562) +++ trunk/AUTHORS Wed Apr 8 20:08:33 2009 (r5563) @@ -2,4 +2,4 @@ arm...@de... Daniel Gollub -dg...@op... +g...@b1... |
From: <svn...@op...> - 2009-04-08 15:38:34
|
Author: bellmich Date: Wed Apr 8 17:38:14 2009 New Revision: 5562 URL: http://www.opensync.org/changeset/5562 Log: replace batch_commit by commit and committed_all (callbacks) The error handling in case of a single failing change was and is wrong. Modified: plugins/syncml/src/syncml_ds_client.c plugins/syncml/src/syncml_ds_client.h plugins/syncml/src/syncml_ds_server.c plugins/syncml/src/syncml_ds_server.h Modified: plugins/syncml/src/syncml_ds_client.c ============================================================================== --- plugins/syncml/src/syncml_ds_client.c Wed Apr 8 17:14:01 2009 (r5561) +++ plugins/syncml/src/syncml_ds_client.c Wed Apr 8 17:38:14 2009 (r5562) @@ -43,7 +43,8 @@ osync_objtype_sink_set_connect_func(sink, syncml_connect); osync_objtype_sink_set_connect_done_func(sink, syncml_connect_done); osync_objtype_sink_set_get_changes_func(sink, ds_client_get_changeinfo); - osync_objtype_sink_set_batch_commit_func(sink, ds_client_batch_commit); + osync_objtype_sink_set_commit_func(sink, ds_client_commit); + osync_objtype_sink_set_committed_all_func(sink, ds_client_committed_all); /* Request a state database from the framework. */ osync_objtype_sink_enable_state_db(sink, TRUE); @@ -126,7 +127,57 @@ return; } -void ds_client_batch_commit(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncContext **contexts, OSyncChange **changes, void *data) +void ds_client_commit(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change, void *data) +{ + osync_trace(TRACE_ENTRY, "%s", __func__); + g_assert(ctx); + + SmlError *error = NULL; + OSyncError *oserror = NULL; + SmlDatabase *database = (SmlDatabase*)data; + + database->pendingCommits++; + + struct commitContext *tracer = osync_try_malloc0(sizeof(struct commitContext), &oserror); + if (!tracer) + goto oserror; + tracer->change = change; + tracer->context = ctx; + tracer->database = database; + + osync_change_ref(change); + osync_context_ref(ctx); + + // prepare data + OSyncData *odata = osync_change_get_data(change); + char *buf = NULL; + unsigned int size = 0; + osync_data_get_data(odata, &buf, &size); + + osync_trace(TRACE_INTERNAL, "%s: Committing entry \"%s\": \"%s\"", + __func__, osync_change_get_uid(change), buf); + if (!smlDataSyncAddChange( + database->env->dsObject2, + database->url, + _get_changetype(change), + osync_change_get_uid(change), + buf, size, + tracer, &error)) + goto error; + + osync_trace(TRACE_EXIT, "%s", __func__); + return; + + /* FIXME: error handling must cleaned up - check context */ +error: + osync_error_set(&oserror, OSYNC_ERROR_GENERIC, "%s", smlErrorPrint(&error)); + smlErrorDeref(&error); +oserror: + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&oserror)); + /* report_error_on_context(&(database->commitCtx), &oserror, TRUE); */ +} + +void ds_client_committed_all(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data) { osync_trace(TRACE_ENTRY, "%s", __func__); g_assert(ctx); @@ -138,7 +189,6 @@ database->commitCtx = ctx; osync_context_ref(database->commitCtx); - database->pendingCommits = get_num_changes(changes); if (database->pendingCommits == 0) { // if there are no changes then we do nothing @@ -149,42 +199,6 @@ return; } - // a batch commit should be called after the first DsSession - // was completely performed - g_assert(database->pendingChanges == 0); - - int i; - for (i=0; i < database->pendingCommits; i++) - { - struct commitContext *tracer = osync_try_malloc0(sizeof(struct commitContext), &oserror); - if (!tracer) - goto oserror; - tracer->change = changes[i]; - tracer->context = contexts[i]; - tracer->database = database; - - osync_change_ref(changes[i]); - osync_context_ref(contexts[i]); - - // prepare data - OSyncData *data = osync_change_get_data(changes[i]); - char *buf = NULL; - unsigned int size = 0; - osync_data_get_data(data, &buf, &size); - - osync_trace(TRACE_INTERNAL, "%s: Committing entry \"%s\": \"%s\"", - __func__, osync_change_get_uid(changes[i]), buf); - if (!smlDataSyncAddChange( - database->env->dsObject2, - database->url, - _get_changetype(changes[i]), - osync_change_get_uid(changes[i]), - buf, size, - tracer, &error)) - goto error; - - } - /* I (bellmich) tested a lot with OCS and the result is * that it is required to start a new OMA DS session for * the data uploading. If I only try to send a new alert @@ -213,7 +227,7 @@ error: osync_error_set(&oserror, OSYNC_ERROR_GENERIC, "%s", smlErrorPrint(&error)); smlErrorDeref(&error); -oserror: +/* oserror: */ osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&oserror)); report_error_on_context(&(database->commitCtx), &oserror, TRUE); } Modified: plugins/syncml/src/syncml_ds_client.h ============================================================================== --- plugins/syncml/src/syncml_ds_client.h Wed Apr 8 17:14:01 2009 (r5561) +++ plugins/syncml/src/syncml_ds_client.h Wed Apr 8 17:38:14 2009 (r5562) @@ -10,12 +10,17 @@ osync_bool slow_sync, void *data); -void ds_client_batch_commit( +void ds_client_commit( + OSyncObjTypeSink *sink, + OSyncPluginInfo *info, + OSyncContext *ctx, + OSyncChange *change, + void *data); + +void ds_client_committed_all( OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, - OSyncContext **contexts, - OSyncChange **changes, void *data); SmlBool ds_client_init_databases( Modified: plugins/syncml/src/syncml_ds_server.c ============================================================================== --- plugins/syncml/src/syncml_ds_server.c Wed Apr 8 17:14:01 2009 (r5561) +++ plugins/syncml/src/syncml_ds_server.c Wed Apr 8 17:38:14 2009 (r5562) @@ -42,7 +42,8 @@ osync_objtype_sink_set_connect_func(sink, syncml_connect); osync_objtype_sink_set_connect_done_func(sink, syncml_connect_done); osync_objtype_sink_set_get_changes_func(sink, ds_server_get_changeinfo); - osync_objtype_sink_set_batch_commit_func(sink, ds_server_batch_commit); + osync_objtype_sink_set_commit_func(sink, ds_server_commit); + osync_objtype_sink_set_committed_all_func(sink, ds_server_committed_all); // Request a state database from the framework. osync_objtype_sink_enable_state_db(sink, TRUE); @@ -118,7 +119,7 @@ return; } -void ds_server_batch_commit(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncContext **contexts, OSyncChange **changes, void *data) +void ds_server_commit(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change, void *data) { osync_trace(TRACE_ENTRY, "%s", __func__); g_assert(ctx); @@ -127,47 +128,64 @@ OSyncError *oserror = NULL; SmlDatabase *database = (SmlDatabase*)data; - database->env->gotDatabaseCommits++; - database->pendingCommits = get_num_changes(changes); + database->pendingCommits++; osync_trace(TRACE_INTERNAL, "%s - %i changes present to send", __func__, database->pendingCommits); - database->commitCtx = ctx; - osync_context_ref(database->commitCtx); - - g_assert(database->pendingChanges == 0); - - int i; - for (i=0; i < database->pendingCommits; i++) - { - struct commitContext *tracer = osync_try_malloc0(sizeof(struct commitContext), &oserror); - if (!tracer) - goto oserror; - tracer->change = changes[i]; - tracer->context = contexts[i]; - tracer->database = database; - - osync_change_ref(changes[i]); - osync_context_ref(contexts[i]); - - // prepare data - OSyncData *data = osync_change_get_data(changes[i]); - char *buf = NULL; - unsigned int size = 0; - osync_data_get_data(data, &buf, &size); - - osync_trace(TRACE_INTERNAL, "%s: Committing entry \"%s\": \"%s\"", - __func__, osync_change_get_uid(changes[i]), buf); - if (!smlDataSyncAddChange( + struct commitContext *tracer = osync_try_malloc0(sizeof(struct commitContext), &oserror); + if (!tracer) + goto oserror; + tracer->change = change; + tracer->context = ctx; + tracer->database = database; + + osync_change_ref(change); + osync_context_ref(ctx); + + // prepare data + OSyncData *odata = osync_change_get_data(change); + char *buf = NULL; + unsigned int size = 0; + osync_data_get_data(odata, &buf, &size); + + osync_trace(TRACE_INTERNAL, "%s: Committing entry \"%s\": \"%s\"", + __func__, osync_change_get_uid(change), buf); + if (!smlDataSyncAddChange( database->env->dsObject1, database->url, - _get_changetype(changes[i]), - osync_change_get_uid(changes[i]), + _get_changetype(change), + osync_change_get_uid(change), buf, size, tracer, &error)) - goto error; + goto error; + + osync_trace(TRACE_EXIT, "%s", __func__); + return; + + /* the context handling in case of an error is wrong */ +error: + osync_error_set(&oserror, OSYNC_ERROR_GENERIC, "%s", smlErrorPrint(&error)); + smlErrorDeref(&error); +oserror: + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&oserror)); + /* report_error_on_context(&(database->commitCtx), &oserror, TRUE); */ +} + +void ds_server_committed_all(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data) +{ + osync_trace(TRACE_ENTRY, "%s", __func__); + g_assert(ctx); + + SmlError *error = NULL; + OSyncError *oserror = NULL; + SmlDatabase *database = (SmlDatabase*)data; + + database->env->gotDatabaseCommits++; + + database->commitCtx = ctx; + osync_context_ref(database->commitCtx); - } + g_assert(database->pendingChanges == 0); if (g_list_length(database->env->databases) == database->env->gotDatabaseCommits && !smlDataSyncSendChanges(database->env->dsObject1, &error)) @@ -179,7 +197,6 @@ error: osync_error_set(&oserror, OSYNC_ERROR_GENERIC, "%s", smlErrorPrint(&error)); smlErrorDeref(&error); -oserror: osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&oserror)); report_error_on_context(&(database->commitCtx), &oserror, TRUE); } Modified: plugins/syncml/src/syncml_ds_server.h ============================================================================== --- plugins/syncml/src/syncml_ds_server.h Wed Apr 8 17:14:01 2009 (r5561) +++ plugins/syncml/src/syncml_ds_server.h Wed Apr 8 17:38:14 2009 (r5562) @@ -10,12 +10,17 @@ osync_bool slow_sync, void *data); -void ds_server_batch_commit( +void ds_server_commit( + OSyncObjTypeSink *sink, + OSyncPluginInfo *info, + OSyncContext *ctx, + OSyncChange *change, + void *data); + +void ds_server_committed_all( OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, - OSyncContext **contexts, - OSyncChange **changes, void *data); SmlBool ds_server_init_databases( |
From: <svn...@op...> - 2009-04-08 15:14:08
|
Author: bellmich Date: Wed Apr 8 17:14:01 2009 New Revision: 5561 URL: http://www.opensync.org/changeset/5561 Log: further batch_commit cleanups - documentation - CMakeLists.txt for test cases - TODOs Modified: trunk/docs/whitepaper/plugins.tex trunk/docs/whitepaper/synchronization.tex trunk/tests/CMakeLists.txt trunk/tests/engine-tests/check_engine.c Modified: trunk/docs/whitepaper/plugins.tex ============================================================================== --- trunk/docs/whitepaper/plugins.tex Wed Apr 8 17:08:25 2009 (r5560) +++ trunk/docs/whitepaper/plugins.tex Wed Apr 8 17:14:01 2009 (r5561) @@ -131,7 +131,7 @@ Connect & Optional \\ Connect Done & Optional \\ Get Changes & Required \\ -Commit / Batch Commit & Required (only Commit \textbf{or} Batch Commit) \\ +Commit & Required \\ Committed All & Optional (only available in combination with Commit)\\ Synchronization Done & Optional \\ Disconnect & Optional @@ -183,14 +183,9 @@ replied with \verb|osync_context_success()|. If Hashtable is already involved in the Get Changes functions, then the Commit function should update the Hashtable for the entries which get committed. -\subsection{Batch Commit} -The batch commit function is intended for protocols, device or application which -only allow batch committing (sending all changes at once). This function gets -called with an array of changes to be committed. \subsection{Committed All} This function is called after all entries have committed, even if error appeared -while committing. This function is not called if a Batch Commit function is -registered for this Sink. +while committing. \subsection{Synchronization Done} This function is called only after a successful synchronization. When using a Hashtable \verb|osync_hashtable_save()| should be called to store the Hashtable Modified: trunk/docs/whitepaper/synchronization.tex ============================================================================== --- trunk/docs/whitepaper/synchronization.tex Wed Apr 8 17:08:25 2009 (r5560) +++ trunk/docs/whitepaper/synchronization.tex Wed Apr 8 17:14:01 2009 (r5561) @@ -31,8 +31,7 @@ information which doesn't allow to do a binary compare? Weak compare? Is conversion to a common format for different parties required? \item Protocol. Does the protocol require to read only the latest changes or - all at once? Does the protocol support single commits or only all at once - (batch commit)? + all at once? \item Transport. Are various transport layer involved? Does it require to connect and disconnect in a specified way? Limited bandwidth? Example: Bluetooth, USB, ... Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Wed Apr 8 17:08:25 2009 (r5560) +++ trunk/tests/CMakeLists.txt Wed Apr 8 17:14:01 2009 (r5561) @@ -186,7 +186,6 @@ OSYNC_TESTCASE( engine-error engine_error_commit_error_modify) OSYNC_TESTCASE( engine-error engine_error_commit_error_delete) OSYNC_TESTCASE( engine-error engine_error_committed_all_error) -OSYNC_TESTCASE( engine-error engine_error_committed_all_batch_error) OSYNC_TESTCASE( engine-error engine_error_single_sync_done_error) OSYNC_TESTCASE( engine-error engine_error_dual_sync_done_error) OSYNC_TESTCASE( engine-error engine_error_triple_sync_done_error) Modified: trunk/tests/engine-tests/check_engine.c ============================================================================== --- trunk/tests/engine-tests/check_engine.c Wed Apr 8 17:08:25 2009 (r5560) +++ trunk/tests/engine-tests/check_engine.c Wed Apr 8 17:14:01 2009 (r5561) @@ -2032,7 +2032,6 @@ OSYNC_TESTCASE_ADD(engine_sync_read_write_stress) OSYNC_TESTCASE_ADD(engine_sync_read_write_stress2) -//batch commit //connect problem //get_changes problem |
From: <svn...@op...> - 2009-04-08 15:08:37
|
Author: bellmich Date: Wed Apr 8 17:08:25 2009 New Revision: 5560 URL: http://www.opensync.org/changeset/5560 Log: removed all disabled tests which used batch_commit Modified: trunk/tests/engine-tests/check_engine_error.c trunk/tests/sync-tests/check_multisync.c Modified: trunk/tests/engine-tests/check_engine_error.c ============================================================================== --- trunk/tests/engine-tests/check_engine_error.c Wed Apr 8 17:01:53 2009 (r5559) +++ trunk/tests/engine-tests/check_engine_error.c Wed Apr 8 17:08:25 2009 (r5560) @@ -2117,71 +2117,6 @@ } END_TEST -/* batch_commit no longer exists - -START_TEST (engine_error_committed_all_batch_error) -{ - char *testbed = setup_testbed("multisync_easy_new"); - char *formatdir = g_strdup_printf("%s/formats", testbed); - char *plugindir = g_strdup_printf("%s/plugins", testbed); - - g_setenv("BATCH_COMMIT", "7", TRUE); - g_setenv("COMMITTED_ALL_ERROR", "3", TRUE); - - OSyncError *error = NULL; - - OSyncGroup *group = osync_group_new(&error); - osync_group_set_schemadir(group, testbed); - osync_group_load(group, "configs/group", &error); - fail_unless(error == NULL, NULL); - - OSyncEngine *engine = osync_engine_new(group, &error); - fail_unless(engine != NULL, NULL); - fail_unless(error == NULL, NULL); - - osync_engine_set_schemadir(engine, testbed); - osync_engine_set_plugindir(engine, plugindir); - osync_engine_set_formatdir(engine, formatdir); - - osync_engine_set_memberstatus_callback(engine, member_status, GINT_TO_POINTER(1)); - osync_engine_set_enginestatus_callback(engine, engine_status, GINT_TO_POINTER(1)); - osync_engine_set_changestatus_callback(engine, entry_status, GINT_TO_POINTER(1)); - osync_engine_set_mappingstatus_callback(engine, mapping_status, GINT_TO_POINTER(1)); - osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, GINT_TO_POINTER(3)); - - fail_unless(osync_engine_initialize(engine, &error), NULL); - fail_unless(error == NULL, NULL); - - fail_unless(!synchronize_once(engine, &error), NULL); - fail_unless(osync_error_is_set(&error), NULL); - - osync_error_unref(&error); - osync_engine_finalize(engine, &error); - osync_engine_unref(engine); - - fail_unless(num_client_errors == 2, NULL); - fail_unless(num_client_connected == 3, NULL); - fail_unless(num_client_disconnected == 3, NULL); - fail_unless(num_client_written == 1, NULL); - fail_unless(num_change_read == 1, NULL); - fail_unless(num_change_written == 2, NULL); - fail_unless(num_change_error == 0, NULL); - fail_unless(num_mapping_errors == 0, NULL); - fail_unless(num_mapping_conflicts == 0, NULL); - fail_unless(num_engine_errors == 1, NULL); - fail_unless(num_engine_successful == 0, NULL); - - fail_unless(osync_testing_diff("data1", "data2")); - fail_unless(osync_testing_diff("data1", "data3")); - - g_free(formatdir); - g_free(plugindir); - - destroy_testbed(testbed); -} -END_TEST -*/ - START_TEST (engine_error_single_sync_done_error) { char *testbed = setup_testbed("multisync_easy_new"); Modified: trunk/tests/sync-tests/check_multisync.c ============================================================================== --- trunk/tests/sync-tests/check_multisync.c Wed Apr 8 17:01:53 2009 (r5559) +++ trunk/tests/sync-tests/check_multisync.c Wed Apr 8 17:08:25 2009 (r5560) @@ -1942,221 +1942,6 @@ } END_TEST -/* batch_commit is no longer supported - -START_TEST(multisync_easy_new_b) -{ - char *testbed = setup_testbed("multisync_easy_new"); - setenv("BATCH_COMMIT", "7", TRUE); - multisync_easy_new_inner(testbed); - destroy_testbed(testbed); -} -END_TEST -*/ - -/* batch_commit is no longer supported - -START_TEST(multisync_triple_del_b) -{ - char *testbed = setup_testbed("multisync_easy_new"); - setenv("BATCH_COMMIT", "7", TRUE); - multisync_triple_del_inner(testbed); - destroy_testbed(testbed); -} -END_TEST -*/ - -/* batch_commit is no longer supported - -START_TEST(multisync_conflict_hybrid_choose2_b) -{ - char *testbed = setup_testbed("multisync_conflict_changetype_choose"); - setenv("BATCH_COMMIT", "7", TRUE); - multisync_conflict_hybrid_choose2_inner(testbed); - destroy_testbed(testbed); -} -END_TEST -*/ - -/* batch_commit is no longer supported - -START_TEST(multisync_delayed_conflict_handler_b) -{ - char *testbed = setup_testbed("multisync_easy_new"); - setenv("BATCH_COMMIT", "7", TRUE); - multisync_delayed_conflict_handler_inner(testbed); - destroy_testbed(testbed); -} -END_TEST -*/ - -/* batch_commit is no longer supported - -START_TEST(multisync_delayed_slow_b) -{ - char *testbed = setup_testbed("multisync_easy_new"); - setenv("BATCH_COMMIT", "7", TRUE); - multisync_delayed_slow_inner(testbed); - destroy_testbed(testbed); -} -END_TEST -*/ - -/* batch_commit is no longer supported - -#if 0 -START_TEST(multisync_conflict_ignore_b) -{ - setenv("BATCH_COMMIT", "7", TRUE); - multisync_conflict_ignore(); - unsetenv("BATCH_COMMIT"); -} -END_TEST - -START_TEST(multisync_conflict_ignore2_b) -{ - setenv("BATCH_COMMIT", "7", TRUE); - setenv("NO_TIMEOUTS", "7", TRUE); - multisync_conflict_ignore2(); - unsetenv("BATCH_COMMIT"); - unsetenv("NO_TIMEOUTS"); -} -END_TEST - -START_TEST(multisync_conflict_hybrid_duplicate_b) -{ - setenv("BATCH_COMMIT", "7", TRUE); - multisync_conflict_hybrid_duplicate(); - unsetenv("BATCH_COMMIT"); -} -END_TEST - -/* batch_commit is no longer supported -{ - setenv("BATCH_COMMIT", "7", TRUE); - multisync_multi_conflict(); - unsetenv("BATCH_COMMIT"); -} -END_TEST - -START_TEST(multisync_zero_changes_b) -{ - setenv("BATCH_COMMIT", "7", TRUE); - char *testbed = setup_testbed("multisync_easy_new"); - - OSyncEnv *osync = init_env(); - OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); - - OSyncEngine *engine = init_engine(group); - osengine_set_conflict_callback(engine, conflict_handler_duplication, GINT_TO_POINTER(3)); - - synchronize_once(engine, NULL); - - fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); - - OSyncMappingTable *maptable = mappingtable_load(group, 1, 0); - check_mapping(maptable, 1, -1, 3, "testdata"); - check_mapping(maptable, 2, -1, 3, "testdata"); - check_mapping(maptable, 3, -1, 3, "testdata"); - mappingtable_close(maptable); - - OSyncHashTable *table = hashtable_load(group, 1, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 1); - check_hash(table, "testdata"); - osync_hashtable_close(table); - - fail_unless(num_engine_connected == 1, NULL); - fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_written == 1, NULL); - fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_change_read == 1, NULL); - fail_unless(num_mapping_conflicts == 0, NULL); - fail_unless(num_change_written == 2, NULL); - fail_unless(num_engine_end_conflicts == 1, NULL); - - setenv("NUM_BATCH_COMMITS", "0", TRUE); - - synchronize_once(engine, NULL); - - fail_unless(num_engine_connected == 1, NULL); - fail_unless(num_engine_read == 1, NULL); - fail_unless(num_engine_written == 1, NULL); - fail_unless(num_engine_disconnected == 1, NULL); - fail_unless(num_change_read == 0, NULL); - fail_unless(num_mapping_conflicts == 0, NULL); - fail_unless(num_change_written == 0, NULL); - fail_unless(num_engine_end_conflicts == 0, NULL); - - osync_testing_system_abort("rm -f data1/*"); - - unsetenv("NUM_BATCH_COMMITS"); - - synchronize_once(engine, NULL); - osengine_finalize(engine); - - maptable = mappingtable_load(group, 0, 0); - mappingtable_close(maptable); - - table = hashtable_load(group, 1, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 2, 0); - osync_hashtable_close(table); - - table = hashtable_load(group, 3, 0); - osync_hashtable_close(table); - - fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL); - fail_unless(!system("test \"x$(ls data3)\" = \"x\""), NULL); - - destroy_testbed(testbed); - unsetenv("BATCH_COMMIT"); -} -END_TEST - -START_TEST(multisync_conflict_hybrid_choose2_b2) -{ - setenv("BATCH_COMMIT", "2", TRUE); - multisync_conflict_hybrid_choose2(); - unsetenv("BATCH_COMMIT"); -} -END_TEST - -START_TEST(multisync_delayed_conflict_handler_b2) -{ - setenv("BATCH_COMMIT", "2", TRUE); - multisync_delayed_conflict_handler(); - unsetenv("BATCH_COMMIT"); -} -END_TEST - -START_TEST(multisync_conflict_ignore_b2) -{ - setenv("BATCH_COMMIT", "2", TRUE); - multisync_conflict_ignore(); - unsetenv("BATCH_COMMIT"); -} -END_TEST - -START_TEST(multisync_multi_conflict_b2) -{ - setenv("BATCH_COMMIT", "2", TRUE); - multisync_multi_conflict(); - unsetenv("BATCH_COMMIT"); -} -END_TEST -#endif -*/ - OSYNC_TESTCASE_START("multisync") OSYNC_TESTCASE_ADD(multisync_easy_new) OSYNC_TESTCASE_ADD(multisync_dual_new) @@ -2199,26 +1984,5 @@ OSYNC_TESTCASE_ADD(multisync_conflict_ignore) OSYNC_TESTCASE_ADD(multisync_conflict_ignore2) -/* batch_commit is no longer supported - -OSYNC_TESTCASE_ADD(multisync_easy_new_b) -OSYNC_TESTCASE_ADD(multisync_triple_del_b) -OSYNC_TESTCASE_ADD(multisync_conflict_hybrid_choose2_b) -OSYNC_TESTCASE_ADD(multisync_delayed_conflict_handler_b) -OSYNC_TESTCASE_ADD(multisync_delayed_slow_b) -#if 0 -OSYNC_TESTCASE_ADD(multisync_conflict_ignore_b) -OSYNC_TESTCASE_ADD(multisync_conflict_ignore2_b) -OSYNC_TESTCASE_ADD(multisync_conflict_hybrid_duplicate_b) -OSYNC_TESTCASE_ADD(multisync_multi_conflict_b) -OSYNC_TESTCASE_ADD(multisync_zero_changes_b) - -OSYNC_TESTCASE_ADD(multisync_conflict_hybrid_choose2_b2) -OSYNC_TESTCASE_ADD(multisync_delayed_conflict_handler_b2) -OSYNC_TESTCASE_ADD(multisync_conflict_ignore_b2) -OSYNC_TESTCASE_ADD(multisync_multi_conflict_b2) -#endif -*/ - OSYNC_TESTCASE_END |
Author: bellmich Date: Wed Apr 8 17:01:53 2009 New Revision: 5559 URL: http://www.opensync.org/changeset/5559 Log: removed batch_commit (please see ticket #1078) Modified: trunk/misc/schemas/syncmember.xsd trunk/opensync.sym trunk/opensync/client/opensync_client_proxy_private.h trunk/opensync/engine/opensync_engine.h trunk/opensync/group/opensync_group.c trunk/opensync/group/opensync_member.c trunk/opensync/ipc/opensync_serializer.c trunk/opensync/plugin/opensync_objtype_sink.c trunk/opensync/plugin/opensync_objtype_sink.h trunk/opensync/plugin/opensync_objtype_sink_internals.h trunk/opensync/plugin/opensync_objtype_sink_private.h trunk/tests/engine-tests/check_engine_error.c trunk/tests/mock-plugin/mock_sync.c trunk/tests/support.c trunk/tests/sync-tests/check_multisync.c trunk/tools/osyncplugin.c Modified: trunk/misc/schemas/syncmember.xsd ============================================================================== --- trunk/misc/schemas/syncmember.xsd Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/misc/schemas/syncmember.xsd Wed Apr 8 17:01:53 2009 (r5559) @@ -31,7 +31,6 @@ <xsd:element maxOccurs="1" minOccurs="0" name="disconnect" type="xsd:integer" /> <xsd:element maxOccurs="1" minOccurs="0" name="get_changes" type="xsd:integer" /> <xsd:element maxOccurs="1" minOccurs="0" name="commit" type="xsd:integer" /> - <xsd:element maxOccurs="1" minOccurs="0" name="batch_commit" type="xsd:integer" /> <xsd:element maxOccurs="1" minOccurs="0" name="committed_all" type="xsd:integer" /> <xsd:element maxOccurs="1" minOccurs="0" name="sync_done" type="xsd:integer" /> <xsd:element maxOccurs="1" minOccurs="0" name="write" type="xsd:integer" /> Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/opensync.sym Wed Apr 8 17:01:53 2009 (r5559) @@ -391,8 +391,6 @@ osync_objtype_sink_remove_objformat_sink osync_objtype_sink_save_hashtable osync_objtype_sink_set_available -osync_objtype_sink_set_batch_commit_func -osync_objtype_sink_set_batchcommit_timeout osync_objtype_sink_set_commit_func osync_objtype_sink_set_commit_timeout osync_objtype_sink_set_committed_all_func Modified: trunk/opensync/client/opensync_client_proxy_private.h ============================================================================== --- trunk/opensync/client/opensync_client_proxy_private.h Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/opensync/client/opensync_client_proxy_private.h Wed Apr 8 17:01:53 2009 (r5559) @@ -32,7 +32,6 @@ #define OSYNC_CLIENT_PROXY_TIMEOUT_DISCONNECT OSYNC_CLIENT_PROXY_TIMEOUT_DEFAULT #define OSYNC_CLIENT_PROXY_TIMEOUT_GETCHANGES OSYNC_CLIENT_PROXY_TIMEOUT_DEFAULT #define OSYNC_CLIENT_PROXY_TIMEOUT_COMMIT OSYNC_CLIENT_PROXY_TIMEOUT_DEFAULT -#define OSYNC_CLIENT_PROXY_TIMEOUT_BATCHCOMMIT OSYNC_CLIENT_PROXY_TIMEOUT_DEFAULT #define OSYNC_CLIENT_PROXY_TIMEOUT_COMMITTEDALL OSYNC_CLIENT_PROXY_TIMEOUT_DEFAULT #define OSYNC_CLIENT_PROXY_TIMEOUT_SYNCDONE OSYNC_CLIENT_PROXY_TIMEOUT_DEFAULT #define OSYNC_CLIENT_PROXY_TIMEOUT_READ OSYNC_CLIENT_PROXY_TIMEOUT_DEFAULT Modified: trunk/opensync/engine/opensync_engine.h ============================================================================== --- trunk/opensync/engine/opensync_engine.h Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/opensync/engine/opensync_engine.h Wed Apr 8 17:01:53 2009 (r5559) @@ -260,8 +260,7 @@ * osync_error_has_error() will return TRUE once the abort got requested. * * FIXME: Currently aborting of the current synchronization is not yet perfect! It - * will not preempt already running commands. For example the batch_commit - * will not be preempted and the engine will abort after the batch_commit is done. + * will not preempt already running commands. * * TODO: Review XMPM Benq patches for abort hander. Is sigaction really sane way * to abort? It's very important that the plugins get called with the disconnect Modified: trunk/opensync/group/opensync_group.c ============================================================================== --- trunk/opensync/group/opensync_group.c Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/opensync/group/opensync_group.c Wed Apr 8 17:01:53 2009 (r5559) @@ -594,7 +594,7 @@ osync_free(path); - /* flush anchor db */ + /* flush state db */ path = osync_strdup_printf("%s%canchor.db", osync_member_get_configdir(member), G_DIR_SEPARATOR); if (!(db = osync_db_new(error))) goto error_and_free; Modified: trunk/opensync/group/opensync_member.c ============================================================================== --- trunk/opensync/group/opensync_member.c Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/opensync/group/opensync_member.c Wed Apr 8 17:01:53 2009 (r5559) @@ -49,8 +49,6 @@ osync_objtype_sink_set_getchanges_timeout(sink, atoi(str)); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"commit")) { osync_objtype_sink_set_commit_timeout(sink, atoi(str)); - } else if (!xmlStrcmp(cur->name, (const xmlChar *)"batch_commit")) { - osync_objtype_sink_set_batchcommit_timeout(sink, atoi(str)); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"committed_all")) { osync_objtype_sink_set_committedall_timeout(sink, atoi(str)); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"sync_done")) { @@ -454,7 +452,6 @@ _osync_member_save_sink_add_timeout(node, "disconnect", osync_objtype_sink_get_disconnect_timeout(sink), error); _osync_member_save_sink_add_timeout(node, "get_changes", osync_objtype_sink_get_getchanges_timeout(sink), error); _osync_member_save_sink_add_timeout(node, "commit", osync_objtype_sink_get_commit_timeout(sink), error); - _osync_member_save_sink_add_timeout(node, "batch_commit", osync_objtype_sink_get_batchcommit_timeout(sink), error); _osync_member_save_sink_add_timeout(node, "committed_all", osync_objtype_sink_get_committedall_timeout(sink), error); _osync_member_save_sink_add_timeout(node, "sync_done", osync_objtype_sink_get_syncdone_timeout(sink), error); _osync_member_save_sink_add_timeout(node, "read", osync_objtype_sink_get_read_timeout(sink), error); Modified: trunk/opensync/ipc/opensync_serializer.c ============================================================================== --- trunk/opensync/ipc/opensync_serializer.c Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/opensync/ipc/opensync_serializer.c Wed Apr 8 17:01:53 2009 (r5559) @@ -296,7 +296,6 @@ * timeout disconnect (int) * timeout get_changes (int) * timeout commit (int) - * timeout batch_commit (int) * timeout committed_all (int) * timeout sync_done (int) * timeout read (int) @@ -327,7 +326,6 @@ osync_message_write_int(message, osync_objtype_sink_get_getchanges_timeout(sink)); osync_message_write_int(message, osync_objtype_sink_get_commit_timeout(sink)); - osync_message_write_int(message, osync_objtype_sink_get_batchcommit_timeout(sink)); osync_message_write_int(message, osync_objtype_sink_get_committedall_timeout(sink)); osync_message_write_int(message, osync_objtype_sink_get_syncdone_timeout(sink)); @@ -364,7 +362,6 @@ * timeout disconnect (int) * timeout get_changes (int) * timeout commit (int) - * timeout batch_commit (int) * timeout committed_all (int) * timeout sync_done (int) * timeout read (int) @@ -417,9 +414,6 @@ osync_objtype_sink_set_commit_timeout(*sink, timeout); osync_message_read_int(message, &timeout); - osync_objtype_sink_set_batchcommit_timeout(*sink, timeout); - - osync_message_read_int(message, &timeout); osync_objtype_sink_set_committedall_timeout(*sink, timeout); osync_message_read_int(message, &timeout); Modified: trunk/opensync/plugin/opensync_objtype_sink.c ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.c Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/opensync/plugin/opensync_objtype_sink.c Wed Apr 8 17:01:53 2009 (r5559) @@ -389,28 +389,15 @@ functions = sink->functions; - if (functions.batch_commit) { - //Append to the stored changes - sink->commit_changes = osync_list_append(sink->commit_changes, change); - - /* Increment refcounting for batch_commit to avoid too early freeing of the context. - Otherwise the context would get freed after this function call. But the batch_commit - is collecting every contexts and changes and finally commits everything at once. */ - osync_context_ref(ctx); - sink->commit_contexts = osync_list_append(sink->commit_contexts, ctx); - osync_trace(TRACE_EXIT, "%s: Waiting for batch processing", __func__); + // Send the change + if (sink->objtype && !functions.commit) { + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "No commit_change function was given"); + osync_trace(TRACE_EXIT_ERROR, "%s: No commit_change function was given", __func__); return; + } else if (!functions.commit) { + osync_context_report_success(ctx); } else { - // Send the change - if (sink->objtype && !functions.commit) { - osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "No commit_change function was given"); - osync_trace(TRACE_EXIT_ERROR, "%s: No commit_change function was given", __func__); - return; - } else if (!functions.commit) { - osync_context_report_success(ctx); - } else { - functions.commit(sink, info, ctx, change, osync_objtype_sink_get_userdata(sink)); - } + functions.commit(sink, info, ctx, change, osync_objtype_sink_get_userdata(sink)); } osync_trace(TRACE_EXIT, "%s", __func__); @@ -431,35 +418,7 @@ osync_assert(ctx); functions = sink->functions; - if (functions.batch_commit) { - OSyncChange **changes = osync_try_malloc0(sizeof(OSyncChange *) * (osync_list_length(sink->commit_changes) + 1), &error); - if (!changes) - goto error; - OSyncContext **contexts = osync_try_malloc0(sizeof(OSyncContext *) * (osync_list_length(sink->commit_contexts) + 1), &error); - if (!contexts) - goto error; - - o = sink->commit_contexts; - c = NULL; - for (c = sink->commit_changes; c && o; c = c->next) { - change = c->data; - context = o->data; - - changes[i] = change; - contexts[i] = context; - - i++; - o = o->next; - } - - osync_list_free(sink->commit_changes); - osync_list_free(sink->commit_contexts); - - functions.batch_commit(sink, info, ctx, contexts, changes, osync_objtype_sink_get_userdata(sink)); - - osync_free(changes); - osync_free(contexts); - } else if (functions.committed_all) { + if (functions.committed_all) { functions.committed_all(sink, info, ctx, osync_objtype_sink_get_userdata(sink)); } else { osync_context_report_success(ctx); @@ -618,24 +577,6 @@ return sink->timeout.commit; } -void osync_objtype_sink_set_batchcommit_timeout(OSyncObjTypeSink *sink, unsigned int timeout) -{ - osync_assert(sink); - sink->timeout.batch_commit = timeout; -} - -unsigned int osync_objtype_sink_get_batchcommit_timeout_or_default(OSyncObjTypeSink *sink) -{ - osync_assert(sink); - return sink->timeout.batch_commit ? sink->timeout.batch_commit : OSYNC_SINK_TIMEOUT_BATCHCOMMIT; -} - -unsigned int osync_objtype_sink_get_batchcommit_timeout(OSyncObjTypeSink *sink) -{ - osync_assert(sink); - return sink->timeout.batch_commit; -} - void osync_objtype_sink_set_committedall_timeout(OSyncObjTypeSink *sink, unsigned int timeout) { osync_assert(sink); @@ -835,12 +776,6 @@ sink->func_read = TRUE; } -void osync_objtype_sink_set_batch_commit_func(OSyncObjTypeSink *sink, OSyncSinkBatchCommitFn batch_commit_func) -{ - osync_return_if_fail(sink); - sink->functions.batch_commit = batch_commit_func; -} - void osync_objtype_sink_set_sync_done_func(OSyncObjTypeSink *sink, OSyncSinkSyncDoneFn sync_done_func) { osync_return_if_fail(sink); Modified: trunk/opensync/plugin/opensync_objtype_sink.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.h Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/opensync/plugin/opensync_objtype_sink.h Wed Apr 8 17:01:53 2009 (r5559) @@ -36,7 +36,6 @@ typedef osync_bool (* OSyncSinkWriteFn) (OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change, void *data); typedef void (* OSyncSinkCommittedAllFn) (OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data); typedef osync_bool (* OSyncSinkReadFn) (OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncChange *change, void *data); -typedef void (* OSyncSinkBatchCommitFn) (OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, OSyncContext **, OSyncChange **changes, void *data); typedef void (* OSyncSinkSyncDoneFn) (OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, void *data); typedef void (* OSyncSinkConnectDoneFn) (OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *ctx, osync_bool slow_sync, void *data); @@ -385,8 +384,7 @@ /** @brief Tells the sink that all changes have been committed * - * Calls the committed_all function on a sink or the batch_commit function - * depending on which function the sink wants to use. + * Calls the committed_all function on a sink. * * @param sink Pointer to the sink * @param info Pointer to the plugin info object @@ -428,14 +426,6 @@ */ OSYNC_EXPORT void osync_objtype_sink_set_commit_timeout(OSyncObjTypeSink *sink, unsigned int timeout); -/** @brief Sets the batchcommit timeout in seconds for the OSyncObjTypeSink - * - * @param sink Pointer to the sink - * @param timeout The timeout in seconds - * - */ -OSYNC_EXPORT void osync_objtype_sink_set_batchcommit_timeout(OSyncObjTypeSink *sink, unsigned int timeout); - /** @brief Sets the committedall timeout in seconds for the OSyncObjTypeSink * * @param sink Pointer to the sink @@ -511,8 +501,6 @@ OSYNC_EXPORT void osync_objtype_sink_set_read_func(OSyncObjTypeSink *sink, OSyncSinkReadFn read_func); -OSYNC_EXPORT void osync_objtype_sink_set_batch_commit_func(OSyncObjTypeSink *sink, OSyncSinkBatchCommitFn batch_commit_func); - OSYNC_EXPORT void osync_objtype_sink_set_sync_done_func(OSyncObjTypeSink *sink, OSyncSinkSyncDoneFn sync_done_func); OSYNC_EXPORT void osync_objtype_sink_set_connect_done_func(OSyncObjTypeSink *sink, OSyncSinkConnectDoneFn connect_done_func); Modified: trunk/opensync/plugin/opensync_objtype_sink_internals.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink_internals.h Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/opensync/plugin/opensync_objtype_sink_internals.h Wed Apr 8 17:01:53 2009 (r5559) @@ -39,7 +39,6 @@ OSyncSinkCommitFn commit; OSyncSinkCommittedAllFn committed_all; OSyncSinkReadFn read; - OSyncSinkBatchCommitFn batch_commit; OSyncSinkSyncDoneFn sync_done; OSyncSinkConnectDoneFn connect_done; } OSyncObjTypeSinkFunctions; @@ -179,24 +178,6 @@ */ unsigned int osync_objtype_sink_get_commit_timeout(OSyncObjTypeSink *sink); - -/** @brief Get the current or default batchcommit timeout in seconds - * - * @param sink Pointer to the sink - * @return The timeout in seconds - * - */ -unsigned int osync_objtype_sink_get_batchcommit_timeout_or_default(OSyncObjTypeSink *sink); - -/** @brief Get the current batchcommit timeout in seconds - * - * @param sink Pointer to the sink - * @return The timeout in seconds - * - */ -unsigned int osync_objtype_sink_get_batchcommit_timeout(OSyncObjTypeSink *sink); - - /** @brief Get the current or default committedall timeout in seconds * * @param sink Pointer to the sink Modified: trunk/opensync/plugin/opensync_objtype_sink_private.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink_private.h Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/opensync/plugin/opensync_objtype_sink_private.h Wed Apr 8 17:01:53 2009 (r5559) @@ -55,7 +55,6 @@ #define OSYNC_SINK_TIMEOUT_DISCONNECT OSYNC_SINK_TIMEOUT_TRANSPORT #define OSYNC_SINK_TIMEOUT_GETCHANGES OSYNC_SINK_TIMEOUT_BATCHIO #define OSYNC_SINK_TIMEOUT_COMMIT OSYNC_SINK_TIMEOUT_BATCHIO /* FIXME */ -#define OSYNC_SINK_TIMEOUT_BATCHCOMMIT OSYNC_SINK_TIMEOUT_BATCHIO #define OSYNC_SINK_TIMEOUT_COMMITTEDALL OSYNC_SINK_TIMEOUT_SINGLEIO #define OSYNC_SINK_TIMEOUT_SYNCDONE OSYNC_SINK_TIMEOUT_SINGLEIO #define OSYNC_SINK_TIMEOUT_READ OSYNC_SINK_TIMEOUT_BATCHIO /* FIXME */ @@ -66,7 +65,6 @@ unsigned int disconnect; unsigned int get_changes; unsigned int commit; - unsigned int batch_commit; unsigned int committed_all; unsigned int sync_done; unsigned int read; @@ -122,9 +120,6 @@ /** Referce counting */ int ref_count; - /** List to pile up changes for batch commit */ - OSyncList *commit_changes; - OSyncList *commit_contexts; osync_bool available; }; Modified: trunk/tests/engine-tests/check_engine_error.c ============================================================================== --- trunk/tests/engine-tests/check_engine_error.c Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/tests/engine-tests/check_engine_error.c Wed Apr 8 17:01:53 2009 (r5559) @@ -2117,6 +2117,8 @@ } END_TEST +/* batch_commit no longer exists + START_TEST (engine_error_committed_all_batch_error) { char *testbed = setup_testbed("multisync_easy_new"); @@ -2178,6 +2180,7 @@ destroy_testbed(testbed); } END_TEST +*/ START_TEST (engine_error_single_sync_done_error) { @@ -3097,7 +3100,6 @@ OSYNC_TESTCASE_ADD(engine_error_commit_error_delete) OSYNC_TESTCASE_ADD(engine_error_committed_all_error) -OSYNC_TESTCASE_ADD(engine_error_committed_all_batch_error) OSYNC_TESTCASE_ADD(engine_error_single_sync_done_error) OSYNC_TESTCASE_ADD(engine_error_dual_sync_done_error) Modified: trunk/tests/mock-plugin/mock_sync.c ============================================================================== --- trunk/tests/mock-plugin/mock_sync.c Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/tests/mock-plugin/mock_sync.c Wed Apr 8 17:01:53 2009 (r5559) @@ -488,49 +488,6 @@ osync_trace(TRACE_EXIT, "%s", __func__); } -static void mock_batch_commit(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *context, OSyncContext **contexts, OSyncChange **changes, void *data) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p, %p)", __func__, sink, info, context, contexts, changes, data); - MockDir *dir = data; - OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(sink); - - osync_assert(dir->committed_all == FALSE); - dir->committed_all = TRUE; - - int i; - for (i = 0; contexts[i]; i++) { - if (mock_write(sink, info, contexts[i], changes[i], data)) { - char *filename = g_strdup_printf ("%s/%s", dir->path, osync_change_get_uid(changes[i])); - char *hash = NULL; - - if (osync_change_get_changetype(changes[i]) != OSYNC_CHANGE_TYPE_DELETED) { - struct stat buf; - stat(filename, &buf); - hash = mock_generate_hash(&buf); - osync_change_set_hash(changes[i], hash); - } - g_free(filename); - - osync_hashtable_update_change(hashtable, changes[i]); - osync_context_report_success(contexts[i]); - } - } - - if (g_getenv("NUM_BATCH_COMMITS")) { - int req = atoi(g_getenv("NUM_BATCH_COMMITS")); - osync_assert(req == i); - } - - if (mock_get_error(info->memberid, "COMMITTED_ALL_ERROR")) { - osync_context_report_error(context, OSYNC_ERROR_EXPECTED, "Triggering COMMITTED_ALL_ERROR error"); - return; - } - - osync_context_report_success(context); - - osync_trace(TRACE_EXIT, "%s", __func__); -} - static void mock_committed_all(OSyncObjTypeSink *sink, OSyncPluginInfo *info, OSyncContext *context, void *data) { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, sink, info, context, data); @@ -656,14 +613,8 @@ osync_objtype_sink_set_get_changes_func(sink, mock_get_changes); - //Rewrite the batch commit functions so we can enable them if necessary - if (mock_get_error(info->memberid, "BATCH_COMMIT")) { - osync_trace(TRACE_INTERNAL, "Enabling batch_commit on %p:%s", sink, osync_objtype_sink_get_name(sink) ? osync_objtype_sink_get_name(sink) : "None"); - osync_objtype_sink_set_batch_commit_func(sink, mock_batch_commit); - } else { - osync_objtype_sink_set_committed_all_func(sink, mock_committed_all); - osync_objtype_sink_set_commit_func(sink, mock_commit_change); - } + osync_objtype_sink_set_committed_all_func(sink, mock_committed_all); + osync_objtype_sink_set_commit_func(sink, mock_commit_change); osync_objtype_sink_set_read_func(sink, mock_read); osync_objtype_sink_set_sync_done_func(sink, mock_sync_done); @@ -682,7 +633,6 @@ osync_objtype_sink_set_getchanges_timeout(sink, 2); osync_objtype_sink_set_commit_timeout(sink, 4); osync_objtype_sink_set_committedall_timeout(sink, 4); - osync_objtype_sink_set_batchcommit_timeout(sink, 4); osync_objtype_sink_set_syncdone_timeout(sink, 2); osync_objtype_sink_set_disconnect_timeout(sink, 2); @@ -706,7 +656,6 @@ osync_objtype_sink_set_getchanges_timeout(sink, 0); osync_objtype_sink_set_commit_timeout(sink, 0); osync_objtype_sink_set_committedall_timeout(sink, 0); - osync_objtype_sink_set_batchcommit_timeout(sink, 0); osync_objtype_sink_set_syncdone_timeout(sink, 0); osync_objtype_sink_set_disconnect_timeout(sink, 0); Modified: trunk/tests/support.c ============================================================================== --- trunk/tests/support.c Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/tests/support.c Wed Apr 8 17:01:53 2009 (r5559) @@ -72,7 +72,6 @@ g_unsetenv("SYNC_DONE_TIMEOUT"); g_unsetenv("DISCONNECT_ERROR"); g_unsetenv("DISCONNECT_TIMEOUT"); - g_unsetenv("BATCH_COMMIT"); g_unsetenv("COMMITTED_ALL_ERROR"); g_unsetenv("NO_COMMITTED_ALL_CHECK"); g_unsetenv("MAINSINK_CONNECT"); Modified: trunk/tests/sync-tests/check_multisync.c ============================================================================== --- trunk/tests/sync-tests/check_multisync.c Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/tests/sync-tests/check_multisync.c Wed Apr 8 17:01:53 2009 (r5559) @@ -1942,6 +1942,8 @@ } END_TEST +/* batch_commit is no longer supported + START_TEST(multisync_easy_new_b) { char *testbed = setup_testbed("multisync_easy_new"); @@ -1950,6 +1952,9 @@ destroy_testbed(testbed); } END_TEST +*/ + +/* batch_commit is no longer supported START_TEST(multisync_triple_del_b) { @@ -1959,6 +1964,9 @@ destroy_testbed(testbed); } END_TEST +*/ + +/* batch_commit is no longer supported START_TEST(multisync_conflict_hybrid_choose2_b) { @@ -1968,6 +1976,9 @@ destroy_testbed(testbed); } END_TEST +*/ + +/* batch_commit is no longer supported START_TEST(multisync_delayed_conflict_handler_b) { @@ -1977,6 +1988,9 @@ destroy_testbed(testbed); } END_TEST +*/ + +/* batch_commit is no longer supported START_TEST(multisync_delayed_slow_b) { @@ -1986,6 +2000,10 @@ destroy_testbed(testbed); } END_TEST +*/ + +/* batch_commit is no longer supported + #if 0 START_TEST(multisync_conflict_ignore_b) { @@ -2013,7 +2031,7 @@ } END_TEST -START_TEST(multisync_multi_conflict_b) +/* batch_commit is no longer supported { setenv("BATCH_COMMIT", "7", TRUE); multisync_multi_conflict(); @@ -2021,7 +2039,6 @@ } END_TEST - START_TEST(multisync_zero_changes_b) { setenv("BATCH_COMMIT", "7", TRUE); @@ -2138,6 +2155,7 @@ } END_TEST #endif +*/ OSYNC_TESTCASE_START("multisync") OSYNC_TESTCASE_ADD(multisync_easy_new) @@ -2181,6 +2199,8 @@ OSYNC_TESTCASE_ADD(multisync_conflict_ignore) OSYNC_TESTCASE_ADD(multisync_conflict_ignore2) +/* batch_commit is no longer supported + OSYNC_TESTCASE_ADD(multisync_easy_new_b) OSYNC_TESTCASE_ADD(multisync_triple_del_b) OSYNC_TESTCASE_ADD(multisync_conflict_hybrid_choose2_b) @@ -2198,6 +2218,7 @@ OSYNC_TESTCASE_ADD(multisync_conflict_ignore_b2) OSYNC_TESTCASE_ADD(multisync_multi_conflict_b2) #endif +*/ OSYNC_TESTCASE_END Modified: trunk/tools/osyncplugin.c ============================================================================== --- trunk/tools/osyncplugin.c Tue Apr 7 22:25:59 2009 (r5558) +++ trunk/tools/osyncplugin.c Wed Apr 8 17:01:53 2009 (r5559) @@ -62,7 +62,6 @@ CMD_SLOWSYNC, CMD_FASTSYNC, CMD_COMMIT, - CMD_BATCHCOMMIT, CMD_COMMITTEDALL, CMD_READ, CMD_WRITE, @@ -152,7 +151,6 @@ fprintf (stderr, "[--syncdone] \t\n"); fprintf (stderr, "[--committedall] \t\n"); fprintf (stderr, "[--commit] \t\n"); - fprintf (stderr, "[--batchcommit] \t\n"); fprintf (stderr, "[--write] \t\n"); fprintf (stderr, "[--read] \t\n"); fprintf (stderr, "[--empty] \t\n"); @@ -271,13 +269,6 @@ new_command(CMD_COMMIT, argv[++i]); continue; - } else if (!strcmp(arg, "--batchcommit")) { - if (!argv[i+1] || *argv[i+1] == '-') - new_command(CMD_BATCHCOMMIT, NULL); - else - new_command(CMD_BATCHCOMMIT, argv[++i]); - - continue; } else if (!strcmp(arg, "--write")) { if (!argv[i+1] || *argv[i+1] == '-') new_command(CMD_WRITE, NULL); @@ -1212,9 +1203,6 @@ case CMD_COMMIT: fprintf(stderr, "COMMIT not yet implemented\n"); break; - case CMD_BATCHCOMMIT: - fprintf(stderr, "BATCHCOMMIT not yet implemented\n"); - break; case CMD_COMMITTEDALL: if (!committedall(cmd, error)) goto error; @@ -1249,7 +1237,6 @@ case CMD_FASTSYNC: case CMD_SYNC: case CMD_COMMIT: - case CMD_BATCHCOMMIT: case CMD_COMMITTEDALL: case CMD_READ: case CMD_WRITE: |
From: <svn...@op...> - 2009-04-07 20:26:03
|
Author: cstender Date: Tue Apr 7 22:25:59 2009 New Revision: 5558 URL: http://www.opensync.org/changeset/5558 Log: fixed invalid osync_trace calls. Patch by scriptor Modified: format-plugins/vformat/src/xmlformat-vcalendar.c Modified: format-plugins/vformat/src/xmlformat-vcalendar.c ============================================================================== --- format-plugins/vformat/src/xmlformat-vcalendar.c Tue Apr 7 22:04:46 2009 (r5557) +++ format-plugins/vformat/src/xmlformat-vcalendar.c Tue Apr 7 22:25:59 2009 (r5558) @@ -428,13 +428,13 @@ void handle_range_parameter(OSyncXMLField *xmlfield, VFormatParam *param) { - osync_trace(TRACE_INTERNAL, "Handling %s parameter %s\n", vformat_attribute_param_get_name(param)); + osync_trace(TRACE_INTERNAL, "Handling %s parameter", vformat_attribute_param_get_name(param)); osync_xmlfield_set_attr(xmlfield, "Range", vformat_attribute_param_get_nth_value(param, 0)); } void handle_trigrel_parameter(OSyncXMLField *xmlfield, VFormatParam *param) { - osync_trace(TRACE_INTERNAL, "Handling %s parameter %s\n", vformat_attribute_param_get_name(param)); + osync_trace(TRACE_INTERNAL, "Handling %s parameter", vformat_attribute_param_get_name(param)); osync_xmlfield_set_attr(xmlfield, "RelatedType", vformat_attribute_param_get_nth_value(param, 0)); } |
From: <svn...@op...> - 2009-04-07 20:04:50
|
Author: cdfrey Date: Tue Apr 7 22:04:46 2009 New Revision: 5557 URL: http://www.opensync.org/changeset/5557 Log: Use opensync's free() Modified: format-plugins/vformat/tools/vconvert.c Modified: format-plugins/vformat/tools/vconvert.c ============================================================================== --- format-plugins/vformat/tools/vconvert.c Tue Apr 7 22:04:11 2009 (r5556) +++ format-plugins/vformat/tools/vconvert.c Tue Apr 7 22:04:46 2009 (r5557) @@ -350,7 +350,7 @@ } else { printf("%s", print); } - g_free(print); + osync_free(print); osync_data_unref(data); osync_converter_path_unref(path); |