Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / uip / RCS / vmh.c,v
1 head    1.20;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.20
9 date    93.08.25.17.29.44;      author jromine; state Exp;
10 branches;
11 next    1.19;
12
13 1.19
14 date    93.02.26.22.00.33;      author jromine; state Exp;
15 branches;
16 next    1.18;
17
18 1.18
19 date    92.12.15.00.20.22;      author jromine; state Exp;
20 branches;
21 next    1.17;
22
23 1.17
24 date    92.11.13.00.32.32;      author jromine; state Exp;
25 branches;
26 next    1.16;
27
28 1.16
29 date    92.11.12.23.41.07;      author jromine; state Exp;
30 branches;
31 next    1.15;
32
33 1.15
34 date    92.11.12.23.32.19;      author jromine; state Exp;
35 branches;
36 next    1.14;
37
38 1.14
39 date    92.11.12.18.22.51;      author jromine; state Exp;
40 branches;
41 next    1.13;
42
43 1.13
44 date    92.11.12.01.02.20;      author jromine; state Exp;
45 branches;
46 next    1.12;
47
48 1.12
49 date    92.11.04.02.34.45;      author jromine; state Exp;
50 branches;
51 next    1.11;
52
53 1.11
54 date    92.02.11.03.05.36;      author jromine; state Exp;
55 branches;
56 next    1.10;
57
58 1.10
59 date    92.02.10.18.12.35;      author jromine; state Exp;
60 branches;
61 next    1.9;
62
63 1.9
64 date    92.02.07.19.20.10;      author jromine; state Exp;
65 branches;
66 next    1.8;
67
68 1.8
69 date    92.01.31.22.28.38;      author jromine; state Exp;
70 branches;
71 next    1.7;
72
73 1.7
74 date    92.01.24.00.05.13;      author jromine; state Exp;
75 branches;
76 next    1.6;
77
78 1.6
79 date    90.04.05.15.00.17;      author sources; state Exp;
80 branches;
81 next    1.5;
82
83 1.5
84 date    90.03.12.10.24.05;      author sources; state Exp;
85 branches;
86 next    1.4;
87
88 1.4
89 date    90.02.06.13.34.13;      author sources; state Exp;
90 branches;
91 next    1.3;
92
93 1.3
94 date    90.02.05.14.26.52;      author sources; state Exp;
95 branches;
96 next    1.2;
97
98 1.2
99 date    90.02.05.14.17.26;      author sources; state Exp;
100 branches;
101 next    1.1;
102
103 1.1
104 date    90.02.05.14.17.07;      author sources; state Exp;
105 branches;
106 next    ;
107
108
109 desc
110 @@
111
112
113 1.20
114 log
115 @off_t fixes for BSD44
116 @
117 text
118 @/* vmh.c - visual front-end to mh */
119 #ifndef lint
120 static char ident[] = "@@(#)$Id: vmh.c,v 1.19 1993/02/26 22:00:33 jromine Exp jromine $";
121 #endif  /* lint */
122 #if defined(SYS5) && !defined(TERMINFO)
123 /*
124  * Define TERMINFO if you have it.
125  * You get it automatically if you're running SYS5, and you don't get
126  * it if you're not.  (If you're not SYS5, you probably have termcap.)
127  * We distinguish TERMINFO from SYS5 because in this file SYS5 really
128  * means "AT&T line discipline" (termio, not sgttyb), whereas terminfo
129  * is quite a separate issue.
130  */
131 #define TERMINFO        1
132 #endif
133
134 /* TODO:
135         Pass signals to client during execution
136
137         Figure out a way for the user to say how big the Scan/Display
138         windows should be.
139
140         If curses ever gets fixed, then XYZ code can be removed
141  */
142
143 #include <curses.h>
144 #ifdef  ncr
145 #define _SYS_REG_H              /* NCR redefines "ERR" in <sys/reg.h> */
146 #endif
147 #undef  OK                      /* tricky */
148 #ifdef  TERMINFO
149 #include <term.h>       /* variables describing terminal capabilities */
150 #endif  /* TERMINFO */
151 #include "../h/mh.h"
152 #include "../h/vmhsbr.h"
153 #include <ctype.h>
154 #include <errno.h>
155 #include <setjmp.h>
156 #include <signal.h>
157 #ifndef sigmask
158 #define sigmask(s)      (1 << ((s) - 1))
159 #endif  /* not sigmask */
160 #ifdef  ridge
161 #undef  SIGTSTP
162 #endif  /* ridge */
163 #ifndef BSD42
164 struct iovec {
165     char   *iov_base;
166     int     iov_len;
167 };
168 #else   /* BSD42 */
169 #include <sys/types.h>
170 #include <sys/uio.h>
171 #endif  /* BSD42 */
172 #ifdef LOCALE
173 #include        <locale.h>
174 #endif
175 #ifdef  hpux
176 #include <termio.h>
177 #define TCGETATTR               /* tcgetattr() */
178 #endif
179 #ifdef  BSD44
180 #define USE_OLD_TTY
181 #define _maxx   maxx            /* curses.h */
182 #define _maxy   maxy
183 #define _curx   curx            /* curses.h */
184 #define _cury   cury
185 void     __cputchar __P((int));
186 #undef  _putchar
187 #define _putchar        __cputchar
188 #include <sys/ioctl.h>          /* sgttyb */
189 #endif
190
191 #define ALARM   ((unsigned int) 10)
192 #define PAUSE   ((unsigned int) 2)
193
194 #ifndef abs
195 #define abs(a)          ((a) > 0 ? (a) : -(a))
196 #endif
197 #define SMALLMOVE       1
198 #define LARGEMOVE       10
199
200
201 #define XYZ                     /* XXX */
202
203 /* \f */
204
205 static struct swit switches[] = {
206 #define PRMPTSW 0
207     "prompt string", 6,
208
209 #define PROGSW  1
210     "vmhproc program", 7,
211 #define NPROGSW 2
212     "novmhproc", 9,
213
214 #define HELPSW  3
215     "help", 4,
216
217     NULL, 0
218 };
219
220 /* \f */
221                                         /* PEERS */
222 static int  PEERpid = NOTOK;
223
224 static  jmp_buf PEERctx;
225
226
227                                         /* WINDOWS */
228 static char *myprompt = "(%s) ";
229
230 static  WINDOW *Scan;
231 static  WINDOW *Status;
232 static  WINDOW *Display;
233 static  WINDOW *Command;
234
235 #define NWIN    3
236 static  int numwins;
237 WINDOW *windows[NWIN + 1];
238
239
240                                         /* LINES */
241
242 struct line {
243     int     l_no;
244     char   *l_buf;
245     struct line *l_prev;
246     struct line *l_next;
247 };
248
249 static struct line *lhead = NULL;
250 static struct line *ltop = NULL;
251 static struct line *ltail = NULL;
252
253 static int did_less = 0;
254 static int smallmove = SMALLMOVE;
255 static int largemove = LARGEMOVE;
256
257
258                                         /* TTYS */
259
260 static int  tty_ready = NOTOK;
261
262 static int  intrc;
263 #ifndef SYS5
264 #define ERASE   sg.sg_erase
265 #define KILL    sg.sg_kill
266 static struct sgttyb    sg;
267
268 #define EOFC    tc.t_eofc
269 #define INTR    tc.t_intrc
270 static struct tchars    tc;
271 #else   /* SYS5 */
272 #define ERASE   sg.c_cc[VERASE]
273 #define KILL    sg.c_cc[VKILL]
274 #define EOFC    sg.c_cc[VEOF]
275 #define INTR    sg.c_cc[VINTR]
276 static struct termio    sg;
277 #endif  /* SYS5 */
278
279 #ifndef TIOCGLTC
280 #define WERASC  ('W' & 037)
281 #else   /* TIOCGLTC */
282 #ifndef SVR4
283 #define WERASC  ltc.t_werasc
284 static struct ltchars ltc;
285 #else   /* SVR4 */
286 #define WERASC  sg.c_cc[VWERASE]
287 #undef TIOCGLTC         /* the define exists, but struct ltchars doesn't */
288 #endif
289 #endif  /* TIOCGLTC */
290
291
292 #if !defined(SYS5) && !defined(BSD44)
293 int     _putchar ();
294 #endif  /* not SYS5 */
295 #ifdef  SIGTSTP
296 char   *tgoto ();
297 #endif  /* SIGTSTP */
298
299
300                                         /* SIGNALS */
301 static TYPESIG     ALRMser (), PIPEser (), SIGser ();
302 #ifdef  SIGTSTP
303 static TYPESIG  TSTPser ();
304 #endif  /* SIGTSTP */
305
306
307                                         /* MISCELLANY */
308 extern int  errno;
309 #ifndef BSD44
310 extern int  sys_nerr;
311 extern char *sys_errlist[];
312 #endif
313
314 static void     adorn ();
315
316 static  vmh(), lreset(), linsert(), ladvance(), lretreat(), lgo();
317 static  TTYon(), TTYoff(), foreground();
318 static int      PEERinit(), pINI(), pLOOP(), pTTY(), pWIN(), WINinit();
319 static int      WINgetstr(), WINless(), WINputc(), TTYinit(), pWINaux();
320 /* \f */
321
322 /* ARGSUSED */
323
324 main (argc, argv)
325 int     argc;
326 char   *argv[];
327 {
328     int     vecp = 1,
329             nprog = 0;
330     char   *cp,
331             buffer[BUFSIZ],
332           **ap,
333           **argp,
334            *arguments[MAXARGS],
335            *vec[MAXARGS];
336
337 #ifdef LOCALE
338         setlocale(LC_ALL, "");
339 #endif
340     invo_name = r1bindex (argv[0], '/');
341     if ((cp = m_find (invo_name)) != NULL) {
342         ap = brkstring (cp = getcpy (cp), " ", "\n");
343         ap = copyip (ap, arguments);
344     }
345     else
346         ap = arguments;
347     (void) copyip (argv + 1, ap);
348     argp = arguments;
349
350 /* \f */
351
352     while (cp = *argp++)
353         if (*cp == '-')
354             switch (smatch (++cp, switches)) {
355                 case AMBIGSW: 
356                     ambigsw (cp, switches);
357                     done (1);
358                 case UNKWNSW: 
359                     vec[vecp++] = --cp;
360                     continue;
361                 case HELPSW: 
362                     (void) sprintf (buffer, "%s [switches for vmhproc]",
363                             invo_name);
364                     help (buffer, switches);
365                     done (1);
366
367                 case PRMPTSW:
368                     if (!(myprompt = *argp++) || *myprompt == '-')
369                         adios (NULLCP, "missing argument to %s", argp[-2]);
370                     continue;
371
372                 case PROGSW: 
373                     if (!(vmhproc = *argp++) || *vmhproc == '-')
374                         adios (NULLCP, "missing argument to %s", argp[-2]);
375                     continue;
376                 case NPROGSW:
377                     nprog++;
378                     continue;
379             }
380         else
381             vec[vecp++] = cp;
382
383 /* \f */
384
385     if (TTYinit (nprog) == NOTOK || WINinit (nprog) == NOTOK) {
386         vec[vecp] = NULL;
387
388         vec[0] = r1bindex (vmhproc, '/');
389         execvp (vmhproc, vec);
390         adios (vmhproc, "unable to exec");
391     }
392     TTYoff ();
393     (void) PEERinit (vecp, vec);
394     TTYon ();
395
396     vmh ();
397
398     done (0);
399 }
400
401 /* \f */
402
403 static  vmh () {
404     char    buffer[BUFSIZ];
405
406     for (;;) {
407         (void) pLOOP (RC_QRY, NULLCP);
408
409         wmove (Command, 0, 0);
410         wprintw (Command, myprompt, invo_name);
411         wclrtoeol (Command);
412         wrefresh (Command);
413
414         switch (WINgetstr (Command, buffer)) {
415             case NOTOK: 
416                 break;
417
418             case OK:
419                 done (0);       /* NOTREACHED */
420
421             default: 
422                 if (*buffer)
423                     (void) pLOOP (RC_CMD, buffer);
424                 break;
425         }
426     }
427 }
428
429 /* \f   PEERS */
430
431 static int  PEERinit (vecp, vec)
432 int     vecp;
433 char   *vec[];
434 {
435     int     pfd0[2],
436             pfd1[2];
437     char    buf1[BUFSIZ],
438             buf2[BUFSIZ];
439
440     if (pipe (pfd0) == NOTOK || pipe (pfd1) == NOTOK)
441         adios ("pipe", "unable to");
442 #ifdef  hpux
443     switch (PEERpid = fork ()) {
444     /*
445      * Calling vfork() and then another routine [like close()] before
446      * an exec() messes up the stack frame, causing crib death.
447      * Use fork() instead.
448      */
449 #else   /* not hpux */
450     switch (PEERpid = vfork ()) {
451 #endif  /* not hpux */
452         case NOTOK: 
453             adios ("vfork", "unable to");/* NOTREACHED */
454
455         case OK: 
456             (void) close (pfd0[0]);
457             (void) close (pfd1[1]);
458
459             vec[vecp++] = "-vmhread";
460             (void) sprintf (buf1, "%d", pfd1[0]);
461             vec[vecp++] = buf1;
462             vec[vecp++] = "-vmhwrite";
463             (void) sprintf (buf2, "%d", pfd0[1]);
464             vec[vecp++] = buf2;
465             vec[vecp] = NULL;
466
467             (void) signal (SIGINT, SIG_DFL);
468             (void) signal (SIGQUIT, SIG_DFL);
469
470             vec[0] = r1bindex (vmhproc, '/');
471             execvp (vmhproc, vec);
472             perror (vmhproc);
473             _exit (-1);         /* NOTREACHED */
474
475         default: 
476             (void) close (pfd0[1]);
477             (void) close (pfd1[0]);
478
479             (void) rcinit (pfd0[0], pfd1[1]);
480             return pINI ();
481     }
482 }
483
484 /* \f */
485
486 static int  pINI () {
487     register char  *bp;
488     char    buffer[BUFSIZ];
489     struct record   rcs;
490     register struct record *rc = &rcs;
491     register    WINDOW **w;
492
493     initrc (rc);
494
495     bp = buffer;
496     (void) sprintf (bp, "%d %d", RC_VRSN, numwins);
497     bp += strlen (bp);
498     for (w = windows; *w; w++) {
499         (void) sprintf (bp, " %d", (*w) -> _maxy);
500         bp += strlen (bp);
501     }
502
503     switch (str2rc (RC_INI, buffer, rc)) {
504         case RC_ACK: 
505             return OK;
506
507         case RC_ERR: 
508             if (rc -> rc_len)
509                 adios (NULLCP, "%s", rc -> rc_data);
510             else
511                 adios (NULLCP, "pINI peer error");
512
513         case RC_XXX: 
514             adios (NULLCP, "%s", rc -> rc_data);
515
516         default:
517             adios (NULLCP, "pINI protocol screw-up");
518     }
519 /* NOTREACHED */
520 }
521
522 /* \f */
523
524 static int  pLOOP (code, str)
525 char    code,
526        *str;
527 {
528     int     i;
529     struct record   rcs;
530     register struct record *rc = &rcs;
531
532     initrc (rc);
533
534     (void) str2peer (code, str);
535     for (;;)
536         switch (peer2rc (rc)) {
537             case RC_TTY:
538                 if (pTTY (rc) == NOTOK)
539                     return NOTOK;
540                 break;
541
542             case RC_WIN:
543                 if (sscanf (rc -> rc_data, "%d", &i) != 1
544                         || i <= 0
545                         || i > numwins) {
546                     (void) fmt2peer (RC_ERR, "no such window \"%s\"",
547                                 rc -> rc_data);
548                     return NOTOK;
549                 }
550                 if (pWIN (windows[i - 1]) == NOTOK)
551                     return NOTOK;
552                 break;
553
554             case RC_EOF:
555                 return OK;
556
557             case RC_ERR:
558                 if (rc -> rc_len)
559                     adorn (NULLCP, "%s", rc -> rc_data);
560                 else
561                     adorn (NULLCP, "pLOOP(%s) peer error",
562                             code == RC_QRY ? "QRY" : "CMD");
563                 return NOTOK;
564
565             case RC_FIN:
566                 if (rc -> rc_len)
567                     adorn (NULLCP, "%s", rc -> rc_data);
568                 (void) rcdone ();
569                 i = pidwait (PEERpid, OK);
570                 PEERpid = NOTOK;
571                 done (i);
572
573             case RC_XXX: 
574                 adios (NULLCP, "%s", rc -> rc_data);
575
576             default:
577                 adios (NULLCP, "pLOOP(%s) protocol screw-up",
578                         code == RC_QRY ? "QRY" : "CMD");
579         }
580 }
581
582 /* \f */
583
584 static int  pTTY (r)
585 register struct record *r;
586 {
587     TYPESIG (*hstat) (), (*istat) (), (*qstat) (), (*tstat) ();
588     struct record   rcs;
589     register struct record *rc = &rcs;
590
591     initrc (rc);
592
593     TTYoff ();
594
595     hstat = signal (SIGHUP, SIG_IGN);
596     istat = signal (SIGINT, SIG_IGN);
597     qstat = signal (SIGQUIT, SIG_IGN);
598     tstat = signal (SIGTERM, SIG_IGN);
599
600     (void) rc2rc (RC_ACK, 0, NULLCP, rc);
601
602     (void) signal (SIGHUP, hstat);
603     (void) signal (SIGINT, istat);
604     (void) signal (SIGQUIT, qstat);
605     (void) signal (SIGTERM, tstat);
606
607     TTYon ();
608
609     if (r -> rc_len && strcmp (r -> rc_data, "FAST") == 0)
610         goto no_refresh;
611
612 #ifdef  SIGTSTP
613     (void) signal (SIGTSTP, SIG_IGN);
614 #endif  /* SIGTSTP */
615 #ifndef TERMINFO
616     if (SO)
617         tputs (SO, 0, _putchar);
618 #else   /* TERMINFO */
619     putp(enter_standout_mode);
620 #endif  /* TERMINFO */
621     fprintf (stdout, "Type any key to continue... ");
622     (void) fflush (stdout);
623 #ifndef TERMINFO
624     if (SE)
625         tputs (SE, 0, _putchar);
626 #else   /* TERMINFO */
627     putp(exit_standout_mode);
628 #endif  /* TERMINFO */
629     (void) getc (stdin);
630 #ifdef  SIGTSTP
631     (void) signal (SIGTSTP, TSTPser);
632 #endif  /* SIGTSTP */
633
634     wrefresh (curscr);
635
636 no_refresh: ;
637     switch (rc -> rc_type) {
638         case RC_EOF: 
639             (void) rc2peer (RC_ACK, 0, NULLCP);
640             return OK;
641
642         case RC_ERR: 
643             if (rc -> rc_len)
644                 adorn (NULLCP, "%s", rc -> rc_data);
645             else
646                 adorn (NULLCP, "pTTY peer error");
647             return NOTOK;
648
649         case RC_XXX: 
650             adios (NULLCP, "%s", rc -> rc_data);
651
652         default:
653             adios (NULLCP, "pTTY protocol screw-up");
654     }
655 /* NOTREACHED */
656 }
657
658 /* \f */
659
660 static int  pWIN (w)
661 register WINDOW *w;
662 {
663     int     i;
664
665     did_less = 0;
666     if ((i = pWINaux (w)) == OK && did_less)
667         (void) WINless (w, 1);
668
669     lreset ();
670
671     return i;
672 }
673
674 /* \f */
675
676 static int  pWINaux (w)
677 register WINDOW *w;
678 {
679     register int    n;
680     int     eol;
681     register char   c,
682                    *bp;
683     struct record   rcs;
684     register struct record *rc = &rcs;
685
686     initrc (rc);
687
688     werase (w);
689     wmove (w, 0, 0);
690 #ifdef  XYZ
691     if (w == Status)
692         wstandout (w);
693 #endif  /* XYZ */
694
695     for (eol = 0;;)
696         switch (rc2rc (RC_ACK, 0, NULLCP, rc)) {
697             case RC_DATA: 
698                 if (eol && WINputc (w, '\n') == ERR && WINless (w, 0))
699                     goto flush;
700                 for (bp = rc -> rc_data, n = rc -> rc_len; n-- > 0; ) {
701                     if ((c = *bp++) == '\n')
702                         linsert (w);
703                     if (WINputc (w, c) == ERR)
704                         if (n == 0 && c == '\n')
705                             eol++;
706                         else
707                             if (WINless (w, 0)) {
708 flush: ;
709                                 (void) fmt2peer (RC_ERR, "flush window");
710 #ifdef  XYZ                     /* should NEVER happen... */
711                                 if (w == Status)
712                                     wstandend (w);
713 #endif  /* XYZ */
714                                 wrefresh (w);
715                                 return NOTOK;
716                             }
717                 }
718                 break;
719
720             case RC_EOF: 
721                 (void) rc2peer (RC_ACK, 0, NULLCP);
722 #ifdef  XYZ
723                 if (w == Status)
724                     wstandend (w);
725 #endif  /* XYZ */
726                 wrefresh (w);
727                 return OK;
728
729             case RC_ERR: 
730                 if (rc -> rc_len)
731                     adorn (NULLCP, "%s", rc -> rc_data);
732                 else
733                     adorn (NULLCP, "pWIN peer error");
734                 return NOTOK;
735
736             case RC_XXX: 
737                 adios (NULLCP, "%s", rc -> rc_data);
738
739             default:
740                 adios (NULLCP, "pWIN protocol screw-up");
741         }
742 /* NOTREACHED */
743 }
744
745 /* \f */
746
747 static int  pFIN () {
748     int     status;
749
750     if (PEERpid <= OK)
751         return OK;
752
753     (void) rc2peer (RC_FIN, 0, NULLCP);
754     (void) rcdone ();
755
756     switch (setjmp (PEERctx)) {
757         case OK: 
758             (void) signal (SIGALRM, ALRMser);
759             (void) alarm (ALARM);
760
761             status = pidwait (PEERpid, OK);
762
763             (void) alarm (0);
764             break;
765
766         default: 
767             (void) kill (PEERpid, SIGKILL);
768             status = NOTOK;
769             break;
770     }
771     PEERpid = NOTOK;
772
773     return status;
774 }
775
776 /* \f   WINDOWS */
777
778 static int  WINinit (nprog) {
779     register int    nlines,     /* not "lines" because terminfo uses that */
780                     top,
781                     bottom;
782
783     foreground ();
784     if (initscr () == (WINDOW *) ERR)
785         if (nprog)
786             return NOTOK;
787         else
788             adios (NULLCP, "could not initialize terminal");
789 #ifdef  SIGTSTP
790     (void) signal (SIGTSTP, SIG_DFL);
791 #endif  /* SIGTSTP */
792     sideground ();
793
794 #ifndef TERMINFO
795     if (CM == NULL)
796 #else   /* TERMINFO */
797     if (cursor_address == NULL) /* assume mtr wanted "cm", not "CM" */
798 #endif  /* TERMINFO */
799         if (nprog)
800             return NOTOK;
801         else
802             adios (NULLCP,
803                     "sorry, your terminal isn't powerful enough to run %s",
804                     invo_name);
805
806 #ifndef TERMINFO
807     if (tgetflag ("xt") || tgetnum ("sg") > 0)
808         SO = SE = US = UE = NULL;
809 #else   /* TERMINFO */
810 /*
811  * If termcap mapped directly to terminfo, we'd use the following:
812  *  if (teleray_glitch || magic_cookie_glitch > 0)
813  *      enter_standout_mode = exit_standout_mode =
814  *      enter_underline_mode = exit_underline_mode = NULL;
815  * But terminfo does the right thing so we don't have to resort to that.
816  */
817 #endif  /* TERMINFO */
818
819     if ((nlines = LINES - 1) < 11)
820         adios (NULLCP, "screen too small");
821     if ((top = nlines / 3 + 1) > LINES / 4 + 2)
822         top--;
823     bottom = nlines - top - 2;
824
825     numwins = 0;
826     Scan = windows[numwins++] = newwin (top, COLS, 0, 0);
827     Status = windows[numwins++] = newwin (1, COLS, top, 0);
828 #ifndef XYZ
829     wstandout (Status);
830 #endif  /* XYZ */
831     Display = windows[numwins++] = newwin (bottom, COLS, top + 1, 0);
832     Command = newwin (1, COLS - 1, top + 1 + bottom, 0);
833     windows[numwins] = NULL;
834
835     largemove = Display -> _maxy / 2 + 2;
836     return OK;
837 }
838
839 /* \f */
840
841 static int WINgetstr (w, buffer)
842 register WINDOW *w;
843 char   *buffer;
844 {
845     register int    c;
846     register char  *bp;
847
848     bp = buffer;
849     *bp = 0;
850
851     for (;;) {
852         switch (c = toascii (wgetch (w))) {
853             case ERR: 
854                 adios (NULLCP, "wgetch lost");
855
856             case '\f':
857                 wrefresh (curscr);
858                 break;
859
860             case '\r': 
861             case '\n': 
862                 *bp = 0;
863                 if (bp > buffer) {
864                     leaveok (curscr, FALSE);
865                     wmove (w, 0, w -> _curx - (bp - buffer));
866                     wrefresh (w);
867                     leaveok (curscr, TRUE);
868                 }
869                 return DONE;
870
871             default: 
872                 if (c == intrc) {
873                     wprintw (w, " ");
874                     wstandout (w);
875                     wprintw (w, "Interrupt");
876                     wstandend (w);
877                     wrefresh (w);
878                     *buffer = 0;
879                     return NOTOK;
880                 }
881                 if (c == EOFC) {
882                     if (bp <= buffer)
883                         return OK;
884                     break;
885                 }
886                 if (c == ERASE) {
887                     if (bp <= buffer)
888                         continue;
889                     bp--, w -> _curx--;
890                     wclrtoeol (w);
891                     break;
892                 }
893                 if (c == KILL) {
894                     if (bp <= buffer)
895                         continue;
896                     w -> _curx -= bp - buffer;
897                     bp = buffer;
898                     wclrtoeol (w);
899                     break;
900                 }
901                 if (c == WERASC) {
902                     if (bp <= buffer)
903                         continue;
904                     do {
905                         bp--, w -> _curx--;
906                     } while (isspace (*bp) && bp > buffer);
907
908                     if (bp > buffer) {
909                         do {
910                             bp--, w -> _curx--;
911                         } while (!isspace (*bp) && bp > buffer);
912                         if (isspace (*bp))
913                             bp++, w -> _curx++;
914                     }
915                     wclrtoeol (w);
916                     break;
917                 }
918                 
919                 if (c >= ' ' && c < '\177')
920                     (void) waddch (w, *bp++ = c);
921                 break;
922         }
923
924         wrefresh (w);
925     }
926 }
927
928 /* \f */
929
930 static int  WINwritev (w, iov, n)
931 register WINDOW *w;
932 register struct iovec   *iov;
933 register int     n;
934 {
935     register int    i;
936
937     werase (w);
938     wmove (w, 0, 0);
939     for (i = 0; i < n; i++, iov++)
940         wprintw (w, "%*.*s", iov -> iov_len, iov -> iov_len, iov -> iov_base);
941     wrefresh (w);
942
943     sleep (PAUSE);
944
945     return OK;
946 }
947
948 /* \f */
949
950 static struct {
951     char   *h_msg;
952     int    *h_val;
953 }               hlpmsg[] = {
954                     "           forward         backwards", NULL,
955                     "           -------         ---------", NULL,
956                     "next screen        SPACE", NULL,
957                     "next %d line%s     RETURN          y", &smallmove,
958                     "next %d line%s     EOT             u", &largemove,
959                     "go         g               G", NULL,
960                     "", NULL,
961                     "refresh            CTRL-L", NULL,
962                     "quit               q", NULL,
963
964                     NULL, NULL
965 };
966
967 /* \f */
968
969 static int  WINless (w, fin)
970 register WINDOW *w;
971 int     fin;
972 {
973     register int    c,
974                     i,
975                     n;
976     int     nfresh,
977 #ifdef  notdef
978             nlatch,
979 #endif  /* notdef */
980             nwait;
981     char   *cp;
982     register struct line   *lbottom;
983
984     did_less++;
985
986     cp = NULL;
987 #ifdef  notdef
988     if (fin)
989         ltop = NULL;
990 #endif  /* notdef */
991     lbottom = NULL;
992     nfresh = 1;
993     nwait = 0;
994     wrefresh (w);
995
996     for (;;) {
997         if (nfresh || nwait) {
998             nfresh = 0;
999 #ifdef  notdef
1000             nlatch = 1;
1001
1002 once_only: ;
1003 #endif  /* notdef */
1004             werase (w);
1005             wmove (w, 0, 0);
1006
1007             if (ltop == NULL)
1008                 if (fin) {
1009                     (void) lgo (ltail -> l_no - w -> _maxy + 1);
1010                     if (ltop == NULL)
1011                         ltop = lhead;
1012                 }
1013                 else
1014                     ltop = lbottom && lbottom -> l_prev ? lbottom -> l_prev
1015                             : lbottom;
1016
1017             for (lbottom = ltop; lbottom; lbottom = lbottom -> l_next)
1018                 if (waddstr (w, lbottom -> l_buf) == ERR
1019                         || waddch (w, '\n') == ERR)
1020                     break;
1021             if (lbottom == NULL)
1022                 if (fin) {
1023 #ifdef  notdef
1024                     if (nlatch && (ltail -> l_no >= w -> _maxy)) {
1025                         (void) lgo (ltail -> l_no - w -> _maxy + 1);
1026                         nlatch = 0;
1027                         goto once_only;
1028                     }
1029 #endif  /* notdef */
1030                     lbottom = ltail;
1031                     while (waddstr (w, "~\n") != ERR)
1032                         continue;
1033                 }
1034                 else {
1035                     wrefresh (w);
1036                     return 0;
1037                 }
1038
1039             if (!nwait)
1040                 wrefresh (w);
1041         }
1042
1043         wmove (Command, 0, 0);
1044         if (cp) {
1045             wstandout (Command);
1046             wprintw (Command, "%s", cp);
1047             wstandend (Command);
1048             cp = NULL;
1049         }
1050         else
1051             wprintw (Command, fin ? "top:%d bot:%d end:%d" : "top:%d bot:%d",
1052                     ltop -> l_no, lbottom -> l_no, ltail -> l_no);
1053         wprintw (Command, ">> ");
1054         wclrtoeol (Command);
1055         wrefresh (Command);
1056
1057         c = toascii (wgetch (Command));
1058
1059         werase (Command);
1060         wrefresh (Command);
1061
1062         if (nwait) {
1063             nwait = 0;
1064             wrefresh (w);
1065         }
1066
1067         n = 0;
1068 again:  ;
1069         switch (c) {
1070             case ' ': 
1071                 ltop = lbottom -> l_next;
1072                 nfresh++;
1073                 break;
1074
1075             case '\r': 
1076             case '\n': 
1077             case 'e': 
1078             case 'j': 
1079                 if (n)
1080                     smallmove = n;
1081                 if (ladvance (smallmove))
1082                     nfresh++;
1083                 break;
1084
1085             case 'y': 
1086             case 'k': 
1087                 if (n)
1088                     smallmove = n;
1089                 if (lretreat (smallmove))
1090                     nfresh++;
1091                 break;
1092
1093             case 'd': 
1094         eof:    ;
1095                 if (n)
1096                     largemove = n;
1097                 if (ladvance (largemove))
1098                     nfresh++;
1099                 break;
1100
1101             case 'u': 
1102                 if (n)
1103                     largemove = n;
1104                 if (lretreat (largemove))
1105                     nfresh++;
1106                 break;
1107
1108             case 'g': 
1109                 if (lgo (n ? n : 1))
1110                     nfresh++;
1111                 break;
1112
1113             case 'G': 
1114                 if (lgo (n ? n : ltail -> l_no - w -> _maxy + 1))
1115                     nfresh++;
1116                 break;
1117
1118             case '\f': 
1119             case 'r': 
1120                 wrefresh (curscr);
1121                 break;
1122
1123             case 'h': 
1124             case '?': 
1125                 werase (w);
1126                 wmove (w, 0, 0);
1127                 for (i = 0; hlpmsg[i].h_msg; i++) {
1128                     if (hlpmsg[i].h_val)
1129                         wprintw (w, hlpmsg[i].h_msg, *hlpmsg[i].h_val,
1130                                 *hlpmsg[i].h_val != 1 ? "s" : "");
1131                     else
1132                         (void) waddstr (w, hlpmsg[i].h_msg);
1133                     (void) waddch (w, '\n');
1134                 }
1135                 wrefresh (w);
1136                 nwait++;
1137                 break;
1138
1139             case 'q': 
1140                 return 1;
1141
1142             default: 
1143                 if (c == EOFC)
1144                     goto eof;
1145
1146                 if (isdigit (c)) {
1147                     wmove (Command, 0, 0);
1148                     i = 0;
1149                     while (isdigit (c)) {
1150                         wprintw (Command, "%c", c);
1151                         wrefresh (Command);
1152                         i = i * 10 + c - '0';
1153                         c = toascii (wgetch (Command));
1154                     }
1155                     werase (Command);
1156                     wrefresh (Command);
1157
1158                     if (i > 0) {
1159                         n = i;
1160                         goto again;
1161                     }
1162                     cp = "bad number";
1163                 }
1164                 else
1165                     cp = "not understood";
1166                 break;
1167         }
1168     }
1169 }
1170
1171 /* \f */
1172
1173 static int  WINputc (w, c)
1174 register WINDOW *w;
1175 register char c;
1176 {
1177     register int    x,
1178                     y;
1179
1180     switch (c) {
1181         default: 
1182             if (!isascii (c)) {
1183                 if (WINputc (w, 'M') == ERR || WINputc (w, '-') == ERR)
1184                     return ERR;
1185                 c = toascii (c);
1186             }
1187             else
1188                 if (c < ' ' || c == '\177') {
1189                     if (WINputc (w, '^') == ERR)
1190                         return ERR;
1191                     c ^= 0100;
1192                 }
1193             break;
1194
1195         case '\t': 
1196         case '\n': 
1197             break;
1198     }
1199
1200     if (w != Scan)
1201         return waddch (w, c);
1202
1203     if ((x = w -> _curx) < 0 || x >= w -> _maxx
1204             || (y = w -> _cury) < 0 || y >= w -> _maxy)
1205         return DONE;
1206
1207     switch (c) {
1208         case '\t': 
1209             for (x = 8 - (x & 0x07); x > 0; x--)
1210                 if (WINputc (w, ' ') == ERR)
1211                     return ERR;
1212             break;
1213
1214         case '\n': 
1215             if (++y < w -> _maxy) 
1216                 (void) waddch (w, c);
1217             else
1218                 wclrtoeol (w);
1219             break;
1220
1221         default: 
1222             if (++x < w -> _maxx) 
1223                 (void) waddch (w, c);
1224             break;
1225     }
1226
1227     return DONE;
1228 }
1229
1230 /* \f   LINES */
1231
1232 static  lreset () {
1233     register struct line   *lp,
1234                            *mp;
1235
1236     for (lp = lhead; lp; lp = mp) {
1237         mp = lp -> l_next;
1238         free (lp -> l_buf);
1239         free ((char *) lp);
1240     }
1241     lhead = ltop = ltail = NULL;
1242 }
1243
1244
1245 static  linsert (w)
1246 WINDOW *w;
1247 {
1248     register char  *cp;
1249     register struct line   *lp;
1250
1251     if ((lp = (struct line  *) calloc ((unsigned) 1, sizeof *lp)) == NULL)
1252         adios (NULLCP, "unable to allocate line storage");
1253
1254     lp -> l_no = (ltail ? ltail -> l_no : 0) + 1;
1255 #ifndef BSD44
1256     lp -> l_buf = getcpy (w -> _y[w -> _cury]);
1257 #else
1258     lp -> l_buf = getcpy (w -> lines[w -> _cury]->line);
1259 #endif
1260     for (cp = lp -> l_buf + strlen (lp -> l_buf) - 1; cp >= lp -> l_buf; cp--)
1261         if (isspace (*cp))
1262             *cp = 0;
1263         else
1264             break;
1265
1266     if (lhead == NULL)
1267         lhead = lp;
1268     if (ltop == NULL)
1269         ltop = lp;
1270     if (ltail)
1271         ltail -> l_next = lp;
1272     lp -> l_prev = ltail;
1273     ltail = lp;
1274 }
1275
1276 /* \f */
1277
1278 static int  ladvance (n)
1279 int     n;
1280 {
1281     register int    i;
1282     register struct line   *lp;
1283
1284     for (i = 0, lp = ltop; i < n && lp; i++, lp = lp -> l_next)
1285         continue;
1286
1287     if (ltop == lp)
1288         return 0;
1289
1290     ltop = lp;
1291     return 1;
1292 }
1293
1294
1295 static int  lretreat (n)
1296 int     n;
1297 {
1298     register int    i;
1299     register struct line   *lp;
1300
1301     for (i = 0, lp = ltop; i < n && lp; i++, lp = lp -> l_prev)
1302         if (!lp -> l_prev)
1303             break;
1304
1305     if (ltop == lp)
1306         return 0;
1307
1308     ltop = lp;
1309     return 1;
1310 }
1311
1312 /* \f */
1313
1314 static int  lgo (n)
1315 int     n;
1316 {
1317     register int    i,
1318                     j;
1319     register struct line   *lp;
1320
1321     if ((i = n - (lp = lhead) -> l_no)
1322             > (j = abs (n - (ltop ? ltop : ltail) -> l_no)))
1323         i = j, lp = ltop ? ltop : ltail;
1324     if (i > (j = abs (ltail -> l_no - n)))
1325         i = j, lp = ltail;
1326
1327     if (n >= lp -> l_no) {
1328         for (; lp; lp = lp -> l_next)
1329             if (lp -> l_no == n)
1330                 break;
1331     }
1332     else {
1333         for (; lp; lp = lp -> l_prev)
1334             if (lp -> l_no == n)
1335                 break;
1336         if (!lp)
1337             lp = lhead;
1338     }
1339
1340     if (ltop == lp)
1341         return 0;
1342
1343     ltop = lp;
1344     return 1;
1345 }
1346
1347 /* \f   TTYS */
1348
1349 static int  TTYinit (nprog) {
1350     if (!isatty (fileno (stdin)) || !isatty (fileno (stdout)))
1351         if (nprog)
1352             return NOTOK;
1353         else
1354             adios (NULLCP, "not a tty");
1355
1356     foreground ();
1357 #ifndef SYS5
1358     if (ioctl (fileno (stdin), TIOCGETP, (char *) &sg) == NOTOK)
1359         adios ("failed", "ioctl TIOCGETP");
1360     if (ioctl (fileno (stdin), TIOCGETC, (char *) &tc) == NOTOK)
1361         adios ("failed", "ioctl TIOCGETC");
1362 #else
1363 #ifdef  TCGETATTR
1364     if( tcgetattr( fileno(stdin), &sg) == NOTOK)
1365         adios( "failed", "tcgetattr");
1366 #else   /* SYS5 */
1367     if (ioctl (fileno (stdin), TCGETA, &sg) == NOTOK)
1368         adios ("failed", "ioctl TCGETA");
1369 #endif
1370 #endif
1371 #ifdef  TIOCGLTC
1372     if (ioctl (fileno (stdin), TIOCGLTC, (char *) &ltc) == NOTOK)
1373         adios ("failed", "ioctl TIOCGLTC");
1374 #endif  /* TIOCGLTC */
1375     intrc = INTR;
1376     sideground ();
1377
1378     tty_ready = OK;
1379
1380     (void) signal (SIGPIPE, PIPEser);
1381
1382     return OK;
1383 }
1384
1385 /* \f */
1386
1387 static  TTYon () {
1388     if (tty_ready == DONE)
1389         return;
1390
1391     INTR = NOTOK;
1392 #ifndef SYS5
1393     (void) ioctl (fileno (stdin), TIOCSETC, (char *) &tc);
1394 #else   /* SYS5 */
1395     (void) ioctl (fileno (stdin), TCSETA, &sg);
1396 #endif  /* SYS5 */
1397
1398     (void) crmode ();
1399     (void) noecho ();
1400     (void) nonl ();
1401     scrollok (curscr, FALSE);
1402
1403     discard (stdin);
1404
1405     tty_ready = DONE;
1406
1407     (void) signal (SIGHUP, SIGser);
1408     (void) signal (SIGINT, SIGser);
1409     (void) signal (SIGQUIT, SIGser);
1410 #ifdef  SIGTSTP
1411     (void) signal (SIGTSTP, TSTPser);
1412 #endif  /* SIGTSTP */
1413 }
1414
1415 /* \f */
1416
1417 static  TTYoff () {
1418     if (tty_ready == NOTOK)
1419         return;
1420
1421     INTR = intrc;
1422 #ifndef SYS5
1423     (void) ioctl (fileno (stdin), TIOCSETC, (char *) &tc);
1424 #else   /* SYS5 */
1425     (void) ioctl (fileno (stdin), TCSETA, &sg);
1426 #endif  /* SYS5 */
1427
1428     leaveok (curscr, TRUE);
1429     mvcur (0, COLS - 1, LINES - 1, 0);
1430     endwin ();
1431     if (tty_ready == DONE) {
1432 #ifndef TERMINFO
1433         if (CE)
1434             tputs (CE, 0, _putchar);
1435         else
1436 #else   /* TERMINFO */
1437         putp(clr_eol);
1438 #endif  /* TERMINFO */
1439             fprintf (stdout, "\r\n");
1440     }
1441     (void) fflush (stdout);
1442
1443     tty_ready = NOTOK;
1444
1445     (void) signal (SIGHUP, SIG_DFL);
1446     (void) signal (SIGINT, SIG_DFL);
1447     (void) signal (SIGQUIT, SIG_DFL);
1448 #ifdef  SIGTSTP
1449     (void) signal (SIGTSTP, SIG_DFL);
1450 #endif  /* SIGTSTP */
1451 }
1452
1453 /* \f */
1454
1455 static  foreground () {
1456 #ifdef  TIOCGPGRP
1457     int     pgrp,
1458             tpgrp;
1459     TYPESIG     (*tstat) ();
1460
1461     if ((pgrp = getpgrp (0)) == NOTOK)
1462         adios ("process group", "unable to determine");
1463     for (;;) {
1464         if (ioctl (fileno (stdin), TIOCGPGRP, (char *) &tpgrp) == NOTOK)
1465             adios ("tty's process group", "unable to determine");
1466         if (pgrp == tpgrp)
1467             break;
1468
1469         tstat = signal (SIGTTIN, SIG_DFL);
1470         (void) kill (0, SIGTTIN);
1471         (void) signal (SIGTTIN, tstat);
1472     }
1473     
1474     (void) signal (SIGTTIN, SIG_IGN);
1475     (void) signal (SIGTTOU, SIG_IGN);
1476     (void) signal (SIGTSTP, SIG_IGN);
1477 #endif  /* TIOCGPGRP */
1478 }
1479
1480
1481 sideground () {
1482 #ifdef  TIOCGPGRP
1483     (void) signal (SIGTTIN, SIG_DFL);
1484     (void) signal (SIGTTOU, SIG_DFL);
1485     (void) signal (SIGTSTP, SIG_DFL);
1486 #endif  /* TIOCGPGRP */
1487 }
1488
1489 /* \f   SIGNALS */
1490
1491 /* ARGSUSED */
1492
1493 static TYPESIG  ALRMser (sig)
1494 int     sig;
1495 {
1496      longjmp (PEERctx, DONE);
1497 }
1498
1499
1500 #ifdef  BSD42
1501 /* ARGSUSED */
1502 #endif  /* BSD42 */
1503
1504 static TYPESIG  PIPEser (sig)
1505 int     sig;
1506 {
1507 #ifndef BSD42
1508     (void) signal (sig, SIG_IGN);
1509 #endif  /* BSD42 */
1510
1511     adios (NULLCP, "lost peer");
1512 }
1513
1514
1515 #ifdef  BSD42
1516 /* ARGSUSED */
1517 #endif  /* BSD42 */
1518
1519 static TYPESIG  SIGser (sig)
1520 int     sig;
1521 {
1522 #ifndef BSD42
1523     (void) signal (sig, SIG_IGN);
1524 #endif  /* BSD42 */
1525
1526     done (1);
1527 }
1528
1529
1530 #ifdef  SIGTSTP
1531 static TYPESIG  TSTPser (sig)
1532 int     sig;
1533 {
1534 #ifndef TERMINFO
1535     tputs (tgoto (CM, 0, LINES - 1), 0, _putchar);
1536 #else   /* TERMINFO */
1537     move(LINES - 1, 0); /* to lower left corner */
1538     clrtoeol();         /* clear bottom line */
1539     wrefresh(curscr);   /* flush out everything */
1540 #endif  /* TERMINFO */
1541     (void) fflush (stdout);
1542
1543     TTYoff ();
1544 #ifdef  BSD42
1545     (void) sigsetmask (sigblock (0) & ~sigmask (SIGTSTP));
1546 #endif  /* BSD42 */
1547
1548     (void) kill (getpid (), sig);
1549
1550 #ifdef  BSD42
1551     (void) sigblock (sigmask (SIGTSTP));
1552 #endif  /* BSD42 */
1553     TTYon ();
1554
1555     wrefresh (curscr);
1556 }
1557 #endif  /* SIGTSTP */
1558
1559 /* \f   MISCELLANY */
1560
1561 void    done (status)
1562 int     status;
1563 {
1564     TTYoff ();
1565     (void) pFIN ();
1566
1567     exit (status);
1568 }
1569
1570 /* \f */
1571
1572 /* VARARGS2 */
1573
1574 static void  adorn (what, fmt, a, b, c, d, e, f)
1575 char   *what,
1576        *fmt,
1577        *a,
1578        *b,
1579        *c,
1580        *d,
1581        *e,
1582        *f;
1583 {
1584     char   *cp = invo_name;
1585
1586     invo_name = NULL;
1587     advise (what, fmt, a, b, c, d, e, f);
1588     invo_name = cp;
1589 }
1590
1591 /* \f */
1592
1593 /* VARARGS3 */
1594
1595 void advertise (what, tail, fmt, a, b, c, d, e, f)
1596 char   *what,
1597        *tail,
1598        *fmt,
1599        *a,
1600        *b,
1601        *c,
1602        *d,
1603        *e,
1604        *f;
1605 {
1606     int     eindex = errno;
1607     char    buffer[BUFSIZ],
1608             err[BUFSIZ];
1609     struct iovec    iob[20];
1610     register struct iovec  *iov = iob;
1611
1612     (void) fflush (stdout);
1613
1614     (void) fflush (stderr);
1615
1616     if (invo_name) {
1617         iov -> iov_len = strlen (iov -> iov_base = invo_name);
1618         iov++;
1619         iov -> iov_len = strlen (iov -> iov_base = ": ");
1620         iov++;
1621     }
1622     
1623     (void) sprintf (buffer, fmt, a, b, c, d, e, f);
1624     iov -> iov_len = strlen (iov -> iov_base = buffer);
1625     iov++;
1626     if (what) {
1627         if (*what) {
1628             iov -> iov_len = strlen (iov -> iov_base = " ");
1629             iov++;
1630             iov -> iov_len = strlen (iov -> iov_base = what);
1631             iov++;
1632             iov -> iov_len = strlen (iov -> iov_base = ": ");
1633             iov++;
1634         }
1635         if (eindex > 0 && eindex < sys_nerr)
1636             iov -> iov_len = strlen (iov -> iov_base = sys_errlist[eindex]);
1637         else {
1638             (void) sprintf (err, "Error %d", eindex);
1639             iov -> iov_len = strlen (iov -> iov_base = err);
1640         }
1641         iov++;
1642     }
1643     if (tail && *tail) {
1644         iov -> iov_len = strlen (iov -> iov_base = ", ");
1645         iov++;
1646         iov -> iov_len = strlen (iov -> iov_base = tail);
1647         iov++;
1648     }
1649     iov -> iov_len = strlen (iov -> iov_base = "\n");
1650     iov++;
1651
1652     if (tty_ready == DONE)
1653         (void) WINwritev (Display, iob, iov - iob);
1654     else
1655         (void) writev (fileno (stderr), iob, iov - iob);
1656 }
1657
1658 /* \f */
1659
1660 #ifndef BSD42
1661 static int     writev (fd, iov, n)
1662 register int     fd;
1663 register struct iovec   *iov;
1664 register int     n;
1665 {
1666     register int    i,
1667                     j;
1668
1669     for (i = j = 0; i < n; i++, iov++)
1670         if (write (fd, iov -> iov_base, iov -> iov_len) != iov -> iov_len)
1671             break;
1672         else
1673             j += iov -> iov_len;
1674
1675     return j;
1676 }
1677 #endif  /* BSD42 */
1678 @
1679
1680
1681 1.19
1682 log
1683 @BSD44
1684 @
1685 text
1686 @d3 1
1687 a3 1
1688 static char ident[] = "@@(#)$Id: vmh.c,v 1.18 1992/12/15 00:20:22 jromine Exp jromine $";
1689 d192 1
1690 d195 1
1691 @
1692
1693
1694 1.18
1695 log
1696 @endif sugar
1697 @
1698 text
1699 @d3 1
1700 a3 1
1701 static char ident[] = "@@(#)$Id: vmh.c,v 1.17 1992/11/13 00:32:32 jromine Exp jromine $";
1702 d62 11
1703 d175 1
1704 a175 1
1705 #ifndef SYS5
1706 d1136 1
1707 d1138 3
1708 @
1709
1710
1711 1.17
1712 log
1713 @fixup termio
1714 @
1715 text
1716 @d3 2
1717 a4 2
1718 static char ident[] = "@@(#)$Id: vmh.c,v 1.16 1992/11/12 23:41:07 jromine Exp jromine $";
1719 #endif  lint
1720 d33 1
1721 a33 1
1722 #endif  TERMINFO
1723 d42 1
1724 a42 1
1725 #endif  not sigmask
1726 d45 1
1727 a45 1
1728 #endif  ridge
1729 d51 1
1730 a51 1
1731 #else   BSD42
1732 d54 1
1733 a54 1
1734 #endif  BSD42
1735 d143 1
1736 a143 1
1737 #else   SYS5
1738 d149 1
1739 a149 1
1740 #endif  SYS5
1741 d319 1
1742 a319 1
1743 #else   not hpux
1744 d321 1
1745 a321 1
1746 #endif  not hpux
1747 d484 1
1748 a484 1
1749 #endif  SIGTSTP
1750 d488 1
1751 a488 1
1752 #else   TERMINFO
1753 d490 1
1754 a490 1
1755 #endif  TERMINFO
1756 d496 1
1757 a496 1
1758 #else   TERMINFO
1759 d498 1
1760 a498 1
1761 #endif  TERMINFO
1762 d502 1
1763 a502 1
1764 #endif  SIGTSTP
1765 d563 1
1766 a563 1
1767 #endif  XYZ
1768 d583 1
1769 a583 1
1770 #endif  XYZ
1771 d595 1
1772 a595 1
1773 #endif  XYZ
1774 d661 1
1775 a661 1
1776 #endif  SIGTSTP
1777 d666 1
1778 a666 1
1779 #else   TERMINFO
1780 d668 1
1781 a668 1
1782 #endif  TERMINFO
1783 d679 1
1784 a679 1
1785 #else   TERMINFO
1786 d687 1
1787 a687 1
1788 #endif  TERMINFO
1789 d700 1
1790 a700 1
1791 #endif  XYZ
1792 d849 1
1793 a849 1
1794 #endif  notdef
1795 d860 1
1796 a860 1
1797 #endif  notdef
1798 d873 1
1799 a873 1
1800 #endif  notdef
1801 d899 1
1802 a899 1
1803 #endif  notdef
1804 d1290 1
1805 a1290 1
1806 #else   SYS5
1807 d1292 1
1808 a1292 1
1809 #endif  SYS5
1810 d1302 1
1811 a1302 1
1812 #else   TERMINFO
1813 d1304 1
1814 a1304 1
1815 #endif  TERMINFO
1816 d1316 1
1817 a1316 1
1818 #endif  SIGTSTP
1819 d1343 1
1820 a1343 1
1821 #endif  TIOCGPGRP
1822 d1352 1
1823 a1352 1
1824 #endif  TIOCGPGRP
1825 d1368 1
1826 a1368 1
1827 #endif  BSD42
1828 d1375 1
1829 a1375 1
1830 #endif  BSD42
1831 d1383 1
1832 a1383 1
1833 #endif  BSD42
1834 d1390 1
1835 a1390 1
1836 #endif  BSD42
1837 d1402 1
1838 a1402 1
1839 #else   TERMINFO
1840 d1406 1
1841 a1406 1
1842 #endif  TERMINFO
1843 d1412 1
1844 a1412 1
1845 #endif  BSD42
1846 d1418 1
1847 a1418 1
1848 #endif  BSD42
1849 d1423 1
1850 a1423 1
1851 #endif  SIGTSTP
1852 d1543 1
1853 a1543 1
1854 #endif  BSD42
1855 @
1856
1857
1858 1.16
1859 log
1860 @NCR/SVR4 fixups
1861 @
1862 text
1863 @d3 1
1864 a3 1
1865 static char ident[] = "@@(#)$Id: vmh.c,v 1.15 1992/11/12 23:32:19 jromine Exp jromine $";
1866 a15 3
1867 #if defined(ncr) || defined(hpux)
1868 #define TERMIOS         /* struct termios, tcgetattr() */
1869 #endif
1870 d58 4
1871 a147 1
1872 #ifndef TERMIOS
1873 a148 3
1874 #else
1875 static struct termios   sg;
1876 #endif
1877 d1229 1
1878 a1229 1
1879 #ifdef  TERMIOS
1880 @
1881
1882
1883 1.15
1884 log
1885 @fixup for TERMINFO
1886 @
1887 text
1888 @d3 1
1889 a3 1
1890 static char ident[] = "@@(#)$Id: vmh.c,v 1.14 1992/11/12 18:22:51 jromine Exp jromine $";
1891 d16 3
1892 d147 1
1893 d149 3
1894 d162 1
1895 d1231 5
1896 a1235 1
1897 #else   /* SYS */
1898 d1238 3
1899 a1240 2
1900 #endif  /* SYS5 */
1901 #if     defined(TIOCGLTC) && !defined(SVR4)
1902 @
1903
1904
1905 1.14
1906 log
1907 @don't re-ifdef abs
1908 @
1909 text
1910 @d3 1
1911 a3 1
1912 static char ident[] = "@@(#)$Id: vmh.c,v 1.13 1992/11/12 01:02:20 jromine Exp jromine $";
1913 d5 1
1914 a5 1
1915 #ifdef  SYS5
1916 d15 1
1917 a15 1
1918 #endif  SYS5
1919 @
1920
1921
1922 1.13
1923 log
1924 @SVR4 changes
1925 @
1926 text
1927 @d3 1
1928 a3 1
1929 static char ident[] = "@@(#)$Id: vmh.c,v 1.12 1992/11/04 02:34:45 jromine Exp jromine $";
1930 d62 1
1931 d64 1
1932 @
1933
1934
1935 1.12
1936 log
1937 @TYPESIG
1938 LOCALE
1939 #endif fixups
1940 @
1941 text
1942 @d3 1
1943 a3 1
1944 static char ident[] = "@@(#)$Id: vmh.c,v 1.11 1992/02/11 03:05:36 jromine Exp jromine $";
1945 d148 1
1946 a148 3
1947 #ifdef SVR4
1948 #include <sgtty.h>
1949 #endif
1950 d151 3
1951 d1225 1
1952 a1225 1
1953 #ifdef  TIOCGLTC
1954 @
1955
1956
1957 1.11
1958 log
1959 @don't double include sgtty.h
1960 @
1961 text
1962 @d3 1
1963 a3 1
1964 static char ident[] = "@@(#)$Id: vmh.c,v 1.10 1992/02/10 18:12:35 jromine Exp jromine $";
1965 d55 3
1966 d147 1
1967 a147 1
1968 #else   TIOCGLTC
1969 d153 1
1970 a153 1
1971 #endif  TIOCGLTC
1972 d158 1
1973 a158 1
1974 #endif  not SYS5
1975 d161 1
1976 a161 1
1977 #endif  SIGTSTP
1978 d165 1
1979 a165 1
1980 static int     ALRMser (), PIPEser (), SIGser ();
1981 d167 2
1982 a168 2
1983 static int      TSTPser ();
1984 #endif  SIGTSTP
1985 d199 3
1986 d1220 1
1987 a1220 1
1988 #else   SYS5
1989 d1223 1
1990 a1223 1
1991 #endif  SYS5
1992 d1227 1
1993 a1227 1
1994 #endif  TIOCGLTC
1995 d1247 1
1996 a1247 1
1997 #else   SYS5
1998 d1249 1
1999 a1249 1
2000 #endif  SYS5
2001 d1265 1
2002 a1265 1
2003 #endif  SIGTSTP
2004 d1346 1
2005 a1346 1
2006 static int  ALRMser (sig)
2007 d1357 1
2008 a1357 1
2009 static int  PIPEser (sig)
2010 d1372 1
2011 a1372 1
2012 static int  SIGser (sig)
2013 d1384 1
2014 a1384 1
2015 static int  TSTPser (sig)
2016 @
2017
2018
2019 1.10
2020 log
2021 @some SVR4 changes
2022 add "localdomain" tailor option
2023 @
2024 text
2025 @d3 1
2026 a3 1
2027 static char ident[] = "@@(#)$Id: vmh.c,v 1.9 1992/02/07 19:20:10 jromine Exp jromine $";
2028 a54 3
2029 #ifdef SVR4
2030 #include <sgtty.h>
2031 #endif
2032 @
2033
2034
2035 1.9
2036 log
2037 @SVR4
2038 @
2039 text
2040 @d3 1
2041 a3 1
2042 static char ident[] = "@@(#)$Id: vmh.c,v 1.8 1992/01/31 22:28:38 jromine Exp jromine $";
2043 d55 3
2044 @
2045
2046
2047 1.8
2048 log
2049 @kerberos
2050 @
2051 text
2052 @d3 1
2053 a3 1
2054 static char ident[] = "@@(#)$Id: vmh.c,v 1.7 1992/01/24 00:05:13 jromine Exp jromine $";
2055 d145 3
2056 @
2057
2058
2059 1.7
2060 log
2061 @ncr
2062 @
2063 text
2064 @d3 1
2065 a3 1
2066 static char ident[] = "@@(#)$Id: vmh.c,v 1.6 1990/04/05 15:00:17 sources Exp jromine $";
2067 d80 1
2068 a80 1
2069     NULL, NULL
2070 d702 1
2071 a702 1
2072     *bp = NULL;
2073 d715 1
2074 a715 1
2075                 *bp = NULL;
2076 d731 1
2077 a731 1
2078                     *buffer = NULL;
2079 d1111 1
2080 a1111 1
2081             *cp = NULL;
2082 @
2083
2084
2085 1.6
2086 log
2087 @add ID
2088 @
2089 text
2090 @d3 1
2091 a3 1
2092 static char ident[] = "@@(#)$Id:$";
2093 d27 3
2094 @
2095
2096
2097 1.5
2098 log
2099 @TYPESIG fixup
2100 @
2101 text
2102 @d2 3
2103 @
2104
2105
2106 1.4
2107 log
2108 @ANSI Compilance
2109 @
2110 text
2111 @d1297 1
2112 a1297 1
2113     int     (*tstat) ();
2114 @
2115
2116
2117 1.3
2118 log
2119 @TYPESIG
2120 @
2121 text
2122 @d153 1
2123 a153 1
2124 int     ALRMser (), PIPEser (), SIGser ();
2125 d155 1
2126 a155 1
2127 int     TSTPser ();
2128 d164 1
2129 a164 1
2130 void    adorn ();
2131 d166 4
2132 @
2133
2134
2135 1.2
2136 log
2137 @*** empty log message ***
2138 @
2139 text
2140 @d430 1
2141 a430 1
2142     int     (*hstat) (), (*istat) (), (*qstat) (), (*tstat) ();
2143 @
2144
2145
2146 1.1
2147 log
2148 @Initial revision
2149 @
2150 text
2151 @d627 1
2152 a627 1
2153     if (initscr () == ERR)
2154 @