2 /*stuff from the unix specification*/
4 /*things from stdio.h */
5 extern void clearerr (FILE *stream) /*@modifies *stream@*/ ;
7 extern char * ctermid (/*@returned@*/ /*@out@*/ /*@null@*/ char *s)
9 // *@requires maxSet(s) >= ( L_ctermid - 1) @*/ *ensures maxRead(s) <= ( L_ctermid - 1) /\ maxRead(s) >= 0 */
11 /*DRL 9-11-001 I've modified the definition in ansi.h to remove modifies SystemState and I've added a requires and ensures*/ ;
15 /* cuserid is in the 1988 version of POSIX but removed in 1990 */
17 cuserid (/*@null@*/ /*@out@*/ char *s)
19 // *@requires maxSet(s) >= ( L_ctermid - 1) @*/ *@ensures maxRead(s) <= ( L_ctermid - 1) /\ maxRead(s) >= 0 /\ maxRead(result) <= ( L_ctermid - 1) /\ maxRead(result) >= 0 @*/
22 extern int fclose (FILE *stream) /*@modifies *stream, errno, fileSystem;@*/ ;
24 extern /*@null@*/ /*@dependent@*/ FILE *fdopen (int fd, const char *type)
25 /*@modifies errno, fileSystem@*/;
27 extern int feof (FILE *stream) /*@modifies errno@*/ ;
28 extern int ferror (FILE *stream) /*@modifies errno@*/ ;
29 extern int fflush (/*@null@*/ FILE *stream)
30 /*@modifies *stream, errno, fileSystem;@*/ ;
32 extern int fgetc (FILE *stream)
33 /*@modifies fileSystem, *stream, errno@*/ ;
35 extern int fgetpos (FILE *stream, /*@out@*/ fpos_t *pos)
36 /*@modifies *pos, errno@*/ /*@requires maxSet(pos) >= 0@*/
37 /*@ensures maxRead(pos) >= 0 @*/;
39 extern /*@null@*/ char *
40 fgets (/*@returned@*/ /*@out@*/ char *s, int n, FILE *stream)
41 /*@modifies fileSystem, *s, *stream, errno@*/
42 /*@requires MaxSet(s) >= (n -1); @*/
43 /*@ensures MaxRead(s) <= (n -1) /\ MaxRead(s) >= 0; @*/ ;
45 extern int fileno (FILE *fp) /*@modifies errno@*/;
47 extern void flockfile (FILE *file) /*@modifies *file, fileSystem@*/ ;
49 extern FILE * fopen (char *filename, char *mode) /*@modifies errno, fileSystem;@*/ ;
53 extern int fprintf (FILE *stream, char *format, ...)
54 /*@modifies fileSystem, *stream, errno@*/ ;
57 extern int /*@alt void@*/ fprintf (FILE *stream, char *format, ...)
58 /*@modifies fileSystem, *stream, errno@*/ ;
61 extern int fputc (int /*@alt char@*/ c, FILE *stream)
62 /*@modifies fileSystem, *stream, errno@*/ ;
64 extern int fputs (char *s, FILE *stream)
65 /*@modifies fileSystem, *stream, errno@*/ ;
67 fread (/*@out@*/ void *ptr, size_t size, size_t nobj, FILE *stream)
68 /*@modifies fileSystem, *ptr, *stream, errno@*/
69 /*requires maxSet(ptr) >= (size - 1) @*/ /*@ensures maxRead(ptr) == (size - 1) @*/
71 extern /*@null@*/ FILE *freopen (char *filename, char *mode, FILE *stream)
72 /*@modifies *stream, fileSystem, errno@*/ ;
75 extern int fscanf (FILE *stream, char *format, ...)
76 /*@modifies fileSystem, *stream, errno@*/ ;
77 extern int fseek (FILE *stream, long int offset, int whence)
78 /*@modifies fileSystem, *stream, errno@*/ ;
80 extern int fseeko (FILE *stream, off_t offset, int whence)
81 /*@modifies fileSystem, *stream, errno@*/ ;
83 extern int fsetpos (FILE *stream, fpos_t *pos)
84 /*@modifies fileSystem, *stream, errno@*/ ;
86 extern long int ftell(FILE *stream) /*@modifies errno@*/ ;
88 extern off_t ftello(FILE *stream) /*@modifies errno@*/ ;
90 extern void ftrylockfile (FILE *file) /*@modifies *file, fileSystem@*/ ;
92 extern void funlockfile (FILE *file) /*@modifies *file, fileSystem;@*/ ;
94 extern size_t fwrite (void *ptr, size_t size, size_t nobj, FILE *stream)
95 /*@modifies fileSystem, *stream, errno@*/
96 /*@requires maxRead(ptr) >= size @*/;
98 extern int getc (/*@sef@*/ FILE *stream)
99 /*@modifies fileSystem, *stream, errno@*/ ; /*drl added errno */
101 extern int getchar (void) /*@globals stdin@*/ /*@modifies fileSystem, *stdin, errno@*/ ; /*drl added errno */
103 extern int getc_unlocked (/*@sef@*/ FILE *stream)
104 /*@modifies fileSystem, *stream, errno@*/ ; /*Drl added 09-18-001 */
106 extern int getchar_unlocked (void) /*@globals stdin@*/ /*@modifies fileSystem, *stdin, errno@*/ ; /*Drl added 09-18-001 */
108 /*@unchecked@*/ extern char *optarg;
109 /*@unchecked@*/ extern int optind;
110 /*@unchecked@*/ extern int optopt;
111 /*@unchecked@*/ extern int opterr;
112 /*@unchecked@*/ extern int optreset;
114 extern int getopt (int argc, char * const *argv, const char *optstring)
115 /*@globals optarg, optind, optopt, opterr, optreset@*/
116 /*@modifies optarg, optind, optopt@*/
117 /*@requires maxRead(argv) >= (argc - 1) @*/
120 /*@-bufferoverflowhigh@*/
121 extern /*@null@*/ char *gets (/*@out@*/ char *s)
122 /*@warn bufferoverflowhigh
123 "Use of gets leads to a buffer overflow vulnerability. Use fgets instead"@*/
125 /*@modifies fileSystem, *s, *stdin, errno@*/ ;
127 extern int getw (FILE *stream)
128 /*@modifies fileSystem, *stream, errno@*/ ; /*drl added 09-18-001 */ /*legacy */
130 extern int pclose (FILE *stream) /*@modifies fileSystem, *stream, errno@*/ ;
132 extern void perror (/*@null@*/ char *s)
133 /*@globals errno, stderr@*/ /*@modifies fileSystem, *stderr@*/ ;
135 extern /*@dependent@*/ /*@null@*/ FILE *popen (char *command, char *ttype)
136 /*@modifies fileSystem, errno@*/ ;
140 extern int printf (char *format, ...)
142 /*@modifies fileSystem, *stdout@*/ ;
145 extern int /*@alt void@*/ printf (char *format, ...)
147 /*@modifies fileSystem, *stdout@*/ ;
150 extern int putc (int /*@alt char@*/ c, /*@sef@*/ FILE *stream)
151 /*@modifies fileSystem, *stream, errno;@*/
152 /*drl added errno 09-18-001 */ ;
154 extern int putchar (int /*@alt char@*/ c)
155 /*@globals stdout@*/ /*@modifies fileSystem, *stdout, errno@*/
156 /*drl added errno 09-18-001 */ ;
158 extern int putc_unlocked (int /*@alt char@*/ c, /*@sef@*/ FILE *stream)
159 /*@modifies fileSystem, *stream, errno;@*/
160 /*Drl added 09-19-001 */ ;
162 extern int putchar_unlocked (int /*@alt char@*/ c)
163 /*@globals stdout@*/ /*@modifies fileSystem, *stdout, errno@*/
164 /*Drl added 09-19-001 */ ;
166 extern int puts (const char *s)
167 /*@globals stdout@*/ /*@modifies fileSystem, *stdout, errno@*/
168 /*drl added errno 09-19-001 */ ;
171 extern int putw(int w, FILE *stream)
172 /*@modifies fileSystem, *stream, errno@*/
173 /*Drl added 09-19-001 */ /*legacy*/ ;
175 extern int remove (char *filename) /*@modifies fileSystem, errno@*/ ;
177 extern int rename (char *old, char *new) /*@modifies fileSystem, errno@*/
180 extern void rewind (FILE *stream) /*@modifies *stream, fileSystem, errno@*/
181 /*drl added errno AND fileSystem 09-19-001 */ ;
184 extern int scanf(char *format, ...)
186 /*@modifies fileSystem, *stdin, errno@*/
187 /*drl added errno 09-19-001 */ ;
189 extern void setbuf (FILE *stream, /*@null@*/ /*@exposed@*/ /*@out@*/ char *buf)
190 /*@modifies fileSystem, *stream, *buf@*/
191 // *@requires maxSet(buf) >= (BUFSIZ - 1) @*/
194 extern int setvbuf (FILE *stream, /*@null@*/ /*@exposed@*/ /*@out@*/ char *buf,
195 int mode, size_t size)
196 /*@modifies fileSystem, *stream, *buf@*/ /*@requires maxSet(buf) >= (size - 1) @*/ ;
200 extern int snprintf (/*@out@*/ char *s, size_t n, char *format, ...)
203 /*@requires maxSet(s) >= (n - 1) @*/
209 extern int /*@alt void@*/ snprintf (/*@out@*/ char *s, size_t n, char *format, ...)
211 /*@requires maxSet(s) >= (n - 1) @*/
218 extern int sprintf (/*@out@*/ char *s, char *format, ...)
223 extern int /*@alt void@*/ sprintf (/*@out@*/ char *s, char *format, ...)
229 int sscanf (/*@out@*/ char *s, char *format, ...)
230 /* modifies extra arguments */ /*@modifies errno@*/
231 /*drl added errno 09-19-001 */ ;
234 extern /*@null@*/ char *tempnam (char *dir, /*@null@*/ char *pfx)
235 /*@modifies internalState, errno@*/
236 /*@ensures maxSet(result) >= 0 /\ maxRead(result) >= 0 @*/
237 /*warn that "Between the time a pathname is created and the file is opened, it is possible
238 for some other process to create a file with the same name. Applications may find tmpfile()
241 /*drl added errno 09-19-001 */
246 extern /*@null@*/ FILE *tmpfile (void) /*@modifies fileSystem, errno@*/
247 /*drl added errno 09-19-001 */
250 extern /*@observer@*/ char *
251 tmpnam (/*@out@*/ /*@null@*/ /*@returned@*/ char *s)
252 /*@modifies *s, internalState @*/
253 // *@requires maxSet(s) >= (L_tmpnam - 1) @*
254 /*warn Between the time a pathname is created and the file is opened, it is possible for some other
255 process to create a file with the same name. Applications may find tmpfile() more useful. */
258 extern int ungetc (int /*@alt char@*/ c, FILE *stream)
259 /*@modifies fileSystem, *stream @*/
261 /*drl REMOVED errno 09-19-001*/
264 int vfprintf (FILE *stream, char *format, va_list arg)
265 /*@modifies fileSystem, *stream, arg, errno@*/ ;
267 int vprintf (const char *format, va_list arg)
269 /*@modifies fileSystem, *stdout@*/ ;
271 int vsnprintf (/*@out@*/ char *str, size_t size, const char *format, va_list ap)
273 /*@requires maxSet(str) >= (size - 1) @*/ ;
275 int vsprintf (/*@out@*/ char *str, const char *format, va_list ap)
276 /*@warn bufferoverflowhigh "Use vsnprintf instead"@*/
281 extern int optind; /*(LEGACY)*/