You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by gs...@locus.apache.org on 2000/06/17 03:29:30 UTC
cvs commit: apache-2.0/src/main buff.c http_protocol.c
gstein 00/06/16 18:29:29
Modified: src/include buff.h
src/main buff.c http_protocol.c
Log:
ap_bvputs() is a misnomer; introduce ap_bputstrs()
[todo: proxy and file_cache code should be updated for new name]
add ap_vbputstrs()
use ap_vbputstrs() from http_protocol.
use EOF in a few places, rather than the magic "-1" constant
Revision Changes Path
1.29 +5 -1 apache-2.0/src/include/buff.h
Index: buff.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/include/buff.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- buff.h 2000/06/13 13:41:17 1.28
+++ buff.h 2000/06/17 01:29:29 1.29
@@ -272,10 +272,14 @@
API_EXPORT(ap_status_t) ap_bflush(BUFF *fb);
API_EXPORT(ap_status_t) ap_bshutdown(BUFF *fb, int how);
API_EXPORT(int) ap_bputs(const char *x, BUFF *fb);
-API_EXPORT(int) ap_bvputs(BUFF *fb,...);
API_EXPORT_NONSTD(int) ap_bprintf(BUFF *fb, const char *fmt,...)
__attribute__((format(printf,2,3)));
API_EXPORT(int) ap_vbprintf(BUFF *fb, const char *fmt, va_list vlist);
+
+/* ### ap_bvputs is a misnomer, since it doesn't take a va_list */
+#define ap_bvputs ap_bputstrs
+API_EXPORT_NONSTD(int) ap_bputstrs(BUFF *fb, ...);
+API_EXPORT(int) ap_vbputstrs(BUFF *fb, va_list va);
/* Internal routines */
API_EXPORT(int) ap_bflsbuf(int c, BUFF *fb);
1.54 +16 -7 apache-2.0/src/main/buff.c
Index: buff.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/buff.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- buff.c 2000/06/16 14:29:19 1.53
+++ buff.c 2000/06/17 01:29:29 1.54
@@ -1242,32 +1242,41 @@
/*
* returns the number of bytes written or -1 on error
*/
-API_EXPORT_NONSTD(int) ap_bvputs(BUFF *fb,...)
+API_EXPORT(int) ap_vbputstrs(BUFF *fb, va_list va)
{
int j, k;
ap_ssize_t i;
- va_list v;
const char *x;
int rv;
- va_start(v, fb);
for (k = 0;;) {
- x = va_arg(v, const char *);
+ x = va_arg(va, const char *);
if (x == NULL)
break;
j = strlen(x);
rv = ap_bwrite(fb, x, j, &i);
if (i != j) {
- va_end(v);
fb->berrno = rv;
return -1;
}
k += i;
}
- va_end(v);
-
return k;
+}
+
+/*
+ * returns the number of bytes written or -1 on error
+ */
+API_EXPORT_NONSTD(int) ap_bputstrs(BUFF *fb, ...)
+{
+ va_list va;
+ int n;
+
+ va_start(va, fb);
+ n = ap_vbputstrs(fb, va);
+ va_end(va);
+ return n;
}
API_EXPORT(void) ap_bonerror(BUFF *fb,
1.80 +17 -27 apache-2.0/src/main/http_protocol.c
Index: http_protocol.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/http_protocol.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- http_protocol.c 2000/06/12 23:02:49 1.79
+++ http_protocol.c 2000/06/17 01:29:29 1.80
@@ -2460,7 +2460,7 @@
int n;
if (r->connection->aborted)
- return -1;
+ return EOF;
n = ap_vbprintf(r->connection->client, fmt, ap);
@@ -2472,7 +2472,7 @@
ap_bsetflag(r->connection->client, B_EOUT, 1);
r->connection->aborted = 1;
}
- return -1;
+ return EOF;
}
SET_BYTES_SENT(r);
return n;
@@ -2484,7 +2484,7 @@
int n;
if (r->connection->aborted)
- return -1;
+ return EOF;
va_start(vlist, fmt);
n = ap_vbprintf(r->connection->client, fmt, vlist);
@@ -2498,7 +2498,7 @@
ap_bsetflag(r->connection->client, B_EOUT, 1);
r->connection->aborted = 1;
}
- return -1;
+ return EOF;
}
SET_BYTES_SENT(r);
return n;
@@ -2507,38 +2507,28 @@
API_EXPORT_NONSTD(int) ap_rvputs(request_rec *r,...)
{
va_list args;
- ap_ssize_t i;
- int j, k;
- const char *x;
- BUFF *fb = r->connection->client;
- ap_status_t rv;
+ int n;
if (r->connection->aborted)
return EOF;
va_start(args, r);
- for (k = 0;;) {
- x = va_arg(args, const char *);
- if (x == NULL)
- break;
- j = strlen(x);
- rv = ap_bwrite(fb, x, j, &i);
- if (i != j) {
- va_end(args);
- if (!r->connection->aborted) {
- ap_log_rerror(APLOG_MARK, APLOG_INFO, rv, r,
- "client stopped connection before rvputs completed");
- ap_bsetflag(r->connection->client, B_EOUT, 1);
- r->connection->aborted = 1;
- }
- return EOF;
+ n = ap_vbputstrs(r->connection->client, args);
+ va_end(args);
+
+ if (n < 0) {
+ if (!r->connection->aborted) {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO,
+ ap_berror(r->connection->client), r,
+ "client stopped connection before rvputs completed");
+ ap_bsetflag(r->connection->client, B_EOUT, 1);
+ r->connection->aborted = 1;
}
- k += i;
+ return EOF;
}
- va_end(args);
SET_BYTES_SENT(r);
- return k;
+ return n;
}
API_EXPORT(int) ap_rflush(request_rec *r)