X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;f=abook.c;h=d91b64f7ef088315368053ebef901bae1cc33a27;hb=ba9b9ffc6eb621ca0094db55f571010f5f5603ed;hp=101dd69d6b41fe787c2cce462e844163a8f612d9;hpb=c38bc4bc5254bd5925d8567e7ff1554a7844b8c7;p=pkg%2Fabook.git diff --git a/abook.c b/abook.c index 101dd69..d91b64f 100644 --- a/abook.c +++ b/abook.c @@ -104,7 +104,10 @@ init_abook() set_filenames(); check_abook_directory(); init_opts(); - load_opts(rcfile); + if(load_opts(rcfile) > 0) { + printf("Press enter to continue...\n"); + fgetc(stdin); + } signal(SIGKILL, quit_abook_sig); signal(SIGTERM, quit_abook_sig); @@ -605,17 +608,18 @@ FILE * abook_fopen (const char *path, const char *mode) { struct stat s; + bool stat_ok; - if((stat(path, &s)) == -1) - return NULL; + stat_ok = (stat(path, &s) != -1); if(strchr(mode, 'r')) - return S_ISREG(s.st_mode) ? fopen(path, mode) : NULL; + return (stat_ok && S_ISREG(s.st_mode)) ? + fopen(path, mode) : NULL; else - return S_ISDIR(s.st_mode) ? NULL : fopen(path, mode); + return (stat_ok && S_ISDIR(s.st_mode)) ? + NULL : fopen(path, mode); } - static void convert(char *srcformat, char *srcfile, char *dstformat, char *dstfile) { @@ -722,6 +726,16 @@ add_email_add_item(int quiet, char *name, char *email) { list_item item; + if(opt_get_bool(BOOL_ADD_EMAIL_PREVENT_DUPLICATES)) { + int search_fields[] = { EMAIL, -1 }; + if(find_item(email, 0, search_fields) >= 0) { + if(!quiet) + printf("Address %s already in addressbook\n", + email); + return 0; + } + } + if(!quiet) { FILE *in = fopen("/dev/tty", "r"); char c;