2 * $Id: pa.c,v 1.4 2001-06-29 14:14:46 rufustfirefly 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
26 /* This is used with pa.h */
30 #endif /* HAVE_CONFIG_H */
36 #endif /* HAVE_UNISTD_H */
40 pa_buf_t *pa_init( fd )
46 h = (pa_buf_t *) malloc( sizeof( pa_buf_t ));
47 h->buf = (char *) malloc( PA_BUFBLK * 2 );
48 h->bufsz = PA_BUFBLK * 2;
50 if (( rc = read( fd, h->buf, PA_BUFBLK )) < 0 ) {
55 h->end = h->buf + rc - 1;
77 if ( h->state == PA_NORMAL ) {
78 *(h->buf) = *(h->cur);
81 bcopy( h->mark, h->buf, h->end - h->mark + 1 );
82 h->cur = h->buf + ( h->cur - h->mark );
83 h->end = h->buf + ( h->end - h->mark );
87 if ( h->bufsz - (( h->cur - h->buf ) + 1 ) < PA_BUFBLK ) {
89 h->buf = (char *) realloc( h->buf, h->bufsz + PA_BUFBLK );
90 h->bufsz += PA_BUFBLK;
91 h->mark = h->buf + ( h->mark - t );
92 h->cur = h->buf + ( h->cur - t );
93 h->end = h->buf + ( h->end - t );
96 if (( rc = read( h->fd, h->cur + 1, PA_BUFBLK )) <= 0 ) {
100 h->end = h->cur + rc;
101 return( *(++(h->cur)) );