File: bin2c.c

package info (click to toggle)
rat 4.2.22-2.2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,896 kB
  • ctags: 3,717
  • sloc: ansic: 36,542; tcl: 2,740; sh: 2,675; makefile: 295
file content (42 lines) | stat: -rw-r--r-- 741 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * FILE:    bin2c.c
 * PROGRAM: bin2c
 * AUTHOR:  Colin Perkins
 * 
 * Copyright (c) 2000-2001 University College London
 * All rights reserved.
 */

#include "config_unix.h"
#include "debug.h"
#include "assert.h"

#ifdef WIN32
#error This program is only needed on unix - use InstallShield on windows
#endif

int main(int argc, char *argv[])
{
	FILE 	*inf;
	int	 c, l;

	assert(argc == 2);
	inf = fopen(argv[1], "r");
	c = fgetc(inf);
	l = 1;
	printf("char encoded_binaries[] = \"\\x%02x", c);
	while (1) {
		c = fgetc(inf);
		if (feof(inf)) {
			break;
		}
		printf("\\x%02x", c);
		l++;
	}
	printf("\";\n");
	printf("int encoded_length = %d;\n", l);
	printf("char encoded_filename[] = \"%s\";\n", argv[1]);
	fclose(inf);
	return 0;
}