/* portions of this code were taken from vorbisfile api documentation examples BSD licensing, etc is still in effect */ #include #include #include #include #include #include #include int outputOggHeaderLen(const char *fileName, const struct stat *status, int type); char* escapeColons( char *stringIn ); int main(int argc, char *argv[]){ if(argc == 1) ftw(".", outputOggHeaderLen, 1); else ftw(argv[1], outputOggHeaderLen, 1); return(0); } int outputOggHeaderLen(const char *fileName, const struct stat *status, int type) { if(type == FTW_F) { FILE *oggFile; OggVorbis_File vf; oggFile = fopen( fileName, "r" ); if(ov_open(oggFile, &vf, NULL, 0) < 0) { //fprintf(stderr,"File: %s skipped.\n", fileName ); return 0; } /* Throw the comments plus a few lines about the bitstream we're decoding */ char **ptr=ov_comment(&vf,-1)->user_comments; unsigned int commentLen = 0; vorbis_info *vi=ov_info(&vf,-1); while(*ptr){ //fprintf(stderr,"%s\n",*ptr); commentLen += strlen(*ptr)+1; ++ptr; } fprintf(stdout,"%s:%d\n", escapeColons(fileName), commentLen); ov_clear(&vf); } return 0; } char* escapeColons( char *stringIn ) { unsigned int colonCount=0; unsigned int length = strlen( stringIn ); while(*stringIn) { if(*stringIn==':') colonCount++; ++stringIn; } stringIn-=length; char *outString,*base; outString = malloc(sizeof(char) * (length + 1 + colonCount)); base=outString; while(*stringIn) { if(*stringIn==':') *(outString++)='\\'; *outString=*stringIn; ++stringIn; ++outString; } *outString='\0'; return base; }