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