home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / programs / internet / tcp / amitcp / amitcp-api-22.lha / AmiTCP-2.2 / src / netlib / userparsing.c < prev   
Encoding:
C/C++ Source or Header  |  1993-10-13  |  870 b   |  42 lines

  1. RCS_ID_C "$Id: userparsing.c,v 1.1 1993/09/15 01:35:56 ppessi Exp $";
  2. /*
  3.  * parsing.c
  4.  *
  5.  * Author: ppessi <Pekka.Pessi@hut.fi>
  6.  *
  7.  * This file is part of the AmiTCP/IP Network Library.
  8.  *
  9.  * Copyright © 1993 AmiTCP/IP Group, <AmiTCP-Group@hut.fi>
  10.  *                  Helsinki University of Technology, Finland.
  11.  *
  12.  * Created      : Wed Sep 15 01:25:26 1993 ppessi
  13.  * Last modified: Wed Sep 15 01:32:21 1993 ppessi
  14.  */
  15.  
  16. #include <exec/types.h>
  17. #include <sys/errno.h>
  18.  
  19. /*
  20.  * Parse n fields into a array from line str
  21.  * Return error code or 0 on success 
  22.  */
  23. int do_parse(UBYTE *str, int n, UBYTE **array)
  24. {
  25.   while (*str && n-- > 0) {
  26.     *array++ = str;
  27.     while (*str != '|') {
  28.       if (*str == '\n') {
  29.     *str = '\0';
  30.     if (n == 0)
  31.       return 0;
  32.     else 
  33.       return EFTYPE;
  34.       }
  35.       if (*str++ == '\0')
  36.     return EFTYPE;
  37.     }
  38.     *str++ = '\0';
  39.   }
  40.   return EFTYPE;
  41. }
  42.