23 #if defined(WIN32) && !defined(__CYGWIN__)
31 #define PGINVALID_SOCKET (-1)
35 #define PGINVALID_SOCKET INVALID_SOCKET
39 #ifndef HAVE_SOCKLEN_T
54 const char *head,
const char *tail);
78 extern char **
pgfnames(
const char *path);
81 #define IS_NONWINDOWS_DIR_SEP(ch) ((ch) == '/')
82 #define is_nonwindows_absolute_path(filename) \
84 IS_NONWINDOWS_DIR_SEP((filename)[0]) \
87 #define IS_WINDOWS_DIR_SEP(ch) ((ch) == '/' || (ch) == '\\')
89 #define is_windows_absolute_path(filename) \
91 IS_WINDOWS_DIR_SEP((filename)[0]) || \
92 (isalpha((unsigned char) ((filename)[0])) && (filename)[1] == ':' && \
93 IS_WINDOWS_DIR_SEP((filename)[2])) \
102 #define IS_DIR_SEP(ch) IS_NONWINDOWS_DIR_SEP(ch)
103 #define is_absolute_path(filename) is_nonwindows_absolute_path(filename)
105 #define IS_DIR_SEP(ch) IS_WINDOWS_DIR_SEP(ch)
106 #define is_absolute_path(filename) is_windows_absolute_path(filename)
121 #define ALL_CONNECTION_FAILURE_ERRNOS \
139 const char *versionstr,
char *retpath);
143 #define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
147 extern int pg_disable_aslr(
void);
151 #if defined(WIN32) || defined(__CYGWIN__)
157 #if defined(WIN32) && !defined(__CYGWIN__)
158 #define DEVNULL "nul"
160 #define DEVNULL "/dev/null"
169 extern unsigned char pg_toupper(
unsigned char ch);
170 extern unsigned char pg_tolower(
unsigned char ch);
179 #define USE_REPL_SNPRINTF 1
225 #define pg_pread pread
226 #define pg_pwrite pwrite
237 #define vsnprintf pg_vsnprintf
238 #define snprintf pg_snprintf
239 #define vsprintf pg_vsprintf
240 #define sprintf pg_sprintf
241 #define vfprintf pg_vfprintf
242 #define fprintf pg_fprintf
243 #define vprintf pg_vprintf
244 #define printf(...) pg_printf(__VA_ARGS__)
251 #define strerror pg_strerror
255 #define strerror_r pg_strerror_r
256 #define PG_STRERROR_R_BUFLEN 256
264 #if defined(WIN32) || defined(__CYGWIN__)
265 #define TIMEZONE_GLOBAL _timezone
266 #define TZNAME_GLOBAL _tzname
268 #define TIMEZONE_GLOBAL timezone
269 #define TZNAME_GLOBAL tzname
272 #if defined(WIN32) || defined(__CYGWIN__)
276 extern int pgrename(
const char *from,
const char *to);
277 extern int pgunlink(
const char *path);
284 #define rename(from, to) pgrename(from, to)
285 #define unlink(path) pgunlink(path)
297 #if defined(WIN32) && !defined(__CYGWIN__)
298 extern int pgsymlink(
const char *oldpath,
const char *newpath);
301 #define symlink(oldpath, newpath) pgsymlink(oldpath, newpath)
302 #define readlink(path, buf, size) pgreadlink(path, buf, size)
305 extern bool rmtree(
const char *path,
bool rmtopdir);
307 #if defined(WIN32) && !defined(__CYGWIN__)
313 #define O_DIRECT 0x80000000
314 extern HANDLE pgwin32_open_handle(
const char *,
int,
bool);
315 extern int pgwin32_open(
const char *,
int,...);
316 extern FILE *pgwin32_fopen(
const char *,
const char *);
317 #define open(a,b,c) pgwin32_open(a,b,c)
318 #define fopen(a,b) pgwin32_fopen(a,b)
336 extern int pgwin32_system(
const char *command);
337 extern FILE *pgwin32_popen(
const char *command,
const char *
type);
339 #define system(a) pgwin32_system(a)
340 #define popen(a,b) pgwin32_popen(a,b)
341 #define pclose(a) _pclose(a)
349 #define closesocket close
361 #define PG_IOLBF _IOLBF
363 #define PG_IOLBF _IONBF
373 #define pgoff_t off_t
376 #ifndef HAVE_GETPEEREID
378 #ifndef PLPERL_HAVE_UID_GID
389 #if defined(__clang__) && !defined(__cplusplus)
391 #if __has_builtin(__builtin_isinf)
395 #define isinf __builtin_isinf
399 #ifndef HAVE_EXPLICIT_BZERO
403 #ifdef HAVE_BUGGY_STRTOF
404 extern float pg_strtof(
const char *nptr,
char **endptr);
405 #define strtof(a,b) (pg_strtof((a),(b)))
410 extern int link(
const char *src,
const char *dst);
414 extern char *
mkdtemp(
char *path);
417 #ifndef HAVE_INET_ATON
420 extern int inet_aton(
const char *cp,
struct in_addr *addr);
423 #if !HAVE_DECL_STRLCAT
424 extern size_t strlcat(
char *dst,
const char *src,
size_t siz);
427 #if !HAVE_DECL_STRLCPY
428 extern size_t strlcpy(
char *dst,
const char *src,
size_t siz);
431 #if !HAVE_DECL_STRNLEN
432 extern size_t strnlen(
const char *
str,
size_t maxlen);
435 #if !HAVE_DECL_STRSEP
436 extern char *
strsep(
char **stringp,
const char *delim);
443 extern void pg_qsort(
void *base,
size_t nel,
size_t elsize,
444 int (*
cmp) (
const void *,
const void *));
447 #define qsort(a,b,c,d) pg_qsort(a,b,c,d)
451 extern void qsort_arg(
void *base,
size_t nel,
size_t elsize,
458 size_t nmemb,
size_t size,
459 int (*compar) (
const void *,
const void *,
void *),
465 #if defined(WIN32) && !defined(FRONTEND)
466 extern int pg_codepage_to_encoding(UINT cp);
471 char *dst,
size_t size);
481 #define pg_backend_random pg_strong_random
513 #define HAVE_GETRLIMIT 1
515 #define HAVE_POLL_H 1
516 #define HAVE_READLINK 1
517 #define HAVE_SETSID 1
518 #define HAVE_SHM_OPEN 1
519 #define HAVE_SYMLINK 1
#define pg_attribute_printf(f, a)
char my_exec_path[MAXPGPATH]
static void const char * fmt
void cleanup_path(char *path)
void get_share_path(const char *my_exec_path, char *ret_path)
int find_my_exec(const char *argv0, char *retpath)
int int pg_snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
void get_pkglib_path(const char *my_exec_path, char *ret_path)
void get_locale_path(const char *my_exec_path, char *ret_path)
int wait_result_to_exit_code(int exit_status)
void join_path_components(char *ret_path, const char *head, const char *tail)
char * last_dir_separator(const char *filename)
int int int int int int int pg_vprintf(const char *fmt, va_list args) pg_attribute_printf(1
void get_man_path(const char *my_exec_path, char *ret_path)
void pg_usleep(long microsec)
int pg_mkdir_p(char *path, int omode)
bool get_home_path(char *ret_path)
char * make_absolute_path(const char *path)
void get_include_path(const char *my_exec_path, char *ret_path)
char * pipe_read_line(char *cmd)
int pg_strfromd(char *str, size_t count, int precision, double value)
char * wait_result_to_str(int exitstatus)
void(* pqsigfunc)(SIGNAL_ARGS)
bool pg_strong_random(void *buf, size_t len)
bool path_is_prefix_of_path(const char *path1, const char *path2)
char * first_dir_separator(const char *filename)
int validate_exec(const char *path)
int pg_strcasecmp(const char *s1, const char *s2)
bool wait_result_is_signal(int exit_status, int signum)
void pgfnames_cleanup(char **filenames)
bool wait_result_is_any_signal(int exit_status, bool include_command_not_found)
void * bsearch_arg(const void *key, const void *base0, size_t nmemb, size_t size, int(*compar)(const void *, const void *, void *), void *arg)
bool path_is_relative_and_below_cwd(const char *path)
void get_lib_path(const char *my_exec_path, char *ret_path)
int(* qsort_arg_comparator)(const void *a, const void *b, void *arg)
int int int int int int pg_fprintf(FILE *stream, const char *fmt,...) pg_attribute_printf(2
void canonicalize_path(char *path)
int pg_qsort_strcmp(const void *a, const void *b)
void get_parent_directory(char *path)
int pg_check_dir(const char *dir)
bool pg_set_noblock(pgsocket sock)
const char * get_progname(const char *argv0)
pqsigfunc pqsignal(int signo, pqsigfunc func)
bool pg_set_block(pgsocket sock)
unsigned char pg_toupper(unsigned char ch)
void explicit_bzero(void *buf, size_t len)
char * pg_strerror_r(int errnum, char *buf, size_t buflen)
int int int int pg_sprintf(char *str, const char *fmt,...) pg_attribute_printf(2
char * pg_inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size)
void get_etc_path(const char *my_exec_path, char *ret_path)
int pclose_check(FILE *stream)
const char * pg_strsignal(int signum)
void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg)
void set_pglocale_pgservice(const char *argv0, const char *app)
void pg_strong_random_init(void)
char * strsep(char **stringp, const char *delim)
int inet_aton(const char *cp, struct in_addr *addr)
bool path_contains_parent_reference(const char *path)
char * first_path_var_separator(const char *pathlist)
void make_native_path(char *filename)
char ** pgfnames(const char *path)
unsigned char pg_tolower(unsigned char ch)
bool rmtree(const char *path, bool rmtopdir)
void get_doc_path(const char *my_exec_path, char *ret_path)
int find_other_exec(const char *argv0, const char *target, const char *versionstr, char *retpath)
unsigned char pg_ascii_tolower(unsigned char ch)
int pg_get_encoding_from_locale(const char *ctype, bool write_message)
int int int int int int int int pg_printf(const char *fmt,...) pg_attribute_printf(1
unsigned char pg_ascii_toupper(unsigned char ch)
void pg_qsort(void *base, size_t nel, size_t elsize, int(*cmp)(const void *, const void *))
void get_html_path(const char *my_exec_path, char *ret_path)
void get_pkginclude_path(const char *my_exec_path, char *ret_path)
int int int int int pg_vfprintf(FILE *stream, const char *fmt, va_list args) pg_attribute_printf(2
int int int pg_vsprintf(char *str, const char *fmt, va_list args) pg_attribute_printf(2
size_t strnlen(const char *str, size_t maxlen)
void qsort_interruptible(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg)
char * pg_strerror(int errnum)
int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args) pg_attribute_printf(3
size_t strlcat(char *dst, const char *src, size_t siz)
bool has_drive_prefix(const char *path)
size_t strlcpy(char *dst, const char *src, size_t siz)
char * escape_single_quotes_ascii(const char *src)
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
void get_includeserver_path(const char *my_exec_path, char *ret_path)
char * mkdtemp(char *path)
int getpeereid(int sock, uid_t *uid, gid_t *gid)
static int cmp(const chr *x, const chr *y, size_t len)
static pg_noinline void Size size
float pg_strtof(const char *nptr, char **endptr)
int pgreadlink(const char *path, char *buf, size_t size)
int pgsymlink(const char *oldpath, const char *newpath)
int link(const char *src, const char *dst)