head 1.1; access; symbols pkgsrc-2023Q4:1.1.0.84 pkgsrc-2023Q4-base:1.1 pkgsrc-2023Q3:1.1.0.82 pkgsrc-2023Q3-base:1.1 pkgsrc-2023Q2:1.1.0.80 pkgsrc-2023Q2-base:1.1 pkgsrc-2023Q1:1.1.0.78 pkgsrc-2023Q1-base:1.1 pkgsrc-2022Q4:1.1.0.76 pkgsrc-2022Q4-base:1.1 pkgsrc-2022Q3:1.1.0.74 pkgsrc-2022Q3-base:1.1 pkgsrc-2022Q2:1.1.0.72 pkgsrc-2022Q2-base:1.1 pkgsrc-2022Q1:1.1.0.70 pkgsrc-2022Q1-base:1.1 pkgsrc-2021Q4:1.1.0.68 pkgsrc-2021Q4-base:1.1 pkgsrc-2021Q3:1.1.0.66 pkgsrc-2021Q3-base:1.1 pkgsrc-2021Q2:1.1.0.64 pkgsrc-2021Q2-base:1.1 pkgsrc-2021Q1:1.1.0.62 pkgsrc-2021Q1-base:1.1 pkgsrc-2020Q4:1.1.0.60 pkgsrc-2020Q4-base:1.1 pkgsrc-2020Q3:1.1.0.58 pkgsrc-2020Q3-base:1.1 pkgsrc-2020Q2:1.1.0.54 pkgsrc-2020Q2-base:1.1 pkgsrc-2020Q1:1.1.0.34 pkgsrc-2020Q1-base:1.1 pkgsrc-2019Q4:1.1.0.56 pkgsrc-2019Q4-base:1.1 pkgsrc-2019Q3:1.1.0.52 pkgsrc-2019Q3-base:1.1 pkgsrc-2019Q2:1.1.0.50 pkgsrc-2019Q2-base:1.1 pkgsrc-2019Q1:1.1.0.48 pkgsrc-2019Q1-base:1.1 pkgsrc-2018Q4:1.1.0.46 pkgsrc-2018Q4-base:1.1 pkgsrc-2018Q3:1.1.0.44 pkgsrc-2018Q3-base:1.1 pkgsrc-2018Q2:1.1.0.42 pkgsrc-2018Q2-base:1.1 pkgsrc-2018Q1:1.1.0.40 pkgsrc-2018Q1-base:1.1 pkgsrc-2017Q4:1.1.0.38 pkgsrc-2017Q4-base:1.1 pkgsrc-2017Q3:1.1.0.36 pkgsrc-2017Q3-base:1.1 pkgsrc-2017Q2:1.1.0.32 pkgsrc-2017Q2-base:1.1 pkgsrc-2017Q1:1.1.0.30 pkgsrc-2017Q1-base:1.1 pkgsrc-2016Q4:1.1.0.28 pkgsrc-2016Q4-base:1.1 pkgsrc-2016Q3:1.1.0.26 pkgsrc-2016Q3-base:1.1 pkgsrc-2016Q2:1.1.0.24 pkgsrc-2016Q2-base:1.1 pkgsrc-2016Q1:1.1.0.22 pkgsrc-2016Q1-base:1.1 pkgsrc-2015Q4:1.1.0.20 pkgsrc-2015Q4-base:1.1 pkgsrc-2015Q3:1.1.0.18 pkgsrc-2015Q3-base:1.1 pkgsrc-2015Q2:1.1.0.16 pkgsrc-2015Q2-base:1.1 pkgsrc-2015Q1:1.1.0.14 pkgsrc-2015Q1-base:1.1 pkgsrc-2014Q4:1.1.0.12 pkgsrc-2014Q4-base:1.1 pkgsrc-2014Q3:1.1.0.10 pkgsrc-2014Q3-base:1.1 pkgsrc-2014Q2:1.1.0.8 pkgsrc-2014Q2-base:1.1 pkgsrc-2014Q1:1.1.0.6 pkgsrc-2014Q1-base:1.1 pkgsrc-2013Q4:1.1.0.4 pkgsrc-2013Q4-base:1.1 pkgsrc-2013Q3:1.1.0.2 pkgsrc-2013Q3-base:1.1; locks; strict; comment @ * @; 1.1 date 2013.07.08.08.37.10; author he; state Exp; branches; next ; commitid 5Hgd4j0D4zrtSDWw; desc @@ 1.1 log @Update x48 from version 0.4.1 to 0.6.4. Pkgsrc changes; * HOMEPAGE & distribution site moved. * HP has released the ROMs, and copies of these are now automatically installed. * I could not get the X11 shm option to work (native X11, NetBSD 6.1/i386), so it is disabled in the Makefile. * Patch with updated pty handling code, borrowing some from FreeBSD's package here. Upstream changes: 2011-08-08 "G. Allen Morris III" release 0.6.4 * Default to throttling speed only when key-pressed * Add throttle switch for speed emulation * Fix buffer overflow bug * release keys on loss of focus * typo in access_time adjust 2010-02-01 "G. Allen Morris III" release 0.6.3 * made updates to x48.spec * put debian directory in dist file * install X48 app data in correct place using pkg-config appdefaultdir xt * removed more debugging messages * added 'netbook' look for small/short screens use +netbook on the command line 2010-01-30 "G. Allen Morris III" release 0.6.2 * remove setlocal code that was causing a bug. * removed some debugging code. 2009-06-31 "G. Allen Morris III" release 0.6.1 * Fix to XShm to solve the 'LCD' Scramble problem. 2006-04-20 "G. Allen Morris III" * Added simple paste feature * Repaired debugger non-readline input * Changed from building with Imakefile to using GNU autoconfig 2005-03-20 "G. Allen Morris III" * added equal key for + and Meta Keys for Alpha * applied a different fix for the arrow repeat key bug * fixed a bug in the timer one logic. The cursor now flashes on input. 2005-03-20 "G. Allen Morris III" * added patch [000390] time.h compile bug * added patch [000391] Arrow key repeat patch * added ChangeLog file 2005-03-18 "G. Allen Morris III" * starting from x48 0.4.0. @ text @$NetBSD$ Improve portability and precision of error messages. Conditionalize to get rid of bare non-portable use of CBAUD. --- src/serial.c.orig 2011-11-15 03:03:40.000000000 +0000 +++ src/serial.c @@@@ -129,6 +129,9 @@@@ serial_init() int n; char tty_dev_name[128]; struct termios ttybuf; +#if defined(CSRG_BASED) + char *ptr1, *ptr2; +#endif wire_fd = -1; ttyp = -1; @@@@ -215,6 +218,88 @@@@ serial_init() } while ((wire_fd < 0) && (errno != ENOENT)); } +#elif defined(CSRG_BASED) +#if defined(HAVE_GRANTPT) + /* Unix98 PTY (Preferred) */ + if ((wire_fd = open("/dev/ptmx", O_RDWR | O_NONBLOCK, 0666)) >= 0) + { + grantpt(wire_fd); + unlockpt(wire_fd); + wire_name = strdup(ptsname(wire_fd)); + if ((ttyp = open(wire_name, O_RDWR | O_NDELAY, 0666)) >= 0) + { + if (verbose) + printf("%s: wire connection on %s\n", progname, + wire_name); + } + else + wire_name = NULL; + } + else +#endif +#if defined(HAVE_OPENPTY) + { + int tty_m, tty_s; + if (openpty(&tty_m, &tty_s, tty_dev_name, NULL, NULL) == 0) + { + if (verbose) + printf("%s: wire connection on %s\n", progname, tty_dev_name); + wire_fd = tty_m; + ttyp = tty_s; + wire_name = strdup(tty_dev_name); + } + else + perror("openpty"); + } +#else + { + c = c; /* XXX gcc */ + /* This is how Stevens does it in: + * Advanced programming in the UNIX environment + */ + strcpy(tty_dev_name, "/dev/ptyXY"); + /* array index: 0123456789 (for references in following code) */ + for (ptr1 = "pqrstuvwxyzPQRST"; *ptr1 != 0; ptr1++) + { + tty_dev_name[8] = *ptr1; + for (ptr2 = "0123456789abcdef"; *ptr2 != 0; ptr2++) + { + tty_dev_name[9] = *ptr2; + + /* try open the master */ + if ((wire_fd = open(tty_dev_name, O_RDWR, 0666)) < 0) + { + if (errno == ENOENT) + { + wire_fd = -1; /* out of pty devices */ + ttyp = -1; + goto break_for_pty; + } + else + continue; /* try next pty device */ + } + + tty_dev_name[5] = 't'; /* change pty to tty */ + if ((ttyp = open(tty_dev_name, O_RDWR, 0666)) < 0) + { + printf("open tty: %s failed: %s, trying with another\n", + tty_dev_name, strerror(errno)); + close(wire_fd); + wire_fd = -1; + ttyp = -1; + continue; + } + if (verbose) + printf("%s: wire connection on %s\n", + progname, tty_dev_name); + wire_name = strdup(tty_dev_name); + goto break_for_pty; + } + } + } + break_for_pty: + c = c; /* must have statement here... */ +#endif /* no openpty */ #else /* * Here we go for SUNOS, HPUX @@@@ -254,9 +339,15 @@@@ serial_init() { #if defined(TCSANOW) if (tcgetattr(ttyp, &ttybuf) < 0) + { + if (!quiet) + fprintf(stderr, "%s: tcgetattr(wire) failed, errno = %d\n", + progname, errno); + wire_fd = -1; + ttyp = -1; + } #else if (ioctl(ttyp, TCGETS, (char *)&ttybuf) < 0) -#endif { if (!quiet) fprintf(stderr, "%s: ioctl(wire, TCGETS) failed, errno = %d\n", @@@@ -264,12 +355,23 @@@@ serial_init() wire_fd = -1; ttyp = -1; } +#endif } ttybuf.c_lflag = 0; ttybuf.c_iflag = 0; ttybuf.c_oflag = 0; - ttybuf.c_cflag = B9600 | CS8 | CLOCAL | CREAD; + ttybuf.c_cflag = CS8 | CLOCAL | CREAD; +#if defined(TCSANOW) +#if defined(HAVE_CFSETSPEED) + cfsetspeed(&ttybuf, B9600); +#else + ttybuf.c_ispeed = B9600; + ttybuf.c_ospeed = B9600; +#endif +#elif defined CBAUD + ttybuf.c_cflag |= B9600; +#endif for (n = 0; n < NCCS; n++) ttybuf.c_cc[n] = 0; ttybuf.c_cc[VTIME] = 0; @@@@ -279,9 +381,15 @@@@ serial_init() { #if defined(TCSANOW) if (tcsetattr(ttyp, TCSANOW, &ttybuf) < 0) + { + if (!quiet) + fprintf(stderr, "%s: tcsetattr(wire) failed, errno = %d\n", + progname, errno); + wire_fd = -1; + ttyp = -1; + } #else if (ioctl(ttyp, TCSETS, (char *)&ttybuf) < 0) -#endif { if (!quiet) fprintf(stderr, "%s: ioctl(wire, TCSETS) failed, errno = %d\n", @@@@ -289,6 +397,7 @@@@ serial_init() wire_fd = -1; ttyp = -1; } +#endif } ir_fd = -1; @@@@ -307,21 +416,37 @@@@ serial_init() { #if defined(TCSANOW) if (tcgetattr(ir_fd, &ttybuf) < 0) + { + if (!quiet) + fprintf(stderr, "%s: tcgetattr(IR) failed, errno = %d\n", + progname, errno); + ir_fd = -1; + } #else if (ioctl(ir_fd, TCGETS, (char *)&ttybuf) < 0) -#endif { if (!quiet) fprintf(stderr, "%s: ioctl(IR, TCGETS) failed, errno = %d\n", progname, errno); ir_fd = -1; } +#endif } ttybuf.c_lflag = 0; ttybuf.c_iflag = 0; ttybuf.c_oflag = 0; - ttybuf.c_cflag = B9600 | CS8 | CLOCAL | CREAD; + ttybuf.c_cflag = CS8 | CLOCAL | CREAD; +#ifdef CBAUD + ttybuf.c_cflag |= B9600; +#elif defined(TCSANOW) +#if defined(HAVE_CFSETSPEED) + cfsetspeed(&ttybuf, B9600); +#else + ttybuf.c_ispeed = B9600; + ttybuf.c_ospeed = B9600; +#endif +#endif for (n = 0; n < NCCS; n++) ttybuf.c_cc[n] = 0; ttybuf.c_cc[VTIME] = 0; @@@@ -331,15 +456,21 @@@@ serial_init() { #if defined(TCSANOW) if (tcsetattr(ir_fd, TCSANOW, &ttybuf) < 0) + { + if (!quiet) + fprintf(stderr, "%s: tcsetattr(IR, TCSANOW) failed, errno = %d\n", + progname, errno); + ir_fd = -1; + } #else if (ioctl(ir_fd, TCSETS, (char *)&ttybuf) < 0) -#endif { if (!quiet) fprintf(stderr, "%s: ioctl(IR, TCSETS) failed, errno = %d\n", progname, errno); ir_fd = -1; } +#endif } update_connection_display(); return 1; @@@@ -355,14 +486,21 @@@@ int baud; { int error = 0; struct termios ttybuf; + int speed; if (ir_fd >= 0) { #if defined(TCSANOW) if (tcgetattr(ir_fd, &ttybuf) < 0) + { + if (!quiet) + fprintf(stderr, "%s: tcgetattr(IR) failed, errno = %d\n", + progname, errno); + ir_fd = -1; + error = 1; + } #else if (ioctl(ir_fd, TCGETS, (char *)&ttybuf) < 0) -#endif { if (!quiet) fprintf(stderr, "%s: ioctl(IR, TCGETS) failed, errno = %d\n", @@@@ -370,106 +508,76 @@@@ int baud; ir_fd = -1; error = 1; } +#endif } -#if defined(__APPLE__) + speed = 0; baud &= 0x7; - switch (baud) - { - case 0: /* 1200 */ - ttybuf.c_cflag |= B1200; - break; - case 1: /* 1920 */ -# ifdef B1920 - ttybuf.c_cflag |= B1920; -# endif - break; - case 2: /* 2400 */ - ttybuf.c_cflag |= B2400; - break; - case 3: /* 3840 */ -# ifdef B3840 - ttybuf.c_cflag |= B3840; -# endif - break; - case 4: /* 4800 */ - ttybuf.c_cflag |= B4800; - break; - case 5: /* 7680 */ -# ifdef B7680 - ttybuf.c_cflag |= B7680; -# endif - break; - case 6: /* 9600 */ - ttybuf.c_cflag |= B9600; - break; - case 7: /* 15360 */ -# ifdef B15360 - ttybuf.c_cflag |= B15360; -# endif - break; - } - - if ((ir_fd >= 0) && ((ttybuf.c_ospeed) == 0)) - { - if (!quiet) - fprintf(stderr, "%s: can\'t set baud rate, using 9600\n", progname); - ttybuf.c_cflag |= B9600; - } -#else - ttybuf.c_cflag &= ~CBAUD; - baud &= 0x7; switch (baud) { case 0: /* 1200 */ - ttybuf.c_cflag |= B1200; + speed = B1200; break; case 1: /* 1920 */ # ifdef B1920 - ttybuf.c_cflag |= B1920; + speed = B1920; # endif break; case 2: /* 2400 */ - ttybuf.c_cflag |= B2400; + speed = B2400; break; case 3: /* 3840 */ # ifdef B3840 - ttybuf.c_cflag |= B3840; + speed = B3840; # endif break; case 4: /* 4800 */ - ttybuf.c_cflag |= B4800; + speed = B4800; break; case 5: /* 7680 */ # ifdef B7680 - ttybuf.c_cflag |= B7680; + speed = B7680; # endif break; case 6: /* 9600 */ - ttybuf.c_cflag |= B9600; + speed = B9600; break; case 7: /* 15360 */ # ifdef B15360 - ttybuf.c_cflag |= B15360; + speed = B15360; # endif break; } - if ((ir_fd >= 0) && ((ttybuf.c_cflag & CBAUD) == 0)) - { + if ((ir_fd >= 0) && (speed == 0)) { if (!quiet) fprintf(stderr, "%s: can\'t set baud rate, using 9600\n", progname); - ttybuf.c_cflag |= B9600; - } -#endif + speed = B9600; + } + if (ir_fd >= 0) { #if defined(TCSANOW) +#if defined(HAVE_CFSETSPEED) + cfsetspeed(&ttybuf, speed); +#else + ttybuf.c_ispeed = speed; + ttybuf.c_ospeed = speed; +#endif if (tcsetattr(ir_fd, TCSANOW, &ttybuf) < 0) + { + if (!quiet) + fprintf(stderr, "%s: tcsetattr(IR, TCSANOW) failed, errno = %d\n", + progname, errno); + ir_fd = -1; + error = 1; + } #else + ttybuf.c_cflag &= ~CBAUD; + ttybuf.c_cflag |= speed; + if (ioctl(ir_fd, TCSETS, (char *)&ttybuf) < 0) -#endif { if (!quiet) fprintf(stderr, "%s: ioctl(IR, TCSETS) failed, errno = %d\n", @@@@ -477,15 +585,23 @@@@ int baud; ir_fd = -1; error = 1; } +#endif } if (ttyp >= 0) { #if defined(TCSANOW) if (tcgetattr(ttyp, &ttybuf) < 0) + { + if (!quiet) + fprintf(stderr, "%s: tcgetattr(wire, TCSANOW) failed, errno = %d\n", + progname, errno); + wire_fd = -1; + ttyp = -1; + error = 1; + } #else if (ioctl(ttyp, TCGETS, (char *)&ttybuf) < 0) -#endif { if (!quiet) fprintf(stderr, "%s: ioctl(wire, TCGETS) failed, errno = %d\n", @@@@ -494,63 +610,80 @@@@ int baud; ttyp = -1; error = 1; } +#endif } #if defined(__APPLE__) #else - ttybuf.c_cflag &= ~CBAUD; + speed = 0; baud &= 0x7; switch (baud) { case 0: /* 1200 */ - ttybuf.c_cflag |= B1200; + speed = B1200; break; case 1: /* 1920 */ # ifdef B1920 - ttybuf.c_cflag |= B1920; + speed = B1920; # endif break; case 2: /* 2400 */ - ttybuf.c_cflag |= B2400; + speed = B2400; break; case 3: /* 3840 */ # ifdef B3840 - ttybuf.c_cflag |= B3840; + speed = B3840; # endif break; case 4: /* 4800 */ - ttybuf.c_cflag |= B4800; + speed = B4800; break; case 5: /* 7680 */ # ifdef B7680 - ttybuf.c_cflag |= B7680; + speed = B7680; # endif break; case 6: /* 9600 */ - ttybuf.c_cflag |= B9600; + speed = B9600; break; case 7: /* 15360 */ # ifdef B15360 - ttybuf.c_cflag |= B15360; + speed = B15360; # endif break; } - if ((ttyp >= 0) && ((ttybuf.c_cflag & CBAUD) == 0)) + if ((ttyp >= 0) && (speed == 0)) { if (!quiet) fprintf(stderr, "%s: can\'t set baud rate, using 9600\n", progname); - ttybuf.c_cflag |= B9600; + speed = B9600; } #endif if (ttyp >= 0) { #if defined(TCSANOW) +#if defined(HAVE_CFSETSPEED) + cfsetspeed(&ttybuf, speed); +#else + ttybuf.c_ispeed = speed; + ttybuf.c_ospeed = speed; +#endif if (tcsetattr(ttyp, TCSANOW, &ttybuf) < 0) + { + if (!quiet) + fprintf(stderr, "%s: tcsetattr(wire, TCSANOW) failed, errno = %d\n", + progname, errno); + wire_fd = -1; + ttyp = -1; + error = 1; + } #else + ttybuf.c_cflag &= ~CBAUD; + ttybuf.c_cflag |= speed; + if (ioctl(ttyp, TCSETS, (char *)&ttybuf) < 0) -#endif { if (!quiet) fprintf(stderr, "%s: ioctl(wire, TCSETS) failed, errno = %d\n", @@@@ -559,6 +692,7 @@@@ int baud; ttyp = -1; error = 1; } +#endif } if (error) update_connection_display(); @