Lines Matching refs:opts
56 static void dologname(struct fn *fnp, struct opts *clopts);
57 static boolean_t rotatelog(struct fn *fnp, struct opts *opts);
58 static void rotateto(struct fn *fnp, struct opts *opts, int n,
61 static void expirefiles(struct fn *fnp, struct opts *opts);
62 static void dorm(struct opts *opts, const char *msg, struct fn *fnp);
63 static void docmd(struct opts *opts, const char *msg, const char *cmd,
65 static void docopytruncate(struct opts *opts, const char *file,
161 struct opts *clopts; /* from parsing command line */ in main()
410 struct opts *opts = (struct opts *)arg; in doaftercmd() local
424 docmd(opts, "-a cmd", Sh, "-c", lhs, NULL); in doaftercmd()
432 struct opts *opts = (struct opts *)arg; in do_delayed_gzip() local
441 docmd(opts, "compress old log (-z flag)", Gzip, "-f", lhs, NULL); in do_delayed_gzip()
447 dologname(struct fn *fnp, struct opts *clopts) in dologname()
450 struct opts *cfopts; in dologname()
451 struct opts *allopts; in dologname()
573 rotatelog(struct fn *fnp, struct opts *opts) in rotatelog() argument
589 if (opts_count(opts, "p") && opts_optarg_int(opts, "p") == OPTP_NEVER) in rotatelog()
600 if (opts_count(opts, "N")) in rotatelog()
617 if (opts_count(opts, "s") && in rotatelog()
618 stbuf.st_size < opts_optarg_int(opts, "s")) { in rotatelog()
624 if (opts_count(opts, "p")) { in rotatelog()
625 off_t when = opts_optarg_int(opts, "p"); in rotatelog()
626 struct opts *cfopts; in rotatelog()
662 if (opts_count(opts, "P")) { in rotatelog()
663 off_t last = opts_optarg_int(opts, "P"); in rotatelog()
688 if (opts_count(opts, "l")) { in rotatelog()
696 rotateto(fnp, opts, 0, recentlog, B_FALSE); in rotatelog()
705 rotateto(fnp, opts, 0, recentlog, B_FALSE); in rotatelog()
709 if (opts_count(opts, "o")) in rotatelog()
710 (void) strlcpy(ownerbuf, opts_optarg(opts, "o"), MAXATTR); in rotatelog()
715 if (opts_count(opts, "g")) in rotatelog()
716 group = opts_optarg(opts, "g"); in rotatelog()
723 if (opts_count(opts, "m")) in rotatelog()
724 mode = opts_optarg(opts, "m"); in rotatelog()
732 docmd(opts, NULL, Touch, fname, NULL, NULL); in rotatelog()
733 docmd(opts, NULL, Chown, owner, fname, NULL); in rotatelog()
734 docmd(opts, NULL, Chmod, mode, fname, NULL); in rotatelog()
737 if (opts_count(opts, "R")) { in rotatelog()
738 struct fn *rawcmd = fn_new(opts_optarg(opts, "R")); in rotatelog()
743 docmd(opts, "-R cmd", Sh, "-c", fn_s(cmd), NULL); in rotatelog()
758 if (opts_count(opts, "a")) { in rotatelog()
759 const char *cmd = opts_optarg(opts, "a"); in rotatelog()
761 if (opts_count(opts, "e")) in rotatelog()
762 addrs = lut_add(addrs, opts_optarg(opts, "e"), NULL); in rotatelog()
763 Aftercmds = lut_add(Aftercmds, opts_optarg(opts, "a"), addrs); in rotatelog()
769 if (opts_count(opts, "v") && fname != NULL) in rotatelog()
779 rotateto(struct fn *fnp, struct opts *opts, int n, struct fn *recentlog, in rotateto() argument
782 struct fn *template = fn_new(opts_optarg(opts, "t")); in rotateto()
803 rotateto(newfile, opts, n + 1, recentlog, isgz); in rotateto()
804 else if (hasn && opts_count(opts, "z")) { in rotateto()
812 rotateto(gzfnp, opts, n + 1, recentlog, B_TRUE); in rotateto()
817 if (n == 0 && opts_count(opts, "b")) { in rotateto()
818 const char *cmd = opts_optarg(opts, "b"); in rotateto()
821 docmd(opts, "-b cmd", Sh, "-c", cmd, NULL); in rotateto()
828 docmd(opts, "verify directory exists", Mkdir, "-p", in rotateto()
833 if (n == 0 && opts_count(opts, "c") != NULL) { in rotateto()
834 docopytruncate(opts, fn_s(fnp), fn_s(newfile)); in rotateto()
835 } else if (n == 0 && opts_count(opts, "M")) { in rotateto()
836 struct fn *rawcmd = fn_new(opts_optarg(opts, "M")); in rotateto()
842 docmd(opts, "-M cmd", Sh, "-c", fn_s(cmd), NULL); in rotateto()
847 docmd(opts, "rotate log file", Mv, "-f", in rotateto()
857 expirefiles(struct fn *fnp, struct opts *opts) in expirefiles() argument
871 if (opts_count(opts, "zAS") == 0 && opts_optarg_int(opts, "C") == 0) in expirefiles()
881 if (opts_count(opts, "T")) { in expirefiles()
882 template = fn_new(opts_optarg(opts, "T")); in expirefiles()
886 template = fn_new(opts_optarg(opts, "t")); in expirefiles()
889 opts_count(opts, "z") != 0); in expirefiles()
911 if ((count = opts_optarg_int(opts, "C")) > 0) { in expirefiles()
920 dorm(opts, "expire by count rule", nextfnp); in expirefiles()
927 if (opts_count(opts, "S") && (size = opts_optarg_int(opts, "S")) > 0) { in expirefiles()
930 dorm(opts, "expire by size rule", nextfnp); in expirefiles()
936 if (opts_count(opts, "A")) { in expirefiles()
937 int mtime = (int)time(0) - (int)opts_optarg_int(opts, "A"); in expirefiles()
941 dorm(opts, "expire by age rule", nextfnp); in expirefiles()
951 if (opts_count(opts, "z")) { in expirefiles()
952 int zcount = (int)opts_optarg_int(opts, "z"); in expirefiles()
982 dorm(struct opts *opts, const char *msg, struct fn *fnp) in dorm() argument
984 if (opts_count(opts, "E")) { in dorm()
985 struct fn *rawcmd = fn_new(opts_optarg(opts, "E")); in dorm()
991 docmd(opts, msg, Sh, "-c", fn_s(cmd), NULL); in dorm()
995 docmd(opts, msg, Rm, "-f", fn_s(fnp), NULL); in dorm()
1001 docmd(struct opts *opts, const char *msg, const char *cmd, in docmd() argument
1008 if (opts_count(opts, "vn")) { in docmd()
1027 if (opts_count(opts, "n")) in docmd()
1103 docopytruncate(struct opts *opts, const char *file, const char *file_copy) in docopytruncate() argument
1113 if (opts_count(opts, "vn") != NULL) { in docopytruncate()
1120 if (opts_count(opts, "n")) in docopytruncate()