summaryrefslogtreecommitdiff
path: root/tools/hi-q.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-06-03 00:00:54 -0700
committerJohn Denker <jsd@av8n.com>2012-06-03 00:00:54 -0700
commite866b3e47fe92eafc9d6d40a579993c8919b9842 (patch)
tree4d3b3723b4a554cb0870b57ed1aae8ec1eb0f028 /tools/hi-q.c
parentcbf5fd559293f7f5b59996a5845c0080e9946f01 (diff)
pass config-file in environment, since can't pass it as arg
Diffstat (limited to 'tools/hi-q.c')
-rw-r--r--tools/hi-q.c24
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 << " ";