1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
// -*-C++-*-
// This file is part of the gmod package
// Copyright (C) 1997 by Andrew J. Robinson
#include <unistd.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include "defines.h"
#include "structs.h"
#include "globals.h"
int
parseArgs (int argc, char *argv[], struct optionsInfo *options)
{
extern char *optarg;
extern int optind;
int option, numErr = 0;
#ifdef USE_X
while ((option = getopt (argc, argv, "chP:rRv:")) != -1)
#else
#ifdef USE_NCURSES
while ((option = getopt (argc, argv, "bchlm:MnP:qrRsv:xz5")) != -1)
#else
while ((option = getopt (argc, argv, "bcehlm:MnP:qrRsv:xz5")) != -1)
#endif
#endif
switch (option)
{
case 'h':
printf (HEADING);
printf ("Original source (C) Hannu Savolainen, 1993\n");
printf ("MTM/ULT loaders by Robert Sanders\n");
printf ("Continuing development by Andrew J. Robinson\n\n");
printf ("Usage: %s [options] [modfile . . .]\n\n", argv[0]);
printf ("Options:\n");
#ifndef USE_X
printf (" -b DISABLE BPM tempos\n");
#endif
printf (" -c DISABLE compression of modules in memory\n");
#ifndef USE_X
#ifndef USE_NCURSES
printf (" -e Show empty samples (for messages)\n");
#endif
#endif
printf (" -h Help\n");
#ifndef USE_X
printf (" -l Break infinite loops\n");
printf (" -m x Use mixer number x (0 - 15)\n");
printf (" -M Check magic numbers\n");
printf (" -n Use NTSC sample timing\n");
#endif
printf (" -P Set panning factor to x percent (-100 to 100)\n");
#ifndef USE_X
printf (" -q Quiet mode\n");
#endif
printf (" -r Infinitely repeat module\n");
printf (" -R Randomize module play order\n");
#ifndef USE_X
printf (" -s Ignore speed 0 commands\n");
#endif
printf (" -v x Set volume to x (0 - 255)\n");
#ifndef USE_X
printf (" -x Extend octaves\n");
printf (" -z Background mode\n");
printf (" -5 Use 50 Hz clock frequency\n\n");
printf ("One or more MultiTracker, UltraTracker, MOD (4/6/8 channel), S3M,\n");
printf ("669, or XM files should be listed on the command line.\n");
#endif
exit (ERR_NOERROR);
#ifndef USE_X
case 'b':
options->bpmTempos = 0;
break;
#endif
case 'c':
options->compress = 0;
break;
#ifndef USE_X
#ifndef USE_NCURSES
case 'e':
options->showEmptySamples = 1;
break;
#endif
#endif
#ifndef USE_X
case 'l':
options->loopBreaker = 1;
/* override repeat */
options->repeat = 0;
break;
case 'm':
option = atoi (optarg);
if ((option > 15) || (option < 0))
{
printf ("%s: mixer number must be between 0 and 15.\n", argv[0]);
numErr = 1;
}
else
options->mixer = option;
break;
case 'M':
options->checkMagic = 1;
break;
case 'n':
options->ntsc = 1;
break;
#endif
case 'P':
option = atoi (optarg);
if ((option > 100) || (option < -100))
{
printf ("%s: panning factor must be between -100 and 100.\n", argv[0]);
numErr = 1;
}
else
options->panFactor = option;
break;
#ifndef USE_X
case 'q':
fclose (stdout);
fclose (stderr);
break;
#endif
case 'r':
options->repeat = 1;
/* override loop breaker */
#ifndef USE_X
options->loopBreaker = 0;
#endif
break;
case 'R':
options->randomize = 1;
break;
#ifndef USE_X
case 's':
options->tolerant = 1;
break;
#endif
case 'v':
option = atoi (optarg);
if ((option > 255) || (option < 0))
{
printf ("%s: volume must be between 0 and 255.\n", argv[0]);
numErr = 1;
}
else
options->mainVolume = option;
break;
#ifndef USE_X
case 'x':
options->extendOct = OCTAVE_EXTEND;
break;
case 'z':
background = 1;
break;
case '5':
options->use_50hz = 1;
break;
#endif
case '?':
numErr = 1;
break;
case ':':
numErr = 1;
break;
}
if (numErr)
{
printf ("\nUsage: %s [options] modfile . . .\n", argv[0]);
printf ("Use %s -h for help.\n\n", argv[0]);
exit (ERR_BADARGS);
}
return optind;
}
|