aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAndrew Hannam <andrewh@inmarket.com.au>2013-04-04 21:01:06 +1000
committerAndrew Hannam <andrewh@inmarket.com.au>2013-04-04 21:01:06 +1000
commit3473ad8820fe80c027acfec76f546d321ef01045 (patch)
treeef1602329076c0260a3bb5315cf67d944ffdaa33 /tools
parentce9b930af0d242bfc61579f4b9badba7d04c5c8e (diff)
downloaduGFX-3473ad8820fe80c027acfec76f546d321ef01045.tar.gz
uGFX-3473ad8820fe80c027acfec76f546d321ef01045.tar.bz2
uGFX-3473ad8820fe80c027acfec76f546d321ef01045.zip
file2c copyright and add comment to output
Diffstat (limited to 'tools')
-rw-r--r--tools/file2c/Binaries - Win32/file2c.exebin9216 -> 9728 bytes
-rw-r--r--tools/file2c/Source/VS 2012 Project/file2c.v11.suobin25600 -> 25600 bytes
-rw-r--r--tools/file2c/Source/file2c.c48
3 files changed, 44 insertions, 4 deletions
diff --git a/tools/file2c/Binaries - Win32/file2c.exe b/tools/file2c/Binaries - Win32/file2c.exe
index d1959ad6..333b1138 100644
--- a/tools/file2c/Binaries - Win32/file2c.exe
+++ b/tools/file2c/Binaries - Win32/file2c.exe
Binary files differ
diff --git a/tools/file2c/Source/VS 2012 Project/file2c.v11.suo b/tools/file2c/Source/VS 2012 Project/file2c.v11.suo
index 586b2c04..38fa846c 100644
--- a/tools/file2c/Source/VS 2012 Project/file2c.v11.suo
+++ b/tools/file2c/Source/VS 2012 Project/file2c.v11.suo
Binary files differ
diff --git a/tools/file2c/Source/file2c.c b/tools/file2c/Source/file2c.c
index d2b862e6..bf726cdf 100644
--- a/tools/file2c/Source/file2c.c
+++ b/tools/file2c/Source/file2c.c
@@ -1,3 +1,22 @@
+/*
+ ChibiOS/GFX - Copyright (C) 2012, 2013
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/GFX is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
@@ -26,7 +45,7 @@ static char *filenameof(char *fname) {
static char *clean4c(char *fname) {
char *p;
- while((p = strpbrk(fname, "-+ `~!@#$%^&*(){}[]|:;'\",<>?/|="))) *p = '_';
+ while((p = strpbrk(fname, "-+ `~!@#$%^&*(){}[]|:;'\",<>?/|=.\\"))) *p = '_';
return fname;
}
@@ -46,7 +65,7 @@ size_t len;
size_t i;
/* Default values for our parameters */
- opt_progname = argv[0];
+ opt_progname = filenameof(argv[0]);
opt_inputfile = 0;
opt_outputfile = 0;
opt_arrayname = 0;
@@ -59,6 +78,7 @@ size_t i;
if (argv[0][0] == '-') {
while (*++(argv[0])) {
switch(argv[0][0]) {
+ case '?': case 'h': goto usage;
case 'b': opt_breakblocks = 1; break;
case 'c': opt_const = "const "; break;
case 's': opt_static = "static "; break;
@@ -77,6 +97,7 @@ size_t i;
fprintf(stderr, "Usage:\n\t%s -?\n"
"\t%s [-bs] [-n name] [inputfile] [outputfile]\n"
"\t\t-?\tThis help\n"
+ "\t\t-h\tThis help\n"
"\t\t-b\tBreak the arrays for compilers that won't handle large arrays\n"
"\t\t-c\tDeclare the arrays as const (useful to ensure they end up in Flash)\n"
"\t\t-s\tDeclare the arrays as static\n"
@@ -116,14 +137,33 @@ size_t i;
} else
f_output = stdout;
- /* Set the array name */
+ /* Print the comment header */
+ fprintf(f_output, "/**\n * This file was generated ");
+ if (opt_inputfile) fprintf(f_output, "from \"%s\" ", opt_inputfile);
+ fprintf(f_output, "using...\n *\n *\t%s", opt_progname);
+ if (opt_arrayname || opt_static[0] || opt_const[0] || opt_breakblocks) {
+ fprintf(f_output, " -");
+ if (opt_breakblocks) fprintf(f_output, "b");
+ if (opt_const[0]) fprintf(f_output, "c");
+ if (opt_static[0]) fprintf(f_output, "s");
+ if (opt_arrayname) fprintf(f_output, "n %s", opt_arrayname);
+ }
+ if (opt_inputfile) fprintf(f_output, " %s", opt_inputfile);
+ if (opt_outputfile) fprintf(f_output, " %s", opt_outputfile);
+ fprintf(f_output, "\n *\n */\n");
+
+ /*
+ * Set the array name.
+ * We do this after printing opt_inputfile for the last time as we
+ * modify opt_inputfile in place to generate opt_arrayname.
+ */
if (!opt_arrayname) {
if (opt_inputfile)
opt_arrayname = filenameof(opt_inputfile);
if (!opt_arrayname || !opt_arrayname[0])
opt_arrayname = "filearray";
- opt_arrayname = clean4c(opt_arrayname);
}
+ opt_arrayname = clean4c(opt_arrayname);
/* Read the file processing 1K at a time */
blocknum = 0;