Annotation of researchv10no/cmd/uucp/utility.c, revision 1.1.1.1

1.1       root        1: /*     /sccs/src/cmd/uucp/s.utility.c
                      2:        utility.c       1.1     8/30/84 17:37:47
                      3: */
                      4: #include "uucp.h"
                      5: VERSION(@(#)utility.c  1.1);
                      6: 
                      7: static void logError();
                      8: 
                      9: #define TY_ASSERT      1
                     10: #define TY_ERROR       2
                     11: 
                     12: /*
                     13:  *     produce an assert error message
                     14:  * input:
                     15:  *     s1 - string 1
                     16:  *     s2 - string 2
                     17:  *     i1 - integer 1 (usually errno)
                     18:  *     sid - sccsid string of calling module
                     19:  *     file - __FILE of calling module
                     20:  *     line - __LINE__ of calling module
                     21:  */
                     22: void
                     23: assert(s1, s2, i1, sid, file, line)
                     24: char *s1, *s2, *file, *sid;
                     25: {
                     26:        logError(s1, s2, i1, TY_ASSERT, sid, file, line);
                     27: }
                     28: 
                     29: 
                     30: /*
                     31:  *     produce an assert error message
                     32:  * input: -- same as assert
                     33:  */
                     34: void
                     35: errent(s1, s2, i1, sid, file, line)
                     36: char *s1, *s2, *sid, *file;
                     37: {
                     38:        logError(s1, s2, i1, TY_ERROR, sid, file, line);
                     39: }
                     40: 
                     41: #define EFORMAT        "%sERROR (%.9s)  pid: %d (%s) %s %s (%d) [SCCSID: %s, FILE: %s, LINE: %d]\n"
                     42: 
                     43: static
                     44: void
                     45: logError(s1, s2, i1, type, sid, file, line)
                     46: char *s1, *s2, *sid, *file;
                     47: {
                     48:        register FILE *errlog;
                     49:        char text[BUFSIZ];
                     50:        int pid;
                     51: 
                     52:        if (Debug)
                     53:                errlog = stderr;
                     54:        else {
                     55:                errlog = fopen(ERRLOG, "a");
                     56:        }
                     57:        if (errlog == NULL)
                     58:                return;
                     59:        (void) chmod(ERRLOG, 0666);
                     60: 
                     61:        pid = getpid();
                     62: 
                     63:        (void) fprintf(errlog, EFORMAT, type == TY_ASSERT ? "ASSERT " : " ",
                     64:            Progname, pid, timeStamp(), s1, s2, i1, sid, file, line);
                     65: 
                     66:        (void) fclose(errlog);
                     67:        (void) sprintf(text, " %sERROR %.100s %.100s (%.9s)",
                     68:            type == TY_ASSERT ? "ASSERT " : " ",
                     69:            s1, s2, Progname);
                     70:        if (type == TY_ASSERT)
                     71:            systat(Rmtname, SS_ASSERT_ERROR, text, Retrytime);
                     72:        return;
                     73: }
                     74: 
                     75: 
                     76: /* timeStamp - create standard time string
                     77:  * return
                     78:  *     pointer to time string
                     79:  */
                     80: 
                     81: char *
                     82: timeStamp()
                     83: {
                     84:        register struct tm *tp;
                     85:        time_t clock;
                     86:        static char str[20];
                     87: 
                     88:        (void) time(&clock);
                     89:        tp = localtime(&clock);
                     90:        (void) sprintf(str, "%d/%d-%d:%2.2d:%2.2d", tp->tm_mon + 1,
                     91:            tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec);
                     92:        return(str);
                     93: }

unix.superglobalmegacorp.com

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