#include #include #include #define ZF_LOGD(...) #include "utils.h" int read_file(const char *filename) { FILE *fp; char buffer[10240]; int read; fp = fopen(filename, "rb"); if (fp == NULL) { ZF_LOGD("Failed to open %s", filename); return 0; } { const char *ccp = filename; while (strchr(ccp, '/') != NULL) ccp = strchr(ccp, '/') + 1; strcpy(buffer, ccp); } char *cp; if ((cp = strchr(buffer, '.')) != NULL) { *cp = 0; } cp = buffer; while (*cp != 0) { if (!isalpha(*cp)) memmove(cp, cp + 1, strlen(cp)); cp++; } printf("const char * %s[] = {\n", buffer); if ((read = fread(buffer, 1, sizeof(buffer), fp)) > 0) { char *nl; buffer[read] = 0; cp = repr(buffer); int first = 1; while ((nl = strstr(cp, "\\r\\n")) != NULL) { strcpy(nl, "\""); if (!first) { printf(",\n"); }; first = 0; printf(" \"%s", cp); cp = nl + 4; } if (strlen(cp) > 0) printf(",\n \"%s\"\n", cp); else printf("\n"); printf("};\n"); }; fclose(fp); return 1; } int main(int argc, char *argv[]) { for (int pos = 1; pos < argc; ++pos) { read_file(argv[pos]); } return 0; }