remove gcc34
[dragonfly.git] / crypto / heimdal-0.6.3 / appl / popper / pop_parse.c
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  */
6
7 #include <popper.h>
8 RCSID("$Id: pop_parse.c,v 1.9 1999/03/13 21:17:27 assar Exp $");
9
10 /* 
11  *  parse:  Parse a raw input line from a POP client 
12  *  into null-delimited tokens
13  */
14
15 int
16 pop_parse(POP *p, char *buf)
17 {
18     char            *   mp;
19     int        i;
20     
21     /*  Loop through the POP command array */
22     for (mp = buf, i = 0; ; i++) {
23     
24         /*  Skip leading spaces and tabs in the message */
25         while (isspace((unsigned char)*mp))mp++;
26
27         /*  Are we at the end of the message? */
28         if (*mp == 0) break;
29
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);
34         }
35
36         /*  Point to the start of the token */
37         p->pop_parm[i] = mp;
38
39         /*  Search for the first space character (end of the token) */
40         while (!isspace((unsigned char)*mp) && *mp) mp++;
41
42         /*  Delimit the token with a null */
43         if (*mp) *mp++ = 0;
44     }
45
46     /*  Were any parameters passed at all? */
47     if (i == 0) return (-1);
48
49     /*  Convert the first token (POP command) to lower case */
50     strlwr(p->pop_command);
51
52     /*  Return the number of tokens extracted minus the command itself */
53     return (i-1);
54     
55 }