- for( i = 1; i < argc; i++ ) {
- if( !strcmp(argv[i], "--help") ) {
- show_usage();
- exit(1);
- } else
- if( !strcmp(argv[i], "--mutt-query") )
- mutt_query(argv[i + 1]);
- else
- if( !strcmp(argv[i], "--datafile") ) {
- if (argv[i+1]) {
- if (argv[i+1][0] != '/') {
- char *cwd = my_getcwd();
- datafile = strconcat(cwd, "/", argv[i+1], NULL);
- free(cwd);
- } else {
- datafile = strdup(argv[i+1]);
- }
- i++;
- } else {
+ for(;;) {
+ int option_index = 0;
+ enum {
+ OPT_ADD_EMAIL,
+ OPT_ADD_EMAIL_QUIET,
+ OPT_MUTT_QUERY,
+ OPT_CONVERT,
+ OPT_INFORMAT,
+ OPT_OUTFORMAT,
+ OPT_INFILE,
+ OPT_OUTFILE,
+ OPT_FORMATS
+ };
+ static struct option long_options[] = {
+ { "help", 0, 0, 'h' },
+ { "add-email", 0, 0, OPT_ADD_EMAIL },
+ { "add-email-quiet", 0, 0, OPT_ADD_EMAIL_QUIET },
+ { "datafile", 1, 0, 'f' },
+ { "mutt-query", 1, 0, OPT_MUTT_QUERY },
+ { "config", 1, 0, 'C' },
+ { "convert", 0, 0, OPT_CONVERT },
+ { "informat", 1, 0, OPT_INFORMAT },
+ { "outformat", 1, 0, OPT_OUTFORMAT },
+ { "infile", 1, 0, OPT_INFILE },
+ { "outfile", 1, 0, OPT_OUTFILE },
+ { "formats", 0, 0, OPT_FORMATS },
+ { 0, 0, 0, 0 }
+ };
+
+ c = getopt_long(argc, argv, "hC:",
+ long_options, &option_index);
+
+ if(c == -1)
+ break;
+
+ switch(c) {
+ case 'h':