Revision 1.2 |
Revision 1.4 |
/* ====================================================================
|
/*
|
|
* buff.c
*
* The CoW I/O buffering library. This code started started out as
* a modified version of Apache's buff.c buffering library and has
* evolved from there. Chunks of this library are still Apache code.
*
*
* ====================================================================
|
* The Apache Software License, Version 1.1 * * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
|
* The Apache Software License, Version 1.1 * * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
|
Line 131 |
Line 139 |
int rv = pth_read_ev(fb->fd_in, buf, nbyte, timeout); if (pth_event_status(timeout) == PTH_STATUS_OCCURRED) { errno = EINTR;
|
int rv = pth_read_ev(fb->fd_in, buf, nbyte, timeout); if (pth_event_status(timeout) == PTH_STATUS_OCCURRED) { errno = EINTR;
|
printf("DEBUG: READ TIMED OUT\n");
|
|
return -1; } else { return rv;
|
return -1; } else { return rv;
|
Line 458 |
Line 465 |
if (nrd > 0) { eol = strchr(in->inptr, '\n'); if (eol != NULL) {
|
if (nrd > 0) { eol = strchr(in->inptr, '\n'); if (eol != NULL) {
|
int len = (eol - (char*)in->inptr) - 1;
|
int len = (eol - (char*)in->inptr);
|
memcpy(buf, in->inptr, len); in->incnt = nrd - (len+1); in->inptr += (len+1);
|
memcpy(buf, in->inptr, len); in->incnt = nrd - (len+1); in->inptr += (len+1);
|
Line 481 |
Line 488 |
if (nrd > 0) { memcpy(buf, in->inptr, nrd); buf = nrd + (char *) buf;
|
if (nrd > 0) { memcpy(buf, in->inptr, nrd); buf = nrd + (char *) buf;
|
in->incnt = 0;
}
|
}
in->incnt = 0;
|
|
in->inptr = in->inbase;
in->inptr[0] = '\0';
|
if (in->flags & B_EOF) return nrd;
|
if (in->flags & B_EOF) return nrd;
|
Line 491 |
Line 500 |
* than one line in, copy the excess back into the hold buffer. */ i = read_with_errors(in, buf, nbyte, timeout);
|
* than one line in, copy the excess back into the hold buffer. */ i = read_with_errors(in, buf, nbyte, timeout);
|
if (i < 0)
return i;
|
if (i <= 0 || errno == EINTR)
return -1;
|
eol = strchr(buf, '\n'); if (eol != NULL) { int len; /* Copy excess into hold buffer */ if (eol != buf + i - 1) {
|
eol = strchr(buf, '\n'); if (eol != NULL) { int len; /* Copy excess into hold buffer */ if (eol != buf + i - 1) {
|
in->incnt = i - (eol - buf);
|
in->incnt = i - (eol - buf) - 1;
|
memcpy(in->inbase, eol+1, in->incnt); in->inptr = in->inbase; } else {
|
memcpy(in->inbase, eol+1, in->incnt); in->inptr = in->inbase; } else {
|
Line 1207 |
Line 1216 |
}
|
}
|