summaryrefslogtreecommitdiff
path: root/includes/cmdline.h
blob: d25e70bae0f5a6526baed6765791678f6ca2c847 (plain)
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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
#ifndef CMDLINE_H
#define CMDLINE_H

#include "cw_common.h"
#include "pref_structs.h"

enum {
    // "Could not get current working directory"
    CLStr1 = 1,
    // "Cannot find my executable '%s'"
    CLStr2 = 2,
    // "Could not initialize plugin '%s'"
    CLStr3 = 3,
    // "The %s '%s' requires functionality not present in the command-line driver."
    CLStr4 = 4,
    // "The command-line parser does not support these panels:"
    CLStr5 = 5,
    // "\t%s\n"
    CLStr6 = 6,
    // "Compiling function: '%s'"
    CLStr7 = 7,
    // "Could not write file '%s'"
    CLStr8 = 8,
    // "Could not write file '%s' in directory '%s'"
    CLStr9 = 9,
    // "Write error on output (errno=%ld)"
    CLStr10 = 10,
    // "Current working directory is too long"
    CLStr11 = 11,
    // "Unknown filetype '%c%c%c%c', defaulting to '%s'"
    CLStr12 = 12,
    // "%s:\ttype %s"
    CLStr13 = 13,
    // "Storing output for '%s' in '%s'"
    CLStr14 = 14,
    // "Writing text file '%s'"
    CLStr15 = 15,
    // "Writing %sobject file '%s'"
    CLStr16 = 16,
    // "Writing browse data '%s'"
    CLStr17 = 17,
    // "Could not write %s '%s' (error %ld)"
    CLStr18 = 18,
    // "Deleting temporary file '%s'"
    CLStr19 = 19,
    // "Could not resolve alias for '%s' (error %ld)"
    CLStr20 = 20,
    // "%s:\t'%s'%s"
    CLStr21 = 21,
    // "File '%s' has browse fileID %d"
    CLStr22 = 22,
    // "Can't locate directory '%s'"
    CLStr23 = 23,
    // "  %8.2f seconds to %s %s%s%s"
    CLStr24 = 24,
    // "  %8d lines compiled"
    CLStr25 = 25,
    // "  %8d %s code\n  %8d %s init'd data\n  %8d %s uninit'd data"
    CLStr26 = 26,
    // "  %8d total %s code\n  %8d total %s init'd data\n  %8d total %s uninit'd data"
    CLStr27 = 27,
    // "File '%s' is not compilable source, target object data, or command file; ignoring"
    CLStr28 = 28,
    // "All specified files were ignored"
    CLStr29 = 29,
    // "Compiling: '%s'"
    CLStr30 = 30,
    // "Compiling: '%s' with '%s'"
    CLStr31 = 31,
    // "Precompiling: '%s'"
    CLStr32 = 32,
    // "Precompiling: '%s' with '%s'"
    CLStr33 = 33,
    // "Preprocessing: '%s'"
    CLStr34 = 34,
    // "Preprocessing: '%s' with '%s'"
    CLStr35 = 35,
    // "Finding dependencies: '%s'"
    CLStr36 = 36,
    // "Finding dependencies: '%s' with '%s'"
    CLStr37 = 37,
    // "Importing: '%s'"
    CLStr38 = 38,
    // "Importing: '%s' with '%s'"
    CLStr39 = 39,
    // "Linking project"
    CLStr40 = 40,
    // "Linking project with '%s'"
    CLStr41 = 41,
    // "Pre-linking project"
    CLStr42 = 42,
    // "Pre-linking project with '%s'"
    CLStr43 = 43,
    // "Post-linking project"
    CLStr44 = 44,
    // "Post-linking project with '%s'"
    CLStr45 = 45,
    // "Disassembling: '%s'"
    CLStr46 = 46,
    // "Disassembling: '%s' with '%s'"
    CLStr47 = 47,
    // "Syntax checking: '%s'"
    CLStr48 = 48,
    // "Syntax checking: '%s' with '%s'"
    CLStr49 = 49,
    // "Getting target info from '%s'"
    CLStr50 = 50,
    // "Initializing '%s'"
    CLStr51 = 51,
    // "Terminating '%s'"
    CLStr52 = 52,
    // "'%s' cannot preprocess, skipping '%s'"
    CLStr53 = 53,
    // "'%s' cannot precompile, skipping '%s'"
    CLStr54 = 54,
    // "'%s' cannot generate code, skipping '%s'"
    CLStr55 = 55,
    // "'%s' has no object code to disassemble"
    CLStr56 = 56,
    // "'%s' cannot disassemble, skipping '%s'"
    CLStr57 = 57,
    // "Neither '%s' nor '%s' can disassemble, skipping '%s'"
    CLStr58 = 58,
    // "No precompiled header name given, '%s' assumed"
    CLStr59 = 59,
    // "Precompile target '%s' given on command line; source-specified name '%s' ignored"
    CLStr60 = 60,
    // "Writing precompiled %s file '%s'"
    CLStr61 = 61,
    // "Reading precompiled %s file '%s'"
    CLStr62 = 62,
    // "Cannot %s memory for %s"
    CLStr63 = 63,
    // "Files/directories must have length <= %ld characters;\n'%s' not accepted"
    CLStr64 = 64,
    // "Guessed linker name '%s' from compiler name '%s'"
    CLStr65 = 65,
    // "Can't find %s '%s' in path"
    CLStr66 = 66,
    // "Calling %s '%s'"
    CLStr67 = 67,
    // "Can't execute %s '%s' (%s)"
    CLStr68 = 68,
    // "%s '%s' returned with exit code %d"
    CLStr69 = 69,
    // "Too many errors printed, aborting program"
    CLStr70 = 70,
    // "Too many errors printed, suppressing errors for current file"
    CLStr71 = 71,
    // "Too many warnings printed, suppressing warnings for current file"
    CLStr72 = 72,
    // "No %s mapping matches '%s' (unrecognized file contents or filename extension); %s"
    CLStr73 = 73,
    // "No plugin or target matches the file '%s', ignoring"
    CLStr74 = 74,
    // "File '%s' cannot be handled by this tool, ignoring"
    CLStr75 = 75,
    // "File '%s' does not match the active target"
    CLStr76 = 76,
    // "Adding%s:\t'%s'"
    CLStr77 = 77,
    // "Creating new overlay '%s' in group '%s'"
    CLStr78 = 78,
    // "Creating new overlay group '%s' at addr %08X:%08X"
    CLStr79 = 79,
    // "File '%s' cannot be added to overlay group; define an overlay in the group first"
    CLStr80 = 80,
    // "Cannot create virtual export file '%s' (from '-export name,...')"
    CLStr81 = 81,
    // "Too many %s defined; at most %d%s is allowed"
    CLStr82 = 82,
    // "Loading preference panel '%s'"
    CLStr83 = 83,
    // "%s:"
    CLStr84 = 84,
    // "\t%s%s"
    CLStr85 = 85,
    // "Already defined %s search path; '%s' added after other paths"
    CLStr86 = 86,
    // "License check failed: %s"
    CLStr87 = 87,
    // "The plugin '%s' (version '%s') cannot be used:\n%s"
    CLStr88 = 88,
    // "Plugin '%s' has already been registered"
    CLStr89 = 89,
    // "Preferences for '%s' have already been registered"
    CLStr90 = 90,
    // "Preferences for '%s' not found"
    CLStr91 = 91,
    // "Some preferences needed by the plugin '%s' have not been registered"
    CLStr92 = 92,
    // "Could not load file '%s'"
    CLStr93 = 93,
    // "Could not find change current working directory to '%s'"
    CLStr94 = 94,
    // "Out of memory"
    CLStr95 = 95,
    // "The tool did not produce any output while %s the file '%s'"
    CLStr96 = 96,
    // "The filename '%s' is invalid"
    CLStr97 = 97,
    // "The %slinker for this target was not found"
    CLStr98 = 98,
    // "%s\n%s (OS error %d)"
    CLStr99 = 99,
    // "%s\n%s (error %d)"
    CLStr100 = 100,
    // "Note:  '%s' did not generate any browse information \nfor '%s'; no browser output generated"
    CLStr101 = 101,
    // "Source and specified output for the file '%s' are identical; no output will be generated"
    CLStr102 = 102,
    // "More than one output filename specified for '%s'; ignoring '%s'"
    CLStr103 = 103,
    // "Pref panel data for '%s' is out-of-date or invalid"
    CLStr104 = 104,
    // "Changing primary user access path to '%s'"
    CLStr105 = 105,
    // "The linker does not expect duplicate files; ignoring repeated '%s'"
    CLStr106 = 106,
};

