home *** CD-ROM | disk | FTP | other *** search
- --- qsubst.c.orig Mon Feb 3 07:38:04 1997
- +++ qsubst.c Mon Feb 3 08:34:49 1997
- @@ -77,10 +77,16 @@
- * are off.
- */
- #include <stdio.h>
- -#include <sgtty.h>
- #include <signal.h>
- +#include <termios.h>
- +#include <unistd.h>
- +#include <sys/types.h>
- #include <sys/file.h>
-
- +#define CBREAK O_CBREAK /* Because SysV doesn't have CBREAK??? */
- +#define bcopy(s1,s2,n) memcpy(s2,s1,n)
- +#define bcmp memcmp
- +
- #ifndef sigmask
- #define sigmask(sig) (1<<((sig)-1))
- #endif
- @@ -120,7 +126,7 @@
- char *endul;
- char tcp_buf[1024];
- char cap_buf[1024];
- -struct sgttyb orig_sg;
- +struct termios orig_sg;
-
- tstp_self()
- {
- @@ -136,15 +142,15 @@
-
- sigtstp()
- {
- - struct sgttyb sg;
- + struct termios sg;
-
- - if (ioctl(fileno(stdin),TIOCGETP,&sg) < 0)
- + if (tcgetattr(fileno(stdin),&sg) < 0)
- { tstp_self();
- return;
- }
- - ioctl(fileno(stdin),TIOCSETN,&orig_sg);
- + tcsetattr(fileno(stdin),TCSANOW,&orig_sg);
- tstp_self();
- - ioctl(fileno(stdin),TIOCSETN,&sg);
- + tcsetattr(fileno(stdin),TCSANOW,&sg);
- }
-
- main(ac,av)
- @@ -153,6 +159,7 @@
- {
- int skip;
- char *cp;
- + char *cp_work;
-
- argvec = av;
- if (ac < 3)
- @@ -194,7 +201,9 @@
- }
- }
- }
- - cp = mktemp("/tmp/qsubst.XXXXXX");
- + cp_work = malloc(32);
- + strcpy (cp_work, "/tmp/qsubst.XXXXXX");
- + cp = mktemp(cp_work);
- tempf = fopen(cp,"w+");
- if (tempf == NULL)
- { fprintf(stderr,"%s: cannot create temp file %s\n",argvec[0],cp);
- @@ -218,7 +227,7 @@
- argvec[0],BUF_SIZ/2);
- exit(1);
- }
- - ioctl(fileno(stdin),TIOCGETP,&orig_sg);
- + tcgetattr(fileno(stdin),&orig_sg);
- signal(SIGTSTP,sigtstp);
- allfly = 0;
- cabove = 2;
- @@ -389,19 +398,19 @@
-
- char getc_cbreak()
- {
- - struct sgttyb sg;
- - struct sgttyb osg;
- + struct termios sg;
- + struct termios osg;
- char c;
-
- - if (ioctl(fileno(stdin),TIOCGETP,&sg) < 0)
- + if (tcgetattr(fileno(stdin),&sg) < 0)
- { return(getchar());
- }
- osg = sg;
- - sg.sg_flags |= CBREAK;
- - sg.sg_flags &= ~ECHO;
- - ioctl(fileno(stdin),TIOCSETN,&sg);
- + sg.c_lflag &= ~ICANON;
- + sg.c_lflag &= ~ECHO;
- + tcsetattr(fileno(stdin),TCSANOW,&sg);
- c = getchar();
- - ioctl(fileno(stdin),TIOCSETN,&osg);
- + tcsetattr(fileno(stdin),TCSANOW,&osg);
- return(c);
- }
-
- --- Makefile.orig Mon Feb 3 07:38:03 1997
- +++ Makefile Mon Feb 3 07:38:04 1997
- @@ -1,5 +1,10 @@
- +BINDIR =<installdir>/bin
- +MANDIR =<installsharedir>/man/man1
- +
- all: qsubst
- -install: qsubst qsubst.1
- - @echo copy qsubst and qsubst.1 to appropriate directories.
- +install:
- + install -s qsubst $(BINDIR)
- + install qsubst.1 $(MANDIR)
- +
- qsubst: qsubst.c
- - $(CC) $(CFLAGS) -o qsubst qsubst.c
- + $(CC) $(CFLAGS) -o qsubst qsubst.c -ltermcap
-