diff options
Diffstat (limited to 'src/main/test_bzip2.c')
-rw-r--r-- | src/main/test_bzip2.c | 120 |
1 files changed, 61 insertions, 59 deletions
diff --git a/src/main/test_bzip2.c b/src/main/test_bzip2.c index 37c9aed..598e913 100644 --- a/src/main/test_bzip2.c +++ b/src/main/test_bzip2.c | |||
@@ -46,74 +46,74 @@ 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 | */ |
50 | static int | 50 | static int |
51 | process_replies (void *cls, | 51 | process_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 | "test")) | 67 | "test")) |
68 | { | 68 | { |
69 | fprintf (stderr, "plugin name invalid\n"); | 69 | fprintf (stderr, "plugin name invalid\n"); |
70 | ret = 4; | 70 | ret = 4; |
71 | return 1; | 71 | return 1; |
72 | } | 72 | } |
73 | if (EXTRACTOR_METATYPE_COMMENT != type) | 73 | if (EXTRACTOR_METATYPE_COMMENT != type) |
74 | { | 74 | { |
75 | fprintf (stderr, "type invalid\n"); | 75 | fprintf (stderr, "type invalid\n"); |
76 | ret = 5; | 76 | ret = 5; |
77 | return 1; | 77 | return 1; |
78 | } | 78 | } |
79 | if (EXTRACTOR_METAFORMAT_UTF8 != format) | 79 | if (EXTRACTOR_METAFORMAT_UTF8 != format) |
80 | { | 80 | { |
81 | fprintf (stderr, "format invalid\n"); | 81 | fprintf (stderr, "format invalid\n"); |
82 | ret = 6; | 82 | ret = 6; |
83 | return 1; | 83 | return 1; |
84 | } | 84 | } |
85 | if ( (NULL == data_mime_type) || | 85 | if ( (NULL == data_mime_type) || |
86 | (0 != strcmp ("<no mime>", | 86 | (0 != strcmp ("<no mime>", |
87 | data_mime_type) ) ) | 87 | data_mime_type) ) ) |
88 | { | 88 | { |
89 | fprintf (stderr, "bad mime type\n"); | 89 | fprintf (stderr, "bad mime type\n"); |
90 | ret = 7; | 90 | ret = 7; |
91 | return 1; | 91 | return 1; |
92 | } | 92 | } |
93 | if ( (2 == ret) && | 93 | if ( (2 == ret) && |
94 | (data_len == strlen (HLO) + 1) && | 94 | (data_len == strlen (HLO) + 1) && |
95 | (0 == strncmp (data, | 95 | (0 == strncmp (data, |
96 | HLO, | 96 | HLO, |
97 | strlen (HLO))) ) | 97 | strlen (HLO))) ) |
98 | { | 98 | { |
99 | #if 0 | 99 | #if 0 |
100 | fprintf (stderr, "Received '%s'\n", HLO); | 100 | fprintf (stderr, "Received '%s'\n", HLO); |
101 | #endif | 101 | #endif |
102 | ret = 1; | 102 | ret = 1; |
103 | return 0; | 103 | return 0; |
104 | } | 104 | } |
105 | if ( (1 == ret) && | 105 | if ( (1 == ret) && |
106 | (data_len == strlen (GOB) + 1) && | 106 | (data_len == strlen (GOB) + 1) && |
107 | (0 == strncmp (data, | 107 | (0 == strncmp (data, |
108 | GOB, | 108 | GOB, |
109 | strlen (GOB))) ) | 109 | strlen (GOB))) ) |
110 | { | 110 | { |
111 | #if 0 | 111 | #if 0 |
112 | fprintf (stderr, "Received '%s'\n", GOB); | 112 | fprintf (stderr, "Received '%s'\n", GOB); |
113 | #endif | 113 | #endif |
114 | ret = 0; | 114 | ret = 0; |
115 | return 1; | 115 | return 1; |
116 | } | 116 | } |
117 | fprintf (stderr, "Invalid meta data\n"); | 117 | fprintf (stderr, "Invalid meta data\n"); |
118 | ret = 8; | 118 | ret = 8; |
119 | return 1; | 119 | return 1; |
@@ -132,23 +132,25 @@ main (int argc, char *argv[]) | |||
132 | { | 132 | { |
133 | struct EXTRACTOR_PluginList *pl; | 133 | struct EXTRACTOR_PluginList *pl; |
134 | 134 | ||
135 | /* change environment to find 'extractor_test' plugin which is | 135 | /* change environment to find 'extractor_test' plugin which is |
136 | not installed but should be in the current directory (or .libs) | 136 | not installed but should be in the current directory (or .libs) |
137 | on 'make check' */ | 137 | on 'make check' */ |
138 | if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/")) | 138 | if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/")) |
139 | fprintf (stderr, | 139 | fprintf (stderr, |
140 | "Failed to update my environment, plugin loading may fail: %s\n", | 140 | "Failed to update my environment, plugin loading may fail: %s\n", |
141 | strerror (errno)); | 141 | strerror (errno)); |
142 | pl = EXTRACTOR_plugin_add_config (NULL, "test(test)", | 142 | pl = EXTRACTOR_plugin_add_config (NULL, "test(test)", |
143 | EXTRACTOR_OPTION_DEFAULT_POLICY); | 143 | EXTRACTOR_OPTION_DEFAULT_POLICY); |
144 | if (NULL == pl) | 144 | if (NULL == pl) |
145 | { | 145 | { |
146 | fprintf (stderr, "failed to load test plugin\n"); | 146 | fprintf (stderr, "failed to load test plugin\n"); |
147 | return 1; | 147 | return 1; |
148 | } | 148 | } |
149 | EXTRACTOR_extract (pl, "test_file.dat.bz2", NULL, 0, &process_replies, "main-cls"); | 149 | EXTRACTOR_extract (pl, "test_file.dat.bz2", NULL, 0, &process_replies, |
150 | "main-cls"); | ||
150 | EXTRACTOR_plugin_remove_all (pl); | 151 | EXTRACTOR_plugin_remove_all (pl); |
151 | return ret; | 152 | return ret; |
152 | } | 153 | } |
153 | 154 | ||
155 | |||
154 | /* end of test_bzip2.c */ | 156 | /* end of test_bzip2.c */ |