2000-12-13 04:03:45 +08:00
|
|
|
/**
|
|
|
|
* \file system.h
|
|
|
|
*/
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
#ifndef H_SYSTEM
|
|
|
|
#define H_SYSTEM
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2002-06-21 01:17:23 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#include <sys/stat.h>
|
1999-11-27 08:15:07 +08:00
|
|
|
#include <stdio.h>
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1998-07-31 06:09:42 +08:00
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
|
|
#include <sys/param.h>
|
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
/* <unistd.h> should be included before any preprocessor test
|
|
|
|
of _POSIX_VERSION. */
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
2007-09-03 20:35:17 +08:00
|
|
|
#if !defined(__GLIBC__)
|
2005-01-05 03:31:31 +08:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <crt_externs.h>
|
|
|
|
#define environ (*_NSGetEnviron())
|
|
|
|
#else
|
2002-04-09 06:52:45 +08:00
|
|
|
extern char ** environ;
|
2005-01-05 03:31:31 +08:00
|
|
|
#endif /* __APPLE__ */
|
2002-04-09 06:52:45 +08:00
|
|
|
#endif
|
1998-07-26 05:00:26 +08:00
|
|
|
#endif
|
|
|
|
|
2001-10-14 03:35:58 +08:00
|
|
|
#if !defined(HAVE_STPCPY)
|
2007-09-12 01:04:11 +08:00
|
|
|
char * stpcpy(char * dest, const char * src);
|
1999-12-02 04:00:39 +08:00
|
|
|
#endif
|
|
|
|
|
2001-10-14 03:35:58 +08:00
|
|
|
#if !defined(HAVE_STPNCPY)
|
2007-09-12 01:04:11 +08:00
|
|
|
char * stpncpy(char * dest, const char * src, size_t n);
|
2000-02-28 04:50:52 +08:00
|
|
|
#endif
|
|
|
|
|
2007-09-03 20:35:17 +08:00
|
|
|
#if HAVE___SECURE_GETENV
|
2003-05-01 04:04:58 +08:00
|
|
|
#define getenv(_s) __secure_getenv(_s)
|
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#ifdef HAVE_FCNTL_H
|
|
|
|
#include <fcntl.h>
|
|
|
|
#else
|
|
|
|
#include <sys/file.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_DIRENT_H
|
|
|
|
# include <dirent.h>
|
|
|
|
# define NLENGTH(direct) (strlen((direct)->d_name))
|
|
|
|
#else /* not HAVE_DIRENT_H */
|
|
|
|
# define dirent direct
|
|
|
|
# define NLENGTH(direct) ((direct)->d_namlen)
|
|
|
|
# ifdef HAVE_SYS_NDIR_H
|
|
|
|
# include <sys/ndir.h>
|
|
|
|
# endif /* HAVE_SYS_NDIR_H */
|
|
|
|
# ifdef HAVE_SYS_DIR_H
|
|
|
|
# include <sys/dir.h>
|
|
|
|
# endif /* HAVE_SYS_DIR_H */
|
|
|
|
# ifdef HAVE_NDIR_H
|
|
|
|
# include <ndir.h>
|
|
|
|
# endif /* HAVE_NDIR_H */
|
|
|
|
#endif /* HAVE_DIRENT_H */
|
|
|
|
|
|
|
|
#if HAVE_LIMITS_H
|
|
|
|
#include <limits.h>
|
|
|
|
#endif
|
|
|
|
|
2008-11-03 20:13:45 +08:00
|
|
|
#ifndef PATH_MAX
|
|
|
|
#ifdef _POSIX_PATH_MAX
|
|
|
|
#define PATH_MAX _POSIX_PATH_MAX
|
|
|
|
#elif defined MAXPATHLEN
|
|
|
|
#define PATH_MAX MAXPATHLEN
|
|
|
|
#else
|
|
|
|
#define PATH_MAX 256
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2004-01-05 22:09:47 +08:00
|
|
|
#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)
|
|
|
|
|
2008-05-08 17:40:37 +08:00
|
|
|
#define is_selinux_enabled() (0)
|
2004-11-11 14:11:37 +08:00
|
|
|
|
2007-09-03 18:59:42 +08:00
|
|
|
#define matchpathcon_init(_fn) (-1)
|
|
|
|
#define matchpathcon_fini() (0)
|
|
|
|
#define matchpathcon(_fn, _fm, _c) (-1)
|
|
|
|
|
2004-11-11 14:11:37 +08:00
|
|
|
#define rpm_execcon(_v, _fn, _av, _envp) (0)
|
2004-01-05 22:09:47 +08:00
|
|
|
#endif
|
|
|
|
|
2009-09-16 22:28:22 +08:00
|
|
|
#include "rpmio/rpmutil.h"
|
|
|
|
/* compatibility macros to avoid a mass-renaming all over the codebase */
|
|
|
|
#define xmalloc(_size) rmalloc((_size))
|
|
|
|
#define xcalloc(_nmemb, _size) rcalloc((_nmemb), (_size))
|
|
|
|
#define xrealloc(_ptr, _size) rrealloc((_ptr), (_size))
|
|
|
|
#define xstrdup(_str) rstrdup((_str))
|
|
|
|
#define _free(_ptr) rfree((_ptr))
|
|
|
|
|
1999-09-26 23:04:03 +08:00
|
|
|
/* Retrofit glibc __progname */
|
|
|
|
#if defined __GLIBC__ && __GLIBC__ >= 2
|
2000-05-25 01:53:35 +08:00
|
|
|
#if __GLIBC_MINOR__ >= 1
|
|
|
|
#define __progname __assert_program_name
|
|
|
|
#endif
|
1999-09-26 23:04:03 +08:00
|
|
|
#define setprogname(pn)
|
|
|
|
#else
|
1999-09-27 01:28:00 +08:00
|
|
|
#define __progname program_name
|
1999-09-26 23:04:03 +08:00
|
|
|
#define setprogname(pn) \
|
1999-09-27 01:28:00 +08:00
|
|
|
{ if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
|
1999-09-26 23:04:03 +08:00
|
|
|
else __progname = pn; \
|
|
|
|
}
|
|
|
|
#endif
|
2005-01-18 07:58:09 +08:00
|
|
|
extern const char *__progname;
|
1999-09-26 23:04:03 +08:00
|
|
|
|
1998-10-08 22:59:17 +08:00
|
|
|
/* Take care of NLS matters. */
|
2007-09-03 20:35:17 +08:00
|
|
|
#if ENABLE_NLS
|
2010-01-05 20:28:47 +08:00
|
|
|
# include <locale.h>
|
1998-10-08 22:59:17 +08:00
|
|
|
# include <libintl.h>
|
2007-11-13 18:57:49 +08:00
|
|
|
# define _(Text) dgettext (PACKAGE, Text)
|
1998-10-08 22:59:17 +08:00
|
|
|
#else
|
|
|
|
# define _(Text) Text
|
|
|
|
#endif
|
|
|
|
|
1998-12-02 01:18:38 +08:00
|
|
|
#define N_(Text) Text
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
/* ============== from misc/miscfn.h */
|
|
|
|
|
2007-09-03 20:35:17 +08:00
|
|
|
#if !defined(USE_GNU_GLOB)
|
1998-07-26 05:00:26 +08:00
|
|
|
#if HAVE_FNMATCH_H
|
|
|
|
#include <fnmatch.h>
|
|
|
|
#endif
|
|
|
|
|
2007-09-03 20:35:17 +08:00
|
|
|
#if HAVE_GLOB_H
|
1998-07-26 05:00:26 +08:00
|
|
|
#include <glob.h>
|
2000-03-12 04:14:07 +08:00
|
|
|
#endif
|
1998-07-26 05:00:26 +08:00
|
|
|
#else
|
|
|
|
#include "misc/glob.h"
|
2000-03-12 04:14:07 +08:00
|
|
|
#include "misc/fnmatch.h"
|
2001-10-14 03:35:58 +08:00
|
|
|
#endif
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#endif /* H_SYSTEM */
|