summaryrefslogtreecommitdiff
path: root/tutorials/sndkit/morse/testgen.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/morse/testgen.c
downloadoss4-upstream.tar.gz
Imported Upstream version 4.2-build2006upstream/4.2-build2006upstream
Diffstat (limited to 'tutorials/sndkit/morse/testgen.c')
-rw-r--r--tutorials/sndkit/morse/testgen.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/tutorials/sndkit/morse/testgen.c b/tutorials/sndkit/morse/testgen.c
new file mode 100644
index 0000000..b74df4b
--- /dev/null
+++ b/tutorials/sndkit/morse/testgen.c
@@ -0,0 +1,65 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <math.h>
+
+int ncodes;
+
+char randomlist[256];
+int nrandom = 0;
+
+#include "charlist.h"
+
+int
+main (int argc, char *argv[])
+{
+ int ngroups = 0, maxgroups = 20;
+ ncodes = strlen (Chars);
+
+ srandom (time (0));
+
+ if (argc > 1)
+ {
+ parse_charlist (argv[1]);
+ }
+ else
+ {
+ strcpy (randomlist, Chars);
+ nrandom = strlen (randomlist);
+ }
+
+ if (argc > 2)
+ maxgroups = atoi (argv[2]);
+
+ if (nrandom < 2)
+ {
+ printf ("Bad character list\n");
+ exit (-1);
+ }
+
+ while (1)
+ {
+ int i, c;
+
+ if (ngroups && !(ngroups % 5))
+ printf ("\n");
+
+ if (ngroups++ >= maxgroups)
+ {
+ printf ("\n");
+ exit (0);
+ }
+
+
+ for (i = 0; i < 5; i++)
+ {
+ c = random () % nrandom;
+
+ printf ("%c", randomlist[c]);
+ }
+
+ printf (" ");
+ fflush (stdout);
+ }
+}