]> thyrsus.com Git - morse-classic.git/commitdiff
Start of ANSification.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 24 Jan 2005 15:01:15 +0000 (15:01 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 24 Jan 2005 15:01:15 +0000 (15:01 +0000)
Makefile
alarm.h
beep.h
morse.c

index 08e22c5d416f870d0101ebf70a66ac199c132546..8eb9ec6eb1fe2928acfa7400f78f508c087a9afa 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,13 @@
 #   AdLib:  AdLib/SoundBlaster FM chip.
 #   OSS:    Open Sound System /dev/dsp device.
 #
+# Two notes about OSS:
+# (1) You can use this even on a recent Linux kernel with ALSA, which
+#     implements enough of the OSS interface for it to work.
+# (2) Many Linux laptops seem to have console speakers that are unreliable 
+#     for various hardware and software reasons.  You may be better off using 
+#     morseOSS than morseLinux.
+#
 # Adding a new device is as simple as creating a new implementation of the
 # beep.h interface.  See beep*.c for examples.  Please send any additions
 # to the authors!
diff --git a/alarm.h b/alarm.h
index 13aec54898abb8c5dd3dd2c475fd5fbfc2b78487..33a5fb188773aa492b520142e10c2c5af1d7a5b4 100644 (file)
--- a/alarm.h
+++ b/alarm.h
@@ -1,4 +1,4 @@
-/* alarm.h -- seligman 6/92 */
+/* alarm.h -- wakeup call interface */
 
 /*
 -- Routines for using the system interval timer to time beeps.  Useful
@@ -12,9 +12,9 @@
 /*
 -- Set the alarm for a time specified in ms.
 */
-void AlarmSet(/*int time*/);
+void AlarmSet(time_t);
 
 /*
 -- Wait for the alarm, or return immediately if the alarm isn't set.
 */
-void AlarmWait();
+void AlarmWait(void);
diff --git a/beep.h b/beep.h
index 18185b8866c0869eddb422fd9507d9582f70cbb1..7e1796bba7f16502cfa129364e1526a2d730b2c0 100644 (file)
--- a/beep.h
+++ b/beep.h
@@ -32,28 +32,28 @@ int BeepInit(void);
 --
 -- Returns nonzero on error.
 */
-int Beep(/*int time, int volume, int pitch*/);
+int Beep(int time, int volume, int pitch);
 
 
 /*
 -- Wait until any currently sounding beeps have completed.
 -- Returns nonzero on error.
 */
-int BeepWait();
+int BeepWait(void);
 
 
 /*
 -- Clean up any altered state before exiting or suspending the program.
 -- Returns nonzero on error.
 */
-int BeepCleanup();
+int BeepCleanup(void);
 
 
 /*
 -- Restore the world when program is resumed after having been suspended.
 -- Returns nonzero on error.
 */
-int BeepResume();
+int BeepResume(void);
 
 
 #endif /* _BEEP_H */
diff --git a/morse.c b/morse.c
index 32f7044656bc098a1517ae92673385a3ad483648..f11ff519746e7596b65da4557b6a010a6b8f9926 100644 (file)
--- a/morse.c
+++ b/morse.c
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -130,13 +126,6 @@ char            copyleftjoe[] =
 #ifdef __hpux
 #define USG
 #endif
-/*
- * Define the return type of a signal handler.  Defaults to void, which is
- * what most modern systems are using these days.
- */
-#ifndef SIGRET
-#define SIGRET void
-#endif
 
 #define FREQUENCY      800.
 #define FREQUENCY2     602.
@@ -204,8 +193,8 @@ static char    *(code[TWOFIFTYSIX]);
 static int      errorlog[TWOFIFTYSIX];
 static int      randomfactor[TWOFIFTYSIX];
 static int      randomripe[TWOFIFTYSIX];
-extern int      testterminal ();
-extern int      randomletter ();
+static int      testterminal (void);
+static int      randomletter (void);
 
 /*
  * Pointers to termcap/terminfo "smso/so" (enter_standout_mode) and "rmso/se"
@@ -213,8 +202,8 @@ extern int      randomletter ();
  * with ANSI sequences "\E[7m" to turn the inverse video mode on and "\E[0m"
  * to turn all video attributes off).
  */
-char           *enter_standout_mode = "\033[7m";
-char           *exit_standout_mode = "\033[0m";
+static const char           *enter_standout_mode = "\033[7m";
+static const char           *exit_standout_mode = "\033[0m";
 
 /*
  * Value of (Wrong - Right), which, if exceeded, will cause the program
@@ -337,27 +326,25 @@ long            lrand48 ();
 int             rand ();
 #endif
 
-void            new_words_per_minute (void);
-void            dowords (int c);
-void            morse (int c);
-void            show (char *s);
-void            testaddchar (char c);
-void            youraddchar (char c);
-void            pollyou (void);
-void            tone (float hertz, float duration, float amplitude);
-void            toneflush (void);
-void            openterminal (void);
-int             readterminal (char **string);
-void            closeterminal (void);
-void            report (void);
-
-SIGRET          die (), suspend ();
-void            cleanup ();
+static void            new_words_per_minute (void);
+static void            dowords (int c);
+static void            morse (int c);
+static void            show (char *s);
+static void            testaddchar (char c);
+static void            youraddchar (char c);
+static void            pollyou (void);
+static void            tone (float hertz, float duration, float amplitude);
+static void            toneflush (void);
+static void            openterminal (void);
+static int             readterminal (char **string);
+static void            closeterminal (void);
+static void            report (void);
+
+static void            die (), suspend ();
+static void            cleanup ();
 
 int
-main (argc, argv)
-    int             argc;
-    char          **argv;
+main (int argc, char **argv)
 {
 extern char    *optarg;
 extern int      optind;
@@ -1791,16 +1778,15 @@ int             resync;
 
 /*----------------------------------------*/
 
-void
-tone (hertz, duration, amplitude)
-    float           hertz, duration, amplitude;
+static void
+tone (float hertz, float duration, float amplitude)
 {
     Beep ((int) (duration * 1000), (int) (amplitude * 100), (int) hertz);
 }
 
 
-void
-toneflush ()
+static void
+toneflush (void)
 {
     BeepWait ();
 }
@@ -1884,7 +1870,7 @@ int             n;
     return n;
 }
 
-void
+static void
 closeterminal ()
 {
 #ifdef USG
@@ -1895,14 +1881,14 @@ closeterminal ()
     close (termfd);
 }
 
-SIGRET
+static void
 die ()
 {
     cleanup ();
     exit (1);
 }
 
-void
+static void
 cleanup ()
 {
     if (termopen)
@@ -1910,7 +1896,7 @@ cleanup ()
     BeepCleanup ();
 }
 
-SIGRET
+static void
 suspend ()
 {
     signal (SIGTSTP, suspend);
@@ -1924,8 +1910,8 @@ suspend ()
 
 /*----------------------------------------*/
 
-int
-randomletter ()
+static int
+randomletter (void)
 {
 int             ii;
 int             sum, sum2;