summaryrefslogtreecommitdiff
path: root/comms/xtel/patches/patch-af
diff options
context:
space:
mode:
Diffstat (limited to 'comms/xtel/patches/patch-af')
-rw-r--r--comms/xtel/patches/patch-af255
1 files changed, 255 insertions, 0 deletions
diff --git a/comms/xtel/patches/patch-af b/comms/xtel/patches/patch-af
new file mode 100644
index 00000000000..c4b24aa5a23
--- /dev/null
+++ b/comms/xtel/patches/patch-af
@@ -0,0 +1,255 @@
+$NetBSD: patch-af,v 1.1.1.1 2002/01/12 18:34:56 bouyer Exp $
+
+--- modem.c.orig Tue Feb 13 10:39:23 2001
++++ modem.c Sat Jan 12 19:27:52 2002
+@@ -32,7 +32,6 @@
+ #include <sgtty.h>
+ #else
+ #ifdef USE_TERMIOS
+-#include <sys/ioctl.h>
+ #include <termios.h>
+ #else
+ #include <termio.h>
+@@ -44,6 +43,11 @@
+ #ifdef USE_SYSLOG
+ #include <syslog.h>
+ #endif /* USE_SYSLOG */
++#ifdef __STDC__
++#include <stdarg.h>
++#else
++#include <varargs.h>
++#endif
+
+ #include "demon.h"
+ #include "globald.h"
+@@ -87,55 +91,56 @@
+ #endif
+ }
+
+-/* Syslog or not syslog ? */
+-#ifdef USE_SYSLOG
+-void log_debug (fmt, p1, p2, p3, p4, p5, p6, p7)
+-char *fmt;
+-int p1, p2, p3, p4, p5, p6, p7;
+-{
+- char msg[256];
+-
+- sprintf (msg, fmt, p1, p2, p3, p4, p5, p6, p7);
+- syslog (LOG_INFO, msg);
+-}
+-
+-void log_err (s)
+-char *s;
+-{
+- syslog (LOG_ERR, s);
+-}
++#ifdef __STDC__
++void log_debug(const char *fmt, ...)
+ #else
+-void log_debug (fmt, p1, p2, p3, p4, p5, p6, p7)
+-char *fmt;
+-int p1, p2, p3, p4, p5, p6, p7;
++void log_debug(va_alist)
++ va_dcl
++#endif
+ {
++ va_list ap;
++#ifdef __STDC__
++ va_start(ap, fmt);
++#else
++ const char *fmt;
++ va_start(ap);
++ fmt = va_arg(ap, const char *);
++#endif
++#ifdef USE_SYSLOG
++ vsyslog(LOG_INFO, fmt, ap);
++#else
+ fprintf (fp_console, "%s[%d] ", prefix, getpid());
+- fprintf (fp_console, fmt, p1, p2, p3, p4, p5, p6, p7);
++ vfprintf (fp_console, fmt, ap);
+ fprintf (fp_console, "\n\r");
++#endif
++ va_end(ap);
+ }
+
+-void log_err (s)
+-char *s;
++#ifdef __STDC__
++void log_err(const char *fmt, ...)
++#else
++void log_err(va_alist)
++ va_dcl
++#endif
+ {
++ va_list ap;
++#ifdef __STDC__
++ va_start(ap, fmt);
++#else
++ const char *fmt;
++ va_start(ap);
++ fmt = va_arg(ap, const char *);
++#endif
++#ifdef USE_SYSLOG
++ vsyslog(LOG_ERR, fmt, ap);
++#else
+ fprintf (fp_console, "%s[%d] ", prefix, getpid());
+-
+- while (*s) {
+- if (*s != '%')
+- fputc (*s, fp_console);
+- else if (*(s+1) == 'm') {
+- fprintf (fp_console, "%s", sys_errlist[errno]);
+- s++;
+- }
+-
+- s++;
+- }
+-
++ vfprintf (fp_console, fmt, ap);
+ fprintf (fp_console, "\n\r");
++#endif
++ va_end(ap);
+ }
+
+-#endif /* USE_SYSLOG */
+-
+-
+ /* Envoi d'une commande MODEM */
+ static void writemodem (fd, buf, n)
+ int fd;
+@@ -165,8 +170,10 @@
+ #else
+
+ #ifdef USE_TERMIOS
+- ioctl (fd, TIOCGETA, &term);
+- memcpy ((char *)&term_sauve, (char *)&term, sizeof(struct termios));
++ if (tcgetattr(fd, &term) < 0) {
++ log_err("tcgetattr: %s", strerror(errno));
++ exit(1);
++ }
+ #else
+ ioctl (fd, TCGETA, &term);
+ memcpy ((char *)&term_sauve, (char *)&term, sizeof(struct termio));
+@@ -174,11 +181,21 @@
+
+ /* Parametrage de la ligne */
+ term.c_cc[VMIN] = 1;
++#ifdef __NetBSD__
++ term.c_cc[VTIME] = term.c_cc[VKILL] = term.c_cc[VERASE] = 0;
++ term.c_iflag = IGNBRK | IGNPAR;
++ term.c_oflag = term.c_lflag = 0;
++#else
+ term.c_cc[VTIME] = 0;
+ term.c_iflag &= ~(IXON|IXOFF|ICRNL);
+ term.c_lflag &= ~(ICANON|ISIG|ECHO|IEXTEN);
++#endif
+
+ #ifdef USE_TERMIOS
++#ifdef __NetBSD__
++ term.c_cflag = (CREAD | HUPCL | CRTSCTS);
++ cfsetspeed( &term, speed);
++#else
+ /*
+ * FreeBSD 1.1 (Beta) n'a pas l'air d'apprecier qu'on mette clocal
+ * a 0... (blocage au premier write sur /dev/cua01)
+@@ -186,6 +203,7 @@
+ term.c_cflag &= ~(CSIZE|CSTOPB);
+ term.c_cflag |= (CREAD|HUPCL);
+ term.c_ispeed = term.c_ospeed = speed;
++#endif /* __NetBSD__ */
+ #else
+ term.c_cflag &= ~(CSIZE|CBAUD|CLOCAL);
+
+@@ -223,10 +241,12 @@
+ #endif /* sun */
+
+ #ifdef USE_TERMIOS
++#ifndef __NetBSD__
+ term.c_iflag &= ~(IGNCR|ICRNL|INLCR|IMAXBEL);
+ term.c_iflag |= (ISTRIP|INPCK);
+ term.c_lflag &= ~(ECHOCTL|IEXTEN);
+ term.c_oflag &= ~OPOST;
++#endif /* __NetBSD__ */
+ #endif /* USE_TERMIOS */
+
+ /* Cas du Minitel 1/2 */
+@@ -235,7 +255,10 @@
+
+ /* Affectation des parametres */
+ #ifdef USE_TERMIOS
+- ioctl (fd, TIOCSETA, &term);
++ if (tcsetattr (fd, TCSANOW, &term) < 0) {
++ log_err("tcsetattr(1):%s", strerror(errno));
++ exit(1);
++ }
+ #else
+ ioctl (fd, TCSETA, &term);
+ #endif /* USE_TERMIOS */
+@@ -256,10 +279,11 @@
+ ioctl (fd, TIOCSETP, &term_sauve);
+ #else
+ #ifdef USE_TERMIOS
+- term.c_ispeed = B0;
+- term.c_ospeed = B0;
+- ioctl (fd, TIOCSETAW, &term);
+- ioctl (fd, TIOCSETA, &term_sauve);
++ cfsetspeed(&term_sauve, B0);
++ if (tcsetattr (fd, TCSADRAIN, &term_sauve) < 0) {
++ log_err("tcsetattr(2):%s", strerror(errno));
++ exit(1);
++ }
+ #else
+ term.c_cflag &= ~CBAUD;
+ term.c_cflag |= B0;
+@@ -285,7 +309,7 @@
+ int reply_size;
+ {
+ fd_set a_lire, t_a_lire;
+- int i, erreur, fin, nbread, cmodem;
++ int i, erreur, fin, nbread, cmodem = 0;
+ char *pt_chat, c, *q;
+
+ delai_maxi.tv_sec = tmax;
+@@ -307,14 +331,20 @@
+ * (comme le Hayes Optima par exemple)...
+ */
+ #ifdef USE_TERMIOS
+- ioctl (fd, TCIOCGETA, &term);
++ if (tcgetattr(fd, &term) < 0) {
++ log_err("tcgetattr: %s", strerror(errno));
++ exit(1);
++ }
+ #else
+ ioctl (fd, TCGETA, &term);
+ #endif /* USE_TERMIOS */
+- if ((term.c_cflag | CLOCAL) == 0) {
++ if ((term.c_cflag & CLOCAL) == 0) {
+ term.c_cflag |= CLOCAL;
+ #ifdef USE_TERMIOS
+- ioctl (fd, TCIOCSETA, &term);
++ if (tcsetattr (fd, TCSANOW, &term) < 0) {
++ log_err("tcsetattr(3):%s", strerror(errno));
++ exit(1);
++ }
+ #else
+ ioctl (fd, TCSETA, &term);
+ #endif /* USE_TERMIOS */
+@@ -586,13 +616,17 @@
+ fin = ((erreur != 0 || *(pt_chat-1) == 0) ? 1 : 0);
+ usleep (30000);
+ }
++ sleep(3);
+
+ #ifndef NO_TERMIO
+ /* Repasse en controle modem */
+ if (cmodem) {
+ term.c_cflag &= ~CLOCAL;
+ #ifdef USE_TERMIOS
+- ioctl (fd, TCIOCSETA, &term);
++ if (tcsetattr (fd, TCSANOW, &term) < 0) {
++ log_err("tcsetattr(4):%s", strerror(errno));
++ exit(1);
++ }
+ #else
+ ioctl (fd, TCSETA, &term);
+ #endif /* USE_TERMIOS */