diff options
Diffstat (limited to 'src/main/extractor_print.c')
-rw-r--r-- | src/main/extractor_print.c | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/src/main/extractor_print.c b/src/main/extractor_print.c index 3530430..a89b522 100644 --- a/src/main/extractor_print.c +++ b/src/main/extractor_print.c | |||
@@ -33,72 +33,73 @@ | |||
33 | * Simple EXTRACTOR_MetaDataProcessor implementation that simply | 33 | * Simple EXTRACTOR_MetaDataProcessor implementation that simply |
34 | * prints the extracted meta data to the given file. Only prints | 34 | * prints the extracted meta data to the given file. Only prints |
35 | * those keywords that are in UTF-8 format. | 35 | * those keywords that are in UTF-8 format. |
36 | * | 36 | * |
37 | * @param handle the file to write to (stdout, stderr), must NOT be NULL, | 37 | * @param handle the file to write to (stdout, stderr), must NOT be NULL, |
38 | * must be of type "FILE *". | 38 | * must be of type "FILE *". |
39 | * @param plugin_name name of the plugin that produced this value | 39 | * @param plugin_name name of the plugin that produced this value |
40 | * @param type libextractor-type describing the meta data | 40 | * @param type libextractor-type describing the meta data |
41 | * @param format basic format information about data | 41 | * @param format basic format information about data |
42 | * @param data_mime_type mime-type of data (not of the original file); | 42 | * @param data_mime_type mime-type of data (not of the original file); |
43 | * can be NULL (if mime-type is not known) | 43 | * can be NULL (if mime-type is not known) |
44 | * @param data actual meta-data found | 44 | * @param data actual meta-data found |
45 | * @param data_len number of bytes in data | 45 | * @param data_len number of bytes in data |
46 | * @return non-zero if printing failed, otherwise 0. | 46 | * @return non-zero if printing failed, otherwise 0. |
47 | */ | 47 | */ |
48 | int | 48 | int |
49 | EXTRACTOR_meta_data_print (void *handle, | 49 | EXTRACTOR_meta_data_print (void *handle, |
50 | const char *plugin_name, | 50 | const char *plugin_name, |
51 | enum EXTRACTOR_MetaType type, | 51 | enum EXTRACTOR_MetaType type, |
52 | enum EXTRACTOR_MetaFormat format, | 52 | enum EXTRACTOR_MetaFormat format, |
53 | const char *data_mime_type, | 53 | const char *data_mime_type, |
54 | const char *data, | 54 | const char *data, |
55 | size_t data_len) | 55 | size_t data_len) |
56 | { | 56 | { |
57 | #if HAVE_ICONV | 57 | #if HAVE_ICONV |
58 | iconv_t cd; | 58 | iconv_t cd; |
59 | #endif | 59 | #endif |
60 | char * buf; | 60 | char *buf; |
61 | int ret; | 61 | int ret; |
62 | const char *mt; | 62 | const char *mt; |
63 | 63 | ||
64 | if (EXTRACTOR_METAFORMAT_UTF8 != format) | 64 | if (EXTRACTOR_METAFORMAT_UTF8 != format) |
65 | return 0; | 65 | return 0; |
66 | #if HAVE_ICONV | 66 | #if HAVE_ICONV |
67 | cd = iconv_open (nl_langinfo(CODESET), | 67 | cd = iconv_open (nl_langinfo (CODESET), |
68 | "UTF-8"); | 68 | "UTF-8"); |
69 | if (((iconv_t) -1) == cd) | 69 | if (((iconv_t) -1) == cd) |
70 | { | 70 | { |
71 | LOG_STRERROR ("iconv_open"); | 71 | LOG_STRERROR ("iconv_open"); |
72 | return 1; | 72 | return 1; |
73 | } | 73 | } |
74 | buf = iconv_helper (cd, data, data_len); | 74 | buf = iconv_helper (cd, data, data_len); |
75 | if (NULL == buf) | 75 | if (NULL == buf) |
76 | { | 76 | { |
77 | LOG_STRERROR ("iconv_helper"); | 77 | LOG_STRERROR ("iconv_helper"); |
78 | ret = -1; | 78 | ret = -1; |
79 | } | 79 | } |
80 | else | 80 | else |
81 | { | 81 | { |
82 | mt = EXTRACTOR_metatype_to_string (type); | 82 | mt = EXTRACTOR_metatype_to_string (type); |
83 | ret = fprintf (handle, | 83 | ret = fprintf (handle, |
84 | "%s - %s\n", | 84 | "%s - %s\n", |
85 | (NULL == mt) | 85 | (NULL == mt) |
86 | ? dgettext ("libextractor", gettext_noop ("unknown")) | 86 | ? dgettext ("libextractor", gettext_noop ("unknown")) |
87 | : dgettext ("libextractor", mt), | 87 | : dgettext ("libextractor", mt), |
88 | buf); | 88 | buf); |
89 | free(buf); | 89 | free (buf); |
90 | } | 90 | } |
91 | iconv_close(cd); | 91 | iconv_close (cd); |
92 | #else | 92 | #else |
93 | ret = fprintf (handle, | 93 | ret = fprintf (handle, |
94 | "%s - %.*s\n", | 94 | "%s - %.*s\n", |
95 | (NULL == mt) | 95 | (NULL == mt) |
96 | ? dgettext ("libextractor", gettext_noop ("unknown")) | 96 | ? dgettext ("libextractor", gettext_noop ("unknown")) |
97 | : dgettext ("libextractor", mt), | 97 | : dgettext ("libextractor", mt), |
98 | (int) data_len, | 98 | (int) data_len, |
99 | data); | 99 | data); |
100 | #endif | 100 | #endif |
101 | return (ret < 0) ? 1 : 0; | 101 | return (ret < 0) ? 1 : 0; |
102 | } | 102 | } |
103 | 103 | ||
104 | |||
104 | /* end of extractor_print.c */ | 105 | /* end of extractor_print.c */ |