// Copyright Naoki Shibata and contributors 2010 - 2021. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include #include #include #include #define CONFIGMAX 4 char *replaceAll(const char *in, const char *pat, const char *replace) { const int replaceLen = (int)strlen(replace); const int patLen = (int)strlen(pat); char *str = malloc(strlen(in)+1); strcpy(str, in); for(;;) { char *p = strstr(str, pat); if (p == NULL) return str; int replace_pos = (int)(p - str); int tail_len = (int)strlen(p + patLen); char *newstr = malloc(strlen(str) + (replaceLen - patLen) + 1); memcpy(newstr, str, replace_pos); memcpy(newstr + replace_pos, replace, replaceLen); memcpy(newstr + replace_pos + replaceLen, str + replace_pos + patLen, tail_len+1); free(str); str = newstr; } return str; } #define LEN 1024 char line[LEN+10]; int main(int argc, char **argv) { if (argc < 2) { fprintf(stderr, "Usage : %s ...\n", argv[0]); exit(-1); } const char *baseType = argv[1]; const int isastart = 2; for(int config=0;config