Lines Matching defs:ent

272 static void free_entry(struct conf_entry *ent);
281 static void createdir(const struct conf_entry *ent, char *dirpart);
282 static void createlog(const struct conf_entry *ent);
435 free_entry(struct conf_entry *ent)
438 if (ent == NULL)
441 if (ent->log != NULL) {
443 printf("\t--> [freeing entry for %s]\n", ent->log);
444 free(ent->log);
445 ent->log = NULL;
448 if (ent->pid_cmd_file != NULL) {
449 free(ent->pid_cmd_file);
450 ent->pid_cmd_file = NULL;
453 if (ent->r_reason != NULL) {
454 free(ent->r_reason);
455 ent->r_reason = NULL;
458 if (ent->trim_at != NULL) {
459 ptime_free(ent->trim_at);
460 ent->trim_at = NULL;
463 free(ent);
469 struct conf_entry *ent;
472 ent = STAILQ_FIRST(list);
474 free_entry(ent);
482 do_entry(struct conf_entry * ent)
493 printf("%s <%d%s>: ", ent->log, ent->numlogs,
494 compress_type[ent->compress].flag);
495 ent->fsize = sizefile(ent->log);
496 oversized = ((ent->trsize > 0) && (ent->fsize >= ent->trsize));
497 modtime = age_old_log(ent->log);
498 ent->rotate = 0;
499 ent->firstcreate = 0;
500 if (ent->fsize < 0) {
509 ent->firstcreate = 1;
510 else if ((ent->flags & CE_CREATE) && createlogs)
511 ent->firstcreate = 1;
512 else if (ent->flags & CE_CREATE)
517 if (ent->firstcreate) {
520 createlog(ent);
525 if (ent->flags & CE_TRIMAT && !force && !rotatereq &&
527 diffsecs = ptimeget_diff(timenow, ent->trim_at);
531 ptime_adjust4dst(ent->trim_at,
534 ptimeget_ctime(ent->trim_at));
545 ptimeget_ctime(ent->trim_at));
547 ptimeset_nxtime(ent->trim_at);
549 ptimeget_ctime(ent->trim_at));
560 ptimeget_ctime(ent->trim_at));
562 } else if (verbose && ent->hours <= 0) {
566 if (verbose && (ent->trsize > 0))
567 printf("size (Kb): %d [%d] ", ent->fsize, ent->trsize);
568 if (verbose && (ent->hours > 0))
569 printf(" age (hr): %d [%d] ", modtime, ent->hours);
576 ent->rotate = 1;
580 ent->rotate = 1;
583 ent->rotate = 1;
585 ent->trsize);
586 } else if (ent->hours <= 0 && (ent->flags & CE_TRIMAT)) {
587 ent->rotate = 1;
588 } else if ((ent->hours > 0) && ((modtime >= ent->hours) ||
590 ent->rotate = 1;
596 if (ent->rotate && !norotate) {
598 ent->r_reason = strdup(temp_reason);
602 printf("%s <%d%s>: trimming\n", ent->log,
603 ent->numlogs,
604 compress_type[ent->compress].flag);
605 free_or_keep = do_rotate(ent);
800 struct conf_entry *defconf, *dupent, *ent;
893 STAILQ_FOREACH(ent, filelist, cf_nextp) {
894 if (strcmp(ent->log, *given) == 0) {
896 dupent = init_entry(*given, ent);
913 STAILQ_FOREACH(ent, globlist, cf_nextp) {
914 fnres = fnmatch(ent->log, *given, FNM_PATHNAME);
917 ent->log);
920 dupent = init_entry(*given, ent);
931 ent->log);
970 struct conf_entry *dupent, *ent, *globent;
997 STAILQ_FOREACH(ent, work_p, cf_nextp) {
998 if (strcmp(mfname, ent->log) == 0) {
1525 delete_oldest_timelog(const struct conf_entry *ent, const char *archive_dir)
1542 if ((cdir = dirname(ent->log)) == NULL)
1547 if ((s = basename(ent->log)) == NULL)
1593 if (logcnt > 0 && logcnt >= ent->numlogs && ent->numlogs > 1) {
1606 for (i = ent->numlogs - 1; i < logcnt; i++) {
1618 printf("No old logs to delete for logfile %s\n", ent->log);
1719 do_rotate(const struct conf_entry *ent)
1733 flags = ent->flags;
1744 strlcpy(dirpart, ent->log, sizeof(dirpart));
1754 createdir(ent, dirpart);
1757 if ((p = strrchr(ent->log, '/')) == NULL)
1758 strlcpy(namepart, ent->log, sizeof(namepart));
1767 strlcpy(namepart, ent->log, sizeof(namepart));
1772 delete_oldest_timelog(ent, dirpart);
1776 * kept ent->numlogs + 1 files. This code can go away
1779 delete_classiclog(dirpart, namepart, ent->numlogs);
1781 if (ent->numlogs > 0)
1782 delete_classiclog(dirpart, namepart, ent->numlogs - 1);
1798 ent->log, datetimestr);
1804 ent->numlogs - 1);
1805 numlogs_c = ent->numlogs - 2; /* copy for countdown */
1829 change_attrs(zfile2, ent);
1832 if (ent->numlogs > 0) {
1841 printf("\tcp %s %s\n", ent->log, file1);
1843 printf("\tln %s %s\n", ent->log, file1);
1850 log_trim(ent->log, ent);
1852 savelog(ent->log, file1);
1860 change_attrs(file1, ent);
1866 createlog(ent);
1875 if (ent->pid_cmd_file != NULL)
1876 swork = save_sigwork(ent);
1877 if (ent->numlogs > 0 && ent->compress > COMPRESS_NONE) {
1883 save_zipwork(ent, swork, ent->fsize, file1);
2082 save_sigwork(const struct conf_entry *ent)
2091 ndiff = strcmp(ent->pid_cmd_file, stmp->sw_fname);
2095 if (ent->sig == stmp->sw_signum)
2097 if (ent->sig > stmp->sw_signum) {
2107 tmpsiz = sizeof(struct sigwork_entry) + strlen(ent->pid_cmd_file) + 1;
2112 if (ent->flags & CE_PID2CMD) {
2117 set_swpid(stmp, ent);
2119 stmp->sw_signum = ent->sig;
2120 strcpy(stmp->sw_fname, ent->pid_cmd_file);
2137 save_zipwork(const struct conf_entry *ent, const struct sigwork_entry *swork,
2162 ztmp->zw_conf = ent;
2175 set_swpid(struct sigwork_entry *swork, const struct conf_entry *ent)
2186 if (ent->flags & CE_SIGNALGROUP) {
2197 f = fopen(ent->pid_cmd_file, "r");
2208 warnx("pid file doesn't exist: %s", ent->pid_cmd_file);
2210 warn("can't open pid file: %s", ent->pid_cmd_file);
2223 warnx("pid/cmd file is empty: %s", ent->pid_cmd_file);
2225 warn("can't read from pid file: %s", ent->pid_cmd_file);
2238 ent->pid_cmd_file);
2241 rval, ent->pid_cmd_file);
2474 createdir(const struct conf_entry *ent, char *dirpart)
2504 if (ent->firstcreate)
2506 dirpart, ent->log);
2519 createlog(const struct conf_entry *ent)
2526 realfile = ent->log;
2533 if (ent->firstcreate) {
2542 createdir(ent, tempfile);
2567 if (!(ent->flags & CE_BINARY)) {
2568 if (log_trim(tempfile, ent))
2574 if (ent->uid != (uid_t)-1 || ent->gid != (gid_t)-1) {
2576 printf("\tchown %u:%u %s\n", ent->uid, ent->gid,
2579 failed = fchown(fd, ent->uid, ent->gid);
2586 if (ent->flags & CE_NODUMP) {
2608 printf("\tchmod %o %s\n", ent->permissions, tempfile);
2611 failed = fchmod(fd, ent->permissions);
2630 change_attrs(const char *fname, const struct conf_entry *ent)
2635 printf("\tchmod %o %s\n", ent->permissions, fname);
2637 if (ent->uid != (uid_t)-1 || ent->gid != (gid_t)-1)
2639 ent->uid, ent->gid, fname);
2641 if (ent->flags & CE_NODUMP)
2646 failed = chmod(fname, ent->permissions);
2653 if (ent->uid != (uid_t)-1 || ent->gid != (gid_t)-1) {
2654 failed = chown(fname, ent->uid, ent->gid);
2659 if (ent->flags & CE_NODUMP) {