diff options
Diffstat (limited to 'tools/hi-q.c')
-rw-r--r-- | tools/hi-q.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/tools/hi-q.c b/tools/hi-q.c index f0e107a..1edf8f0 100644 --- a/tools/hi-q.c +++ b/tools/hi-q.c @@ -103,6 +103,13 @@ int Execve(char const * fn, return execve(fn, (char*const*) argv, (char*const*) env); } +void usage() { + cerr << "Usage:\n" +" hi-q filter.conf\n" +"or\n" +" HI_Q_CONF=filter.conf hi-q\n"; +} + //////////////////////////////////////// // we have data coming in on fd 0. // and control coming in on fd 1. @@ -136,12 +143,22 @@ int main(int argc, char** argv, char const * const * env) { typedef vector<string> VS; vector<VS> filter; - if (argc != 2) { - cerr << "Usage: hi-q filter.conf" << endl; + char* conf_name; + + if (argc == 1) { + conf_name = getenv("HI_Q_CONF"); + if (!conf_name) { + usage(); + exit(1); + } + } + else if (argc == 2) { + conf_name = argv[1]; + } else { + usage(); exit(1); } - char* conf_name = argv[1]; ifstream conf; conf.open(conf_name); if (! conf.good()) { @@ -165,6 +182,7 @@ int main(int argc, char** argv, char const * const * env) { } if (verbose) for (vector<VS>::const_iterator job = filter.begin(); job != filter.end(); job++) { + cerr << "Filter: "; for (VS::const_iterator token = job->begin(); token != job->end(); token++){ cerr << *token << " "; |