RCS_ID_C "$Id: userparsing.c,v 1.1 1993/09/15 01:35:56 ppessi Exp $";
/*
 * parsing.c
 *
 * Author: ppessi <Pekka.Pessi@hut.fi>
 *
 * This file is part of the AmiTCP/IP Network Library.
 *
 * Copyright © 1993 AmiTCP/IP Group, <AmiTCP-Group@hut.fi>
 *                  Helsinki University of Technology, Finland.
 *
 * Created      : Wed Sep 15 01:25:26 1993 ppessi
 * Last modified: Wed Sep 15 01:32:21 1993 ppessi
 */

#include <exec/types.h>
#include <sys/errno.h>

/*
 * Parse n fields into a array from line str
 * Return error code or 0 on success 
 */
int do_parse(UBYTE *str, int n, UBYTE **array)
{
  while (*str && n-- > 0) {
    *array++ = str;
    while (*str != '|') {
      if (*str == '\n') {
	*str = '\0';
	if (n == 0)
	  return 0;
	else 
	  return EFTYPE;
      }
      if (*str++ == '\0')
	return EFTYPE;
    }
    *str++ = '\0';
  }
  return EFTYPE;
}
