From 8dba900025a094b13900ba67b10c12772911d199 Mon Sep 17 00:00:00 2001 From: "berkeviktor@aol.com" Date: Tue, 25 Jan 2011 22:35:21 +0100 Subject: initial sources for mpcinfo --- plugins/mpcinfo/functions.c | 146 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 plugins/mpcinfo/functions.c (limited to 'plugins/mpcinfo/functions.c') diff --git a/plugins/mpcinfo/functions.c b/plugins/mpcinfo/functions.c new file mode 100644 index 00000000..5db0bc12 --- /dev/null +++ b/plugins/mpcinfo/functions.c @@ -0,0 +1,146 @@ +/* + * 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., 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; + int res; + if (hinstLib != NULL){ + proc = (MYPROC) GetProcAddress(hinstLib, name); + if (proc!=NULL){ + res=(proc)(NULL,NULL,data,NULL,TRUE,TRUE); + } + else{fprintf(stderr,"can't get proc: %s\n",name);res=-2;} + } + else{fprintf(stderr,"can't access dll\n");return -1;} + FreeLibrary(hinstLib); + return res; +} + +char *split(char *text, char seperator){ + //if (DEBUG==1) putlog("splitting"); + int i;int pos=-1; + for (i=0;i=0;i--){ + if (ret[i]==32) ret[i]=0; + else i=-1; + } + } + //if (DEBUG==1) putlog("substring created"); + return ret; +} + +static char *substring(char *text, int first, int length){return subString(text,first,length,0);} + + +char *readLine(FILE *f){ + //if (DEBUG==1) putlog("reading line from file"); + char *buffer=(char*)calloc(1024,sizeof(char)); //malloc(sizeof(char)*1024); + int pos=0; + int cc=0; + while((cc!=EOF)&&(pos<1024)&&(cc!=10)){ + cc=fgetc(f); + if ((cc!=10)&&(cc!=13)){ + if (cc==EOF) buffer[pos]=0; + else buffer[pos]=(char)cc;pos++; + } + } + if (buffer[pos]==EOF) xchat_printf(ph,"EOF: %i\n",pos); + return buffer; +} + +char *toUpper(char *text){ + //if (DEBUG==1) putlog("converting text to upper case"); + char *ret=(char*) calloc(strlen(text)+1,sizeof(char)); + int i; + for (i=0;i