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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
|
#pragma once
#include "common.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __MWERKS__
#pragma options align=packed
#endif
enum {
OptParseError = 0,
OptParseSuccess = 1
};
typedef struct PARAM_T {
char which;
char flags;
char *myname;
struct PARAM_T *next;
} PARAM_T;
typedef struct MASK_T {
char which;
char flags;
char *myname;
PARAM_T *next;
char size;
UInt32 ormask;
UInt32 andmask;
void *num;
} MASK_T;
typedef struct STRING_T {
char which;
char flags;
char *myname;
PARAM_T *next;
SInt16 maxlen;
Boolean pstring;
char *str;
} STRING_T;
typedef struct SET_T {
char which;
char flags;
char *myname;
PARAM_T *next;
char size;
UInt32 value;
char *num;
} SET_T;
typedef struct SETSTRING_T {
char which;
char flags;
char *myname;
PARAM_T *next;
char *value;
char pstring;
void *var;
} SETSTRING_T;
typedef struct GENERIC_T {
char which;
char flags;
char *myname;
PARAM_T *next;
int (*parse)(const char *opt, void *var, const char *pstr, int flags);
void *var;
char *help;
} GENERIC_T;
typedef struct SETTING_T {
char which;
char flags;
char *myname;
PARAM_T *next;
int (*parse)(const char *a, const char *b); // TODO name these args
char *valuename;
} SETTING_T;
typedef struct TOGGLE_T {
char which;
char flags;
char *myname;
PARAM_T *next;
char size;
UInt32 mask;
void *num;
} TOGGLE_T;
typedef struct NUM_T {
char which;
char flags;
char *myname;
PARAM_T *next;
char size;
char fit;
UInt32 lo;
UInt32 hi;
void *num;
} NUM_T;
typedef struct FILEPATH_T {
char which;
char flags;
char *myname;
PARAM_T *next;
char fflags;
char *defaultstr;
void *filename;
int maxlen;
} FILEPATH_T;
typedef struct IFARG_T {
char which;
char flags;
char *myname;
PARAM_T *next;
PARAM_T *parg;
char *helpa;
PARAM_T *pnone;
char *helpn;
} IFARG_T;
typedef struct ONOFF_T {
char which;
char flags;
char *myname;
PARAM_T *next;
unsigned char *var;
} ONOFF_T;
typedef struct OFFON_T {
char which;
char flags;
char *myname;
PARAM_T *next;
unsigned char *var;
} OFFON_T;
typedef struct FTYPE_T {
char which;
char flags;
char *myname;
PARAM_T *next;
OSType *fc;
Boolean iscreator;
} FTYPE_T;
typedef struct OptionList {
char *help;
int flags;
struct Option **list;
} OptionList;
typedef struct Option {
char *names;
int avail;
PARAM_T *param;
OptionList *sub;
OptionList *conflicts;
char *help;
} Option;
enum {
HELPFLAGS_1 = 1,
HELPFLAGS_IGNORED = 2,
HELPFLAGS_OBSOLETE = 4,
HELPFLAGS_DEPRECATED = 8,
HELPFLAGS_SECRET = 0x10,
HELPFLAGS_MEANINGLESS = 0x20,
HELPFLAGS_COMPATIBLE = 0x40,
HELPFLAGS_NORMAL = 0x80, // andmask = 0xE?
HELPFLAGS_SPACES = 0x100,
HELPFLAGS_TOOL = 0x200,
HELPFLAGS_TOOL_THIS = 0x400,
HELPFLAGS_TOOL_OTHER = 0x800,
HELPFLAGS_TOOL_BOTH = 0xC00,
HELPFLAGS_1000 = 0x1000,
HELPFLAGS_2000 = 0x2000,
HELPFLAGS_USAGE = 0x4000,
HELPFLAGS_8000 = 0x8000
};
enum {
OTF_GLOBAL = 1,
OTF_STICKY = 2,
OTF_CASED = 4,
OTF_OBSOLETE = 8,
OTF_SUBSTITUTED = 0x10,
OTF_DEPRECATED = 0x20,
OTF_TOOL_LINKER = 0x40,
OTF_TOOL_DISASSEMBLER = 0x80,
OTF_TOOL_COMPILER = 0x100,
OTF_TOOL_MASK = OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER | OTF_TOOL_COMPILER,
OTF200 = 0x200,
OTF400 = 0x400,
OTF_IGNORED = 0x800,
OTF_SECRET = 0x1000,
OTF_HIDE_DEFAULT = 0x2000,
OTF_COMPATIBILITY = 0x4000,
OTF_HAS_SUB_OPTIONS = 0x8000,
OTF_SUB_OPTIONS_OPTIONAL = 0x10000,
OTF_ONLY_ONCE = 0x20000,
OTF_HAS_CONFLICTS = 0x40000,
OTF_WARNING = 0x80000,
OTF_SLFLAGS_8 = 0x100000,
OTF_SLFLAGS_10 = 0x200000,
OTF_SLFLAGS_20 = 0x400000,
OTF_SLFLAGS_MASK = OTF_SLFLAGS_8 | OTF_SLFLAGS_10 | OTF_SLFLAGS_20,
OTF_MEANINGLESS = 0x800000,
OTF_ALL_HIDDEN_BY_DEFAULT = OTF_OBSOLETE | OTF_DEPRECATED | OTF_IGNORED | OTF_SECRET | OTF_MEANINGLESS,
OTF1000000 = 0x1000000,
OTF2000000 = 0x2000000,
OTF4000000 = 0x4000000,
OTF8000000 = 0x8000000,
OTF10000000 = 0x10000000,
OTF20000000 = 0x20000000,
OTF_INTERNAL_SEEN_CONFLICTED = 0x40000000,
OTF_INTERNAL_ALREADY_SEEN = 0x80000000
};
enum {
PARAMWHICH_None = 0,
PARAMWHICH_FTypeCreator = 1,
PARAMWHICH_FilePath = 2,
PARAMWHICH_Number = 3,
PARAMWHICH_String = 4,
PARAMWHICH_Id = 5,
PARAMWHICH_Sym = 6,
PARAMWHICH_OnOff = 7,
PARAMWHICH_OffOn = 8,
PARAMWHICH_Mask = 9,
PARAMWHICH_Toggle = 0xA,
PARAMWHICH_Set = 0xB,
PARAMWHICH_SetString = 0xC,
PARAMWHICH_Generic = 0xD,
PARAMWHICH_IfArg = 0xE,
PARAMWHICH_Setting = 0xF,
PARAMWHICH_MAX = 0x10
};
enum {
PARAMFLAGS_1 = 1,
PARAMFLAGS_2 = 2,
PARAMFLAGS_3 = 3,
PARAMFLAGS_4 = 4,
PARAMFLAGS_8 = 8,
PARAMFLAGS_10 = 0x10,
PARAMFLAGS_12 = 0x12
};
enum {
PARAMPARSEFLAGS_0 = 0,
PARAMPARSEFLAGS_1 = 1,
PARAMPARSEFLAGS_2 = 2,
PARAMPARSEFLAGS_4 = 4,
PARAMPARSEFLAGS_8 = 8,
PARAMPARSEFLAGS_10 = 0x10,
PARAMPARSEFLAGS_20 = 0x20,
PARAMPARSEFLAGS_40 = 0x40,
PARAMPARSEFLAGS_80 = 0x80,
PARAMPARSEFLAGS_100 = 0x100
};
enum {
SLFLAGS_1 = 1,
SLFLAGS_2 = 2,
SLFLAGS_4 = 4, // displays =...
SLFLAGS_8 = 8, // displays [no] -- produces e.g. [no]err[or] | [no]iserr[or], [no]implicit[conv]
SLFLAGS_10 = 0x10, // displays [-]
SLFLAGS_20 = 0x20, // displays [no-]
SLFLAGS_40 = 0x40
};
enum {
LISTFLAGS_NONE = 0,
LISTFLAGS_EXCLUSIVE = 1,
LISTFLAGS_ALLOW_UNKNOWNS = 2,
LISTFLAGS_4 = 4,
LISTFLAGS_COMPILER = 0x100,
LISTFLAGS_LINKER = 0x200,
LISTFLAGS_DISASSEMBLER = 0x400,
LISTFLAGS_TOOL_MASK = LISTFLAGS_COMPILER | LISTFLAGS_LINKER | LISTFLAGS_DISASSEMBLER
};
enum {
OFLAGS_1 = 1,
OFLAGS_2 = 2,
OFLAGS_4 = 4,
OFLAGS_8 = 8,
OFLAGS_10 = 0x10,
OFLAGS_20 = 0x20,
OFLAGS_40 = 0x40,
OFLAGS_80 = 0x80
};
enum {
PFLAGS_1 = 1,
PFLAGS_2 = 2,
PFLAGS_4 = 4,
PFLAGS_8 = 8,
PFLAGS_10 = 0x10,
PFLAGS_20 = 0x20,
PFLAGS_40 = 0x40,
PFLAGS_80 = 0x80
};
#ifdef __MWERKS__
#pragma options align=reset
#endif
/********************************/
/* Arguments.c */
typedef struct {
SInt16 val;
char *text;
} ArgToken;
enum {
ATK_END,
ATK_ARG_END,
ATK_ARG,
ATK_OPTION,
ATK_EQUALS,
ATK_COMMA
};
typedef struct {
int argc;
int nargv;
char **argv;
} anon0_50;
extern char compat;
extern char *MAINOPTCHAR;
extern char *FIRSTARGCHAR;
extern char *SEPOPTSTR;
extern char SEPOPTCHAR;
extern char SEP1;
extern char SEP2;
extern char SEP3;
extern char RESPFILECHAR;
extern char *RESPFILESTR;
extern anon0_50 linkargs;
extern anon0_50 prelinkargs;
extern anon0_50 postlinkargs;
extern void Arg_Init(int theargc, char **theargv);
extern void Arg_Terminate();
extern void Arg_Reset();
extern void Arg_Stop(ArgToken *where);
extern ArgToken *Arg_PeekToken();
extern ArgToken *Arg_UsedToken();
extern int Arg_IsEmpty();
extern ArgToken *Arg_GetToken();
extern ArgToken *Arg_UndoToken();
extern const char *Arg_GetTokenName(ArgToken *tok);
extern const char *Arg_GetTokenText(ArgToken *tok, char *buffer, int maxlen, unsigned char warn);
extern void Arg_InitToolArgs(anon0_50 *ta);
extern void Arg_AddToToolArgs(anon0_50 *ta, SInt16 tokval, char *toktxt);
extern void Arg_FinishToolArgs(anon0_50 *ta);
extern void Arg_ToolArgsForPlugin(anon0_50 *ta, struct CWCommandLineArgs *args);
extern void Arg_FreeToolArgs(anon0_50 *ta);
/********************************/
/* Option.c */
typedef struct {
void *first;
void *second;
} Opt50;
typedef struct {
Option *opt;
char *curopt;
} Opt52;
typedef struct {
union {
Opt50 v;
OptionList *lst;
Opt52 o;
char *param;
} e;
SInt16 flags;
} Opt48;
extern char curopt[1024];
extern void Args_InitStack();
extern int Args_StackSize();
extern void Args_Push(SInt16 flags, void *first, void *second);
extern Opt48 *Args_Pop(SInt16 flags);
extern void Args_SpellStack(char *buffer, SInt16 flags);
extern void Args_AddToToolArgs(anon0_50 *ta);
extern void Options_Init();
extern OptionList *Options_GetOptions();
extern void Options_SortOptions();
extern int Options_AddList(OptionList *optlst);
extern int Options_AddLists(OptionList **optlst);
extern int Option_ForTool(Option *opt, int which);
extern int Option_ThisTool();
extern int Option_ForThisTool(Option *opt);
extern int Option_AlsoPassedToTool(Option *opt, int which);
extern int Option_AlsoPassedFromThisTool(Option *opt);
extern int Option_Parse(Option *opt, int oflags);
extern int Options_Parse(OptionList *options, int flags);
extern int Option_ParseDefaultOption(OptionList *options);
extern void Option_ParamError(SInt16 id, va_list ap);
extern void Option_ParamWarning(SInt16 id, va_list ap);
extern void Option_OptionError(SInt16 id, va_list ap);
extern void Option_OptionWarning(SInt16 id, va_list ap);
extern void Option_Error(SInt16 id, ...);
extern void Option_Warning(SInt16 id, ...);
extern int Options_Help(const char *keyword);
extern int Option_Help(const char *opt);
extern int Options_DisplayHelp();
/********************************/
/* Parameter.c */
extern char curparam[4096];
extern void Param_DescHelp(PARAM_T *param, const char **desc, const char **help, const char **defaul);
extern int Param_Compare(PARAM_T *param);
extern int Params_Parse(PARAM_T *param, int flags);
extern void Param_Error(SInt16 id, ...);
extern void Param_Warning(SInt16 id, ...);
/********************************/
/* Help.c */
extern int Help_Option(OptionList *lst, Option *opt, int subprint, const char *keyword);
extern void Help_Options(OptionList *lst, int subprint, const char *keyword);
extern void Help_Usage();
extern void Help_Null();
extern void Help_Init();
extern void Help_Line(char ch);
extern void Help_Term();
#ifdef __cplusplus
}
#endif
|