-
Notifications
You must be signed in to change notification settings - Fork 20
/
gbsinfo.c
81 lines (69 loc) · 1.41 KB
/
gbsinfo.c
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
/*
* gbsplay is a Gameboy sound player
*
* 2003-2021 (C) by Tobias Diedrich <[email protected]>
* Christian Garbs <[email protected]>
*
* Licensed under GNU GPL v1 or, at your option, any later version.
*/
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "common.h"
#include "gbhw.h"
#include "gbcpu.h"
#include "libgbs.h"
#include "gbs_internal.h"
/* global variables */
char *myname;
void usage(long exitcode)
{
FILE *out = exitcode ? stderr : stdout;
fprintf(out,
_("Usage: %s [option] <gbs-file>\n"
"\n"
"Available options are:\n"
" -h display this help and exit\n"
" -V print version and exit\n"),
myname);
exit(exitcode);
}
void version(void)
{
(void)puts("gbsplay " GBS_VERSION);
exit(0);
}
void parseopts(int *argc, char ***argv)
{
long res;
myname = *argv[0];
while ((res = getopt(*argc, *argv, "hV")) != -1) {
switch (res) {
default:
usage(1);
break;
case 'h':
usage(0);
break;
case 'V':
version();
break;
}
}
*argc -= optind;
*argv += optind;
}
int main(int argc, char **argv)
{
struct gbs *gbs;
i18n_init();
parseopts(&argc, &argv);
if (argc < 1) {
usage(1);
}
if ((gbs = gbs_open(argv[0])) == NULL) exit(EXIT_FAILURE);
gbs_internal_api.print_info(gbs, 1);
gbs_close(gbs);
return 0;
}