summary refs log tree commit diff stats
path: root/plugins/mpcinfo/functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/mpcinfo/functions.c')
-rw-r--r--plugins/mpcinfo/functions.c105
1 files changed, 47 insertions, 58 deletions
diff --git a/plugins/mpcinfo/functions.c b/plugins/mpcinfo/functions.c
index ff2d563e..e5993948 100644
--- a/plugins/mpcinfo/functions.c
+++ b/plugins/mpcinfo/functions.c
@@ -14,54 +14,27 @@
  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 = ;
-       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;}
-    }
-    else{fprintf(stderr,"can't access dll\n");return -1;}
-    FreeLibrary(hinstLib);
-    return res;
-}
-*/
+#include <glib.h>
 
-/*
-int dllProc(char *name, char *data)
+char *split(char *text, char separator)
 {
-	static HMODULE lib = NULL;
-	if (!lib)
+	int pos = -1;
+	size_t i;
+	for (i = 0; i < strlen(text); i++)
 	{
-		lib = LoadLibraryA ("mpcinfo");
-		if (!lib)
-		{
-			return FALSE;
+		if (text[i] == separator) {
+			pos = i;
+			i = strlen(text) + 1;
 		}
-		FreeLibrary (lib);
 	}
 
-	return TRUE;
-}
-*/
+	if (pos == -1)
+	{
+		return text;
+	}
 
-char *split(char *text, char seperator){
-     //if (DEBUG==1) putlog("splitting");
-     int i;int pos=-1;
-     for (i=0;i<strlen(text);i++){
-         if (text[i]==seperator){pos=i;i=strlen(text)+1;}
-     }
-     if (pos==-1) return text;
-     text[pos]=0;
-     return &(text[pos+1]);
+	text[pos] = 0;
+	return &(text[pos + 1]);
 }
 
 int endsWith(char *text, char *suffix){
@@ -71,21 +44,32 @@ int endsWith(char *text, char *suffix){
     return 0;
 }
 
-int inStr(char *s1, int sl1, char *s2){
-    //if (DEBUG==1) putlog("checking instr");
-	int i;int j;
-	for(i=0;i<sl1-strlen(s2);i++){
-		for (j=0;j<strlen(s2);j++){
-			if (s1[i+j]!=s2[j]) j=strlen(s2)+2;
+int inStr(char *s1, size_t sl1, char *s2)
+{
+	size_t i;
+	for (i = 0; i < sl1 - strlen(s2); i++)
+	{
+		size_t j;
+		for (j = 0; j < strlen(s2); j++)
+		{
+			if (s1[i + j] != s2[j])
+			{
+				j = strlen(s2) + 2;
+			}
+		}
+
+		if (j == strlen(s2))
+		{
+			return i;
 		}
-		if (j==strlen(s2)) return i;
 	}
+
 	return -1;
 }
 
 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));
+	char *ret = g_new (char, length + 1);
 	int i;
 	ret[length]=0;
 	for (i=0;i<length;i++){
@@ -107,7 +91,7 @@ static char *substring(char *text, int first, int length){return subString(text,
 
 char *readLine(FILE *f){
      //if (DEBUG==1) putlog("reading line from file");
-     char *buffer=(char*)calloc(1024,sizeof(char)); //malloc(sizeof(char)*1024);
+     char *buffer = g_new (char, 1024);
      int pos=0;
      int cc=0;
      while((cc!=EOF)&&(pos<1024)&&(cc!=10)){
@@ -121,14 +105,19 @@ char *readLine(FILE *f){
      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<strlen(text);i++) ret[i]=toupper(text[i]);
-     ret[strlen(text)]=0;
-     //if (DEBUG==1) putlog("uc done");
-     return ret;
+char *toUpper(char *text)
+{
+	char *ret = (char*) calloc(strlen(text) + 1, sizeof(char));
+
+	size_t i;
+	for (i = 0; i < strlen(text); i++)
+	{
+		ret[i] = toupper(text[i]);
+	}
+
+	ret[strlen(text)] = 0;
+
+	return ret;
 }
 
 static char *str3cat(char *s1, char *s2, char *s3){