summaryrefslogtreecommitdiff
path: root/command_line/C++_Parser/Src/Library/IO.c
blob: 0ce74df15eb4e0959f3720188a662f4a08e68170 (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
#include "parser.h"

void ShowTextHandle(const char *description, Handle text) {
    CWMemHandle mh;

    if (!text)
        return;

    if (description)
        CLPStatus(CLPStr71, description);
    CWSecretAttachHandle(parseopts.context, text, &mh);
    CWParserDisplayTextHandle(parseopts.context, description, mh);
}

void ShowVersion(Boolean decorate) {
    char *vplugin;
    char *valtplugin;
    const char *bdate;
    const char *btime;
    Handle txt;
    int x;

    vplugin = 0;
    valtplugin = 0;
    if (parseopts.printedVersion)
        return;

    txt = NewHandle(0);
    if (!txt) {
        fprintf(stderr, "\n*** Out of memory\n");
        exit(-23);
    }

    for (x = 0; x < parseopts.numPlugins; x++) {
        if (parseopts.plugins[x].plugintype == CWDROPINDRIVERTYPE) continue;
        if (parseopts.plugins[x].plugintype == CWDROPINPARSERTYPE) continue;

        if (pTool->TYPE == parseopts.plugins[x].plugintype) {
            if (!vplugin && pTool->LANG == parseopts.plugins[x].language)
                vplugin = parseopts.plugins[x].version;
            else
                valtplugin = parseopts.plugins[x].version;
        }
    }

    CWParserGetBuildDate(parseopts.context, &bdate, &btime);
    HPrintF(txt, "\n");
    if (parseopts.toolVersion) {
        HPrintF(
                txt,
                "%s.\n%s, %s\nAll rights reserved.\n%s\n",
                pTool->toolInfo,
                parseopts.toolVersion->copyright,
                parseopts.toolVersion->company,
                parseopts.toolVersion->version
                );
    } else {
        HPrintF(
                txt,
                "%s.\nCopyright (c)%s Metrowerks, Inc.\nAll rights reserved.\n%s\n",
                pTool->toolInfo,
                pTool->copyright,
                vplugin ? vplugin : valtplugin ? valtplugin : ""
                );
    }

    HPrintF(txt, "Runtime Built: %s %s\n", bdate, btime);
    HPrintF(txt, "\n");

    if (decorate) {
        HPrintF(
                txt,
                "Please enter '%s %chelp' for information about options.\n\n",
                OS_GetFileNamePtr(parseopts.args->argv[0]),
                MAINOPTCHAR[0]
                );
    }

    ShowTextHandle(0, txt);
    DisposeHandle(txt);

    parseopts.printedVersion = 1;
}