#include "ui/TTY/console-tty.h" /* for stuff in stuff_char and
others. Seriously in need of
refactoring... */
-#else
-#include "syssignal.h"
-#include "ui/systty.h"
-#endif /* HAVE_TTY */
+#else /* !HAVE_TTY */
+#include "syssignal.h" /* always include before systty.h */
+#include "ui/TTY/systty.h"
+#endif /* HAVE_TTY */
#include "ui/console-stream.h"
void init_baud_rate(struct device *d)
{
- struct console *con = XCONSOLE(DEVICE_CONSOLE(d));
if (DEVICE_WIN_P(d) || DEVICE_STREAM_P(d)) {
DEVICE_BAUD_RATE(d) = 38400;
return;
- }
+ }
#ifdef HAVE_TTY
assert(DEVICE_TTY_P(d));
{
+ struct console *con = XCONSOLE(DEVICE_CONSOLE(d));
int input_fd = CONSOLE_TTY_DATA(con)->infd;
#if defined (HAVE_TERMIOS)
struct termios sg;
int owner = getpid();
int ioctl_status;
if (DEVICE_TTY_P(d)) {
+#ifdef HAVE_UNIXOID_EVENT_LOOP
ioctl_status = ioctl(filedesc, FIOGSAIOOWN,
&DEVICE_OLD_FCNTL_OWNER(d));
+#endif
ioctl_status = ioctl(filedesc, FIOSSAIOOWN, &owner);
}
#ifdef HAVE_WINDOW_SYSTEM
else if (!DEVICE_STREAM_P(d)) {
+#ifdef HAVE_UNIXOID_EVENT_LOOP
ioctl_status = ioctl(filedesc, SIOCGPGRP,
&DEVICE_OLD_FCNTL_OWNER(d));
+#endif
ioctl_status = ioctl(filedesc, SIOCSPGRP, &owner);
}
#endif
}
#elif defined (F_SETOWN) && !defined (F_SETOWN_BUG)
+# ifdef HAVE_UNIXOID_EVENT_LOOP
DEVICE_OLD_FCNTL_OWNER(d) = fcntl(filedesc, F_GETOWN, 0);
+# endif
# ifdef F_SETOWN_SOCK_NEG
/* stdin is a socket here */
fcntl(filedesc, F_SETOWN, -getpid());
{ /* HPUX stuff */
int ioctl_status;
if (DEVICE_TTY_P(d)) {
+# ifdef HAVE_UNIXOID_EVENT_LOOP
ioctl_status = ioctl(filedesc, FIOSSAIOOWN,
&DEVICE_OLD_FCNTL_OWNER(d));
+# endif
}
#ifdef HAVE_WINDOW_SYSTEM
else if (!DEVICE_STREAM_P(d)) {
+# ifdef HAVE_UNIXOID_EVENT_LOOP
ioctl_status = ioctl(filedesc, SIOCSPGRP,
&DEVICE_OLD_FCNTL_OWNER(d));
+# endif
}
#endif
}
#elif defined (F_SETOWN) && !defined (F_SETOWN_BUG)
+# ifdef HAVE_UNIXOID_EVENT_LOOP
fcntl(filedesc, F_SETOWN, DEVICE_OLD_FCNTL_OWNER(d));
+# endif
#endif
}
*
*/
-#if defined(ORDINARY_LINK)
+#if defined(ORDINARY_LINK)
extern char **environ;
#endif
# endif
if (hp) {
const char *fqdn = (const char *)hp->h_name;
+ size_t len = 0;
if (!strchr(fqdn, '.')) {
/* We still don't have a fully qualified domain name.
if (*alias)
fqdn = *alias;
}
- hostname = (char *)alloca(strlen(fqdn) + 1);
- strcpy(hostname, fqdn);
+ len = strlen(fqdn) + 1;
+ hostname = (char *)alloca(len);
+ xstrncpy(hostname, fqdn,len);
}
# else /* !(HAVE_GETADDRINFO && HAVE_GETNAMEINFO) */
struct addrinfo hints, *res;
ssize_t canon_len=strlen(res->ai_canonname)+1;
hostname = (char *)alloca(canon_len);
- strncpy(hostname, res->ai_canonname, canon_len);
+ xstrncpy(hostname, res->ai_canonname, canon_len);
freeaddrinfo(res);
}
# endif /* !(HAVE_GETADDRINFO && HAVE_GETNAMEINFO) */
Jamie's home page (http://www.jwz.org/worse-is-better.html). */
#ifdef ENCAPSULATE_OPEN
+
+int raw_open(const char *path, int oflag, ...)
+{
+ int mode;
+ va_list ap;
+
+ va_start(ap, oflag);
+ mode = va_arg(ap, int);
+ va_end(ap);
+ return open(path, oflag, mode);
+}
+
int sys_open(const char *path, int oflag, ...)
{
int mode;
int sys_fclose(FILE * stream)
{
#ifdef INTERRUPTIBLE_CLOSE
- int rtnval;
+ int fd = fileno(stream);
+ int rtnval = fclose(stream);
- while ((rtnval = fclose(stream)) == EOF && (errno == EINTR)) ;
+ if (rtnval == EOF && (errno == EINTR))
+ while (((rtnval=close(fd))<0) && (errno == EINTR));
return rtnval;
#else
return fclose(stream);
static int get_process_times_1(long *user_ticks, long *system_ticks)
{
-#if defined (_SC_CLK_TCK) || defined (CLK_TCK)
+#if defined (_SC_CLK_TCK) || defined (CLK_TCK)
/* We have the POSIX times() function available. */
struct tms tttt;
times(&tttt);
#endif
#endif
+#if defined HAVE_MPZ && (defined WITH_GMP || defined WITH_MP)
+# include "ent/ent-gmp.h"
+#endif /* MPZ && (GMP || MP) */
+
/* Figure out how many bits the system's random number generator uses.
`random' and `lrand48' are assumed to return 31 usable bits.
BSD `rand' returns a 31 bit value but the low order bits are unusable;
if (dp->od_ino != 0) { /* not deleted entry */
dir_static.d_ino = dp->od_ino;
- strncpy(dir_static.d_name, dp->od_name, DIRSIZ);
+ xstrncpy(dir_static.d_name, dp->od_name, DIRSIZ);
dir_static.d_name[DIRSIZ] = '\0';
dir_static.d_namlen = strlen(dir_static.d_name);
dir_static.d_reclen = sizeof(struct direct)