home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.7z / ftp.whtech.com / emulators / v9t9 / linux / sources / V9t9 / source / sysdeps.c < prev    next >
Encoding:
C/C++ Source or Header  |  2006-10-19  |  1.0 KB  |  83 lines

  1. #include <conf.h>
  2. #include "sysdeps.h"
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6.  
  7. #if !HAVE_STRCASECMP
  8. int
  9. strcasecmp(const char *a, const char *b) 
  10. {
  11.     int        x;
  12.  
  13.     while ((x = tolower(*a) - tolower(*b)) == 0 && *a) {
  14.         a++;
  15.         b++;
  16.     }
  17.     return x;
  18. }
  19. #endif
  20.  
  21. #if !HAVE_STRNCASECMP
  22. int
  23. strncasecmp(const char *a, const char *b, int max)
  24. {
  25.     int        x = 0;
  26.  
  27.     while (max-- && (x = tolower(*a) - tolower(*b)) == 0 && *a) {
  28.         a++;
  29.         b++;
  30.     }
  31.     return x;
  32. }
  33. #endif 
  34.    
  35. #if !HAVE_STRDUP
  36. char *
  37. strdup(const char *s)
  38. {
  39.     int        len = strlen(s) + 1;
  40.     char      *ret = (char *) malloc(len);
  41.  
  42.     if (ret)
  43.         strcpy(ret, s);
  44.     return ret;
  45. }
  46.  
  47. #endif
  48.  
  49. #if !HAVE_SWAB
  50. void
  51. swab(const void *_src, void *_dst, int num)
  52. {
  53.     const char *src = (const char *)_src;
  54.     char *dst = (char *)_dst;
  55.  
  56.     while (num > 2) {
  57.         char       tmp;
  58.  
  59.         tmp = src[0];
  60.         dst[0] = src[1];
  61.         dst[1] = tmp;
  62.         dst += 2;
  63.         src += 2;
  64.         num -= 2;
  65.     }
  66. #endif 
  67.  
  68. #if !HAVE_STRUPR
  69. char *
  70. strupr(char *s)
  71. {
  72.     char      *orig = s;
  73.  
  74.     while (*s) {
  75.         *s = toupper(*s);
  76.         s++;
  77.     }
  78.     return orig;
  79. }
  80.  
  81. #endif
  82.