From: <dg...@su...> - 2009-01-20 18:14:42
|
Author: savago Date: Tue Jan 20 19:13:36 2009 New Revision: 5211 URL: http://www.opensync.org/changeset/5211 Log: Adding code to actually do the conversion. Modified: format-plugins/xsltformat/src/xsltformat.c Modified: format-plugins/xsltformat/src/xsltformat.c ============================================================================== --- format-plugins/xsltformat/src/xsltformat.c Tue Jan 20 17:19:10 2009 (r5210) +++ format-plugins/xsltformat/src/xsltformat.c Tue Jan 20 19:13:36 2009 (r5211) @@ -68,42 +68,22 @@ static osync_bool conv_xslt_to_contact(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) { - /* - * This function can be used to convert your format to another format. - * Return TRUE if the conversion was successful or return FALSE and set - * the error if something bad has happend. - * - */ - - /* The arguments mean: - * - * - conv_data: - * Pointer to the data you returned in your init function (if any) - * - * - input: - * The data you need to convert - * - inpsize - * The size of the input data - * - * - output: - * After converting you need to set this - * to your result - * - outpsize: - * The size of the output - * - * - free_input: - * You need to set this to TRUE if opensync - * can free the input after the conversion (so you dont - * use any reference from or to the input). A example where - * *free_input = FALSE; needs to be done would be a encapsulator - * that stores the input reference somewhere in its struct - * - * - error: - * if something bad happens and you cannot convert, set the error! - * - */ + osync_bool result = FALSE; + struct xslt_resources *converter = NULL; - return TRUE; + converter = (struct xslt_resources *)userdata; + if ((result = xslt_transform(converter, input))) + goto exit; + + if (!(*output = strdup(converter->xml_str))) + goto exit; + + *free_input = TRUE; + + /* TODO: set OsyncError */ + +exit: + return result; } static osync_bool conv_contact_to_xslt(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) |