Author: Ben Hutchings Description: Add makefw -b option to enable binary output Bug-Debian: http://bugs.debian.org/693666 We can't compile these bitfiles into the drivers in the free dahdi-source package. Add the -b option to write a binary instead of a C array. --- --- a/drivers/dahdi/makefw.c +++ b/drivers/dahdi/makefw.c @@ -1,6 +1,7 @@ /* Xilinx firmware convertor program. * * Written by Jim Dixon . + * Binary output added by Ben Hutchings . * * Copyright (C) 2001 Jim Dixon / Zapata Telephony. * Copyright (C) 2001-2008 Digium, Inc. @@ -34,10 +35,12 @@ FILE *fp; int i,j,nbytes; unsigned char c; char buf[300]; +int bin; if (argc < 3) { puts("Usage... makefw filename.rbt array_name"); + puts(" makefw filename.rbt -b"); exit(1); } @@ -47,8 +50,10 @@ char buf[300]; perror("bit file open"); exit(1); } + bin = !strcmp(argv[2], "-b"); nbytes = 0; - printf("static unsigned char %s[] = {\n",argv[2]); + if (!bin) + printf("static unsigned char %s[] = {\n",argv[2]); i = 0; while(fgets(buf,sizeof(buf) - 1,fp)) { @@ -66,17 +71,22 @@ char buf[300]; if ((j & 7) == 7) { nbytes++; - if (i) printf(","); - printf("0x%02x",c); - if (i++ == SWATH) { - printf(",\n"); - i = 0; + if (bin) { + putchar(c); + } else { + if (i) printf(","); + printf("0x%02x",c); + if (i++ == SWATH) { + printf(",\n"); + i = 0; + } } c = 0; } } } - printf("\n};\n\n"); + if (!bin) + printf("\n};\n\n"); fprintf(stderr,"Loaded %d bytes from file\n",nbytes); fclose(fp); exit(0);