summaryrefslogtreecommitdiff
path: root/tutorials/sndkit/sblive/mkheader.c
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2013-05-03 21:08:42 +0400
committerIgor Pashev <pashev.igor@gmail.com>2013-05-03 21:08:42 +0400
commit1058def8e7827e56ce4a70afb4aeacb5dc44148f (patch)
tree4495d23e7b54ab5700e3839081e797c1eafe0db9 /tutorials/sndkit/sblive/mkheader.c
downloadoss4-upstream.tar.gz
Imported Upstream version 4.2-build2006upstream/4.2-build2006upstream
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);
+}