Nothing Fancy File Manager
 All Classes
tlpi_hdr.h
1 /**********************************************************************\
2 * Copyright (C) Michael Kerrisk, 2010. *
3 * *
4 * This program is free software. You may use, modify, and redistribute *
5 * it under the terms of the GNU Affero General Public License as *
6 * published by the Free Software Foundation, either version 3 or (at *
7 * your option) any later version. This program is distributed without *
8 * any warranty. See the file COPYING for details. *
9 \**********************************************************************/
10 
11 /* tlpi_hdr.h
12 
13  Standard header file used by nearly all of our example programs.
14 */
15 #ifndef TLPI_HDR_H
16 #define TLPI_HDR_H /* Prevent accidental double inclusion */
17 
18 #include <sys/types.h> /* Type definitions used by many programs */
19 #include <stdio.h> /* Standard I/O functions */
20 #include <stdlib.h> /* Prototypes of commonly used library functions,
21  plus EXIT_SUCCESS and EXIT_FAILURE constants */
22 #include <unistd.h> /* Prototypes for many system calls */
23 #include <errno.h> /* Declares errno and defines error constants */
24 #include <string.h> /* Commonly used string-handling functions */
25 
26 #include "get_num.h" /* Declares our functions for handling numeric
27  arguments (getInt(), getLong()) */
28 
29 #include "error_functions.h" /* Declares our error-handling functions */
30 
31 /* Unfortunately some UNIX implementations define FALSE and TRUE -
32  here we'll undefine them */
33 
34 #ifdef TRUE
35 #undef TRUE
36 #endif
37 
38 #ifdef FALSE
39 #undef FALSE
40 #endif
41 
42 typedef enum { FALSE, TRUE } Boolean;
43 
44 #define min(m,n) ((m) < (n) ? (m) : (n))
45 #define max(m,n) ((m) > (n) ? (m) : (n))
46 
47 /* Some systems don't define 'socklen_t' */
48 
49 #if defined(__sgi)
50 typedef int socklen_t;
51 #endif
52 
53 /* The remainder of this file creates various definitions to help
54  the example programs run on UNIX implementations other than Linux. */
55 
56 #include "alt_functions.h" /* Declares simple replacements for some
57  functions that are absent on other systems */
58 
59 #if defined(__sun)
60 #include <sys/file.h> /* Has definition of FASYNC */
61 #endif
62 
63 #if ! defined(O_ASYNC) && defined(FASYNC)
64 /* Some systems define FASYNC instead of O_ASYNC */
65 #define O_ASYNC FASYNC
66 #endif
67 
68 #if defined(MAP_ANON) && ! defined(MAP_ANONYMOUS)
69 /* BSD derivatives usually have MAP_ANON, not MAP_ANONYMOUS */
70 #define MAP_ANONYMOUS MAP_ANON
71 
72 #endif
73 
74 #if ! defined(O_SYNC) && defined(O_FSYNC)
75 /* Some implementations have O_FSYNC instead of O_SYNC */
76 #define O_SYNC O_FSYNC
77 #endif
78 
79 #if defined(__FreeBSD__)
80 
81 /* FreeBSD uses these alternate names for fields in the sigval structure */
82 
83 #define sival_int sigval_int
84 #define sival_ptr sigval_ptr
85 #endif
86 
87 #endif