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+
13 int main(int argc, char **argv)
16 fprintf(stderr, "%s needs one argument: the structure name\n",
21 printf("/* bin2header output - automatically generated */\n");
22 printf("unsigned char %s[] = {\n", argv[1]);
26 unsigned char buf[10];
27 nread = read(0, buf, sizeof(buf));
32 for (i = 0; i < nread - 1; i++)
33 printf("0x%02x, ", buf[i]);
35 printf("0x%02x,\n", buf[nread-1]);