36 char **macroTag,
char **macroValue,
long macros) {
39 char *version1 = NULL, *version2 = NULL;
40 if (!(buffer = malloc(
sizeof(*buffer) * buflen)))
41 bomb(
"memory allocation failure doing macro substitution", NULL);
42 for (i = 0; i < macros; i++) {
44 if (!(version1 = malloc(
sizeof(*version1) * (strlen(macroTag[i]) + 10))) ||
45 !(version2 = malloc(
sizeof(*version2) * (strlen(macroTag[i]) + 10))))
46 bomb(
"memory allocation failure doing macro substitution", NULL);
48 if (!(version1 = realloc(version1,
sizeof(*version1) * (strlen(macroTag[i]) + 10))) ||
49 !(version2 = realloc(version2,
sizeof(*version2) * (strlen(macroTag[i]) + 10))))
50 bomb(
"memory allocation failure doing macro substitution", NULL);
52 sprintf(version1,
"<%s>", macroTag[i]);
53 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.