|
|
1.1 root 1: #include <stdio.h>
2: #include <sysexits.h>
3:
4: /* string extraction/restoration routines */
5:
6: /* Modify the pathname below to suit system requirements */
7:
8: char *StringFile = "/usr/local/lib/kermit5.sr";
9:
10: static int strfile = -1, ourpid = 0;
11:
12: #define BUFLEN 256
13:
14: errprep(offset, buf)
15: unsigned short offset;
16: char *buf;
17: {
18: register int pid = getpid();
19:
20: if (pid != ourpid) {
21: ourpid = pid;
22: if (strfile >= 0) {
23: close(strfile);
24: strfile = -1;
25: }
26: }
27: if (strfile < 0) {
28: char *p, *getenv();
29: if (p = getenv("KSTR")) StringFile = p;
30: strfile = open(StringFile, 0);
31: if (strfile < 0) {
32: oops:
33: fprintf(stderr, "Cannot find %s\r\n", StringFile);
34: exit(EX_OSFILE);
35: }
36: }
37: if (lseek(strfile, (long) offset, 0) < 0
38: || read(strfile, buf, BUFLEN) <= 0)
39: goto oops;
40: }
41:
42: /* extracted string front end for printf() */
43: /*VARARGS1*/
44: strprerror(fmt, a, b, c, d, e)
45: int fmt;
46: {
47: char buf[BUFLEN];
48:
49: errprep(fmt, buf);
50: printf(buf, a, b, c, d, e);
51: }
52:
53: /* extracted string front end for sprintf() */
54: /*VARARGS1*/
55: strsrerror(fmt, obuf, a, b, c, d, e)
56: int fmt;
57: char *obuf;
58: {
59: char buf[BUFLEN];
60:
61: errprep(fmt, buf);
62: sprintf(obuf, buf, a, b, c, d, e);
63: }
64:
65: /* extracted string front end for fprintf() */
66: /*VARARGS1*/
67: strfrerror(fmt, fd, a, b, c, d, e)
68: int fmt, fd;
69: {
70: char buf[BUFLEN];
71:
72: errprep(fmt, buf);
73: fprintf(fd, buf, a, b, c, d, e);
74: }
75:
76: /* extracted string front end for perror() */
77: strperror(fmt)
78: int fmt;
79: {
80: char buf[BUFLEN];
81:
82: errprep(fmt, buf);
83: perror(buf);
84: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.