summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authordgaudet <dgaudet@unknown>1998-03-28 11:58:35 +0000
committerdgaudet <dgaudet@unknown>1998-03-28 11:58:35 +0000
commit474c582c288ad22a3b0ea0d51811b6a89ec52a1b (patch)
tree4df3812a03c6d05d7c33d05262acb645472d01f2 /src/include
parenteaa70a4c0e7952c58f0f9579eaa78d23960fc4f7 (diff)
downloadhttpd-474c582c288ad22a3b0ea0d51811b6a89ec52a1b.tar.gz
Finally dealt with the vformatter() thing that's been sitting in STATUS
since october. - apapi_vformatter() is generic printf-style routine with arbitrary output - replaces ap_snprintf(), eliminate the possibility of HAVE_SNPRINTF - replaces bprintf() and bvprintf() - add new psprintf()/pvsprintf() which allocate the string from the pool -- no static limitations - use psprintf() in a bunch of places git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@80715 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/include')
-rw-r--r--src/include/alloc.h3
-rw-r--r--src/include/ap.h23
-rw-r--r--src/include/ap_alloc.h3
-rw-r--r--src/include/ap_config.h14
-rw-r--r--src/include/buff.h2
-rw-r--r--src/include/conf.h14
6 files changed, 30 insertions, 29 deletions
diff --git a/src/include/alloc.h b/src/include/alloc.h
index 385fe3392e..ffe5011165 100644
--- a/src/include/alloc.h
+++ b/src/include/alloc.h
@@ -117,6 +117,9 @@ API_EXPORT(char *) pstrdup(struct pool *, const char *s);
/* make a nul terminated copy of the n characters starting with s */
API_EXPORT(char *) pstrndup(struct pool *, const char *s, int n);
API_EXPORT(char *) pstrcat(struct pool *,...); /* all '...' must be char* */
+API_EXPORT_NONSTD(char *) psprintf(struct pool *, const char *fmt, ...)
+ __attribute__((format(printf,2,3)));
+API_EXPORT(char *) pvsprintf(struct pool *, const char *fmt, va_list);
/* array and alist management... keeping lists of things.
* Common enough to want common support code ...
diff --git a/src/include/ap.h b/src/include/ap.h
index 4ec8e49ae7..ca05dcddfa 100644
--- a/src/include/ap.h
+++ b/src/include/ap.h
@@ -77,4 +77,27 @@ int ap_execve(const char *, const char *argv[], const char *envp[]);
#endif
#endif /* WIN32 */
+/* apapi_vformatter() is a generic printf-style formatting routine
+ * with some extensions.
+ *
+ * The write_func() is called when there is data available to be
+ * output. write_func() should return 0 when it wishes apapi_vformatter
+ * to continue, and non-zero otherwise. apapi_vformatter will stop
+ * immediately and return -1 when a non-zero return from
+ * write_func().
+ *
+ * If write_func() always returns 0 then apapi_vformatter will return
+ * the number of characters written.
+ */
+
+API_EXPORT(int) apapi_vformatter(
+ int (*write_func)(void *write_data, const char *outp, size_t len),
+ void *write_data, const char *fmt, va_list ap);
+
+/* These are snprintf implementations based on apapi_vformatter(). */
+API_EXPORT(int) ap_snprintf(char *buf, size_t len, const char *format,...)
+ __attribute__((format(printf,3,4)));
+API_EXPORT(int) ap_vsnprintf(char *buf, size_t len, const char *format,
+ va_list ap);
+
#endif /* !APACHE_AP_H */
diff --git a/src/include/ap_alloc.h b/src/include/ap_alloc.h
index 385fe3392e..ffe5011165 100644
--- a/src/include/ap_alloc.h
+++ b/src/include/ap_alloc.h
@@ -117,6 +117,9 @@ API_EXPORT(char *) pstrdup(struct pool *, const char *s);
/* make a nul terminated copy of the n characters starting with s */
API_EXPORT(char *) pstrndup(struct pool *, const char *s, int n);
API_EXPORT(char *) pstrcat(struct pool *,...); /* all '...' must be char* */
+API_EXPORT_NONSTD(char *) psprintf(struct pool *, const char *fmt, ...)
+ __attribute__((format(printf,2,3)));
+API_EXPORT(char *) pvsprintf(struct pool *, const char *fmt, va_list);
/* array and alist management... keeping lists of things.
* Common enough to want common support code ...
diff --git a/src/include/ap_config.h b/src/include/ap_config.h
index 4b1f66527e..8127520111 100644
--- a/src/include/ap_config.h
+++ b/src/include/ap_config.h
@@ -806,20 +806,6 @@ typedef int rlim_t;
#include <sys/types.h>
#include <stdarg.h>
-/*
- * We use snprintf() to avoid overflows, but we include
- * our own version (ap_snprintf). Allow for people to use their
- * snprintf() if they want
- */
-#ifdef HAVE_SNPRINTF
-#define ap_snprintf snprintf
-#define ap_vsnprintf vsnprintf
-#else
-API_EXPORT(int) ap_snprintf(char *buf, size_t len, const char *format,...)
- __attribute__((format(printf,3,4)));
-API_EXPORT(int) ap_vsnprintf(char *buf, size_t len, const char *format,
- va_list ap);
-#endif
#if !defined(NEXT) && !defined(WIN32)
#include <dirent.h>
diff --git a/src/include/buff.h b/src/include/buff.h
index c0e54df7a8..38f0dfe91a 100644
--- a/src/include/buff.h
+++ b/src/include/buff.h
@@ -156,7 +156,7 @@ API_EXPORT(int) bputs(const char *x, BUFF *fb);
API_EXPORT(int) bvputs(BUFF *fb,...);
API_EXPORT_NONSTD(int) bprintf(BUFF *fb, const char *fmt,...)
__attribute__((format(printf,2,3)));
-API_EXPORT_NONSTD(int) vbprintf(BUFF *fb, const char *fmt, va_list vlist);
+API_EXPORT(int) vbprintf(BUFF *fb, const char *fmt, va_list vlist);
/* Internal routines */
API_EXPORT(int) bflsbuf(int c, BUFF *fb);
diff --git a/src/include/conf.h b/src/include/conf.h
index 4b1f66527e..8127520111 100644
--- a/src/include/conf.h
+++ b/src/include/conf.h
@@ -806,20 +806,6 @@ typedef int rlim_t;
#include <sys/types.h>
#include <stdarg.h>
-/*
- * We use snprintf() to avoid overflows, but we include
- * our own version (ap_snprintf). Allow for people to use their
- * snprintf() if they want
- */
-#ifdef HAVE_SNPRINTF
-#define ap_snprintf snprintf
-#define ap_vsnprintf vsnprintf
-#else
-API_EXPORT(int) ap_snprintf(char *buf, size_t len, const char *format,...)
- __attribute__((format(printf,3,4)));
-API_EXPORT(int) ap_vsnprintf(char *buf, size_t len, const char *format,
- va_list ap);
-#endif
#if !defined(NEXT) && !defined(WIN32)
#include <dirent.h>