]> thyrsus.com Git - morse-classic.git/commitdiff
Merge in new options -A, -B, -S, X, -x.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 24 Jan 2005 15:18:45 +0000 (15:18 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 24 Jan 2005 15:18:45 +0000 (15:18 +0000)
morse.c

diff --git a/morse.c b/morse.c
index 29c0648fe2ac3553a1b1aaaadf4e1e404ec7c024..1a663965e513ea69e0b82b00f7d971f1fa2b856b 100644 (file)
--- a/morse.c
+++ b/morse.c
@@ -122,16 +122,14 @@ char            copyleftjoe[] =
 #include <ctype.h>
 #include <signal.h>
 #include "beep.h"
-/* Define USG for termio a la System V. */
-#ifdef __hpux
-#define USG
-#endif
 
-#define FREQUENCY      800.
-#define FREQUENCY2     602.
-#define VOLUME         .5
-#define WORDS_PER_MINUTE       20.
+#define FREQUENCY      800.0
+#define FREQUENCY2     602.0
+#define VOLUME         0.5
+#define ERROR_VOLUME           0.5
+#define WORDS_PER_MINUTE       20.0
 #define MAX_BEHINDNESS 0
+#define ERROR_FREQUENCY        2000.0
 
 static int      whichfrequ = 0;
 static float    frequency1 = FREQUENCY;
@@ -155,8 +153,13 @@ static int      showtesting = 0;
 static int      keepquiet = 0;
 static int      dynamicspeed = 0;
 static int      charbychar = 0;
+static int     international = 0;
+static int     allprosigns = 0;
+static int     allpunctuation = 1;
 static int      tryagaincount = 1;
-static float    words_per_minute;
+static float    words_per_minute = WORDS_PER_MINUTE;
+static float   error_frequency = ERROR_FREQUENCY;
+static float   error_volume = ERROR_VOLUME;
 static float    fwords_per_minute;
 static int      randomletters = 0;
 #define LETMESEE 2
@@ -418,6 +421,12 @@ extern time_t   time ();
        printf ("      (implies -t)\n");
        printf ("-d    Dynamically speed up or slow down depending on how you are doing.\n");
        printf ("      (if also -s, then -d _only speeds up_!)\n");
+       printf ("-A    Add ISO 8850-1 (Latin-1) signs to test set.\n");
+       printf ("-B    Add uncommon punctuation to test set.\n");
+       printf ("-S    Add uncommon prosigns to test set.\n");
+       printf ("-X    Set error volume. Defaults to %g.\n", ERROR_VOLUME);
+       printf ("      Error volume 0 means use console speaker.\n");
+       printf ("-x    Set frequency of error tone, default 2000.0Hz\n");
        printf ("\n");
        printf ("\n");
        printf ("\n");
@@ -492,7 +501,7 @@ extern time_t   time ();
     code[(int) '/'] = "-..-.";
     code[(int) '-'] = "-....-";
 
-#ifdef ALLPUNCTUATION
+    if (allpunctuation) {
     /* Not so commonly used punctuation marks */
     code[(int) ')'] = "-.--.-";
     code[(int) '\"'] = ".-..-.";
@@ -502,7 +511,7 @@ extern time_t   time ();
     code[(int) ';'] = "-.-.-.";
     code[(int) '$'] = "...-..-";
     code[(int) '!'] = "-.-.--";
-#endif
+    }
 
     /* Commonly used procedure signs ("prosigns") */
     code[(int) '+'] = ".-.-.";  /* <AR> end of message */
@@ -511,15 +520,15 @@ extern time_t   time ();
     code[(int) '('] = "-.--.";  /* <KN> over-specified station only */
     code[(int) '%'] = "...-.-"; /* <SK> end of contact, known also as <VA> */
 
-#ifdef ALLPROSIGNS
+    if (allprosigns) {
     /* Not so commonly used procedure signs ("prosigns") */
     code[(int) '^'] = ".-.-";   /* <AA> new line, the same as :a, ae */
     code[(int) '#'] = "-...-.-";/* <BK> invite receiving station to transmit */
     code[(int) '&'] = "-.-.-";  /* <KA> attention */
     code[(int) '@'] = "...-.";  /* <SN> understood */
-#endif
+    }
 
-#ifdef ALLINTERNATIONAL
+    if (international) {
     /* Not so commonly used international extensions (ISO 8859-1) */
     code[(int) ((unsigned char)'\344')] = ".-.-";   /* :a (also for ae), the same as <AA> */
     if (code[(int) '^'] != NULL) code[(int) '^'] = NULL;
@@ -532,7 +541,7 @@ extern time_t   time ();
     code[(int) ((unsigned char)'\374')] = "..--";   /* :u (also for ue) */
     code[(int) ((unsigned char)'\376')] = ".--..";  /* ]p (thorn, overstrike ] with p) */
     code[(int) ((unsigned char)'\247')] = ".-.-.."; /* paragraph */
-#endif
+    }
 
     for (ii = 0; ii < TWOFIFTYSIX; ii++)
     {
@@ -558,10 +567,16 @@ extern time_t   time ();
     words_per_minute = WORDS_PER_MINUTE;
     fwords_per_minute = -1.;
 
-    /* ABDGHJKLMOPQSUVWXYZhjkouxyz are still available */
-    while ((ch = getopt (argc, argv, "ABC:E:F:IM:N:R:Tabcdef:g:ilmn:p:qrstv:w:")) != EOF)
+    /* DGHJKLMOPQUVWYZhjkouyz are still available */
+    while ((ch = getopt (argc, argv, "ABC:E:F:IM:N:R:STXabcdef:g:ilmn:p:qrstv:w:x:")) != EOF)
        switch ((char) ch)
        {
+       case 'A':
+           international = 1;
+           break;
+       case 'B':
+           allpunctuation = 1;
+           break;
        case 'C':
            for (ii = 0; ii < strlen(optarg); ii++)
              {
@@ -608,10 +623,16 @@ extern time_t   time ();
            timeout *= 60;
            if (timeout < 1) timeout = -1;
            break;
+       case 'S':
+           allprosigns = 1;
+           break;
        case 'T':
            testing = 1;
            showtesting = 1;
            break;
+       case 'X':
+           sscanf (optarg, "%f", &error_volume);
+           break;
        case 'a':
            wordsafter = 1;
            break;
@@ -675,6 +696,9 @@ extern time_t   time ();
        case 'w':
            sscanf (optarg, "%f", &words_per_minute);
            break;
+       case 'x':
+           sscanf (optarg, "%f", &error_frequency);
+           break;
        default:
            fprintf (stderr, "Type \"morse\" without arguments to get self-doc!\n");
            exit (1);