]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | ** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2001. | |
3 | ** See ../LICENSE for license information. | |
4 | ** | |
5 | */ | |
6 | /* | |
7 | ** fileTable.h | |
8 | */ | |
9 | ||
10 | # ifndef FILETABLE_H | |
11 | # define FILETABLE_H | |
12 | ||
13 | /*@constant int FTBASESIZE; @*/ | |
14 | # define FTBASESIZE 64 | |
15 | ||
16 | /* moved to fileloc.h | |
17 | ** typedef int fileId; | |
18 | */ | |
19 | ||
20 | typedef enum { FILE_NORMAL, FILE_LSLTEMP, FILE_NODELETE, | |
21 | FILE_HEADER, FILE_XH, FILE_MACROS, FILE_METASTATE } fileType; | |
22 | ||
23 | /*@private@*/ typedef struct | |
24 | { | |
25 | bool ftemp BOOLBITS; | |
26 | bool fsystem BOOLBITS; | |
27 | bool fspecial BOOLBITS; | |
28 | cstring fname; | |
29 | cstring basename; | |
30 | fileType ftype; | |
31 | fileId fder; | |
32 | } *ftentry; | |
33 | ||
34 | typedef /*@only@*/ ftentry o_ftentry; | |
35 | ||
36 | typedef /*@only@*/ struct { | |
37 | /*@null@*/ /*@dependent@*/ /*@exposed@*/ FILE *f; | |
38 | /*@only@*/ cstring fname; | |
39 | } *foentry; | |
40 | ||
41 | abst_typedef /*@null@*/ struct | |
42 | { | |
43 | int nentries; | |
44 | int nspace; | |
45 | cstringTable htable; | |
46 | /*@reldef@*/ /*@only@*/ o_ftentry *elements; | |
47 | ||
48 | /* | |
49 | ** Keep track of all the open files, so we can close them on error exits. | |
50 | */ | |
51 | ||
52 | int nopen; | |
53 | int nopenspace; | |
54 | /*@reldef@*/ /*@only@*/ foentry *openelements; | |
55 | } *fileTable ; | |
56 | ||
57 | /*@constant null fileTable fileTable_undefined; @*/ | |
58 | # define fileTable_undefined ((fileTable) NULL) | |
59 | ||
60 | extern /*@unused@*/ /*@nullwhentrue@*/ bool | |
61 | fileTable_isUndefined (/*@null@*/ fileTable p_f) /*@*/ ; | |
62 | extern /*@unused@*/ /*@falsewhennull@*/ bool | |
63 | fileTable_isDefined (/*@null@*/ fileTable p_f) /*@*/ ; | |
64 | ||
65 | # define fileTable_isUndefined(ft) ((ft) == fileTable_undefined) | |
66 | # define fileTable_isDefined(ft) ((ft) != fileTable_undefined) | |
67 | extern /*@observer@*/ cstring fileTable_getName (fileTable p_ft, fileId p_fid) /*@*/ ; | |
68 | extern /*@observer@*/ cstring fileTable_getNameBase (fileTable p_ft, fileId p_fid) ; | |
69 | extern fileId fileTable_addFile (fileTable p_ft, cstring p_name) | |
70 | /*@modifies p_ft@*/ ; | |
71 | ||
72 | extern void fileTable_addStreamFile (fileTable p_ft, /*@dependent@*/ FILE *p_fstream, | |
73 | cstring p_name) | |
74 | /*@modifies p_ft@*/ ; | |
75 | ||
76 | extern fileId fileTable_addHeaderFile (fileTable p_ft, cstring p_name) | |
77 | /*@modifies p_ft@*/ ; | |
78 | extern fileId fileTable_addXHFile (fileTable p_ft, cstring p_name) | |
79 | /*@modifies p_ft@*/ ; | |
80 | extern fileId fileTable_addLibraryFile (fileTable p_ft, cstring p_name) | |
81 | /*@modifies p_ft@*/ ; | |
82 | ||
83 | # ifndef NOLCL | |
84 | extern fileId fileTable_addLCLFile (fileTable p_ft, cstring p_name) | |
85 | /*@modifies p_ft@*/ ; | |
86 | ||
87 | extern fileId fileTable_addltemp (fileTable p_ft); | |
88 | ||
89 | # endif | |
90 | ||
91 | extern /*@notnull@*/ /*@only@*/ fileTable fileTable_create (void) /*@*/ ; | |
92 | extern fileId fileTable_lookup (fileTable p_ft, cstring p_s) /*@*/ ; | |
93 | extern fileId fileTable_addCTempFile (fileTable p_ft, fileId p_fid) | |
94 | /*@modifies p_ft@*/ ; | |
95 | extern fileId fileTable_addFileOnly (fileTable p_ft, /*@only@*/ cstring p_name) | |
96 | /*@modifies p_ft@*/ ; | |
97 | ||
98 | # ifndef NOLCL | |
99 | extern fileId fileTable_addImportFile (fileTable p_ft, cstring p_name) | |
100 | /*@modifies p_ft@*/ ; | |
101 | # endif | |
102 | ||
103 | extern fileId fileTable_addMacrosFile (fileTable p_ft) | |
104 | /*@modifies p_ft@*/ ; | |
105 | ||
106 | extern fileId fileTable_addMetastateFile (fileTable p_ft, cstring p_name) | |
107 | /*@modifies p_ft@*/ ; | |
108 | ||
109 | extern void fileTable_setFilePath (fileTable p_ft, fileId p_fid, cstring p_path) | |
110 | /*@modifies p_ft@*/ ; | |
111 | ||
112 | extern /*@observer@*/ cstring fileTable_getRootName (fileTable p_ft, fileId p_fid) /*@*/ ; | |
113 | extern bool fileTable_isHeader (fileTable p_ft, fileId p_fid) /*@*/ ; | |
114 | extern bool fileId_isHeader (fileId p_f) /*@*/ ; | |
115 | # define fileId_isHeader(f) (fileTable_isHeader (context_fileTable(), f)) | |
116 | ||
117 | extern bool fileTable_sameBase (fileTable p_ft, fileId p_f1, fileId p_f2); | |
118 | extern void fileTable_cleanup (fileTable p_ft) /*@modifies fileSystem@*/; | |
119 | extern fileId fileTable_lookupBase (fileTable p_ft, cstring p_base) /*@modifies p_ft@*/ ; | |
120 | extern void fileTable_printTemps (fileTable p_ft) /*@modifies g_warningstream@*/ ; | |
121 | extern /*@unused@*/ /*@only@*/ cstring fileTable_unparse (fileTable p_ft) /*@*/ ; | |
122 | extern bool fileTable_exists (fileTable p_ft, cstring p_s) /*@*/ ; | |
123 | extern void fileTable_free (/*@only@*/ fileTable p_f); | |
124 | extern bool fileTable_isSpecialFile (fileTable p_ft, fileId p_fid) /*@*/ ; | |
125 | extern bool fileTable_isSystemFile (fileTable p_ft, fileId p_fid) /*@*/ ; | |
126 | extern bool fileTable_isXHFile (fileTable p_ft, fileId p_fid) /*@*/ ; | |
127 | ||
128 | extern /*@observer@*/ cstring fileTable_fileName (fileId p_fid) /*@*/ ; | |
129 | extern /*@observer@*/ cstring fileTable_fileNameBase (fileId p_fid) /*@*/ ; | |
130 | extern /*@observer@*/ cstring fileTable_rootFileName (fileId p_fid) /*@*/ ; | |
131 | ||
132 | extern /*@null@*/ /*@open@*/ /*@dependent@*/ FILE *fileTable_createFile (fileTable p_ft, cstring p_fname) | |
133 | /*@modifies p_ft, fileSystem@*/ ; | |
134 | ||
135 | extern /*@null@*/ /*@open@*/ /*@dependent@*/ FILE *fileTable_createMacrosFile (fileTable p_ft, cstring p_fname) | |
136 | /*@modifies p_ft, fileSystem@*/ ; | |
137 | ||
138 | # define fileTable_fileName(fid) (fileTable_getName(context_fileTable(), fid)) | |
139 | # define fileTable_fileNameBase(fid) (fileTable_getNameBase(context_fileTable(), fid)) | |
140 | # define fileTable_rootFileName(fid) (fileTable_getRootName(context_fileTable(), fid)) | |
141 | ||
142 | extern void fileTable_noDelete (fileTable, cstring); | |
143 | extern bool fileId_baseEqual (/*@sef@*/ fileId p_t1, /*@sef@*/ fileId p_t2) /*@*/ ; | |
144 | # define fileId_baseEqual(t1,t2) \ | |
145 | (fileId_equal (t1, t2) || fileTable_sameBase (context_fileTable (), t1, t2)) | |
146 | ||
147 | extern /*@null@*/ /*@open@*/ /*@dependent@*/ FILE * | |
148 | fileTable_openReadFile (fileTable p_ft, cstring p_fname) | |
149 | /*@modifies p_ft@*/ ; | |
150 | ||
151 | extern /*@null@*/ /*@open@*/ /*@dependent@*/ FILE * | |
152 | fileTable_openWriteFile (fileTable p_ft, cstring p_fname) | |
153 | /*@modifies p_ft@*/ ; | |
154 | ||
155 | extern /*@null@*/ /*@open@*/ /*@dependent@*/ FILE * | |
156 | fileTable_openWriteUpdateFile (fileTable p_ft, cstring p_fname) | |
157 | /*@modifies p_ft@*/ ; | |
158 | ||
159 | extern bool fileTable_closeFile (fileTable p_ft, FILE *p_f) | |
160 | /*@ensures closed p_f@*/ | |
161 | /*@modifies p_ft, p_f@*/ ; | |
162 | ||
163 | extern void fileTable_closeAll (fileTable p_ft) | |
164 | /*@modifies p_ft@*/ ; | |
165 | ||
166 | # else | |
167 | # error "Multiple include" | |
168 | #endif | |
169 |