136 info(0,
"Usage: test_mime [options] source_file");
137 info(0,
"Parse source file into component parts.");
138 info(0,
"Source file has the following format:");
139 info(0,
" boundary=<mime boundary>;");
140 info(0,
" content=<mime content>;");
141 info(0,
"Content headers are added into the content_file. This file has");
142 info(0,
"following format:");
143 info(0,
" headers=<content_headers>;");
144 info(0,
" content=<push-content>;");
145 info(0,
"And options are");
147 info(0,
"print this info");
148 info(0,
" -d filename");
149 info(0,
"store push data to file filename. Default test/data.txt");
150 info(0,
" -c filename");
151 info(0,
"store push control message to file filename. Default");
152 info(0,
" test/pap.txt");
154 info(0,
"write push control message and push data to standard output");
155 info(0,
"Default write it to the file.");
158 int main(
int argc,
char **argv)
165 *push_content_file = NULL,
169 List *content_headers,
171 char *pap_content_file,
190 while ((opt =
getopt(argc, argv,
"hd:sc:")) != EOF) {
213 error(0,
"Invalid option %c", opt);
215 panic(0,
"Stopping");
222 panic(0,
"missing arguments, stopping");
226 pap_content_file =
"test/pap.txt";
230 push_data_file =
"test/data.txt";
233 rdf_content_file =
"test/rdf.txt";
236 if (mime_content == NULL) {
238 error(0,
"No MIME source");
239 panic(0,
"Stopping");
244 error(0,
"Badly formatted source:");
247 panic(0,
"Stopping");
253 error(0,
"Cannot determine boundary, no delimiter; possible");
261 error(0,
"Cannot determine mime content, no delimiter");
270 &content_headers, &rdf_content);
272 error(0,
"Mime_parse returned 0, cannot continue");
278 fp1 = fopen(pap_content_file,
"a");
280 error(0,
"Cannot open the file for pap control message");
284 debug(
"test.mime", 0,
"pap control message appended to the file");
287 debug(
"test.mime", 0,
"pap control message was");
293 fp2 = fopen(push_data_file,
"a");
295 error(0,
"Cannot open the push data file");
311 debug(
"test.mime", 0,
"push content appended to the file");
314 debug(
"test.mime", 0,
"Content headers were");
316 debug(
"test.mime", 0,
"And push content itself");
320 if (rdf_content != NULL)
322 if (!std_out && rdf_content != NULL) {
324 if (rdf_content != NULL) {
325 fp3 = fopen(rdf_content_file,
"a");
327 error(0,
"Cannot open the rdf file");
331 debug(
"test.mime", 0,
"push caps message appended to the file");
335 if (rdf_content != NULL) {
336 debug(
"test.mime", 0,
"push caps message was");
353 info(0,
"MIME data parsed successfully");
363 panic(0,
"Stopping");
376 panic(0,
"Stopping");
390 panic(0,
"Stopping");
void error(int err, const char *fmt,...)
static Octstr * delimiter
void info(int err, const char *fmt,...)
static void prepend_crlf(Octstr **os)
static void remove_crs(Octstr *os)
void octstr_append(Octstr *ostr1, const Octstr *ostr2)
long gwlist_len(List *list)
static int skip_tail(Octstr **os, int delimiter)
int octstr_print(FILE *f, Octstr *ostr)
#define octstr_get_cstr(ostr)
long octstr_search_char(const Octstr *ostr, int ch, long pos)
void http_destroy_headers(List *headers)
int getopt(int argc, char **argv, char *opts)
Octstr * octstr_imm(const char *cstr)
static void add_crs(Octstr *os)
void octstr_insert(Octstr *ostr1, const Octstr *ostr2, long pos)
void * gwlist_extract_first(List *list)
void octstr_delete(Octstr *ostr1, long pos, long len)
#define octstr_dump(ostr, level,...)
Octstr * octstr_format(const char *fmt,...)
void octstr_destroy(Octstr *ostr)
#define octstr_create(cstr)
void octstr_destroy_item(void *os)
Octstr * octstr_read_file(const char *filename)
long octstr_len(const Octstr *ostr)
int main(int argc, char **argv)
void debug(const char *place, int err, const char *fmt,...)
static void append_crlf(Octstr *os)
void octstr_format_append(Octstr *os, const char *fmt,...)
void gwlib_shutdown(void)
int octstr_get_char(const Octstr *ostr, long pos)
List * octstr_split(const Octstr *os, const Octstr *sep)
int mime_parse(Octstr *boundary, Octstr *mime_content, Octstr **pap_content, Octstr **push_data, List **content_headers, Octstr **rdf_content)
void http_header_dump(List *headers)
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)