char *db_filename;
char *db_root_path;
-int multi_db_files;
-
int paranoid;
int action_index;
print_version(out);
fprintf(out, "Written by Francois Fleuret <francois@fleuret.org>.\n");
fprintf(out, "\n");
- fprintf(out, "Usage: mymail [options] [<filename1> [<filename2> ...]]\n");
+ fprintf(out, "Usage: mymail [options] [<mbox dir1> [<mbox dir2> ...]]\n");
fprintf(out, "\n");
fprintf(out, " -h, --help\n");
fprintf(out, " show this help\n");
fprintf(out, " print the version number\n");
fprintf(out, " -i, --index\n");
fprintf(out, " index mails\n");
- fprintf(out, " -d <db filename>, --db-file <db filename>\n");
- fprintf(out, " set the data-base file\n");
fprintf(out, " -s <search pattern>, --search <search pattern>\n");
fprintf(out, " search for matching mails in the data-base file\n");
+ fprintf(out, " -d <db filename>, --db-file <db filename>\n");
+ fprintf(out, " set the data-base file\n");
+ fprintf(out, " -r <db root path>, --db-root <db root path>\n");
+ fprintf(out, " set the data-base root path for recursive search\n");
}
/*********************************************************************/
else {
for(n = 0; n < nb_search_patterns; n++) {
hits[n] |=
- (strcmp(search_name[n], name) == 0 && regexec(®exp[n], value, 0, 0, 0) == 0);
+ (strncmp(search_name[n], name, strlen(search_name[n])) == 0 &&
+ regexec(®exp[n], value, 0, 0, 0) == 0);
}
}
}
{ "help", no_argument, 0, 'h' },
{ "version", no_argument, 0, 'v' },
{ "db-file", 1, 0, 'd' },
- { "db-root", 1, 0, 'p' },
- { "search-pattern", 1, 0, 's' },
+ { "db-root", 1, 0, 'r' },
+ { "search", 1, 0, 's' },
{ "index", 0, 0, 'i' },
- { "multi-db-files", 0, 0, 'm' },
{ 0, 0, 0, 0 }
};
int nb_search_patterns;
char *search_pattern[MAX_NB_SEARCH_PATTERNS];
+ /* for(f = 0; f < argc; f++) { */
+ /* printf("arg %d \"%s\"\n", f, argv[f]); */
+ /* } */
+
paranoid = 0;
action_index = 0;
db_filename = 0;
db_root_path = 0;
- multi_db_files = 0;
setlocale(LC_ALL, "");
nb_search_patterns = 0;
- while ((c = getopt_long(argc, argv, "hvimp:s:d:p:",
+ while ((c = getopt_long(argc, argv, "hvip:s:d:r:",
long_options, NULL)) != -1) {
switch(c) {
action_index = 1;
break;
- case 'm':
- multi_db_files = 1;
- break;
-
case 'd':
db_filename = strdup(optarg);
break;
- case 'p':
+ case 'r':
db_root_path = strdup(optarg);
break;
char *default_db_filename = getenv("MYMAIL_DB_FILE");
if(!default_db_filename) {
- if(multi_db_files) {
- default_db_filename = "mymail.db";
- } else {
- default_db_filename = "/tmp/mymail.db";
- }
+ default_db_filename = "mymail.db";
}
db_filename = strdup(default_db_filename);
if(!db_root_path) {
char *default_db_root_path = getenv("MYMAIL_DB_ROOT");
- if(!default_db_root_path) {
- if(multi_db_files) {
- default_db_root_path = "mymail.db";
- } else {
- default_db_root_path = "/tmp/mymail.db";
- }
+ if(default_db_root_path) {
+ db_root_path = strdup(default_db_root_path);
}
+ }
- db_root_path = strdup(default_db_root_path);
+ if(!db_root_path) {
+ fprintf(stderr,
+ "mymail: db root path is not set\n");
+ exit(EXIT_FAILURE);
}
+
if(error) {
print_usage(stderr);
exit(EXIT_FAILURE);