Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

Common.c

Go to the documentation of this file.
00001 /*
00002  *    gui - [gega user interface] the flexible solution for user interface problems
00003  *    Copyright (C) 2002  Gergely Gati
00004  *
00005  *    This program is free software; you can redistribute it and/or modify
00006  *    it under the terms of the GNU General Public License as published by
00007  *    the Free Software Foundation; version 2 of the License.
00008  *
00009  *    This program is distributed in the hope that it will be useful,
00010  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *    GNU General Public License for more details.
00013  *
00014  *    You should have received a copy of the GNU General Public License
00015  *    along with this program; if not, write to the Free Software
00016  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  *
00018  *    Gergely Gati
00019  *      email:           g.gati@freemail.hu
00020  *      AIM screenname:  GatiGergely
00021  *      ICQ number:      93131690
00022  *
00023  */
00024 #include <string.h>
00025 #include <ctype.h>
00026 
00027 #include "debug.h"
00028 #include "Memory.h"
00029 #include "Common.h"
00030 
00031 
00032 int common_stricmp(const char *s1, const char *s2)
00033 {
00034   register const unsigned char *p1 = (const unsigned char *) s1;
00035   register const unsigned char *p2 = (const unsigned char *) s2;
00036   register int ret;
00037   unsigned char c1;
00038 
00039   if (p1 == p2) return 0;
00040 
00041   for (; !(ret = (c1 = tolower(*p1)) - tolower(*p2)); p1++, p2++)
00042       if (c1 == '\0') break;
00043   return ret;
00044 }
00045 
00046 char *common_GetAttr(const char **atts, char *attname)
00047 {
00048   int i;
00049   char *ret=NULL;
00050 
00051   if(atts!=NULL&&attname!=NULL)
00052   {
00053     for(i=0;atts[i]!=NULL;i+=2) if(strcmp(atts[i],attname)==0) { ret=(char *)atts[i+1]; break; }
00054   }
00055 
00056   return(ret);
00057 }
00058 
00059 
00060 char *common_strdup(const char *s)
00061 {
00062   char *ret=NULL;
00063 
00064   if(s!=NULL&&NULL!=(ret=mem_malloc(strlen(s)+1)))
00065   {
00066     strcpy(ret,s);
00067   }
00068 
00069   return(ret);
00070 }

Generated on Tue Jan 7 12:11:18 2003 for THEGUI by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002