]> thyrsus.com Git - morse-classic.git/commitdiff
Mac OS X port changes.
authorEric S. Raymond <esr@thyrsus.com>
Tue, 25 Jan 2005 02:46:43 +0000 (02:46 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 25 Jan 2005 02:46:43 +0000 (02:46 +0000)
HISTORY
Makefile
morse.d/alarm.c
morse.d/morse.c
morse.spec

diff --git a/HISTORY b/HISTORY
index 4234cca022ac9aaccddc8cbb7be94ba2d1a3aca3..eca179ddb44af3f3ed81807af64be9f796e596f3 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -42,3 +42,5 @@ Eric S. Raymond <esr@thyrsus.com>, January 2005:
     Wrote the manual page.
     Updated all code to use ANSI prototypes.
 
+Jay Maynard K5ZC, January 2005:
+    Mac OS X port patches.
index 34553af980a88c7469606f876e1bdc5686e92ebc..64b7f3098d1fddc5f041fe05faa9c80a57a367c5 100644 (file)
--- a/Makefile
+++ b/Makefile
 #     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!
index 25eb9cfe16096dd4ef4be9b89b0d07021db02482..32985adc7bdbbefe40d3339b3800d1d391816f77 100644 (file)
@@ -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);
 }
 
index 29af690cff24bc82e1164ebe2b4f2d155e8a089b..5bbe3457715f671cdd339b8234f74fdc3198a38e 100644 (file)
@@ -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 <SK> 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 <sys/ioctl.h>
 #include <fcntl.h>
-#include <termio.h>
-struct termio   oldtermgtty;
-struct termio   termgtty;
+#include <termios.h>
+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)
index 1edf9f368d42575f6a6380068051613211848c52..b858d7ea9c0c6c85d089d37518818130ff29dc77 100644 (file)
@@ -41,6 +41,10 @@ cp morse.1 "$RPM_BUILD_ROOT"%{_mandir}/man1/
 %{_bindir}/QSO
 
 %changelog
-* Mon Jan 24 2005 Eric S. Raymond <esr@snark.thyrsus.com> - 
+* Mon Jan 24 2005 Eric S. Raymond <esr@snark.thyrsus.com> - 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 <esr@snark.thyrsus.com> - 2.0-1
 - Initial build.  See HISTORY file in the distribution for prior history.