Annotation of researchv10no/cmd/spitbol/ocint/sysem.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  *     sysem
                      3:  *
                      4:  *     wa: error code number on input
                      5:  *     xr: pointer to scblk with message text on output
                      6:  */
                      7: 
                      8: #include "inter.h"
                      9: #define MSGFILE "/usr/lib/vaxspitv35.err"
                     10: #define MSGCHUNK 49
                     11: 
                     12: sysem()
                     13: {
                     14:        long msg;
                     15:        static int fd = -1;
                     16:        register char *p;
                     17: 
                     18:        msg = WA(long);
                     19: 
                     20:        /* any premature return gives a null result */
                     21:        SET_XR(&tempstr);
                     22:        tempstr.len = 0;
                     23: 
                     24:        /* we keep a file descriptor open after the first message */
                     25:        if (fd < 0) {
                     26:                fd = open (MSGFILE, 0);
                     27:                if (fd < 0)
                     28:                        return 0;
                     29:        }
                     30: 
                     31:        /* calculate how far into the file to go and go there */
                     32:        if (lseek (fd, (msg - 1) * MSGCHUNK, 0) < 0)
                     33:                return 0;
                     34: 
                     35:        /* read the message, check for success */
                     36:        if (read (fd, tempstr.s, MSGCHUNK - 1) != MSGCHUNK - 1)
                     37:                return 0;
                     38: 
                     39:        /* cut trailing blanks */
                     40:        p = tempstr.s + MSGCHUNK - 2;
                     41:        while (*p == ' ' && p > tempstr.s)
                     42:                p--;
                     43: 
                     44:        /* insert message length and return */
                     45:        tempstr.len = p - tempstr.s + 1;
                     46:        return 0;
                     47: }

unix.superglobalmegacorp.com

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