aboutsummaryrefslogtreecommitdiff
path: root/src/main/test_gzip.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/test_gzip.c')
-rw-r--r--src/main/test_gzip.c124
1 files changed, 63 insertions, 61 deletions
diff --git a/src/main/test_gzip.c b/src/main/test_gzip.c
index 87a61cb..071c74c 100644
--- a/src/main/test_gzip.c
+++ b/src/main/test_gzip.c
@@ -46,78 +46,78 @@ static int ret = 2;
46 * @param data hello world or good bye 46 * @param data hello world or good bye
47 * @param data_len number of bytes in data 47 * @param data_len number of bytes in data
48 * @return 0 on hello world, 1 on goodbye 48 * @return 0 on hello world, 1 on goodbye
49 */ 49 */
50static int 50static int
51process_replies (void *cls, 51process_replies (void *cls,
52 const char *plugin_name, 52 const char *plugin_name,
53 enum EXTRACTOR_MetaType type, 53 enum EXTRACTOR_MetaType type,
54 enum EXTRACTOR_MetaFormat format, 54 enum EXTRACTOR_MetaFormat format,
55 const char *data_mime_type, 55 const char *data_mime_type,
56 const char *data, 56 const char *data,
57 size_t data_len) 57 size_t data_len)
58{ 58{
59 if (0 != strcmp (cls, 59 if (0 != strcmp (cls,
60 "main-cls")) 60 "main-cls"))
61 { 61 {
62 fprintf (stderr, "closure invalid\n"); 62 fprintf (stderr, "closure invalid\n");
63 ret = 3; 63 ret = 3;
64 return 1; 64 return 1;
65 } 65 }
66 if (0 == strcmp (plugin_name, 66 if (0 == strcmp (plugin_name,
67 "<zlib>")) 67 "<zlib>"))
68 return 0; /* skip this one */ 68 return 0; /* skip this one */
69 if (0 != strcmp (plugin_name, 69 if (0 != strcmp (plugin_name,
70 "test")) 70 "test"))
71 { 71 {
72 fprintf (stderr, "plugin name invalid: `%s'\n", 72 fprintf (stderr, "plugin name invalid: `%s'\n",
73 plugin_name); 73 plugin_name);
74 ret = 4; 74 ret = 4;
75 return 1; 75 return 1;
76 } 76 }
77 if (EXTRACTOR_METATYPE_COMMENT != type) 77 if (EXTRACTOR_METATYPE_COMMENT != type)
78 { 78 {
79 fprintf (stderr, "type invalid\n"); 79 fprintf (stderr, "type invalid\n");
80 ret = 5; 80 ret = 5;
81 return 1; 81 return 1;
82 } 82 }
83 if (EXTRACTOR_METAFORMAT_UTF8 != format) 83 if (EXTRACTOR_METAFORMAT_UTF8 != format)
84 { 84 {
85 fprintf (stderr, "format invalid\n"); 85 fprintf (stderr, "format invalid\n");
86 ret = 6; 86 ret = 6;
87 return 1; 87 return 1;
88 } 88 }
89 if ( (NULL == data_mime_type) || 89 if ( (NULL == data_mime_type) ||
90 (0 != strcmp ("<no mime>", 90 (0 != strcmp ("<no mime>",
91 data_mime_type) ) ) 91 data_mime_type) ) )
92 { 92 {
93 fprintf (stderr, "bad mime type\n"); 93 fprintf (stderr, "bad mime type\n");
94 ret = 7; 94 ret = 7;
95 return 1; 95 return 1;
96 } 96 }
97 if ( (2 == ret) && 97 if ( (2 == ret) &&
98 (data_len == strlen (HLO) + 1) && 98 (data_len == strlen (HLO) + 1) &&
99 (0 == strncmp (data, 99 (0 == strncmp (data,
100 HLO, 100 HLO,
101 strlen (HLO))) ) 101 strlen (HLO))) )
102 { 102 {
103#if 0 103#if 0
104 fprintf (stderr, "Received '%s'\n", HLO); 104 fprintf (stderr, "Received '%s'\n", HLO);
105#endif 105#endif
106 ret = 1; 106 ret = 1;
107 return 0; 107 return 0;
108 } 108 }
109 if ( (1 == ret) && 109 if ( (1 == ret) &&
110 (data_len == strlen (GOB) + 1) && 110 (data_len == strlen (GOB) + 1) &&
111 (0 == strncmp (data, 111 (0 == strncmp (data,
112 GOB, 112 GOB,
113 strlen (GOB))) ) 113 strlen (GOB))) )
114 { 114 {
115#if 0 115#if 0
116 fprintf (stderr, "Received '%s'\n", GOB); 116 fprintf (stderr, "Received '%s'\n", GOB);
117#endif 117#endif
118 ret = 0; 118 ret = 0;
119 return 1; 119 return 1;
120 } 120 }
121 fprintf (stderr, "Invalid meta data\n"); 121 fprintf (stderr, "Invalid meta data\n");
122 ret = 8; 122 ret = 8;
123 return 1; 123 return 1;
@@ -136,23 +136,25 @@ main (int argc, char *argv[])
136{ 136{
137 struct EXTRACTOR_PluginList *pl; 137 struct EXTRACTOR_PluginList *pl;
138 138
139 /* change environment to find 'extractor_test' plugin which is 139 /* change environment to find 'extractor_test' plugin which is
140 not installed but should be in the current directory (or .libs) 140 not installed but should be in the current directory (or .libs)
141 on 'make check' */ 141 on 'make check' */
142 if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/")) 142 if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/"))
143 fprintf (stderr, 143 fprintf (stderr,
144 "Failed to update my environment, plugin loading may fail: %s\n", 144 "Failed to update my environment, plugin loading may fail: %s\n",
145 strerror (errno)); 145 strerror (errno));
146 pl = EXTRACTOR_plugin_add_config (NULL, "test(test)", 146 pl = EXTRACTOR_plugin_add_config (NULL, "test(test)",
147 EXTRACTOR_OPTION_DEFAULT_POLICY); 147 EXTRACTOR_OPTION_DEFAULT_POLICY);
148 if (NULL == pl) 148 if (NULL == pl)
149 { 149 {
150 fprintf (stderr, "failed to load test plugin\n"); 150 fprintf (stderr, "failed to load test plugin\n");
151 return 1; 151 return 1;
152 } 152 }
153 EXTRACTOR_extract (pl, "test_file.dat.gz", NULL, 0, &process_replies, "main-cls"); 153 EXTRACTOR_extract (pl, "test_file.dat.gz", NULL, 0, &process_replies,
154 "main-cls");
154 EXTRACTOR_plugin_remove_all (pl); 155 EXTRACTOR_plugin_remove_all (pl);
155 return ret; 156 return ret;
156} 157}
157 158
159
158/* end of test_gzip.c */ 160/* end of test_gzip.c */