#define DO_INTERNAL_ERROR(line, ...) CLInternalError(__FILE__, line, __VA_ARGS__)

#ifdef	__MWERKS__
#pragma options align=mac68k
#endif
// TODO fixme
typedef struct CPrepFileInfo {
    FSSpec textfile;
    void *nameNode;
    SInt32 fileModDate;
    char *textbuffer;
    SInt32 textlength;
    SInt32 linenumber;
    SInt32 pos;
    Boolean hasprepline;
    SInt16 fileID;
    Boolean recordbrowseinfo;
    void *unk;
} CPrepFileInfo;
typedef CPrepFileInfo *CPrepFileInfoStack[];
#ifdef	__MWERKS__
#pragma options align=reset
#endif

enum {
    OptsCmdLineState_0 = 0,
    OptsCmdLineState_1 = 1,
    OptsCmdLineState_2 = 2,
    OptsCmdLineState_3 = 3
};
enum {
    OptsCompilerSbmState_0 = 0,
    OptsCompilerSbmState_1 = 1, // sbmRebuild?
    OptsCompilerSbmState_2 = 2,
    OptsCompilerSbmState_3 = 3 // sbmClean?
};
enum {
    CmdLineStage_Cg = 1,
    CmdLineStage_Pp = 2,
    CmdLineStage_Ds = 3
};
enum {
    CmdLineStageMask_Pp = 1,
    CmdLineStageMask_Cg = 2,
    CmdLineStageMask_Ds = 4,
    CmdLineStageMask_Dp = 8
};

