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