static const char *arg0 = NULL;
-void usage()
+static void version() {
+ printf("GMQCC-QCVM %d.%d.%d Built %s %s\n",
+ GMQCC_VERSION_MAJOR,
+ GMQCC_VERSION_MINOR,
+ GMQCC_VERSION_PATCH,
+ __DATE__,
+ __TIME__
+ );
+}
+
+static void usage()
{
printf("usage: %s [options] [parameters] file\n", arg0);
printf("options:\n");
bool opts_disasm = false;
bool opts_info = false;
bool noexec = false;
+ const char *progsfile = NULL;
arg0 = argv[0];
exit(1);
}
- while (argc > 2) {
+ while (argc > 1) {
if (!strcmp(argv[1], "-h") ||
!strcmp(argv[1], "-help") ||
!strcmp(argv[1], "--help"))
usage();
exit(0);
}
+ else if (!strcmp(argv[1], "-v") ||
+ !strcmp(argv[1], "-version") ||
+ !strcmp(argv[1], "--version"))
+ {
+ version();
+ exit(0);
+ }
else if (!strcmp(argv[1], "-trace")) {
--argc;
++argv;
--argc;
++argv;
}
+ else if (!strcmp(argv[1], "--")) {
+ --argc;
+ ++argv;
+ break;
+ }
+ else if (argv[1][0] != '-') {
+ if (progsfile) {
+ printf("only 1 program file may be specified\n");
+ usage();
+ exit(1);
+ }
+ progsfile = argv[1];
+ --argc;
+ ++argv;
+ }
else
{
usage();
}
}
+ if (argc > 2) {
+ usage();
+ exit(1);
+ }
+ if (argc > 1) {
+ if (progsfile) {
+ printf("only 1 program file may be specified\n");
+ usage();
+ exit(1);
+ }
+ progsfile = argv[1];
+ --argc;
+ ++argv;
+ }
+
+ if (!progsfile) {
+ usage();
+ exit(1);
+ }
- prog = prog_load(argv[1]);
+ prog = prog_load(progsfile);
if (!prog) {
- printf("failed to load program '%s'\n", argv[1]);
+ printf("failed to load program '%s'\n", progsfile);
exit(1);
}