gtk addon



Hi,
	these are some enachment (??) for the gtk library.
Any comment is welcome..

--
#define GTKADDON
#include "gpop.h"
extern GString *ts;
extern gint tmpint;
extern gchar tmpchar[1024];
extern GList *LMail;

/* in the gpop.h file there are some defines, some includes and this 3 declaration for 3 
global variabile 
GString *ts;
gint tmpint;
gchar tmpchar[1024];
*/

int      g_string_length    (GString     *string);
gchar*   g_string_return    (GString     *string);
int      g_strncmp          (gchar       *s1,
                             gchar       *s2,
                             int          n);
int      g_string_ncmp      (GString     *s1,
                             GString     *s2,
                             int          n);
/* Funzioni riferite alle stringhe */

/* Return the data of the string. I think that is usefull */
char *
g_string_return(GString *string)
{ return string->str;
}

/* Return the length of the string's data (str) */
int 
g_string_length(GString *string)
{ return string->len;
}

/* Compare 2 chars-array*/
int
g_strncmp(gchar *s1, gchar *s2, int n)
{
  return (strncmp(s1,s2,n));
}

/* Campare 2 strings. Use the function above */
int g_string_ncmp(GString *s1, GString *s2, int n)
{ return g_strncmp(s1->str, s2->str,n);
}

/* Substitute some chars in a string. 
   This function is complete, but can contain some bugs.
   It works like s/ of perl.

chstr = what;
whstr = with;
*/
char *
g_char_subs(char *data, char *chstr, char *whstr)
{ int i;
  GString *tmps2;
  
  tmps2 = g_string_new(data);
  
  bzero(tmpchar,1024);
  g_string_free(ts,TRUE);
  
  for (tmpint = 0; tmpint < (strlen(tmps2->str)); tmpint++)
   { 
     if (!g_strncmp(&tmps2->str[tmpint], chstr, strlen(chstr)))
      { bzero(tmpchar,1024);
        g_string_free(ts,TRUE);
        strncpy (tmpchar, tmps2->str, tmpint);
	ts =  g_string_new(tmpchar);
	
	bzero(tmpchar,1024);
	ts = g_string_append(ts,whstr);
	bcopy(&tmps2->str[tmpint+1], tmpchar, strlen(&tmps2->str[tmpint+1]));
	ts = g_string_append(ts, tmpchar);
	
	g_string_free(tmps2,TRUE);
	tmps2 = g_string_new(ts->str);
      }
   }
   return tmps2->str;
}

/*Funzioni riferite alle GList*/
/*This function take 2 argoment:
char *data -- the string
char *delim -- il delimitatore
and return a GList * create from the division of data via delim

It does not work for the moment
*/
GList *
g_string_split(char *delim, char *data)
{ int i;
  GString *tmps2;
  //GList *;
  
  g_list_free(LMail);
  LMail = g_list_alloc();
  
  tmps2 = g_string_new(data);
  
  bzero(tmpchar,1024);
  g_string_free(ts,TRUE);
  
  for (tmpint = 0; tmpint < (strlen(tmps2->str)); tmpint++)
   { if (!g_strncmp(&tmps2->str[tmpint], delim, strlen(delim))) 
      { bzero(tmpchar,1024);
        g_string_free(ts,TRUE);
        strncpy (tmpchar, tmps2->str, tmpint);
	LMail =  g_list_insert(LMail, tmpchar,0);
	ts = g_string_new(&tmps2->str[tmpint+1]);
	g_string_free(tmps2,TRUE);
	tmps2 = g_string_new(ts->str);
        tmpint = 0;
      }
  // glist = g_list_append(glist, tmps2->str);
   }
  strncpy (tmpchar, tmps2->str, tmpint-1);
  LMail =  g_list_insert(LMail, tmpchar,0);
  //LMail = g_list_insert(LMail, tmps2->str,0);
  return LMail;

}
 
--
ciaoz
--
Morelli 'ZioBudda' Davide Michel - Member of Pluto Linux User Group
ziobudda@chiara.dei.unipd.it - http://www.dau.ing.univaq.it/~ziobudda/
Linux Problem? Ask to linux@media.dsi.unimi.it
"/dev/ziobudda: access to /var/tmp/beer denied, use /var/adm/pineapple"



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]