********************************************************************
function: libvorbis codec headers
- last mod: $Id: codec.h,v 1.23 2000/08/04 01:05:45 xiphmont Exp $
+ last mod: $Id: codec.h,v 1.24 2000/08/13 13:55:41 msmith Exp $
********************************************************************/
extern void vorbis_comment_add_tag(vorbis_comment *vc,
char *tag, char *contents);
extern char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count);
+extern int vorbis_comment_query_count(vorbis_comment *vc, char *tag);
extern void vorbis_comment_clear(vorbis_comment *vc);
extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
********************************************************************
function: maintain the info structure, info <-> header packets
- last mod: $Id: info.c,v 1.28 2000/08/01 13:45:13 msmith Exp $
+ last mod: $Id: info.c,v 1.29 2000/08/13 13:55:39 msmith Exp $
********************************************************************/
char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){
long i;
int found = 0;
- int taglen = strlen(tag);
- char *fulltag = alloca(taglen+ 2);
+ int taglen = strlen(tag)+1; /* +1 for the = we append */
+ char *fulltag = alloca(taglen+ 1);
strcpy(fulltag, tag);
strcat(fulltag, "=");
if(!tagcompare(vc->user_comments[i], fulltag, taglen)){
if(count == found)
/* We return a pointer to the data, not a copy */
- return vc->user_comments[i] + taglen + 1;
+ return vc->user_comments[i] + taglen;
else
found++;
}
return NULL; /* didn't find anything */
}
+int vorbis_comment_query_count(vorbis_comment *vc, char *tag){
+ int i,count=0;
+ int taglen = strlen(tag)+1; /* +1 for the = we append */
+ char *fulltag = alloca(taglen+1);
+ strcpy(fulltag,tag);
+ strcat(fulltag, "=");
+
+ for(i=0;i<vc->comments;i++){
+ if(!tagcompare(vc->user_comments[i], fulltag, taglen))
+ count++;
+ }
+
+ return count;
+}
+
+
void vorbis_comment_clear(vorbis_comment *vc){
if(vc){
long i;