00001 /* 00002 Common header file 00003 AUP2, Sec. 1.06 00004 00005 Copyright 2003 by Marc J. Rochkind. All rights reserved. 00006 May be copied only for purposes and under conditions described 00007 on the Web page www.basepath.com/aup/copyright.htm. 00008 00009 The Example Files are provided "as is," without any warranty; 00010 without even the implied warranty of merchantability or fitness 00011 for a particular purpose. The author and his publisher are not 00012 responsible for any damages, direct or incidental, resulting 00013 from the use or non-use of these Example Files. 00014 00015 The Example Files may contain defects, and some contain deliberate 00016 coding mistakes that were included for educational reasons. 00017 You are responsible for determining if and how the Example Files 00018 are to be used. 00019 00020 */ 00021 #ifndef _DEFS_H_ 00022 #define _DEFS_H_ 00023 00024 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 #ifdef _POSIX_SOURCE /* tmp */ 00029 #error 00030 #endif 00031 00032 /* 00033 FREEBSD and DARWIN (Mac OS X) have many similarities, and some differences. Use BSD_DERIVED 00034 to treat them the same, and the separate symbols (FREEBSD or DARWIN) to treat them 00035 differently. 00036 */ 00037 #if defined(FREEBSD) || defined(DARWIN) 00038 #define BSD_DERIVED 00039 #endif 00040 00041 #ifndef __EXTENSIONS__ 00042 #define UNDEF__EXTENSIONS__ 00043 #endif 00044 00045 /*[defs1]*/ 00046 #if !defined(BSD_DERIVED) /* _POSIX_SOURCE too restrictive */ 00047 #define SUV_SUS2 00048 #include "suvreq.h" 00049 #endif 00050 00051 #ifdef __GNUC__ 00052 #undef _GNU_SOURCE 00053 #define _GNU_SOURCE /* bring GNU as close to C99 as possible */ 00054 #endif 00055 00056 #include <sys/types.h> 00057 #include <unistd.h> 00058 00059 #if !defined(__cplusplus) && !defined(SKIP_BOOL) 00060 #include <stdbool.h> /* C99 only */ 00061 #endif 00062 /*[]*/ 00063 #include <signal.h> 00064 00065 #if defined(SOLARIS) || defined(HPUX) 00066 #ifndef __EXTENSIONS__ 00067 #define __EXTENSIONS__ /* sys/stat.h won't compile without this */ 00068 #endif 00069 #endif 00070 #include <sys/stat.h> 00071 #if defined(SOLARIS) || defined(HPUX) 00072 #ifdef UNDEF__EXTENSIONS__ 00073 #undef __EXTENSIONS__ 00074 #endif 00075 #endif 00076 00077 /*[defs2]*/ 00078 #include <time.h> 00079 #include <limits.h> 00080 #if defined(SOLARIS) 00081 #define _VA_LIST /* can't define it in stdio.h */ 00082 #endif 00083 #include <stdio.h> 00084 #if defined(SOLARIS) 00085 #undef _VA_LIST 00086 #endif 00087 #include <stdarg.h> /* this is the place to define _VA_LIST */ 00088 #include <stdlib.h> 00089 #include <stddef.h> 00090 #include <string.h> 00091 #include <strings.h> 00092 #include <ctype.h> 00093 #include <errno.h> 00094 #include <fcntl.h> 00095 #include <assert.h> 00096 #ifndef AUP2_SKIP_WAIT 00097 #include <sys/wait.h> 00098 #endif 00099 #include "ec.h" 00100 /*[]*/ 00101 #include "logf.h" 00102 #include "options.h" 00103 #include "macrostr.h" 00104 #include "extio.h" 00105 00106 /* 00107 File-permission-bit symbols 00108 */ 00109 /*[defs-perm]*/ 00110 #define PERM_DIRECTORY S_IRWXU 00111 #define PERM_FILE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) 00112 /*[]*/ 00113 00114 bool setblock(int fd, bool on); /* also in c4/setblock.h */ 00115 #define syserrmsg(buf, buf_max, msg, s_errno)\ 00116 syserrmsgtype(buf, buf_max, msg, s_errno, EC_ERRNO) 00117 char *syserrmsgtype(char *buf, size_t buf_max, const char *msg, 00118 int s_errno, EC_ERRTYPE type); 00119 char *syserrmsgline(char *buf, size_t buf_max, 00120 int s_errno, EC_ERRTYPE type); 00121 const char *getdate_strerror(int e); 00122 const char *errsymbol(int errno_arg); 00123 void syserr(const char *msg); 00124 void syserr_print(const char *msg); 00125 void timestart(void); 00126 void timestop(char *msg); 00127 00128 unsigned long getblksize(const char *path); /* c2/getvlksize.c */ 00129 00130 #ifdef __cplusplus 00131 } /* extern "C" */ 00132 #endif 00133 00134 #endif /* _DEFS_H_ */ 00135