Lines Matching refs:f

238 #define   REPEATTIME(f)       ((f)->f_time + repeatinterval[(f)->f_repeatcount])  argument
239 #define BACKOFF(f) { if (++(f)->f_repeatcount > MAXREPEAT) \ argument
240 (f)->f_repeatcount = MAXREPEAT; \
897 struct filed *f; in logmsg() local
964 f = &consfile; in logmsg()
969 f->f_file = open(ctty, O_WRONLY | O_NONBLOCK, 0); in logmsg()
971 if (f->f_file >= 0) { in logmsg()
972 (void)strlcpy(f->f_lasttime, timestamp, in logmsg()
973 sizeof(f->f_lasttime)); in logmsg()
974 fprintlog(f, flags, msg); in logmsg()
975 (void)close(f->f_file); in logmsg()
980 for (f = Files; f; f = f->f_next) { in logmsg()
982 if (!(((f->f_pcmp[fac] & PRI_EQ) && (f->f_pmask[fac] == prilev)) in logmsg()
983 ||((f->f_pcmp[fac] & PRI_LT) && (f->f_pmask[fac] < prilev)) in logmsg()
984 ||((f->f_pcmp[fac] & PRI_GT) && (f->f_pmask[fac] > prilev)) in logmsg()
986 || f->f_pmask[fac] == INTERNAL_NOPRI) in logmsg()
990 if (skip_message(from, f->f_host, 0)) in logmsg()
994 if (skip_message(prog, f->f_program, 1)) in logmsg()
998 if (f->f_type == F_CONSOLE && (flags & IGN_CONS)) in logmsg()
1002 if ((flags & MARK) && (now - f->f_time) < MarkInterval / 2) in logmsg()
1008 if (no_compress - (f->f_type != F_PIPE) < 1 && in logmsg()
1009 (flags & MARK) == 0 && msglen == f->f_prevlen && in logmsg()
1010 f->f_prevline && !strcmp(msg, f->f_prevline) && in logmsg()
1011 !strcasecmp(from, f->f_prevhost)) { in logmsg()
1012 (void)strlcpy(f->f_lasttime, timestamp, in logmsg()
1013 sizeof(f->f_lasttime)); in logmsg()
1014 f->f_prevcount++; in logmsg()
1016 f->f_prevcount, (long)(now - f->f_time), in logmsg()
1017 repeatinterval[f->f_repeatcount]); in logmsg()
1024 if (now > REPEATTIME(f)) { in logmsg()
1025 fprintlog(f, flags, NULL); in logmsg()
1026 BACKOFF(f); in logmsg()
1030 if (f->f_prevcount) in logmsg()
1031 fprintlog(f, 0, NULL); in logmsg()
1032 f->f_repeatcount = 0; in logmsg()
1033 f->f_prevpri = pri; in logmsg()
1034 (void)strlcpy(f->f_lasttime, timestamp, in logmsg()
1035 sizeof(f->f_lasttime)); in logmsg()
1036 (void)strlcpy(f->f_prevhost, from, in logmsg()
1037 sizeof(f->f_prevhost)); in logmsg()
1039 f->f_prevlen = msglen; in logmsg()
1040 (void)strlcpy(f->f_prevline, msg, sizeof(f->f_prevline)); in logmsg()
1041 fprintlog(f, flags, NULL); in logmsg()
1043 f->f_prevline[0] = 0; in logmsg()
1044 f->f_prevlen = 0; in logmsg()
1045 fprintlog(f, flags, msg); in logmsg()
1055 struct filed *f; in dofsync() local
1057 for (f = Files; f; f = f->f_next) { in dofsync()
1058 if ((f->f_type == F_FILE) && in dofsync()
1059 (f->f_flags & FFLAG_NEEDSYNC)) { in dofsync()
1060 f->f_flags &= ~FFLAG_NEEDSYNC; in dofsync()
1061 (void)fsync(f->f_file); in dofsync()
1068 fprintlog(struct filed *f, int flags, const char *msg) in fprintlog() argument
1079 if (f->f_type == F_WALL) { in fprintlog()
1088 f->f_prevhost, f->f_lasttime); in fprintlog()
1096 v->iov_base = f->f_lasttime; in fprintlog()
1097 v->iov_len = strlen(f->f_lasttime); in fprintlog()
1106 int fac = f->f_prevpri & LOG_FACMASK; in fprintlog()
1107 int pri = LOG_PRI(f->f_prevpri); in fprintlog()
1146 v->iov_base = f->f_prevhost; in fprintlog()
1161 } else if (f->f_prevcount > 1) { in fprintlog()
1164 "last message repeated %d times", f->f_prevcount); in fprintlog()
1165 } else if (f->f_prevline) { in fprintlog()
1166 v->iov_base = f->f_prevline; in fprintlog()
1167 v->iov_len = f->f_prevlen; in fprintlog()
1173 dprintf("Logging to %s", TypeNames[f->f_type]); in fprintlog()
1174 f->f_time = now; in fprintlog()
1176 switch (f->f_type) { in fprintlog()
1184 (f->f_un.f_forw.f_addr->ai_addr))->sin_port); in fprintlog()
1186 dprintf(" %s:%d\n", f->f_un.f_forw.f_hname, port); in fprintlog()
1188 dprintf(" %s\n", f->f_un.f_forw.f_hname); in fprintlog()
1191 if (strcasecmp(f->f_prevhost, LocalHostName)) in fprintlog()
1194 f->f_prevpri, (char *)iov[0].iov_base, in fprintlog()
1195 f->f_prevhost, (char *)iov[5].iov_base); in fprintlog()
1198 f->f_prevpri, (char *)iov[0].iov_base, in fprintlog()
1206 for (r = f->f_un.f_forw.f_addr; r; r = r->ai_next) { in fprintlog()
1247 f->f_type = F_UNUSED; in fprintlog()
1255 dprintf(" %s\n", f->f_un.f_fname); in fprintlog()
1258 if (writev(f->f_file, iov, IOV_SIZE) < 0) { in fprintlog()
1266 (void)close(f->f_file); in fprintlog()
1267 f->f_type = F_UNUSED; in fprintlog()
1269 logerror(f->f_un.f_fname); in fprintlog()
1271 } else if ((flags & SYNC_FILE) && (f->f_flags & FFLAG_SYNC)) { in fprintlog()
1272 f->f_flags |= FFLAG_NEEDSYNC; in fprintlog()
1278 dprintf(" %s\n", f->f_un.f_pipe.f_pname); in fprintlog()
1281 if (f->f_un.f_pipe.f_pid == 0) { in fprintlog()
1282 if ((f->f_file = p_open(f->f_un.f_pipe.f_pname, in fprintlog()
1283 &f->f_un.f_pipe.f_pid)) < 0) { in fprintlog()
1284 f->f_type = F_UNUSED; in fprintlog()
1285 logerror(f->f_un.f_pipe.f_pname); in fprintlog()
1289 if (writev(f->f_file, iov, IOV_SIZE) < 0) { in fprintlog()
1291 (void)close(f->f_file); in fprintlog()
1292 if (f->f_un.f_pipe.f_pid > 0) in fprintlog()
1293 deadq_enter(f->f_un.f_pipe.f_pid, in fprintlog()
1294 f->f_un.f_pipe.f_pname); in fprintlog()
1295 f->f_un.f_pipe.f_pid = 0; in fprintlog()
1297 logerror(f->f_un.f_pipe.f_pname); in fprintlog()
1309 dprintf(" %s%s\n", _PATH_DEV, f->f_un.f_fname); in fprintlog()
1314 if ((msgret = ttymsg(iov, IOV_SIZE, f->f_un.f_fname, 10))) { in fprintlog()
1315 f->f_type = F_UNUSED; in fprintlog()
1325 wallmsg(f, iov, IOV_SIZE); in fprintlog()
1328 f->f_prevcount = 0; in fprintlog()
1339 wallmsg(struct filed *f, struct iovec *iov, const int iovlen) in wallmsg() argument
1353 if (f->f_type == F_WALL) { in wallmsg()
1363 if (!f->f_un.f_uname[i][0]) in wallmsg()
1365 if (!strcmp(f->f_un.f_uname[i], ut->ut_user)) { in wallmsg()
1384 struct filed *f; in reapchild() local
1396 for (f = Files; f; f = f->f_next) { in reapchild()
1397 if (f->f_type == F_PIPE && in reapchild()
1398 f->f_un.f_pipe.f_pid == pid) { in reapchild()
1399 (void)close(f->f_file); in reapchild()
1400 f->f_un.f_pipe.f_pid = 0; in reapchild()
1402 f->f_un.f_pipe.f_pname); in reapchild()
1413 cvthname(struct sockaddr *f) in cvthname() argument
1419 error = getnameinfo((struct sockaddr *)f, in cvthname()
1420 ((struct sockaddr *)f)->sa_len, in cvthname()
1434 error = getnameinfo((struct sockaddr *)f, in cvthname()
1435 ((struct sockaddr *)f)->sa_len, in cvthname()
1490 struct filed *f; in die() local
1497 for (f = Files; f != NULL; f = f->f_next) { in die()
1499 if (f->f_prevcount) in die()
1500 fprintlog(f, 0, NULL); in die()
1501 if (f->f_type == F_PIPE && f->f_un.f_pipe.f_pid > 0) { in die()
1502 (void)close(f->f_file); in die()
1503 f->f_un.f_pipe.f_pid = 0; in die()
1528 struct filed *f, *next, **nextp; in init() local
1558 for (f = Files; f != NULL; f = next) { in init()
1560 if (f->f_prevcount) in init()
1561 fprintlog(f, 0, NULL); in init()
1563 switch (f->f_type) { in init()
1568 (void)close(f->f_file); in init()
1571 if (f->f_un.f_pipe.f_pid > 0) { in init()
1572 (void)close(f->f_file); in init()
1573 deadq_enter(f->f_un.f_pipe.f_pid, in init()
1574 f->f_un.f_pipe.f_pname); in init()
1576 f->f_un.f_pipe.f_pid = 0; in init()
1579 next = f->f_next; in init()
1580 if (f->f_program) free(f->f_program); in init()
1581 if (f->f_host) free(f->f_host); in init()
1582 free((char *)f); in init()
1590 *nextp = (struct filed *)calloc(1, sizeof(*f)); in init()
1596 (*nextp)->f_next = (struct filed *)calloc(1, sizeof(*f)); in init()
1609 f = NULL; in init()
1674 f = (struct filed *)calloc(1, sizeof(*f)); in init()
1675 if (f == NULL) { in init()
1679 *nextp = f; in init()
1680 nextp = &f->f_next; in init()
1681 cfline(cline, f, prog, host); in init()
1691 for (f = Files; f; f = f->f_next) { in init()
1693 if (f->f_pmask[i] == INTERNAL_NOPRI) in init()
1696 printf("%d ", f->f_pmask[i]); in init()
1697 printf("%s: ", TypeNames[f->f_type]); in init()
1698 switch (f->f_type) { in init()
1700 printf("%s", f->f_un.f_fname); in init()
1705 printf("%s%s", _PATH_DEV, f->f_un.f_fname); in init()
1710 (f->f_un.f_forw.f_addr->ai_addr))->sin_port); in init()
1713 f->f_un.f_forw.f_hname, port); in init()
1715 printf("%s", f->f_un.f_forw.f_hname); in init()
1720 printf("%s", f->f_un.f_pipe.f_pname); in init()
1724 for (i = 0; i < MAXUNAMES && *f->f_un.f_uname[i]; i++) in init()
1725 printf("%s, ", f->f_un.f_uname[i]); in init()
1728 if (f->f_program) in init()
1729 printf(" (%s)", f->f_program); in init()
1762 cfline(const char *line, struct filed *f, const char *prog, const char *host) in cfline() argument
1775 memset(f, 0, sizeof(*f)); in cfline()
1777 f->f_pmask[i] = INTERNAL_NOPRI; in cfline()
1785 f->f_host = strdup(host); in cfline()
1786 if (f->f_host == NULL) { in cfline()
1790 hl = strlen(f->f_host); in cfline()
1791 if (hl > 0 && f->f_host[hl-1] == '.') in cfline()
1792 f->f_host[--hl] = '\0'; in cfline()
1793 trimdomain(f->f_host, hl); in cfline()
1800 f->f_program = strdup(prog); in cfline()
1801 if (f->f_program == NULL) { in cfline()
1888 f->f_pmask[i] = pri; in cfline()
1889 f->f_pcmp[i] = pri_cmp; in cfline()
1901 f->f_pmask[i >> 3] = pri; in cfline()
1902 f->f_pcmp[i >> 3] = pri_cmp; in cfline()
1930 i = sizeof(f->f_un.f_forw.f_hname); in cfline()
1931 tp = f->f_un.f_forw.f_hname; in cfline()
1958 error = getaddrinfo(f->f_un.f_forw.f_hname, in cfline()
1964 f->f_un.f_forw.f_addr = res; in cfline()
1965 f->f_type = F_FORW; in cfline()
1969 if ((f->f_file = open(p, logflags, 0600)) < 0) { in cfline()
1970 f->f_type = F_UNUSED; in cfline()
1975 f->f_flags |= FFLAG_SYNC; in cfline()
1976 if (isatty(f->f_file)) { in cfline()
1978 f->f_type = F_CONSOLE; in cfline()
1980 f->f_type = F_TTY; in cfline()
1981 (void)strlcpy(f->f_un.f_fname, p + sizeof(_PATH_DEV) - 1, in cfline()
1982 sizeof(f->f_un.f_fname)); in cfline()
1984 (void)strlcpy(f->f_un.f_fname, p, sizeof(f->f_un.f_fname)); in cfline()
1985 f->f_type = F_FILE; in cfline()
1990 f->f_un.f_pipe.f_pid = 0; in cfline()
1991 (void)strlcpy(f->f_un.f_pipe.f_pname, p + 1, in cfline()
1992 sizeof(f->f_un.f_pipe.f_pname)); in cfline()
1993 f->f_type = F_PIPE; in cfline()
1997 f->f_type = F_WALL; in cfline()
2004 (void)strncpy(f->f_un.f_uname[i], p, MAXLOGNAME - 1); in cfline()
2006 f->f_un.f_uname[i][MAXLOGNAME - 1] = '\0'; in cfline()
2008 f->f_un.f_uname[i][q - p] = '\0'; in cfline()
2013 f->f_type = F_USERS; in cfline()
2048 struct filed *f; in markit() local
2059 for (f = Files; f; f = f->f_next) { in markit()
2060 if (f->f_prevcount && now >= REPEATTIME(f)) { in markit()
2062 TypeNames[f->f_type], f->f_prevcount, in markit()
2063 repeatinterval[f->f_repeatcount]); in markit()
2064 fprintlog(f, 0, NULL); in markit()
2065 BACKOFF(f); in markit()