xref: /haiku/src/tools/misc/bin2h.c (revision c7b36669c29f503b39086ddcbd0c7de43230ca75)
1 /*
2 ** Copyright 2001, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
4 */
5 #include <stdio.h>
6 #include <stdlib.h>
7 
8 #define NUM_COLUMNS 16
9 
main(int argc,char ** argv)10 int main(int argc, char **argv)
11 {
12 	FILE *infp = stdin;
13 	char c;
14 	int column = 0;
15 
16 	while(!feof(infp)) {
17 		int err;
18 		err = fread(&c, sizeof(c), 1, infp);
19 		if(err != 1)
20 			break;
21 
22 		printf("0x%02x,", ((int)c) & 0xff);
23 		if((++column % NUM_COLUMNS) == 0) {
24 			printf("\n");
25 		}
26 	}
27 
28 	return 0;
29 }
30 
31