diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-12-16 13:25:07 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-12-16 13:25:07 +0000 |
commit | aa056e44077dc7ed731cdfc1dcdcdd1d18b6004d (patch) | |
tree | 8f912da33b0aa227f5fc4f456822ec205c4bf121 /src/plugins | |
parent | e4423c3bcb9b184b037bd5c0c7b70c46a770b83f (diff) | |
download | libextractor-aa056e44077dc7ed731cdfc1dcdcdd1d18b6004d.tar.gz libextractor-aa056e44077dc7ed731cdfc1dcdcdd1d18b6004d.zip |
man
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Makefile.am | 17 | ||||
-rw-r--r-- | src/plugins/deb_extractor.c | 2 | ||||
-rw-r--r-- | src/plugins/man_extractor.c (renamed from src/plugins/manextractor.c) | 116 | ||||
-rw-r--r-- | src/plugins/rpm_extractor.c | 2 |
4 files changed, 69 insertions, 68 deletions
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 7c81197..3bbe644 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am | |||
@@ -93,6 +93,7 @@ plugin_LTLIBRARIES = \ | |||
93 | libextractor_html.la \ | 93 | libextractor_html.la \ |
94 | libextractor_it.la \ | 94 | libextractor_it.la \ |
95 | libextractor_jpeg.la \ | 95 | libextractor_jpeg.la \ |
96 | libextractor_man.la \ | ||
96 | libextractor_mime.la \ | 97 | libextractor_mime.la \ |
97 | $(pdf) \ | 98 | $(pdf) \ |
98 | $(rpm) \ | 99 | $(rpm) \ |
@@ -163,6 +164,13 @@ libextractor_jpeg_la_LDFLAGS = \ | |||
163 | libextractor_jpeg_la_LIBADD = \ | 164 | libextractor_jpeg_la_LIBADD = \ |
164 | $(LE_LIBINTL) | 165 | $(LE_LIBINTL) |
165 | 166 | ||
167 | libextractor_man_la_SOURCES = \ | ||
168 | man_extractor.c | ||
169 | libextractor_man_la_LDFLAGS = \ | ||
170 | $(PLUGINFLAGS) | ||
171 | libextractor_man_la_LIBADD = \ | ||
172 | $(LE_LIBINTL) | ||
173 | |||
166 | libextractor_mime_la_SOURCES = \ | 174 | libextractor_mime_la_SOURCES = \ |
167 | mime_extractor.c | 175 | mime_extractor.c |
168 | libextractor_mime_la_LDFLAGS = \ | 176 | libextractor_mime_la_LDFLAGS = \ |
@@ -202,7 +210,6 @@ OLD_LIBS = \ | |||
202 | libextractor_id3v2.la \ | 210 | libextractor_id3v2.la \ |
203 | libextractor_id3v24.la \ | 211 | libextractor_id3v24.la \ |
204 | libextractor_id3v23.la \ | 212 | libextractor_id3v23.la \ |
205 | libextractor_man.la \ | ||
206 | libextractor_mp3.la \ | 213 | libextractor_mp3.la \ |
207 | $(extrampeg) \ | 214 | $(extrampeg) \ |
208 | libextractor_nsf.la \ | 215 | libextractor_nsf.la \ |
@@ -340,14 +347,6 @@ libextractor_mpeg_la_LIBADD = \ | |||
340 | $(top_builddir)/src/main/libextractor.la | 347 | $(top_builddir)/src/main/libextractor.la |
341 | endif | 348 | endif |
342 | 349 | ||
343 | libextractor_man_la_SOURCES = \ | ||
344 | manextractor.c | ||
345 | libextractor_man_la_LDFLAGS = \ | ||
346 | $(PLUGINFLAGS) | ||
347 | libextractor_man_la_LIBADD = \ | ||
348 | $(top_builddir)/src/main/libextractor.la \ | ||
349 | $(LE_LIBINTL) | ||
350 | |||
351 | libextractor_riff_la_SOURCES = \ | 350 | libextractor_riff_la_SOURCES = \ |
352 | riffextractor.c | 351 | riffextractor.c |
353 | libextractor_riff_la_LDFLAGS = \ | 352 | libextractor_riff_la_LDFLAGS = \ |
diff --git a/src/plugins/deb_extractor.c b/src/plugins/deb_extractor.c index 376e208..9c61af7 100644 --- a/src/plugins/deb_extractor.c +++ b/src/plugins/deb_extractor.c | |||
@@ -57,7 +57,7 @@ typedef struct | |||
57 | static Matches tmap[] = { | 57 | static Matches tmap[] = { |
58 | {"Package: ", EXTRACTOR_METATYPE_PACKAGE_NAME}, | 58 | {"Package: ", EXTRACTOR_METATYPE_PACKAGE_NAME}, |
59 | {"Version: ", EXTRACTOR_METATYPE_PACKAGE_VERSION}, | 59 | {"Version: ", EXTRACTOR_METATYPE_PACKAGE_VERSION}, |
60 | {"Section: ", EXTRACTOR_METATYPE_PACKAGE_SECTION}, | 60 | {"Section: ", EXTRACTOR_METATYPE_SECTION}, |
61 | {"Priority: ", EXTRACTOR_METATYPE_UPLOAD_PRIORITY}, | 61 | {"Priority: ", EXTRACTOR_METATYPE_UPLOAD_PRIORITY}, |
62 | {"Architecture: ", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE}, | 62 | {"Architecture: ", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE}, |
63 | {"Depends: ", EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY}, | 63 | {"Depends: ", EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY}, |
diff --git a/src/plugins/manextractor.c b/src/plugins/man_extractor.c index c043bf1..c53c4f5 100644 --- a/src/plugins/manextractor.c +++ b/src/plugins/man_extractor.c | |||
@@ -32,18 +32,19 @@ stndup (const char *str, size_t n) | |||
32 | return tmp; | 32 | return tmp; |
33 | } | 33 | } |
34 | 34 | ||
35 | static EXTRACTOR_KeywordList * | 35 | static int |
36 | addKeyword (EXTRACTOR_KeywordType type, | 36 | addKeyword (enum EXTRACTOR_MetaType type, |
37 | char *keyword, EXTRACTOR_KeywordList * next) | 37 | char *keyword, |
38 | EXTRACTOR_MetaDataProcessor proc, | ||
39 | void *proc_cls) | ||
38 | { | 40 | { |
39 | EXTRACTOR_KeywordList *result; | 41 | int ret; |
40 | |||
41 | if (keyword == NULL) | 42 | if (keyword == NULL) |
42 | return next; | 43 | return 0; |
43 | if (strlen (keyword) == 0) | 44 | if (strlen (keyword) == 0) |
44 | { | 45 | { |
45 | free (keyword); | 46 | free (keyword); |
46 | return next; | 47 | return 0; |
47 | } | 48 | } |
48 | if ((keyword[0] == '\"') && (keyword[strlen (keyword) - 1] == '\"')) | 49 | if ((keyword[0] == '\"') && (keyword[strlen (keyword) - 1] == '\"')) |
49 | { | 50 | { |
@@ -57,13 +58,17 @@ addKeyword (EXTRACTOR_KeywordType type, | |||
57 | if (strlen (keyword) == 0) | 58 | if (strlen (keyword) == 0) |
58 | { | 59 | { |
59 | free (keyword); | 60 | free (keyword); |
60 | return next; | 61 | return 0; |
61 | } | 62 | } |
62 | result = malloc (sizeof (EXTRACTOR_KeywordList)); | 63 | ret = proc (proc_cls, |
63 | result->next = next; | 64 | "man", |
64 | result->keyword = keyword; | 65 | type, |
65 | result->keywordType = type; | 66 | EXTRACTOR_METAFORMAT_UTF8, |
66 | return result; | 67 | "text/plain", |
68 | keyword, | ||
69 | strlen (keyword)+1); | ||
70 | free (keyword); | ||
71 | return ret; | ||
67 | } | 72 | } |
68 | 73 | ||
69 | static void | 74 | static void |
@@ -88,12 +93,14 @@ NEXT (size_t * end, const char *buf, const size_t size) | |||
88 | */ | 93 | */ |
89 | #define MAX_READ (16 * 1024) | 94 | #define MAX_READ (16 * 1024) |
90 | 95 | ||
96 | #define ADD(t,s) do { if (0 != addKeyword (t, s, proc, proc_cls)) return 1; } while (0) | ||
91 | 97 | ||
92 | 98 | int | |
93 | struct EXTRACTOR_Keywords * | 99 | EXTRACTOR_man_extract (const char *buf, |
94 | libextractor_man_extract (const char *filename, | 100 | size_t size, |
95 | const char *buf, | 101 | EXTRACTOR_MetaDataProcessor proc, |
96 | size_t size, struct EXTRACTOR_Keywords *prev) | 102 | void *proc_cls, |
103 | const char *options) | ||
97 | { | 104 | { |
98 | int pos; | 105 | int pos; |
99 | size_t xsize; | 106 | size_t xsize; |
@@ -103,14 +110,14 @@ libextractor_man_extract (const char *filename, | |||
103 | size = MAX_READ; | 110 | size = MAX_READ; |
104 | pos = 0; | 111 | pos = 0; |
105 | if (size < xlen) | 112 | if (size < xlen) |
106 | return prev; | 113 | return 0; |
107 | while ((pos < size - xlen) && | 114 | while ((pos < size - xlen) && |
108 | ((0 != strncmp (".TH ", | 115 | ((0 != strncmp (".TH ", |
109 | &buf[pos], | 116 | &buf[pos], |
110 | xlen)) || ((pos != 0) && (buf[pos - 1] != '\n')))) | 117 | xlen)) || ((pos != 0) && (buf[pos - 1] != '\n')))) |
111 | { | 118 | { |
112 | if (!isgraph (buf[pos]) && !isspace (buf[pos])) | 119 | if (!isgraph (buf[pos]) && !isspace (buf[pos])) |
113 | return prev; | 120 | return 0; |
114 | pos++; | 121 | pos++; |
115 | } | 122 | } |
116 | xsize = pos; | 123 | xsize = pos; |
@@ -126,19 +133,18 @@ libextractor_man_extract (const char *filename, | |||
126 | end = pos; | 133 | end = pos; |
127 | NEXT (&end, buf, size); | 134 | NEXT (&end, buf, size); |
128 | if (end > size) | 135 | if (end > size) |
129 | return prev; | 136 | return 0; |
130 | if (end - pos > 0) | 137 | if (end - pos > 0) |
131 | { | 138 | { |
132 | prev = addKeyword (EXTRACTOR_TITLE, | 139 | ADD (EXTRACTOR_METATYPE_TITLE, stndup (&buf[pos], end - pos)); |
133 | stndup (&buf[pos], end - pos), prev); | ||
134 | pos = end + 1; | 140 | pos = end + 1; |
135 | } | 141 | } |
136 | if (pos >= size) | 142 | if (pos >= size) |
137 | return prev; | 143 | return 0; |
138 | end = pos; | 144 | end = pos; |
139 | NEXT (&end, buf, size); | 145 | NEXT (&end, buf, size); |
140 | if (end > size) | 146 | if (end > size) |
141 | return prev; | 147 | return 0; |
142 | if (buf[pos] == '\"') | 148 | if (buf[pos] == '\"') |
143 | pos++; | 149 | pos++; |
144 | if ((end - pos >= 1) && (end - pos <= 4)) | 150 | if ((end - pos >= 1) && (end - pos <= 4)) |
@@ -146,43 +152,40 @@ libextractor_man_extract (const char *filename, | |||
146 | switch (buf[pos]) | 152 | switch (buf[pos]) |
147 | { | 153 | { |
148 | case '1': | 154 | case '1': |
149 | prev = addKeyword (EXTRACTOR_CATEGORY, | 155 | ADD (EXTRACTOR_METATYPE_SECTION, |
150 | strdup (_("Commands")), prev); | 156 | strdup (_("Commands"))); |
151 | break; | 157 | break; |
152 | case '2': | 158 | case '2': |
153 | prev = addKeyword (EXTRACTOR_CATEGORY, | 159 | ADD (EXTRACTOR_METATYPE_SECTION, |
154 | strdup (_("System calls")), prev); | 160 | strdup (_("System calls"))); |
155 | break; | 161 | break; |
156 | case '3': | 162 | case '3': |
157 | prev = addKeyword (EXTRACTOR_CATEGORY, | 163 | ADD (EXTRACTOR_METATYPE_SECTION, |
158 | strdup (_("Library calls")), prev); | 164 | strdup (_("Library calls"))); |
159 | break; | 165 | break; |
160 | case '4': | 166 | case '4': |
161 | prev = addKeyword (EXTRACTOR_CATEGORY, | 167 | ADD (EXTRACTOR_METATYPE_SECTION, |
162 | strdup (_("Special files")), prev); | 168 | strdup (_("Special files"))); |
163 | break; | 169 | break; |
164 | case '5': | 170 | case '5': |
165 | prev = addKeyword (EXTRACTOR_CATEGORY, | 171 | ADD (EXTRACTOR_METATYPE_SECTION, |
166 | strdup (_("File formats and conventions")), | 172 | strdup (_("File formats and conventions"))); |
167 | prev); | ||
168 | break; | 173 | break; |
169 | case '6': | 174 | case '6': |
170 | prev = addKeyword (EXTRACTOR_CATEGORY, | 175 | ADD (EXTRACTOR_METATYPE_SECTION, |
171 | strdup (_("Games")), prev); | 176 | strdup (_("Games"))); |
172 | break; | 177 | break; |
173 | case '7': | 178 | case '7': |
174 | prev = addKeyword (EXTRACTOR_CATEGORY, | 179 | ADD (EXTRACTOR_METATYPE_SECTION, |
175 | strdup (_("Conventions and miscellaneous")), | 180 | strdup (_("Conventions and miscellaneous"))); |
176 | prev); | ||
177 | break; | 181 | break; |
178 | case '8': | 182 | case '8': |
179 | prev = addKeyword (EXTRACTOR_CATEGORY, | 183 | ADD (EXTRACTOR_METATYPE_SECTION, |
180 | strdup (_("System management commands")), | 184 | strdup (_("System management commands"))); |
181 | prev); | ||
182 | break; | 185 | break; |
183 | case '9': | 186 | case '9': |
184 | prev = addKeyword (EXTRACTOR_CATEGORY, | 187 | ADD (EXTRACTOR_METATYPE_SECTION, |
185 | strdup (_("Kernel routines")), prev); | 188 | strdup (_("Kernel routines"))); |
186 | break; | 189 | break; |
187 | } | 190 | } |
188 | pos = end + 1; | 191 | pos = end + 1; |
@@ -190,36 +193,35 @@ libextractor_man_extract (const char *filename, | |||
190 | end = pos; | 193 | end = pos; |
191 | NEXT (&end, buf, size); | 194 | NEXT (&end, buf, size); |
192 | if (end > size) | 195 | if (end > size) |
193 | return prev; | 196 | return 0; |
194 | if (end - pos > 0) | 197 | if (end - pos > 0) |
195 | { | 198 | { |
196 | prev = addKeyword (EXTRACTOR_DATE, | 199 | ADD (EXTRACTOR_METATYPE_MODIFICATION_DATE, stndup (&buf[pos], end - pos)); |
197 | stndup (&buf[pos], end - pos), prev); | ||
198 | pos = end + 1; | 200 | pos = end + 1; |
199 | } | 201 | } |
200 | end = pos; | 202 | end = pos; |
201 | NEXT (&end, buf, size); | 203 | NEXT (&end, buf, size); |
202 | if (end > size) | 204 | if (end > size) |
203 | return prev; | 205 | return 0; |
204 | if (end - pos > 0) | 206 | if (end - pos > 0) |
205 | { | 207 | { |
206 | prev = addKeyword (EXTRACTOR_SOURCE, | 208 | ADD (EXTRACTOR_METATYPE_SOURCE, |
207 | stndup (&buf[pos], end - pos), prev); | 209 | stndup (&buf[pos], end - pos)); |
208 | pos = end + 1; | 210 | pos = end + 1; |
209 | } | 211 | } |
210 | end = pos; | 212 | end = pos; |
211 | NEXT (&end, buf, size); | 213 | NEXT (&end, buf, size); |
212 | if (end > size) | 214 | if (end > size) |
213 | return prev; | 215 | return 0; |
214 | if (end - pos > 0) | 216 | if (end - pos > 0) |
215 | { | 217 | { |
216 | prev = addKeyword (EXTRACTOR_BOOKTITLE, | 218 | ADD (EXTRACTOR_METATYPE_BOOK_TITLE, |
217 | stndup (&buf[pos], end - pos), prev); | 219 | stndup (&buf[pos], end - pos)); |
218 | pos = end + 1; | 220 | pos = end + 1; |
219 | } | 221 | } |
220 | } | 222 | } |
221 | 223 | ||
222 | return prev; | 224 | return 0; |
223 | } | 225 | } |
224 | 226 | ||
225 | /* end of manextractor.c */ | 227 | /* end of man_extractor.c */ |
diff --git a/src/plugins/rpm_extractor.c b/src/plugins/rpm_extractor.c index 21755ce..344a6f6 100644 --- a/src/plugins/rpm_extractor.c +++ b/src/plugins/rpm_extractor.c | |||
@@ -71,7 +71,7 @@ typedef struct | |||
71 | static Matches tests[] = { | 71 | static Matches tests[] = { |
72 | {RPMTAG_NAME, EXTRACTOR_METATYPE_PACKAGE_NAME}, | 72 | {RPMTAG_NAME, EXTRACTOR_METATYPE_PACKAGE_NAME}, |
73 | {RPMTAG_VERSION, EXTRACTOR_METATYPE_SOFTWARE_VERSION}, | 73 | {RPMTAG_VERSION, EXTRACTOR_METATYPE_SOFTWARE_VERSION}, |
74 | {RPMTAG_GROUP, EXTRACTOR_METATYPE_PACKAGE_SECTION}, | 74 | {RPMTAG_GROUP, EXTRACTOR_METATYPE_SECTION}, |
75 | {RPMTAG_SIZE, EXTRACTOR_METATYPE_PACKAGE_INSTALLED_SIZE}, | 75 | {RPMTAG_SIZE, EXTRACTOR_METATYPE_PACKAGE_INSTALLED_SIZE}, |
76 | {RPMTAG_SUMMARY, EXTRACTOR_METATYPE_SUMMARY}, | 76 | {RPMTAG_SUMMARY, EXTRACTOR_METATYPE_SUMMARY}, |
77 | {RPMTAG_PACKAGER, EXTRACTOR_METATYPE_PACKAGE_MAINTAINER}, | 77 | {RPMTAG_PACKAGER, EXTRACTOR_METATYPE_PACKAGE_MAINTAINER}, |