summaryrefslogtreecommitdiff
path: root/command_line/CmdLine/Src/Clients/CLStaticMain.c
blob: 77910feac348786b4715ada6e0d65b094053c0d5 (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
#include "cmdline.h"

extern const char *CMDLINE_BUILD_TIME;
extern const char *CMDLINE_BUILD_DATE;

// Glue functions
extern int RegisterStaticParserPlugins(void);
extern int RegisterStaticParserResources(void);

extern void GetStaticTarget(OSType *cpu, OSType *os);
extern void GetStaticPluginType(OSType *language, OSType *plugintype);
extern void GetStaticParserPluginType(OSType *style);
extern int RegisterStaticTargetResources(void);
extern int RegisterStaticTargetPlugins(void);

extern int RegisterStaticParserToolInfo(void);

int main(int argc, char **argv) {
    OSType cpu;
    OSType os;
    OSType lang;
    OSType type;
    OSType style;
    int ret;

    if (CmdLine_Initialize(argc, argv, CMDLINE_BUILD_DATE, CMDLINE_BUILD_TIME))
        exit(1);

    if (!RegisterStaticParserResources() || !RegisterStaticTargetResources()) {
        fprintf(stderr, "\nFATAL ERROR:  Could not initialize resource strings\n");
        exit(1);
    }

    if (!RegisterStaticParserPlugins() || !RegisterStaticTargetPlugins()) {
        fprintf(stderr, "\nFATAL ERROR:  Could not initialize built-in plugins\n");
        exit(1);
    }

    if (!RegisterStaticParserToolInfo()) {
        fprintf(stderr, "\nFATAL ERROR:  Could not initialize options\n");
        exit(1);
    }

    GetStaticTarget(&cpu, &os);
    SetBuildTarget(cpu, os);
    GetStaticPluginType(&lang, &type);
    SetPluginType(lang, type);
    GetStaticParserPluginType(&style);
    SetParserType(style);

    ret = CmdLine_Driver();
    if (ret) {
        if (ret == 2)
            fprintf(stderr, "\nUser break, cancelled...\n");
        else
            fprintf(stderr, "\nErrors caused tool to abort.\n");
    }
    CmdLine_Terminate(ret);
    return ret;
}