summaryrefslogtreecommitdiff
path: root/tutorials/sndkit/sblive/mkheader.c
diff options
context:
space:
mode:
Diffstat (limited to 'tutorials/sndkit/sblive/mkheader.c')
-rw-r--r--tutorials/sndkit/sblive/mkheader.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/tutorials/sndkit/sblive/mkheader.c b/tutorials/sndkit/sblive/mkheader.c
new file mode 100644
index 0000000..4081a56
--- /dev/null
+++ b/tutorials/sndkit/sblive/mkheader.c
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int
+main (int argc, char *argv[])
+{
+ unsigned char buffer[1024];
+ int i, l, n = 0;
+
+ if (argc != 2)
+ {
+ fprintf (stderr, "Bad usage\n");
+ exit (-1);
+ }
+
+ printf ("static unsigned char %s[] =\n", argv[1]);
+ printf ("{\n");
+
+ while ((l = read (0, buffer, sizeof (buffer))) > 0)
+ {
+ for (i = 0; i < l; i++)
+ {
+ if (n > 0)
+ printf (", ");
+
+ if (n && (n % 16) == 0)
+ printf ("\n");
+ printf ("0x%02x", buffer[i]);
+ n++;
+ }
+ }
+
+ printf ("\n};\n");
+
+ exit (0);
+}