Include osdep/stat.h to get S_* macros
[elinks.git] / src / protocol / ftp / ftp-parser.c
blob197466a59dc3e2ca1b94761b61cdba455e1d3adf
1 /* Tool for testing the FTP parser */
3 #ifdef HAVE_CONFIG_H
4 #include "config.h"
5 #endif
7 #include <stdarg.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
12 #include "elinks.h"
14 #include "osdep/stat.h"
15 #include "protocol/ftp/parse.h"
18 void die(const char *msg, ...)
20 va_list args;
22 if (msg) {
23 va_start(args, msg);
24 vfprintf(stderr, msg, args);
25 fputs("\n", stderr);
26 va_end(args);
29 exit(!!NULL);
32 int
33 main(int argc, char *argv[])
35 struct ftp_file_info ftp_info = INIT_FTP_FILE_INFO;
36 unsigned char *response = "";
37 int responselen = 0;
38 int i;
40 for (i = 1; i < argc; i++) {
41 char *arg = argv[i];
43 if (strncmp(arg, "--", 2))
44 break;
46 arg += 2;
48 if (!strncmp(arg, "response", 8)) {
49 arg += 8;
50 if (*arg == '=') {
51 arg++;
52 response = arg;
53 } else {
54 i++;
55 if (i >= argc)
56 die("--response expects a string");
57 response = argv[i];
59 responselen = strlen(response);
61 } else {
62 die("Unknown argument '%s'", arg - 2);
66 if (!responselen)
67 die("Usage: %s --response \"string\"", argv[0]);
69 if (parse_ftp_file_info(&ftp_info, response, responselen))
70 return 0;
72 return 1;