remove gcc34
[dragonfly.git] / crypto / heimdal-0.6.3 / appl / popper / pop_parse.c
blob37aef369a98f9fdd8a95bcf511aff0f1bce8abe3
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("$Id: pop_parse.c,v 1.9 1999/03/13 21:17:27 assar Exp $");
10 /*
11 * parse: Parse a raw input line from a POP client
12 * into null-delimited tokens
15 int
16 pop_parse(POP *p, char *buf)
18 char * mp;
19 int i;
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? */
28 if (*mp == 0) break;
30 /* Have we already obtained the maximum allowable parameters? */
31 if (i >= MAXPARMCOUNT) {
32 pop_msg(p,POP_FAILURE,"Too many arguments supplied.");
33 return(-1);
36 /* Point to the start of the token */
37 p->pop_parm[i] = mp;
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 */
43 if (*mp) *mp++ = 0;
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 */
53 return (i-1);