No empty .Rs/.Re
[netbsd-mini2440.git] / crypto / dist / heimdal / appl / popper / pop_parse.c
blob99c854fc69ac95f20999bb9099f22facc9333be3
1 /*
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.
5 */
7 #include <popper.h>
8 __RCSID("$Heimdal: pop_parse.c 5530 1999-03-13 21:17:27Z assar $"
9 "$NetBSD$");
11 /*
12 * parse: Parse a raw input line from a POP client
13 * into null-delimited tokens
16 int
17 pop_parse(POP *p, char *buf)
19 char * mp;
20 int i;
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? */
29 if (*mp == 0) break;
31 /* Have we already obtained the maximum allowable parameters? */
32 if (i >= MAXPARMCOUNT) {
33 pop_msg(p,POP_FAILURE,"Too many arguments supplied.");
34 return(-1);
37 /* Point to the start of the token */
38 p->pop_parm[i] = mp;
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 */
44 if (*mp) *mp++ = 0;
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 */
54 return (i-1);