Changeset 3294 in MondoRescue for branches/3.2/mondo/src/lib/mr_str.c
- Timestamp:
- Jun 3, 2014, 8:20:52 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mondo/src/lib/mr_str.c
r3194 r3294 194 194 } 195 195 196 char *mr_str_substitute(const char *in, const char *token, const char *subst) { 197 198 char *output = NULL; 199 char *tmp = NULL; 200 int i = 0; 201 202 mr_asprintf(output, "%s", in); 203 tmp = strstr(output, token); 204 if (tmp == NULL) { 205 // token not found returning initial string unmodified 206 return(output); 207 } 208 // token found end string here for now 209 *tmp = '\0'; 210 211 // Add subst content to the string 212 mr_strcat(output,subst); 213 214 // now add the rest of in 215 tmp = strstr(in, token); 216 for (; i < strlen(token) ; i++) { 217 tmp++; 218 } 219 mr_strcat(output,tmp); 220 return(output); 221 } 222 196 223 197 224 /*
Note:
See TracChangeset
for help on using the changeset viewer.