Annotation of 43BSDReno/contrib/isode-beta/compat/asprintf.c, revision 1.1.1.1

1.1       root        1: /* asprintf.c - sprintf with errno */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/compat/RCS/asprintf.c,v 7.1 90/02/19 13:07:10 mrose Exp $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/compat/RCS/asprintf.c,v 7.1 90/02/19 13:07:10 mrose Exp $
                      9:  *
                     10:  *
                     11:  * $Log:       asprintf.c,v $
                     12:  * Revision 7.1  90/02/19  13:07:10  mrose
                     13:  * update
                     14:  * 
                     15:  * Revision 7.0  89/11/23  21:22:54  mrose
                     16:  * Release 6.0
                     17:  * 
                     18:  */
                     19: 
                     20: /*
                     21:  *                               NOTICE
                     22:  *
                     23:  *    Acquisition, use, and distribution of this module and related
                     24:  *    materials are subject to the restrictions of a license agreement.
                     25:  *    Consult the Preface in the User's Manual for the full terms of
                     26:  *    this agreement.
                     27:  *
                     28:  */
                     29: 
                     30: 
                     31: /* LINTLIBRARY */
                     32: 
                     33: #include <stdio.h>
                     34: #include <varargs.h>
                     35: #include "general.h"
                     36: #include "manifest.h"
                     37: 
                     38: /*    DATA */
                     39: 
                     40: extern int errno;
                     41: 
                     42: /*  */
                     43: 
                     44: void   asprintf (bp, ap)               /* what, fmt, args, ... */
                     45: char *bp;
                     46: va_list        ap;
                     47: {
                     48:     char   *what;
                     49: 
                     50:     what = va_arg (ap, char *);
                     51: 
                     52:     _asprintf (bp, what, ap);
                     53: }
                     54: 
                     55: 
                     56: void   _asprintf (bp, what, ap)        /* fmt, args, ... */
                     57: register char *bp;
                     58: char   *what;
                     59: va_list        ap;
                     60: {
                     61:     register int    eindex;
                     62:     char   *fmt;
                     63: 
                     64:     eindex = errno;
                     65: 
                     66:     *bp = NULL;
                     67:     fmt = va_arg (ap, char *);
                     68: 
                     69:     if (fmt) {
                     70: #ifndef        VSPRINTF
                     71:        struct _iobuf iob;
                     72: #endif
                     73: 
                     74: #ifndef        VSPRINTF
                     75: #ifdef pyr
                     76:        bzero ((char *) &iob, sizeof iob);
                     77:        iob._file = _NFILE;
                     78: #endif
                     79:        iob._flag = _IOWRT | _IOSTRG;
                     80: #if    !defined(vax) && !defined(pyr)
                     81:        iob._ptr = (unsigned char *) bp;
                     82: #else
                     83:        iob._ptr = bp;
                     84: #endif
                     85:        iob._cnt = BUFSIZ;
                     86:        _doprnt (fmt, ap, &iob);
                     87:        putc (NULL, &iob);
                     88: #else
                     89:        (void) vsprintf (bp, fmt, ap);
                     90: #endif
                     91:        bp += strlen (bp);
                     92: 
                     93:     }
                     94: 
                     95:     if (what) {
                     96:        if (*what) {
                     97:            (void) sprintf (bp, " %s: ", what);
                     98:            bp += strlen (bp);
                     99:        }
                    100:        (void) strcpy (bp, sys_errname (eindex));
                    101:        bp += strlen (bp);
                    102:     }
                    103: 
                    104:     errno = eindex;
                    105: }

unix.superglobalmegacorp.com

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