Various minor fixes for compiler/linter (other then splint itself) warnings.
[splint-patched.git] / src / Headers / fileTable.h
blob73433cf4ae37d44d7a021984bbc7a5726ed5a5b3
1 /*
2 ** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2003.
3 ** See ../LICENSE for license information.
4 **
5 */
6 /*
7 ** fileTable.h
8 */
10 # ifndef FILETABLE_H
11 # define FILETABLE_H
13 /*@constant int FTBASESIZE; @*/
14 # define FTBASESIZE 64
16 /* moved to fileloc.h
17 ** typedef int fileId;
20 typedef enum { FILE_NORMAL, FILE_HEADER, FILE_RC, FILE_XH, FILE_METASTATE,
21 FILE_LCL, FILE_LCD, FILE_IMPORT,
22 FILE_PP, FILE_MACROS, FILE_LSLTEMP, FILE_NODELETE } fileType;
24 /*:private:*/ typedef struct
26 bool ftemp BOOLBITS;
27 bool fsystem BOOLBITS;
28 bool fspecial BOOLBITS;
29 /*@only@*/ cstring fname;
30 /*@only@*/ cstring basename;
31 fileType ftype;
32 fileId fder;
33 } *ftentry;
35 typedef /*@only@*/ ftentry o_ftentry;
37 typedef /*@only@*/ struct {
38 /*@null@*/ /*@dependent@*/ /*@exposed@*/ FILE *f;
39 /*@only@*/ cstring fname;
40 } *foentry;
42 abst_typedef /*@null@*/ struct
44 int nentries;
45 int nspace;
46 cstringTable htable;
47 /*@reldef@*/ /*@only@*/ o_ftentry *elements;
50 ** Keep track of all the open files, so we can close them on error exits.
53 int nopen;
54 int nopenspace;
55 /*@reldef@*/ /*@only@*/ foentry *openelements; /* evans 2002-07-12: removed reldef */
56 } *fileTable ;
58 /*@constant null fileTable fileTable_undefined; @*/
59 # define fileTable_undefined ((fileTable) NULL)
61 extern /*@unused@*/ /*@nullwhentrue@*/ bool
62 fileTable_isUndefined (/*@null@*/ fileTable p_f) /*@*/ ;
63 extern /*@unused@*/ /*@falsewhennull@*/ bool
64 fileTable_isDefined (/*@null@*/ fileTable p_f) /*@*/ ;
66 # define fileTable_isUndefined(ft) ((ft) == fileTable_undefined)
67 # define fileTable_isDefined(ft) ((ft) != fileTable_undefined)
69 extern /*@notnull@*/ /*@only@*/ fileTable fileTable_create (void) /*@*/ ;
70 extern fileId fileTable_lookup (fileTable p_ft, cstring p_s) /*@*/ ;
71 extern /*@observer@*/ cstring fileTable_getName (fileTable p_ft, fileId p_fid) /*@*/ ;
72 extern /*@observer@*/ cstring fileTable_getNameBase (fileTable p_ft, fileId p_fid) ;
74 extern fileId fileTable_addFile (fileTable p_ft, fileType p_typ, cstring p_name)
75 /*@modifies p_ft@*/ ;
76 extern fileId fileTable_addTempFile (fileTable p_ft, fileType p_ftype, fileId p_fid)
77 /*@modifies p_ft@*/ ;
79 extern void fileTable_addStreamFile (fileTable p_ft, /*@dependent@*/ FILE *p_fstream,
80 cstring p_name)
81 /*@modifies p_ft@*/ ;
83 extern /*@observer@*/ cstring fileTable_getRootName (fileTable p_ft, fileId p_fid) /*@*/ ;
84 extern bool fileTable_isHeader (fileTable p_ft, fileId p_fid) /*@*/ ;
85 extern bool fileId_isHeader (fileId p_f) /*@*/ ;
86 # define fileId_isHeader(f) (fileTable_isHeader (context_fileTable(), f))
88 extern bool fileTable_sameBase (fileTable p_ft, fileId p_f1, fileId p_f2);
89 extern void fileTable_cleanup (fileTable p_ft) /*@modifies fileSystem@*/;
90 extern fileId fileTable_lookupBase (fileTable p_ft, cstring p_base) /*@modifies p_ft@*/ ;
91 extern void fileTable_printTemps (fileTable p_ft) /*@modifies g_warningstream@*/ ;
92 extern bool fileTable_exists (fileTable p_ft, cstring p_s) /*@*/ ;
93 extern void fileTable_free (/*@only@*/ fileTable p_f);
94 extern bool fileTable_isSpecialFile (fileTable p_ft, fileId p_fid) /*@*/ ;
95 extern bool fileTable_isSystemFile (fileTable p_ft, fileId p_fid) /*@*/ ;
96 extern bool fileTable_isXHFile (fileTable p_ft, fileId p_fid) /*@*/ ;
98 extern /*@observer@*/ cstring fileTable_fileName (fileId p_fid) /*@*/ ;
99 extern /*@observer@*/ cstring fileTable_fileNameBase (fileId p_fid) /*@*/ ;
100 extern /*@observer@*/ cstring fileTable_rootFileName (fileId p_fid) /*@*/ ;
102 extern /*@null@*/ /*@open@*/ /*@dependent@*/ FILE *fileTable_createTempFile (fileTable p_ft, cstring p_fname, bool p_read)
103 /*@modifies p_ft, fileSystem@*/ ;
105 # define fileTable_fileName(fid) (fileTable_getName(context_fileTable(), fid))
106 # define fileTable_fileNameBase(fid) (fileTable_getNameBase(context_fileTable(), fid))
107 # define fileTable_rootFileName(fid) (fileTable_getRootName(context_fileTable(), fid))
109 extern void fileTable_noDelete (fileTable, cstring);
110 extern bool fileId_baseEqual (/*@sef@*/ fileId p_t1, /*@sef@*/ fileId p_t2) /*@*/ ;
111 # define fileId_baseEqual(t1,t2) \
112 (fileId_equal (t1, t2) || fileTable_sameBase (context_fileTable (), t1, t2))
114 extern /*@null@*/ /*@open@*/ /*@dependent@*/ FILE *
115 fileTable_openReadFile (fileTable p_ft, cstring p_fname)
116 /*@modifies p_ft@*/ ;
118 extern /*@null@*/ /*@open@*/ /*@dependent@*/ FILE *
119 fileTable_openWriteFile (fileTable p_ft, cstring p_fname)
120 /*@modifies p_ft@*/ ;
122 extern /*@null@*/ /*@open@*/ /*@dependent@*/ FILE *
123 fileTable_openWriteUpdateFile (fileTable p_ft, cstring p_fname)
124 /*@modifies p_ft@*/ ;
126 extern bool fileTable_closeFile (fileTable p_ft, FILE *p_f)
127 /*@ensures closed p_f@*/
128 /*@modifies p_ft, p_f@*/ ;
130 extern void fileTable_closeAll (fileTable p_ft)
131 /*@modifies p_ft@*/ ;
133 # else
134 # error "Multiple include"
135 #endif