summaryrefslogtreecommitdiff
path: root/scripts/bin2sql.c
blob: 4f83dd3f2f4a4147543d1ef0320b317a364b2a75 (plain)
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

#include <stdio.h>

/**
 * convert standard input to SQL hex binary
 */
int main(int argc, char *argv[])
{
	int end = 0;
	unsigned char byte;

	printf("X'");
	while (1)
	{
		if (fread(&byte, 1, 1, stdin) != 1)
		{
			end = 1;
			break;
		}
		printf("%02x", (unsigned int)byte);
	}	
	printf("'\n");
	return 0;
}