1 /* wmh.c - window front-end to mh */
3 static char ident[] = "@(#)$Id: wmh.c,v 1.5 1993/08/25 17:29:59 jromine Exp $";
7 Pass signals to client during execution
9 Figure out a way for the user to say how big the Scan/Display
10 windows should be, and where all the windows should be.
15 #include "../h/vmhsbr.h"
21 #define sigmask(s) (1 << ((s) - 1))
23 #include <sys/types.h>
33 #define ALARM ((unsigned int) 10)
34 #define PAUSE ((unsigned int) 2)
36 #define abs(a) ((a) > 0 ? (a) : -(a))
38 #define SZ(a) (sizeof a / sizeof a[0])
42 static struct swit switches[] = {
59 static int PEERpid = NOTOK;
61 static jmp_buf PEERctx;
66 static int dfd = NOTOK;
68 static int twd = NOTOK;
70 static char *myprompt = "(%s) ";
106 struct line *w_bottom;
109 char w_buffer[BUFSIZ];
115 static WINDOW *Status;
116 static WINDOW *Display;
117 static WINDOW *Command;
122 WINDOW *windows[NWIN + 1];
129 #define ERASE sg.sg_erase
130 #define KILL sg.sg_kill
131 static struct sgttyb sg;
133 #define EOFC tc.t_eofc
134 #define INTR tc.t_intrc
135 static struct tchars tc;
137 #define WERASC ltc.t_werasc
138 static struct ltchars ltc;
141 int ALRMser (), PIPEser (), SIGser ();
142 int ADJser (), REFser ();
149 extern char *sys_errlist[];
172 setlocale(LC_ALL, "");
174 invo_name = r1bindex (argv[0], '/');
175 if ((cp = m_find (invo_name)) != NULL) {
176 ap = brkstring (cp = getcpy (cp), " ", "\n");
177 ap = copyip (ap, arguments);
181 (void) copyip (argv + 1, ap);
188 switch (smatch (++cp, switches)) {
190 ambigsw (cp, switches);
196 (void) sprintf (buffer, "%s [switches for vmhproc]",
198 help (buffer, switches);
202 if (!(myprompt = *argp++) || *myprompt == '-')
203 adios (NULLCP, "missing argument to %s", argp[-2]);
207 if (!(vmhproc = *argp++) || *vmhproc == '-')
208 adios (NULLCP, "missing argument to %s", argp[-2]);
220 if (WINinit (nprog) == NOTOK) {
223 vec[0] = r1bindex (vmhproc, '/');
224 execvp (vmhproc, vec);
225 adios (vmhproc, "unable to exec");
227 (void) PEERinit (vecp, vec);
241 (void) pLOOP (RC_QRY, NULLCP);
243 (void) sprintf (prompt, myprompt, invo_name);
245 switch (WINgetstr (Command, prompt, buffer)) {
250 done (0); /* NOTREACHED */
254 (void) pLOOP (RC_CMD, buffer);
262 static int PEERinit (vecp, vec)
272 (void) signal (SIGPIPE, PIPEser);
274 if (pipe (pfd0) == NOTOK || pipe (pfd1) == NOTOK)
275 adios ("pipe", "unable to");
276 switch (PEERpid = vfork ()) {
278 adios ("vfork", "unable to");/* NOTREACHED */
281 for (w = windows; *w; w++)
282 if ((*w) -> w_fd != NOTOK)
283 (void) close ((*w) -> w_fd);
284 (void) close (pfd0[0]);
285 (void) close (pfd1[1]);
287 vec[vecp++] = "-vmhread";
288 (void) sprintf (buf1, "%d", pfd1[0]);
290 vec[vecp++] = "-vmhwrite";
291 (void) sprintf (buf2, "%d", pfd0[1]);
295 (void) signal (SIGINT, SIG_DFL);
296 (void) signal (SIGQUIT, SIG_DFL);
297 (void) signal (SIGTERM, SIG_DFL);
299 vec[0] = r1bindex (vmhproc, '/');
300 execvp (vmhproc, vec);
302 _exit (-1); /* NOTREACHED */
305 (void) close (pfd0[1]);
306 (void) close (pfd1[0]);
308 (void) rcinit (pfd0[0], pfd1[1]);
319 register struct record *rc = &rcs;
325 (void) sprintf (bp, "%d %d", RC_VRSN, numwins);
327 for (w = windows; *w; w++) {
328 (void) sprintf (bp, " %d", (*w) -> w_height);
332 switch (str2rc (RC_INI, buffer, rc)) {
338 adios (NULLCP, "%s", rc -> rc_data);
340 adios (NULLCP, "pINI peer error");
343 adios (NULLCP, "%s", rc -> rc_data);
346 adios (NULLCP, "pINI protocol screw-up");
353 static int pLOOP (code, str)
359 register struct record *rc = &rcs;
364 (void) str2peer (code, str);
366 switch (peer2rc (rc)) {
368 if (pTTY () == NOTOK)
373 if (sscanf (rc -> rc_data, "%d", &i) != 1
376 (void) fmt2peer (RC_ERR, "no such window \"%s\"",
380 if ((w = windows[i - 1]) -> w_flags & W_CMND) {
381 (void) fmt2peer (RC_ERR, "not a display window \"%s\"",
385 if (pWIN (w) == NOTOK)
394 adorn (NULLCP, "%s", rc -> rc_data);
396 adorn (NULLCP, "pLOOP(%s) peer error",
397 code == RC_QRY ? "QRY" : "CMD");
402 adorn (NULLCP, "%s", rc -> rc_data);
404 i = pidwait (PEERpid, OK);
409 adios (NULLCP, "%s", rc -> rc_data);
412 adios (NULLCP, "pLOOP(%s) protocol screw-up",
413 code == RC_QRY ? "QRY" : "CMD");
420 TYPESIG (*hstat) (), (*istat) (), (*qstat) (), (*tstat) ();
422 register struct record *rc = &rcs;
426 if (ChangeWindowDepth (dfd, twd, 0) == NOTOK)
427 adios ("failed", "ChangeWindowDepth");
429 hstat = signal (SIGHUP, SIG_IGN);
430 istat = signal (SIGINT, SIG_IGN);
431 qstat = signal (SIGQUIT, SIG_IGN);
432 tstat = signal (SIGTERM, SIG_IGN);
434 (void) rc2rc (RC_ACK, 0, NULLCP, rc);
436 (void) signal (SIGHUP, hstat);
437 (void) signal (SIGINT, istat);
438 (void) signal (SIGQUIT, qstat);
439 (void) signal (SIGTERM, tstat);
441 switch (rc -> rc_type) {
443 (void) rc2peer (RC_ACK, 0, NULLCP);
448 adorn (NULLCP, "%s", rc -> rc_data);
450 adorn (NULLCP, "pTTY peer error");
454 adios (NULLCP, "%s", rc -> rc_data);
457 adios (NULLCP, "pTTY protocol screw-up");
469 if ((i = pWINaux (w)) == OK)
477 static int pWINaux (w)
482 register struct line *lp,
485 register struct record *rc = &rcs;
489 for (lp = w -> w_head; lp; lp = mp) {
494 w -> w_head = w -> w_top = w -> w_bottom = w -> w_tail = NULL;
498 switch (rc2rc (RC_ACK, 0, NULLCP, rc)) {
500 for (bp = rc -> rc_data, n = rc -> rc_len; n-- > 0; )
501 (void) WINputc (w, *bp++);
505 (void) rc2peer (RC_ACK, 0, NULLCP);
507 (void) WINputc (w, '\n');
512 adorn (NULLCP, "%s", rc -> rc_data);
514 adorn (NULLCP, "pWIN peer error");
518 adios (NULLCP, "%s", rc -> rc_data);
521 adios (NULLCP, "pWIN protocol screw-up");
534 (void) rc2peer (RC_FIN, 0, NULLCP);
537 switch (setjmp (PEERctx)) {
539 (void) signal (SIGALRM, ALRMser);
540 (void) alarm (ALARM);
542 status = pidwait (PEERpid, OK);
548 (void) kill (PEERpid, SIGKILL);
559 /* should dynamically determine all this stuff from gconfig... */
561 #define MyX 20 /* anchored hpos */
562 #define MyY 40 /* .. vpos */
563 #define MyW 800 /* .. width */
564 #define MyH 500 /* .. height */
565 #define MyS 30 /* .. height for Status, about one line */
568 #define MySlop 45 /* slop */
570 #define EWIDTH 25 /* Width of vertical EBAR */
571 #define ESLOP 5 /* .. slop */
574 static int WINinit (nprog) {
581 if (GetGraphicsConfig (fileno (stderr), &gc) == NOTOK)
585 adios (NULLCP, "not a window");
587 if ((dfd = open ("/dev/ttyw0", 2)) == NOTOK)
588 adios ("/dev/ttyw0", "unable to open");
590 if ((twd = GetTopWindow (dfd)) == NOTOK)
591 adios ("failed", "GetTopWindow");
593 (void) BlockRefreshAdjust (1);
597 wx = gc.w - (MyX + MyW + EWIDTH + ESLOP);
598 Scan = WINnew (wx, wy = MyY, MyW, wh = MyH * 2 / 3, "Scan", W_EBAR);
601 Status = WINnew (wx, sy = wy, MyW, wh = MyS, "Status", W_FAKE);
604 Display = WINnew (wx, wy, MyW, MyH, "Display", W_EBAR);
606 Command = WINnew (wx, sy, MyW, MyS, invo_name, W_CMND);
608 windows[numwins] = NULL;
615 WINDOW *WINnew (wx, wy, ww, wh, name, flags)
625 if ((w = (WINDOW *) calloc (1, sizeof *w)) == NULL)
626 adios (NULLCP, "unable to allocate window");
628 if ((w -> w_flags = flags) & W_FAKE) {
635 if (w -> w_flags & W_EBAR)
636 ww += EWIDTH + ESLOP;
638 wx += EWIDTH + ESLOP;
640 if ((w -> w_fd = OpenWindow (wx, wy, ww, wh, name)) == NOTOK)
641 adios ("failed", "OpenWindow");
642 if ((w -> w_wd = GetTopWindow (dfd)) == NOTOK)
643 adios ("failed", "GetTopWindow");
644 if (GetWindowState (w -> w_fd, &w -> w_ws) == NOTOK)
645 adios ("failed", "GetWindowState");
646 if (SetLineDisc (w -> w_fd, TWSDISC) == NOTOK)
647 adios ("failed", "SetLineDisc");
649 SetBuf (w -> w_fd, 1024);
650 (void) SetAdjust (w -> w_fd, numwins, ADJser);
651 (void) SetRefresh (w -> w_fd, numwins, REFser);
653 SetAddressing (w -> w_fd, VT_ABSOLUTE);
655 if (w -> w_flags & W_EBAR) {
656 w -> w_eb = CreateElevatorBar (w -> w_fd, 0, 0, EWIDTH,
657 w -> w_ws.height, VT_Gray50, 1, EB_VERTICAL,
658 EB_ARROWS, w -> w_ebloc = 0, w -> w_ebsize = EB_MAX,
660 if (w -> w_eb == NULL)
661 adios (NULLCP, "CreateElevatorBar failed");
662 RefreshElevatorBar (w -> w_eb);
665 if ((w -> w_cbase = CharacterBaseline (w -> w_ws.font)) <= 0)
668 if ((w -> w_cheight = CharacterHeight (w -> w_ws.font)) <= 0)
670 w -> w_height = w -> w_ws.height / w -> w_cheight;
671 if (w -> w_height < 1)
675 if ((w -> w_cwidth = CharacterWidth (w -> w_ws.font, 'm')) <= 0)
677 w -> w_width = (w -> w_ws.width - (w -> w_eb ? (EWIDTH + ESLOP) : 0))
679 if (w -> w_width < 1)
683 windows[numwins++] = w;
690 static int WINgetstr (w, prompt, buffer)
700 register struct vtseq *vt = &vts;
702 if (w -> w_eb != NULL)
703 adios (NULLCP, "internal error--elevator bar found");
705 if (w -> w_head == NULL
706 && (w -> w_head = (struct line *) calloc (1, sizeof *w -> w_head))
708 adios (NULLCP, "unable to allocate line storage");
709 w -> w_head -> l_buf = image;
710 w -> w_top = w -> w_bottom = w -> w_tail = w -> w_head;
712 if (ChangeWindowDepth (dfd, w -> w_wd, 0) == NOTOK)
713 adios ("failed", "ChangeWindowDepth");
715 (void) strcpy (image, prompt);
716 bp = ip = image + strlen (image);
721 switch (getvtseq (w -> w_fd, vt)) {
723 DisplayStatus (w -> w_fd, "no hardkeys, please");
727 switch (c = toascii (vt -> u.ascii)) {
728 case '\f': /* refresh? */
733 (void) strcpy (buffer, ip);
738 adorn (NULLCP, "Interrupt");
767 } while (isspace (*bp) && bp > ip);
771 } while (!isspace (*bp) && bp > buffer);
778 if (c < ' ' || c >= '\177')
788 switch (vt -> u.mouse.buttons
789 & (VT_MOUSE_LEFT | VT_MOUSE_MIDDLE | VT_MOUSE_RIGHT)) {
791 DisplayStatus (w -> w_fd, "use middle or right button");
794 #define WPOP "WMH\0Advance\0Burst\0Exit\0EOF\0"
795 case VT_MOUSE_MIDDLE:
796 SetPosition (w -> w_fd, vt -> u.mouse.x,
798 switch (DisplayPopUp (w -> w_fd, WPOP)) {
799 case 1: /* Advance */
801 (void) strcpy (buffer, "advance");
805 (void) strcpy (buffer, "burst");
809 (void) strcpy (buffer, "exit");
815 default: /* failed or none taken */
827 adios (NULLCP, "end-of-file on window");/* NOTREACHED */
830 DisplayStatus (w -> w_fd, "unknown VT sequence");
837 static int WINputc (w, c)
843 register struct line *lp;
848 if (WINputc (w, 'M') == NOTOK || WINputc (w, '-') == NOTOK)
853 if (c < ' ' || c == '\177') {
854 if (WINputc (w, '^') == NOTOK)
861 for (i = 8 - (w -> w_bufpos & 0x07); i > 0; i--)
862 if (WINputc (w, ' ') == NOTOK)
867 if (w -> w_bufpos > 0)
876 w -> w_buffer[w -> w_bufpos++] = c;
880 w -> w_buffer[w -> w_bufpos] = NULL;
883 if ((lp = (struct line *) calloc (1, sizeof *lp)) == NULL)
884 adios (NULLCP, "unable to allocate line storage");
886 lp -> l_no = (w -> w_tail ? w -> w_tail -> l_no : 0) + 1;
887 lp -> l_buf = getcpy (w -> w_buffer);
888 for (cp = lp -> l_buf + strlen (lp -> l_buf) - 1; cp >= lp -> l_buf; cp--)
894 if (w -> w_head == NULL)
896 if (w -> w_top == NULL)
898 if (w -> w_bottom == NULL)
901 w -> w_tail -> l_next = lp;
902 lp -> l_prev = w -> w_tail;
913 static char mylineno[5];
915 static bool cancel[] = { 1 };
916 static struct choice mychoices[] = { LABEL, "cancel", VT_White };
918 static struct question myquestions[] = {
919 STRING, "Line", SZ (mylineno), (struct choice *) 0,
921 TOGGLE, "", SZ (mychoices), mychoices
924 static struct menu mymenu = { "Goto", SZ (myquestions), myquestions };
926 static int *myanswers[] = { (int *) mylineno, (int *) cancel };
937 register struct vtseq *vt = &vts;
939 if (w -> w_fd == NOTOK) {
941 DisplayStatus (dfd, w -> w_top -> l_buf);
948 if (ChangeWindowDepth (dfd, w -> w_wd, 0) == NOTOK)
949 adios ("failed", "ChangeWindowDepth");
953 if (w -> w_bottom == w -> w_tail)
956 if (w -> w_eb == NULL)
957 adios (NULLCP, "internal error--no elevator bar");
959 for (clear = refresh = 0, forw = 1;;) {
961 RemoveStatus (w -> w_fd);
969 switch (getvtseq (w -> w_fd, vt)) {
972 DisplayStatus (w -> w_fd, "use the mouse");
977 switch (vt -> u.mouse.buttons
978 & (VT_MOUSE_LEFT | VT_MOUSE_MIDDLE | VT_MOUSE_RIGHT)) {
980 if ((pos = vt -> u.mouse.x) < EWIDTH) {
981 pos = w -> w_ebloc = DoElevatorBar (w -> w_eb, pos,
983 refresh = WINgoto (w, ((pos * (w -> w_tail -> l_no
984 - w -> w_head -> l_no))
985 / EB_MAX) + w -> w_head -> l_no);
989 #define WPOP "Paging\0Next\0Prev\0Left\0Right\0First\0Last\0Goto ...\0Exit\0"
990 case VT_MOUSE_MIDDLE:
991 SetPosition (w -> w_fd, vt -> u.mouse.x,
993 switch (DisplayPopUp (w -> w_fd, WPOP)) {
996 if (w -> w_bottom == w -> w_tail)
998 refresh = WINgoto (w, w -> w_bottom -> l_no + 1 - PSLOP);
1003 if (w -> w_top == w -> w_head)
1005 refresh = WINgoto (w, w -> w_top -> l_no
1006 - w -> w_height + PSLOP);
1011 DisplayStatus (w -> w_fd, "not yet");
1017 refresh = WINgoto (w, w -> w_head -> l_no);
1022 refresh = WINgoto (w, w -> w_tail -> l_no
1023 - w -> w_height + 1);
1026 case 7: /* Goto ... */
1027 (void) sprintf (mylineno, "%d",
1028 w -> w_top -> l_no);
1030 if (PresentMenu (&mymenu, myanswers)
1033 if (sscanf (mylineno, "%d", &pos) != 1) {
1034 DisplayStatus (w -> w_fd, "bad format");
1038 if (pos < w -> w_head -> l_no
1039 || pos > w -> w_tail -> l_no) {
1040 DisplayStatus (w -> w_fd, "no such line");
1044 refresh = WINgoto (w, pos);
1050 default: /* failed or none taken */
1056 case VT_MOUSE_RIGHT:
1058 if (w -> w_bottom == w -> w_tail)
1069 adios (NULLCP, "end-of-file on window");/* NOTREACHED */
1072 DisplayStatus (w -> w_fd, "unknown VT sequence");
1081 static int WINgoto (w, n)
1087 register struct line *lp;
1089 if (n > (i = w -> w_tail -> l_no - w -> w_height + 1))
1091 if (n < w -> w_head -> l_no)
1092 n = w -> w_head -> l_no;
1094 if ((i = n - (lp = w -> w_head) -> l_no)
1095 > (j = abs (n - w -> w_top -> l_no)))
1096 i = j, lp = w -> w_top;
1098 if (i > (j = abs (w -> w_tail -> l_no - n)))
1099 i = j, lp = w -> w_tail;
1101 if (n >= lp -> l_no) {
1102 for (; lp; lp = lp -> l_next)
1103 if (lp -> l_no == n)
1107 for (; lp; lp = lp -> l_prev)
1108 if (lp -> l_no == n)
1114 if (w -> w_top == lp)
1124 static int ADJser (id, ww, wh)
1131 if (id < 0 || id >= numwins)
1132 adios (NULLCP, "ADJser on bogus window (%d)", id);
1134 if (w -> w_fd == NOTOK)
1135 adios (NULLCP, "ADJser on closed window (%d)", id);
1137 w -> w_ws.width = w -> w_ws.tw = ww;
1138 w -> w_ws.height = w -> w_ws.th = wh;
1141 DeleteElevatorBar (w -> w_eb);
1142 w -> w_eb = CreateElevatorBar (w -> w_fd, 0, 0, EWIDTH,
1143 w -> w_ws.height, VT_Gray50, 1, EB_VERTICAL,
1144 EB_ARROWS, w -> w_ebloc = 0, w -> w_ebsize = EB_MAX,
1146 if (w -> w_eb == NULL)
1147 adios (NULLCP, "CreateElevatorBar failed");
1156 static int REFser (id, wx, wy, ww, wh)
1169 if (id < 0 || id >= numwins)
1170 adios (NULLCP, "REFser on bogus window (%d)", id);
1172 if (w -> w_fd == NOTOK)
1173 adios (NULLCP, "REFser on closed window (%d)", id);
1176 if (GetWindowState (w -> w_fd, &w -> w_ws) == NOTOK)
1177 adios ("failed", "GetWindowState");
1179 GetPermanentClipping (w -> w_fd, &cx, &cy, &cw, &ch);
1180 SetPermanentClipping (w -> w_fd, wx, wy, ww, wh);
1182 SetPermanentClipping (w -> w_fd, cx, cy, cw, ch);
1187 static Redisplay (w, doeb)
1193 register struct line *lp;
1195 if (w -> w_fd == NOTOK)
1198 sx = w -> w_eb ? (EWIDTH + ESLOP) : 0;
1199 w -> w_height = w -> w_ws.height / w -> w_cheight;
1200 if (w -> w_height < 1)
1203 w -> w_width = (w -> w_ws.width - (w -> w_eb ? (EWIDTH + ESLOP) : 0))
1205 if (w -> w_width < 1)
1208 SetPosition (w -> w_fd, sx, 0);
1209 SetColor (w -> w_fd, VT_White);
1210 PaintRectangleInterior (w -> w_fd, w -> w_ws.width, w -> w_ws.height);
1213 SetColor (w -> w_fd, VT_Black);
1214 for (lp = w -> w_top, y = 0;
1215 lp && y < w -> w_height;
1216 w -> w_bottom = lp, lp = lp -> l_next, y++) {
1217 SetPosition (w -> w_fd, sx, y * w -> w_cheight + w -> w_cbase);
1218 PaintString (w -> w_fd, VT_STREND, lp -> l_buf);
1223 if ((y = EB_LOC (w)) != w -> w_ebloc)
1224 MoveElevator (w -> w_eb, w -> w_ebloc = y);
1225 if ((y = EB_SIZE (w)) != w -> w_ebsize)
1226 SizeElevator (w -> w_eb, w -> w_ebsize = y);
1228 RefreshElevatorBar (w -> w_eb);
1236 static int EB_SIZE (w)
1241 if (w -> w_head == NULL)
1244 if ((i = w -> w_tail -> l_no - w -> w_head -> l_no) <= 0)
1247 return (((w -> w_bottom -> l_no - w -> w_top -> l_no) * EB_MAX) / i);
1251 static int EB_LOC (w)
1256 if (w -> w_head == NULL)
1259 if ((i = w -> w_tail -> l_no - w -> w_head -> l_no) <= 0)
1262 return (((w -> w_top -> l_no - w -> w_head -> l_no) * EB_MAX) / i);
1269 if (ioctl (fileno (stdin), TIOCGETP, (char *) &sg) == NOTOK)
1270 adios ("failed", "ioctl TIOCGETP");
1271 if (ioctl (fileno (stdin), TIOCGETC, (char *) &tc) == NOTOK)
1272 adios ("failed", "ioctl TIOCGETC");
1273 if (ioctl (fileno (stdin), TIOCGLTC, (char *) <c) == NOTOK)
1274 adios ("failed", "ioctl TIOCGLTC");
1277 (void) signal (SIGHUP, SIGser);
1278 (void) signal (SIGINT, SIGser);
1279 (void) signal (SIGQUIT, SIGser);
1284 static foreground () {
1288 TYPESIG (*tstat) ();
1290 if ((pgrp = getpgrp (0)) == NOTOK)
1291 adios ("process group", "unable to determine");
1293 if (ioctl (fileno (stdin), TIOCGPGRP, (char *) &tpgrp) == NOTOK)
1294 adios ("tty's process group", "unable to determine");
1298 tstat = signal (SIGTTIN, SIG_DFL);
1299 (void) kill (0, SIGTTIN);
1300 (void) signal (SIGTTIN, tstat);
1303 (void) signal (SIGTTIN, SIG_IGN);
1304 (void) signal (SIGTTOU, SIG_IGN);
1305 (void) signal (SIGTSTP, SIG_IGN);
1310 static sideground () {
1312 (void) signal (SIGTTIN, SIG_DFL);
1313 (void) signal (SIGTTOU, SIG_DFL);
1314 (void) signal (SIGTSTP, SIG_DFL);
1322 static int ALRMser (sig)
1325 longjmp (PEERctx, DONE);
1333 static int PIPEser (sig)
1337 (void) signal (sig, SIG_IGN);
1340 adios (NULLCP, "lost peer");
1348 static int SIGser (sig)
1352 (void) signal (sig, SIG_IGN);
1375 static void adorn (what, fmt, a, b, c, d, e, f)
1385 char *cp = invo_name;
1388 advise (what, fmt, a, b, c, d, e, f);
1396 void advertise (what, tail, fmt, a, b, c, d, e, f)
1408 char buffer[BUFSIZ],
1410 struct iovec iob[20];
1411 register struct iovec *iov = iob;
1413 (void) fflush (stdout);
1415 (void) fflush (stderr);
1418 iov -> iov_len = strlen (iov -> iov_base = invo_name);
1420 iov -> iov_len = strlen (iov -> iov_base = ": ");
1424 (void) sprintf (buffer, fmt, a, b, c, d, e, f);
1425 iov -> iov_len = strlen (iov -> iov_base = buffer);
1429 iov -> iov_len = strlen (iov -> iov_base = " ");
1431 iov -> iov_len = strlen (iov -> iov_base = what);
1433 iov -> iov_len = strlen (iov -> iov_base = ": ");
1436 if (eindex > 0 && eindex < sys_nerr)
1437 iov -> iov_len = strlen (iov -> iov_base = sys_errlist[eindex]);
1439 (void) sprintf (err, "Error %d", eindex);
1440 iov -> iov_len = strlen (iov -> iov_base = err);
1444 if (tail && *tail) {
1445 iov -> iov_len = strlen (iov -> iov_base = ", ");
1447 iov -> iov_len = strlen (iov -> iov_base = tail);
1450 iov -> iov_len = strlen (iov -> iov_base = "\n");
1454 (void) DisplayVector (iob, iov - iob);
1456 (void) writev (fileno (stderr), iob, iov - iob);
1461 static DisplayVector (iov, n)
1462 register struct iovec *iov;
1467 char buffer[BUFSIZ];
1469 for (i = 0, cp = NULL; i < n; i++, iov++) {
1470 (void) sprintf (buffer, "%*.*s", iov -> iov_len, iov -> iov_len,
1472 cp = add (buffer, cp);
1475 DisplayStatus (dfd, cp);