rpm  4.9.1.3
system.h
Go to the documentation of this file.
00001 
00005 #ifndef H_SYSTEM
00006 #define H_SYSTEM
00007 
00008 #ifdef HAVE_CONFIG_H
00009 #include "config.h"
00010 #endif
00011 
00012 #ifdef HAVE_SYS_PARAM_H
00013 #include <sys/param.h>
00014 #endif
00015 
00016 /* <unistd.h> should be included before any preprocessor test
00017    of _POSIX_VERSION.  */
00018 #ifdef HAVE_UNISTD_H
00019 #include <unistd.h>
00020 #if !defined(__GLIBC__)
00021 #ifdef __APPLE__
00022 #include <crt_externs.h>
00023 #define environ (*_NSGetEnviron())
00024 #else
00025 extern char ** environ;
00026 #endif /* __APPLE__ */
00027 #endif
00028 #endif
00029 
00030 #if !defined(HAVE_STPCPY)
00031 char * stpcpy(char * dest, const char * src);
00032 #endif
00033 
00034 #if !defined(HAVE_STPNCPY)
00035 char * stpncpy(char * dest, const char * src, size_t n);
00036 #endif
00037 
00038 #if HAVE___SECURE_GETENV
00039 #define getenv(_s)      __secure_getenv(_s)
00040 #endif
00041 
00042 #ifdef HAVE_FCNTL_H
00043 #include <fcntl.h>
00044 #else
00045 #include <sys/file.h>
00046 #endif
00047 
00048 #ifdef HAVE_DIRENT_H
00049 # include <dirent.h>
00050 # define NLENGTH(direct) (strlen((direct)->d_name))
00051 #else /* not HAVE_DIRENT_H */
00052 # define dirent direct
00053 # define NLENGTH(direct) ((direct)->d_namlen)
00054 # ifdef HAVE_SYS_NDIR_H
00055 #  include <sys/ndir.h>
00056 # endif /* HAVE_SYS_NDIR_H */
00057 # ifdef HAVE_SYS_DIR_H
00058 #  include <sys/dir.h>
00059 # endif /* HAVE_SYS_DIR_H */
00060 # ifdef HAVE_NDIR_H
00061 #  include <ndir.h>
00062 # endif /* HAVE_NDIR_H */
00063 #endif /* HAVE_DIRENT_H */
00064 
00065 #if HAVE_LIMITS_H
00066 #include <limits.h>
00067 #endif
00068 
00069 #ifndef PATH_MAX
00070 #ifdef _POSIX_PATH_MAX
00071 #define PATH_MAX _POSIX_PATH_MAX
00072 #elif defined MAXPATHLEN
00073 #define PATH_MAX MAXPATHLEN
00074 #else
00075 #define PATH_MAX 256
00076 #endif
00077 #endif
00078 
00079 #if WITH_SELINUX
00080 #include <selinux/selinux.h>
00081 #include <selinux/label.h>
00082 #else
00083 typedef char * security_context_t;
00084 
00085 #define freecon(_c)
00086 
00087 #define setfilecon(_fn, _c)     (-1)
00088 #define lsetfilecon(_fn, _c)    (-1)
00089 
00090 #define is_selinux_enabled()    (0)
00091 
00092 #define matchpathcon_init(_fn)                  (-1)
00093 #define matchpathcon_fini()                     (0)
00094 #define matchpathcon(_fn, _fm, _c)              (-1)
00095 
00096 #define selabel_lookup_raw(_hnd, _scon, _key,_type)     (-1)
00097 
00098 #define selinux_file_context_path() (0)
00099 
00100 #define rpm_execcon(_v, _fn, _av, _envp)        (0)
00101 #endif
00102 
00103 #include "rpmio/rpmutil.h"
00104 /* compatibility macros to avoid a mass-renaming all over the codebase */
00105 #define xmalloc(_size) rmalloc((_size))
00106 #define xcalloc(_nmemb, _size) rcalloc((_nmemb), (_size))
00107 #define xrealloc(_ptr, _size) rrealloc((_ptr), (_size))
00108 #define xstrdup(_str) rstrdup((_str))
00109 #define _free(_ptr) rfree((_ptr))
00110 
00111 /* Retrofit glibc __progname */
00112 #if defined __GLIBC__ && __GLIBC__ >= 2
00113 #if __GLIBC_MINOR__ >= 1
00114 #define __progname      __assert_program_name
00115 #endif
00116 #define setprogname(pn)
00117 #else
00118 #define __progname      program_name
00119 #define setprogname(pn) \
00120   { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
00121     else __progname = pn;               \
00122   }
00123 #endif
00124 extern const char *__progname;
00125 
00126 /* Take care of NLS matters.  */
00127 #if ENABLE_NLS
00128 # include <locale.h>
00129 # include <libintl.h>
00130 # define _(Text) dgettext (PACKAGE, Text)
00131 #else
00132 # define _(Text) Text
00133 #endif
00134 
00135 #define N_(Text) Text
00136 
00137 /* ============== from misc/miscfn.h */
00138 
00139 #if !defined(USE_GNU_GLOB) 
00140 #if HAVE_FNMATCH_H
00141 #include <fnmatch.h>
00142 #endif
00143 
00144 #if HAVE_GLOB_H 
00145 #include <glob.h>
00146 #endif
00147 #else
00148 #include "misc/glob.h"
00149 #include "misc/fnmatch.h"
00150 #endif
00151 
00152 #include <dlfcn.h>
00153 
00154 #endif  /* H_SYSTEM */