]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r814091, r814779, r81544, r816701 from trunk:
authorEric Covener <covener@apache.org>
Sat, 19 Sep 2009 12:28:58 +0000 (12:28 +0000)
committerEric Covener <covener@apache.org>
Sat, 19 Sep 2009 12:28:58 +0000 (12:28 +0000)
htcacheclean: 19 ways to fail, 1 error message. Fixed.
  Move declaration to remove a compiler warning.
  Detab.

Submitted by: minfrin, trawick
Reviewed by: minfrin, poirier, covener

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@816906 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
support/htcacheclean.c

diff --git a/CHANGES b/CHANGES
index e6c48eae882da517dfd2c1169f9348669eb1e9d1..b178f02fe1abff061a7da7d49ee71d69e6131bf8 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,8 @@ Changes with Apache 2.2.14
      mod_proxy_ftp: NULL pointer dereference on error paths.
      [Stefan Fritsch <sf fritsch.de>, Joe Orton]
 
+  *) htcacheclean: 19 ways to fail, 1 error message. Fixed. [Graham Leggett]
+
   *) mod_ldap: Bring the LDAPCacheEntries and LDAPOpCacheEntries
      usage() in synch with the manual and the implementation (0 and -1
      both disable the cache). [Eric Covener]
diff --git a/STATUS b/STATUS
index bcad22dc09b120e90ebeb2a0f6242075536c5a8f..e2c23a1c4ca93255898d8c4dcf8d15884e3b0567 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -89,13 +89,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
- * htcacheclean: 19 ways to fail, 1 error message. Fixed.
-   Trunk Patch: http://svn.apache.org/viewvc?view=rev&revision=814091
-                http://svn.apache.org/viewvc?view=rev&revision=814779
-                http://svn.apache.org/viewvc?rev=815448&view=rev
-                http://svn.apache.org/viewvc?view=rev&revision=816701
-   +1: minfrin, poirier, covener
-
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
 
index 36a80051f09d403c3b5926d3db87c1296837e6bf..e826639a1183b3727c1a3fabc9b0e57a6e046ba2 100644 (file)
@@ -697,9 +697,12 @@ static void purge(char *path, apr_pool_t *pool, apr_off_t max)
  * usage info
  */
 #define NL APR_EOL_STR
-static void usage(void)
+static void usage(const char *error)
 {
-    apr_file_printf(errfile,
+    if (error) {
+       apr_file_printf(errfile, "%s error: %s\n", shortname, error);
+    }
+       apr_file_printf(errfile,
     "%s -- program for cleaning the disk cache."                             NL
     "Usage: %s [-Dvtrn] -pPATH -lLIMIT"                                      NL
     "       %s [-nti] -dINTERVAL -pPATH -lLIMIT"                             NL
@@ -758,6 +761,7 @@ int main(int argc, const char * const argv[])
     char opt;
     const char *arg;
     char *proxypath, *path;
+    char errmsg[1024];
 
     interrupted = 0;
     repeat = 0;
@@ -798,48 +802,48 @@ int main(int argc, const char * const argv[])
             break;
         }
         else if (status != APR_SUCCESS) {
-            usage();
+            usage(NULL);
         }
         else {
             switch (opt) {
             case 'i':
                 if (intelligent) {
-                    usage();
+                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
                 }
                 intelligent = 1;
                 break;
 
             case 'D':
                 if (dryrun) {
-                    usage();
+                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
                 }
                 dryrun = 1;
                 break;
 
             case 'n':
                 if (benice) {
-                    usage();
+                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
                 }
                 benice = 1;
                 break;
 
             case 't':
                 if (deldirs) {
-                    usage();
+                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
                 }
                 deldirs = 1;
                 break;
 
             case 'v':
                 if (verbose) {
-                    usage();
+                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
                 }
                 verbose = 1;
                 break;
 
             case 'r':
                 if (realclean) {
-                    usage();
+                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
                 }
                 realclean = 1;
                 deldirs = 1;
@@ -847,7 +851,7 @@ int main(int argc, const char * const argv[])
 
             case 'd':
                 if (isdaemon) {
-                    usage();
+                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
                 }
                 isdaemon = 1;
                 repeat = apr_atoi64(arg);
@@ -857,7 +861,7 @@ int main(int argc, const char * const argv[])
 
             case 'l':
                 if (limit_found) {
-                    usage();
+                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
                 }
                 limit_found = 1;
 
@@ -882,44 +886,57 @@ int main(int argc, const char * const argv[])
                         }
                     }
                     if (rv != APR_SUCCESS) {
-                        apr_file_printf(errfile, "Invalid limit: %s"
-                                                 APR_EOL_STR APR_EOL_STR, arg);
-                        usage();
+                        usage(apr_psprintf(pool, "Invalid limit: %s"
+                                                 APR_EOL_STR APR_EOL_STR, arg));
                     }
                 } while(0);
                 break;
 
             case 'p':
                 if (proxypath) {
-                    usage();
+                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
                 }
                 proxypath = apr_pstrdup(pool, arg);
-                if (apr_filepath_set(proxypath, pool) != APR_SUCCESS) {
-                    usage();
+                if ((status = apr_filepath_set(proxypath, pool)) != APR_SUCCESS) {
+                    usage(apr_psprintf(pool, "Could not set filepath to '%s': %s",
+                                       proxypath, apr_strerror(status, errmsg, sizeof errmsg)));
                 }
                 break;
             } /* switch */
         } /* else */
     } /* while */
 
+    if (argc <= 1) {
+        usage(NULL);
+    }
+
     if (o->ind != argc) {
-         usage();
+         usage("Additional parameters specified on the command line, aborting");
     }
 
-    if (isdaemon && (repeat <= 0 || verbose || realclean || dryrun)) {
-         usage();
+    if (isdaemon && repeat <= 0) {
+         usage("Option -d must be greater than zero");
+    }
+
+    if (isdaemon && (verbose || realclean || dryrun)) {
+         usage("Option -d cannot be used with -v, -r or -D");
     }
 
     if (!isdaemon && intelligent) {
-         usage();
+         usage("Option -i cannot be used without -d");
+    }
+
+    if (!proxypath) {
+         usage("Option -p must be specified");
     }
 
-    if (!proxypath || max <= 0) {
-         usage();
+    if (max <= 0) {
+         usage("Option -l must be greater than zero");
     }
 
     if (apr_filepath_get(&path, 0, pool) != APR_SUCCESS) {
-        usage();
+        usage(apr_psprintf(pool, "Could not get the filepath: %s",
+                           apr_strerror(status, errmsg, sizeof errmsg)));
     }
     baselen = strlen(path);