2 ashd - A Sane HTTP Daemon
3 Copyright (C) 2008 Fredrik Tolf <fredrik@dolda2000.com>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 static void logloop(int fd)
35 while(fgets(buf, sizeof(buf), in) != NULL) {
37 if(buf[len - 1] == '\n')
39 syslog(prio, "%s", buf);
44 static void usage(FILE *out)
46 fprintf(out, "usage: errlogger [-h] [-n NAME] [-f FACILITY] [-p PRIO] PROGRAM [ARGS...]\n");
49 int main(int argc, char **argv)
60 while((c = getopt(argc, argv, "hn:p:f:")) >= 0) {
66 if(!strcmp(optarg, "auth")) {
68 } else if(!strcmp(optarg, "authpriv")) {
70 } else if(!strcmp(optarg, "cron")) {
72 } else if(!strcmp(optarg, "daemon")) {
74 } else if(!strcmp(optarg, "ftp")) {
76 } else if(!strcmp(optarg, "kern")) {
78 } else if(!strcmp(optarg, "lpr")) {
80 } else if(!strcmp(optarg, "mail")) {
82 } else if(!strcmp(optarg, "news")) {
84 } else if(!strcmp(optarg, "user")) {
86 } else if(!strcmp(optarg, "uucp")) {
88 } else if(!strncmp(optarg, "local", 5) && (optarg[5] >= '0') && (optarg[5] <= '7') && !optarg[6]) {
89 fac = LOG_LOCAL0 + (optarg[5] - '0');
91 fprintf(stderr, "errlogger: unknown facility %s\n", optarg);
96 if(!strcmp(optarg, "emerg")) {
98 } else if(!strcmp(optarg, "alert")) {
100 } else if(!strcmp(optarg, "crit")) {
102 } else if(!strcmp(optarg, "err")) {
104 } else if(!strcmp(optarg, "warning")) {
106 } else if(!strcmp(optarg, "notice")) {
108 } else if(!strcmp(optarg, "info")) {
110 } else if(!strcmp(optarg, "debug")) {
113 fprintf(stderr, "errlogger: unknown priorty %s\n", optarg);
125 if(argc - optind < 1) {
131 openlog(name, 0, fac);
133 if((ch = fork()) == 0) {
139 execvp(argv[optind], argv + optind);
140 fprintf(stderr, "errlogger: %s: %s", argv[optind], strerror(errno));