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
|
#include "parser.h"
Handle definesHandle;
int Opt_AddStringToDefines(const char *opt, void *str, const char *param, int flags) {
AddStringToHandle(&definesHandle, (const char *) str);
if (param)
AddStringToHandle(&definesHandle, param);
return 1;
}
int Opt_DefineSymbol(const char *var, const char *value) {
char tmp[1024];
if (pTool->LANG == Lang_C_CPP || pTool->LANG == CWFOURCHAR('A','s','m',' ') || pTool->LANG == Lang_Rez) {
sprintf(tmp, "#define %s %s\n", var, value ? value : "1");
} else if (pTool->LANG == Lang_Pascal) {
sprintf(tmp, "{$definec %s %s}\n", var, value ? value : "1");
} else {
sprintf(tmp, "Option '-D|d' is not supported with this plugin");
CLPReportError(CLPStr28_WarningText, tmp);
return 0;
}
AddStringToHandle(&definesHandle, tmp);
return 1;
}
int Opt_UndefineSymbol(const char *opt, void *, const char *arg, int flags) {
char tmp[300];
if (pTool->LANG == Lang_C_CPP || pTool->LANG == CWFOURCHAR('A','s','m',' ')) {
sprintf(tmp, "#undef %s\n", arg);
} else if (pTool->LANG == Lang_Pascal) {
sprintf(tmp, "{$undefc %s}\n", arg);
} else {
sprintf(tmp, "Option -%s is not supported with this plugin", opt);
CLPReportError(CLPStr28_WarningText, tmp);
return 0;
}
AddStringToHandle(&definesHandle, tmp);
return 1;
}
int Opt_AddPrefixFile(const char *opt, void *handle, const char *filename, int flags) {
char tmp[300];
handle = !handle ? &definesHandle : handle;
if (!filename[0])
return 1;
if (pTool->LANG == Lang_C_CPP || pTool->LANG == CWFOURCHAR('A','s','m',' ')) {
if (filename[0] == '<' && filename[strlen(filename) - 1] == '>') {
snprintf(tmp, sizeof(tmp), "#include %s\n", filename);
} else {
snprintf(tmp, sizeof(tmp), "#include \"%s\"\n", filename);
}
} else if (pTool->LANG == Lang_Pascal) {
snprintf(tmp, sizeof(tmp), "{$I+}\n{$I %s}\n{$I-}\n", filename);
} else {
sprintf(tmp, "Option -%s is not supported with this plugin", opt);
CLPReportError(CLPStr28_WarningText, tmp);
return 0;
}
AddStringToHandle((Handle *) handle, tmp);
return 1;
}
int Opt_PragmaTrueFalse(const char *, void *flag, const char *, int flags) {
if (flags & PARAMPARSEFLAGS_8)
*((unsigned char *) flag) = PR_OFF;
else
*((unsigned char *) flag) = PR_ON;
return 1;
}
int Opt_PragmaFalseTrue(const char *, void *flag, const char *, int flags) {
if (flags & PARAMPARSEFLAGS_8)
*((unsigned char *) flag) = PR_ON;
else
*((unsigned char *) flag) = PR_OFF;
return 1;
}
int Opt_PragmaOnOff(const char *, void *flag, const char *arg) {
if (!arg) {
CLPReportError(CLPStr34_ArgumentsExpected);
return 0;
}
if (!ustrcmp(arg, "on")) {
*((unsigned char *) flag) = PR_ON;
} else if (!ustrcmp(arg, "off")) {
*((unsigned char *) flag) = PR_OFF;
} else {
CLPReportError(CLPStr12, arg);
return 0;
}
return 1;
}
int Opt_PragmaOffOn(const char *, void *flag, const char *arg) {
if (!arg) {
CLPReportError(CLPStr34_ArgumentsExpected);
return 0;
}
if (!ustrcmp(arg, "on")) {
*((unsigned char *) flag) = PR_OFF;
} else if (!ustrcmp(arg, "off")) {
*((unsigned char *) flag) = PR_ON;
} else {
CLPReportError(CLPStr12, arg);
return 0;
}
return 1;
}
int SetupPragmas(const Pragma *pragmas) {
const char *set;
char on;
char off;
char tmp[300];
while (pragmas->pragma) {
if (pragmas->flags == PRAGMA_FLAGS_0 || pragmas->flags == PRAGMA_FLAGS_1) {
set = 0;
on = !(pragmas->flags == PRAGMA_FLAGS_1) ? PR_ON : PR_OFF;
off = !(pragmas->flags == PRAGMA_FLAGS_1) ? PR_OFF : PR_ON;
if (*((char *)pragmas->value) == on)
set = "on";
else if (*((char *)pragmas->value) == off)
set = "off";
else if (*((char *)pragmas->value) == PR_AUTO)
set = "auto";
else if (*((char *)pragmas->value) == PR_RESET)
set = "reset";
else
OS_ASSERT(186, *((char *)pragmas->value) == PR_UNSET);
if (set) {
snprintf(tmp, sizeof(tmp), "#pragma %s %s\n", pragmas->pragma, set);
AddStringToHandle(&definesHandle, tmp);
}
} else {
OS_ASSERT(195, !"Can't handle pragma");
}
pragmas++;
}
return 1;
}
|