100 std::string substitutionName;
101 char *templateName = 0;
102 bool localScope =
true;
104 inputConstruct(&inputPvt);
106 while ((argc > 1) && (argv[1][0] ==
'-')) {
107 int narg = (strlen(argv[1]) == 2) ? 2 : 1;
108 pval = (narg == 1) ? (argv[1] + 2) : argv[2];
110 if (strncmp(argv[1],
"-I", 2) == 0) {
111 inputAddPath(inputPvt, pval);
113 else if (strcmp(argv[1],
"-D") == 0) {
117 else if(strncmp(argv[1],
"-o", 2) == 0) {
120 else if(strncmp(argv[1],
"-M", 2) == 0) {
121 addMacroReplacements(macPvt, pval);
123 else if(strncmp(argv[1],
"-S", 2) == 0) {
124 substitutionName = pval;
126 else if (strcmp(argv[1],
"-V") == 0) {
130 else if (strcmp(argv[1],
"-g") == 0) {
134 else if (strcmp(argv[1],
"-h") == 0) {
138 fprintf(
stderr,
"msi: Bad argument \"%s\"\n", argv[1]);
143 for (
int i = 1;
i < argc;
i++)
144 argv[
i] = argv[
i + narg];
151 fprintf(
stderr,
"msi: Too many arguments\n");
157 fprintf(
stderr,
"msi: Option -D requires -o for Makefile target\n");
162 else if (outFile && freopen(outFile,
"w",
stdout) ==
NULL) {
163 fprintf(
stderr,
"msi: Can't open %s for writing: %s\n",
164 outFile, strerror(errno));
171 if (substitutionName.empty()) {
172 STEP(
"Single template+substitutions file");
173 makeSubstitutions(inputPvt, macPvt, templateName);
178 bool isGlobal, isFile;
180 STEPS(
"Substitutions from file", substitutionName.c_str());
181 substituteOpen(&substitutePvt, substitutionName);
183 isGlobal = substituteGetGlobalSet(substitutePvt);
185 STEP(
"Handling global macros");
186 const char *macStr = substituteGetGlobalReplacements(substitutePvt);
188 addMacroReplacements(macPvt, macStr);
190 else if ((isFile = substituteGetNextSet(substitutePvt, &filename))) {
192 filename = templateName;
194 fprintf(
stderr,
"msi: No template file\n");
198 STEPS(
"Handling template file", filename);
200 while ((macStr = substituteGetReplacements(substitutePvt))) {
204 addMacroReplacements(macPvt, macStr);
205 makeSubstitutions(inputPvt, macPvt, filename);
211 }
while (isGlobal || isFile);
212 substituteDestruct(substitutePvt);
216 inputDestruct(inputPvt);
Macro substitution context, for use by macLib routines only.
void epicsStdCall macSuppressWarning(MAC_HANDLE *handle, int suppress)
Disable or enable warning messages.
char * epicsStrDup(const char *s)
long epicsStdCall macDeleteHandle(MAC_HANDLE *handle)
Marks a handle invalid, and frees all storage associated with it.
long epicsStdCall macPopScope(MAC_HANDLE *handle)
Retrieve the last pushed scope (like stack operations)
long epicsStdCall macCreateHandle(MAC_HANDLE **pHandle, const char *pairs[])
Creates a new macro substitution context.
long epicsStdCall macPushScope(MAC_HANDLE *handle)
Marks the start of a new scoping level.