mirror of
https://github.com/Stichting-MINIX-Research-Foundation/pkgsrc-ng.git
synced 2025-09-08 03:44:13 -04:00
209 lines
4.1 KiB
Plaintext
209 lines
4.1 KiB
Plaintext
$NetBSD: patch-av,v 1.5 2013/01/11 13:24:32 joerg Exp $
|
|
|
|
--- icb/unix.c.orig 1995-02-24 21:20:31.000000000 +0000
|
|
+++ icb/unix.c
|
|
@@ -7,20 +7,27 @@
|
|
#include <stdio.h>
|
|
#include "icb.h"
|
|
#include "externs.h"
|
|
+#include <limits.h>
|
|
#include <pwd.h>
|
|
-#include <sys/dir.h>
|
|
+#include <time.h>
|
|
+#include <dirent.h>
|
|
|
|
#undef stty
|
|
#undef gtty
|
|
|
|
-#ifndef SYSV
|
|
-
|
|
#ifdef linux
|
|
#include <bsd/sgtty.h>
|
|
#else
|
|
#include <sgtty.h>
|
|
#endif
|
|
|
|
+#if defined(__linux__) || defined(__NetBSD__) || defined(__sun)
|
|
+#include <termios.h>
|
|
+#define TTYSTRUCT termios
|
|
+#define stty(fd,buf) tcsetattr((fd),TCSANOW,(buf))
|
|
+#define gtty(fd,buf) tcgetattr((fd),(buf))
|
|
+#else
|
|
+#ifndef SYSV
|
|
#define TTYSTRUCT sgttyb
|
|
#define stty(fd,buf) ioctl((fd),TIOCSETN,(buf))
|
|
#define gtty(fd,buf) ioctl((fd),TIOCGETP,(buf))
|
|
@@ -30,6 +37,7 @@
|
|
#define stty(fd,buf) ioctl((fd),TCSETA,(buf))
|
|
#define gtty(fd,buf) ioctl((fd),TCGETA,(buf))
|
|
#endif /* SYSV */
|
|
+#endif /* TIOCSETA */
|
|
|
|
char *getlogin();
|
|
|
|
@@ -65,13 +73,16 @@ gettime()
|
|
|
|
/* set line buffering for an open file pointer */
|
|
/* output will be flushed every newline */
|
|
+static char buf[1024];
|
|
|
|
linebuffer(fp)
|
|
FILE *fp;
|
|
{
|
|
-#ifndef SYSV
|
|
+#ifndef _IOLBF
|
|
+ setvbuf(fp, buf, _IOLBF, sizeof(buf));
|
|
+#else
|
|
setlinebuf(fp);
|
|
-#endif /* SYSV */
|
|
+#endif
|
|
}
|
|
|
|
|
|
@@ -79,13 +90,13 @@ FILE *fp;
|
|
pushback(c)
|
|
char c;
|
|
{
|
|
-#ifndef SYSV
|
|
+#ifdef TIOCSTI
|
|
if (ioctl(0, TIOCSTI, &c) < 0)
|
|
perror("TIOCSTI ioctl failed");
|
|
-#else /* SYSV */
|
|
+#else
|
|
if (ungetc(c,stdin) == EOF)
|
|
perror("ungetc() failed");
|
|
-#endif /* SYSV */
|
|
+#endif
|
|
}
|
|
|
|
|
|
@@ -94,25 +105,25 @@ char c;
|
|
|
|
getterm()
|
|
{
|
|
-#ifndef SYSV
|
|
+#if !defined(TCSETA) && !defined(TCSANOW)
|
|
struct ltchars lt;
|
|
-#endif /* SYSV */
|
|
+#endif
|
|
/* get tty settings */
|
|
if (gtty(0,&origtty) < 0) {
|
|
badttyinfo++;
|
|
ttyinfo.erase = '\b'; /* ^H */
|
|
ttyinfo.kill = '\025'; /* ^U */
|
|
} else {
|
|
-#ifndef SYSV
|
|
- ttyinfo.erase = origtty.sg_erase;
|
|
- ttyinfo.kill = origtty.sg_kill;
|
|
-#else /* SYSV */
|
|
+#if defined(TCSETA) || defined(TCSANOW)
|
|
ttyinfo.erase = origtty.c_cc[VERASE];
|
|
ttyinfo.kill = origtty.c_cc[VKILL];
|
|
-#endif /* SYSV */
|
|
+#else
|
|
+ ttyinfo.erase = origtty.sg_erase;
|
|
+ ttyinfo.kill = origtty.sg_kill;
|
|
+#endif
|
|
}
|
|
|
|
-#ifndef SYSV
|
|
+#if !defined(TCSETA) && !defined(TCSANOW)
|
|
/* get local special chars */
|
|
if (ioctl(0, TIOCGLTC, <) < 0) {
|
|
ttyinfo.redraw = '\022'; /* ^R */
|
|
@@ -121,10 +132,10 @@ getterm()
|
|
ttyinfo.redraw = lt.t_rprntc;
|
|
ttyinfo.werase = lt.t_werasc;
|
|
}
|
|
-#else /* SYSV */
|
|
+#else
|
|
ttyinfo.redraw = '\022'; /* ^R */
|
|
ttyinfo.werase = '\027'; /* ^W */
|
|
-#endif /* SYSV */
|
|
+#endif
|
|
|
|
/* get the current window size */
|
|
getwinsize();
|
|
@@ -134,7 +145,7 @@ getterm()
|
|
|
|
/* set up terminal modes optimal for icb */
|
|
|
|
-icbterm()
|
|
+void icbterm(void)
|
|
{
|
|
struct TTYSTRUCT tty;
|
|
|
|
@@ -145,14 +156,14 @@ icbterm()
|
|
bcopy((char *)&origtty, (char *)&tty, (unsigned)sizeof(struct TTYSTRUCT));
|
|
|
|
/* turn on cbreak - turn off echo */
|
|
-#ifndef SYSV
|
|
- tty.sg_flags |= CBREAK;
|
|
- tty.sg_flags &= ~ECHO;
|
|
-#else /* SYSV */
|
|
+#if defined(TCSETA) || defined(TCSANOW)
|
|
tty.c_lflag &= ~ICANON;
|
|
tty.c_cc[VEOF] = 1;
|
|
tty.c_lflag &= ~ECHO;
|
|
-#endif /* SYSV */
|
|
+#else
|
|
+ tty.sg_flags |= CBREAK;
|
|
+ tty.sg_flags &= ~ECHO;
|
|
+#endif
|
|
|
|
echomode = 0;
|
|
/* set the new flags */
|
|
@@ -165,7 +176,7 @@ icbterm()
|
|
|
|
/* restore term to original settings */
|
|
|
|
-restoreterm()
|
|
+void restoreterm(void)
|
|
{
|
|
if (badttyinfo)
|
|
return;
|
|
@@ -206,7 +217,11 @@ char *s;
|
|
struct passwd *pw;
|
|
char login[17];
|
|
char *p = login;
|
|
+#ifdef NAME_MAX
|
|
+ static char path[NAME_MAX + 1];
|
|
+#else
|
|
static char path[MAXNAMLEN+1];
|
|
+#endif
|
|
|
|
/* has to start with a tilde */
|
|
if (*s++ != '~')
|
|
@@ -258,11 +273,11 @@ echo()
|
|
}
|
|
|
|
/* turn on echo */
|
|
-#ifndef SYSV
|
|
- tty.sg_flags |= ECHO;
|
|
-#else /* SYSV */
|
|
+#if defined(TCSETA) || defined(TCSANOW)
|
|
tty.c_lflag |= ECHO;
|
|
-#endif /* SYSV */
|
|
+#else
|
|
+ tty.sg_flags |= ECHO;
|
|
+#endif
|
|
|
|
echomode = 1;
|
|
|
|
@@ -287,11 +302,11 @@ noecho()
|
|
}
|
|
|
|
/* turn off echo */
|
|
-#ifndef SYSV
|
|
- tty.sg_flags &= ~ECHO;
|
|
-#else /* SYSV */
|
|
+#if defined(TCSETA) || defined(TCSANOW)
|
|
tty.c_lflag &= ~ECHO;
|
|
-#endif /* SYSV */
|
|
+#else
|
|
+ tty.sg_flags &= ~ECHO;
|
|
+#endif
|
|
|
|
echomode = 0;
|
|
|