Binary size formatter as bytes, K, M, T, etc, for apr_vformatter based
upon apr_strfsize.
---
srclib/apr/include/apr_lib.h | 3 +++
srclib/apr/strings/apr_snprintf.c | 26 ++++++++++++++++++++++++++
2 files changed, 29 insertions(+)
Index: 2.2.x/srclib/apr/include/apr_lib.h
===================================================================
--- 2.2.x.orig/srclib/apr/include/apr_lib.h 2007-04-27 11:09:49.000000000
-0300
+++ 2.2.x/srclib/apr/include/apr_lib.h 2007-04-27 11:09:51.000000000 -0300
@@ -121,6 +121,9 @@
* %%pm takes an apr_status_t * and prints the appropriate error
* string (from apr_strerror) corresponding to that error code.
* %%pp takes a void * and outputs it in hex
+ * %%pB takes a apr_uint32_t * as bytes and outputs it's apr_strfsize
+ * %%pF same as above, but takes a apr_off_t *
+ * %%pS same as above, but takes a apr_size_t *
*
* %%pt is only available from APR 1.2.0 onwards.
* %%pm is only available from APR 1.3.0 onwards.
Index: 2.2.x/srclib/apr/strings/apr_snprintf.c
===================================================================
--- 2.2.x.orig/srclib/apr/strings/apr_snprintf.c 2007-04-27
11:09:50.000000000 -0300
+++ 2.2.x/srclib/apr/strings/apr_snprintf.c 2007-04-27 11:09:51.000000000
-0300
@@ -1220,6 +1220,32 @@
#endif
break;
+ case 'B':
+ case 'F':
+ case 'S':
+ {
+ char buf[5];
+ apr_off_t size = 0;
+
+ if (*fmt == 'B') {
+ apr_uint32_t *arg = va_arg(ap, apr_uint32_t *);
+ size = (arg) ? *arg : 0;
+ }
+ else if (*fmt == 'F') {
+ apr_off_t *arg = va_arg(ap, apr_off_t *);
+ size = (arg) ? *arg : 0;
+ }
+ else {
+ apr_size_t *arg = va_arg(ap, apr_size_t *);
+ size = (arg) ? *arg : 0;
+ }
+
+ s = apr_strfsize(size, buf);
+ s_len = strlen(s);
+ pad_char = ' ';
+ }
+ break;
+
case NUL:
/* if %p ends the string, oh well ignore it */
continue;
--