2 * Copyright (c) 1990,1991 Regents of The University of Michigan.
5 * Permission to use, copy, modify, and distribute this software and
6 * its documentation for any purpose and without fee is hereby granted,
7 * provided that the above copyright notice appears in all copies and
8 * that both that copyright notice and this permission notice appear
9 * in supporting documentation, and that the name of The University
10 * of Michigan not be used in advertising or publicity pertaining to
11 * distribution of the software without specific, written prior
12 * permission. This software is supplied as is without expressed or
13 * implied warranties of any kind.
15 * Research Systems Unix Group
16 * The University of Michigan
18 * 535 W. William Street
21 * netatalk@itd.umich.edu
25 * Functions to aid in parsing:
27 * pa_init( fd ) Allocate and return a handle. Reads
28 * from fd. Call this first, always.
29 * pa_getchar( h ) Return a single character or nul, 0,
30 * to indicate end-of-file.
31 * pa_match( h ) Mark the character last read as the start
33 * pa_gettok( h ) The match up to but excluding the last
34 * character is returned.
35 * pa_cont( h ) Continue match with previous match. Call
36 * immediately after pa_gettok() to get
38 * pa_cancel( h ) Cancel previous match start.
45 #define PA_BUFBLK 1024
50 typedef struct pa_buf_t {
61 extern pa_buf_t *pa_init();
62 extern char _pa_fixbuf();
63 extern char *pa_gettok();
65 #define pa_getchar(h) (((h)->cur==(h)->end)?(_pa_fixbuf(h)):\
67 #define pa_match(h) ((h)->state=PA_MATCHING,(h)->mark=(h)->cur)
68 #define pa_cont(h) (*((h)->cur)=(h)->tmp,(h)->state=PA_MATCHING)
69 #define pa_cancel(h) ((h)->state=PA_NORMAL)
70 #define pa_back(h) (--((h)->cur))