2 * Copyright (c) 1989 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
8 RCSID("$Id: pop_parse.c,v 1.9 1999/03/13 21:17:27 assar Exp $");
11 * parse: Parse a raw input line from a POP client
12 * into null-delimited tokens
16 pop_parse(POP *p, char *buf)
21 /* Loop through the POP command array */
22 for (mp = buf, i = 0; ; i++) {
24 /* Skip leading spaces and tabs in the message */
25 while (isspace((unsigned char)*mp))mp++;
27 /* Are we at the end of the message? */
30 /* Have we already obtained the maximum allowable parameters? */
31 if (i >= MAXPARMCOUNT) {
32 pop_msg(p,POP_FAILURE,"Too many arguments supplied.");
36 /* Point to the start of the token */
39 /* Search for the first space character (end of the token) */
40 while (!isspace((unsigned char)*mp) && *mp) mp++;
42 /* Delimit the token with a null */
46 /* Were any parameters passed at all? */
47 if (i == 0) return (-1);
49 /* Convert the first token (POP command) to lower case */
50 strlwr(p->pop_command);
52 /* Return the number of tokens extracted minus the command itself */