*/
void ap_xlate_proto_from_ascii(char *buffer, apr_size_t len);
+/**
+ * Convert protocol data from the implementation charater
+ * set to ASCII, then send it.
+ * @param r the current request
+ * @param ... the strings to write, followed by a NULL pointer
+ */
+int ap_rvputs_proto_in_ascii(request_rec *r, ...);
+
#ifdef __cplusplus
}
#endif
#define ap_xlate_proto_to_ascii(x,y) /* NOOP */
#define ap_xlate_proto_from_ascii(x,y) /* NOOP */
+#define ap_rvputs_proto_in_ascii ap_rvputs
+
#endif /* APR_CHARSET_EBCDIC */
#endif /* !APACHE_UTIL_EBCDIC_H */
/* folks decided they didn't want the error code in the H1 text */
h1 = &title[4];
- ap_rvputs(rlast,
+ /* can't count on a charset filter being in place here,
+ * so do ebcdic->ascii translation explicity (if needed)
+ */
+
+ ap_rvputs_proto_in_ascii(rlast,
DOCTYPE_HTML_2_0
"<HTML><HEAD>\n<TITLE>", title,
"</TITLE>\n</HEAD><BODY>\n<H1>", h1, "</H1>\n",
NULL);
- ap_rputs(get_canned_error_string(status, r, location),rlast);
+ ap_rvputs_proto_in_ascii(rlast,
+ get_canned_error_string(status, r, location),
+ NULL);
if (recursive_error) {
- ap_rvputs(rlast, "<P>Additionally, a ",
+ ap_rvputs_proto_in_ascii(rlast, "<P>Additionally, a ",
status_lines[ap_index_of_response(recursive_error)],
"\nerror was encountered while trying to use an "
"ErrorDocument to handle the request.\n", NULL);
}
- ap_rputs(ap_psignature("<HR>\n", r), rlast);
- ap_rputs("</BODY></HTML>\n", rlast);
+ ap_rvputs_proto_in_ascii(rlast, ap_psignature("<HR>\n", r), NULL);
+ ap_rvputs_proto_in_ascii(rlast, "</BODY></HTML>\n", NULL);
}
ap_finalize_request_protocol(r);
}
buffer, &outbytes_left);
}
+int ap_rvputs_proto_in_ascii(request_rec *r, ...)
+{
+ va_list va;
+ const char *s;
+ char *ascii_s;
+ apr_size_t len;
+ apr_size_t written = 0;
+
+ va_start(va, r);
+ while (1) {
+ s = va_arg(va, const char *);
+ if (s == NULL)
+ break;
+ len = strlen(s);
+ ascii_s = apr_pstrndup(r->pool, s, len);
+ ap_xlate_proto_to_ascii(ascii_s, len);
+ if (ap_rputs(ascii_s, r) < 0)
+ return -1;
+ written += len;
+ }
+ va_end(va);
+
+ return written;
+}
#endif /* APR_CHARSET_EBCDIC */