home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / lora299s.zip / LINUX.CPP < prev    next >
C/C++ Source or Header  |  1996-05-04  |  2KB  |  125 lines

  1.  
  2. #include "_ldefs.h"
  3.  
  4. FILE *_fsopen (char *name, char *mode, int shflags)
  5. {
  6.    shflags = shflags;
  7.    return (fopen (name, mode));
  8. }
  9.  
  10. char *strlwr (char *s)
  11. {
  12.    char *p = s;
  13.  
  14.    while (*p != '\0') {
  15.       *p = (char)tolower (*p);
  16.       p++;
  17.    }
  18.  
  19.    return (s);
  20. }
  21.  
  22. char *strupr (char *s)
  23. {
  24.    char *p = s;
  25.  
  26.    while (*p != '\0') {
  27.       *p = (char)toupper (*p);
  28.       p++;
  29.    }
  30.  
  31.    return (s);
  32. }
  33.  
  34. void chsize (int fd, long size)
  35. {
  36.    fd = fd;
  37.    size = size;
  38. }
  39.  
  40. int strnicmp (char *s1, char *s2, size_t maxlen)
  41. {
  42.    int i = maxlen;
  43.  
  44.    do {
  45.       if (toupper (*s1) != toupper (*s2))
  46.          return ((int)(toupper (*s1) - toupper (*s2)));
  47.       s1++;
  48.       s2++;
  49.    } while (--maxlen > 0);
  50.  
  51.    return (0);
  52. }
  53.  
  54. int stricmp (char *s1, char *s2)
  55. {
  56.    while (*s1 != '\0' && *s2 != '\0') {
  57.       if (toupper (*s1) != toupper (*s2))
  58.          return ((int)(toupper (*s1) - toupper (*s2)));
  59.       s1++;
  60.       s2++;
  61.    }
  62.  
  63.    if (toupper (*s1) != toupper (*s2))
  64.       return ((int)(toupper (*s1) - toupper (*s2)));
  65.  
  66.    return (0);
  67. }
  68.  
  69. void _dos_getdate (struct dosdate_t *ddate)
  70. {
  71.    time_t t;
  72.    struct tm *ltm;
  73.  
  74.    t = time (NULL);
  75.    ltm = localtime (&t);
  76.  
  77.    ddate->day = (unsigned char)ltm->tm_mday;
  78.    ddate->month = (unsigned char)(ltm->tm_mon + 1);
  79.    ddate->year = (unsigned int)(ltm->tm_year + 1900);
  80.    ddate->dayofweek = (unsigned char)ltm->tm_wday;
  81. }
  82.  
  83. void _dos_gettime (struct dostime_t *dtime)
  84. {
  85.    time_t t;
  86.    struct tm *ltm;
  87.  
  88.    t = time (NULL);
  89.    ltm = localtime (&t);
  90.  
  91.    dtime->hour = (unsigned char)ltm->tm_hour;
  92.    dtime->minute = (unsigned char)ltm->tm_min;
  93.    dtime->second = (unsigned char)ltm->tm_sec;
  94.    dtime->hsecond = 0;
  95. }
  96.  
  97. long filelength (int fd)
  98. {
  99.    long retval = -1L;
  100.    struct stat buf;
  101.  
  102.    if (fd != -1) {
  103.       fstat (fd, &buf);
  104.       retval = buf.st_size;
  105.    }
  106.  
  107.    return (retval);
  108. }
  109.  
  110. long tell (int fd)
  111. {
  112.    long retval = -1L;
  113.  
  114.    if (fd != -1)
  115.       retval = lseek (fd, 0L, SEEK_CUR);
  116.  
  117.    return (retval);
  118. }
  119.  
  120. int sopen (char *file, int flags, int shmode, int mode)
  121. {
  122.    return (open (file, flags|shmode, mode));
  123. }
  124.  
  125.