diff --git a/opustags.c b/opustags.c index 62fd4e5..cb61ac0 100644 --- a/opustags.c +++ b/opustags.c @@ -160,9 +160,11 @@ int main(int argc, char **argv){ const char* to_add[argc]; const char* to_delete[argc]; int count_add = 0, count_delete = 0; + int delete_all = 0; + int set_all = 0; int overwrite = 0; int c; - while((c = getopt(argc, argv, "o:yd:a:s:")) != -1){ + while((c = getopt(argc, argv, "o:yd:a:s:DS")) != -1){ switch(c){ case 'o': path_out = optarg; @@ -187,6 +189,11 @@ int main(int argc, char **argv){ if(c == 's') to_delete[count_delete++] = optarg; break; + case 'S': + set_all = 1; + case 'D': + delete_all = 1; + break; default: return EXIT_FAILURE; } @@ -215,8 +222,15 @@ int main(int argc, char **argv){ } } FILE *in; - if(strcmp(path_in, "-") == 0) + if(strcmp(path_in, "-") == 0){ + if(set_all){ + fputs("can't open stdin for input when -S is specified\n", stderr); + if(out) + fclose(out); + return EXIT_FAILURE; + } in = stdin; + } else in = fopen(path_in, "r"); if(!in){ @@ -294,8 +308,50 @@ int main(int argc, char **argv){ error = "opustags: invalid comment header"; break; } - for(int i=0; i