From bafe269d8ecea8a32155329b1edd2ee6f0ecc06e Mon Sep 17 00:00:00 2001 From: Ralf Corsepius Date: Thu, 29 Jul 2010 17:12:38 +0000 Subject: =?UTF-8?q?2010-07-29=09Ralf=20Cors=C3=A9pius=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * rtems-bin2c.c: Add -C and -H options. --- tools/build/ChangeLog | 4 ++++ tools/build/rtems-bin2c.c | 37 ++++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 7 deletions(-) (limited to 'tools') diff --git a/tools/build/ChangeLog b/tools/build/ChangeLog index cb559b66ee..06f46a69c9 100644 --- a/tools/build/ChangeLog +++ b/tools/build/ChangeLog @@ -1,3 +1,7 @@ +2010-07-29 Ralf Corsépius + + * rtems-bin2c.c: Add -C and -H options. + 2010-03-12 Joel Sherrill * eolstrip.c: Readdress use of ctype methods per recommendation from diff --git a/tools/build/rtems-bin2c.c b/tools/build/rtems-bin2c.c index 193ee2385b..b8e39e8090 100644 --- a/tools/build/rtems-bin2c.c +++ b/tools/build/rtems-bin2c.c @@ -38,6 +38,8 @@ int useconst = 1; int usestatic = 0; int verbose = 0; int zeroterminated = 0; +int createC = 1; +int createH = 1; int myfgetc(FILE *f) { @@ -91,18 +93,23 @@ void process(const char *ifname, const char *ofname) fprintf(stderr, "cannot open %s for reading\n", ifname); exit(1); } + + if ( createC ) { ocfile = fopen(ocname, "wb"); if (ocfile == NULL) { fprintf(stderr, "cannot open %s for writing\n", ocname); exit(1); } - + } + + if ( createH ) { ohfile = fopen(ohname, "wb"); if (ohfile == NULL) { fprintf(stderr, "cannot open %s for writing\n", ohname); exit(1); } - + } + /* find basename */ if ((cp = strrchr(ifname, '/')) != NULL) ++cp; @@ -117,6 +124,7 @@ void process(const char *ifname, const char *ofname) if (!isalnum(*p)) *p = '_'; + if ( createC ) { /* print C file header */ fprintf( ocfile, @@ -161,11 +169,13 @@ void process(const char *ifname, const char *ofname) buf, buf ); - + } /* createC */ + /*****************************************************************/ /****** END OF C FILE *****/ /*****************************************************************/ + if ( createH ) { /* print H file header */ fprintf( ohfile, @@ -208,21 +218,22 @@ void process(const char *ifname, const char *ofname) "\n" "#endif\n" ); - + } /* createH */ + /*****************************************************************/ /****** END OF H FILE *****/ /*****************************************************************/ fclose(ifile); - fclose(ocfile); - fclose(ohfile); + if ( createC ) { fclose(ocfile); } + if ( createH ) { fclose(ohfile); } } void usage(void) { fprintf( stderr, - "usage: bin2c [-csvz] \n" + "usage: bin2c [-csvzCH] \n" " is the binary file to convert\n" " should not have a .c or .h extension\n" "\n" @@ -230,6 +241,8 @@ void usage(void) " -s - do use static in declaration\n" " -v - verbose\n" " -z - add zero terminator\n" + " -H - create c-header only\n" + " -C - create c-source file only\n" ); exit(1); } @@ -253,6 +266,16 @@ int main(int argc, char **argv) zeroterminated = 1; --argc; ++argv; + } else if (!strcmp(argv[1], "-C")) { + createH = 0; + createC = 1; + --argc; + ++argv; + } else if (!strcmp(argv[1], "-H")) { + createC = 0; + createH = 1; + --argc; + ++argv; } else { usage(); } -- cgit v1.2.3