Dolda2000 GitWeb
/
ashd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
048ac11
)
accesslog: Changed command-line format.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 3 Oct 2010 05:58:23 +0000
(07:58 +0200)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 3 Oct 2010 05:58:23 +0000
(07:58 +0200)
src/accesslog.c
patch
|
blob
|
blame
|
history
diff --git
a/src/accesslog.c
b/src/accesslog.c
index
4961483
..
13e60ff
100644
(file)
--- a/
src/accesslog.c
+++ b/
src/accesslog.c
@@
-171,7
+171,7
@@
static void serve(struct hthead *req, int fd)
static void usage(FILE *out)
{
static void usage(FILE *out)
{
- fprintf(out, "usage: accesslog [-hFa] [-f FORMAT]
[-o OUTFILE]
CHILD [ARGS...]\n");
+ fprintf(out, "usage: accesslog [-hFa] [-f FORMAT]
OUTFILE
CHILD [ARGS...]\n");
}
int main(int argc, char **argv)
}
int main(int argc, char **argv)
@@
-180,17
+180,13
@@
int main(int argc, char **argv)
struct hthead *req;
int fd;
struct pollfd pfd[2];
struct hthead *req;
int fd;
struct pollfd pfd[2];
- char *outfile;
optarg = NULL;
optarg = NULL;
- while((c = getopt(argc, argv, "+hFaf:
o:
")) >= 0) {
+ while((c = getopt(argc, argv, "+hFaf:")) >= 0) {
switch(c) {
case 'h':
usage(stdout);
exit(0);
switch(c) {
case 'h':
usage(stdout);
exit(0);
- case 'o':
- outfile = optarg;
- break;
case 'F':
flush = 0;
break;
case 'F':
flush = 0;
break;
@@
-205,21
+201,21
@@
int main(int argc, char **argv)
exit(1);
}
}
exit(1);
}
}
- if(
optind >= argc
) {
+ if(
argc - optind < 2
) {
usage(stderr);
exit(1);
}
if(format == NULL)
format = DEFFORMAT;
usage(stderr);
exit(1);
}
if(format == NULL)
format = DEFFORMAT;
- if(outfile != NULL) {
- if((out = fopen(outfile, "a")) == NULL) {
- flog(LOG_ERR, "accesslog: could not open %s for logging: %s", outfile, strerror(errno));
+ if(!strcmp(argv[optind], "-")) {
+ out = stdout;
+ } else {
+ if((out = fopen(argv[optind], "a")) == NULL) {
+ flog(LOG_ERR, "accesslog: could not open %s for logging: %s", argv[optind], strerror(errno));
exit(1);
}
exit(1);
}
- } else {
- out = stdout;
}
}
- if((ch = stdmkchild(argv + optind, NULL, NULL)) < 0) {
+ if((ch = stdmkchild(argv + optind
+ 1
, NULL, NULL)) < 0) {
flog(LOG_ERR, "accesslog: could fork child: %s", strerror(errno));
exit(1);
}
flog(LOG_ERR, "accesslog: could fork child: %s", strerror(errno));
exit(1);
}