19f40fa41de40351b94796d7df53d3ada2b16dec
3 * $Id: main.c,v 1.3 2002/02/02 19:21:53 mdw Exp $
7 * (c) 2001 Mark Wooding
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Jog: Programming for a jogging machine.
14 * Jog is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * Jog is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Jog; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 /*----- Revision history --------------------------------------------------*
32 * Revision 1.3 2002/02/02 19:21:53 mdw
33 * New audio subsystem.
35 * Revision 1.2 2002/01/30 09:27:55 mdw
36 * Parse tracing options on the command-line.
38 * Revision 1.1 2002/01/25 19:34:45 mdw
43 /*----- Header files ------------------------------------------------------*/
58 #include <mLib/alloc.h>
59 #include <mLib/mdwopt.h>
60 #include <mLib/quis.h>
61 #include <mLib/report.h>
62 #include <mLib/trace.h>
69 #include "tx-serial-unix.h"
71 /*----- Shutdown stuff ----------------------------------------------------*/
73 static int sigtab
[] = { SIGINT
, SIGQUIT
, SIGTERM
, SIGHUP
, -1 };
75 static void tidy(void)
81 static void sigtidy(int sig
)
88 /*----- Help functions ----------------------------------------------------*/
90 static void usage(FILE *fp
)
93 Usage: $ [-t TRANSPORT] [-f FILE] [-c CONFIG] [-a AUDIR] [-x SIZE]\n\
98 static void version(FILE *fp
)
100 pquis(fp
, "$, version " VERSION
"\n");
103 static void help(FILE *fp
)
111 -h, --help Print this help message.\n\
112 -v, --version Show the version number.\n\
113 -u, --usage Show terse usage summary.\n\
115 -t, --transport=NAME Use transport type NAME.\n\
116 -f, --tx-file=FILE Communicate using the named FILE.\n\
117 -c, --tx-config=CONFIG Use CONFIG as transport configuration.\n\
119 -a, --audio=DIR Set directory containing audio samples.\n\
120 -x, --cache-max=SIZE Maximum size for audio sample cache.\n\
125 /*----- Main code ---------------------------------------------------------*/
127 int main(int argc
, char *argv
[])
132 const char *audir
= 0;
133 size_t aumax
= AU_CACHEMAX
;
139 for (i
= 0; sigtab
[i
] >= 0; i
++)
140 signal(sigtab
[i
], sigtidy
);
144 T( trace_on(stderr
, 0u); )
145 if ((txname
= getenv("JOGTX")) != 0)
148 txname
= txlist
->name
;
151 static const struct option opt
[] = {
153 /* --- Standard help options --- */
155 { "help", 0, 0, 'h' },
156 { "version", 0, 0, 'v' },
157 { "usage", 0, 0, 'u' },
159 /* --- Transport configuration stuff --- */
161 { "transport", OPTF_ARGREQ
, 0, 't' },
162 { "transport-config",
163 OPTF_ARGREQ
, 0, 'c' },
164 { "tx-config", OPTF_ARGREQ
, 0, 'c' },
165 { "txconfig", OPTF_ARGREQ
, 0, 'c' },
166 { "config", OPTF_ARGREQ
, 0, 'c' },
168 OPTF_ARGREQ
, 0, 'f' },
169 { "tx-file", OPTF_ARGREQ
, 0, 'f' },
170 { "txfile", OPTF_ARGREQ
, 0, 'f' },
171 { "file", OPTF_ARGREQ
, 0, 'f' },
173 /* --- Audio configuration stuff --- */
176 OPTF_ARGREQ
, 0, 'a' },
178 OPTF_ARGREQ
, 0, 'x' },
180 OPTF_ARGREQ
, 0, 'x' },
182 /* --- Debugging stuff --- */
185 { "trace", OPTF_ARGREQ
, 0, 'T' },
188 /* --- End marker --- */
194 static const trace_opt tropt
[] = {
195 { 'x', T_TX
, "transport layer" },
196 { 's', T_TXSYS
, "low-level transport" },
197 { 'a', T_AU
, "audio subsystem" },
198 { 'y', T_AUSYS
, "system-specific audio" },
199 { 'A', T_ALL
, "all of the above" },
204 i
= mdwopt(argc
, argv
, "hvu" "t:c:f:" "a:x:" T("T:"), opt
, 0, 0, 0);
210 /* --- Standard help options --- */
222 /* --- Transport configuration stuff --- */
234 /* --- Audio configuration stuff --- */
240 aumax
= strtoul(optarg
, 0, 0);
243 /* --- Tracing --- */
247 trace_level(traceopt(tropt
, optarg
, tracing(), 0));
259 if ((f
& f_bogus
) || optind
> argc
- 1) {
264 au_init(audir
, aumax
);
265 rc
= rx_runfile(argv
[optind
],
266 argc
- optind
- 1, (const char *const *)argv
+ optind
+ 1);
267 return (rc ? EXIT_FAILURE
: 0);
270 /*----- That's all, folks -------------------------------------------------*/