home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_02 / 1102021b < prev    next >
Text File  |  1992-12-09  |  541b  |  27 lines

  1. /* _Gettime function */
  2. #include <string.h>
  3. #include "xtime.h"
  4.  
  5. const char *_Gettime(const char *s, int n, int *len)
  6.     {    /*    get time info from environment */
  7.     const char delim = *s ? *s++ : '\0';
  8.     const char *s1;
  9.  
  10.     for (; ; --n, s = s1 + 1)
  11.         {    /* find end of current field */
  12.         if ((s1 = strchr(s, delim)) == NULL)
  13.             s1 = s + strlen(s);
  14.         if (n <= 0)
  15.             {    /* found proper field */
  16.             *len = s1 - s;
  17.             return (s);
  18.             }
  19.         else if (*s1 == '\0')
  20.             {    /* not enough fields */
  21.             *len = 1;
  22.             return (s1);
  23.             }
  24.         }
  25.     }
  26.  
  27.