// Result codes used by various things in CLMain and CLFileOps
enum {
    Result_Success = 0,
    Result_Failed = 1,
    Result_Cancelled = 2
};

#ifdef __cplusplus
extern "C" {
#endif

typedef struct MessageRef {
    OSSpec sourcefile;
    OSSpec errorfile;
    char *sourceline;
    SInt32 linenumber;
    SInt32 tokenoffset;
    SInt16 tokenlength;
    SInt32 selectionoffset;
    SInt16 selectionlength;
} MessageRef;

typedef struct Paths {
    struct Path **pathsArray;
    UInt16 arraySize;
    UInt16 pathsCount;
} Paths;

typedef struct Frameworks {
    struct Paths_FWInfo **fwsArray;
    UInt16 arraySize;
    UInt16 fwsCount;
} Frameworks;

typedef struct Path {
    OSPathSpec *spec;
    Paths *recursive;
    char *dirlist;
    SInt16 flags;
} Path;

typedef struct Paths_FWInfo {
    OSSpec fileSpec;
    OSPathSpec version;
    OSPathSpec name;
    Path *path;
    Boolean hidden;
} Paths_FWInfo;

typedef struct InclFile {
    SInt32 filenameoffs;
    Path *accesspath;
    Path *globalpath;
    Path *specialpath;
    Boolean syspath;
} InclFile;

typedef struct Incls {
    struct Target *targ;
    SInt32 numincls;
    SInt32 maxincls;
    InclFile *files;
    SInt32 buflen;
    SInt32 bufpos;
    char *buffer;
    Paths *allPaths;
} Incls;

typedef struct Deps {
    int numDeps;
    int maxDeps;
    SInt32 *list;
    Incls *incls;
} Deps;

typedef struct OvlAddr {
    UInt32 lo, hi;
} OvlAddr;

typedef struct Overlay {
    char name[256];
    SInt32 *list;
    SInt32 cnt;
    SInt32 max;
    struct Overlay *next;
} Overlay;

typedef struct OvlGroup {
    char name[256];
    OvlAddr addr;
    Overlay *olys;
    Overlay *lastoly;
    int olycnt;
    struct OvlGroup *next;
} OvlGroup;

typedef struct Overlays {
    OvlGroup *groups;
    OvlGroup *lastgrp;
    SInt32 grpcnt;
} Overlays;

typedef struct Segment {
    char name[32];
    UInt16 attrs;
} Segment;

typedef struct Segments {
    Segment **segsArray;
    UInt16 arraySize;
    UInt16 segsCount;
} Segments;
typedef struct File {
    struct File *next;
    SInt32 filenum;
    UInt16 segnum;
    time_t srcmoddate;
    time_t outmoddate;
    char srcfilename[256];
    char outfilename[256];
    SInt16 outfileowner;
    OSSpec srcfss;
    OSSpec outfss;
    SInt16 writeToDisk;
    SInt16 wroteToDisk;
    SInt16 tempOnDisk;
    struct Plugin *compiler;
    SInt32 dropinflags;
    SInt32 objectflags;
    SInt32 mappingflags;
    SInt16 sourceUsage;
    SInt16 objectUsage;
    Handle textdata;
    Handle objectdata;
    Handle browsedata;
    SInt32 codesize;
    SInt32 udatasize;
    SInt32 idatasize;
    SInt32 compiledlines;
    Boolean recompileDependents;
    Boolean gendebug;
    Boolean hasobjectcode;
    Boolean hasresources;
    Boolean isresourcefile;
    Boolean weakimport;
    Boolean initbefore;
    Boolean mergeintooutput;
    Deps deps;
    Boolean recordbrowseinfo;
    SInt16 browseFileID;
    char browseoptions[32];
    OSType filetype;
    OSType filecreator;
} File;

typedef struct Files {
    File *fileList;
    SInt32 fileCount;
} Files;

typedef struct VFile {
    char displayName[32];
    Handle data;
    struct VFile *next;
} VFile;

enum {
    LinkModel0 = 0,
    LinkModel1 = 1,
    LinkModel2 = 2
};

typedef struct Target {
    struct BuildInfo {
        UInt32 linesCompiled;
        UInt32 codeSize;
        UInt32 iDataSize;
        UInt32 uDataSize;
    } info;
    CWTargetInfo *targetinfo;
    struct {
        Segments segs;
        Overlays overlays;
    } linkage;
    SInt32 linkmodel;
    Files files;
    Files pchs;
    Incls incls;
    Paths sysPaths;
    Paths userPaths;
    OSType lang;
    OSType cpu;
    OSType os;
    char targetName[64];
    struct Plugin *preLinker;
    struct Plugin *linker;
    struct Plugin *postLinker;
    UInt32 preLinkerDropinFlags;
    UInt32 linkerDropinFlags;
    UInt32 postLinkerDropinFlags;
    OSPathSpec outputDirectory;
    VFile *virtualFiles;
    struct Target *next;
} Target;

typedef struct Project {
    Target *targets;
    OSSpec projectDirectory;
} Project;

enum {
    CLStyledMessageDispatch_Type0 = 0,
    CLStyledMessageDispatch_Type1 = 1,
    CLStyledMessageDispatch_Type2 = 2,
    CLStyledMessageDispatch_Type3 = 3,
    CLStyledMessageDispatch_Type4 = 4,
    CLStyledMessageDispatch_Type5 = 5
};

enum {
    IncludeSearch_Type0 = 0,
    IncludeSearch_Type1 = 1,
    IncludeSearch_Type2 = 2,
    IncludeSearch_Type3 = 3,
    IncludeSearch_Type4 = 4
};

typedef struct PrefPanel PrefPanel;

typedef struct Plugin {
    BasePluginCallbacks *cb;
    CompilerLinkerPluginCallbacks *cl_cb;
    ParserPluginCallbacks *pr_cb;
    CWPluginContext context;
    char *cached_ascii_version;
    struct Plugin *next;
} Plugin;

/********************************/
/* State */
typedef struct {
    int argc;
    char **argv;
    OSType cpu;
    OSType os;
    OSType plugintype;
    OSType language;
    OSType parserstyle;
    OSSpec programSpec;
    const char *programName;
    SInt16 countWarnings;
    SInt16 countErrors;
    Boolean pluginDebug;
    Boolean userBreak;
    Boolean withholdWarnings;
    Boolean withholdErrors;
    OSSpec makefileSpec;
    OSPathSpec sbmPathSpec;
    OSHandle browseTableHandle;
    char *stdout_base;
    Boolean stdout_written;
} CLState; // assumed name

extern char cmdline_build_time[32];
extern char cmdline_build_date[32];
extern CLState clState;
extern PCmdLineLinker optsLinker;
extern PCmdLineCompiler optsCompiler;
extern PCmdLineEnvir optsEnvir;
extern PCmdLine optsCmdLine;
extern Target *gTarg;
extern Project mainProj;
extern CWCommandLineArgs *plugin_args;
extern CWCommandLineArgs *panel_args;
extern const char **panelNames;
extern int numPanels;
extern CLPluginInfo *pluginInfo;
extern int numPlugins;
extern jmp_buf exit_program;

/********************************/
/* Callbacks/CLParserCallbacks_V1.cpp */
extern int (*PrefPanelsChangedCallback)(const char *);

/********************************/
/* Clients/ClientGlue.c */
extern int RegisterResource(const char *name, SInt16 rsrcid, const char **list);
extern int RegisterStaticPlugin(const BasePluginCallbacks *callbacks);
extern int RegisterStaticCompilerLinkerPlugin(const BasePluginCallbacks *callbacks, const CompilerLinkerPluginCallbacks *cl_callbacks);
extern int RegisterStaticParserPlugin(const BasePluginCallbacks *cb, const ParserPluginCallbacks *pr_callbacks);
extern void SetBuildTarget(OSType cpu, OSType os);
extern void SetParserType(OSType plang);
extern void SetPluginType(OSType lang, OSType type);
extern int CmdLine_Initialize(int argc, char **argv, const char *builddate, const char *buildtime);
extern int CmdLine_Driver(void);
extern int CmdLine_Terminate(int exitcode);

/********************************/
/* Envir/CLErrors.c */
extern void CLReportError(SInt16 errid, ...);
extern void CLReportWarning(SInt16 errid, ...);
extern void CLReport(SInt16 errid, ...);
extern void CLReportOSError(SInt16 errid, int err, ...);
extern void CLReportCError(SInt16 errid, int err_no, ...);
extern void CLInternalError(const char *file, int line, const char *format, ...);
extern void CLFatalError(const char *format, ...);

/********************************/
/* Envir/CLIO.c */
extern void SetupDebuggingTraps(void);
extern Boolean IO_Initialize(void);
extern Boolean IO_Terminate(void);
extern Boolean IO_HelpInitialize(void);
extern Boolean IO_HelpTerminate(void);
extern void FixHandleForIDE(Handle text, UInt32 size);
extern Boolean ShowHandle(Handle text, UInt32 size, Boolean decorate);
extern Boolean WriteHandleToFile(OSSpec *spec, Handle text, UInt32 size, OSType creator, OSType type);
extern Boolean WriteBinaryHandleToFile(OSSpec *spec, OSType maccreator, OSType mactype, OSHandle *text);
extern Boolean AppendHandleToFile(OSSpec *spec, Handle text, UInt32 size, OSType maccreator, OSType mactype);
extern void InitWorking(void);
extern void ShowWorking(int x);
extern void TermWorking(void);
extern Boolean CheckForUserBreak(void);
extern char *IO_FormatText(char *buffer, SInt32 size, char *newline, const char *format, ...);
extern void CLPrintDispatch(int unk, SInt16 msgtype, const char *message);
extern void CLPrintType(SInt16 msgtype, const char *format, ...);
extern void CLPrint(const char *format, ...);
extern void CLPrintWarning(const char *format, ...);
extern void CLPrintErr(const char *format, ...);
extern SInt16 CLStyledMessageDispatch(Plugin *plugin, MessageRef *ref, SInt32 errorNumber, SInt16 msgType, const char *format, ...);

/********************************/
/* Plugins/CLPlugins.c */
extern const ToolVersionInfo *Plugin_GetToolVersionInfo(void);
extern const char *Plugin_GetDropInName(Plugin *pl);
extern const VersionInfo *Plugin_GetVersionInfo(Plugin *pl);
extern char *Plugin_GetVersionInfoASCII(Plugin *pl);
extern DropInFlags *Plugin_GetDropInFlags(Plugin *pl);
extern OSType Plugin_GetPluginType(Plugin *pl);
extern const CWTargetList *Plugin_CL_GetTargetList(Plugin *pl);
extern const CWPanelList *Plugin_GetPanelList(Plugin *pl);
extern const CWExtMapList *Plugin_CL_GetExtMapList(Plugin *pl);
extern const OSFileTypeMappingList *Plugin_GetFileTypeMappingList(Plugin *pl);
extern const CWObjectFlags *Plugin_CL_GetObjectFlags(Plugin *pl);
extern Boolean Plugin_MatchesName(Plugin *pl, const char *name);
extern Boolean Plugin_CL_MatchesTarget(Plugin *pl, OSType cpu, OSType os, Boolean exact);
extern Boolean Plugins_CL_HaveMatchingTargets(Plugin *p1, Plugin *p2, Boolean exact);
extern Boolean Plugin_CL_MatchesFileType(Plugin *pl, OSType type, const char *extension, Boolean exact);
extern Boolean Plugin_MatchesType(Plugin *pl, OSType type, OSType lang, Boolean exact);
extern Boolean Plugin_Pr_MatchesPlugin(Plugin *pl, CLPluginInfo *pluginfo, OSType cpu, OSType os);
extern Boolean Plugin_Pr_MatchesPanels(Plugin *pl, int numPanels, const char **panelNames);
extern Boolean Plugin_CL_WriteObjectFile(Plugin *pl, FSSpec *srcfss, FSSpec *outfss, OSType creator, OSType type, Handle data);
extern Boolean Plugin_CL_GetCompilerMapping(Plugin *pl, OSType type, const char *ext, UInt32 *flags);
extern Plugin *Plugin_New(const BasePluginCallbacks *cb, const CompilerLinkerPluginCallbacks *cl_cb, const ParserPluginCallbacks *pr_cb);
extern void Plugin_Free(Plugin *pl);
extern Boolean Plugin_VerifyPanels(Plugin *pl);
extern void Plugins_Init(void);
extern void Plugins_Term(void);
extern int Plugins_Add(Plugin *pl);
extern Plugin *Plugins_MatchName(Plugin *list, const char *name);
extern Plugin *Plugins_CL_MatchTarget(Plugin *list, OSType cpu, OSType os, OSType type, OSType lang);
extern Plugin *Plugins_CL_MatchFileType(Plugin *list, OSType type, const char *ext, Boolean exact);
extern Plugin *Plugins_GetPluginForFile(Plugin *list, OSType plugintype, OSType cpu, OSType os, OSType type, const char *ext, OSType lang);
extern Plugin *Plugins_GetLinker(Plugin *list, OSType cpu, OSType os);
extern Plugin *Plugins_GetPreLinker(Plugin *list, OSType cpu, OSType os);
extern Plugin *Plugins_GetPostLinker(Plugin *list, OSType cpu, OSType os);
extern Plugin *Plugins_GetParserForPlugin(Plugin *list, OSType style, int numPlugins, CLPluginInfo *plugins, OSType cpu, OSType os, int numPanels, const char **panelNames);
extern Plugin *Plugins_GetCompilerForLinker(Plugin *list, Plugin *linker, OSType type, const char *ext, OSType edit);
extern int Plugins_GetPluginList(Plugin *list, int *numPlugins, CLPluginInfo **pluginInfo);
extern int Plugins_GetPrefPanelUnion(Plugin *list, int *numPanels, const char ***panelNames);
extern int Plugin_AddFileTypeMappings(Plugin *pl, OSFileTypeMappings **mlist);
extern int Plugins_AddFileTypeMappingsForTarget(Plugin *list, OSFileTypeMappings **mlist, OSType cpu, OSType os);
extern SInt16 Plugin_Call(Plugin *pl, void *context);

/********************************/
/* Project/CLAccessPaths.c */
extern Path *Path_Init(const OSPathSpec *dir, Path *path);
extern Path *Path_New(const OSPathSpec *dir);
extern void Path_Free(Path *path);
extern Boolean Paths_Initialize(Paths *paths);
extern Boolean Paths_Terminate(Paths *paths);
extern Boolean Paths_AddPath(Paths *paths, Path *path);
extern Boolean Paths_InsertPath(Paths *paths, UInt16 index, Path *path);
extern Boolean Paths_RemovePath(Paths *paths, UInt16 index);
extern Boolean Paths_DeletePath(Paths *paths, UInt16 index);
extern Path *Paths_GetPath(Paths *paths, UInt16 pathnum);
extern UInt16 Paths_Count(const Paths *paths);
extern Boolean Paths_FindPath(const Paths *paths, const Path *path);
extern Path *Paths_FindPathSpec(const Paths *paths, const OSPathSpec *dir);
extern Boolean Paths_GatherRecurse(Path *path);
extern int Paths_CountRecurse(Paths *paths);
extern void Paths_CopyRecurseFSS(FSSpec *list, Paths *paths, UInt16 count);
extern Boolean MakeFrameworkPath(char *out, const char *filename, Path *globalpath);
extern void Frameworks_AddPath(const OSPathSpec *oss);
extern int Frameworks_AddFramework(const char *name, const char *version, Boolean hidden);
extern void Framework_GetEnvInfo(void);
extern int Frameworks_GetCount(void);
extern Paths_FWInfo *Frameworks_GetInfo(int which);

// Not sure if this is the right TU for this
extern Paths FrameworkPaths;

/********************************/
/* Project/CLFiles.c */
extern File *File_New(void);
extern void File_Free(File *file);
extern Boolean Files_Initialize(Files *);
extern Boolean Files_Terminate(Files *);
extern Boolean Files_AddFile(Files *, File *file);
extern Boolean Files_InsertFile(Files *, File *file, SInt32 position);
extern File *Files_GetFile(Files *, SInt32 filenum);
extern File *Files_FindFile(Files *, OSSpec *spec);
extern int Files_Count(Files *);
extern Boolean VFiles_Initialize(VFile **list);
extern void VFiles_Terminate(VFile **list);
extern VFile *VFile_New(const char *name, Handle data);
extern Boolean VFiles_Add(VFile **list, VFile *entry);
extern VFile *VFiles_Find(VFile *list, const char *name);

/********************************/
/* Project/CLOverlays.c */
extern Boolean Overlays_Initialize(Overlays *);
extern Boolean Overlays_Terminate(Overlays *);
extern Boolean Overlays_AddOvlGroup(Overlays *, OvlGroup *grp, SInt32 *grpnum);
extern OvlGroup *Overlays_GetOvlGroup(Overlays *, SInt32 grpnum);
extern SInt32 Overlays_CountGroups(Overlays *);
extern Boolean Overlays_AddFileToOverlay(Overlays *, SInt32 grpnum, SInt32 ovlnum, SInt32 filenum);
extern Overlay *Overlays_GetOverlayInGroup(Overlays *, SInt32 grpnum, SInt32 ovlnum);
extern SInt32 Overlays_GetFileInOverlay(Overlays *, SInt32 grpnum, SInt32 ovlnum, SInt32 filnum);
extern OvlGroup *OvlGroup_New(const char *name, OvlAddr addr);
extern void OvlGroup_Delete(OvlGroup *grp);
extern Boolean OvlGroup_AddOverlay(OvlGroup *, Overlay *oly, SInt32 *olynum);
extern Overlay *OvlGroup_GetOverlay(OvlGroup *, SInt32 olynum);
extern SInt32 OvlGroup_CountOverlays(OvlGroup *);
extern Overlay *Overlay_New(const char *name);
extern void Overlay_Delete(Overlay *oly);
extern Boolean Overlay_AddFile(Overlay *oly, SInt32 filenum, SInt32 *filnum);
extern SInt32 Overlay_GetFile(Overlay *oly, SInt32 filnum);
extern SInt32 Overlay_CountFiles(Overlay *oly);

/********************************/
/* Project/CLProj.c */
extern Boolean Proj_Initialize(Project *);
extern Boolean Proj_Terminate(Project *);

/********************************/
/* Project/CLSegs.c */
extern Segment *Segment_New(const char *name, UInt16 attrs);
extern void Segment_Free(Segment *seg);
extern Boolean Segments_Initialize(Segments *segs);
extern Boolean Segments_Terminate(Segments *segs);
extern Boolean Segments_AddSegment(Segments *segs, Segment *seg, UInt16 *index);
extern Boolean Segments_InsertSegment(Segments *segs, UInt16 index, Segment *seg);
extern Boolean Segments_DeleteSegment(Segments *segs, UInt16 index);
extern Segment *Segments_GetSegment(Segments *segs, UInt16 segnum);
extern UInt16 Segments_Count(const Segments *segs);

/********************************/
/* CLBrowser.c */
extern int Browser_Initialize(OSHandle *browsetableptr);
extern int Browser_Terminate(OSHandle *browsetableptr);
extern int Browser_SearchFile(OSHandle *browsetable, const char *fullpath, SInt16 *ID);
extern int Browser_SearchAndAddFile(OSHandle *browsetable, const char *fullpath, SInt16 *ID);
extern int Browser_PackBrowseFile(Handle browsedata, OSHandle *browsetable, OSHandle *browsefileptr);

/********************************/
/* CLDependencies.c */
extern SInt16 *CLT_filesp;
extern CPrepFileInfoStack *CLT_filestack;

extern Boolean Incls_Initialize(Incls *incls, Target *targ);
extern void Incls_Terminate(Incls *incls);
extern Boolean Incls_FindFileInPaths(Incls *incls, char *filename, Boolean fullsearch, OSSpec *spec, SInt32 *inclidx);
extern Boolean Deps_Initialize(Deps *deps, Incls *incls);
extern void Deps_Terminate(Deps *deps);
extern int Deps_ChangeSpecialAccessPath(OSSpec *srcfss, Boolean initialize);
extern Path *Deps_GetSpecialAccessPath(void);
extern void Deps_AddDependency(Deps *deps, SInt32 incl, OSSpec *spec, Boolean unk, SInt16 dependencyType, Boolean *alreadyincluded);
extern void Deps_ListDependencies(Incls *incls, File *file, OSHandle *h);

/********************************/
/* CLFileOps.c */
extern int GetOutputFile(File *file, SInt16 stage);
extern int StoreObjectFile(File *file);
extern int CompileFilesInProject(void);
extern int LinkProject(void);

/********************************/
/* CLFileTypes.c */
extern void AddFileTypeMappingList(OSFileTypeMappings **list, const OSFileTypeMappingList *entry);
extern void UseFileTypeMappings(OSFileTypeMappings *list);
extern OSErr SetMacFileType(const FSSpec *spec, OSType mactype);
extern OSErr GetMacFileType(const FSSpec *spec, OSType *mactype);

/********************************/
/* CLIncludeFileCache.c */
extern void InitializeIncludeCache(void);
extern void CleanupIncludeCache(void);
extern void CacheIncludeFile(OSSpec *spec, Handle text, Boolean precompiled);
extern Handle CachedIncludeFile(OSSpec *spec, Boolean *precompiled);
extern void FreeIncludeFile(Handle text);

/********************************/
/* CLLicenses.c */
extern void License_Initialize(void);
extern void License_Terminate(void);
extern SInt32 License_Checkout(const char *featureName, const char *licenseVersion, Boolean flag, char *errorBuf);
extern void License_Refresh(/* unknown args */);
extern void License_Checkin(/* unknown args */);
extern void License_AutoCheckin(void);

/********************************/
/* CLLoadAndCache.c */
extern short FixTextHandle(Handle txt);
extern int LoadAndCacheFile(OSSpec *spec, Handle *texthandle, Boolean *precomp);
extern void CopyFileText(Handle src, char **text, SInt32 *textsize);

/********************************/
/* CLMain.c */
extern void Main_PreParse(int *argc, char ***argv);
extern void Main_PassSpecialArgs(int *argc, char ***argv);
extern int Main_Initialize(int argc, char **argv);
extern int Main_Terminate(int code);
extern int Main_Driver(void);

/********************************/
/* CLPluginRequests.cpp */
extern Boolean SendParserRequest(
        Plugin *plugin,
        Target *target,
        CWCommandLineArgs *args,
        OSType cpu,
        OSType os,
        int numPlugins,
        CLPluginInfo *pluginInfo,
        int numPanels,
        const char **panelNames,
        CWCommandLineArgs *plugin_args,
        CWCommandLineArgs *panel_args,
        const char *build_date,
        const char *build_time,
        const ToolVersionInfo *build_tool
);
extern Boolean SendCompilerRequest(Plugin *plugin, File *file, SInt16 stage);
extern Boolean SendTargetInfoRequest(Target *targ, Plugin *linker, SInt32 dropinflags);
extern Boolean SendLinkerRequest(Plugin *plugin, SInt32 dropinflags, CWTargetInfo *targetInfo);
extern Boolean SendDisassemblerRequest(Plugin *linker, File *file);
extern Boolean SendInitOrTermRequest(Plugin *plugin, Boolean reqIsInitialize);

/********************************/
/* CLPrefs.c */
extern PrefPanel *PrefPanel_New(const char *name, void *initdata, SInt32 initdatasize);
extern Handle PrefPanel_GetHandle(PrefPanel *panel);
extern int PrefPanel_PutHandle(PrefPanel *panel, Handle data);
extern void Prefs_Initialize(void);
extern void Prefs_Terminate(void);
extern Boolean Prefs_AddPanel(PrefPanel *panel);
extern PrefPanel *Prefs_FindPanel(const char *name);

/********************************/
/* CLTarg.c */
extern Target *Target_New(const char *name, OSType cpu, OSType os, OSType lang);
extern void Target_Free(Target *targ);
extern void Targets_Term(Target *list);
extern void Target_Add(Target **list, Target *targ);

/********************************/
/* CLToolExec.c */
extern void AppendArgumentList(int *argc, char ***argv, const char *str);
extern int SetupTemporaries(void);
extern int DeleteTemporaries(void);
extern int ExecuteLinker(Plugin *plugin, SInt32 dropinflags, File *file, char *stdoutfile, char *stderrfile);

/********************************/
/* CLWriteObjectFile.c */
extern int WriteObjectFile(File *file, OSType maccreator, OSType mactype);
extern int WriteBrowseData(File *file, OSType maccreator, OSType mactype);

#ifdef __cplusplus
}
#endif

#endif