From 43ea64e4ff21a4337b47f7b7cd849e2ce3317c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano?= Date: Tue, 1 Jan 2013 17:50:59 +0100 Subject: [PATCH] delete, set, add --- opustags.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/opustags.c b/opustags.c index 42929e4..13cd1ff 100644 --- a/opustags.c +++ b/opustags.c @@ -153,9 +153,12 @@ int write_page(ogg_page *og, FILE *stream){ int main(int argc, char **argv){ const char *path_in, *path_out = NULL; + const char* to_add[argc]; + const char* to_delete[argc]; + int count_add = 0, count_delete = 0; int overwrite = 0; int c; - while((c = getopt(argc, argv, "o:y")) != -1){ + while((c = getopt(argc, argv, "o:yd:a:s:")) != -1){ switch(c){ case 'o': path_out = optarg; @@ -163,6 +166,23 @@ int main(int argc, char **argv){ case 'y': overwrite = 1; break; + case 'd': + if(strchr(optarg, '=') != NULL){ + fprintf(stderr, "invalid field: '%s'\n", optarg); + return EXIT_FAILURE; + } + to_delete[count_delete++] = optarg; + break; + case 'a': + case 's': + if(strchr(optarg, '=') == NULL){ + fprintf(stderr, "invalid comment: '%s'\n", optarg); + return EXIT_FAILURE; + } + to_add[count_add++] = optarg; + if(c == 's') + to_delete[count_delete++] = optarg; + break; default: return EXIT_FAILURE; } @@ -262,6 +282,9 @@ int main(int argc, char **argv){ error = "opustags: invalid comment header"; break; } + for(int i=0; i