summaryrefslogtreecommitdiff
path: root/sound/oss/bin2hex.c
diff options
context:
space:
mode:
authorAndré Fabian Silva Delgado <emulatorman@parabola.nu>2015-08-05 17:04:01 -0300
committerAndré Fabian Silva Delgado <emulatorman@parabola.nu>2015-08-05 17:04:01 -0300
commit57f0f512b273f60d52568b8c6b77e17f5636edc0 (patch)
tree5e910f0e82173f4ef4f51111366a3f1299037a7b /sound/oss/bin2hex.c
Initial import
Diffstat (limited to 'sound/oss/bin2hex.c')
-rw-r--r--sound/oss/bin2hex.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/sound/oss/bin2hex.c b/sound/oss/bin2hex.c
new file mode 100644
index 000000000..b59109eb0
--- /dev/null
+++ b/sound/oss/bin2hex.c
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int main( int argc, const char * argv [] )
+{
+ const char * varname;
+ int i = 0;
+ int c;
+ int id = 0;
+
+ if(argv[1] && strcmp(argv[1],"-i")==0)
+ {
+ argv++;
+ argc--;
+ id=1;
+ }
+
+ if(argc==1)
+ {
+ fprintf(stderr, "bin2hex: [-i] firmware\n");
+ exit(1);
+ }
+
+ varname = argv[1];
+ printf( "/* automatically generated by bin2hex */\n" );
+ printf( "static unsigned char %s [] %s =\n{\n", varname , id?"__initdata":"");
+
+ while ( ( c = getchar( ) ) != EOF )
+ {
+ if ( i != 0 && i % 10 == 0 )
+ printf( "\n" );
+ printf( "0x%02lx,", c & 0xFFl );
+ i++;
+ }
+
+ printf( "};\nstatic int %sLen = %d;\n", varname, i );
+ return 0;
+}