1 /* bin2header.c - program to convert binary file into a C structure
2 * definition to be included in a header file.
4 * (C) Copyright 2008 by Harald Welte <laforge@openmoko.org>
6 * SPDX-License-Identifier: GPL-2.0+
12 int main(int argc, char **argv)
15 fprintf(stderr, "%s needs one argument: the structure name\n",
20 printf("/* bin2header output - automatically generated */\n");
21 printf("unsigned char %s[] = {\n", argv[1]);
25 unsigned char buf[10];
26 nread = read(0, buf, sizeof(buf));
31 for (i = 0; i < nread - 1; i++)
32 printf("0x%02x, ", buf[i]);
34 printf("0x%02x,\n", buf[nread-1]);