X-Git-Url: https://git.ti.com/gitweb?p=keystone-rtos%2Fmcsdk-tools.git;a=blobdiff_plain;f=hfile2array%2Fhfile2array.c;h=a6d7a5b06254f39e88d26f176a6c020163a6a57f;hp=19e658d452b91b5a5dd04a516fa6213fe1eb86d8;hb=3885044fafd0450482675efeefa0eefac66ee49d;hpb=cacac223050597dffd7154eb8fe496a48d9c59cc diff --git a/hfile2array/hfile2array.c b/hfile2array/hfile2array.c index 19e658d..a6d7a5b 100644 --- a/hfile2array/hfile2array.c +++ b/hfile2array/hfile2array.c @@ -43,8 +43,9 @@ int main(int argc, char **argv) { - FILE *out, *in; + FILE *out, *in, *in_hdr; char line[200] = "uint8_t "; + char line_hdr[200]; if (argc != 4) { @@ -68,12 +69,38 @@ int main(int argc, char **argv) printf ("Can not open %s\n", *argv[1]); return (-1); } + + in_hdr = fopen("header.txt", "rt"); + + if (in_hdr == NULL) + { + printf ("Can not open header.tx\n"); + return (-1); + } + + while (1) + { + if (fgets(line_hdr, 200, in_hdr) != NULL) + { + if (fputs(line_hdr, out) != 0) + { + printf ("fputs %s error\n", line_hdr); + goto error; + } + } + else + { + /* EOF reached */ + break; + } + } + strcat (line, (const char *)(*argv++)); strcat (line, "[] = {\n"); if (fputs(line, out) != 0) { - printf ("fputs %s error\n", fputs); + printf ("fputs %s error\n", line); goto error; } @@ -101,12 +128,14 @@ int main(int argc, char **argv) } fclose(in); + fclose(in_hdr); fclose(out); return 0; error: fclose(in); + fclose(in_hdr); fclose(out); return (-1);