home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 328_01 / wdtparse.c < prev    next >
C/C++ Source or Header  |  1991-03-17  |  953b  |  35 lines

  1. /* wdtparse.c
  2.  *    a simple parser used by date and time validation funcs.
  3.  *
  4.  *this routine helps parse strings in the form n1/n2/n3/n4/n5.....
  5.  *    into successive numeric values n1, n2, n3, n4,
  6.  *    with each call, the ptr is moved past the next slash.
  7.  * when done , returns 0 for n.
  8.  *
  9.  */
  10. #include "wsys.h"
  11.  
  12. /*this routine helps parse strings in the form n1/n2/n3/n4/n5.....
  13.  *    into successive numeric values n1, n2, n3, n4,
  14.  *    with each call, the ptr is moved past the next slash.
  15.  * when done , returns 0 for n.
  16.  */
  17. void wdtparse (unsigned int *n_ptr, char **ptr_ptr, char parse_char)
  18.     {
  19.     char *ptr = *ptr_ptr;
  20.     if ( ptr == NULL )
  21.         {
  22.         *n_ptr =0;    
  23.         }
  24.     else
  25.         {
  26.         *n_ptr = atoi ( ptr );
  27.         ptr = strchr ( ptr, parse_char );    /* advance to next slash */    
  28.         if ( ptr != NULL )  ++ptr;    /* adv. beyond slash, if it was present */
  29.         *ptr_ptr = ptr;
  30.         }
  31.     return;
  32.     }
  33.  
  34. /*----------------- end of WDTPARSE.C ----------------*/
  35.