]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Change over to apr_strfsize() for apr_off_t file size formatting.
authorWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 25 Jul 2001 21:34:15 +0000 (21:34 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 25 Jul 2001 21:34:15 +0000 (21:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89713 13f79535-47bb-0310-9956-ffa450edef68

include/util_script.h
modules/filters/mod_include.c
modules/generators/mod_autoindex.c
modules/test/mod_autoindex.c
server/util_script.c

index 4e436bf0b1b53118d2e749665a1a8bd1f142fe73..1cf8796b6ad20e57b5a1ecc6bc1243ccdd613e24 100644 (file)
@@ -160,17 +160,6 @@ AP_DECLARE(int) ap_scan_script_header_err_core(request_rec *r, char *buffer,
                                       int (*getsfunc) (char *, int, void *),
                                       void *getsfunc_data);
 
-/**
- * Convert the file size given in size into a formatted string and send the
- * string to the client.  The size should always be in bytes, although the
- * string sent to the client may be in bytes, kb, or MB, depending on the size
- * of the file.
- * @param size The size of the file
- * @param r The currnt request
- * @deffunc void ap_send_size(apr_ssize_t size, request_rec *r)
- */
-AP_DECLARE(void) ap_send_size(apr_ssize_t size, request_rec *r);
-
 #ifdef __cplusplus
 }
 #endif
index b4540074b3503f5dcfd18af6fc250421e4487588..a375712ad23823ceeaf987c855a10d0b30e5c22b 100644 (file)
@@ -1079,33 +1079,6 @@ static int find_file(request_rec *r, const char *directive, const char *tag,
     }
 }
 
-#define NEG_SIGN  "    -"
-#define ZERO_K    "   0k"
-#define ONE_K     "   1k"
-
-static void generate_size(apr_ssize_t size, char *buff, apr_size_t buff_size)
-{
-    /* XXX: this -1 thing is a gross hack */
-    if (size == (apr_ssize_t)-1) {
-       memcpy (buff, NEG_SIGN, sizeof(NEG_SIGN)+1);
-    }
-    else if (!size) {
-       memcpy (buff, ZERO_K, sizeof(ZERO_K)+1);
-    }
-    else if (size < 1024) {
-       memcpy (buff, ONE_K, sizeof(ONE_K)+1);
-    }
-    else if (size < 1048576) {
-        apr_snprintf(buff, buff_size, "%4" APR_SSIZE_T_FMT "k", (size + 512) / 1024);
-    }
-    else if (size < 103809024) {
-        apr_snprintf(buff, buff_size, "%4.1fM", size / 1048576.0);
-    }
-    else {
-        apr_snprintf(buff, buff_size, "%4" APR_SSIZE_T_FMT "M", (size + 524288) / 1048576);
-    }
-}
-
 static int handle_fsize(include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec *r,
                         ap_filter_t *f, apr_bucket *head_ptr, apr_bucket **inserted_head)
 {
@@ -1134,7 +1107,7 @@ static int handle_fsize(include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec
                     char buff[50];
 
                     if (!(ctx->flags & FLAG_SIZE_IN_BYTES)) {
-                        generate_size(finfo.size, buff, sizeof(buff));
+                        apr_strfsize(finfo.size, buff);
                         s_len = strlen (buff);
                     }
                     else {
index 8906251ddcba49ac68dc8621cb1ee2d8084f93aa..90575c5d86a71ace0003e64d6837b89881b9844a 100644 (file)
@@ -1355,7 +1355,7 @@ static void output_directories(struct ent **ar, int n,
        if (!(autoindex_opts & SUPPRESS_LAST_MOD)) {
             emit_link(r, "Last modified", K_LAST_MOD, keyid, direction,
                       static_columns);
-           ap_rputs("       ", r);
+           ap_rputs("      ", r);
        }
        if (!(autoindex_opts & SUPPRESS_SIZE)) {
             emit_link(r, "Size", K_SIZE, keyid, direction, static_columns);
@@ -1445,7 +1445,8 @@ static void output_directories(struct ent **ar, int n,
                }
            }
            if (!(autoindex_opts & SUPPRESS_SIZE)) {
-               ap_send_size(ar[x]->size, r);
+                char buf[5];
+               ap_rputs(apr_strfsize(ar[x]->size, buf), r);
                ap_rputs("  ", r);
            }
            if (!(autoindex_opts & SUPPRESS_DESC)) {
index d875082a85dcb43c990c622168c27f954ec6f40e..f01365c04349237967a1888610d70f22583f0546 100644 (file)
@@ -1442,7 +1442,8 @@ static void output_directories(struct ent **ar, int n,
                }
            }
            if (!(autoindex_opts & SUPPRESS_SIZE)) {
-               ap_send_size(ar[x]->size, r);
+               char buf[5];
+               ap_rputs(apr_strfsize(ar[x]->size, buf), r);
                ap_rputs("  ", r);
            }
            if (!(autoindex_opts & SUPPRESS_DESC)) {
index f6d3e483f09711c38d88025c91c616a4c54e9154..c80fba1d83a575176e3b9aa4bb0040e561978016 100644 (file)
@@ -634,27 +634,3 @@ AP_DECLARE_NONSTD(int) ap_scan_script_header_err_strs(request_rec *r,
     va_end(strs.args);
     return res;
 }
-
-AP_DECLARE(void) ap_send_size(apr_ssize_t size, request_rec *r)
-{
-    /* XXX: this -1 thing is a gross hack */
-    if (size == (apr_ssize_t)-1) {
-       ap_rputs("    -", r);
-    }
-    else if (!size) {
-       ap_rputs("   0k", r);
-    }
-    else if (size < 1024) {
-       ap_rputs("   1k", r);
-    }
-    else if (size < 1048576) {
-       ap_rprintf(r, "%4" APR_SSIZE_T_FMT "k", (size + 512) / 1024);
-    }
-    else if (size < 103809024) {
-       ap_rprintf(r, "%4.1fM", size / 1048576.0);
-    }
-    else {
-       ap_rprintf(r, "%4" APR_SSIZE_T_FMT "M", (size + 524288) / 1048576);
-    }
-}
-