fix msm-plugin.c svace issue: make sure dupPath is not NULL before strchr()
[platform/upstream/rpm.git] / system.h
index 71fd887..570cef1 100644 (file)
--- a/system.h
+++ b/system.h
@@ -1,5 +1,7 @@
 /**
  * \file system.h
+ *
+ *  Some misc low-level API
  */
 
 #ifndef        H_SYSTEM
@@ -9,11 +11,6 @@
 #include "config.h"
 #endif
 
-#include <sys/types.h>
-
-#include <sys/stat.h>
-#include <stdio.h>
-
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif
@@ -40,12 +37,9 @@ char * stpcpy(char * dest, const char * src);
 char * stpncpy(char * dest, const char * src, size_t n);
 #endif
 
-#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
-#if HAVE___SECURE_GETENV
+#if HAVE_SECURE_GETENV
+#define        getenv(_s)      secure_getenv(_s)
+#elif HAVE___SECURE_GETENV
 #define        getenv(_s)      __secure_getenv(_s)
 #endif
 
@@ -72,8 +66,6 @@ extern int errno;
 # endif /* HAVE_NDIR_H */
 #endif /* HAVE_DIRENT_H */
 
-#include <ctype.h>
-
 #if HAVE_LIMITS_H
 #include <limits.h>
 #endif
@@ -88,23 +80,8 @@ extern int errno;
 #endif
 #endif
 
-#if WITH_SELINUX
-#include <selinux/selinux.h>
-#else
-typedef        char * security_context_t;
-
-#define        freecon(_c)
-
-#define        setfilecon(_fn, _c)     (-1)
-#define        lsetfilecon(_fn, _c)    (-1)
-
-#define        is_selinux_enabled()    (0)
-
-#define matchpathcon_init(_fn)                 (-1)
-#define matchpathcon_fini()                    (0)
-#define matchpathcon(_fn, _fm, _c)             (-1)
-
-#define rpm_execcon(_v, _fn, _av, _envp)       (0)
+#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
+extern int fdatasync(int fildes);
 #endif
 
 #include "rpmio/rpmutil.h"
@@ -115,20 +92,23 @@ typedef    char * security_context_t;
 #define xstrdup(_str) rstrdup((_str))
 #define _free(_ptr) rfree((_ptr))
 
-/* Retrofit glibc __progname */
-#if defined __GLIBC__ && __GLIBC__ >= 2
-#if __GLIBC_MINOR__ >= 1
-#define        __progname      __assert_program_name
-#endif
-#define        setprogname(pn)
+/* To extract program's name: use calls (reimplemented or shipped with system):
+   - void setprogname(const char *pn)
+   - const char *getprogname(void)
+
+   setprogname(*pn) must be the first call in main() in order to set the name
+   as soon as possible. */
+#if defined(HAVE_SETPROGNAME) /* BSD'ish systems */
+# include <stdlib.h> /* Make sure this header is included */
+# define xsetprogname(pn) setprogname(pn)
+# define xgetprogname(pn) getprogname(pn)
+#elif defined(HAVE___PROGNAME) /* glibc and others */
+# define xsetprogname(pn)
+  extern const char *__progname;
+# define xgetprogname(pn) __progname
 #else
-#define        __progname      program_name
-#define        setprogname(pn) \
-  { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
-    else __progname = pn;              \
-  }
+# error "Did not find any sutable implementation of xsetprogname/xgetprogname"
 #endif
-extern const char *__progname;
 
 /* Take care of NLS matters.  */
 #if ENABLE_NLS
@@ -143,17 +123,8 @@ extern const char *__progname;
 
 /* ============== from misc/miscfn.h */
 
-#if !defined(USE_GNU_GLOB) 
-#if HAVE_FNMATCH_H
-#include <fnmatch.h>
-#endif
-
-#if HAVE_GLOB_H 
-#include <glob.h>
-#endif
-#else
-#include "misc/glob.h"
 #include "misc/fnmatch.h"
-#endif
+
+#include <dlfcn.h>
 
 #endif /* H_SYSTEM */