3 * wmh.c -- window front-end to nmh
7 * This code is Copyright (c) 2002, by the authors of nmh. See the
8 * COPYRIGHT file in the root directory of the nmh distribution for
9 * complete copyright information.
14 * Pass signals to client during execution
16 * Figure out a way for the user to say how big the Scan/Display
17 * windows should be, and where all the windows should be.
21 #include <h/signals.h>
32 #define ALARM ((unsigned int) 10)
33 #define PAUSE ((unsigned int) 2)
35 #define SZ(a) (sizeof a / sizeof a[0])
37 static struct swit switches[] = {
39 { "prompt string", 6 },
41 { "vmhproc program", 7 },
51 static int PEERpid = NOTOK;
53 static jmp_buf PEERctx;
57 static int dfd = NOTOK;
58 static int twd = NOTOK;
59 static char *myprompt = "(%s) ";
88 struct line *w_bottom;
90 char w_buffer[BUFSIZ];
96 static WINDOW *Status;
97 static WINDOW *Display;
98 static WINDOW *Command;
102 WINDOW *windows[NWIN + 1];
107 #ifdef HAVE_TERMIOS_H
108 static struct termios tio;
109 # define ERASE tio.c_cc[VERASE]
110 # define KILL tio.c_cc[VKILL]
111 # define INTR tio.c_cc[VINTR]
113 # ifdef HAVE_TERMIO_H
114 static struct termio tio;
115 # define ERASE tio.c_cc[VERASE]
116 # define KILL tio.c_cc[VKILL]
117 # define INTR tio.c_cc[VINTR]
119 static struct sgttyb tio;
120 static struct tchars tc;
121 # define ERASE tio.sg_erase
122 # define KILL tio.sg_kill
123 # define INTR tc.t_intrc
124 # define EOFC tc.t_eofc
128 #define WERASC ltc.t_werasc
129 static struct ltchars ltc;
132 int ALRMser (), PIPEser (), SIGser ();
133 int ADJser (), REFser ();
138 static void adorn(char *, char *, ...);
142 main (int argc, char **argv)
144 int vecp = 1, nprog = 0;
145 char *cp, buffer[BUFSIZ], **argp;
146 char **arguments, *vec[MAXARGS];
149 setlocale(LC_ALL, "");
151 invo_name = r1bindex (argv[0], '/');
153 /* read user profile/context */
156 arguments = getarguments (invo_name, argc,argv, 1);
159 while ((cp = *argp++))
161 switch (smatch (++cp, switches)) {
163 ambigsw (cp, switches);
170 snprintf (buffer, sizeof(buffer), "%s [switches for vmhproc]",
172 print_help (buffer, switches, 1);
175 print_version(invo_name);
179 if (!(myprompt = *argp++) || *myprompt == '-')
180 adios (NULL, "missing argument to %s", argp[-2]);
184 if (!(vmhproc = *argp++) || *vmhproc == '-')
185 adios (NULL, "missing argument to %s", argp[-2]);
195 if (WINinit (nprog) == NOTOK) {
198 vec[0] = r1bindex (vmhproc, '/');
199 execvp (vmhproc, vec);
200 adios (vmhproc, "unable to exec");
202 PEERinit (vecp, vec);
213 char buffer[BUFSIZ], prompt[BUFSIZ];
216 pLOOP (RC_QRY, NULL);
218 snprintf (prompt, sizeof(prompt), myprompt, invo_name);
220 switch (WINgetstr (Command, prompt, buffer)) {
225 done (0); /* NOTREACHED */
229 pLOOP (RC_CMD, buffer);
238 PEERinit (int vecp, char *vec[])
240 int pfd0[2], pfd1[2];
241 char buf1[BUFSIZ], buf2[BUFSIZ];
244 SIGNAL (SIGPIPE, PIPEser);
246 if (pipe (pfd0) == NOTOK || pipe (pfd1) == NOTOK)
247 adios ("pipe", "unable to");
248 switch (PEERpid = vfork ()) {
250 adios ("vfork", "unable to");/* NOTREACHED */
253 for (w = windows; *w; w++)
254 if ((*w)->w_fd != NOTOK)
259 vec[vecp++] = "-vmhread";
260 snprintf (buf1, sizeof(buf1), "%d", pfd1[0]);
262 vec[vecp++] = "-vmhwrite";
263 snprintf (buf2, sizeof(buf2), "%d", pfd0[1]);
267 SIGNAL (SIGINT, SIG_DFL);
268 SIGNAL (SIGQUIT, SIG_DFL);
269 SIGNAL (SIGTERM, SIG_DFL);
271 vec[0] = r1bindex (vmhproc, '/');
272 execvp (vmhproc, vec);
274 _exit (-1); /* NOTREACHED */
280 rcinit (pfd0[0], pfd1[1]);
290 char *bp, buffer[BUFSIZ];
291 struct record rcs, *rc;
297 /* Get buffer ready to go */
299 buflen = sizeof(buffer);
301 snprintf (bp, buflen, "%d %d", RC_VRSN, numwins);
306 for (w = windows; *w; w++) {
307 snprintf (bp, buflen, " %d", (*w)->w_height);
313 switch (str2rc (RC_INI, buffer, rc)) {
319 adios (NULL, "%s", rc->rc_data);
321 adios (NULL, "pINI peer error");
324 adios (NULL, "%s", rc->rc_data);
327 adios (NULL, "pINI protocol screw-up");
334 pLOOP (char code, char *str)
337 struct record rcs, *rc;
343 str2peer (code, str);
345 switch (peer2rc (rc)) {
347 if (pTTY () == NOTOK)
352 if (sscanf (rc->rc_data, "%d", &i) != 1
355 fmt2peer (RC_ERR, "no such window \"%s\"", rc->rc_data);
358 if ((w = windows[i - 1])->w_flags & W_CMND) {
359 fmt2peer (RC_ERR, "not a display window \"%s\"", rc->rc_data);
362 if (pWIN (w) == NOTOK)
371 adorn (NULL, "%s", rc->rc_data);
373 adorn (NULL, "pLOOP(%s) peer error",
374 code == RC_QRY ? "QRY" : "CMD");
379 adorn (NULL, "%s", rc->rc_data);
381 i = pidwait (PEERpid, OK);
386 adios (NULL, "%s", rc->rc_data);
389 adios (NULL, "pLOOP(%s) protocol screw-up",
390 code == RC_QRY ? "QRY" : "CMD");
398 SIGNAL_HANDLER hstat, istat, qstat, tstat;
399 struct record rcs, *rc;
404 if (ChangeWindowDepth (dfd, twd, 0) == NOTOK)
405 adios ("failed", "ChangeWindowDepth");
407 /* should block here instead of ignore */
408 hstat = SIGNAL (SIGHUP, SIG_IGN);
409 istat = SIGNAL (SIGINT, SIG_IGN);
410 qstat = SIGNAL (SIGQUIT, SIG_IGN);
411 tstat = SIGNAL (SIGTERM, SIG_IGN);
413 rc2rc (RC_ACK, 0, NULL, rc);
415 SIGNAL (SIGHUP, hstat);
416 SIGNAL (SIGINT, istat);
417 SIGNAL (SIGQUIT, qstat);
418 SIGNAL (SIGTERM, tstat);
420 switch (rc->rc_type) {
422 rc2peer (RC_ACK, 0, NULL);
427 adorn (NULL, "%s", rc->rc_data);
429 adorn (NULL, "pTTY peer error");
433 adios (NULL, "%s", rc->rc_data);
436 adios (NULL, "pTTY protocol screw-up");
447 if ((i = pWINaux (w)) == OK)
459 register struct line *lp, *mp;
460 struct record rcs, *rc;
465 for (lp = w->w_head; lp; lp = mp) {
470 w->w_head = w->w_top = w->w_bottom = w->w_tail = NULL;
474 switch (rc2rc (RC_ACK, 0, NULL, rc)) {
476 for (bp = rc->rc_data, n = rc->rc_len; n-- > 0; )
481 rc2peer (RC_ACK, 0, NULL);
488 adorn (NULL, "%s", rc->rc_data);
490 adorn (NULL, "pWIN peer error");
494 adios (NULL, "%s", rc->rc_data);
497 adios (NULL, "pWIN protocol screw-up");
511 rc2peer (RC_FIN, 0, NULL);
514 switch (setjmp (PEERctx)) {
516 SIGNAL (SIGALRM, ALRMser);
519 status = pidwait (PEERpid, OK);
525 kill (PEERpid, SIGKILL);
536 /* should dynamically determine all this stuff from gconfig... */
538 #define MyX 20 /* anchored hpos */
539 #define MyY 40 /* .. vpos */
540 #define MyW 800 /* .. width */
541 #define MyH 500 /* .. height */
542 #define MyS 30 /* .. height for Status, about one line */
545 #define MySlop 45 /* slop */
547 #define EWIDTH 25 /* Width of vertical EBAR */
548 #define ESLOP 5 /* .. slop */
551 static intWINinit (nprog) {
552 short wx, wy, wh, sy;
555 if (GetGraphicsConfig (fileno (stderr), &gc) == NOTOK)
559 adios (NULL, "not a window");
561 if ((dfd = open ("/dev/ttyw0", O_RDWR)) == NOTOK)
562 adios ("/dev/ttyw0", "unable to open");
564 if ((twd = GetTopWindow (dfd)) == NOTOK)
565 adios ("failed", "GetTopWindow");
567 BlockRefreshAdjust (1);
571 wx = gc.w - (MyX + MyW + EWIDTH + ESLOP);
572 Scan = WINnew (wx, wy = MyY, MyW, wh = MyH * 2 / 3, "Scan", W_EBAR);
575 Status = WINnew (wx, sy = wy, MyW, wh = MyS, "Status", W_FAKE);
578 Display = WINnew (wx, wy, MyW, MyH, "Display", W_EBAR);
580 Command = WINnew (wx, sy, MyW, MyS, invo_name, W_CMND);
582 windows[numwins] = NULL;
589 WINnew (short wx, short wy, short ww, short wh, char *name, int flags)
593 if ((w = (WINDOW *) calloc (1, sizeof *w)) == NULL)
594 adios (NULL, "unable to allocate window");
596 if ((w->w_flags = flags) & W_FAKE) {
603 if (w->w_flags & W_EBAR)
604 ww += EWIDTH + ESLOP;
606 wx += EWIDTH + ESLOP;
608 if ((w->w_fd = OpenWindow (wx, wy, ww, wh, name)) == NOTOK)
609 adios ("failed", "OpenWindow");
610 if ((w->w_wd = GetTopWindow (dfd)) == NOTOK)
611 adios ("failed", "GetTopWindow");
612 if (GetWindowState (w->w_fd, &w->w_ws) == NOTOK)
613 adios ("failed", "GetWindowState");
614 if (SetLineDisc (w->w_fd, TWSDISC) == NOTOK)
615 adios ("failed", "SetLineDisc");
617 SetBuf (w->w_fd, 1024);
618 SetAdjust (w->w_fd, numwins, ADJser);
619 SetRefresh (w->w_fd, numwins, REFser);
621 SetAddressing (w->w_fd, VT_ABSOLUTE);
623 if (w->w_flags & W_EBAR) {
624 w->w_eb = CreateElevatorBar (w->w_fd, 0, 0, EWIDTH,
625 w->w_ws.height, VT_Gray50, 1, EB_VERTICAL,
626 EB_ARROWS, w->w_ebloc = 0, w->w_ebsize = EB_MAX,
629 adios (NULL, "CreateElevatorBar failed");
630 RefreshElevatorBar (w->w_eb);
633 if ((w->w_cbase = CharacterBaseline (w->w_ws.font)) <= 0)
636 if ((w->w_cheight = CharacterHeight (w->w_ws.font)) <= 0)
638 w->w_height = w->w_ws.height / w->w_cheight;
643 if ((w->w_cwidth = CharacterWidth (w->w_ws.font, 'm')) <= 0)
645 w->w_width = (w->w_ws.width - (w->w_eb ? (EWIDTH + ESLOP) : 0))
651 windows[numwins++] = w;
658 WINgetstr (WINDOW *w, char *prompt, char *buffer)
661 register char *bp, *ip;
664 register struct vtseq *vt = &vts;
667 adios (NULL, "internal error--elevator bar found");
669 if (w->w_head == NULL
670 && (w->w_head = (struct line *) calloc (1, sizeof *w->w_head))
672 adios (NULL, "unable to allocate line storage");
673 w->w_head->l_buf = image;
674 w->w_top = w->w_bottom = w->w_tail = w->w_head;
676 if (ChangeWindowDepth (dfd, w->w_wd, 0) == NOTOK)
677 adios ("failed", "ChangeWindowDepth");
679 strncpy (image, prompt, sizeof(image));
680 bp = ip = image + strlen (image);
685 switch (getvtseq (w->w_fd, vt)) {
687 DisplayStatus (w->w_fd, "no hardkeys, please");
691 switch (c = toascii (vt->u.ascii)) {
692 case '\f': /* refresh? */
702 adorn (NULL, "Interrupt");
731 } while (isspace (*bp) && bp > ip);
735 } while (!isspace (*bp) && bp > buffer);
742 if (c < ' ' || c >= '\177')
752 switch (vt->u.mouse.buttons
753 & (VT_MOUSE_LEFT | VT_MOUSE_MIDDLE | VT_MOUSE_RIGHT)) {
755 DisplayStatus (w->w_fd, "use middle or right button");
758 #define WPOP "WMH\0Advance\0Burst\0Exit\0EOF\0"
759 case VT_MOUSE_MIDDLE:
760 SetPosition (w->w_fd, vt->u.mouse.x,
762 switch (DisplayPopUp (w->w_fd, WPOP)) {
763 case 1: /* Advance */
765 strcpy (buffer, "advance");
769 strcpy (buffer, "burst");
773 strcpy (buffer, "exit");
779 default: /* failed or none taken */
791 adios (NULL, "end-of-file on window");/* NOTREACHED */
794 DisplayStatus (w->w_fd, "unknown VT sequence");
801 WINputc (WINDOW *w, char c)
805 register struct line *lp;
810 if (WINputc (w, 'M') == NOTOK || WINputc (w, '-') == NOTOK)
815 if (c < ' ' || c == '\177') {
816 if (WINputc (w, '^') == NOTOK)
823 for (i = 8 - (w->w_bufpos & 0x07); i > 0; i--)
824 if (WINputc (w, ' ') == NOTOK)
838 w->w_buffer[w->w_bufpos++] = c;
842 w->w_buffer[w->w_bufpos] = NULL;
845 if ((lp = (struct line *) calloc (1, sizeof *lp)) == NULL)
846 adios (NULL, "unable to allocate line storage");
848 lp->l_no = (w->w_tail ? w->w_tail->l_no : 0) + 1;
849 lp->l_buf = getcpy (w->w_buffer);
850 for (cp = lp->l_buf + strlen (lp->l_buf) - 1; cp >= lp->l_buf; cp--)
856 if (w->w_head == NULL)
858 if (w->w_top == NULL)
860 if (w->w_bottom == NULL)
863 w->w_tail->l_next = lp;
864 lp->l_prev = w->w_tail;
873 static char mylineno[5];
875 static bool cancel[] = { 1 };
876 static struct choice mychoices[] = { LABEL, "cancel", VT_White };
878 static struct question myquestions[] = {
879 STRING, "Line", SZ (mylineno), (struct choice *) 0,
881 TOGGLE, "", SZ (mychoices), mychoices
884 static struct menu mymenu = { "Goto", SZ (myquestions), myquestions };
886 static int *myanswers[] = { (int *) mylineno, (int *) cancel };
892 int clear, pos, forw, refresh;
894 register struct vtseq *vt = &vts;
896 if (w->w_fd == NOTOK) {
898 DisplayStatus (dfd, w->w_top->l_buf);
905 if (ChangeWindowDepth (dfd, w->w_wd, 0) == NOTOK)
906 adios ("failed", "ChangeWindowDepth");
910 if (w->w_bottom == w->w_tail)
914 adios (NULL, "internal error--no elevator bar");
916 for (clear = refresh = 0, forw = 1;;) {
918 RemoveStatus (w->w_fd);
926 switch (getvtseq (w->w_fd, vt)) {
929 DisplayStatus (w->w_fd, "use the mouse");
934 switch (vt->u.mouse.buttons
935 & (VT_MOUSE_LEFT | VT_MOUSE_MIDDLE | VT_MOUSE_RIGHT)) {
937 if ((pos = vt->u.mouse.x) < EWIDTH) {
938 pos = w->w_ebloc = DoElevatorBar (w->w_eb, pos,
940 refresh = WINgoto (w, ((pos * (w->w_tail->l_no
942 / EB_MAX) + w->w_head->l_no);
946 #define WPOP "Paging\0Next\0Prev\0Left\0Right\0First\0Last\0Goto ...\0Exit\0"
947 case VT_MOUSE_MIDDLE:
948 SetPosition (w->w_fd, vt->u.mouse.x,
950 switch (DisplayPopUp (w->w_fd, WPOP)) {
953 if (w->w_bottom == w->w_tail)
955 refresh = WINgoto (w, w->w_bottom->l_no + 1 - PSLOP);
960 if (w->w_top == w->w_head)
962 refresh = WINgoto (w, w->w_top->l_no
963 - w->w_height + PSLOP);
968 DisplayStatus (w->w_fd, "not yet");
974 refresh = WINgoto (w, w->w_head->l_no);
979 refresh = WINgoto (w, w->w_tail->l_no
983 case 7: /* Goto ... */
984 snprintf (mylineno, sizeof(mylineno),
985 "%d", w->w_top->l_no);
987 if (PresentMenu (&mymenu, myanswers)
990 if (sscanf (mylineno, "%d", &pos) != 1) {
991 DisplayStatus (w->w_fd, "bad format");
995 if (pos < w->w_head->l_no
996 || pos > w->w_tail->l_no) {
997 DisplayStatus (w->w_fd, "no such line");
1001 refresh = WINgoto (w, pos);
1007 default: /* failed or none taken */
1013 case VT_MOUSE_RIGHT:
1015 if (w->w_bottom == w->w_tail)
1026 adios (NULL, "end-of-file on window");/* NOTREACHED */
1029 DisplayStatus (w->w_fd, "unknown VT sequence");
1038 WINgoto (WINDOW *w, int n)
1041 register struct line *lp;
1043 if (n > (i = w->w_tail->l_no - w->w_height + 1))
1045 if (n < w->w_head->l_no)
1046 n = w->w_head->l_no;
1048 if ((i = n - (lp = w->w_head)->l_no)
1049 > (j = abs (n - w->w_top->l_no)))
1050 i = j, lp = w->w_top;
1052 if (i > (j = abs (w->w_tail->l_no - n)))
1053 i = j, lp = w->w_tail;
1055 if (n >= lp->l_no) {
1056 for (; lp; lp = lp->l_next)
1061 for (; lp; lp = lp->l_prev)
1078 ADJser (int id, short ww, short wh)
1082 if (id < 0 || id >= numwins)
1083 adios (NULL, "ADJser on bogus window (%d)", id);
1085 if (w->w_fd == NOTOK)
1086 adios (NULL, "ADJser on closed window (%d)", id);
1088 w->w_ws.width = w->w_ws.tw = ww;
1089 w->w_ws.height = w->w_ws.th = wh;
1092 DeleteElevatorBar (w->w_eb);
1093 w->w_eb = CreateElevatorBar (w->w_fd, 0, 0, EWIDTH,
1094 w->w_ws.height, VT_Gray50, 1, EB_VERTICAL,
1095 EB_ARROWS, w->w_ebloc = 0, w->w_ebsize = EB_MAX,
1097 if (w->w_eb == NULL)
1098 adios (NULL, "CreateElevatorBar failed");
1106 REFser (int id, short wx, short wy, short ww, short wh)
1108 short cx, cy, cw, ch;
1111 if (id < 0 || id >= numwins)
1112 adios (NULL, "REFser on bogus window (%d)", id);
1114 if (w->w_fd == NOTOK)
1115 adios (NULL, "REFser on closed window (%d)", id);
1118 if (GetWindowState (w->w_fd, &w->w_ws) == NOTOK)
1119 adios ("failed", "GetWindowState");
1121 GetPermanentClipping (w->w_fd, &cx, &cy, &cw, &ch);
1122 SetPermanentClipping (w->w_fd, wx, wy, ww, wh);
1124 SetPermanentClipping (w->w_fd, cx, cy, cw, ch);
1129 Redisplay (WINDOW *w, int doeb)
1133 register struct line *lp;
1135 if (w->w_fd == NOTOK)
1138 sx = w->w_eb ? (EWIDTH + ESLOP) : 0;
1139 w->w_height = w->w_ws.height / w->w_cheight;
1140 if (w->w_height < 1)
1143 w->w_width = (w->w_ws.width - (w->w_eb ? (EWIDTH + ESLOP) : 0))
1148 SetPosition (w->w_fd, sx, 0);
1149 SetColor (w->w_fd, VT_White);
1150 PaintRectangleInterior (w->w_fd, w->w_ws.width, w->w_ws.height);
1153 SetColor (w->w_fd, VT_Black);
1154 for (lp = w->w_top, y = 0;
1155 lp && y < w->w_height;
1156 w->w_bottom = lp, lp = lp->l_next, y++) {
1157 SetPosition (w->w_fd, sx, y * w->w_cheight + w->w_cbase);
1158 PaintString (w->w_fd, VT_STREND, lp->l_buf);
1163 if ((y = EB_LOC (w)) != w->w_ebloc)
1164 MoveElevator (w->w_eb, w->w_ebloc = y);
1165 if ((y = EB_SIZE (w)) != w->w_ebsize)
1166 SizeElevator (w->w_eb, w->w_ebsize = y);
1168 RefreshElevatorBar (w->w_eb);
1180 if (w->w_head == NULL)
1183 if ((i = w->w_tail->l_no - w->w_head->l_no) <= 0)
1186 return (((w->w_bottom->l_no - w->w_top->l_no) * EB_MAX) / i);
1195 if (w->w_head == NULL)
1198 if ((i = w->w_tail->l_no - w->w_head->l_no) <= 0)
1201 return (((w->w_top->l_no - w->w_head->l_no) * EB_MAX) / i);
1210 if (ioctl (fileno (stdin), TIOCGETP, (char *) &tio) == NOTOK)
1211 adios ("failed", "ioctl TIOCGETP");
1212 if (ioctl (fileno (stdin), TIOCGETC, (char *) &tc) == NOTOK)
1213 adios ("failed", "ioctl TIOCGETC");
1214 if (ioctl (fileno (stdin), TIOCGLTC, (char *) <c) == NOTOK)
1215 adios ("failed", "ioctl TIOCGLTC");
1218 SIGNAL (SIGHUP, SIGser);
1219 SIGNAL (SIGINT, SIGser);
1220 SIGNAL (SIGQUIT, SIGser);
1229 SIGNAL_HANDLER tstat;
1231 if ((pgrp = getpgrp (0)) == NOTOK)
1232 adios ("process group", "unable to determine");
1234 if (ioctl (fileno (stdin), TIOCGPGRP, (char *) &tpgrp) == NOTOK)
1235 adios ("tty's process group", "unable to determine");
1239 tstat = SIGNAL (SIGTTIN, SIG_DFL);
1241 SIGNAL (SIGTTIN, tstat);
1244 SIGNAL (SIGTTIN, SIG_IGN);
1245 SIGNAL (SIGTTOU, SIG_IGN);
1246 SIGNAL (SIGTSTP, SIG_IGN);
1255 SIGNAL (SIGTTIN, SIG_DFL);
1256 SIGNAL (SIGTTOU, SIG_DFL);
1257 SIGNAL (SIGTSTP, SIG_DFL);
1265 longjmp (PEERctx, DONE);
1272 #ifndef RELIABLE_SIGNALS
1273 SIGNAL (sig, SIG_IGN);
1276 adios (NULL, "lost peer");
1283 #ifndef RELIABLE_SIGNALS
1284 SIGNAL (sig, SIG_IGN);
1300 return 1; /* dead code to satisfy the compiler */
1305 adorn (char *what, char *fmt, ...)
1314 advertise (what, NULL, fmt, ap);
1322 advertise (char *what, char *tail, va_list ap)
1325 char buffer[BUFSIZ], err[BUFSIZ];
1326 struct iovec iob[20];
1327 register struct iovec *iov = iob;
1333 iov->iov_len = strlen (iov->iov_base = invo_name);
1335 iov->iov_len = strlen (iov->iov_base = ": ");
1339 vsnprintf (buffer, sizeof(buffer), fmt, ap);
1340 iov->iov_len = strlen (iov->iov_base = buffer);
1344 iov->iov_len = strlen (iov->iov_base = " ");
1346 iov->iov_len = strlen (iov->iov_base = what);
1348 iov->iov_len = strlen (iov->iov_base = ": ");
1351 if (!(iov->iov_base = strerror (eindex))) {
1352 snprintf (err, sizeof(err), "unknown error %d", eindex);
1353 iov->iov_base = err;
1355 iov->iov_len = strlen (iov->iov_base);
1358 if (tail && *tail) {
1359 iov->iov_len = strlen (iov->iov_base = ", ");
1361 iov->iov_len = strlen (iov->iov_base = tail);
1364 iov->iov_len = strlen (iov->iov_base = "\n");
1368 DisplayVector (iob, iov - iob);
1370 writev (fileno (stderr), iob, iov - iob);
1375 DisplayVector (struct iovec *iov, int n)
1379 char buffer[BUFSIZ];
1381 for (i = 0, cp = NULL; i < n; i++, iov++) {
1382 snprintf (buffer, sizeof(buffer), "%*.*s", iov->iov_len,
1383 iov->iov_len, iov->iov_base);
1384 cp = add (buffer, cp);
1387 DisplayStatus (dfd, cp);