From: Eric S. Raymond Date: Mon, 24 Jan 2005 15:01:15 +0000 (+0000) Subject: Start of ANSification. X-Git-Tag: 2.0~21 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=b084fc15800999c427d91362c9dc1f4905ef6dd8;p=morse-classic.git Start of ANSification. --- diff --git a/Makefile b/Makefile index 08e22c5..8eb9ec6 100644 --- 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 13aec54..33a5fb1 100644 --- 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 18185b8..7e1796b 100644 --- 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 32f7044..f11ff51 100644 --- a/morse.c +++ b/morse.c @@ -71,11 +71,7 @@ * 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;