Annotation of 43BSD/contrib/mh/sbr/advertise.c, revision 1.1.1.1

1.1       root        1: /* advertise.c - the heart of adios */
                      2: 
                      3: #include "../h/mh.h"
                      4: #include <stdio.h>
                      5: #ifdef BSD42
                      6: #include <sys/types.h>
                      7: #include <sys/uio.h>
                      8: #endif BSD42
                      9: 
                     10: /* For 4.2BSD systems, use writev() for slightly better performance.  Why?
                     11:    Well, there are a couple of reasons.  Primarily, it gives a smoother
                     12:    output...  More importantly though, it's a sexy syscall()...
                     13:  */
                     14: 
                     15: extern int  errno;
                     16: extern int  sys_nerr;
                     17: extern char *sys_errlist[];
                     18: 
                     19: /*  */
                     20: 
                     21: /* VARARGS3 */
                     22: 
                     23: void advertise (what, tail, fmt, a, b, c, d, e, f)
                     24: char   *what,
                     25:        *tail,
                     26:        *fmt,
                     27:        *a,
                     28:        *b,
                     29:        *c,
                     30:        *d,
                     31:        *e,
                     32:        *f;
                     33: {
                     34:     int            eindex = errno;
                     35: #ifdef BSD42
                     36:     char    buffer[BUFSIZ],
                     37:             err[BUFSIZ];
                     38:     struct iovec    iob[20];
                     39:     register struct iovec  *iov = iob;
                     40: #endif BSD42
                     41: 
                     42:     (void) fflush (stdout);
                     43: 
                     44: #ifndef        BSD42
                     45:     fprintf (stderr, "%s: ", invo_name);
                     46:     fprintf (stderr, fmt, a, b, c, d, e, f);
                     47:     if (what) {
                     48:        if (*what)
                     49:            fprintf (stderr, " %s: ", what);
                     50:        if (eindex > 0 && eindex < sys_nerr)
                     51:            fprintf (stderr, "%s", sys_errlist[eindex]);
                     52:        else
                     53:            fprintf (stderr, "Error %d", eindex);
                     54:     }
                     55:     if (tail)
                     56:        fprintf (stderr, ", %s", tail);
                     57:     (void) fputc ('\n', stderr);
                     58: #else  BSD42
                     59:     (void) fflush (stderr);
                     60: 
                     61:     iov -> iov_len = strlen (iov -> iov_base = invo_name);
                     62:     iov++;
                     63:     iov -> iov_len = strlen (iov -> iov_base = ": ");
                     64:     iov++;
                     65:     
                     66:     (void) sprintf (buffer, fmt, a, b, c, d, e, f);
                     67:     iov -> iov_len = strlen (iov -> iov_base = buffer);
                     68:     iov++;
                     69:     if (what) {
                     70:        if (*what) {
                     71:            iov -> iov_len = strlen (iov -> iov_base = " ");
                     72:            iov++;
                     73:            iov -> iov_len = strlen (iov -> iov_base = what);
                     74:            iov++;
                     75:            iov -> iov_len = strlen (iov -> iov_base = ": ");
                     76:            iov++;
                     77:        }
                     78:        if (eindex > 0 && eindex < sys_nerr)
                     79:            iov -> iov_len = strlen (iov -> iov_base = sys_errlist[eindex]);
                     80:        else {
                     81:            (void) sprintf (err, "Error %d", eindex);
                     82:            iov -> iov_len = strlen (iov -> iov_base = err);
                     83:        }
                     84:        iov++;
                     85:     }
                     86:     if (tail && *tail) {
                     87:        iov -> iov_len = strlen (iov -> iov_base = ", ");
                     88:        iov++;
                     89:        iov -> iov_len = strlen (iov -> iov_base = tail);
                     90:        iov++;
                     91:     }
                     92:     iov -> iov_len = strlen (iov -> iov_base = "\n");
                     93:     iov++;
                     94:     (void) writev (fileno (stderr), iob, iov - iob);
                     95: #endif BSD42
                     96: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.