35 char **macroTag,
char **macroValue,
long macros) {
38 char *version1 = NULL, *version2 = NULL;
39 if (!(buffer = malloc(
sizeof(*buffer) * buflen)))
40 bomb(
"memory allocation failure doing macro substitution", NULL);
41 for (i = 0; i < macros; i++) {
43 if (!(version1 = malloc(
sizeof(*version1) * (strlen(macroTag[i]) + 10))) ||
44 !(version2 = malloc(
sizeof(*version2) * (strlen(macroTag[i]) + 10))))
45 bomb(
"memory allocation failure doing macro substitution", NULL);
47 if (!(version1 = realloc(version1,
sizeof(*version1) * (strlen(macroTag[i]) + 10))) ||
48 !(version2 = realloc(version2,
sizeof(*version2) * (strlen(macroTag[i]) + 10))))
49 bomb(
"memory allocation failure doing macro substitution", NULL);
51 sprintf(version1,
"<%s>", macroTag[i]);
52 sprintf(version2,
"$%s", macroTag[i]);
int replace_string(char *t, char *s, char *orig, char *repl)
Replace all occurrences of one string with another string.
void substituteTagValue(char *input, long buflen, char **macroTag, char **macroValue, long macros)
Replaces macro tags in the input string with their corresponding values.