summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorberkeviktor@aol.com <berkeviktor@aol.com>2011-01-25 23:44:52 +0100
committerberkeviktor@aol.com <berkeviktor@aol.com>2011-01-25 23:44:52 +0100
commitd5854a90cb58ed75da92aebc99061dd8133536d5 (patch)
tree891968b0549ce0cc113e2688b9f357d0c483fdb5
parent8dba900025a094b13900ba67b10c12772911d199 (diff)
msvc compilation fixes
-rw-r--r--plugins/mpcinfo/functions.c31
-rw-r--r--plugins/mpcinfo/mp3Info.c68
-rw-r--r--plugins/mpcinfo/mpcInfo.c16
-rw-r--r--plugins/mpcinfo/oggInfo.c46
-rw-r--r--plugins/mpcinfo/theme.c79
5 files changed, 148 insertions, 92 deletions
diff --git a/plugins/mpcinfo/functions.c b/plugins/mpcinfo/functions.c
index 5db0bc12..ed0632d4 100644
--- a/plugins/mpcinfo/functions.c
+++ b/plugins/mpcinfo/functions.c
@@ -14,17 +14,18 @@
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+/*
 typedef int (*MYPROC)(HWND,HWND,char*,char*,BOOL,BOOL); 
 
 int dllProc(char *name, char *data){
     HINSTANCE hinstLib; 
     hinstLib = LoadLibrary("mpcinfo");
-    MYPROC proc;
+    //MYPROC proc;
     int res;
     if (hinstLib != NULL){
-       proc = (MYPROC) GetProcAddress(hinstLib, name);
-       if (proc!=NULL){
-          res=(proc)(NULL,NULL,data,NULL,TRUE,TRUE);
+       //proc = ;
+       if ((MYPROC) GetProcAddress(hinstLib, name)!=NULL){
+          res=(MYPROC)(NULL,NULL,data,NULL,TRUE,TRUE);
        }
        else{fprintf(stderr,"can't get proc: %s\n",name);res=-2;}
     }
@@ -32,6 +33,25 @@ int dllProc(char *name, char *data){
     FreeLibrary(hinstLib);
     return res;
 }
+*/
+
+/*
+int dllProc(char *name, char *data)
+{
+	static HMODULE lib = NULL;
+	if (!lib)
+	{
+		lib = LoadLibraryA ("mpcinfo");
+		if (!lib)
+		{
+			return FALSE;
+		}
+		FreeLibrary (lib);
+	}
+
+	return TRUE;
+}
+*/
 
 char *split(char *text, char seperator){
      //if (DEBUG==1) putlog("splitting");
@@ -66,7 +86,8 @@ int inStr(char *s1, int sl1, char *s2){
 static char *subString(char *text, int first, int length, int spcKill){
 //if (DEBUG==1) putlog("creating substring");
 	char *ret=(char*) calloc (length+1,sizeof(char)); //malloc(sizeof(char)*(length+1));
-	ret[length]=0;int i;
+	int i;
+	ret[length]=0;
 	for (i=0;i<length;i++){
 		ret[i]=text[i+first];
 		//if (ret[i]==0) ret[i]='0';
diff --git a/plugins/mpcinfo/mp3Info.c b/plugins/mpcinfo/mp3Info.c
index 22916d05..f75ba9c4 100644
--- a/plugins/mpcinfo/mp3Info.c
+++ b/plugins/mpcinfo/mp3Info.c
@@ -133,12 +133,12 @@ static char *substring(char *text, int first, int length){return subString(text,
 
 static char *tagExtract(char *tag, int tagLen, char* info){
 //if (DEBUG==1) putlog("extracting tag");
-	int pos=inStr(tag,tagLen,info);
+	int pos, len, i;
+	pos=inStr(tag,tagLen,info);
 //xchat_printf(ph,"pos=%i",pos);
 	if (pos==-1) return "";//NULL;
 	//printf("position of %s = %i\n",info,pos);
-	int len=0;
-	int i;
+	len=0;
 	//for (i=pos;i<pos+10;i++)printf("tag[%i]=%i \n",i,tag[i]);
 	for (i=0;i<4;i++) {
 		len+=tag[pos+strlen(info)+i]*iPow(255,3-i);
@@ -153,20 +153,25 @@ static char *tagExtract(char *tag, int tagLen, char* info){
 
 struct tagInfo readID3V1(char *file){
 //if (DEBUG==1) putlog("reading ID3V1");
-	FILE *f=fopen(file,"rb");
-	struct tagInfo ret; ret.artist=NULL;
-	char *tag =(char*) malloc(sizeof(char)*129);
+	FILE *f;
+	struct tagInfo ret;
+	int res, i, c, val;
+	char *tag;
+	char *id;
+	char *tmp;
+	tag = (char*) malloc(sizeof(char)*129);
+	ret.artist=NULL;
+	f=fopen(file,"rb");
 	if (f==NULL){
        xchat_print(ph,"file not found while trying to read id3v1");
        //if (DEBUG==1) putlog("file not found while trying to read id3v1");
        return ret;
     }
 	//int offset=getSize(file)-128;
-	int res=fseek(f,-128,SEEK_END);
+	res=fseek(f,-128,SEEK_END);
 	if (res!=0) {printf("seek failed\n");fclose(f);return ret;}
 	//long int pos=ftell(f);
 	//printf("position= %li\n",pos);
-	int i;int c;
 	for (i=0;i<128;i++) {
 		c=fgetc(f);
 		if (c==EOF) {xchat_printf(ph,"read ID3V1 failed\n");fclose(f);return ret;}
@@ -174,17 +179,17 @@ struct tagInfo readID3V1(char *file){
 	}
 	fclose(f);
 	//printf("tag readed: \n");
-	char *id=substring(tag,0,3);
+	id=substring(tag,0,3);
 	//printf("header: %s\n",id);
 	if (strcmp(id,"TAG")!=0){xchat_printf(ph,"no id3 v1 found\n");return ret;}
 	ret.title=subString(tag,3,30,1);
 	ret.artist=subString(tag,33,30,1);
 	ret.album=subString(tag,63,30,1);
 	ret.comment=subString(tag,97,30,1);
-	char *tmp=substring(tag,127,1);
+	tmp=substring(tag,127,1);
 	//ret.genre=substring(tag,127,1);
 	
-	int val=(int)tmp[0];
+	val=(int)tmp[0];
 	if (val<0)val+=256;
 	//xchat_printf(ph, "tmp[0]=%i (%i)",val,tmp[0]);
 	if ((val<148)&&(val>=0)) 
@@ -220,17 +225,21 @@ char *extractID3Genre(char *tag){
 
 struct tagInfo readID3V2(char *file){
 //if (DEBUG==1) putlog("reading id3v2");
-	FILE *f=fopen(file,"rb");
-//xchat_printf(ph,"file :%s",file);
+	FILE *f;
+	int i, c, len;
+	char header[10];
+	char *tag;
 	struct tagInfo ret;
-	if (f==NULL){
+
+	f = fopen(file,"rb");
+	//xchat_printf(ph,"file :%s",file);
+	if (f==NULL)
+	{
        xchat_print(ph,"file not found whilt trying to read ID3V2");
        //if (DEBUG==1)putlog("file not found while trying to read ID3V2");
        return ret;
     }
-	int i;
-	char header[10];
-	int c;
+
 	ret.artist=NULL;
 	for (i=0;i<10;i++){
         c=fgetc(f);
@@ -242,11 +251,11 @@ struct tagInfo readID3V2(char *file){
     }
 	if (strstr(header,"ID3")==header){
 		//xchat_printf(ph,"found id3v2\n");
-		int len=0;
+		len=0;
 		for (i=6;i<10;i++) len+=(int)header[i]*iPow(256,9-i);
 		
 		//char *tag=(char*)malloc(sizeof(char)*len);
-		char *tag=(char*) calloc(len,sizeof(char)); //malloc(sizeof(char)*len);
+		tag=(char*) calloc(len,sizeof(char)); //malloc(sizeof(char)*len);
 		for (i=0;i<len;i++){c=fgetc(f);tag[i]=(char)c;}
 //xchat_printf(ph,"tag length: %i\n",len);
 //xchat_printf(ph,"tag: %s\n",tag);
@@ -273,13 +282,18 @@ struct tagInfo readID3V2(char *file){
 
 struct tagInfo readHeader(char *file){
 //if (DEBUG==1) putlog("reading header");
-	FILE *f=fopen(file,"rb");
+	FILE *f;
 	//int buffer[5120];
+	int versionB, layerB, bitrateB, freqB, modeB;
 	int header[4];
 	int count=0;
 	int cc=0;
-	struct tagInfo info; info.artist=NULL;
-	if (f==NULL){
+	struct tagInfo info;
+	info.artist=NULL;
+
+	f = fopen(file,"rb");
+	if (f==NULL)
+	{
        xchat_print(ph,"file not found while trying to read mp3 header");
        //if (DEBUG==1) putlog("file not found while trying to read mp3 header");
        return info;
@@ -310,11 +324,11 @@ struct tagInfo readHeader(char *file){
 			header[count]=fgetc(f);
 			//printf("header[%i]=%i\n",count,header[count]);
 		}
-		int versionB=(header[1]&8)>>3;
-		int layerB=(header[1]&6)>>1;
-		int bitrateB=(header[2]&240)>>4; //4
-		int freqB=(header[2]&12)>>2;//2
-		int modeB=(header[3]&192)>>6;//6
+		versionB=(header[1]&8)>>3;
+		layerB=(header[1]&6)>>1;
+		bitrateB=(header[2]&240)>>4; //4
+		freqB=(header[2]&12)>>2;//2
+		modeB=(header[3]&192)>>6;//6
 		//printf("Mpeg: %i\nLayer: %i\nBitrate: %i\nFreq: %i\nMode: %i\n",versionB, layerB, bitrateB, freqB, modeB);
 		//int Bitrate=RATES[versionB][layerB-1][bitrateB];
 		//int Freq=FREQS[versionB][freqB];
diff --git a/plugins/mpcinfo/mpcInfo.c b/plugins/mpcinfo/mpcInfo.c
index 89a9f18f..92a6d357 100644
--- a/plugins/mpcinfo/mpcInfo.c
+++ b/plugins/mpcinfo/mpcInfo.c
@@ -43,12 +43,14 @@ static int mpc_themeReload(char *word[], char *word_eol[], void *userdata){
 }
 
 static int mpc_tell(char *word[], char *word_eol[], void *userdata){
-       HWND hwnd = FindWindow("MediaPlayerClassicW",NULL);
+       char *tTitle, *zero, *oggLine, *line;
+	   struct tagInfo info;
+	   HWND hwnd = FindWindow("MediaPlayerClassicW",NULL);
        if (hwnd==0) {xchat_command(ph, randomLine(notRunTheme));return XCHAT_EAT_ALL;}
        
-       char *tTitle=(char*)malloc(sizeof(char)*1024);
+       tTitle=(char*)malloc(sizeof(char)*1024);
        GetWindowText(hwnd, tTitle, 1024);
-       char *zero=strstr(tTitle," - Media Player Classic");
+       zero=strstr(tTitle," - Media Player Classic");
        if (zero!=NULL) zero[0]=0;
        else xchat_print(ph,"pattern not found");
        
@@ -56,7 +58,7 @@ static int mpc_tell(char *word[], char *word_eol[], void *userdata){
           //xchat_print(ph,"seams to be full path");
           if (endsWith(tTitle,".mp3")==1){
              //xchat_print(ph,"seams to be a mp3 file");
-             struct tagInfo info = readHeader(tTitle);
+             info = readHeader(tTitle);
              
              if ((info.artist!=NULL)&&(strcmp(info.artist,"")!=0)){
                 char *mode=MODES[info.mode];
@@ -86,11 +88,11 @@ static int mpc_tell(char *word[], char *word_eol[], void *userdata){
           }
           if (endsWith(tTitle,".ogg")==1){
              xchat_printf(ph,"Ogg detected\n");
-             struct tagInfo info = getOggHeader(tTitle);
+             info = getOggHeader(tTitle);
              if (info.artist!=NULL){
                 char *cbr;
                 if (info.cbr==1) cbr="CBR"; else cbr="VBR";
-                char *oggLine=randomLine(oggTheme);
+                oggLine=randomLine(oggTheme);
                 //if (cue==1) oggLine=cueLine;
                 //xchat_printf(ph,"ogg-line: %s\n",oggLine);
                 oggLine=replace(oggLine,"%art",info.artist);
@@ -114,7 +116,7 @@ static int mpc_tell(char *word[], char *word_eol[], void *userdata){
              }
           }
        }
-       char *line=randomLine(titleTheme);
+       line=randomLine(titleTheme);
        line=replace(line,"%title", tTitle);
        xchat_command(ph,line); 
        return XCHAT_EAT_ALL;
diff --git a/plugins/mpcinfo/oggInfo.c b/plugins/mpcinfo/oggInfo.c
index d9afc3bf..83c2beb5 100644
--- a/plugins/mpcinfo/oggInfo.c
+++ b/plugins/mpcinfo/oggInfo.c
@@ -28,9 +28,9 @@ static int getOggInt(char *buff, int beg, int bytes){
 static char *upperStr(char *text){
 //if (DEBUG==1) putlog("converting text to uc");
     //printf("upperStr(%s)\n",text);
+	int i;
 	char *ret=(char*) malloc(sizeof(char)*(strlen(text)+1));
 	ret[strlen(text)]=0;
-	int i;
 	for (i=0;i<strlen(text);i++) ret[i]=toupper(text[i]);
 	//printf("Result: %s\n",ret);
 	return ret;
@@ -38,42 +38,52 @@ static char *upperStr(char *text){
 
 struct tagInfo getOggHeader(char *file){
 //if (DEBUG==1) putlog("reading ogg header");
-	FILE *f=fopen(file,"rb");
-	struct tagInfo info; info.artist=NULL;
+	char header[4096];
+	int i, c;
+	int h1pos, h3pos, maxBr, nomBr, minBr, pos, count, tagLen;
+	char *sub;
+	char *name;
+	char *val;
+	char *HEADLOC1, *HEADLOC3, *HEADLOC5;
+	FILE *f;
+	struct tagInfo info;
+
+	info.artist=NULL;
+	f = fopen(file,"rb");
 	if (f==NULL){
        xchat_print(ph,"file not found while trying to read ogg header");
        //if (DEBUG==1) putlog("file not found while trying to read ogg header");
        return info;
     }
-	char header[4096];
-	int i;int c;
+
 	for (i=0;i<4095;i++) {c=fgetc(f);header[i]=(char)c;}
 	fclose(f);
-	char HEADLOC1[]="_vorbis";HEADLOC1[0]=1;
-	char HEADLOC3[]="_vorbis";HEADLOC3[0]=3;
-	char HEADLOC5[]="_vorbis";HEADLOC5[0]=5;
-	int h1pos=inStr(header,4096,HEADLOC1);
-	int h3pos=inStr(header,4096,HEADLOC3);
+	HEADLOC1="_vorbis";
+	HEADLOC1[0]=1;
+	HEADLOC3="_vorbis";
+	HEADLOC3[0]=3;
+	HEADLOC5="_vorbis";
+	HEADLOC5[0]=5;
+	h1pos=inStr(header,4096,HEADLOC1);
+	h3pos=inStr(header,4096,HEADLOC3);
 	//int h5pos=inStr(header,4096,HEADLOC5); //not needed
 	
 	//printf("loc1: %i\n",h1pos);printf("loc3: %i\n",h3pos);printf("loc5: %i\n",h5pos);
-	int maxBr=getOggInt(header,h1pos+7+9,4);
-	int nomBr=getOggInt(header,h1pos+7+13,4);
-	int minBr=getOggInt(header,h1pos+7+17,4);
+	maxBr=getOggInt(header,h1pos+7+9,4);
+	nomBr=getOggInt(header,h1pos+7+13,4);
+	minBr=getOggInt(header,h1pos+7+17,4);
 	info.freq=getOggInt(header,h1pos+7+5,4);
 	info.mode=header[h1pos+7+4];
 	info.bitrate=nomBr;
 	if (((maxBr==nomBr)&&(nomBr=minBr))||((minBr==0)&&(maxBr==0))||((minBr=-1)&&(maxBr=-1)) )info.cbr=1;else info.cbr=0;
 	printf("bitrates: %i|%i|%i\n",maxBr,nomBr,minBr);
 	printf("freq: %i\n",info.freq);
-	int pos=h3pos+7;
+	pos=h3pos+7;
 	pos+=getOggInt(header,pos,4)+4;
-	int count=getOggInt(header,pos,4);
+	count=getOggInt(header,pos,4);
 	//printf("tags: %i\n",count);
 	pos+=4;
-	int tagLen;
-	char *sub;
-	char *name;char *val;
+
 	info.artist=NULL;info.title=NULL;info.album=NULL;info.comment=NULL;info.genre=NULL;
 	for (i=0;i<count;i++){
 		tagLen=getOggInt(header,pos,4);
diff --git a/plugins/mpcinfo/theme.c b/plugins/mpcinfo/theme.c
index e622936f..000c00b1 100644
--- a/plugins/mpcinfo/theme.c
+++ b/plugins/mpcinfo/theme.c
@@ -51,7 +51,7 @@ void printThemes(){
 
 void cbFix(char *line){
      //if (DEBUG==1) putlog("cbfix");
-     int i;
+     int i, j;
      for (i=0;i<strlen(line);i++){
          if (line[i]=='%'){
             if ((line[i+1]=='C')||(line[i+1]=='B')||(line[i+1]=='U')||(line[i+1]=='O')||(line[i+1]=='R')){
@@ -60,7 +60,7 @@ void cbFix(char *line){
                if(line[i+1]=='U') line[i]=37;
                if(line[i+1]=='O') line[i]=17;
                if(line[i+1]=='R') line[i]=26;
-               int j;
+
                for (j=i+1;j<strlen(line)-1;j++) line[j]=line[j+1];
                line[strlen(line)-1]=0;
             }
@@ -83,39 +83,48 @@ struct theme themeAdd(struct theme data, char *info){
 }
 
 void loadThemes(){
-     xchat_print(ph,"loading themes\n");
-     char *hDir=(char*)calloc(1024,sizeof(char));
-     strcpy(hDir,xchat_get_info(ph,"xchatdirfs"));
-     char *hFile=str3cat(hDir,"\\","mpcInfo.theme.txt");
-     FILE *f=fopen(hFile,"r");
-     if(f==NULL){
-        xchat_print(ph,"no theme in homedir, checking global theme");
-        f=fopen("mpcInfo.theme.txt","r");
-     }
-     //xchat_printf(ph,"file_desc: %p\n",f);
-     if (f==NULL) xchat_print(ph, "no theme found, using hardcoded\n");
-     else {
-          char *line;
-          if (f>0) line=" ";else line="\0";
-          char *val;
-          while (line[0]!=0){
-                 line=readLine(f);
-                 val=split(line,'=');
-                 printf("line: %s\n",line);
-                 printf("val: %s\n",val);
-                 if (strcmp(toUpper(line),"OFF_LINE")==0) notRunTheme=themeAdd(notRunTheme,val);
-                 if (strcmp(toUpper(line),"TITLE_LINE")==0) titleTheme=themeAdd(titleTheme,val);
-                 if (strcmp(toUpper(line),"MP3_LINE")==0) mp3Theme=themeAdd(mp3Theme,val);
-                 if (strcmp(toUpper(line),"OGG_LINE")==0) mp3Theme=themeAdd(oggTheme,val);
-          }
-          fclose(f);
-          xchat_print(ph, "theme loaded successfull\n");
-     }
-     if (notRunTheme.size==0) notRunTheme=themeAdd(notRunTheme,"say Media Player Classic not running");
-     if (titleTheme.size==0) titleTheme=themeAdd(titleTheme,"say Playing %title in Media Player Classic");
-     if (mp3Theme.size==0) mp3Theme=themeAdd(mp3Theme,"me listens to %art with %tit from %alb [%gen|%br kbps|%frq kHz|%mode] in Media Player Classic ");
-     if (oggTheme.size==0) oggTheme=themeAdd(oggTheme,"me listens to %art with %tit from %alb [%gen|%br kbps|%frq kHz|%chan channels] in Media Player Classic ");
-     //mp3Theme=themeAdd(mp3Theme,"me listens to %art with %tit from %alb [%time|%length|%perc%|%br kbps|%frq kHz|%mode] in Media Player Classic ");
+    char *hDir, *hFile, *line, *val;
+	FILE *f;
+	xchat_print(ph,"loading themes\n");
+    hDir=(char*)calloc(1024,sizeof(char));
+    strcpy(hDir,xchat_get_info(ph,"xchatdirfs"));
+    hFile=str3cat(hDir,"\\","mpcInfo.theme.txt");
+    f = fopen(hFile,"r");
+    if(f==NULL)
+	{
+		xchat_print(ph,"no theme in homedir, checking global theme");
+		f=fopen("mpcInfo.theme.txt","r");
+    }
+	//xchat_printf(ph,"file_desc: %p\n",f);
+	if (f==NULL) xchat_print(ph, "no theme found, using hardcoded\n");
+	else {
+		if (f > 0)
+		{
+			line=" ";
+		} else
+		{
+			line="\0";
+		}
+
+		while (line[0]!=0)
+		{
+			line=readLine(f);
+			val=split(line,'=');
+			printf("line: %s\n",line);
+			printf("val: %s\n",val);
+			if (strcmp(toUpper(line),"OFF_LINE")==0) notRunTheme=themeAdd(notRunTheme,val);
+			if (strcmp(toUpper(line),"TITLE_LINE")==0) titleTheme=themeAdd(titleTheme,val);
+			if (strcmp(toUpper(line),"MP3_LINE")==0) mp3Theme=themeAdd(mp3Theme,val);
+			if (strcmp(toUpper(line),"OGG_LINE")==0) mp3Theme=themeAdd(oggTheme,val);
+		}
+		fclose(f);
+		xchat_print(ph, "theme loaded successfull\n");
+	}
+	if (notRunTheme.size==0) notRunTheme=themeAdd(notRunTheme,"say Media Player Classic not running");
+	if (titleTheme.size==0) titleTheme=themeAdd(titleTheme,"say Playing %title in Media Player Classic");
+	if (mp3Theme.size==0) mp3Theme=themeAdd(mp3Theme,"me listens to %art with %tit from %alb [%gen|%br kbps|%frq kHz|%mode] in Media Player Classic ");
+	if (oggTheme.size==0) oggTheme=themeAdd(oggTheme,"me listens to %art with %tit from %alb [%gen|%br kbps|%frq kHz|%chan channels] in Media Player Classic ");
+	//mp3Theme=themeAdd(mp3Theme,"me listens to %art with %tit from %alb [%time|%length|%perc%|%br kbps|%frq kHz|%mode] in Media Player Classic ");
 }
 
 int rnd(int max){