From: <dg...@su...> - 2009-01-11 00:20:07
|
Author: dgollub Date: Sun Jan 11 01:19:29 2009 New Revision: 5086 URL: http://www.opensync.org/changeset/5086 Log: Fix vconvert-tool format detection. This "detection full" slighlty changed. In most cases regular detection is enough for vconvert, since no encapsulated formats are involved. "detection full" starts with encapsulator detection... and aborts if there is none. Added --format-config parameter to set conversion-path configs. Modified: format-plugins/vformat/tools/vconvert.c Modified: format-plugins/vformat/tools/vconvert.c ============================================================================== --- format-plugins/vformat/tools/vconvert.c Sun Jan 11 01:09:25 2009 (r5085) +++ format-plugins/vformat/tools/vconvert.c Sun Jan 11 01:19:29 2009 (r5086) @@ -50,6 +50,7 @@ fprintf (stderr, "Switches:\n"); fprintf (stderr, "--help\t\tShow this help message\n"); fprintf (stderr, "--out <file>\tStore the output in this file (No output to stdout)\n"); + fprintf (stderr, "--format-config <config>\t Apply conversion config (e.g. VCARD_EXTENSION=KDE)\n"); fprintf (stderr, "--to-vcard21\tConvert to vcard 2.1\n"); fprintf (stderr, "--to-vcard30\tConvert to vcard 3.0\n"); fprintf (stderr, "--to-vevent10\tConvert to vevent 1.0\n"); @@ -232,6 +233,7 @@ OSyncObjFormat *targetformat = NULL; conv_detection type = TARGET_AUTO; char *output = NULL; + char *format_config = NULL; char *filename = NULL; char *buffer = NULL; char *print = NULL; @@ -273,6 +275,11 @@ i++; if (!output) usage (argv[0], 1); + } else if (!strcmp (arg, "--format-config")) { + format_config = argv[i + 1]; + i++; + if (!format_config) + usage (argv[0], 1); } else if (!strcmp (arg, "--")) { break; } else if (arg[0] == '-') { @@ -309,13 +316,20 @@ goto error; } - // detect source and target xmlformat - sourceformat = NULL; - if (!(sourceformat = osync_format_env_detect_objformat_full(format_env, data, &error))) { - fprintf(stderr, "Unable to detect file format\n"); + // detect source and target xmlformat. First update the initial objformat. + // Then run decapsulator driven detection. + sourceformat = osync_format_env_detect_objformat(format_env, data); + if (sourceformat) + osync_data_set_objformat(data, sourceformat); + + sourceformat = osync_format_env_detect_objformat_full(format_env, data, &error); + if (sourceformat) + osync_data_set_objformat(data, sourceformat); + + if (osync_error_is_set(&error)) goto error; - } - osync_data_set_objformat(data, sourceformat); + + sourceformat = osync_data_get_objformat(data); targetformat = conv_run_detection(format_env, osync_objformat_get_name(sourceformat), type); if (!targetformat) { @@ -325,6 +339,9 @@ // find converter path OSyncFormatConverterPath *path = osync_format_env_find_path(format_env, sourceformat, targetformat, &error); + if (format_config) + osync_converter_path_set_config(path, format_config); + // convert data if (!osync_format_env_convert(format_env, path, data, &error)) { fprintf(stderr, "Unable to convert data\n"); |