]>
Commit | Line | Data |
---|---|---|
885824d3 | 1 | /* |
2 | ** posix.h | |
3 | ** | |
4 | ** This file should be processed with one of the standard libraries | |
5 | ** (standard.h or strict.h) to produce posix.lcd or posixstrict.lcd. | |
6 | */ | |
7 | ||
8 | /*@-nextlinemacros@*/ | |
9 | /*@+allimponly@*/ | |
10 | /*@+globsimpmodifiesnothing@*/ | |
11 | ||
12 | /* | |
13 | * LCLint ISO C + POSIX Library | |
14 | * | |
15 | * $Id$ | |
16 | */ | |
17 | ||
18 | /* | |
19 | * In 1988, IEEE Std 1003.1-1988, commonly known as "POSIX" or the | |
20 | * "IEEE Portable Operating System Interface for Computing Environments" | |
21 | * was published as an American National Standard. In 1990, IEEE Std | |
22 | * 1003.1-1990 was published as an International Standard. The two | |
23 | * standards differ slightly, and where they do, the 1990 International | |
24 | * standard was used for this lclint library. The differences are: | |
25 | * | |
26 | * 1988: cuserid() | |
27 | * 1990: -removed- (but still in this lclint library) | |
28 | * | |
29 | * 1988: int read (int, void*, unsigned int) | |
30 | * 1990: ssize_t read (int, void*, size_t) | |
31 | * | |
32 | * 1988: int write (int, const void*, unsigned int) | |
33 | * 1990: ssize_t write (int, const void*, size_t) | |
34 | * | |
35 | * The other differences are in the semantics of functions. | |
36 | */ | |
37 | ||
38 | /* | |
39 | * The reference for the ISO C part of this library was | |
40 | * Plauger, Brodie's "Standard C - A Reference", Prentice Hall. | |
41 | * The reference for the POSIX part of this library was | |
42 | * Donald Lewine's "POSIX Programmer's Guide", O'Reilly. | |
43 | * Transcription by Jens Schweikhardt <schweikhardt@rus.uni-stuttgart.de> | |
44 | */ | |
45 | ||
46 | /* | |
47 | * Note that Amendment 1 to ISO C was published in 1995 after POSIX was out. | |
48 | * Amendment 1 basically adds support for wide characters and iso 646 | |
49 | * source character sets. In particular, there are three new headers: | |
50 | * <iso646.h>, <wchar.h>, and <wctype.h> | |
51 | */ | |
52 | ||
53 | /* | |
54 | * Each header has annotations in this order: | |
55 | * | |
56 | * 1) type definitions (if any) | |
57 | * 2) constant definitions (if any) | |
58 | * 3) structure definitions (if any) | |
59 | * 4) function prototypes and externals (if any) | |
60 | * | |
61 | * 5) type definitions augmented by POSIX (if any) | |
62 | * 6) constant definitions augmented by POSIX (if any) | |
63 | * 7) structure definitions augmented by POSIX (if any) | |
64 | * 8) function prototypes and externals augmented by POSIX (if any) | |
65 | * | |
66 | * Builtins are mentioned in the header where they appear according to ISO. | |
67 | */ | |
68 | ||
69 | /* | |
70 | ** sys/types.h | |
71 | */ | |
72 | ||
73 | typedef /*@integraltype@*/ dev_t; | |
74 | typedef /*@integraltype@*/ gid_t; | |
8fe44445 | 75 | typedef /*@unsignedintegraltype@*/ ino_t; /*: is this definitely unsigned? */ |
885824d3 | 76 | typedef /*@integraltype@*/ mode_t; |
77 | typedef /*@integraltype@*/ nlink_t; | |
78 | typedef /*@integraltype@*/ off_t; | |
79 | typedef /*@integraltype@*/ pid_t; | |
80 | typedef /*@integraltype@*/ uid_t; | |
81 | ||
82 | /* | |
83 | ** dirent.h | |
84 | */ | |
85 | ||
86 | typedef /*@abstract@*/ /*@mutable@*/ void *DIR; | |
87 | ||
88 | struct dirent { | |
89 | char d_name[]; | |
90 | }; | |
91 | ||
8fe44445 | 92 | extern int closedir (DIR *dirp) |
93 | /*@modifies errno@*/; | |
885824d3 | 94 | |
8fe44445 | 95 | extern /*@null@*/ DIR *opendir (const char *dirname) |
96 | /*@modifies errno@*/; | |
885824d3 | 97 | |
8fe44445 | 98 | extern /*@null@*/ struct dirent *readdir (DIR *dirp) |
99 | /*@modifies errno@*/; | |
885824d3 | 100 | |
8fe44445 | 101 | extern void rewinddir (DIR *dirp) |
102 | /*@*/; | |
885824d3 | 103 | |
104 | /* | |
105 | ** errno.h | |
106 | */ | |
107 | ||
108 | /*@constant int E2BIG@*/ | |
109 | /*@constant int EACCES@*/ | |
110 | /*@constant int EAGAIN@*/ | |
111 | /*@constant int EBADF@*/ | |
112 | /*@constant int EBUSY@*/ | |
113 | /*@constant int ECHILD@*/ | |
114 | /*@constant int EDEADLK@*/ | |
115 | /*@constant int EEXIST@*/ | |
116 | /*@constant int EFAULT@*/ | |
117 | /*@constant int EFBIG@*/ | |
118 | /*@constant int EINTR@*/ | |
119 | /*@constant int EINVAL@*/ | |
120 | /*@constant int EIO@*/ | |
121 | /*@constant int EISDIR@*/ | |
122 | /*@constant int EMFILE@*/ | |
123 | /*@constant int EMLINK@*/ | |
124 | /*@constant int ENAMETOOLONG@*/ | |
125 | /*@constant int ENFILE@*/ | |
126 | /*@constant int ENODEV@*/ | |
127 | /*@constant int ENOENT@*/ | |
128 | /*@constant int ENOEXEC@*/ | |
129 | /*@constant int ENOLCK@*/ | |
130 | /*@constant int ENOMEM@*/ | |
131 | /*@constant int ENOSPC@*/ | |
132 | /*@constant int ENOSYS@*/ | |
133 | /*@constant int ENOTDIR@*/ | |
134 | /*@constant int ENOTEMPTY@*/ | |
135 | /*@constant int ENOTTY@*/ | |
136 | /*@constant int ENXIO@*/ | |
137 | /*@constant int EPERM@*/ | |
138 | /*@constant int EPIPE@*/ | |
139 | /*@constant int EROFS@*/ | |
140 | /*@constant int ESPIPE@*/ | |
141 | /*@constant int ESRCH@*/ | |
142 | /*@constant int EXDEV@*/ | |
143 | ||
144 | /* | |
145 | ** fcntl.h | |
146 | */ | |
147 | ||
148 | /*@constant int FD_CLOEXEC@*/ | |
149 | /*@constant int F_DUPFD@*/ | |
150 | /*@constant int F_GETFD@*/ | |
151 | /*@constant int F_GETFL@*/ | |
152 | /*@constant int F_GETLK@*/ | |
153 | /*@constant int F_RDLCK@*/ | |
154 | /*@constant int F_SETFD@*/ | |
155 | /*@constant int F_SETFL@*/ | |
156 | /*@constant int F_SETLK@*/ | |
157 | /*@constant int F_SETLKW@*/ | |
158 | /*@constant int F_UNLCK@*/ | |
159 | /*@constant int F_WRLCK@*/ | |
160 | /*@constant int O_ACCMODE@*/ | |
161 | /*@constant int O_APPEND@*/ | |
162 | /*@constant int O_CREAT@*/ | |
163 | /*@constant int O_EXCL@*/ | |
164 | /*@constant int O_NOCTTY@*/ | |
165 | /*@constant int O_NONBLOCK@*/ | |
166 | /*@constant int O_RDONLY@*/ | |
167 | /*@constant int O_RDWR@*/ | |
168 | /*@constant int O_TRUNC@*/ | |
169 | /*@constant int O_WRONLY@*/ | |
170 | /*@constant int SEEK_CUR@*/ | |
171 | /*@constant int SEEK_END@*/ | |
172 | /*@constant int SEEK_SET@*/ | |
173 | /*@constant int S_IRGRP@*/ | |
174 | /*@constant int S_IROTH@*/ | |
175 | /*@constant int S_IUSR@*/ | |
176 | /*@constant int S_IWXG@*/ | |
177 | /*@constant int S_IWXO@*/ | |
178 | /*@constant int S_IWXU@*/ | |
179 | /*@constant int S_ISGID@*/ | |
180 | /*@constant int S_ISUID@*/ | |
181 | /*@constant int S_IWGRP@*/ | |
182 | /*@constant int S_IWOTH@*/ | |
183 | /*@constant int S_IWUSR@*/ | |
184 | /*@constant int S_IXGRP@*/ | |
185 | /*@constant int S_IXOTH@*/ | |
186 | /*@constant int S_IXUSR@*/ | |
187 | ||
188 | struct flock { | |
189 | short l_type; | |
190 | short l_whence; | |
191 | off_t l_start; | |
192 | off_t l_len; | |
193 | pid_t l_pid; | |
194 | }; | |
195 | ||
1d239d69 | 196 | extern int creat (const char *path, mode_t mode) |
197 | /*@modifies errno@*/; | |
885824d3 | 198 | |
1d239d69 | 199 | extern int fcntl (int fd, int cmd, ...) |
200 | /*@modifies errno@*/; | |
885824d3 | 201 | |
1d239d69 | 202 | extern int open (const char *path, int oflag, ...) |
203 | /*:checkerror -1 - returns -1 on error */ | |
204 | /*@modifies errno@*/; | |
885824d3 | 205 | |
206 | /* | |
207 | ** grp.h | |
208 | */ | |
209 | ||
210 | struct group { | |
211 | char *gr_name; | |
212 | gid_t gr_gid; | |
213 | char **gr_mem; | |
214 | }; | |
215 | ||
216 | extern /*@null@*/ struct group * | |
217 | getgrgid (gid_t gid) | |
218 | /*@modifies errno@*/; | |
219 | ||
220 | extern /*@null@*/ struct group * | |
221 | getgrnam (const char *nm) | |
222 | /*@modifies errno@*/; | |
223 | ||
224 | /* | |
225 | ** limits.h | |
226 | */ | |
227 | ||
1d239d69 | 228 | /* These are always defined: */ |
229 | ||
230 | /*@constant int CHAR_BIT@*/ | |
231 | /*@constant char CHAR_MIN@*/ | |
232 | /*@constant char CHAR_MAX@*/ | |
233 | /*@constant int INT_MIN@*/ | |
234 | /*@constant int INT_MAX@*/ | |
235 | /*@constant long LONG_MIN@*/ | |
236 | /*@constant long LONG_MAX@*/ | |
237 | /*@constant int MB_LEN_MAX@*/ | |
238 | /*@constant signed char SCHAR_MIN@*/ | |
239 | /*@constant signed char SCHAR_MAX@*/ | |
240 | /*@constant short SHRT_MIN@*/ | |
241 | /*@constant short SHRT_MAX@*/ | |
242 | /*@constant unsigned char UCHAR_MAX@*/ | |
243 | /*@constant unsigned int UINT_MAX@*/ | |
244 | /*@constant unsigned long ULONG_MAX@*/ | |
245 | /*@constant unsigned short USHRT_MAX@*/ | |
246 | ||
247 | /* When _POSIX_SOURCE is defined */ | |
248 | ||
885824d3 | 249 | /*@constant long ARG_MAX@*/ |
250 | /*@constant long CHILD_MAX@*/ | |
251 | /*@constant long LINK_MAX@*/ | |
252 | /*@constant long MAX_CANON@*/ | |
53a89507 | 253 | /*@constant size_t MAX_INPUT@*/ /* evans 2001-10-15 changed type to size_t from long */ |
254 | /*@constant size_t NAME_MAX@*/ /* evans 2001-10-15 changed type to size_t from long */ | |
885824d3 | 255 | /*@constant long NGROUPS_MAX@*/ |
256 | /*@constant long OPEN_MAX@*/ | |
53a89507 | 257 | /*@constant size_t PATH_MAX@*/ /* evans 2001-10-15 changed type to size_t from long */ |
258 | /*@constant size_t PIPE_BUF@*/ /* evans 2001-10-15 changed type to size_t from long */ | |
885824d3 | 259 | /*@constant long SSIZE_MAX@*/ |
260 | /*@constant long STREAM_MAX@*/ | |
261 | /*@constant long TZNAME_MAX@*/ | |
262 | /*@constant long _POSIX_ARG_MAX@*/ | |
263 | /*@constant long _POSIX_CHILD_MAX@*/ | |
264 | /*@constant long _POSIX_LINK_MAX@*/ | |
265 | /*@constant long _POSIX_MAX_CANON@*/ | |
266 | /*@constant long _POSIX_MAX_INPUT@*/ | |
267 | /*@constant long _POSIX_NAME_MAX@*/ | |
268 | /*@constant long _POSIX_NGROUPS_MAX@*/ | |
269 | /*@constant long _POSIX_OPEN_MAX@*/ | |
270 | /*@constant long _POSIX_PATH_MAX@*/ | |
271 | /*@constant long _POSIX_PIPE_BUF@*/ | |
272 | /*@constant long _POSIX_SSIZE@*/ | |
273 | /*@constant long _POSIX_STREAM@*/ | |
274 | /*@constant long _POSIX_TZNAME_MAX@*/ | |
275 | ||
276 | /* | |
277 | ** pwd.h | |
278 | */ | |
279 | ||
280 | struct passwd { | |
281 | char *pw_name; | |
282 | uid_t pw_uid; | |
283 | gid_t pw_gid; | |
284 | char *pw_dir; | |
285 | char *pw_shell; | |
286 | } ; | |
287 | ||
288 | extern /*@observer@*/ /*@null@*/ struct passwd * | |
7bf96067 | 289 | getpwnam (const char *) |
290 | /*@modifies errno@*/ /*@ensures maxRead(result) == 0 /\ maxSet(result) == 0 @*/; | |
885824d3 | 291 | |
292 | extern /*@observer@*/ /*@null@*/ struct passwd * | |
293 | getpwuid (uid_t uid) | |
7bf96067 | 294 | /*@modifies errno@*/ /*@ensures maxRead(result) == 0 /\ maxSet(result) == 0 @*/; |
885824d3 | 295 | |
296 | /* | |
297 | ** setjmp.h | |
298 | */ | |
299 | ||
300 | typedef /*@abstract@*/ /*@mutable@*/ void *sigjmp_buf; | |
301 | ||
302 | extern /*@mayexit@*/ void | |
303 | siglongjmp (sigjmp_buf env, int val) | |
304 | /*@*/; | |
305 | ||
306 | extern int | |
307 | sigsetjmp (/*@out@*/ sigjmp_buf env, int savemask) | |
308 | /*@modifies env@*/; | |
309 | ||
310 | /* | |
311 | ** signal.h | |
312 | */ | |
313 | ||
314 | typedef /*@abstract@*/ sigset_t; | |
315 | ||
316 | /*@constant int SA_NOCLDSTOP@*/ | |
317 | /*@constant int SIG_BLOCK@*/ | |
318 | /*@constant int SIG_SETMASK@*/ | |
319 | /*@constant int SIG_UNBLOCK@*/ | |
320 | /*@constant int SIGALRM@*/ | |
321 | /*@constant int SIGCHLD@*/ | |
322 | /*@constant int SIGCONT@*/ | |
323 | /*@constant int SIGHUP@*/ | |
324 | /*@constant int SIGKILL@*/ | |
325 | /*@constant int SIGPIPE@*/ | |
326 | /*@constant int SIGQUIT@*/ | |
327 | /*@constant int SIGSTOP@*/ | |
328 | /*@constant int SIGTSTP@*/ | |
329 | /*@constant int SIGTTIN@*/ | |
330 | /*@constant int SIGTTOU@*/ | |
331 | /*@constant int SIGUSR1@*/ | |
332 | /*@constant int SIGUSR2@*/ | |
333 | ||
334 | struct sigaction { | |
335 | void (*sa_handler)(); | |
336 | sigset_t sa_mask; | |
337 | int sa_flags; | |
338 | } ; | |
339 | ||
340 | extern /*@mayexit@*/ int | |
341 | kill (pid_t pid, int sig) | |
342 | /*@modifies errno@*/; | |
343 | ||
344 | extern int | |
345 | sigaction (int sig, const struct sigaction *act, /*@out@*/ /*@null@*/ struct sigaction *oact) | |
ccf0a4a8 | 346 | /*@modifies *oact, errno, systemState@*/; |
885824d3 | 347 | |
348 | extern int | |
349 | sigaddset (sigset_t *set, int signo) | |
350 | /*@modifies *set, errno@*/; | |
351 | ||
352 | extern int | |
353 | sigdelset (sigset_t *set, int signo) | |
354 | /*@modifies *set, errno@*/; | |
355 | ||
356 | extern int | |
357 | sigemptyset (/*@out@*/ sigset_t *set) | |
358 | /*@modifies *set, errno@*/; | |
359 | ||
360 | extern int | |
361 | sigfillset (/*@out@*/ sigset_t *set) | |
362 | /*@modifies *set, errno@*/; | |
363 | ||
364 | extern int | |
365 | sigismember (const sigset_t *set, int signo) | |
366 | /*@modifies errno@*/; | |
367 | ||
368 | extern int | |
369 | sigpending (/*@out@*/ sigset_t *set) | |
370 | /*@modifies *set, errno@*/; | |
371 | ||
372 | extern int | |
373 | sigprocmask (int how, /*@null@*/ const sigset_t *set, /*@null@*/ /*@out@*/ sigset_t *oset) | |
ccf0a4a8 | 374 | /*@modifies *oset, errno, systemState@*/; |
885824d3 | 375 | |
376 | extern int | |
377 | sigsuspend (const sigset_t *sigmask) | |
ccf0a4a8 | 378 | /*@modifies errno, systemState@*/; |
885824d3 | 379 | |
380 | /* | |
381 | ** stdio.h | |
382 | */ | |
383 | ||
384 | /*@constant int L_ctermid@*/ | |
385 | /*@constant int L_cuserid@*/ | |
386 | /*@constant int STREAM_MAX@*/ | |
387 | ||
15b3d2b2 | 388 | extern /*@null@*/ /*@dependent@*/ FILE *fdopen (int fd, const char *type) |
389 | /*@modifies errno, fileSystem@*/; | |
885824d3 | 390 | |
15b3d2b2 | 391 | extern int fileno (FILE *fp) /*@modifies errno@*/; |
885824d3 | 392 | |
393 | /* | |
394 | ** sys/stat.h | |
395 | */ | |
396 | ||
397 | /*@constant int S_IRGRP@*/ | |
398 | /*@constant int S_IROTH@*/ | |
399 | /*@constant int S_IUSR@*/ | |
400 | /*@constant int S_IWXG@*/ | |
401 | /*@constant int S_IWXO@*/ | |
402 | /*@constant int S_IWXU@*/ | |
403 | /*@constant int S_ISGID@*/ | |
404 | /*@constant int S_ISUID@*/ | |
405 | /*@constant int S_IWGRP@*/ | |
406 | /*@constant int S_IWOTH@*/ | |
407 | /*@constant int S_IWUSR@*/ | |
408 | /*@constant int S_IXGRP@*/ | |
409 | /*@constant int S_IXOTH@*/ | |
410 | /*@constant int S_IXUSR@*/ | |
411 | ||
412 | struct stat { | |
1d239d69 | 413 | mode_t st_mode; |
885824d3 | 414 | ino_t st_ino; |
415 | dev_t st_dev; | |
1d239d69 | 416 | nlink_t st_nlink; |
885824d3 | 417 | uid_t st_uid; |
418 | gid_t st_gid; | |
419 | off_t st_size; | |
1d239d69 | 420 | time_t st_atime; /* evans 2001-08-23 - these were previously st_st_atime - POSIX spec says st_atime */ |
421 | time_t st_mtime; /* evans 2001-08-23 - these were previously st_st_mtime - POSIX spec says st_mtime */ | |
422 | time_t st_ctime; /* evans 2001-08-23 - these were previously st_st_ctime - POSIX spec says st_ctime */ | |
885824d3 | 423 | } ; |
424 | ||
425 | /* | |
426 | ** POSIX does not require that the S_I* be functions. They're | |
427 | ** macros virtually everywhere. | |
428 | */ | |
429 | ||
430 | # ifdef STRICT | |
431 | /*@notfunction@*/ | |
432 | # define SBOOLINT lltX_bool /*@alt int@*/ | |
433 | # else | |
434 | /*@notfunction@*/ | |
435 | # define SBOOLINT lltX_bool | |
436 | # endif | |
437 | ||
438 | extern SBOOLINT S_ISBLK (/*@sef@*/ mode_t m) /*@*/ ; | |
439 | ||
440 | extern SBOOLINT S_ISCHR (/*@sef@*/ mode_t m) /*@*/ ; | |
441 | ||
442 | extern SBOOLINT S_ISDIR (/*@sef@*/ mode_t m) /*@*/ ; | |
443 | ||
444 | extern SBOOLINT S_ISFIFO (/*@sef@*/ mode_t m) /*@*/ ; | |
445 | ||
446 | extern SBOOLINT S_ISREG (/*@sef@*/ mode_t m) /*@*/ ; | |
447 | ||
1d239d69 | 448 | int chmod (const char *path, mode_t mode) |
449 | /*@modifies fileSystem, errno@*/ ; | |
450 | ||
451 | int fstat (int fd, /*@out@*/ struct stat *buf) | |
885824d3 | 452 | /*@modifies errno, *buf@*/ ; |
453 | ||
1d239d69 | 454 | int mkdir (const char *path, mode_t mode) |
455 | /*@modifies fileSystem, errno@*/; | |
456 | ||
457 | int mkfifo (const char *path, mode_t mode) | |
458 | /*@modifies fileSystem, errno@*/; | |
885824d3 | 459 | |
1d239d69 | 460 | int stat (const char *path, /*@out@*/ struct stat *buf) |
461 | /*:errorcode -1*/ | |
462 | /*@modifies errno, *buf@*/; | |
885824d3 | 463 | |
1d239d69 | 464 | int umask (mode_t cmask) |
465 | /*@modifies systemState@*/; | |
885824d3 | 466 | |
467 | /* | |
468 | ** sys/times.h | |
469 | */ | |
470 | ||
471 | struct tms { | |
472 | clock_t tms_utime; | |
473 | clock_t tms_stime; | |
474 | clock_t tms_cutime; | |
475 | clock_t tms_cstime; | |
476 | }; | |
477 | ||
478 | extern clock_t | |
479 | times (/*@out@*/ struct tms *tp) | |
480 | /*@modifies *tp@*/; | |
481 | ||
482 | /* | |
483 | ** sys/utsname.h | |
484 | */ | |
485 | ||
486 | struct utsname { | |
487 | char sysname[]; | |
488 | char nodename[]; | |
489 | char release[]; | |
490 | char version[]; | |
491 | char machine[]; | |
492 | }; | |
493 | ||
494 | extern int | |
495 | uname (/*@out@*/ struct utsname *name) | |
496 | /*@modifies *name, errno@*/ ; | |
497 | ||
498 | /* | |
499 | ** sys/wait.h | |
500 | */ | |
501 | ||
502 | extern int WEXITSTATUS (int status) /*@*/ ; | |
503 | extern int WIFEXITED (int status) /*@*/ ; | |
504 | extern int WIFSIGNALED (int status) /*@*/ ; | |
505 | extern int WIFSTOPPED (int status) /*@*/ ; | |
506 | extern int WSTOPSIG (int status) /*@*/ ; | |
507 | extern int WTERMSIG (int status) /*@*/ ; | |
508 | ||
509 | /*@constant int WUNTRACED@*/ | |
510 | ||
ccf0a4a8 | 511 | pid_t wait (/*@out@*/ /*@null@*/ int *st) |
512 | /*@modifies *st, errno, systemState@*/; | |
885824d3 | 513 | |
ccf0a4a8 | 514 | pid_t waitpid (pid_t pid, /*@out@*/ /*@null@*/ int *st, int opt) |
515 | /*@modifies *st, errno, systemState@*/; | |
885824d3 | 516 | |
517 | /* | |
518 | ** termios.h | |
519 | */ | |
520 | ||
521 | typedef unsigned char /*@alt unsigned short@*/ cc_t; | |
522 | typedef unsigned long /*@alt long@*/ speed_t; | |
523 | typedef unsigned long /*@alt long@*/ tcflag_t; | |
524 | ||
525 | /*@constant int B0@*/ | |
526 | /*@constant int B50@*/ | |
527 | /*@constant int B75@*/ | |
528 | /*@constant int B110@*/ | |
529 | /*@constant int B134@*/ | |
530 | /*@constant int B150@*/ | |
531 | /*@constant int B200@*/ | |
532 | /*@constant int B300@*/ | |
533 | /*@constant int B600@*/ | |
534 | /*@constant int B1200@*/ | |
535 | /*@constant int B1800@*/ | |
536 | /*@constant int B2400@*/ | |
537 | /*@constant int B4800@*/ | |
538 | /*@constant int B9600@*/ | |
539 | /*@constant int B19200@*/ | |
540 | /*@constant int B38400@*/ | |
541 | /*@constant int BRKINT@*/ | |
542 | /*@constant int CLOCAL@*/ | |
543 | /*@constant int CREAD@*/ | |
544 | /*@constant int CS5@*/ | |
545 | /*@constant int CS6@*/ | |
546 | /*@constant int CS7@*/ | |
547 | /*@constant int CS8@*/ | |
548 | /*@constant int CSIZE@*/ | |
549 | /*@constant int CSTOPB@*/ | |
550 | /*@constant int ECHO@*/ | |
551 | /*@constant int ECHOE@*/ | |
552 | /*@constant int ECHOK@*/ | |
553 | /*@constant int ECHONL@*/ | |
554 | /*@constant int HUPCL@*/ | |
555 | /*@constant int ICANON@*/ | |
556 | /*@constant int ICRNL@*/ | |
557 | /*@constant int IEXTEN@*/ | |
558 | /*@constant int IGNBRK@*/ | |
559 | /*@constant int IGNCR@*/ | |
560 | /*@constant int IGNPAR@*/ | |
561 | /*@constant int IGNLCR@*/ | |
562 | /*@constant int INPCK@*/ | |
563 | /*@constant int ISIG@*/ | |
564 | /*@constant int ISTRIP@*/ | |
565 | /*@constant int IXOFF@*/ | |
566 | /*@constant int IXON@*/ | |
567 | /*@constant int NCCS@*/ | |
568 | /*@constant int NOFLSH@*/ | |
569 | /*@constant int OPOST@*/ | |
570 | /*@constant int PARENB@*/ | |
571 | /*@constant int PARMRK@*/ | |
572 | /*@constant int PARODD@*/ | |
573 | /*@constant int TCIFLUSH@*/ | |
574 | /*@constant int TCIOFF@*/ | |
575 | /*@constant int TCIOFLUSH@*/ | |
576 | /*@constant int TCION@*/ | |
577 | /*@constant int TCOFLUSH@*/ | |
578 | /*@constant int TCSADRAIN@*/ | |
579 | /*@constant int TCSAFLUSH@*/ | |
580 | /*@constant int TCSANOW@*/ | |
581 | /*@constant int TOSTOP@*/ | |
582 | /*@constant int VEOF@*/ | |
583 | /*@constant int VEOL@*/ | |
584 | /*@constant int VERASE@*/ | |
585 | /*@constant int VINTR@*/ | |
586 | /*@constant int VKILL@*/ | |
587 | /*@constant int VMIN@*/ | |
588 | /*@constant int VQUIT@*/ | |
589 | /*@constant int VSTART@*/ | |
590 | /*@constant int VSTOP@*/ | |
591 | /*@constant int VSUSP@*/ | |
592 | /*@constant int VTIME@*/ | |
593 | ||
594 | struct termios { | |
595 | tcflag_t c_iflag; | |
596 | tcflag_t c_oflag; | |
597 | tcflag_t c_cflag; | |
598 | tcflag_t c_lflag; | |
599 | cc_t c_cc; | |
600 | } ; | |
601 | ||
602 | extern speed_t | |
603 | cfgetispeed (const struct termios *p) | |
604 | /*@*/; | |
605 | ||
606 | extern speed_t | |
607 | cfgetospeed (const struct termios *p) | |
608 | /*@*/; | |
609 | ||
610 | extern int | |
611 | cfsetispeed (struct termios *p) | |
612 | /*@modifies *p@*/; | |
613 | ||
614 | extern int | |
615 | cfsetospeed (struct termios *p) | |
616 | /*@modifies *p@*/; | |
617 | ||
618 | extern int | |
619 | tcdrain (int fd) | |
620 | /*@modifies errno@*/; | |
621 | ||
622 | extern int | |
623 | tcflow (int fd, int action) | |
624 | /*@modifies errno@*/; | |
625 | ||
626 | extern int | |
627 | tcflush (int fd, int qs) | |
628 | /*@modifies errno@*/; | |
629 | ||
630 | extern int | |
631 | tcgetattr (int fd, /*@out@*/ struct termios *p) | |
632 | /*@modifies errno, *p@*/; | |
633 | ||
634 | extern int | |
635 | tcsendbreak (int fd, int d) | |
636 | /*@modifies errno@*/; | |
637 | ||
638 | extern int | |
639 | tcsetattr (int fd, int opt, const struct termios *p) | |
640 | /*@modifies errno@*/; | |
641 | ||
642 | /* | |
643 | ** time.h | |
644 | */ | |
645 | ||
646 | /* Environ must be known before it can be used in `globals' clauses. */ | |
647 | ||
648 | /*@unchecked@*/ extern char **environ; | |
649 | ||
650 | /*@constant int CLK_TCK@*/ | |
651 | ||
652 | extern void | |
653 | tzset (void) | |
ccf0a4a8 | 654 | /*@globals environ@*/ /*@modifies systemState@*/; |
885824d3 | 655 | |
656 | /* | |
657 | ** unistd.h | |
658 | */ | |
659 | ||
660 | /*@constant int F_OK@*/ | |
661 | /*@constant int R_OK@*/ | |
662 | /*@constant int SEEK_CUR@*/ | |
663 | /*@constant int SEEK_END@*/ | |
664 | /*@constant int SEEK_SET@*/ | |
665 | /*@constant int STDERR_FILENO@*/ | |
666 | /*@constant int STDIN_FILENO@*/ | |
667 | /*@constant int STDOUT_FILENO@*/ | |
668 | /*@constant int W_OK@*/ | |
669 | /*@constant int X_OK@*/ | |
670 | /*@constant int _PC_CHOWN_RESTRUCTED@*/ | |
671 | /*@constant int _PC_MAX_CANON@*/ | |
672 | /*@constant int _PC_MAX_INPUT@*/ | |
673 | /*@constant int _PC_NAME_MAX@*/ | |
674 | /*@constant int _PC_NO_TRUNC@*/ | |
675 | /*@constant int _PC_PATH_MAX@*/ | |
676 | /*@constant int _PC_PIPE_BUF@*/ | |
677 | /*@constant int _PC_VDISABLE@*/ | |
678 | /*@constant int _POSIX_CHOWN_RESTRICTED@*/ | |
679 | /*@constant int _POSIX_JOB_CONTROL@*/ | |
680 | /*@constant int _POSIX_NO_TRUNC@*/ | |
681 | /*@constant int _POSIX_SAVED_IDS@*/ | |
682 | /*@constant int _POSIX_VDISABLE@*/ | |
683 | /*@constant int _POSIX_VERSION@*/ | |
684 | /*@constant int _SC_ARG_MAX@*/ | |
685 | /*@constant int _SC_CHILD_MAX@*/ | |
686 | /*@constant int _SC_CLK_TCK@*/ | |
687 | /*@constant int _SC_JOB_CONTROL@*/ | |
688 | /*@constant int _SC_NGROUPS_MAX@*/ | |
689 | /*@constant int _SC_OPEN_MAX@*/ | |
690 | /*@constant int _SC_SAVED_IDS@*/ | |
691 | /*@constant int _SC_STREAM_MAX@*/ | |
692 | /*@constant int _SC_TZNAME_MAX@*/ | |
693 | /*@constant int _SC_VERSION@*/ | |
694 | ||
53a89507 | 695 | extern /*@exits@*/ void _exit (int status) /*@*/; |
885824d3 | 696 | |
53a89507 | 697 | extern int access (const char *path, int mode) /*@modifies errno@*/; |
885824d3 | 698 | |
53a89507 | 699 | extern unsigned int alarm (unsigned int) /*@modifies systemState@*/; |
885824d3 | 700 | |
53a89507 | 701 | extern int chdir (const char *path) /*@modifies errno@*/; |
885824d3 | 702 | |
53a89507 | 703 | extern int chown (const char *path, uid_t owner, gid_t group) |
704 | /*@modifies fileSystem, errno@*/; | |
885824d3 | 705 | |
706 | extern int | |
707 | close (int fd) | |
ccf0a4a8 | 708 | /*@modifies fileSystem, errno, systemState@*/; |
885824d3 | 709 | /* state: record locks are unlocked */ |
710 | ||
711 | extern char * | |
712 | ctermid (/*@returned@*/ /*@out@*/ /*@null@*/ char *s) | |
ccf0a4a8 | 713 | /*@modifies *s, systemState@*/; |
885824d3 | 714 | |
715 | /* cuserid is in the 1988 version of POSIX but removed in 1990 */ | |
716 | extern char * | |
717 | cuserid (/*@null@*/ /*@out@*/ char *s) | |
718 | /*@modifies *s@*/; | |
719 | ||
720 | extern int | |
721 | dup2 (int fd, int fd2) | |
722 | /*@modifies errno, fileSystem@*/; | |
723 | ||
724 | extern int | |
725 | dup (int fd) | |
726 | /*@modifies errno, fileSystem@*/; | |
727 | ||
728 | extern /*@mayexit@*/ int | |
729 | execl (const char *path, const char *arg, ...) | |
730 | /*@modifies errno@*/; | |
731 | ||
732 | extern /*@mayexit@*/ int | |
733 | execle (const char *file, const char *arg, ...) | |
734 | /*@modifies errno@*/; | |
735 | ||
736 | extern /*@mayexit@*/ int | |
737 | execlp (const char *file, const char *arg, ...) | |
738 | /*@modifies errno@*/; | |
739 | ||
740 | extern /*@mayexit@*/ int | |
741 | execv (const char *path, char *const argv[]) | |
742 | /*@modifies errno@*/; | |
743 | ||
744 | extern /*@mayexit@*/ int | |
745 | execve (const char *path, char *const argv[], char *const *envp) | |
746 | /*@modifies errno@*/; | |
747 | ||
748 | extern /*@mayexit@*/ int | |
749 | execvp (const char *file, char *const argv[]) | |
750 | /*@modifies errno@*/; | |
751 | ||
752 | extern pid_t | |
753 | fork (void) | |
754 | /*@modifies fileSystem, errno@*/; | |
755 | ||
756 | extern long | |
757 | fpathconf (int fd, int name) | |
758 | /*@modifies errno@*/; | |
759 | ||
53a89507 | 760 | extern /*@null@*/ char *getcwd (/*@returned@*/ /*@out@*/ /*@notnull@*/ char *buf, size_t size) |
e5f31c00 | 761 | /*@requires maxSet(buf) >= (size - 1)@*/ |
135ea728 | 762 | /*@ensures maxRead(buf) <= (size - 1)@*/ |
e5f31c00 | 763 | |
764 | /*@modifies errno, *buf@*/ ; | |
885824d3 | 765 | |
766 | extern gid_t | |
767 | getegid (void) | |
768 | /*@*/; | |
769 | ||
770 | extern uid_t | |
771 | geteuid (void) | |
772 | /*@*/; | |
773 | ||
774 | extern gid_t | |
775 | getgid (void) | |
776 | /*@*/; | |
777 | ||
778 | extern int | |
779 | getgroups (int gs, /*@out@*/ gid_t gl[]) | |
780 | /*@modifies errno, gl[]@*/; | |
781 | ||
782 | extern /*@observer@*/ char * | |
783 | getlogin (void) | |
784 | /*@*/; | |
785 | ||
786 | extern pid_t | |
787 | getpgrp (void) | |
788 | /*@*/; | |
789 | ||
790 | extern pid_t | |
791 | getpid (void) | |
792 | /*@*/; | |
793 | ||
794 | extern pid_t | |
795 | getppid (void) | |
796 | /*@*/; | |
797 | ||
798 | extern uid_t | |
799 | getuid (void) | |
800 | /*@*/; | |
801 | ||
802 | extern int | |
803 | isatty (int fd) | |
804 | /*@*/; | |
805 | ||
806 | extern int | |
807 | link (const char *o, const char *n) | |
808 | /*@modifies errno, fileSystem@*/; | |
809 | ||
810 | extern off_t | |
811 | lseek (int fd, off_t offset, int whence) | |
812 | /*@modifies errno@*/; | |
813 | ||
814 | extern long | |
815 | pathconf (const char *path, int name) | |
816 | /*@modifies errno@*/; | |
817 | ||
818 | extern int | |
819 | pause (void) | |
820 | /*@modifies errno@*/; | |
821 | ||
822 | extern int | |
823 | pipe (/*@out@*/ int fd[]) /* Out parameter noticed by Marc Espie. */ | |
824 | /*@modifies errno@*/; | |
825 | ||
15b3d2b2 | 826 | extern ssize_t read (int fd, /*@out@*/ void *buf, size_t nbyte) |
827 | /*@modifies errno, *buf@*/ /*@requires maxSet(buf) >= (nbyte - 1) @*/ | |
828 | /*@ensures maxRead(buf) >= nbyte @*/ ; | |
885824d3 | 829 | |
15b3d2b2 | 830 | extern int rmdir (const char *path) |
831 | /*@modifies fileSystem, errno@*/; | |
885824d3 | 832 | |
15b3d2b2 | 833 | extern int setgid (gid_t gid) |
834 | /*@modifies errno, systemState@*/; | |
885824d3 | 835 | |
15b3d2b2 | 836 | extern int setpgid (pid_t pid, pid_t pgid) |
837 | /*@modifies errno, systemState@*/; | |
885824d3 | 838 | |
15b3d2b2 | 839 | extern pid_t setsid (void) /*@modifies systemState@*/; |
840 | ||
841 | extern int setuid (uid_t uid) | |
842 | /*@modifies errno, systemState@*/; | |
885824d3 | 843 | |
ccf0a4a8 | 844 | unsigned int sleep (unsigned int sec) /*@modifies systemState@*/ ; |
885824d3 | 845 | |
15b3d2b2 | 846 | extern long sysconf (int name) |
847 | /*@modifies errno@*/; | |
885824d3 | 848 | |
15b3d2b2 | 849 | extern pid_t tcgetpgrp (int fd) |
850 | /*@modifies errno@*/; | |
885824d3 | 851 | |
15b3d2b2 | 852 | extern int tcsetpgrp (int fd, pid_t pgrpid) |
853 | /*@modifies errno, systemState@*/; | |
885824d3 | 854 | |
15b3d2b2 | 855 | /* Q: observer ok? */ |
856 | extern /*@null@*/ /*@observer@*/ char *ttyname (int fd) | |
857 | /*@modifies errno@*/; | |
885824d3 | 858 | |
15b3d2b2 | 859 | extern int unlink (const char *path) |
860 | /*@modifies fileSystem, errno@*/; | |
885824d3 | 861 | |
15b3d2b2 | 862 | extern ssize_t write (int fd, const void *buf, size_t nbyte) |
863 | /*@modifies errno@*/; | |
885824d3 | 864 | |
865 | /* | |
866 | ** utime.h | |
867 | */ | |
868 | ||
869 | struct utimbuf { | |
870 | time_t actime; | |
871 | time_t modtime; | |
872 | } ; | |
873 | ||
874 | extern int | |
875 | utime (const char *path, /*@null@*/ const struct utimbuf *times) | |
876 | /*@modifies fileSystem, errno@*/; | |
877 | ||
b072092f | 878 | /* |
879 | ** regex.h | |
880 | */ | |
881 | ||
882 | typedef /*@abstract@*/ /*@mutable@*/ void *regex_t; | |
883 | typedef /*@integraltype@*/ regoff_t; | |
884 | ||
885 | typedef struct | |
886 | { | |
887 | regoff_t rm_so; | |
888 | regoff_t rm_eo; | |
889 | } regmatch_t; | |
890 | ||
891 | int regcomp (/*@out@*/ regex_t *preg, /*@nullterminated@*/ const char *regex, int cflags) | |
892 | /*:statusreturn@*/ | |
893 | /*@modifies preg@*/ ; | |
894 | ||
895 | int regexec (const regex_t *preg, /*@nullterminated@*/ const char *string, size_t nmatch, /*@out@*/ regmatch_t pmatch[], int eflags) | |
896 | /*@requires maxSet(pmatch) >= nmatch@*/ | |
897 | /*@modifies pmatch@*/ ; | |
898 | ||
899 | size_t regerror (int errcode, const regex_t *preg, /*@out@*/ char *errbuf, size_t errbuf_size) | |
900 | /*@requires maxSet(errbuf) >= errbuf_size@*/ | |
901 | /*@modifies errbuf@*/ ; | |
902 | ||
903 | void regfree (/*@only@*/ regex_t *preg) ; | |
904 | ||
905 | /* regcomp flags */ | |
906 | /*@constant int REG_BASIC@*/ | |
907 | /*@constant int REG_EXTENDED@*/ | |
908 | /*@constant int REG_ICASE@*/ | |
909 | /*@constant int REG_NOSUB@*/ | |
910 | /*@constant int REG_NEWLINE@*/ | |
911 | /*@constant int REG_NOSPEC@*/ | |
912 | /*@constant int REG_PEND@*/ | |
913 | /*@constant int REG_DUMP@*/ | |
914 | ||
915 | /* regerror flags */ | |
916 | /*@constant int REG_NOMATCH@*/ | |
917 | /*@constant int REG_BADPAT@*/ | |
918 | /*@constant int REG_ECOLLATE@*/ | |
919 | /*@constant int REG_ECTYPE@*/ | |
920 | /*@constant int REG_EESCAPE@*/ | |
921 | /*@constant int REG_ESUBREG@*/ | |
922 | /*@constant int REG_EBRACK@*/ | |
923 | /*@constant int REG_EPAREN@*/ | |
924 | /*@constant int REG_EBRACE@*/ | |
925 | /*@constant int REG_BADBR@*/ | |
926 | /*@constant int REG_ERANGE@*/ | |
927 | /*@constant int REG_ESPACE@*/ | |
928 | /*@constant int REG_BADRPT@*/ | |
929 | /*@constant int REG_EMPTY@*/ | |
930 | /*@constant int REG_ASSERT@*/ | |
931 | /*@constant int REG_INVARG@*/ | |
932 | /*@constant int REG_ATOI@*/ /* non standard */ | |
933 | /*@constant int REG_ITOA@*/ /* non standard */ | |
934 | ||
935 | /* regexec flags */ | |
936 | /*@constant int REG_NOTBOL@*/ | |
937 | /*@constant int REG_NOTEOL@*/ | |
938 | /*@constant int REG_STARTEND@*/ | |
939 | /*@constant int REG_TRACE@*/ | |
940 | /*@constant int REG_LARGE@*/ | |
941 | /*@constant int REG_BACKR@*/ | |
942 | ||
ccf0a4a8 | 943 |