Rewrite tools/pokemon_animation_graphics.c, and keep void usage and void parse_args at the top of tools' files

This commit is contained in:
Rangi
2021-09-02 17:15:50 -04:00
parent c8f06f45d5
commit a18f83b911
3 changed files with 193 additions and 254 deletions

View File

@@ -1,9 +1,31 @@
#include "common.h"
void usage(void) {
void usage() {
fputs("Usage: scan_includes [-h|--help] [-s|--strict] filename.asm\n", stderr);
}
void parse_args(int argc, char *argv[], bool *strict) {
struct option long_options[] = {
{"strict", no_argument, 0, 's'},
{"help", no_argument, 0, 'h'},
{0}
};
for (int opt; (opt = getopt_long(argc, argv, "sh", long_options)) != -1;) {
switch (opt) {
case 's':
*strict = true;
break;
case 'h':
usage();
exit(0);
break;
default:
usage();
exit(1);
}
}
}
void scan_file(const char *filename, bool strict) {
errno = 0;
FILE *f = fopen(filename, "rb");
@@ -66,28 +88,6 @@ void scan_file(const char *filename, bool strict) {
free(contents);
}
void parse_args(int argc, char *argv[], bool *strict) {
struct option long_options[] = {
{"strict", no_argument, 0, 's'},
{"help", no_argument, 0, 'h'},
{0}
};
for (int opt; (opt = getopt_long(argc, argv, "sh", long_options)) != -1;) {
switch (opt) {
case 's':
*strict = true;
break;
case 'h':
usage();
exit(0);
break;
default:
usage();
exit(1);
}
}
}
int main(int argc, char *argv[]) {
bool strict = false;
parse_args(argc, argv, &strict);