Remove <string.h> include from system.h into the few places that still need
[platform/upstream/rpm.git] / system.h
1 /**
2  * \file system.h
3  */
4
5 #ifndef H_SYSTEM
6 #define H_SYSTEM
7
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11
12 #include <sys/types.h>
13
14 #include <sys/stat.h>
15 #include <stdio.h>
16
17 #ifdef HAVE_SYS_PARAM_H
18 #include <sys/param.h>
19 #endif
20
21 /* <unistd.h> should be included before any preprocessor test
22    of _POSIX_VERSION.  */
23 #ifdef HAVE_UNISTD_H
24 #include <unistd.h>
25 #if !defined(__GLIBC__)
26 #ifdef __APPLE__
27 #include <crt_externs.h>
28 #define environ (*_NSGetEnviron())
29 #else
30 extern char ** environ;
31 #endif /* __APPLE__ */
32 #endif
33 #endif
34
35 #if !defined(HAVE_STPCPY)
36 char * stpcpy(char * dest, const char * src);
37 #endif
38
39 #if !defined(HAVE_STPNCPY)
40 char * stpncpy(char * dest, const char * src, size_t n);
41 #endif
42
43 #include <errno.h>
44 #ifndef errno
45 extern int errno;
46 #endif
47
48 #if HAVE___SECURE_GETENV
49 #define getenv(_s)      __secure_getenv(_s)
50 #endif
51
52 #ifdef HAVE_FCNTL_H
53 #include <fcntl.h>
54 #else
55 #include <sys/file.h>
56 #endif
57
58 #ifdef HAVE_DIRENT_H
59 # include <dirent.h>
60 # define NLENGTH(direct) (strlen((direct)->d_name))
61 #else /* not HAVE_DIRENT_H */
62 # define dirent direct
63 # define NLENGTH(direct) ((direct)->d_namlen)
64 # ifdef HAVE_SYS_NDIR_H
65 #  include <sys/ndir.h>
66 # endif /* HAVE_SYS_NDIR_H */
67 # ifdef HAVE_SYS_DIR_H
68 #  include <sys/dir.h>
69 # endif /* HAVE_SYS_DIR_H */
70 # ifdef HAVE_NDIR_H
71 #  include <ndir.h>
72 # endif /* HAVE_NDIR_H */
73 #endif /* HAVE_DIRENT_H */
74
75 #include <ctype.h>
76
77 #if HAVE_LIMITS_H
78 #include <limits.h>
79 #endif
80
81 #ifndef PATH_MAX
82 #ifdef _POSIX_PATH_MAX
83 #define PATH_MAX _POSIX_PATH_MAX
84 #elif defined MAXPATHLEN
85 #define PATH_MAX MAXPATHLEN
86 #else
87 #define PATH_MAX 256
88 #endif
89 #endif
90
91 #if WITH_SELINUX
92 #include <selinux/selinux.h>
93 #else
94 typedef char * security_context_t;
95
96 #define freecon(_c)
97
98 #define setfilecon(_fn, _c)     (-1)
99 #define lsetfilecon(_fn, _c)    (-1)
100
101 #define is_selinux_enabled()    (0)
102
103 #define matchpathcon_init(_fn)                  (-1)
104 #define matchpathcon_fini()                     (0)
105 #define matchpathcon(_fn, _fm, _c)              (-1)
106
107 #define rpm_execcon(_v, _fn, _av, _envp)        (0)
108 #endif
109
110 #include "rpmio/rpmutil.h"
111 /* compatibility macros to avoid a mass-renaming all over the codebase */
112 #define xmalloc(_size) rmalloc((_size))
113 #define xcalloc(_nmemb, _size) rcalloc((_nmemb), (_size))
114 #define xrealloc(_ptr, _size) rrealloc((_ptr), (_size))
115 #define xstrdup(_str) rstrdup((_str))
116 #define _free(_ptr) rfree((_ptr))
117
118 /* Retrofit glibc __progname */
119 #if defined __GLIBC__ && __GLIBC__ >= 2
120 #if __GLIBC_MINOR__ >= 1
121 #define __progname      __assert_program_name
122 #endif
123 #define setprogname(pn)
124 #else
125 #define __progname      program_name
126 #define setprogname(pn) \
127   { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
128     else __progname = pn;               \
129   }
130 #endif
131 extern const char *__progname;
132
133 /* Take care of NLS matters.  */
134 #if ENABLE_NLS
135 # include <locale.h>
136 # include <libintl.h>
137 # define _(Text) dgettext (PACKAGE, Text)
138 #else
139 # define _(Text) Text
140 #endif
141
142 #define N_(Text) Text
143
144 /* ============== from misc/miscfn.h */
145
146 #if !defined(USE_GNU_GLOB) 
147 #if HAVE_FNMATCH_H
148 #include <fnmatch.h>
149 #endif
150
151 #if HAVE_GLOB_H 
152 #include <glob.h>
153 #endif
154 #else
155 #include "misc/glob.h"
156 #include "misc/fnmatch.h"
157 #endif
158
159 #endif  /* H_SYSTEM */