/* -*-c-*-
*
- * $Id: main.c,v 1.1 2002/01/25 19:34:45 mdw Exp $
+ * $Id: main.c,v 1.2 2002/01/30 09:27:55 mdw Exp $
*
* Main program
*
/*----- Revision history --------------------------------------------------*
*
* $Log: main.c,v $
+ * Revision 1.2 2002/01/30 09:27:55 mdw
+ * Parse tracing options on the command-line.
+ *
* Revision 1.1 2002/01/25 19:34:45 mdw
* Initial revision
*
#include <mLib/trace.h>
#include "err.h"
+#include "jog.h"
#include "rxglue.h"
#include "txport.h"
#include "tx-serial-unix.h"
static void usage(FILE *fp)
{
- pquis(fp, "Usage: $ [-t TRANSPORT] [-f FILE] [-c CONFIG] SCRIPT [ARG]\n");
+ pquis(fp, "\
+Usage: $ [-t TRANSPORT] [-f FILE] [-c CONFIG] SCRIPT ARG...\n\
+");
}
static void version(FILE *fp)
err_init();
rx_init();
- trace_on(stderr, 0u);
+ T( trace_on(stderr, 0u); )
if ((txname = getenv("JOGTX")) != 0)
;
else
{ "txfile", OPTF_ARGREQ, 0, 'f' },
{ "file", OPTF_ARGREQ, 0, 'f' },
+ /* --- Debugging stuff --- */
+
+#ifndef NTRACE
+ { "trace", OPTF_ARGREQ, 0, 'T' },
+#endif
+
/* --- End marker --- */
{ 0, 0, 0, 0 }
};
- i = mdwopt(argc, argv, "hvut:c:f:", opt, 0, 0, 0);
+#ifndef NTRACE
+ static const trace_opt tropt[] = {
+ { 'x', T_TX, "transport layer" },
+ { 's', T_TXSYS, "low-level transport" },
+ { 'A', T_ALL, "all of the above" },
+ { 0, 0, 0 }
+ };
+#endif
+
+ i = mdwopt(argc, argv, "hvu" "t:c:f:" T("T:"), opt, 0, 0, 0);
if (i < 0)
break;
txfile = optarg;
break;
+ /* --- Tracing --- */
+
+#ifndef NTRACE
+ case 'T':
+ trace_level(traceopt(tropt, optarg, tracing(), 0));
+ break;
+#endif
+
/* --- Errors --- */
default:
}
}
- if ((f & f_bogus) || (optind != argc - 1 && optind != argc - 2)) {
+ if ((f & f_bogus) || optind > argc - 1) {
usage(stderr);
exit(EXIT_FAILURE);
}