|
|
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 "osint.h"
9: #include "spitblks.h"
10:
11: #define MSGFILE "/usr/lib/vaxspitv35.err"
12: #define MSGCHUNK 49
13:
14: extern struct scblk tscblk;
15:
16: sysem()
17: {
18: long msg;
19: static int fd = -1;
20: register char *p;
21:
22: msg = WA(long);
23:
24: /* any premature return gives a null result */
25: SET_XR( &tscblk );
26: tscblk.len = 0;
27:
28: /* we keep a file descriptor open after the first message */
29: if (fd < 0) {
30: fd = open (MSGFILE, 0);
31: if (fd < 0)
32: return 0;
33: }
34:
35: /* calculate how far into the file to go and go there */
36: if (lseek (fd, (msg - 1) * MSGCHUNK, 0) < 0)
37: return 0;
38:
39: /* read the message, check for success */
40: if (read (fd, tscblk.str, MSGCHUNK - 1) != MSGCHUNK - 1)
41: return 0;
42:
43: /* cut trailing blanks */
44: p = tscblk.str + MSGCHUNK - 2;
45: while ( *p == ' ' && p > tscblk.str )
46: p--;
47:
48: /* insert message length and return */
49: tscblk.len = p - tscblk.str + 1;
50: return NORMAL_RETURN;
51: }
52:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.