Revert "tizen: Use upstream version of find-provides.ksyms"
[platform/upstream/rpm.git] / system.h
1 /**
2  * \file system.h
3  *
4  *  Some misc low-level API
5  */
6
7 #ifndef H_SYSTEM
8 #define H_SYSTEM
9
10 #ifdef HAVE_CONFIG_H
11 #include "config.h"
12 #endif
13
14 #ifdef HAVE_SYS_PARAM_H
15 #include <sys/param.h>
16 #endif
17
18 /* <unistd.h> should be included before any preprocessor test
19    of _POSIX_VERSION.  */
20 #ifdef HAVE_UNISTD_H
21 #include <unistd.h>
22 #if !defined(__GLIBC__)
23 #ifdef __APPLE__
24 #include <crt_externs.h>
25 #define environ (*_NSGetEnviron())
26 #else
27 extern char ** environ;
28 #endif /* __APPLE__ */
29 #endif
30 #endif
31
32 #if !defined(HAVE_STPCPY)
33 char * stpcpy(char * dest, const char * src);
34 #endif
35
36 #if !defined(HAVE_STPNCPY)
37 char * stpncpy(char * dest, const char * src, size_t n);
38 #endif
39
40 #if HAVE_SECURE_GETENV
41 #define getenv(_s)      secure_getenv(_s)
42 #elif HAVE___SECURE_GETENV
43 #define getenv(_s)      __secure_getenv(_s)
44 #endif
45
46 #ifdef HAVE_FCNTL_H
47 #include <fcntl.h>
48 #else
49 #include <sys/file.h>
50 #endif
51
52 #ifdef HAVE_DIRENT_H
53 # include <dirent.h>
54 # define NLENGTH(direct) (strlen((direct)->d_name))
55 #else /* not HAVE_DIRENT_H */
56 # define dirent direct
57 # define NLENGTH(direct) ((direct)->d_namlen)
58 # ifdef HAVE_SYS_NDIR_H
59 #  include <sys/ndir.h>
60 # endif /* HAVE_SYS_NDIR_H */
61 # ifdef HAVE_SYS_DIR_H
62 #  include <sys/dir.h>
63 # endif /* HAVE_SYS_DIR_H */
64 # ifdef HAVE_NDIR_H
65 #  include <ndir.h>
66 # endif /* HAVE_NDIR_H */
67 #endif /* HAVE_DIRENT_H */
68
69 #if HAVE_LIMITS_H
70 #include <limits.h>
71 #endif
72
73 #ifndef PATH_MAX
74 #ifdef _POSIX_PATH_MAX
75 #define PATH_MAX _POSIX_PATH_MAX
76 #elif defined MAXPATHLEN
77 #define PATH_MAX MAXPATHLEN
78 #else
79 #define PATH_MAX 256
80 #endif
81 #endif
82
83 #if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
84 extern int fdatasync(int fildes);
85 #endif
86
87 #include "rpmio/rpmutil.h"
88 /* compatibility macros to avoid a mass-renaming all over the codebase */
89 #define xmalloc(_size) rmalloc((_size))
90 #define xcalloc(_nmemb, _size) rcalloc((_nmemb), (_size))
91 #define xrealloc(_ptr, _size) rrealloc((_ptr), (_size))
92 #define xstrdup(_str) rstrdup((_str))
93 #define _free(_ptr) rfree((_ptr))
94
95 /* To extract program's name: use calls (reimplemented or shipped with system):
96    - void setprogname(const char *pn)
97    - const char *getprogname(void)
98
99    setprogname(*pn) must be the first call in main() in order to set the name
100    as soon as possible. */
101 #if defined(HAVE_SETPROGNAME) /* BSD'ish systems */
102 # include <stdlib.h> /* Make sure this header is included */
103 # define xsetprogname(pn) setprogname(pn)
104 # define xgetprogname(pn) getprogname(pn)
105 #elif defined(HAVE___PROGNAME) /* glibc and others */
106 # define xsetprogname(pn)
107   extern const char *__progname;
108 # define xgetprogname(pn) __progname
109 #else
110 # error "Did not find any sutable implementation of xsetprogname/xgetprogname"
111 #endif
112
113 /* Take care of NLS matters.  */
114 #if ENABLE_NLS
115 # include <locale.h>
116 # include <libintl.h>
117 # define _(Text) dgettext (PACKAGE, Text)
118 #else
119 # define _(Text) Text
120 #endif
121
122 #define N_(Text) Text
123
124 /* ============== from misc/miscfn.h */
125
126 #include "misc/fnmatch.h"
127
128 #include <dlfcn.h>
129
130 #endif  /* H_SYSTEM */