File: pa.h

package info (click to toggle)
netatalk 2.0.3-4%2Betch2
  • links: PTS
  • area: main
  • in suites: etch
  • size: 9,012 kB
  • ctags: 6,109
  • sloc: ansic: 67,633; sh: 8,424; perl: 1,187; makefile: 1,001
file content (77 lines) | stat: -rw-r--r-- 2,167 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * $Id: pa.h,v 1.2 2001/06/29 14:14:46 rufustfirefly Exp $
 *
 * Copyright (c) 1990,1991 Regents of The University of Michigan.
 * All Rights Reserved.
 *
 * Permission to use, copy, modify, and distribute this software and
 * its documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appears in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation, and that the name of The University
 * of Michigan not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior
 * permission. This software is supplied as is without expressed or
 * implied warranties of any kind.
 *
 *	Research Systems Unix Group
 *	The University of Michigan
 *	c/o Mike Clark
 *	535 W. William Street
 *	Ann Arbor, Michigan
 *	+1-313-763-0525
 *	netatalk@itd.umich.edu
 */

/*
 * Functions to aid in parsing:
 *
 *	pa_init( fd )		Allocate and return a handle. Reads
 *				from fd. Call this first, always.
 *	pa_getchar( h )		Return a single character or nul, 0,
 *				to indicate end-of-file.
 *	pa_match( h )		Mark the character last read as the start
 *				of a match.
 *	pa_gettok( h )		The match up to but excluding the last
 *				character is returned.
 *	pa_cont( h )		Continue match with previous match. Call
 *				immediately after pa_gettok() to get
 *				correct behavior.
 *	pa_cancel( h )		Cancel previous match start.
 */

#ifndef _PA_H
#define _PA_H 1

#ifndef FILE_H
#include <stdio.h>
#endif /* FILE_H */

#define PA_BUFBLK	1024

#define PA_NORMAL	0
#define PA_MATCHING	1

typedef struct pa_buf_t {
	char *buf;
	char *cur;
	char *mark;
	char *end;
	int fd;
	int state;
	unsigned bufsz;
	char tmp;
} pa_buf_t;

extern pa_buf_t *pa_init();
extern char _pa_fixbuf();
extern char *pa_gettok();

#define pa_getchar(h)	(((h)->cur==(h)->end)?(_pa_fixbuf(h)):\
			(*(++((h)->cur))))
#define pa_match(h)	((h)->state=PA_MATCHING,(h)->mark=(h)->cur)
#define pa_cont(h)	(*((h)->cur)=(h)->tmp,(h)->state=PA_MATCHING)
#define pa_cancel(h)	((h)->state=PA_NORMAL)
#define pa_back(h)	(--((h)->cur))

#endif /* _PA_H */