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
24 /* This is used with pa.h */
34 pa_buf_t *pa_init( fd )
40 h = (pa_buf_t *) malloc( sizeof( pa_buf_t ));
41 h->buf = (char *) malloc( PA_BUFBLK * 2 );
42 h->bufsz = PA_BUFBLK * 2;
44 if (( rc = read( fd, h->buf, PA_BUFBLK )) < 0 ) {
49 h->end = h->buf + rc - 1;
71 if ( h->state == PA_NORMAL ) {
72 *(h->buf) = *(h->cur);
75 bcopy( h->mark, h->buf, h->end - h->mark + 1 );
76 h->cur = h->buf + ( h->cur - h->mark );
77 h->end = h->buf + ( h->end - h->mark );
81 if ( h->bufsz - (( h->cur - h->buf ) + 1 ) < PA_BUFBLK ) {
83 h->buf = (char *) realloc( h->buf, h->bufsz + PA_BUFBLK );
84 h->bufsz += PA_BUFBLK;
85 h->mark = h->buf + ( h->mark - t );
86 h->cur = h->buf + ( h->cur - t );
87 h->end = h->buf + ( h->end - t );
90 if (( rc = read( h->fd, h->cur + 1, PA_BUFBLK )) <= 0 ) {
95 return( *(++(h->cur)) );