|
|
1.1 root 1: #include "stdio.h"
2: #include "h00vars.h"
3: #include "h01errs.h"
4: #include "h02opcs.h"
5:
6: /*
7: * allocate a block of storage on the heap
8: */
9: char *palloc(need)
10:
11: long need;
12:
13: {
14: extern char *malloc();
15: register char *memblk, *ptr;
16:
17: memblk = malloc(need);
18: if (memblk == 0)
19: error(EOUTOFMEM);
20: if (memblk == (char *)(-1))
21: error(ETRASHHEAP);
22: for(ptr=memblk; ptr<memblk+need; ptr++)
23: *ptr = 0;
24: return(memblk);
25: }
26:
27:
28:
29: /*
30: * Free a block of storage on the stack
31: */
32: pfree(ptr)
33:
34: char *ptr;
35:
36: {
37: extern long free();
38:
39: if (ptr == 0)
40: error(ENILPTR);
41: else if (free(ptr) == -1)
42: error(ETRASHHEAP);
43: }
44:
45: /*
46: * Constant set constructor (yechh!)
47: */
48:
49: #define sets int short
50:
51: sets *pcttot(uprbp, lwrb, n, av)
52:
53: int uprbp, lwrb, n;
54: sets av;
55:
56: {
57: register int l, h;
58: register sets *set, *ap;
59:
60: ap = &av;
61: set = &ap[2 * n];
62: while(--n >= 0) {
63: if ((l = *ap++ - lwrb) < 0 || l > uprbp ||
64: (h = *ap++ - lwrb) < 0 || h > uprbp)
65: error(ECTTOT);
66: while (l <= h) {
67: set[l >> 4] = set[l >> 4] | 1 << (l & 017);
68: l++;
69: }
70: }
71: return(set);
72: }
73:
74: char pd_date[] = {
75: 8, 9, 10, 4, 5, 6, 10, 22, 23, 10, 0
76: };
77:
78: char *ctime();
79:
80: pdattim(op, alfap)
81: register char *alfap;
82: {
83: register char *ap, *cp, *dp;
84: long a;
85: int i;
86:
87: time(&a);
88: cp = ctime(&a);
89: ap = alfap;
90: if (op == O_DATE)
91: for (dp = pd_date; *dp; *ap++ = cp[*dp++]);
92: else
93: for (cp = cp + 10, i = 10; i; *ap++ = *cp++, i--);
94: }
95:
96: psexit(code)
97:
98: long code;
99: {
100:
101: pmflush();
102: if (mode == PIX && nodump == 0) {
103: fputs("Execution terminated",stderr);
104: if (code)
105: fputs(" abnormally",stderr);
106: fputc('.',stderr);
107: fputc('\n',stderr);
108: }
109: stats();
110: exit(code);
111: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.