comparison src/sysdep.c @ 185:3d6bfa290dbd r20-3b19

Import from CVS: tag r20-3b19
author cvs
date Mon, 13 Aug 2007 09:55:28 +0200
parents 9ad43877534d
children b405438285a2
comparison
equal deleted inserted replaced
184:bcd2674570bf 185:3d6bfa290dbd
110 #endif 110 #endif
111 #endif /* TIOCGWINSZ or ISC4_0 */ 111 #endif /* TIOCGWINSZ or ISC4_0 */
112 #endif /* USG */ 112 #endif /* USG */
113 113
114 #ifdef HAVE_SYS_STROPTS_H 114 #ifdef HAVE_SYS_STROPTS_H
115 #include <sys/stropts.h> 115 #include <sys/stropts.h>
116 #endif /* HAVE_SYS_STROPTS_H */ 116 #endif /* HAVE_SYS_STROPTS_H */
117 117
118 /* LPASS8 is new in 4.3, and makes cbreak mode provide all 8 bits. */ 118 /* LPASS8 is new in 4.3, and makes cbreak mode provide all 8 bits. */
119 #ifndef LPASS8 119 #ifndef LPASS8
120 #define LPASS8 0 120 #define LPASS8 0
399 399
400 /* 400 /*
401 * flush any pending output 401 * flush any pending output
402 * (may flush input as well; it does not matter the way we use it) 402 * (may flush input as well; it does not matter the way we use it)
403 */ 403 */
404 404
405 void 405 void
406 flush_pending_output (int channel) 406 flush_pending_output (int channel)
407 { 407 {
408 #ifdef HAVE_TERMIOS 408 #ifdef HAVE_TERMIOS
409 /* If we try this, we get hit with SIGTTIN, because 409 /* If we try this, we get hit with SIGTTIN, because
644 close_process_descs (); /* Close Emacs's pipes/ptys */ 644 close_process_descs (); /* Close Emacs's pipes/ptys */
645 #endif 645 #endif
646 646
647 #ifdef SET_EMACS_PRIORITY 647 #ifdef SET_EMACS_PRIORITY
648 if (emacs_priority != 0) 648 if (emacs_priority != 0)
649 nice (-emacs_priority); /* Give the new shell the default priority */ 649 nice (-emacs_priority); /* Give the new shell the default priority */
650 #endif 650 #endif
651 651
652 #ifdef MSDOS 652 #ifdef MSDOS
653 st = system (sh); 653 st = system (sh);
654 sys_chdir (oldwd); 654 sys_chdir (oldwd);
753 #endif 753 #endif
754 } 754 }
755 755
756 /* Suspend a process if possible; give terminal to its superior. */ 756 /* Suspend a process if possible; give terminal to its superior. */
757 void 757 void
758 sys_suspend_process (process) 758 sys_suspend_process (int process)
759 int process;
760 { 759 {
761 /* I don't doubt that it is possible to suspend processes on 760 /* I don't doubt that it is possible to suspend processes on
762 * VMS machines or thost that use USG_JOBCTRL, 761 * VMS machines or thost that use USG_JOBCTRL,
763 * but I don't know how to do it, so... 762 * but I don't know how to do it, so...
764 */ 763 */
786 return 1; 785 return 1;
787 786
788 #elif defined (TIOCSSIZE) 787 #elif defined (TIOCSSIZE)
789 788
790 /* SunOS - style. */ 789 /* SunOS - style. */
791 struct ttysize size; 790 struct ttysize size;
792 size.ts_lines = height; 791 size.ts_lines = height;
793 size.ts_cols = width; 792 size.ts_cols = width;
794 793
795 if (ioctl (fd, TIOCGSIZE, &size) == -1) 794 if (ioctl (fd, TIOCGSIZE, &size) == -1)
796 return 0; 795 return 0;
820 will hang. In particular, the "timeout" feature (which 819 will hang. In particular, the "timeout" feature (which
821 causes a read to return if there is no data available) 820 causes a read to return if there is no data available)
822 does this. Also it is known that telnet mode will hang 821 does this. Also it is known that telnet mode will hang
823 in such a way that Emacs must be stopped (perhaps this 822 in such a way that Emacs must be stopped (perhaps this
824 is the same problem). 823 is the same problem).
825 824
826 If TIOCREMOTE is turned off, then there is a bug in 825 If TIOCREMOTE is turned off, then there is a bug in
827 hp-ux which sometimes loses data. Apparently the 826 hp-ux which sometimes loses data. Apparently the
828 code which blocks the master process when the internal 827 code which blocks the master process when the internal
829 buffer fills up does not work. Other than this, 828 buffer fills up does not work. Other than this,
830 though, everything else seems to work fine. 829 though, everything else seems to work fine.
831 830
832 Since the latter lossage is more benign, we may as well 831 Since the latter lossage is more benign, we may as well
833 lose that way. -- cph */ 832 lose that way. -- cph */
834 #if defined (FIONBIO) && defined (SYSV_PTYS) 833 #if defined (FIONBIO) && defined (SYSV_PTYS)
835 { 834 {
836 int on = 1; 835 int on = 1;
889 int input_fd = CONSOLE_TTY_DATA (con)->infd; 888 int input_fd = CONSOLE_TTY_DATA (con)->infd;
890 #ifdef MSDOS 889 #ifdef MSDOS
891 DEVICE_TTY_DATA (d)->ospeed = 15; 890 DEVICE_TTY_DATA (d)->ospeed = 15;
892 #elif defined (VMS) 891 #elif defined (VMS)
893 struct vms_sensemode sg; 892 struct vms_sensemode sg;
894 893
895 SYS$QIOW (0, input_fd, IO$_SENSEMODE, &sg, 0, 0, 894 SYS$QIOW (0, input_fd, IO$_SENSEMODE, &sg, 0, 0,
896 &sg.class, 12, 0, 0, 0, 0 ); 895 &sg.class, 12, 0, 0, 0, 0 );
897 DEVICE_TTY_DATA (d)->ospeed = sg.xmit_baud; 896 DEVICE_TTY_DATA (d)->ospeed = sg.xmit_baud;
898 #elif defined (HAVE_TERMIOS) 897 #elif defined (HAVE_TERMIOS)
899 struct termios sg; 898 struct termios sg;
900 899
901 sg.c_cflag = B9600; 900 sg.c_cflag = B9600;
902 tcgetattr (input_fd, &sg); 901 tcgetattr (input_fd, &sg);
903 DEVICE_TTY_DATA (d)->ospeed = cfgetospeed (&sg); 902 DEVICE_TTY_DATA (d)->ospeed = cfgetospeed (&sg);
904 # if defined (USE_GETOBAUD) && defined (getobaud) 903 # if defined (USE_GETOBAUD) && defined (getobaud)
905 /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */ 904 /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */
906 if (DEVICE_TTY_DATA (d)->ospeed == 0) 905 if (DEVICE_TTY_DATA (d)->ospeed == 0)
907 DEVICE_TTY_DATA (d)->ospeed = getobaud (sg.c_cflag); 906 DEVICE_TTY_DATA (d)->ospeed = getobaud (sg.c_cflag);
908 # endif 907 # endif
909 #elif defined (HAVE_TERMIO) 908 #elif defined (HAVE_TERMIO)
910 struct termio sg; 909 struct termio sg;
911 910
912 sg.c_cflag = B9600; 911 sg.c_cflag = B9600;
913 # ifdef HAVE_TCATTR 912 # ifdef HAVE_TCATTR
914 tcgetattr (input_fd, &sg); 913 tcgetattr (input_fd, &sg);
915 # else 914 # else
916 ioctl (input_fd, TCGETA, &sg); 915 ioctl (input_fd, TCGETA, &sg);
917 # endif 916 # endif
918 DEVICE_TTY_DATA (d)->ospeed = sg.c_cflag & CBAUD; 917 DEVICE_TTY_DATA (d)->ospeed = sg.c_cflag & CBAUD;
919 #else /* neither VMS nor TERMIOS nor TERMIO */ 918 #else /* neither VMS nor TERMIOS nor TERMIO */
920 struct sgttyb sg; 919 struct sgttyb sg;
921 920
922 sg.sg_ospeed = B9600; 921 sg.sg_ospeed = B9600;
923 if (ioctl (input_fd, TIOCGETP, &sg) < 0) 922 if (ioctl (input_fd, TIOCGETP, &sg) < 0)
924 abort (); 923 abort ();
925 DEVICE_TTY_DATA (d)->ospeed = sg.sg_ospeed; 924 DEVICE_TTY_DATA (d)->ospeed = sg.sg_ospeed;
926 #endif 925 #endif
927 } 926 }
928 927
929 DEVICE_BAUD_RATE (d) = 928 DEVICE_BAUD_RATE (d) =
930 (DEVICE_TTY_DATA (d)->ospeed < sizeof baud_convert / sizeof baud_convert[0] 929 (DEVICE_TTY_DATA (d)->ospeed < sizeof baud_convert / sizeof baud_convert[0]
931 ? baud_convert[DEVICE_TTY_DATA (d)->ospeed] 930 ? baud_convert[DEVICE_TTY_DATA (d)->ospeed]
932 : 9600); 931 : 9600);
933 932
1089 1088
1090 if (DEVICE_TTY_P (d)) 1089 if (DEVICE_TTY_P (d))
1091 { 1090 {
1092 ioctl_status = ioctl (filedesc, FIOSSAIOSTAT, &off); 1091 ioctl_status = ioctl (filedesc, FIOSSAIOSTAT, &off);
1093 } 1092 }
1094 else 1093 else
1095 { 1094 {
1096 ioctl_status = ioctl (filedesc, FIOASYNC, &off); 1095 ioctl_status = ioctl (filedesc, FIOASYNC, &off);
1097 } 1096 }
1098 } 1097 }
1099 #elif defined (FIOASYNC) 1098 #elif defined (FIOASYNC)
1253 So go ahead and put ourselves into our own process group. This 1252 So go ahead and put ourselves into our own process group. This
1254 will fail if we're already in our own process group, but who cares. 1253 will fail if we're already in our own process group, but who cares.
1255 Also record whether we were in our own process group. (In general, 1254 Also record whether we were in our own process group. (In general,
1256 we will already be in our own process group if we were started from 1255 we will already be in our own process group if we were started from
1257 a job-control shell like csh, but not if we were started from sh). 1256 a job-control shell like csh, but not if we were started from sh).
1258 1257
1259 If we succeeded in changing our process group, then we will no 1258 If we succeeded in changing our process group, then we will no
1260 longer be in the foreground process group of our controlling 1259 longer be in the foreground process group of our controlling
1261 terminal. Therefore, if we have a console open onto this terminal, 1260 terminal. Therefore, if we have a console open onto this terminal,
1262 we have to change the controlling terminal's foreground process 1261 we have to change the controlling terminal's foreground process
1263 group (otherwise we will get stopped with a SIGTTIN signal when 1262 group (otherwise we will get stopped with a SIGTTIN signal when
1310 On systems without TIOCNOTTY and without 1309 On systems without TIOCNOTTY and without
1311 setsid(), we don't need to do anything more to 1310 setsid(), we don't need to do anything more to
1312 disconnect our controlling terminal. Here is 1311 disconnect our controlling terminal. Here is
1313 what the man page for termio(7) from a SYSV 3.2 1312 what the man page for termio(7) from a SYSV 3.2
1314 system says: 1313 system says:
1315 1314
1316 "The first terminal file opened by the process group leader 1315 "The first terminal file opened by the process group leader
1317 of a terminal file not already associated with a process 1316 of a terminal file not already associated with a process
1318 group becomes the control terminal for that process group. 1317 group becomes the control terminal for that process group.
1319 The control terminal plays a special role in handling quit 1318 The control terminal plays a special role in handling quit
1320 and interrupt signals, as discussed below. The control 1319 and interrupt signals, as discussed below. The control
1321 terminal is inherited by a child process during a fork(2). 1320 terminal is inherited by a child process during a fork(2).
1322 A process can break this association by changing its process 1321 A process can break this association by changing its process
1323 group using setpgrp(2)." 1322 group using setpgrp(2)."
1324 1323
1325 */ 1324 */
1326 # endif /* not HAVE_SETSID */ 1325 # endif /* not HAVE_SETSID */
1327 } 1326 }
1328 1327
1329 1328
1468 #ifdef HAVE_TCHARS 1467 #ifdef HAVE_TCHARS
1469 if (ioctl (fd, TIOCSETC, &settings->tchars) < 0 1468 if (ioctl (fd, TIOCSETC, &settings->tchars) < 0
1470 || ioctl (fd, TIOCLSET, &settings->lmode) < 0) 1469 || ioctl (fd, TIOCLSET, &settings->lmode) < 0)
1471 return -1; 1470 return -1;
1472 #endif 1471 #endif
1473 1472
1474 /* We have survived the tempest. */ 1473 /* We have survived the tempest. */
1475 return 0; 1474 return 0;
1476 } 1475 }
1477 1476
1478 #endif /* WINDOWSNT */ 1477 #endif /* WINDOWSNT */
1492 #elif (defined(USG) && !defined(LINUX) && !defined(_SCO_DS)) || defined(IRIX5) 1491 #elif (defined(USG) && !defined(LINUX) && !defined(_SCO_DS)) || defined(IRIX5)
1493 extern unsigned char _sobuf[BUFSIZ+8]; 1492 extern unsigned char _sobuf[BUFSIZ+8];
1494 #else 1493 #else
1495 char _sobuf[BUFSIZ]; 1494 char _sobuf[BUFSIZ];
1496 #endif 1495 #endif
1497 1496
1498 #if defined (TIOCGLTC) && defined (HAVE_LTCHARS) /* HAVE_LTCHARS */ 1497 #if defined (TIOCGLTC) && defined (HAVE_LTCHARS) /* HAVE_LTCHARS */
1499 static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1}; 1498 static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1};
1500 #endif 1499 #endif
1501 #ifdef TIOCGETC /* HAVE_TCHARS */ 1500 #ifdef TIOCGETC /* HAVE_TCHARS */
1502 #ifdef HAVE_TCHARS 1501 #ifdef HAVE_TCHARS
1503 static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1}; 1502 static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1};
1504 #endif 1503 #endif
1505 #endif 1504 #endif
1506 1505
1507 static void 1506 static void
1508 tty_init_sys_modes_on_device (struct device *d) 1507 tty_init_sys_modes_on_device (struct device *d)
1509 { 1508 {
1510 struct emacs_tty tty; 1509 struct emacs_tty tty;
1544 tty.main.c_iflag &= ~IXANY; 1543 tty.main.c_iflag &= ~IXANY;
1545 #endif /* IXANY */ 1544 #endif /* IXANY */
1546 } 1545 }
1547 else 1546 else
1548 tty.main.c_iflag &= ~IXON; /* Disable start/stop output control */ 1547 tty.main.c_iflag &= ~IXON; /* Disable start/stop output control */
1549 tty.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL 1548 tty.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL
1550 on output */ 1549 on output */
1551 tty.main.c_oflag &= ~TAB3; /* Disable tab expansion */ 1550 tty.main.c_oflag &= ~TAB3; /* Disable tab expansion */
1552 #ifdef CS8 1551 #ifdef CS8
1553 if (TTY_FLAGS (con).meta_key) 1552 if (TTY_FLAGS (con).meta_key)
1554 { 1553 {
1613 #ifdef SET_LINE_DISCIPLINE 1612 #ifdef SET_LINE_DISCIPLINE
1614 /* Need to explicitely request TERMIODISC line discipline or 1613 /* Need to explicitely request TERMIODISC line discipline or
1615 Ultrix's termios does not work correctly. */ 1614 Ultrix's termios does not work correctly. */
1616 tty.main.c_line = SET_LINE_DISCIPLINE; 1615 tty.main.c_line = SET_LINE_DISCIPLINE;
1617 #endif 1616 #endif
1618 1617
1619 #ifdef AIX 1618 #ifdef AIX
1620 #ifndef IBMR2AIX 1619 #ifndef IBMR2AIX
1621 /* AIX enhanced edit loses NULs, so disable it. */ 1620 /* AIX enhanced edit loses NULs, so disable it. */
1622 tty.main.c_line = 0; 1621 tty.main.c_line = 0;
1623 tty.main.c_iflag &= ~ASCEDIT; 1622 tty.main.c_iflag &= ~ASCEDIT;
1642 tty.main.sg_flags |= ANYP; 1641 tty.main.sg_flags |= ANYP;
1643 /* #### should we be using RAW mode here? */ 1642 /* #### should we be using RAW mode here? */
1644 tty.main.sg_flags |= /* interrupt_input ? RAW : */ CBREAK; 1643 tty.main.sg_flags |= /* interrupt_input ? RAW : */ CBREAK;
1645 #endif /* not MSDOS */ 1644 #endif /* not MSDOS */
1646 #endif /* not HAVE_TERMIO */ 1645 #endif /* not HAVE_TERMIO */
1647 1646
1648 /* If going to use CBREAK mode, we must request C-g to interrupt 1647 /* If going to use CBREAK mode, we must request C-g to interrupt
1649 and turn off start and stop chars, etc. If not going to use 1648 and turn off start and stop chars, etc. If not going to use
1650 CBREAK mode, do this anyway so as to turn off local flow 1649 CBREAK mode, do this anyway so as to turn off local flow
1651 control for user coming over network on 4.2; in this case, 1650 control for user coming over network on 4.2; in this case,
1652 only t_stopc and t_startc really matter. */ 1651 only t_stopc and t_startc really matter. */
1659 if (TTY_FLAGS (con).flow_control) 1658 if (TTY_FLAGS (con).flow_control)
1660 { 1659 {
1661 tty.tchars.t_startc = '\021'; 1660 tty.tchars.t_startc = '\021';
1662 tty.tchars.t_stopc = '\023'; 1661 tty.tchars.t_stopc = '\023';
1663 } 1662 }
1664 1663
1665 tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | 1664 tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH |
1666 CONSOLE_TTY_DATA (con)->old_tty.lmode; 1665 CONSOLE_TTY_DATA (con)->old_tty.lmode;
1667 1666
1668 #if defined (ultrix) || defined (__bsdi__) 1667 #if defined (ultrix) || defined (__bsdi__)
1669 /* Under Ultrix 4.2a, leaving this out doesn't seem to hurt 1668 /* Under Ultrix 4.2a, leaving this out doesn't seem to hurt
1670 anything, and leaving it in breaks the meta key. Go figure. */ 1669 anything, and leaving it in breaks the meta key. Go figure. */
1671 /* Turning off ONLCR is enough under BSD/386. Leave the general 1670 /* Turning off ONLCR is enough under BSD/386. Leave the general
1672 output post-processing flag alone since for some reason it 1671 output post-processing flag alone since for some reason it
1673 doesn't get reset after XEmacs goes away. */ 1672 doesn't get reset after XEmacs goes away. */
1674 tty.lmode &= ~LLITOUT; 1673 tty.lmode &= ~LLITOUT;
1675 #endif 1674 #endif
1676 1675
1677 #endif /* HAVE_TCHARS */ 1676 #endif /* HAVE_TCHARS */
1678 #endif /* not HAVE_TERMIO */ 1677 #endif /* not HAVE_TERMIO */
1679 1678
1680 #ifdef HAVE_LTCHARS 1679 #ifdef HAVE_LTCHARS
1681 tty.ltchars = new_ltchars; 1680 tty.ltchars = new_ltchars;
1682 #endif /* HAVE_LTCHARS */ 1681 #endif /* HAVE_LTCHARS */
1683 #ifdef MSDOS 1682 #ifdef MSDOS
1684 internal_terminal_init (); 1683 internal_terminal_init ();
1685 dos_ttraw (); 1684 dos_ttraw ();
1686 #endif 1685 #endif
1687 1686
1688 EMACS_SET_TTY (input_fd, &tty, 0); 1687 EMACS_SET_TTY (input_fd, &tty, 0);
1689 1688
1690 /* This code added to insure that, if flow-control is not to be used, 1689 /* This code added to insure that, if flow-control is not to be used,
1691 we have an unlocked terminal at the start. */ 1690 we have an unlocked terminal at the start. */
1692 1691
1693 #ifdef TCXONC 1692 #ifdef TCXONC
1694 if (!TTY_FLAGS (con).flow_control) ioctl (input_fd, TCXONC, 1); 1693 if (!TTY_FLAGS (con).flow_control) ioctl (input_fd, TCXONC, 1);
1695 #endif 1694 #endif
1696 #ifndef APOLLO 1695 #ifndef APOLLO
1697 #ifdef TIOCSTART 1696 #ifdef TIOCSTART
1698 if (!TTY_FLAGS (con).flow_control) ioctl (input_fd, TIOCSTART, 0); 1697 if (!TTY_FLAGS (con).flow_control) ioctl (input_fd, TIOCSTART, 0);
1699 #endif 1698 #endif
1700 #endif 1699 #endif
1701 1700
1702 #if defined (HAVE_TERMIOS) || defined (HPUX9) 1701 #if defined (HAVE_TERMIOS) || defined (HPUX9)
1703 #ifdef TCOON 1702 #ifdef TCOON
1704 if (!TTY_FLAGS (con).flow_control) tcflow (input_fd, TCOON); 1703 if (!TTY_FLAGS (con).flow_control) tcflow (input_fd, TCOON);
1705 #endif 1704 #endif
1706 #endif 1705 #endif
1710 { 1709 {
1711 /* IBM's HFT device usually thinks a ^J should be LF/CR. 1710 /* IBM's HFT device usually thinks a ^J should be LF/CR.
1712 We need it to be only LF. This is the way that is 1711 We need it to be only LF. This is the way that is
1713 done. */ 1712 done. */
1714 struct termio tty; 1713 struct termio tty;
1715 1714
1716 if (ioctl (output_fd, HFTGETID, &tty) != -1) 1715 if (ioctl (output_fd, HFTGETID, &tty) != -1)
1717 write (output_fd, "\033[20l", 5); 1716 write (output_fd, "\033[20l", 5);
1718 } 1717 }
1719 #endif 1718 #endif
1720 #endif 1719 #endif
1764 Lisp_Object devcons; 1763 Lisp_Object devcons;
1765 1764
1766 CONSOLE_DEVICE_LOOP (devcons, con) 1765 CONSOLE_DEVICE_LOOP (devcons, con)
1767 { 1766 {
1768 struct device *d = XDEVICE (XCAR (devcons)); 1767 struct device *d = XDEVICE (XCAR (devcons));
1769 1768
1770 init_one_device (d); 1769 init_one_device (d);
1771 } 1770 }
1772 } 1771 }
1773 1772
1774 void 1773 void
1789 1788
1790 #if 0 /* not currently used */ 1789 #if 0 /* not currently used */
1791 1790
1792 /* Return nonzero if safe to use tabs in output. 1791 /* Return nonzero if safe to use tabs in output.
1793 At the time this is called, init_sys_modes has not been done yet. */ 1792 At the time this is called, init_sys_modes has not been done yet. */
1794 1793
1795 int 1794 int
1796 tabs_safe_p (struct device *d) 1795 tabs_safe_p (struct device *d)
1797 { 1796 {
1798 #ifdef HAVE_TTY 1797 #ifdef HAVE_TTY
1799 if (DEVICE_TTY_P (d)) 1798 if (DEVICE_TTY_P (d))
1800 { 1799 {
1801 struct emacs_tty tty; 1800 struct emacs_tty tty;
1802 1801
1803 EMACS_GET_TTY (DEVICE_INFD (d), &tty); 1802 EMACS_GET_TTY (DEVICE_INFD (d), &tty);
1804 return EMACS_TTY_TABS_OK (&tty); 1803 return EMACS_TTY_TABS_OK (&tty);
1805 } 1804 }
1806 #endif 1805 #endif
1807 return 1; 1806 return 1;
1822 1821
1823 #ifdef TIOCGWINSZ 1822 #ifdef TIOCGWINSZ
1824 { 1823 {
1825 /* BSD-style. */ 1824 /* BSD-style. */
1826 struct winsize size; 1825 struct winsize size;
1827 1826
1828 if (ioctl (input_fd, TIOCGWINSZ, &size) == -1) 1827 if (ioctl (input_fd, TIOCGWINSZ, &size) == -1)
1829 *widthp = *heightp = 0; 1828 *widthp = *heightp = 0;
1830 else 1829 else
1831 { 1830 {
1832 *widthp = size.ws_col; 1831 *widthp = size.ws_col;
1835 } 1834 }
1836 #else 1835 #else
1837 #ifdef TIOCGSIZE 1836 #ifdef TIOCGSIZE
1838 { 1837 {
1839 /* SunOS - style. */ 1838 /* SunOS - style. */
1840 struct ttysize size; 1839 struct ttysize size;
1841 1840
1842 if (ioctl (input_fd, TIOCGSIZE, &size) == -1) 1841 if (ioctl (input_fd, TIOCGSIZE, &size) == -1)
1843 *widthp = *heightp = 0; 1842 *widthp = *heightp = 0;
1844 else 1843 else
1845 { 1844 {
1846 *widthp = size.ts_cols; 1845 *widthp = size.ts_cols;
1849 } 1848 }
1850 #else 1849 #else
1851 #ifdef VMS 1850 #ifdef VMS
1852 { 1851 {
1853 struct vms_sensemode tty; 1852 struct vms_sensemode tty;
1854 1853
1855 SYS$QIOW (0, input_fd, IO$_SENSEMODE, &tty, 0, 0, 1854 SYS$QIOW (0, input_fd, IO$_SENSEMODE, &tty, 0, 0,
1856 &tty.class, 12, 0, 0, 0, 0); 1855 &tty.class, 12, 0, 0, 0, 0);
1857 *widthp = tty.scr_wid; 1856 *widthp = tty.scr_wid;
1858 *heightp = tty.scr_len; 1857 *heightp = tty.scr_len;
1859 } 1858 }
1923 input_fd = CONSOLE_TTY_DATA (con)->infd; 1922 input_fd = CONSOLE_TTY_DATA (con)->infd;
1924 output_fd = CONSOLE_TTY_DATA (con)->outfd; 1923 output_fd = CONSOLE_TTY_DATA (con)->outfd;
1925 1924
1926 #if defined (IBMR2AIX) && defined (AIXHFT) 1925 #if defined (IBMR2AIX) && defined (AIXHFT)
1927 { 1926 {
1928 /* HFT consoles normally use ^J as a LF/CR. We forced it to 1927 /* HFT consoles normally use ^J as a LF/CR. We forced it to
1929 do the LF only. Now, we need to reset it. */ 1928 do the LF only. Now, we need to reset it. */
1930 struct termio tty; 1929 struct termio tty;
1931 1930
1932 if (ioctl (output_fd, HFTGETID, &tty) != -1) 1931 if (ioctl (output_fd, HFTGETID, &tty) != -1)
1933 write (output_fd, "\033[20h", 5); 1932 write (output_fd, "\033[20h", 5);
1934 } 1933 }
1935 #endif 1934 #endif
1936 1935
1937 tty_redisplay_shutdown (con); 1936 tty_redisplay_shutdown (con);
1938 /* reset_tty_modes() flushes the connection at its end. */ 1937 /* reset_tty_modes() flushes the connection at its end. */
1939 reset_tty_modes (con); 1938 reset_tty_modes (con);
1940 1939
1941 #if defined (BSD) 1940 #if defined (BSD)
1942 /* Avoid possible loss of output when changing terminal modes. */ 1941 /* Avoid possible loss of output when changing terminal modes. */
1943 fsync (output_fd); 1942 fsync (output_fd);
1944 #endif 1943 #endif
1945 1944
1946 while (EMACS_SET_TTY (input_fd, &CONSOLE_TTY_DATA (con)->old_tty, 0) 1945 while (EMACS_SET_TTY (input_fd, &CONSOLE_TTY_DATA (con)->old_tty, 0)
1947 < 0 && errno == EINTR) 1946 < 0 && errno == EINTR)
1948 ; 1947 ;
1949 1948
1950 #ifdef MSDOS 1949 #ifdef MSDOS
1951 dos_ttcooked (); 1950 dos_ttcooked ();
1952 #endif 1951 #endif
1953 1952
1954 #ifdef SET_LINE_DISCIPLINE 1953 #ifdef SET_LINE_DISCIPLINE
1955 /* Ultrix's termios *ignores* any line discipline except TERMIODISC. 1954 /* Ultrix's termios *ignores* any line discipline except TERMIODISC.
1956 A different old line discipline is therefore not restored, yet. 1955 A different old line discipline is therefore not restored, yet.
1957 Restore the old line discipline by hand. */ 1956 Restore the old line discipline by hand. */
1958 ioctl (input_fd, TIOCSETD, &old_tty.main.c_line); 1957 ioctl (input_fd, TIOCSETD, &old_tty.main.c_line);
1995 Lisp_Object devcons; 1994 Lisp_Object devcons;
1996 1995
1997 CONSOLE_DEVICE_LOOP (devcons, con) 1996 CONSOLE_DEVICE_LOOP (devcons, con)
1998 { 1997 {
1999 struct device *d = XDEVICE (XCAR (devcons)); 1998 struct device *d = XDEVICE (XCAR (devcons));
2000 1999
2001 reset_one_device (d); 2000 reset_one_device (d);
2002 } 2001 }
2003 } 2002 }
2004 2003
2005 void 2004 void
2009 Lisp_Object concons; 2008 Lisp_Object concons;
2010 2009
2011 CONSOLE_LOOP (concons) 2010 CONSOLE_LOOP (concons)
2012 { 2011 {
2013 struct console *con = XCONSOLE (XCAR (concons)); 2012 struct console *con = XCONSOLE (XCAR (concons));
2014 2013
2015 reset_one_console (con); 2014 reset_one_console (con);
2016 } 2015 }
2017 2016
2018 unmunge_process_groups (); 2017 unmunge_process_groups ();
2019 } 2018 }
2044 assert (CONSOLE_TTY_P (con)); 2043 assert (CONSOLE_TTY_P (con));
2045 input_fd = CONSOLE_TTY_DATA (con)->infd; 2044 input_fd = CONSOLE_TTY_DATA (con)->infd;
2046 2045
2047 /* If we're not on an HFT we shouldn't do any of this. We determine 2046 /* If we're not on an HFT we shouldn't do any of this. We determine
2048 if we are on an HFT by trying to get an HFT error code. If this 2047 if we are on an HFT by trying to get an HFT error code. If this
2049 call fails, we're not on an HFT. */ 2048 call fails, we're not on an HFT. */
2050 #ifdef IBMR2AIX 2049 #ifdef IBMR2AIX
2051 if (ioctl (input_fd, HFQERROR, &junk) < 0) 2050 if (ioctl (input_fd, HFQERROR, &junk) < 0)
2052 return; 2051 return;
2053 #else /* not IBMR2AIX */ 2052 #else /* not IBMR2AIX */
2054 if (ioctl (input_fd, HFQEIO, 0) < 0) 2053 if (ioctl (input_fd, HFQEIO, 0) < 0)
2155 void 2154 void
2156 init_vms_input (void) 2155 init_vms_input (void)
2157 { 2156 {
2158 /* #### broken. */ 2157 /* #### broken. */
2159 int status; 2158 int status;
2160 2159
2161 if (input_fd == 0) 2160 if (input_fd == 0)
2162 { 2161 {
2163 status = SYS$ASSIGN (&vms_input_dsc, &input_fd, 0, 0); 2162 status = SYS$ASSIGN (&vms_input_dsc, &input_fd, 0, 0);
2164 if (! (status & 1)) 2163 if (! (status & 1))
2165 LIB$STOP (status); 2164 LIB$STOP (status);
2211 #ifdef ASTDEBUG 2210 #ifdef ASTDEBUG
2212 if (vms_input_count == 25) 2211 if (vms_input_count == 25)
2213 exit (1); 2212 exit (1);
2214 printf ("Ast # %d,", vms_input_count); 2213 printf ("Ast # %d,", vms_input_count);
2215 printf (" iosb = %x, %x, %x, %x", 2214 printf (" iosb = %x, %x, %x, %x",
2216 vms_input_iosb.offset, vms_input_iosb.status, 2215 vms_input_iosb.offset, vms_input_iosb.status,
2217 vms_input_iosb.termlen, vms_input_iosb.term); 2216 vms_input_iosb.termlen, vms_input_iosb.term);
2218 #endif 2217 #endif
2219 if (vms_input_iosb.offset) 2218 if (vms_input_iosb.offset)
2220 { 2219 {
2221 c = vms_input_buffer; 2220 c = vms_input_buffer;
2376 * doing an unexec. After unexec the return value is undefined. 2375 * doing an unexec. After unexec the return value is undefined.
2377 * See crt0.c for further explanation and _start. 2376 * See crt0.c for further explanation and _start.
2378 * 2377 *
2379 */ 2378 */
2380 2379
2380 #ifdef __cplusplus
2381 extern "C" int _start ();
2382 #else
2383 extern int _start ();
2384 #endif
2385
2381 #ifndef HAVE_TEXT_START 2386 #ifndef HAVE_TEXT_START
2382 char * 2387 char *
2383 start_of_text (void) 2388 start_of_text (void)
2384 { 2389 {
2385 #ifdef TEXT_START 2390 #ifdef TEXT_START
2387 #else 2392 #else
2388 #ifdef GOULD 2393 #ifdef GOULD
2389 extern csrt (); 2394 extern csrt ();
2390 return ((char *) csrt); 2395 return ((char *) csrt);
2391 #else /* not GOULD */ 2396 #else /* not GOULD */
2392 extern int _start ();
2393 return ((char *) _start); 2397 return ((char *) _start);
2394 #endif /* GOULD */ 2398 #endif /* GOULD */
2395 #endif /* TEXT_START */ 2399 #endif /* TEXT_START */
2396 } 2400 }
2397 #endif /* not HAVE_TEXT_START */ 2401 #endif /* not HAVE_TEXT_START */
2419 * unexec will produce a shared executable where the data can be 2423 * unexec will produce a shared executable where the data can be
2420 * at the normal shared text boundry and the startofdata variable 2424 * at the normal shared text boundry and the startofdata variable
2421 * will be patched by unexec to the correct value. 2425 * will be patched by unexec to the correct value.
2422 * 2426 *
2423 */ 2427 */
2424 2428
2425 void * 2429 void *
2426 start_of_data (void) 2430 start_of_data (void)
2427 { 2431 {
2428 #ifdef DATA_START 2432 #ifdef DATA_START
2429 return ((char *) DATA_START); 2433 return ((char *) DATA_START);
2451 2455
2452 /* 2456 /*
2453 * Return the address of the end of the text segment prior to 2457 * Return the address of the end of the text segment prior to
2454 * doing an unexec. After unexec the return value is undefined. 2458 * doing an unexec. After unexec the return value is undefined.
2455 */ 2459 */
2456 2460
2457 char * 2461 char *
2458 end_of_text (void) 2462 end_of_text (void)
2459 { 2463 {
2460 #ifdef TEXT_END 2464 #ifdef TEXT_END
2461 return ((char *) TEXT_END); 2465 return ((char *) TEXT_END);
2462 #else 2466 #else
2463 extern int etext; 2467 extern int etext;
2464 return ((char *) &etext); 2468 return ((char *) &etext);
2465 #endif 2469 #endif
2466 } 2470 }
2467 2471
2468 /* 2472 /*
2469 * Return the address of the end of the data segment prior to 2473 * Return the address of the end of the data segment prior to
2470 * doing an unexec. After unexec the return value is undefined. 2474 * doing an unexec. After unexec the return value is undefined.
2471 */ 2475 */
2472 2476
2614 /* BSD 4.1 crap deleted. 4.2 was released in 1983, for God's sake! I 2618 /* BSD 4.1 crap deleted. 4.2 was released in 1983, for God's sake! I
2615 can't imagine that anyone is actually running that OS any more. 2619 can't imagine that anyone is actually running that OS any more.
2616 You can't use X under it (I think) because there's no select(). 2620 You can't use X under it (I think) because there's no select().
2617 Anyway, the signal stuff has all been changed. If someone wants to 2621 Anyway, the signal stuff has all been changed. If someone wants to
2618 get this stuff working again, look in the FSF Emacs sources. */ 2622 get this stuff working again, look in the FSF Emacs sources. */
2619 2623
2620 /* POSIX signals support - DJB */ 2624 /* POSIX signals support - DJB */
2621 2625
2622 #ifdef HAVE_SIGPROCMASK 2626 #ifdef HAVE_SIGPROCMASK
2623 2627
2624 /* #### Is there any reason this is static global rather than local? */ 2628 /* #### Is there any reason this is static global rather than local? */
2813 int 2817 int
2814 sys_open (CONST char *path, int oflag, ...) 2818 sys_open (CONST char *path, int oflag, ...)
2815 { 2819 {
2816 int mode; 2820 int mode;
2817 va_list ap; 2821 va_list ap;
2818 2822
2819 va_start (ap, oflag); 2823 va_start (ap, oflag);
2820 mode = va_arg (ap, int); 2824 mode = va_arg (ap, int);
2821 va_end (ap); 2825 va_end (ap);
2822 2826
2823 PATHNAME_CONVERT_OUT (path); 2827 PATHNAME_CONVERT_OUT (path);
2893 #ifdef VMS 2897 #ifdef VMS
2894 return vms_write (fildes, buf, nbyte); 2898 return vms_write (fildes, buf, nbyte);
2895 #else 2899 #else
2896 int rtnval; 2900 int rtnval;
2897 int bytes_written = 0; 2901 int bytes_written = 0;
2898 CONST char *b = buf; 2902 CONST char *b = (CONST char *) buf;
2899 2903
2900 /* No harm in looping regardless of the INTERRUPTIBLE_IO setting. */ 2904 /* No harm in looping regardless of the INTERRUPTIBLE_IO setting. */
2901 while (nbyte > 0) 2905 while (nbyte > 0)
2902 { 2906 {
2903 rtnval = write (fildes, b, nbyte); 2907 rtnval = write (fildes, b, nbyte);
3080 3084
3081 3085
3082 #ifdef ENCAPSULATE_READDIR 3086 #ifdef ENCAPSULATE_READDIR
3083 DIRENTRY * 3087 DIRENTRY *
3084 sys_readdir (DIR *dirp) 3088 sys_readdir (DIR *dirp)
3085 { 3089 {
3086 DIRENTRY *rtnval; 3090 DIRENTRY *rtnval;
3087 3091
3088 /* Apparently setting errno is necessary on some systems? 3092 /* Apparently setting errno is necessary on some systems?
3089 Maybe readdir() doesn't always set errno ?! */ 3093 Maybe readdir() doesn't always set errno ?! */
3090 while (!(errno = 0, rtnval = readdir (dirp)) 3094 while (!(errno = 0, rtnval = readdir (dirp))
3097 return NULL; 3101 return NULL;
3098 { 3102 {
3099 Extcount external_len; 3103 Extcount external_len;
3100 int ascii_filename_p = 1; 3104 int ascii_filename_p = 1;
3101 CONST Extbyte * CONST external_name = (CONST Extbyte *) rtnval->d_name; 3105 CONST Extbyte * CONST external_name = (CONST Extbyte *) rtnval->d_name;
3102 3106
3103 /* Optimize for the common all-ASCII case, computing len en passant */ 3107 /* Optimize for the common all-ASCII case, computing len en passant */
3104 for (external_len = 0; external_name[external_len] ; external_len++) 3108 for (external_len = 0; external_name[external_len] ; external_len++)
3105 { 3109 {
3106 if (!BYTE_ASCII_P (external_name[external_len])) 3110 if (!BYTE_ASCII_P (external_name[external_len]))
3107 ascii_filename_p = 0; 3111 ascii_filename_p = 0;
3108 } 3112 }
3109 if (ascii_filename_p) 3113 if (ascii_filename_p)
3110 return rtnval; 3114 return rtnval;
3111 3115
3112 { /* Non-ASCII filename */ 3116 { /* Non-ASCII filename */
3113 static bufbyte_dynarr *internal_DIRENTRY; 3117 static Bufbyte_dynarr *internal_DIRENTRY;
3114 CONST Bufbyte *internal_name; 3118 CONST Bufbyte *internal_name;
3115 Bytecount internal_len; 3119 Bytecount internal_len;
3116 if (!internal_DIRENTRY) 3120 if (!internal_DIRENTRY)
3117 internal_DIRENTRY = Dynarr_new (Bufbyte); 3121 internal_DIRENTRY = Dynarr_new (Bufbyte);
3118 else 3122 else
3287 int 3291 int
3288 sys_execvp (CONST char *path, char * CONST * argv) 3292 sys_execvp (CONST char *path, char * CONST * argv)
3289 { 3293 {
3290 int i, argc; 3294 int i, argc;
3291 CONST char ** new_argv; 3295 CONST char ** new_argv;
3292 3296
3293 PATHNAME_CONVERT_OUT (path); 3297 PATHNAME_CONVERT_OUT (path);
3294 for (argc = 0; argv[argc]; argc++) 3298 for (argc = 0; argv[argc]; argc++)
3295 ; 3299 ;
3296 new_argv = (CONST char **) alloca ( (argc + 1) * sizeof (* new_argv)); 3300 new_argv = alloca_array (CONST char *, argc + 1);
3297 for (i = 0; i < argc; i++) 3301 for (i = 0; i < argc; i++)
3298 GET_C_CHARPTR_EXT_FILENAME_DATA_ALLOCA (argv[i], new_argv[i]); 3302 GET_C_CHARPTR_EXT_FILENAME_DATA_ALLOCA (argv[i], new_argv[i]);
3299 new_argv[argc] = NULL; 3303 new_argv[argc] = NULL;
3300 return execvp (path, (char **) new_argv); 3304 return execvp (path, (char **) new_argv);
3301 } 3305 }
3390 3394
3391 int 3395 int
3392 dup2 (int oldd, int newd) 3396 dup2 (int oldd, int newd)
3393 { 3397 {
3394 int fd, ret; 3398 int fd, ret;
3395 3399
3396 sys_close (newd); 3400 sys_close (newd);
3397 3401
3398 #ifdef F_DUPFD 3402 #ifdef F_DUPFD
3399 fd = fcntl (oldd, F_DUPFD, newd); 3403 fd = fcntl (oldd, F_DUPFD, newd);
3400 if (fd != newd) 3404 if (fd != newd)
3417 * Gettimeofday. Simulate as much as possible. Only accurate 3421 * Gettimeofday. Simulate as much as possible. Only accurate
3418 * to nearest second. Emacs doesn't use tzp so ignore it for now. 3422 * to nearest second. Emacs doesn't use tzp so ignore it for now.
3419 */ 3423 */
3420 3424
3421 #if !defined (HAVE_GETTIMEOFDAY) 3425 #if !defined (HAVE_GETTIMEOFDAY)
3422 3426
3423 int 3427 int
3424 gettimeofday (struct timeval *tp, struct timezone *tzp) 3428 gettimeofday (struct timeval *tp, struct timezone *tzp)
3425 { 3429 {
3426 extern long time (); 3430 extern long time ();
3427 3431
3428 tp->tv_sec = time ((long *)0); 3432 tp->tv_sec = time ((long *)0);
3429 tp->tv_usec = 0; 3433 tp->tv_usec = 0;
3430 if (tzp != 0) 3434 if (tzp != 0)
3431 tzp->tz_minuteswest = -1; 3435 tzp->tz_minuteswest = -1;
3432 return (0); 3436 return (0);
3433 } 3437 }
3434 3438
3435 #endif /* !HAVE_GETTIMEOFDAY */ 3439 #endif /* !HAVE_GETTIMEOFDAY */
3436 3440
3437 /* No need to encapsulate utime and utimes explicitly because all 3441 /* No need to encapsulate utime and utimes explicitly because all
3438 access to those functions goes through the following. */ 3442 access to those functions goes through the following. */
3439 3443
3440 int 3444 int
3441 set_file_times (char *filename, EMACS_TIME atime, EMACS_TIME mtime) 3445 set_file_times (char *filename, EMACS_TIME atime, EMACS_TIME mtime)
4171 return buf; 4175 return buf;
4172 } 4176 }
4173 4177
4174 #ifdef access 4178 #ifdef access
4175 #undef access 4179 #undef access
4176 4180
4177 /* The following is necessary because 'access' emulation by VMS C (2.0) does 4181 /* The following is necessary because 'access' emulation by VMS C (2.0) does
4178 * not work correctly. (It also doesn't work well in version 2.3.) 4182 * not work correctly. (It also doesn't work well in version 2.3.)
4179 */ 4183 */
4180 4184
4181 #ifdef VMS4_4 4185 #ifdef VMS4_4
4210 4214
4211 /* translate possible directory spec into .DIR file name, so brain-dead 4215 /* translate possible directory spec into .DIR file name, so brain-dead
4212 * access can treat the directory like a file. */ 4216 * access can treat the directory like a file. */
4213 if (directory_file_name (path, dir_fn)) 4217 if (directory_file_name (path, dir_fn))
4214 path = dir_fn; 4218 path = dir_fn;
4215 4219
4216 if (mode == F_OK) 4220 if (mode == F_OK)
4217 return access (path, mode); 4221 return access (path, mode);
4218 if (user == NULL && (user = (char *) getenv ("USER")) == NULL) 4222 if (user == NULL && (user = (char *) getenv ("USER")) == NULL)
4219 return -1; 4223 return -1;
4220 { 4224 {
4224 unsigned short int dummy; 4228 unsigned short int dummy;
4225 item itemlst[3]; 4229 item itemlst[3];
4226 static int constant = ACL$C_FILE; 4230 static int constant = ACL$C_FILE;
4227 DESCRIPTOR (path_desc, path); 4231 DESCRIPTOR (path_desc, path);
4228 DESCRIPTOR (user_desc, user); 4232 DESCRIPTOR (user_desc, user);
4229 4233
4230 flags = 0; 4234 flags = 0;
4231 acces = 0; 4235 acces = 0;
4232 if ((mode & X_OK) && ((stat = access (path, mode)) < 0 || mode == X_OK)) 4236 if ((mode & X_OK) && ((stat = access (path, mode)) < 0 || mode == X_OK))
4233 return stat; 4237 return stat;
4234 if (mode & R_OK) 4238 if (mode & R_OK)
4286 4290
4287 if (type != 2) /* not checking write access */ 4291 if (type != 2) /* not checking write access */
4288 return access (filename, type); 4292 return access (filename, type);
4289 4293
4290 /* Check write protection. */ 4294 /* Check write protection. */
4291 4295
4292 #define CHECKPRIV(bit) (prvmask.bit) 4296 #define CHECKPRIV(bit) (prvmask.bit)
4293 #define WRITEABLE(field) (! ((xab.xab$w_pro >> field) & XAB$M_NOWRITE)) 4297 #define WRITEABLE(field) (! ((xab.xab$w_pro >> field) & XAB$M_NOWRITE))
4294 4298
4295 /* Find privilege bits */ 4299 /* Find privilege bits */
4296 status = SYS$SETPRV (0, 0, 0, prvmask); 4300 status = SYS$SETPRV (0, 0, 0, prvmask);
4348 4352
4349 return -1; /* Not writeable */ 4353 return -1; /* Not writeable */
4350 } 4354 }
4351 #endif /* not VMS4_4 */ 4355 #endif /* not VMS4_4 */
4352 #endif /* access */ 4356 #endif /* access */
4353 4357
4354 static char vtbuf[NAM$C_MAXRSS+1]; 4358 static char vtbuf[NAM$C_MAXRSS+1];
4355 4359
4356 /* translate a vms file spec to a unix path */ 4360 /* translate a vms file spec to a unix path */
4357 char * 4361 char *
4358 sys_translate_vms (char *vfile) 4362 sys_translate_vms (char *vfile)
4388 4392
4389 case '-': 4393 case '-':
4390 *targ++ = '.'; 4394 *targ++ = '.';
4391 *targ++ = '.'; 4395 *targ++ = '.';
4392 break; 4396 break;
4393 4397
4394 default: 4398 default:
4395 *targ++ = *vfile; 4399 *targ++ = *vfile;
4396 break; 4400 break;
4397 } 4401 }
4398 vfile++; 4402 vfile++;
4480 break; 4484 break;
4481 } 4485 }
4482 ufile++; 4486 ufile++;
4483 } 4487 }
4484 *targ = '\0'; 4488 *targ = '\0';
4485 4489
4486 return utbuf; 4490 return utbuf;
4487 } 4491 }
4488 4492
4489 char * 4493 char *
4490 getwd (char *pathname) 4494 getwd (char *pathname)
4804 * The VMS C library routine creat actually creates a new version of an 4808 * The VMS C library routine creat actually creates a new version of an
4805 * existing file rather than truncating the old version. There are times 4809 * existing file rather than truncating the old version. There are times
4806 * when this is not the desired behavior, for instance, when writing an 4810 * when this is not the desired behavior, for instance, when writing an
4807 * auto save file (you only want one version), or when you don't have 4811 * auto save file (you only want one version), or when you don't have
4808 * write permission in the directory containing the file (but the file 4812 * write permission in the directory containing the file (but the file
4809 * itself is writable). Hence this routine, which is equivalent to 4813 * itself is writable). Hence this routine, which is equivalent to
4810 * "close (creat (fn, 0));" on Unix if fn already exists. 4814 * "close (creat (fn, 0));" on Unix if fn already exists.
4811 */ 4815 */
4812 int 4816 int
4813 vms_truncate (char *fn) 4817 vms_truncate (char *fn)
4814 { 4818 {
4859 get_uaf_name (char *uname) 4863 get_uaf_name (char *uname)
4860 { 4864 {
4861 status; 4865 status;
4862 struct FAB uaf_fab; 4866 struct FAB uaf_fab;
4863 struct RAB uaf_rab; 4867 struct RAB uaf_rab;
4864 4868
4865 uaf_fab = cc$rms_fab; 4869 uaf_fab = cc$rms_fab;
4866 uaf_rab = cc$rms_rab; 4870 uaf_rab = cc$rms_rab;
4867 /* initialize fab fields */ 4871 /* initialize fab fields */
4868 uaf_fab.fab$l_fna = "SYS$SYSTEM:SYSUAF.DAT"; 4872 uaf_fab.fab$l_fna = "SYS$SYSTEM:SYSUAF.DAT";
4869 uaf_fab.fab$b_fns = 21; 4873 uaf_fab.fab$b_fns = 21;
4922 get_uaf_uic (unsigned long uic) 4926 get_uaf_uic (unsigned long uic)
4923 { 4927 {
4924 status; 4928 status;
4925 struct FAB uaf_fab; 4929 struct FAB uaf_fab;
4926 struct RAB uaf_rab; 4930 struct RAB uaf_rab;
4927 4931
4928 uaf_fab = cc$rms_fab; 4932 uaf_fab = cc$rms_fab;
4929 uaf_rab = cc$rms_rab; 4933 uaf_rab = cc$rms_rab;
4930 /* initialize fab fields */ 4934 /* initialize fab fields */
4931 uaf_fab.fab$l_fna = "SYS$SYSTEM:SYSUAF.DAT"; 4935 uaf_fab.fab$l_fna = "SYS$SYSTEM:SYSUAF.DAT";
4932 uaf_fab.fab$b_fns = 21; 4936 uaf_fab.fab$b_fns = 21;
5193 We could use the chmod function, but Eunichs uses 3 bits per user category 5197 We could use the chmod function, but Eunichs uses 3 bits per user category
5194 to describe the protection, and VMS uses 4 (write and delete are separate 5198 to describe the protection, and VMS uses 4 (write and delete are separate
5195 bits). To maintain portability, the VMS implementation of `chmod' wires 5199 bits). To maintain portability, the VMS implementation of `chmod' wires
5196 the W and D bits together. */ 5200 the W and D bits together. */
5197 5201
5198 5202
5199 static char vms_file_written[NAM$C_MAXRSS]; 5203 static char vms_file_written[NAM$C_MAXRSS];
5200 5204
5201 int 5205 int
5202 rename_sans_version (char *from, char *to) 5206 rename_sans_version (char *from, char *to)
5203 { 5207 {