From d5854a90cb58ed75da92aebc99061dd8133536d5 Mon Sep 17 00:00:00 2001 From: "berkeviktor@aol.com" Date: Tue, 25 Jan 2011 23:44:52 +0100 Subject: [PATCH] msvc compilation fixes --- plugins/mpcinfo/functions.c | 31 ++++++++++++--- plugins/mpcinfo/mp3Info.c | 68 ++++++++++++++++++------------- plugins/mpcinfo/mpcInfo.c | 16 ++++---- plugins/mpcinfo/oggInfo.c | 46 ++++++++++++--------- plugins/mpcinfo/theme.c | 79 +++++++++++++++++++++---------------- 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=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>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;i0) 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){