1: # include <useful.h>
2: # include <opsys.h>
3: # include <sccs.h>
4:
5: SCCSID(@(#)markopen.c 8.2 1/6/85)
6:
7: /*
8: ** MARKOPEN -- mark all open files
9: **
10: ** Marked files will not be closed later.
11: **
12: ** Parameters:
13: ** ovect -- pointer to bitmap of open files.
14: **
15: ** Returns:
16: ** none
17: **
18: ** Side Effects:
19: ** Sets *ovect to represent the open files.
20: */
21:
22: long CmOfiles; /* default set of files, used all over */
23:
24: markopen(ovect)
25: register long *ovect;
26: {
27: register int i;
28: register int j;
29: extern int errno;
30: struct stat sbuf;
31:
32: if (ovect == NULL)
33: ovect = &CmOfiles;
34:
35: *ovect = 0;
36: for (i = 0; i < NOFILE; i++)
37: {
38: if (fstat(i, &sbuf) >= 0)
39: *ovect |= 1 << i;
40: }
41: errno = 0;
42: }
43: /*
44: ** CLOSEALL -- close all open files (except marked files)
45: **
46: ** Parameters:
47: ** tell -- if set, report files that are open and should
48: ** not have been.
49: ** ovect -- vector of files to leave open.
50: **
51: ** Returns:
52: ** none
53: **
54: ** Side Effects:
55: ** none
56: **
57: ** Trace Flags:
58: ** none
59: */
60:
61: closeall(tell, ovect)
62: register int tell;
63: register long ovect;
64: {
65: register int i;
66:
67: ovect |= CmOfiles;
68:
69: for (i = 0; i < NOFILE; i++)
70: {
71: if (!bitset(1 << i, ovect))
72: if (close(i) >= 0 && tell)
73: lprintf("File %d open\n", i);
74: }
75: }
76:
77: /*
78: ** ADDMARKOPEN -- mark individial file descriptors as open
79: **
80: ** Marked descriptors will not be closed
81: **
82: ** Parameters:
83: ** long pvect pointer to file descriptor vector
84: ** int fd descriptor to mark
85: **
86: ** Returns:
87: ** nothing
88: **
89: ** Side effects:
90: ** none
91: */
92:
93: addmarkopen(pvect, fd)
94: register long *pvect;
95: int fd;
96: {
97: *pvect |= 1 << fd;
98: }
Defined functions
Defined variables