[xiph-cvs] cvs commit: vorbis-tools/vorbiscomment vcomment.c
Michael Smith
msmith at xiph.org
Tue Jul 17 05:28:32 PDT 2001
msmith 01/07/17 05:28:31
Modified: vorbiscomment vcomment.c
Log:
Allow specifying tags on the command line with -t as an alternative to
reading them all from stdin.
Revision Changes Path
1.9 +25 -1 vorbis-tools/vorbiscomment/vcomment.c
Index: vcomment.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vorbiscomment/vcomment.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- vcomment.c 2001/07/12 04:01:43 1.8
+++ vcomment.c 2001/07/17 12:28:31 1.9
@@ -32,6 +32,8 @@
char *infilename, *outfilename;
char *commentfilename;
FILE *in, *out, *com;
+ int commentcount;
+ char **comments;
int tempoutfile;
} param_t;
@@ -68,6 +70,7 @@
vcedit_state *state;
vorbis_comment *vc;
param_t *param;
+ int i;
/* initialize the cmdline interface */
param = new_param();
@@ -120,7 +123,14 @@
vorbis_comment_init(vc);
}
+ for(i=0; i < param->commentcount; i++)
+ {
+ if(add_comment(param->comments[i], vc) < 0)
+ fprintf(stderr, "Bad comment: \"%s\"\n", param->comments[i]);
+ }
+
/* build the replacement structure */
+ if(param->commentcount==0)
{
/* FIXME should use a resizeable buffer! */
char *buf = (char *)malloc(sizeof(char)*1024);
@@ -242,6 +252,11 @@
" instead of stdin.\n"
" Example: vorbiscomment -a in.ogg -c comments.txt\n"
" will append the comments in comments.txt to in.ogg\n"
+ " Finally, you may specify any number of tags to add on\n"
+ " the command line using the -t option. e.g.\n"
+ " vorbiscomment -a in.ogg -t \"ARTIST=Some Guy\" -t \"TITLE=A Title\"\n"
+ " (note that when using this, reading comments from the comment\n"
+ " file or stdin is disabled)\n"
);
}
@@ -268,6 +283,10 @@
param->in = param->out = NULL;
param->com = NULL;
+ param->commentcount=0;
+ param->comments=NULL;
+ param->tempoutfile=0;
+
return param;
}
@@ -285,7 +304,7 @@
int ret;
int option_index = 1;
- while ((ret = getopt_long(argc, argv, "alwhqc:",
+ while ((ret = getopt_long(argc, argv, "alwhqc:t:",
long_options, &option_index)) != -1) {
switch (ret) {
case 0:
@@ -310,6 +329,11 @@
break;
case 'c':
param->commentfilename = strdup(optarg);
+ break;
+ case 't':
+ param->comments = realloc(param->comments,
+ (param->commentcount+1)*sizeof(char *));
+ param->comments[param->commentcount++] = strdup(optarg);
break;
default:
usage();
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list