]> andersk Git - libfaim.git/blobdiff - aim_util.c
- Thu Feb 8 02:31:25 UTC 2001
[libfaim.git] / aim_util.c
index 0fa8427cc790bf35b63f6d658b6f81a581e22e72..6ab4f38e206a50de8219443a161b66263fe36a4a 100644 (file)
@@ -7,13 +7,16 @@
 #include <faim/aim.h>
 #include <ctype.h>
 
-int aimutil_put8(u_char *buf, u_char data)
+#ifdef AIMUTIL_USEMACROS
+/* macros in faim/aim.h */
+#else
+faim_shortfunc int aimutil_put8(u_char *buf, u_char data)
 {
   buf[0] = (u_char)data&0xff;
   return 1;
 }
 
-u_char aimutil_get8(u_char *buf)
+faim_shortfunc u_char aimutil_get8(u_char *buf)
 {
   return buf[0];
 }
@@ -21,14 +24,14 @@ u_char aimutil_get8(u_char *buf)
 /*
  * Endian-ness issues here?
  */
-int aimutil_put16(u_char *buf, u_short data)
+faim_shortfunc int aimutil_put16(u_char *buf, u_short data)
 {
   buf[0] = (u_char)(data>>8)&0xff;
   buf[1] = (u_char)(data)&0xff;
   return 2;
 }
 
-u_short aimutil_get16(u_char *buf)
+faim_shortfunc u_short aimutil_get16(u_char *buf)
 {
   u_short val;
   val = (buf[0] << 8) & 0xff00;
@@ -36,7 +39,7 @@ u_short aimutil_get16(u_char *buf)
   return val;
 }
 
-int aimutil_put32(u_char *buf, u_long data)
+faim_shortfunc int aimutil_put32(u_char *buf, u_long data)
 {
   buf[0] = (u_char)(data>>24)&0xff;
   buf[1] = (u_char)(data>>16)&0xff;
@@ -45,7 +48,7 @@ int aimutil_put32(u_char *buf, u_long data)
   return 4;
 }
 
-u_long aimutil_get32(u_char *buf)
+faim_shortfunc u_long aimutil_get32(u_char *buf)
 {
   u_long val;
   val = (buf[0] << 24) & 0xff000000;
@@ -54,8 +57,9 @@ u_long aimutil_get32(u_char *buf)
   val+= (buf[3]      ) & 0x000000ff;
   return val;
 }
+#endif /* AIMUTIL_USEMACROS */
 
-int aimutil_putstr(u_char *dest, const u_char *src, int len)
+faim_export faim_shortfunc int aimutil_putstr(u_char *dest, const char *src, int len)
 {
   memcpy(dest, src, len);
   return len;
@@ -66,7 +70,7 @@ int aimutil_putstr(u_char *dest, const u_char *src, int len)
  *   -- DMP.
  *
  */
-int aimutil_tokslen(char *toSearch, int index, char dl)
+faim_export int aimutil_tokslen(char *toSearch, int index, char dl)
 {
   int curCount = 1;
   char *next;
@@ -91,7 +95,7 @@ int aimutil_tokslen(char *toSearch, int index, char dl)
   return toReturn;
 }
 
-int aimutil_itemcnt(char *toSearch, char dl)
+faim_export int aimutil_itemcnt(char *toSearch, char dl)
 {
   int curCount;
   char *next;
@@ -109,7 +113,7 @@ int aimutil_itemcnt(char *toSearch, char dl)
   return curCount;
 }
 
-char *aimutil_itemidx(char *toSearch, int index, char dl)
+faim_export char *aimutil_itemidx(char *toSearch, int index, char dl)
 {
   int curCount;
   char *next;
@@ -165,7 +169,7 @@ char *aimutil_itemidx(char *toSearch, int index, char dl)
  * return is equal to that of strlen().
  *
  */
-int aim_snlen(const char *sn)
+faim_export int aim_snlen(const char *sn)
 {
   int i = 0;
   const char *curPtr = NULL;
@@ -174,8 +178,7 @@ int aim_snlen(const char *sn)
     return 0;
 
   curPtr = sn;
-  while ( (*curPtr) != (char) NULL)
-    {
+  while ( (*curPtr) != (char) NULL) {
       if ((*curPtr) != ' ')
        i++;
       curPtr++;
@@ -197,7 +200,7 @@ int aim_snlen(const char *sn)
  *
  */
 
-int aim_sncmp(const char *sn1, const char *sn2)
+faim_export int aim_sncmp(const char *sn1, const char *sn2)
 {
   const char *curPtr1 = NULL, *curPtr2 = NULL;
 
@@ -206,23 +209,57 @@ int aim_sncmp(const char *sn1, const char *sn2)
 
   curPtr1 = sn1;
   curPtr2 = sn2;
-  while ( (*curPtr1 != (char) NULL) && (*curPtr2 != (char) NULL) )
-    {
-      if ( (*curPtr1 == ' ') || (*curPtr2 == ' ') )
-       {
-         if (*curPtr1 == ' ')
-           curPtr1++;
-         if (*curPtr2 == ' ')
-           curPtr2++;
-       }
-      else
-       {
-         if ( toupper(*curPtr1) != toupper(*curPtr2))
-             return 1;
-         curPtr1++;
-         curPtr2++;
-       }
+  while ( (*curPtr1 != (char) NULL) && (*curPtr2 != (char) NULL) ) {
+    if ( (*curPtr1 == ' ') || (*curPtr2 == ' ') ) {
+      if (*curPtr1 == ' ')
+       curPtr1++;
+      if (*curPtr2 == ' ')
+       curPtr2++;
+    } else {
+      if ( toupper(*curPtr1) != toupper(*curPtr2))
+       return 1;
+      curPtr1++;
+      curPtr2++;
     }
+  }
 
   return 0;
 }
+
+/* strsep Copyright (C) 1992, 1993 Free Software Foundation, Inc.
+   strsep is part of the GNU C Library.
+   
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+   
+   The GNU C Library 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
+   Library General Public License for more details.
+   
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+   Cambridge, MA 02139, USA.  */
+
+/* Minor changes by and1000 on 15/1/97 to make it go under Nemesis */
+
+faim_export char *aim_strsep(char **pp, const char *delim)
+{
+  char *p, *q;
+  
+  if (!(p = *pp))
+    return 0;
+  
+  if ((q = strpbrk (p, delim)))
+    {
+      *pp = q + 1;
+      *q = '\0';
+    }
+  else
+    *pp = 0;
+  
+  return p;
+}
This page took 1.350501 seconds and 4 git commands to generate.