where '-' is stdin
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
{
char linebuf[linebufsize];
char *line;
{
char linebuf[linebufsize];
char *line;
+ char *inputfile = NULL;
const char *text;
const char *idx1;
const char *text;
const char *idx1;
- while ((opt = getopt (argc, argv, "f:t:s:e:h:m:q:x:l:vgn")) != -1) {
+ while ((opt = getopt (argc, argv, "f:t:s:e:h:m:q:x:i:l:vgn")) != -1) {
if (opt == 'f') {
parser->from = epool_strdup (&parser->ep, optarg);
} else if (opt == 't') {
if (opt == 'f') {
parser->from = epool_strdup (&parser->ep, optarg);
} else if (opt == 't') {
}
} else if (opt == 'x') {
parser->strmatch = epool_strdup (&parser->ep, optarg);
}
} else if (opt == 'x') {
parser->strmatch = epool_strdup (&parser->ep, optarg);
+ } else if (opt == 'i') {
+ inputfile = optarg;
} else if (opt == 'l') {
char *l;
parser->limit = strtoul (optarg, &l, 0);
} else if (opt == 'l') {
char *l;
parser->limit = strtoul (optarg, &l, 0);
- if ((filecount = parser_count_files (parser)) <= 0) {
+ if (inputfile) {
+ filecount = 1;
+ } else if ((filecount = parser_count_files (parser)) <= 0) {
fprintf (stderr, "unable to access log files\n");
exit (-1);
}
fprintf (stderr, "unable to access log files\n");
exit (-1);
}
cur_year = parser->year[i];
if (i <= 1) {
cur_year = parser->year[i];
if (i <= 1) {
- if (!(stream = (gpointer) fopen (logfiles[i], "r"))) continue;
+ if (inputfile && strlen(inputfile) == 1 && *inputfile == '-') {
+ stream = (gpointer) stdin;
+ } else if (inputfile) {
+ if (!(stream = (gpointer) fopen (inputfile, "r"))) {
+ fprintf(stderr, "unable to open log file\n");
+ exit (-1);
+ }
+ } else if (!(stream = (gpointer) fopen (logfiles[i], "r"))) continue;
} else {
if (!(stream = (gpointer) gzopen (logfiles[i], "r"))) continue;
}
} else {
if (!(stream = (gpointer) gzopen (logfiles[i], "r"))) continue;
}