9 date 93.08.25.17.29.59; author jromine; state Exp;
14 date 92.11.04.02.29.30; author jromine; state Exp;
19 date 90.04.05.15.03.31; author sources; state Exp;
24 date 90.03.12.14.01.46; author sources; state Exp;
29 date 90.03.12.14.00.55; author sources; state Exp;
40 @off_t fixes for BSD44
43 @/* wmh.c - window front-end to mh */
45 static char ident[] = "@@(#)$Id: wmh.c,v 1.4 1992/11/04 02:29:30 jromine Exp jromine $";
49 Pass signals to client during execution
51 Figure out a way for the user to say how big the Scan/Display
52 windows should be, and where all the windows should be.
57 #include "../h/vmhsbr.h"
63 #define sigmask(s) (1 << ((s) - 1))
65 #include <sys/types.h>
75 #define ALARM ((unsigned int) 10)
76 #define PAUSE ((unsigned int) 2)
78 #define abs(a) ((a) > 0 ? (a) : -(a))
80 #define SZ(a) (sizeof a / sizeof a[0])
84 static struct swit switches[] = {
101 static int PEERpid = NOTOK;
103 static jmp_buf PEERctx;
108 static int dfd = NOTOK;
110 static int twd = NOTOK;
112 static char *myprompt = "(%s) ";
148 struct line *w_bottom;
151 char w_buffer[BUFSIZ];
157 static WINDOW *Status;
158 static WINDOW *Display;
159 static WINDOW *Command;
164 WINDOW *windows[NWIN + 1];
171 #define ERASE sg.sg_erase
172 #define KILL sg.sg_kill
173 static struct sgttyb sg;
175 #define EOFC tc.t_eofc
176 #define INTR tc.t_intrc
177 static struct tchars tc;
179 #define WERASC ltc.t_werasc
180 static struct ltchars ltc;
183 int ALRMser (), PIPEser (), SIGser ();
184 int ADJser (), REFser ();
191 extern char *sys_errlist[];
214 setlocale(LC_ALL, "");
216 invo_name = r1bindex (argv[0], '/');
217 if ((cp = m_find (invo_name)) != NULL) {
218 ap = brkstring (cp = getcpy (cp), " ", "\n");
219 ap = copyip (ap, arguments);
223 (void) copyip (argv + 1, ap);
230 switch (smatch (++cp, switches)) {
232 ambigsw (cp, switches);
238 (void) sprintf (buffer, "%s [switches for vmhproc]",
240 help (buffer, switches);
244 if (!(myprompt = *argp++) || *myprompt == '-')
245 adios (NULLCP, "missing argument to %s", argp[-2]);
249 if (!(vmhproc = *argp++) || *vmhproc == '-')
250 adios (NULLCP, "missing argument to %s", argp[-2]);
262 if (WINinit (nprog) == NOTOK) {
265 vec[0] = r1bindex (vmhproc, '/');
266 execvp (vmhproc, vec);
267 adios (vmhproc, "unable to exec");
269 (void) PEERinit (vecp, vec);
283 (void) pLOOP (RC_QRY, NULLCP);
285 (void) sprintf (prompt, myprompt, invo_name);
287 switch (WINgetstr (Command, prompt, buffer)) {
292 done (0); /* NOTREACHED */
296 (void) pLOOP (RC_CMD, buffer);
304 static int PEERinit (vecp, vec)
314 (void) signal (SIGPIPE, PIPEser);
316 if (pipe (pfd0) == NOTOK || pipe (pfd1) == NOTOK)
317 adios ("pipe", "unable to");
318 switch (PEERpid = vfork ()) {
320 adios ("vfork", "unable to");/* NOTREACHED */
323 for (w = windows; *w; w++)
324 if ((*w) -> w_fd != NOTOK)
325 (void) close ((*w) -> w_fd);
326 (void) close (pfd0[0]);
327 (void) close (pfd1[1]);
329 vec[vecp++] = "-vmhread";
330 (void) sprintf (buf1, "%d", pfd1[0]);
332 vec[vecp++] = "-vmhwrite";
333 (void) sprintf (buf2, "%d", pfd0[1]);
337 (void) signal (SIGINT, SIG_DFL);
338 (void) signal (SIGQUIT, SIG_DFL);
339 (void) signal (SIGTERM, SIG_DFL);
341 vec[0] = r1bindex (vmhproc, '/');
342 execvp (vmhproc, vec);
344 _exit (-1); /* NOTREACHED */
347 (void) close (pfd0[1]);
348 (void) close (pfd1[0]);
350 (void) rcinit (pfd0[0], pfd1[1]);
361 register struct record *rc = &rcs;
367 (void) sprintf (bp, "%d %d", RC_VRSN, numwins);
369 for (w = windows; *w; w++) {
370 (void) sprintf (bp, " %d", (*w) -> w_height);
374 switch (str2rc (RC_INI, buffer, rc)) {
380 adios (NULLCP, "%s", rc -> rc_data);
382 adios (NULLCP, "pINI peer error");
385 adios (NULLCP, "%s", rc -> rc_data);
388 adios (NULLCP, "pINI protocol screw-up");
395 static int pLOOP (code, str)
401 register struct record *rc = &rcs;
406 (void) str2peer (code, str);
408 switch (peer2rc (rc)) {
410 if (pTTY () == NOTOK)
415 if (sscanf (rc -> rc_data, "%d", &i) != 1
418 (void) fmt2peer (RC_ERR, "no such window \"%s\"",
422 if ((w = windows[i - 1]) -> w_flags & W_CMND) {
423 (void) fmt2peer (RC_ERR, "not a display window \"%s\"",
427 if (pWIN (w) == NOTOK)
436 adorn (NULLCP, "%s", rc -> rc_data);
438 adorn (NULLCP, "pLOOP(%s) peer error",
439 code == RC_QRY ? "QRY" : "CMD");
444 adorn (NULLCP, "%s", rc -> rc_data);
446 i = pidwait (PEERpid, OK);
451 adios (NULLCP, "%s", rc -> rc_data);
454 adios (NULLCP, "pLOOP(%s) protocol screw-up",
455 code == RC_QRY ? "QRY" : "CMD");
462 TYPESIG (*hstat) (), (*istat) (), (*qstat) (), (*tstat) ();
464 register struct record *rc = &rcs;
468 if (ChangeWindowDepth (dfd, twd, 0) == NOTOK)
469 adios ("failed", "ChangeWindowDepth");
471 hstat = signal (SIGHUP, SIG_IGN);
472 istat = signal (SIGINT, SIG_IGN);
473 qstat = signal (SIGQUIT, SIG_IGN);
474 tstat = signal (SIGTERM, SIG_IGN);
476 (void) rc2rc (RC_ACK, 0, NULLCP, rc);
478 (void) signal (SIGHUP, hstat);
479 (void) signal (SIGINT, istat);
480 (void) signal (SIGQUIT, qstat);
481 (void) signal (SIGTERM, tstat);
483 switch (rc -> rc_type) {
485 (void) rc2peer (RC_ACK, 0, NULLCP);
490 adorn (NULLCP, "%s", rc -> rc_data);
492 adorn (NULLCP, "pTTY peer error");
496 adios (NULLCP, "%s", rc -> rc_data);
499 adios (NULLCP, "pTTY protocol screw-up");
511 if ((i = pWINaux (w)) == OK)
519 static int pWINaux (w)
524 register struct line *lp,
527 register struct record *rc = &rcs;
531 for (lp = w -> w_head; lp; lp = mp) {
536 w -> w_head = w -> w_top = w -> w_bottom = w -> w_tail = NULL;
540 switch (rc2rc (RC_ACK, 0, NULLCP, rc)) {
542 for (bp = rc -> rc_data, n = rc -> rc_len; n-- > 0; )
543 (void) WINputc (w, *bp++);
547 (void) rc2peer (RC_ACK, 0, NULLCP);
549 (void) WINputc (w, '\n');
554 adorn (NULLCP, "%s", rc -> rc_data);
556 adorn (NULLCP, "pWIN peer error");
560 adios (NULLCP, "%s", rc -> rc_data);
563 adios (NULLCP, "pWIN protocol screw-up");
576 (void) rc2peer (RC_FIN, 0, NULLCP);
579 switch (setjmp (PEERctx)) {
581 (void) signal (SIGALRM, ALRMser);
582 (void) alarm (ALARM);
584 status = pidwait (PEERpid, OK);
590 (void) kill (PEERpid, SIGKILL);
601 /* should dynamically determine all this stuff from gconfig... */
603 #define MyX 20 /* anchored hpos */
604 #define MyY 40 /* .. vpos */
605 #define MyW 800 /* .. width */
606 #define MyH 500 /* .. height */
607 #define MyS 30 /* .. height for Status, about one line */
610 #define MySlop 45 /* slop */
612 #define EWIDTH 25 /* Width of vertical EBAR */
613 #define ESLOP 5 /* .. slop */
616 static int WINinit (nprog) {
623 if (GetGraphicsConfig (fileno (stderr), &gc) == NOTOK)
627 adios (NULLCP, "not a window");
629 if ((dfd = open ("/dev/ttyw0", 2)) == NOTOK)
630 adios ("/dev/ttyw0", "unable to open");
632 if ((twd = GetTopWindow (dfd)) == NOTOK)
633 adios ("failed", "GetTopWindow");
635 (void) BlockRefreshAdjust (1);
639 wx = gc.w - (MyX + MyW + EWIDTH + ESLOP);
640 Scan = WINnew (wx, wy = MyY, MyW, wh = MyH * 2 / 3, "Scan", W_EBAR);
643 Status = WINnew (wx, sy = wy, MyW, wh = MyS, "Status", W_FAKE);
646 Display = WINnew (wx, wy, MyW, MyH, "Display", W_EBAR);
648 Command = WINnew (wx, sy, MyW, MyS, invo_name, W_CMND);
650 windows[numwins] = NULL;
657 WINDOW *WINnew (wx, wy, ww, wh, name, flags)
667 if ((w = (WINDOW *) calloc (1, sizeof *w)) == NULL)
668 adios (NULLCP, "unable to allocate window");
670 if ((w -> w_flags = flags) & W_FAKE) {
677 if (w -> w_flags & W_EBAR)
678 ww += EWIDTH + ESLOP;
680 wx += EWIDTH + ESLOP;
682 if ((w -> w_fd = OpenWindow (wx, wy, ww, wh, name)) == NOTOK)
683 adios ("failed", "OpenWindow");
684 if ((w -> w_wd = GetTopWindow (dfd)) == NOTOK)
685 adios ("failed", "GetTopWindow");
686 if (GetWindowState (w -> w_fd, &w -> w_ws) == NOTOK)
687 adios ("failed", "GetWindowState");
688 if (SetLineDisc (w -> w_fd, TWSDISC) == NOTOK)
689 adios ("failed", "SetLineDisc");
691 SetBuf (w -> w_fd, 1024);
692 (void) SetAdjust (w -> w_fd, numwins, ADJser);
693 (void) SetRefresh (w -> w_fd, numwins, REFser);
695 SetAddressing (w -> w_fd, VT_ABSOLUTE);
697 if (w -> w_flags & W_EBAR) {
698 w -> w_eb = CreateElevatorBar (w -> w_fd, 0, 0, EWIDTH,
699 w -> w_ws.height, VT_Gray50, 1, EB_VERTICAL,
700 EB_ARROWS, w -> w_ebloc = 0, w -> w_ebsize = EB_MAX,
702 if (w -> w_eb == NULL)
703 adios (NULLCP, "CreateElevatorBar failed");
704 RefreshElevatorBar (w -> w_eb);
707 if ((w -> w_cbase = CharacterBaseline (w -> w_ws.font)) <= 0)
710 if ((w -> w_cheight = CharacterHeight (w -> w_ws.font)) <= 0)
712 w -> w_height = w -> w_ws.height / w -> w_cheight;
713 if (w -> w_height < 1)
717 if ((w -> w_cwidth = CharacterWidth (w -> w_ws.font, 'm')) <= 0)
719 w -> w_width = (w -> w_ws.width - (w -> w_eb ? (EWIDTH + ESLOP) : 0))
721 if (w -> w_width < 1)
725 windows[numwins++] = w;
732 static int WINgetstr (w, prompt, buffer)
742 register struct vtseq *vt = &vts;
744 if (w -> w_eb != NULL)
745 adios (NULLCP, "internal error--elevator bar found");
747 if (w -> w_head == NULL
748 && (w -> w_head = (struct line *) calloc (1, sizeof *w -> w_head))
750 adios (NULLCP, "unable to allocate line storage");
751 w -> w_head -> l_buf = image;
752 w -> w_top = w -> w_bottom = w -> w_tail = w -> w_head;
754 if (ChangeWindowDepth (dfd, w -> w_wd, 0) == NOTOK)
755 adios ("failed", "ChangeWindowDepth");
757 (void) strcpy (image, prompt);
758 bp = ip = image + strlen (image);
763 switch (getvtseq (w -> w_fd, vt)) {
765 DisplayStatus (w -> w_fd, "no hardkeys, please");
769 switch (c = toascii (vt -> u.ascii)) {
770 case '\f': /* refresh? */
775 (void) strcpy (buffer, ip);
780 adorn (NULLCP, "Interrupt");
809 } while (isspace (*bp) && bp > ip);
813 } while (!isspace (*bp) && bp > buffer);
820 if (c < ' ' || c >= '\177')
830 switch (vt -> u.mouse.buttons
831 & (VT_MOUSE_LEFT | VT_MOUSE_MIDDLE | VT_MOUSE_RIGHT)) {
833 DisplayStatus (w -> w_fd, "use middle or right button");
836 #define WPOP "WMH\0Advance\0Burst\0Exit\0EOF\0"
837 case VT_MOUSE_MIDDLE:
838 SetPosition (w -> w_fd, vt -> u.mouse.x,
840 switch (DisplayPopUp (w -> w_fd, WPOP)) {
841 case 1: /* Advance */
843 (void) strcpy (buffer, "advance");
847 (void) strcpy (buffer, "burst");
851 (void) strcpy (buffer, "exit");
857 default: /* failed or none taken */
869 adios (NULLCP, "end-of-file on window");/* NOTREACHED */
872 DisplayStatus (w -> w_fd, "unknown VT sequence");
879 static int WINputc (w, c)
885 register struct line *lp;
890 if (WINputc (w, 'M') == NOTOK || WINputc (w, '-') == NOTOK)
895 if (c < ' ' || c == '\177') {
896 if (WINputc (w, '^') == NOTOK)
903 for (i = 8 - (w -> w_bufpos & 0x07); i > 0; i--)
904 if (WINputc (w, ' ') == NOTOK)
909 if (w -> w_bufpos > 0)
918 w -> w_buffer[w -> w_bufpos++] = c;
922 w -> w_buffer[w -> w_bufpos] = NULL;
925 if ((lp = (struct line *) calloc (1, sizeof *lp)) == NULL)
926 adios (NULLCP, "unable to allocate line storage");
928 lp -> l_no = (w -> w_tail ? w -> w_tail -> l_no : 0) + 1;
929 lp -> l_buf = getcpy (w -> w_buffer);
930 for (cp = lp -> l_buf + strlen (lp -> l_buf) - 1; cp >= lp -> l_buf; cp--)
936 if (w -> w_head == NULL)
938 if (w -> w_top == NULL)
940 if (w -> w_bottom == NULL)
943 w -> w_tail -> l_next = lp;
944 lp -> l_prev = w -> w_tail;
955 static char mylineno[5];
957 static bool cancel[] = { 1 };
958 static struct choice mychoices[] = { LABEL, "cancel", VT_White };
960 static struct question myquestions[] = {
961 STRING, "Line", SZ (mylineno), (struct choice *) 0,
963 TOGGLE, "", SZ (mychoices), mychoices
966 static struct menu mymenu = { "Goto", SZ (myquestions), myquestions };
968 static int *myanswers[] = { (int *) mylineno, (int *) cancel };
979 register struct vtseq *vt = &vts;
981 if (w -> w_fd == NOTOK) {
983 DisplayStatus (dfd, w -> w_top -> l_buf);
990 if (ChangeWindowDepth (dfd, w -> w_wd, 0) == NOTOK)
991 adios ("failed", "ChangeWindowDepth");
995 if (w -> w_bottom == w -> w_tail)
998 if (w -> w_eb == NULL)
999 adios (NULLCP, "internal error--no elevator bar");
1001 for (clear = refresh = 0, forw = 1;;) {
1003 RemoveStatus (w -> w_fd);
1011 switch (getvtseq (w -> w_fd, vt)) {
1014 DisplayStatus (w -> w_fd, "use the mouse");
1019 switch (vt -> u.mouse.buttons
1020 & (VT_MOUSE_LEFT | VT_MOUSE_MIDDLE | VT_MOUSE_RIGHT)) {
1022 if ((pos = vt -> u.mouse.x) < EWIDTH) {
1023 pos = w -> w_ebloc = DoElevatorBar (w -> w_eb, pos,
1025 refresh = WINgoto (w, ((pos * (w -> w_tail -> l_no
1026 - w -> w_head -> l_no))
1027 / EB_MAX) + w -> w_head -> l_no);
1031 #define WPOP "Paging\0Next\0Prev\0Left\0Right\0First\0Last\0Goto ...\0Exit\0"
1032 case VT_MOUSE_MIDDLE:
1033 SetPosition (w -> w_fd, vt -> u.mouse.x,
1035 switch (DisplayPopUp (w -> w_fd, WPOP)) {
1038 if (w -> w_bottom == w -> w_tail)
1040 refresh = WINgoto (w, w -> w_bottom -> l_no + 1 - PSLOP);
1045 if (w -> w_top == w -> w_head)
1047 refresh = WINgoto (w, w -> w_top -> l_no
1048 - w -> w_height + PSLOP);
1053 DisplayStatus (w -> w_fd, "not yet");
1059 refresh = WINgoto (w, w -> w_head -> l_no);
1064 refresh = WINgoto (w, w -> w_tail -> l_no
1065 - w -> w_height + 1);
1068 case 7: /* Goto ... */
1069 (void) sprintf (mylineno, "%d",
1070 w -> w_top -> l_no);
1072 if (PresentMenu (&mymenu, myanswers)
1075 if (sscanf (mylineno, "%d", &pos) != 1) {
1076 DisplayStatus (w -> w_fd, "bad format");
1080 if (pos < w -> w_head -> l_no
1081 || pos > w -> w_tail -> l_no) {
1082 DisplayStatus (w -> w_fd, "no such line");
1086 refresh = WINgoto (w, pos);
1092 default: /* failed or none taken */
1098 case VT_MOUSE_RIGHT:
1100 if (w -> w_bottom == w -> w_tail)
1111 adios (NULLCP, "end-of-file on window");/* NOTREACHED */
1114 DisplayStatus (w -> w_fd, "unknown VT sequence");
1123 static int WINgoto (w, n)
1129 register struct line *lp;
1131 if (n > (i = w -> w_tail -> l_no - w -> w_height + 1))
1133 if (n < w -> w_head -> l_no)
1134 n = w -> w_head -> l_no;
1136 if ((i = n - (lp = w -> w_head) -> l_no)
1137 > (j = abs (n - w -> w_top -> l_no)))
1138 i = j, lp = w -> w_top;
1140 if (i > (j = abs (w -> w_tail -> l_no - n)))
1141 i = j, lp = w -> w_tail;
1143 if (n >= lp -> l_no) {
1144 for (; lp; lp = lp -> l_next)
1145 if (lp -> l_no == n)
1149 for (; lp; lp = lp -> l_prev)
1150 if (lp -> l_no == n)
1156 if (w -> w_top == lp)
1166 static int ADJser (id, ww, wh)
1173 if (id < 0 || id >= numwins)
1174 adios (NULLCP, "ADJser on bogus window (%d)", id);
1176 if (w -> w_fd == NOTOK)
1177 adios (NULLCP, "ADJser on closed window (%d)", id);
1179 w -> w_ws.width = w -> w_ws.tw = ww;
1180 w -> w_ws.height = w -> w_ws.th = wh;
1183 DeleteElevatorBar (w -> w_eb);
1184 w -> w_eb = CreateElevatorBar (w -> w_fd, 0, 0, EWIDTH,
1185 w -> w_ws.height, VT_Gray50, 1, EB_VERTICAL,
1186 EB_ARROWS, w -> w_ebloc = 0, w -> w_ebsize = EB_MAX,
1188 if (w -> w_eb == NULL)
1189 adios (NULLCP, "CreateElevatorBar failed");
1198 static int REFser (id, wx, wy, ww, wh)
1211 if (id < 0 || id >= numwins)
1212 adios (NULLCP, "REFser on bogus window (%d)", id);
1214 if (w -> w_fd == NOTOK)
1215 adios (NULLCP, "REFser on closed window (%d)", id);
1218 if (GetWindowState (w -> w_fd, &w -> w_ws) == NOTOK)
1219 adios ("failed", "GetWindowState");
1221 GetPermanentClipping (w -> w_fd, &cx, &cy, &cw, &ch);
1222 SetPermanentClipping (w -> w_fd, wx, wy, ww, wh);
1224 SetPermanentClipping (w -> w_fd, cx, cy, cw, ch);
1229 static Redisplay (w, doeb)
1235 register struct line *lp;
1237 if (w -> w_fd == NOTOK)
1240 sx = w -> w_eb ? (EWIDTH + ESLOP) : 0;
1241 w -> w_height = w -> w_ws.height / w -> w_cheight;
1242 if (w -> w_height < 1)
1245 w -> w_width = (w -> w_ws.width - (w -> w_eb ? (EWIDTH + ESLOP) : 0))
1247 if (w -> w_width < 1)
1250 SetPosition (w -> w_fd, sx, 0);
1251 SetColor (w -> w_fd, VT_White);
1252 PaintRectangleInterior (w -> w_fd, w -> w_ws.width, w -> w_ws.height);
1255 SetColor (w -> w_fd, VT_Black);
1256 for (lp = w -> w_top, y = 0;
1257 lp && y < w -> w_height;
1258 w -> w_bottom = lp, lp = lp -> l_next, y++) {
1259 SetPosition (w -> w_fd, sx, y * w -> w_cheight + w -> w_cbase);
1260 PaintString (w -> w_fd, VT_STREND, lp -> l_buf);
1265 if ((y = EB_LOC (w)) != w -> w_ebloc)
1266 MoveElevator (w -> w_eb, w -> w_ebloc = y);
1267 if ((y = EB_SIZE (w)) != w -> w_ebsize)
1268 SizeElevator (w -> w_eb, w -> w_ebsize = y);
1270 RefreshElevatorBar (w -> w_eb);
1278 static int EB_SIZE (w)
1283 if (w -> w_head == NULL)
1286 if ((i = w -> w_tail -> l_no - w -> w_head -> l_no) <= 0)
1289 return (((w -> w_bottom -> l_no - w -> w_top -> l_no) * EB_MAX) / i);
1293 static int EB_LOC (w)
1298 if (w -> w_head == NULL)
1301 if ((i = w -> w_tail -> l_no - w -> w_head -> l_no) <= 0)
1304 return (((w -> w_top -> l_no - w -> w_head -> l_no) * EB_MAX) / i);
1311 if (ioctl (fileno (stdin), TIOCGETP, (char *) &sg) == NOTOK)
1312 adios ("failed", "ioctl TIOCGETP");
1313 if (ioctl (fileno (stdin), TIOCGETC, (char *) &tc) == NOTOK)
1314 adios ("failed", "ioctl TIOCGETC");
1315 if (ioctl (fileno (stdin), TIOCGLTC, (char *) <c) == NOTOK)
1316 adios ("failed", "ioctl TIOCGLTC");
1319 (void) signal (SIGHUP, SIGser);
1320 (void) signal (SIGINT, SIGser);
1321 (void) signal (SIGQUIT, SIGser);
1326 static foreground () {
1330 TYPESIG (*tstat) ();
1332 if ((pgrp = getpgrp (0)) == NOTOK)
1333 adios ("process group", "unable to determine");
1335 if (ioctl (fileno (stdin), TIOCGPGRP, (char *) &tpgrp) == NOTOK)
1336 adios ("tty's process group", "unable to determine");
1340 tstat = signal (SIGTTIN, SIG_DFL);
1341 (void) kill (0, SIGTTIN);
1342 (void) signal (SIGTTIN, tstat);
1345 (void) signal (SIGTTIN, SIG_IGN);
1346 (void) signal (SIGTTOU, SIG_IGN);
1347 (void) signal (SIGTSTP, SIG_IGN);
1352 static sideground () {
1354 (void) signal (SIGTTIN, SIG_DFL);
1355 (void) signal (SIGTTOU, SIG_DFL);
1356 (void) signal (SIGTSTP, SIG_DFL);
1364 static int ALRMser (sig)
1367 longjmp (PEERctx, DONE);
1375 static int PIPEser (sig)
1379 (void) signal (sig, SIG_IGN);
1382 adios (NULLCP, "lost peer");
1390 static int SIGser (sig)
1394 (void) signal (sig, SIG_IGN);
1417 static void adorn (what, fmt, a, b, c, d, e, f)
1427 char *cp = invo_name;
1430 advise (what, fmt, a, b, c, d, e, f);
1438 void advertise (what, tail, fmt, a, b, c, d, e, f)
1450 char buffer[BUFSIZ],
1452 struct iovec iob[20];
1453 register struct iovec *iov = iob;
1455 (void) fflush (stdout);
1457 (void) fflush (stderr);
1460 iov -> iov_len = strlen (iov -> iov_base = invo_name);
1462 iov -> iov_len = strlen (iov -> iov_base = ": ");
1466 (void) sprintf (buffer, fmt, a, b, c, d, e, f);
1467 iov -> iov_len = strlen (iov -> iov_base = buffer);
1471 iov -> iov_len = strlen (iov -> iov_base = " ");
1473 iov -> iov_len = strlen (iov -> iov_base = what);
1475 iov -> iov_len = strlen (iov -> iov_base = ": ");
1478 if (eindex > 0 && eindex < sys_nerr)
1479 iov -> iov_len = strlen (iov -> iov_base = sys_errlist[eindex]);
1481 (void) sprintf (err, "Error %d", eindex);
1482 iov -> iov_len = strlen (iov -> iov_base = err);
1486 if (tail && *tail) {
1487 iov -> iov_len = strlen (iov -> iov_base = ", ");
1489 iov -> iov_len = strlen (iov -> iov_base = tail);
1492 iov -> iov_len = strlen (iov -> iov_base = "\n");
1496 (void) DisplayVector (iob, iov - iob);
1498 (void) writev (fileno (stderr), iob, iov - iob);
1503 static DisplayVector (iov, n)
1504 register struct iovec *iov;
1509 char buffer[BUFSIZ];
1511 for (i = 0, cp = NULL; i < n; i++, iov++) {
1512 (void) sprintf (buffer, "%*.*s", iov -> iov_len, iov -> iov_len,
1514 cp = add (buffer, cp);
1517 DisplayStatus (dfd, cp);
1535 static char ident[] = "@@(#)$Id: wmh.c,v 1.3 1990/04/05 15:03:31 sources Exp jromine $";
1548 static char ident[] = "@@(#)$Id:$";
1570 int (*hstat) (), (*istat) (), (*qstat) (), (*tstat) ();