aboutsummaryrefslogtreecommitdiff
path: root/src/helper/bin2char.c
diff options
context:
space:
mode:
authorPaul Fertser <fercerpav@gmail.com>2014-05-11 22:15:55 +0400
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>2014-08-02 09:00:28 +0000
commitf1b04a20dcf6baedbd0f06a38d8748586d48dbb7 (patch)
treee1e55a4334058d337a7345c3709d1c6f52a2503d /src/helper/bin2char.c
parente03eb89cfb7ee7a952bf8536ae1a4e7f2087d766 (diff)
Provide od+sed replacement for the bin2char helper
Using custom build-time tools is always more problematic, especially for cross-compiling. This alternative implementation assumes "od" (IEEE Std 1003.1-2001) and sed are available which should be the case for any reasonably modern system. Change-Id: I0208f475648c78e7dca127ff4bab60d314b2bf53 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/2139 Tested-by: jenkins Reviewed-by: Fatih Aşıcı <fatih.asici@gmail.com> Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Diffstat (limited to 'src/helper/bin2char.c')
-rw-r--r--src/helper/bin2char.c58
1 files changed, 0 insertions, 58 deletions
diff --git a/src/helper/bin2char.c b/src/helper/bin2char.c
deleted file mode 100644
index d5fe7f30..00000000
--- a/src/helper/bin2char.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 by Dominic Rath *
- * Dominic.Rath@gmx.de *
- * *
- * This program 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 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program 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, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
- ***************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifdef _WIN32
- #include <fcntl.h>
-#endif
-
-int main(int argc, char **argv)
-{
- int c;
- unsigned int n;
- const char *name;
-
- if (argc == 1) {
- fprintf(stderr, "bin2char <varname>\n");
- fprintf(stderr, "read from standard input and write a char"
- " array out to standard output\n");
- exit(1);
- }
-
-#ifdef _WIN32
- /* for win32 set stdin/stdout to binary mode */
- _setmode(_fileno(stdin), _O_BINARY);
- _setmode(_fileno(stdout), _O_BINARY);
-#endif
-
- n = 0;
- name = argv[1];
- fprintf(stdout, "/* autogenerated from %s */\n", argv[0]);
- fprintf(stdout, "unsigned const char %s[] = {\n", name);
- while ((c = getc(stdin)) != EOF) {
- fprintf(stdout, "0x%02x,", c & 0xff);
- if ((++n % 16) == 0)
- fprintf(stdout, "\n");
- }
- fprintf(stdout, "0 /* terminate with a null */};\n");
- return 0;
-}