Lines Matching defs:opts

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