~ubuntu-branches/ubuntu/natty/apache2/natty

« back to all changes in this revision

Viewing changes to support/htcacheclean.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-11-06 00:29:03 UTC
  • mfrom: (14.3.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091106002903-a7zl7sh2z1z3uxqb
Tags: 2.2.14-1ubuntu1
* Merge from debian testing, remaining changes:
  - debian/{control, rules}: Enable PIE hardening.
  - debian/{control, rules, pache2.2-common.ufw.profile}: Add ufw profiles.
  - debian/conrol: Add bzr tag and point it to our tree.
  - Dropped debian/patches/203_fix_legacy_ap_rputs_segfaults.dpatch: 
    Already applied upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
697
697
 * usage info
698
698
 */
699
699
#define NL APR_EOL_STR
700
 
static void usage(void)
 
700
static void usage(const char *error)
701
701
{
702
 
    apr_file_printf(errfile,
 
702
    if (error) {
 
703
        apr_file_printf(errfile, "%s error: %s\n", shortname, error);
 
704
    }
 
705
        apr_file_printf(errfile,
703
706
    "%s -- program for cleaning the disk cache."                             NL
704
707
    "Usage: %s [-Dvtrn] -pPATH -lLIMIT"                                      NL
705
708
    "       %s [-nti] -dINTERVAL -pPATH -lLIMIT"                             NL
758
761
    char opt;
759
762
    const char *arg;
760
763
    char *proxypath, *path;
 
764
    char errmsg[1024];
761
765
 
762
766
    interrupted = 0;
763
767
    repeat = 0;
798
802
            break;
799
803
        }
800
804
        else if (status != APR_SUCCESS) {
801
 
            usage();
 
805
            usage(NULL);
802
806
        }
803
807
        else {
804
808
            switch (opt) {
805
809
            case 'i':
806
810
                if (intelligent) {
807
 
                    usage();
 
811
                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
808
812
                }
809
813
                intelligent = 1;
810
814
                break;
811
815
 
812
816
            case 'D':
813
817
                if (dryrun) {
814
 
                    usage();
 
818
                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
815
819
                }
816
820
                dryrun = 1;
817
821
                break;
818
822
 
819
823
            case 'n':
820
824
                if (benice) {
821
 
                    usage();
 
825
                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
822
826
                }
823
827
                benice = 1;
824
828
                break;
825
829
 
826
830
            case 't':
827
831
                if (deldirs) {
828
 
                    usage();
 
832
                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
829
833
                }
830
834
                deldirs = 1;
831
835
                break;
832
836
 
833
837
            case 'v':
834
838
                if (verbose) {
835
 
                    usage();
 
839
                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
836
840
                }
837
841
                verbose = 1;
838
842
                break;
839
843
 
840
844
            case 'r':
841
845
                if (realclean) {
842
 
                    usage();
 
846
                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
843
847
                }
844
848
                realclean = 1;
845
849
                deldirs = 1;
847
851
 
848
852
            case 'd':
849
853
                if (isdaemon) {
850
 
                    usage();
 
854
                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
851
855
                }
852
856
                isdaemon = 1;
853
857
                repeat = apr_atoi64(arg);
857
861
 
858
862
            case 'l':
859
863
                if (limit_found) {
860
 
                    usage();
 
864
                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
861
865
                }
862
866
                limit_found = 1;
863
867
 
882
886
                        }
883
887
                    }
884
888
                    if (rv != APR_SUCCESS) {
885
 
                        apr_file_printf(errfile, "Invalid limit: %s"
886
 
                                                 APR_EOL_STR APR_EOL_STR, arg);
887
 
                        usage();
 
889
                        usage(apr_psprintf(pool, "Invalid limit: %s"
 
890
                                                 APR_EOL_STR APR_EOL_STR, arg));
888
891
                    }
889
892
                } while(0);
890
893
                break;
891
894
 
892
895
            case 'p':
893
896
                if (proxypath) {
894
 
                    usage();
 
897
                    usage(apr_psprintf(pool, "The option '%c' cannot be specified more than once", (int)opt));
895
898
                }
896
899
                proxypath = apr_pstrdup(pool, arg);
897
 
                if (apr_filepath_set(proxypath, pool) != APR_SUCCESS) {
898
 
                    usage();
 
900
                if ((status = apr_filepath_set(proxypath, pool)) != APR_SUCCESS) {
 
901
                    usage(apr_psprintf(pool, "Could not set filepath to '%s': %s",
 
902
                                       proxypath, apr_strerror(status, errmsg, sizeof errmsg)));
899
903
                }
900
904
                break;
901
905
            } /* switch */
902
906
        } /* else */
903
907
    } /* while */
904
908
 
 
909
    if (argc <= 1) {
 
910
        usage(NULL);
 
911
    }
 
912
 
905
913
    if (o->ind != argc) {
906
 
         usage();
907
 
    }
908
 
 
909
 
    if (isdaemon && (repeat <= 0 || verbose || realclean || dryrun)) {
910
 
         usage();
 
914
         usage("Additional parameters specified on the command line, aborting");
 
915
    }
 
916
 
 
917
    if (isdaemon && repeat <= 0) {
 
918
         usage("Option -d must be greater than zero");
 
919
    }
 
920
 
 
921
    if (isdaemon && (verbose || realclean || dryrun)) {
 
922
         usage("Option -d cannot be used with -v, -r or -D");
911
923
    }
912
924
 
913
925
    if (!isdaemon && intelligent) {
914
 
         usage();
915
 
    }
916
 
 
917
 
    if (!proxypath || max <= 0) {
918
 
         usage();
 
926
         usage("Option -i cannot be used without -d");
 
927
    }
 
928
 
 
929
    if (!proxypath) {
 
930
         usage("Option -p must be specified");
 
931
    }
 
932
 
 
933
    if (max <= 0) {
 
934
         usage("Option -l must be greater than zero");
919
935
    }
920
936
 
921
937
    if (apr_filepath_get(&path, 0, pool) != APR_SUCCESS) {
922
 
        usage();
 
938
        usage(apr_psprintf(pool, "Could not get the filepath: %s",
 
939
                           apr_strerror(status, errmsg, sizeof errmsg)));
923
940
    }
924
941
    baselen = strlen(path);
925
942