about summary refs log blame commit diff
path: root/src/bin2c/bin2c.c
blob: 5ed8a57082fdaae6f541b2aa5e1c69b3c1c7b1c3 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16















                                         
                                                     


                                             
                    

             
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>

void print(const char *format, ...)
{
    va_list ap;
    va_start(ap, format);
    if (vprintf(format, ap) < 0) abort();
    va_end(ap);
}

int main(int argc, char * * argv)
{
    int c;
    if (argc != 2) abort();
    print("static unsigned char %s[] = { ", argv[1]);
    while ((c = getchar()) != EOF) {
        print("0x%02x, ", (unsigned char) c);
    }
    print("0 };\n");
    return 0;
}