From: Eric S. Raymond Date: Tue, 25 Jan 2005 02:46:43 +0000 (+0000) Subject: Mac OS X port changes. X-Git-Tag: 2.1~5 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=c05664440cfe17bc11c5f5cfb5cef529f117fe24;p=morse-classic.git Mac OS X port changes. --- diff --git a/HISTORY b/HISTORY index 4234cca..eca179d 100644 --- a/HISTORY +++ b/HISTORY @@ -42,3 +42,5 @@ Eric S. Raymond , January 2005: Wrote the manual page. Updated all code to use ANSI prototypes. +Jay Maynard K5ZC, January 2005: + Mac OS X port patches. diff --git a/Makefile b/Makefile index 34553af..64b7f30 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,13 @@ # for various hardware and software reasons. You may be better off using # morseOSS than morseLinux. # +# Running on Mac OS X: +# (1) Use X11. The user must, as with any X11 client, set the DISPLAY +# variable, and have the X server running. Finally, the X11 output +# preferences dialog should have "Use system alert effect" unchecked; +# otherwise, the system alert (settable, but unlikely to be useful to +# copy code in any event) will be used instead of the X beep. +# # 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/morse.d/alarm.c b/morse.d/alarm.c index 25eb9cf..32985ad 100644 --- a/morse.d/alarm.c +++ b/morse.d/alarm.c @@ -16,8 +16,12 @@ static void AlarmHandler(); void AlarmSet(time) int time; { + struct sigaction handler; + alarmPending = 1; - sigset(SIGALRM, AlarmHandler); + handler.sa_handler = AlarmHandler; + handler.sa_mask = handler.sa_flags = 0; + sigaction(SIGALRM, &handler, NULL); ualarm(1000 * time, 0); } diff --git a/morse.d/morse.c b/morse.d/morse.c index 29af690..5bbe345 100644 --- a/morse.d/morse.c +++ b/morse.d/morse.c @@ -272,6 +272,7 @@ int firsttime, notdoneyet; int yourchar; float randexp, randnum; extern time_t time (); +struct sigaction handler; if (argc == 1 && isatty (fileno (stdin))) { @@ -297,9 +298,12 @@ extern time_t time (); printf (" Set the total number of words (groups) to generate.\n"); printf ("-C \'STRING\' (default all available characters)\n"); printf (" Select characters to send from this STRING only.\n"); - printf ("-w words_per_minute (default %g)\n-f frequency_in_hertz (default %g)\n-v volume (zero to one, rather nonlinear, default %g)\n", - WORDS_PER_MINUTE, FREQUENCY, VOLUME); - printf ("-g alternate_frequency (default %g)\n (toggles via control-G in input FILE at a word break)\n", FREQUENCY2); + printf ("-w words_per_minute (default %g)\n", WORDS_PER_MINUTE); + printf ("-f frequency_in_hertz (default %g)\n", FREQUENCY); + printf ("-v volume (zero to one, rather nonlinear, default %g)\n", + VOLUME); + printf ("-g alternate_frequency (default %g)\n", FREQUENCY2); + printf (" (toggles via control-G in input FILE at a word break)\n"); printf ("-F Farnsworth_character_words_per_minute\n"); printf ("-e leave off the sound at the end\n"); printf ("-c complain about illegal characters instead of just ignoring them\n"); @@ -613,10 +617,13 @@ extern time_t time (); time(&starttime); - sigset (SIGINT, die); - sigset (SIGTERM, die); - sigset (SIGQUIT, die); - sigset (SIGTSTP, suspend); + handler.sa_handler = die; + handler.sa_mask = handler.sa_flags = 0; + sigaction (SIGINT, &handler, NULL); + sigaction (SIGTERM, &handler, NULL); + sigaction (SIGQUIT, &handler, NULL); + handler.sa_handler = suspend; + sigaction (SIGTSTP, &handler, NULL); if (testing || typeaway) { @@ -1704,9 +1711,9 @@ toneflush (void) #include #include -#include -struct termio oldtermgtty; -struct termio termgtty; +#include +struct termios oldtermgtty; +struct termios termgtty; static char *terminal = "/dev/tty"; static int termfd; static int termopen = 0; @@ -1718,14 +1725,14 @@ openterminal (void) /* get parameters and open terminal */ termfd = open (terminal, O_RDWR | O_NDELAY, 0); - ioctl (termfd, TCGETA, &termgtty); + tcgetattr(termfd, &termgtty); oldtermgtty = termgtty; if (typeaway != LETMESEE) termgtty.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL); termgtty.c_lflag &= ~ICANON; termgtty.c_cc[VMIN] = 1; termgtty.c_cc[VTIME] = 0; - ioctl (termfd, TCSETAW, &termgtty); + tcsetattr(termfd, TCSADRAIN, &termgtty); termopen = 1; } @@ -1752,7 +1759,7 @@ int n; static void closeterminal (void) { - ioctl (termfd, TCSETAW, &oldtermgtty); + tcsetattr(termfd, TCSADRAIN, &oldtermgtty); close (termfd); } @@ -1774,7 +1781,9 @@ cleanup (void) static void suspend (int sig) { - sigset (SIGTSTP, suspend); +#ifdef SIGTSTP + sigset (SIGTSTP, suspend); */ +#endif /* SIGTSTP */ cleanup (); kill (getpid (), SIGSTOP); if (termopen) diff --git a/morse.spec b/morse.spec index 1edf9f3..b858d7e 100644 --- a/morse.spec +++ b/morse.spec @@ -41,6 +41,10 @@ cp morse.1 "$RPM_BUILD_ROOT"%{_mandir}/man1/ %{_bindir}/QSO %changelog -* Mon Jan 24 2005 Eric S. Raymond - +* Mon Jan 24 2005 Eric S. Raymond - 2.1-1 +- Patched to use termios(3) rather than ioctls() and sigaction rather + than sigset(3). This should allow it to run under Mac OS. + +* Mon Jan 24 2005 Eric S. Raymond - 2.0-1 - Initial build. See HISTORY file in the distribution for prior history.