projects
/
mymail.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ab41ec8
)
Cosmetics.
author
Francois Fleuret
<francois@fleuret.org>
Thu, 31 Jan 2013 16:02:27 +0000
(17:02 +0100)
committer
Francois Fleuret
<francois@fleuret.org>
Thu, 31 Jan 2013 16:02:27 +0000
(17:02 +0100)
mymail.c
patch
|
blob
|
history
diff --git
a/mymail.c
b/mymail.c
index
a241a86
..
313b8d5
100644
(file)
--- a/
mymail.c
+++ b/
mymail.c
@@
-60,8
+60,6
@@
struct parsable_field {
char *db_filename;
char *db_root_path;
char *db_filename;
char *db_root_path;
-int multi_db_files;
-
int paranoid;
int action_index;
int paranoid;
int action_index;
@@
-101,7
+99,7
@@
void print_usage(FILE *out) {
print_version(out);
fprintf(out, "Written by Francois Fleuret <francois@fleuret.org>.\n");
fprintf(out, "\n");
print_version(out);
fprintf(out, "Written by Francois Fleuret <francois@fleuret.org>.\n");
fprintf(out, "\n");
- fprintf(out, "Usage: mymail [options] [<
filename1> [<filename
2> ...]]\n");
+ fprintf(out, "Usage: mymail [options] [<
mbox dir1> [<mbox dir
2> ...]]\n");
fprintf(out, "\n");
fprintf(out, " -h, --help\n");
fprintf(out, " show this help\n");
fprintf(out, "\n");
fprintf(out, " -h, --help\n");
fprintf(out, " show this help\n");
@@
-109,10
+107,12
@@
void print_usage(FILE *out) {
fprintf(out, " print the version number\n");
fprintf(out, " -i, --index\n");
fprintf(out, " index mails\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, " -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");
}
/*********************************************************************/
}
/*********************************************************************/
@@
-195,7
+195,8
@@
void search_in_db(int nb_search_patterns,
else {
for(n = 0; n < nb_search_patterns; n++) {
hits[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);
}
}
}
}
}
}
@@
-414,10
+415,9
@@
static struct option long_options[] = {
{ "help", no_argument, 0, 'h' },
{ "version", no_argument, 0, 'v' },
{ "db-file", 1, 0, 'd' },
{ "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' },
{ "index", 0, 0, 'i' },
- { "multi-db-files", 0, 0, 'm' },
{ 0, 0, 0, 0 }
};
{ 0, 0, 0, 0 }
};
@@
-452,17
+452,20
@@
int main(int argc, char **argv) {
int nb_search_patterns;
char *search_pattern[MAX_NB_SEARCH_PATTERNS];
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;
paranoid = 0;
action_index = 0;
db_filename = 0;
db_root_path = 0;
- multi_db_files = 0;
setlocale(LC_ALL, "");
nb_search_patterns = 0;
setlocale(LC_ALL, "");
nb_search_patterns = 0;
- while ((c = getopt_long(argc, argv, "hvi
mp:s:d:p
:",
+ while ((c = getopt_long(argc, argv, "hvi
p:s:d:r
:",
long_options, NULL)) != -1) {
switch(c) {
long_options, NULL)) != -1) {
switch(c) {
@@
-479,15
+482,11
@@
int main(int argc, char **argv) {
action_index = 1;
break;
action_index = 1;
break;
- case 'm':
- multi_db_files = 1;
- break;
-
case 'd':
db_filename = strdup(optarg);
break;
case 'd':
db_filename = strdup(optarg);
break;
- case '
p
':
+ case '
r
':
db_root_path = strdup(optarg);
break;
db_root_path = strdup(optarg);
break;
@@
-509,11
+508,7
@@
int main(int argc, char **argv) {
char *default_db_filename = getenv("MYMAIL_DB_FILE");
if(!default_db_filename) {
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);
}
db_filename = strdup(default_db_filename);
@@
-522,17
+517,18
@@
int main(int argc, char **argv) {
if(!db_root_path) {
char *default_db_root_path = getenv("MYMAIL_DB_ROOT");
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);
if(error) {
print_usage(stderr);
exit(EXIT_FAILURE);