⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 专门处理mp3文件的tag信息
💻 C
字号:
/* *  MP3Tag - Add ID3 tags to MP3 files based on their filename *  Copyright (C)2000 Dave Ewart (davee@sungate.co.uk) * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */#include <stdio.h>#include <ctype.h>#include <unistd.h>#include "defs.h"#include "const.h"extern int ShowVersion(void);extern int ShowUsage(void);extern int ShowCopy(void);extern int AlreadyGotTag(FILE *somefile);extern struct tagdata ReadTag(FILE *somefile);extern int DisplayTag (struct tagdata sometag);extern struct tagdata CreateTag (char *filename);extern int WriteTag (struct tagdata sometag, FILE *somefile, int style);int main (int argc, char *argv[]){   FILE *InputFile, *OutputFile;   int z;   int i;   int j;   long FileSize;   char *a,*b,*c,*d,*e;   char *filename;   int genre, r;   int verbose=1;   int replace=0;   int dummy=0;   struct tagdata mytag;   int myargs;   int nfiles=0;   int nskipped=0;   /*   printf("------\n");   for (i=0;i<argc;i++) {     printf("Arg %d is %s\n",i,argv[i]);   }   printf("------\n");   while ((myargs=getopt(argc,argv,"+rqv"))!=EOF) {     printf("Option is %c\n",myargs);   }   printf("------\n");   printf("Optind is %d\n",optind);   printf("------\n");   for (i=optind;i<argc;i++) {     printf("Filename parameter is %s\n",argv[i]);   }   printf("------\n");   for (i=0;i<argc;i++) {     printf("Arg %d is %s\n",i,argv[i]);   }   printf("------\n");   */   // filename=argv[argc-1];    opterr=0;   while ((myargs=getopt(argc,argv,"+qrvd"))!=EOF) {     switch(myargs) {       case '?': ShowCopy();                 ShowUsage();                 exit(0);                 break;       case 'q': verbose=0;                 break;       case 'v': verbose=2;                 break;       case 'r': replace=1;                 break;       case 'd': dummy=1;                 break;     }   }   if (argc-optind<1)   {     ShowCopy();     ShowUsage();     exit(0);   }   ShowVersion();   for (j=optind;j<argc;j++) {     filename=argv[j];     if (!(InputFile=fopen (filename,"r")))     {        printf("- *** ERROR *** Cannot open %s.\n",filename);        nskipped++;     }     else {       if (verbose>0) {         if (dummy==0) {           printf("Processing file %s ...\n",filename);         }         else {           printf("Dummy processing file %s ...\n",filename);         }       }       nfiles++;       r=AlreadyGotTag(InputFile);       if (r==TAG_NOTFOUND) {         if (verbose==2) {           printf("- No ID3 tag present.  Creating new tag ...\n");         }         // DisplayTag(CreateTag(filename));         fclose(InputFile);         if (!(InputFile=fopen(filename,"a"))) {           printf("- *** Cannot write to file.\n");         }         else {           if (dummy==0) {             WriteTag(CreateTag(filename),InputFile,WRITETAG_NEW);           }         }       }       else if (r==TAG_FOUND) {         if (verbose==2) {           printf("- ID3 tag found, ");         }         if (replace==0) {           if (verbose==2) {             printf("which will be kept.\n");             DisplayTag(ReadTag(InputFile));           }         }         else {           if (verbose==2) {             printf("which will be overwritten.\n");           }           //DisplayTag(CreateTag(filename));           fclose(InputFile);           if (!(InputFile=fopen(filename,"w"))) {             printf("- *** Cannot write to file.\n");           }           else {             if (dummy==0) {               WriteTag(CreateTag(filename),InputFile,WRITETAG_REPLACE);             }           }         }       }       else {         printf("- *** Error detecting tag.\n");       }     }   }   printf("\nSummary:\n\nFiles procesed: %d\n",nfiles);   if (nskipped>0) {     printf("Files skipped:  %d\n",nskipped);   }   printf("\n");   return(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -