Annotation of researchv10no/cmd/dist/lib/print.c, revision 1.1

1.1     ! root        1: #include <stdarg.h>
        !             2: #include <stdio.h>
        !             3: #include <time.h>
        !             4: #include "lib.h"
        !             5: 
        !             6: #ifdef DOPRNT
        !             7: #define vfprintf(fp, fmt, ap) _doprnt(fmt, ap, fp)
        !             8: #endif
        !             9: 
        !            10: char *prog = "(uninitialized)";
        !            11: 
        !            12: static FILE *logfp;
        !            13: 
        !            14: void
        !            15: openlog(char *logfile)
        !            16: {
        !            17:        if (logfp)
        !            18:                fclose(logfp);
        !            19:        logfp = fopen(logfile, "a");
        !            20: }
        !            21: 
        !            22: static void
        !            23: vlprintf(char *fmt, va_list ap)
        !            24: {
        !            25:        time_t now;
        !            26: 
        !            27:        if (logfp) {
        !            28:                time(&now);
        !            29:                fprintf(logfp, "%s [%d %.24s]: ", prog, getpid(), ctime(&now));
        !            30:                vfprintf(logfp, fmt, ap);
        !            31:                putc('\n', logfp);
        !            32:                fflush(logfp);
        !            33:        }
        !            34: }
        !            35: 
        !            36: void
        !            37: eprintf(char *fmt, ...)
        !            38: {
        !            39:        va_list ap;
        !            40: 
        !            41:        fprintf(stderr, "%s: ", prog);
        !            42:        va_start(ap, fmt);
        !            43:        vfprintf(stderr, fmt, ap);
        !            44:        va_end(ap);
        !            45:        putc('\n', stderr);
        !            46: 
        !            47:        va_start(ap, fmt);
        !            48:        vlprintf(fmt, ap);
        !            49:        va_end(ap);
        !            50: }
        !            51: 
        !            52: void
        !            53: lprintf(char *fmt, ...)
        !            54: {
        !            55:        va_list ap;
        !            56: 
        !            57:        va_start(ap, fmt);
        !            58:        vlprintf(fmt, ap);
        !            59:        va_end(ap);
        !            60: }

unix.superglobalmegacorp.com

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