ap_file_t *f;
int i;
struct stat finfo;
+ ap_ssize_t n; /* Ignored */
if (!conf->logname ||
((stat(ap_server_root_relative(r->pool, conf->logname), &finfo) == 0)
(ap_open(&f, ap_server_root_relative(r->pool, conf->logname),
APR_APPEND, APR_OS_DEFAULT, r->pool) != APR_SUCCESS)) {
/* Soak up script output */
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0)
+ while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in, &n)
+ == APR_SUCCESS)
continue;
#ifdef WIN32
/* Soak up stderr and redirect it to the error log.
* Script output to stderr is already directed to the error log
* on Unix, thanks to the magic of fork().
*/
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
+ while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, &n)
+ == APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, r,
"%s", argsbuffer);
}
#else
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0)
+ while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, &n)
+ == APR_SUCCESS)
continue;
#endif
return ret;
if (sbuf && *sbuf)
ap_fprintf(f, "%s\n", sbuf);
- if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0) {
+ if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in, &n) == APR_SUCCESS) {
ap_puts("%stdout\n", f);
ap_puts(argsbuffer, f);
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0)
+ while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in, &n) > 0)
ap_puts(argsbuffer, f);
ap_puts("\n", f);
}
- if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
+ if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, &n) == APR_SUCCESS) {
ap_puts("%stderr\n", f);
ap_puts(argsbuffer, f);
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0)
+ while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, &n)
+ == APR_SUCCESS)
ap_puts(argsbuffer, f);
ap_puts("\n", f);
}
char *argv0, *dbuf = NULL;
char *command;
char **argv = NULL;
+ ap_ssize_t n; /* Ignored */
BUFF *script_out = NULL, *script_in = NULL, *script_err = NULL;
char argsbuffer[HUGE_STRING_LEN];
if (location && location[0] == '/' && r->status == 200) {
/* Soak up all the script output */
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0) {
+ while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in, &n)
+ == APR_SUCCESS) {
continue;
}
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
+ while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, &n)
+ == APR_SUCCESS) {
continue;
}
/* This redirect needs to be a GET no matter what the original
}
ap_bclose(script_in);
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
+ while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, &n)
+ == APR_SUCCESS) {
continue;
}
ap_bclose(script_err);
static int getline(char *s, int n, BUFF *in, int fold)
{
char *pos, next;
- int retval;
+ ap_status_t retval;
+ ap_ssize_t nbytes;
int total = 0;
pos = s;
do {
- retval = ap_bgets(pos, n, in);
- /* retval == -1 if error, 0 if EOF */
+ retval = ap_bgets(pos, n, in, &nbytes);
+ /* retval == APR_EOF if EOF, normal error codes otherwise */
- if (retval <= 0)
- return ((retval < 0) && (total == 0)) ? -1 : total;
+ if (retval != APR_SUCCESS) /* error or eof */
+ return ((retval != APR_EOF) && (total == 0)) ? -1 : total;
- /* retval is the number of characters read, not including NUL */
+ /* nbytes is the number of characters read, not including NUL */
- n -= retval; /* Keep track of how much of s is full */
- pos += (retval - 1); /* and where s ends */
- total += retval; /* and how long s has become */
+ n -= nbytes; /* Keep track of how much of s is full */
+ pos += (nbytes - 1); /* and where s ends */
+ total += nbytes; /* and how long s has become */
if (*pos == '\n') { /* Did we get a full line of input? */
/*
* the last line was not empty and we have room in the buffer and
* the next line begins with a continuation character.
*/
- } while (fold && (retval != 1) && (n > 1)
+ } while (fold && (nbytes != 1) && (n > 1)
&& (next = ap_blookc(in))
&& ((next == ' ') || (next == '\t')));