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("$Heimdal: pop_parse.c 5530 1999-03-13 21:17:27Z assar $"
12 * parse: Parse a raw input line from a POP client
13 * into null-delimited tokens
17 pop_parse(POP
*p
, char *buf
)
22 /* Loop through the POP command array */
23 for (mp
= buf
, i
= 0; ; i
++) {
25 /* Skip leading spaces and tabs in the message */
26 while (isspace((unsigned char)*mp
))mp
++;
28 /* Are we at the end of the message? */
31 /* Have we already obtained the maximum allowable parameters? */
32 if (i
>= MAXPARMCOUNT
) {
33 pop_msg(p
,POP_FAILURE
,"Too many arguments supplied.");
37 /* Point to the start of the token */
40 /* Search for the first space character (end of the token) */
41 while (!isspace((unsigned char)*mp
) && *mp
) mp
++;
43 /* Delimit the token with a null */
47 /* Were any parameters passed at all? */
48 if (i
== 0) return (-1);
50 /* Convert the first token (POP command) to lower case */
51 strlwr(p
->pop_command
);
53 /* Return the number of tokens extracted minus the command itself */