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 */
30 pa_buf_t *pa_init( fd )
36 h = (pa_buf_t *) malloc( sizeof( pa_buf_t ));
37 h->buf = (char *) malloc( PA_BUFBLK * 2 );
38 h->bufsz = PA_BUFBLK * 2;
40 if (( rc = read( fd, h->buf, PA_BUFBLK )) < 0 ) {
45 h->end = h->buf + rc - 1;
67 if ( h->state == PA_NORMAL ) {
68 *(h->buf) = *(h->cur);
71 bcopy( h->mark, h->buf, h->end - h->mark + 1 );
72 h->cur = h->buf + ( h->cur - h->mark );
73 h->end = h->buf + ( h->end - h->mark );
77 if ( h->bufsz - (( h->cur - h->buf ) + 1 ) < PA_BUFBLK ) {
79 h->buf = (char *) realloc( h->buf, h->bufsz + PA_BUFBLK );
80 h->bufsz += PA_BUFBLK;
81 h->mark = h->buf + ( h->mark - t );
82 h->cur = h->buf + ( h->cur - t );
83 h->end = h->buf + ( h->end - t );
86 if (( rc = read( h->fd, h->cur + 1, PA_BUFBLK )) <= 0 ) {
91 return( *(++(h->cur)) );