-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.h
More file actions
73 lines (59 loc) · 1.48 KB
/
setup.h
File metadata and controls
73 lines (59 loc) · 1.48 KB
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
/*SPDX-FileCopyrightText: 2025 - 2026 Eli Array Minkoff
*
* SPDX-License-Identifier: GPL-3.0-only */
#ifndef BFC_PARSE_ARGS
#define BFC_PARSE_ARGS 1
/* C99 */
#include <stdio.h>
/* internal */
#include "arch_inter.h"
#include "err.h"
#include "types.h"
typedef struct {
enum { STANDARD_RUN, SHOW_VERSION, SHOW_HELP, LIST_TARGETS } run_type;
OutMode out_mode;
ArchInter *restrict backend;
const char *source_extension;
const char *output_extension;
u64 tape_blocks;
size_t nfiles;
char **files;
bool optimize;
bool keep;
bool continue_on_error;
} RunConfig;
typedef enum {
ARGS_OK,
#define DEFINE_ARGS_ERR
#include "arg_parse_errs.h"
#undef DEFINE_ARGS_ERR
} ArgParseOutcome;
typedef union {
const char *str;
const char *str2[2];
char unknown_short_opt;
u64 tape_sizes[2];
struct tape_too_large {
u64 tape_blocks;
enum bit_count { BITS_32 = 32, BITS_64 = 64 } bits;
} tape_too_large;
} ArgParseErrPayload;
typedef struct {
const ArchInter *inter;
const char *ext;
const char *out_ext;
u64 tape_blocks;
bool keep : 1;
bool cont_on_fail: 1;
bool optimize : 1;
} RunCfg;
typedef union {
RunConfig ok;
ArgParseErrPayload err;
} ArgParseOut;
nonnull_args ArgParseOutcome
parse_args(int argc, char *argv[], ArgParseOut *out);
void show_help(const char *progname, FILE *stream);
void show_version(const char *progname);
void list_targets(void);
#endif /* BFC_PARSE_ARGS */