PostgreSQL Source Code git master
Loading...
Searching...
No Matches
port.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * port.h
4 * Header for src/port/ compatibility functions.
5 *
6 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * src/include/port.h
10 *
11 *-------------------------------------------------------------------------
12 */
13#ifndef PG_PORT_H
14#define PG_PORT_H
15
16#include <ctype.h>
17
18/*
19 * Windows has enough specialized port stuff that we push most of it off
20 * into another file.
21 * Note: Some CYGWIN includes might #define WIN32.
22 */
23#if defined(WIN32) && !defined(__CYGWIN__)
24#include "port/win32_port.h"
25#endif
26
27/* socket has a different definition on WIN32 */
28#ifndef WIN32
29typedef int pgsocket;
30
31#define PGINVALID_SOCKET (-1)
32#else
33typedef SOCKET pgsocket;
34
35#define PGINVALID_SOCKET INVALID_SOCKET
36#endif
37
38/* if platform lacks socklen_t, we assume this will work */
39#ifndef HAVE_SOCKLEN_T
40typedef unsigned int socklen_t;
41#endif
42
43/* non-blocking */
44extern bool pg_set_noblock(pgsocket sock);
45extern bool pg_set_block(pgsocket sock);
46
47/* Portable path handling for Unix/Win32 (in path.c) */
48
49extern bool has_drive_prefix(const char *path);
50extern char *first_dir_separator(const char *filename);
51extern char *last_dir_separator(const char *filename);
52extern char *first_path_var_separator(const char *pathlist);
53extern void join_path_components(char *ret_path,
54 const char *head, const char *tail);
55extern void canonicalize_path(char *path);
56extern void canonicalize_path_enc(char *path, int encoding);
57extern void make_native_path(char *filename);
58extern void cleanup_path(char *path);
59extern bool path_contains_parent_reference(const char *path);
60extern bool path_is_relative_and_below_cwd(const char *path);
61extern bool path_is_safe_for_extraction(const char *path);
62extern bool path_is_prefix_of_path(const char *path1, const char *path2);
63extern char *make_absolute_path(const char *path);
64extern const char *get_progname(const char *argv0);
65extern void get_share_path(const char *my_exec_path, char *ret_path);
66extern void get_etc_path(const char *my_exec_path, char *ret_path);
67extern void get_include_path(const char *my_exec_path, char *ret_path);
68extern void get_pkginclude_path(const char *my_exec_path, char *ret_path);
69extern void get_includeserver_path(const char *my_exec_path, char *ret_path);
70extern void get_lib_path(const char *my_exec_path, char *ret_path);
71extern void get_pkglib_path(const char *my_exec_path, char *ret_path);
72extern void get_locale_path(const char *my_exec_path, char *ret_path);
73extern void get_doc_path(const char *my_exec_path, char *ret_path);
74extern void get_html_path(const char *my_exec_path, char *ret_path);
75extern void get_man_path(const char *my_exec_path, char *ret_path);
76extern bool get_home_path(char *ret_path);
77extern void get_parent_directory(char *path);
78
79/* common/pgfnames.c */
80extern char **pgfnames(const char *path);
81extern void pgfnames_cleanup(char **filenames);
82
83#define IS_NONWINDOWS_DIR_SEP(ch) ((ch) == '/')
84#define is_nonwindows_absolute_path(filename) \
85( \
86 IS_NONWINDOWS_DIR_SEP((filename)[0]) \
87)
88
89#define IS_WINDOWS_DIR_SEP(ch) ((ch) == '/' || (ch) == '\\')
90/* See path_is_relative_and_below_cwd() for how we handle 'E:abc'. */
91#define is_windows_absolute_path(filename) \
92( \
93 IS_WINDOWS_DIR_SEP((filename)[0]) || \
94 (isalpha((unsigned char) ((filename)[0])) && (filename)[1] == ':' && \
95 IS_WINDOWS_DIR_SEP((filename)[2])) \
96)
97
98/*
99 * is_absolute_path and IS_DIR_SEP
100 *
101 * By using macros here we avoid needing to include path.c in libpq.
102 */
103#ifndef WIN32
104#define IS_DIR_SEP(ch) IS_NONWINDOWS_DIR_SEP(ch)
105#define is_absolute_path(filename) is_nonwindows_absolute_path(filename)
106#else
107#define IS_DIR_SEP(ch) IS_WINDOWS_DIR_SEP(ch)
108#define is_absolute_path(filename) is_windows_absolute_path(filename)
109#endif
110
111/*
112 * This macro provides a centralized list of all errnos that identify
113 * hard failure of a previously-established network connection.
114 * The macro is intended to be used in a switch statement, in the form
115 * "case ALL_CONNECTION_FAILURE_ERRNOS:".
116 *
117 * Note: this groups EPIPE and ECONNRESET, which we take to indicate a
118 * probable server crash, with other errors that indicate loss of network
119 * connectivity without proving much about the server's state. Places that
120 * are actually reporting errors typically single out EPIPE and ECONNRESET,
121 * while allowing the network failures to be reported generically.
122 */
123#define ALL_CONNECTION_FAILURE_ERRNOS \
124 EPIPE: \
125 case ECONNRESET: \
126 case ECONNABORTED: \
127 case EHOSTDOWN: \
128 case EHOSTUNREACH: \
129 case ENETDOWN: \
130 case ENETRESET: \
131 case ENETUNREACH: \
132 case ETIMEDOUT
133
134/* Portable locale initialization (in exec.c) */
135extern void set_pglocale_pgservice(const char *argv0, const char *app);
136
137/* Portable way to find and execute binaries (in exec.c) */
138extern int validate_exec(const char *path);
139extern int find_my_exec(const char *argv0, char *retpath);
140extern int find_other_exec(const char *argv0, const char *target,
141 const char *versionstr, char *retpath);
142extern char *pipe_read_line(char *cmd);
143
144/* Doesn't belong here, but this is used with find_other_exec(), so... */
145#define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
146
147#ifdef EXEC_BACKEND
148/* Disable ASLR before exec, for developer builds only (in exec.c) */
149extern int pg_disable_aslr(void);
150#endif
151
152
153#if defined(WIN32) || defined(__CYGWIN__)
154#define EXE ".exe"
155#else
156#define EXE ""
157#endif
158
159#if defined(WIN32) && !defined(__CYGWIN__)
160#define DEVNULL "nul"
161#else
162#define DEVNULL "/dev/null"
163#endif
164
165/* Portable delay handling */
166extern void pg_usleep(long microsec);
167
168/* Portable SQL-like case-independent comparisons and conversions */
169extern int pg_strcasecmp(const char *s1, const char *s2);
170extern int pg_strncasecmp(const char *s1, const char *s2, size_t n);
171extern unsigned char pg_toupper(unsigned char ch);
172extern unsigned char pg_tolower(unsigned char ch);
173
174/*
175 * Fold a character to upper case, following C/POSIX locale rules.
176 */
177static inline unsigned char
178pg_ascii_toupper(unsigned char ch)
179{
180 if (ch >= 'a' && ch <= 'z')
181 ch += 'A' - 'a';
182 return ch;
183}
184
185/*
186 * Fold a character to lower case, following C/POSIX locale rules.
187 */
188static inline unsigned char
189pg_ascii_tolower(unsigned char ch)
190{
191 if (ch >= 'A' && ch <= 'Z')
192 ch += 'a' - 'A';
193 return ch;
194}
195
196
197/*
198 * Beginning in v12, we always replace snprintf() and friends with our own
199 * implementation. This symbol is no longer consulted by the core code,
200 * but keep it defined anyway in case any extensions are looking at it.
201 */
202#define USE_REPL_SNPRINTF 1
203
204/*
205 * Versions of libintl >= 0.13 try to replace printf() and friends with
206 * macros to their own versions that understand the %$ format. We do the
207 * same, so disable their macros, if they exist.
208 */
209#ifdef vsnprintf
210#undef vsnprintf
211#endif
212#ifdef snprintf
213#undef snprintf
214#endif
215#ifdef vsprintf
216#undef vsprintf
217#endif
218#ifdef sprintf
219#undef sprintf
220#endif
221#ifdef vfprintf
222#undef vfprintf
223#endif
224#ifdef fprintf
225#undef fprintf
226#endif
227#ifdef vprintf
228#undef vprintf
229#endif
230#ifdef printf
231#undef printf
232#endif
233
234extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args) pg_attribute_printf(3, 0);
235extern int pg_snprintf(char *str, size_t count, const char *fmt, ...) pg_attribute_printf(3, 4);
237extern int pg_sprintf(char *str, const char *fmt, ...) pg_attribute_printf(2, 3);
239extern int pg_fprintf(FILE *stream, const char *fmt, ...) pg_attribute_printf(2, 3);
242
243#ifndef WIN32
244/*
245 * We add a pg_ prefix as a warning that the Windows implementations have the
246 * non-standard side-effect of changing the current file position.
247 */
248#define pg_pread pread
249#define pg_pwrite pwrite
250#endif
251
252/*
253 * We use __VA_ARGS__ for printf to prevent replacing references to
254 * the "printf" format archetype in format() attribute declarations.
255 * That unfortunately means that taking a function pointer to printf
256 * will not do what we'd wish. (If you need to do that, you must name
257 * pg_printf explicitly.) For printf's sibling functions, use
258 * parameterless macros so that function pointers will work unsurprisingly.
259 */
260#define vsnprintf pg_vsnprintf
261#define snprintf pg_snprintf
262#define vsprintf pg_vsprintf
263#define sprintf pg_sprintf
264#define vfprintf pg_vfprintf
265#define fprintf pg_fprintf
266#define vprintf pg_vprintf
267#define printf(...) pg_printf(__VA_ARGS__)
268
269/* This is also provided by snprintf.c */
270extern int pg_strfromd(char *str, size_t count, int precision, double value);
271
272/* Replace strerror() with our own, somewhat more robust wrapper */
273extern char *pg_strerror(int errnum);
274#define strerror pg_strerror
275
276/* Likewise for strerror_r(); note we prefer the GNU API for that */
277extern char *pg_strerror_r(int errnum, char *buf, size_t buflen);
278#define strerror_r pg_strerror_r
279#define PG_STRERROR_R_BUFLEN 256 /* Recommended buffer size for strerror_r */
280
281/* Wrap strsignal(), or provide our own version if necessary */
282extern const char *pg_strsignal(int signum);
283
284extern int pclose_check(FILE *stream);
285
286/* Global variable holding time zone information. */
287#if defined(WIN32) || defined(__CYGWIN__)
288#define TIMEZONE_GLOBAL _timezone
289#define TZNAME_GLOBAL _tzname
290#else
291#define TIMEZONE_GLOBAL timezone
292#define TZNAME_GLOBAL tzname
293#endif
294
295#if defined(WIN32) || defined(__CYGWIN__)
296/*
297 * Win32 doesn't have reliable rename/unlink during concurrent access.
298 */
299extern int pgrename(const char *from, const char *to);
300extern int pgunlink(const char *path);
301
302/* Include this first so later includes don't see these defines */
303#ifdef _MSC_VER
304#include <io.h>
305#endif
306
307#define rename(from, to) pgrename(from, to)
308#define unlink(path) pgunlink(path)
309#endif /* defined(WIN32) || defined(__CYGWIN__) */
310
311/*
312 * Win32 also doesn't have symlinks, but we can emulate them with
313 * junction points on newer Win32 versions.
314 *
315 * Cygwin has its own symlinks which work on Win95/98/ME where
316 * junction points don't, so use those instead. We have no way of
317 * knowing what type of system Cygwin binaries will be run on.
318 * Note: Some CYGWIN includes might #define WIN32.
319 */
320#if defined(WIN32) && !defined(__CYGWIN__)
321extern int pgsymlink(const char *oldpath, const char *newpath);
322extern int pgreadlink(const char *path, char *buf, size_t size);
323
324#define symlink(oldpath, newpath) pgsymlink(oldpath, newpath)
325#define readlink(path, buf, size) pgreadlink(path, buf, size)
326#endif
327
328extern bool rmtree(const char *path, bool rmtopdir);
329
330#if defined(WIN32) && !defined(__CYGWIN__)
331
332/*
333 * We want the 64-bit variant of lseek().
334 *
335 * For Visual Studio, this must be after <io.h> to avoid messing up its
336 * lseek() and _lseeki64() function declarations.
337 *
338 * For MinGW there is already a macro, so we have to undefine it (depending on
339 * _FILE_OFFSET_BITS, it may point at its own lseek64, but we don't want to
340 * count on that being set).
341 */
342#undef lseek
343#define lseek(a,b,c) _lseeki64((a),(b),(c))
344
345/*
346 * We want the 64-bit variant of chsize(). It sets errno and also returns it,
347 * so convert non-zero result to -1 to match POSIX.
348 *
349 * Prevent MinGW from declaring functions, and undefine its macro before we
350 * define our own.
351 */
352#ifndef _MSC_VER
353#define FTRUNCATE_DEFINED
354#include <unistd.h>
355#undef ftruncate
356#endif
357#define ftruncate(a,b) (_chsize_s((a),(b)) == 0 ? 0 : -1)
358
359/*
360 * open() and fopen() replacements to allow deletion of open files and
361 * passing of other special options.
362 */
363extern HANDLE pgwin32_open_handle(const char *, int, bool);
364extern int pgwin32_open(const char *, int, ...);
365extern FILE *pgwin32_fopen(const char *, const char *);
366#define open(a,b,c) pgwin32_open(a,b,c)
367#define fopen(a,b) pgwin32_fopen(a,b)
368
369/*
370 * Mingw-w64 headers #define popen and pclose to _popen and _pclose. We want
371 * to use our popen wrapper, rather than plain _popen, so override that. For
372 * consistency, use our version of pclose, too.
373 */
374#ifdef popen
375#undef popen
376#endif
377#ifdef pclose
378#undef pclose
379#endif
380
381/*
382 * system() and popen() replacements to enclose the command in an extra
383 * pair of quotes.
384 */
385extern int pgwin32_system(const char *command);
386extern FILE *pgwin32_popen(const char *command, const char *type);
387
388#define system(a) pgwin32_system(a)
389#define popen(a,b) pgwin32_popen(a,b)
390#define pclose(a) _pclose(a)
391
392#else /* !WIN32 */
393
394/*
395 * Win32 requires a special close for sockets and pipes, while on Unix
396 * close() does them all.
397 */
398#define closesocket close
399#endif /* WIN32 */
400
401/*
402 * On Windows, setvbuf() does not support _IOLBF mode, and interprets that
403 * as _IOFBF. To add insult to injury, setvbuf(file, NULL, _IOFBF, 0)
404 * crashes outright if "parameter validation" is enabled. Therefore, in
405 * places where we'd like to select line-buffered mode, we fall back to
406 * unbuffered mode instead on Windows. Always use PG_IOLBF not _IOLBF
407 * directly in order to implement this behavior.
408 */
409#ifndef WIN32
410#define PG_IOLBF _IOLBF
411#else
412#define PG_IOLBF _IONBF
413#endif
414
415/*
416 * Default "extern" declarations or macro substitutes for library routines.
417 * When necessary, these routines are provided by files in src/port/.
418 */
419
420/* Type to use with fseeko/ftello */
421#ifndef WIN32 /* WIN32 is handled in port/win32_port.h */
423#endif
424
425#ifndef HAVE_GETPEEREID
426/* On Windows, Perl might have incompatible definitions of uid_t and gid_t. */
427#ifndef PLPERL_HAVE_UID_GID
428extern int getpeereid(int sock, uid_t *uid, gid_t *gid);
429#endif
430#endif
431
432/*
433 * Glibc doesn't use the builtin for clang due to a *gcc* bug in a version
434 * newer than the gcc compatibility clang claims to have. This would cause a
435 * *lot* of superfluous function calls, therefore revert when using clang. In
436 * C++ there's issues with libc++ (not libstdc++), so disable as well.
437 */
438#if defined(__clang__) && !defined(__cplusplus)
439/* needs to be separate to not confuse other compilers */
440#if __has_builtin(__builtin_isinf)
441/* need to include before, to avoid getting overwritten */
442#include <math.h>
443#undef isinf
444#define isinf __builtin_isinf
445#endif /* __has_builtin(isinf) */
446#endif /* __clang__ && !__cplusplus */
447
448#ifndef HAVE_EXPLICIT_BZERO
449extern void explicit_bzero(void *buf, size_t len);
450#endif
451
452#ifdef HAVE_BUGGY_STRTOF
453extern float pg_strtof(const char *nptr, char **endptr);
454#define strtof(a,b) (pg_strtof((a),(b)))
455#endif
456
457#ifdef WIN32
458/* src/port/win32link.c */
459extern int link(const char *src, const char *dst);
460#endif
461
462#ifndef HAVE_MKDTEMP
463extern char *mkdtemp(char *path);
464#endif
465
466#ifndef HAVE_INET_ATON
467#include <netinet/in.h>
468#include <arpa/inet.h>
469extern int inet_aton(const char *cp, struct in_addr *addr);
470#endif
471
472#if !HAVE_DECL_STRLCAT
473extern size_t strlcat(char *dst, const char *src, size_t siz);
474#endif
475
476#if !HAVE_DECL_STRLCPY
477extern size_t strlcpy(char *dst, const char *src, size_t siz);
478#endif
479
480#if !HAVE_DECL_STRSEP
481extern char *strsep(char **stringp, const char *delim);
482#endif
483
484#if !HAVE_DECL_TIMINGSAFE_BCMP
485extern int timingsafe_bcmp(const void *b1, const void *b2, size_t n);
486#endif
487
488/*
489 * Callers should use the qsort() macro defined below instead of calling
490 * pg_qsort() directly.
491 */
492extern void pg_qsort(void *base, size_t nel, size_t elsize,
493 int (*cmp) (const void *, const void *));
494extern int pg_qsort_strcmp(const void *a, const void *b);
495
496#define qsort(a,b,c,d) pg_qsort(a,b,c,d)
497
498typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg);
499
500extern void qsort_arg(void *base, size_t nel, size_t elsize,
502
503extern void qsort_interruptible(void *base, size_t nel, size_t elsize,
505
506extern void *bsearch_arg(const void *key, const void *base0,
507 size_t nmemb, size_t size,
508 int (*compar) (const void *, const void *, void *),
509 void *arg);
510
511/* port/pg_localeconv_r.c */
512extern int pg_localeconv_r(const char *lc_monetary,
513 const char *lc_numeric,
514 struct lconv *output);
515extern void pg_localeconv_free(struct lconv *lconv);
516
517/* port/chklocale.c */
518extern int pg_get_encoding_from_locale(const char *ctype, bool write_message);
519
520#if defined(WIN32) && !defined(FRONTEND)
522#endif
523
524/* port/inet_net_ntop.c */
525extern char *pg_inet_net_ntop(int af, const void *src, int bits,
526 char *dst, size_t size);
527
528/* port/pg_strong_random.c */
529extern void pg_strong_random_init(void);
530extern bool pg_strong_random(void *buf, size_t len);
531
532/*
533 * pg_backend_random used to be a wrapper for pg_strong_random before
534 * Postgres 12 for the backend code.
535 */
536#define pg_backend_random pg_strong_random
537
538/* port/pgcheckdir.c */
539extern int pg_check_dir(const char *dir);
540
541/* port/pgmkdirp.c */
542extern int pg_mkdir_p(char *path, int omode);
543
544/* port/pqsignal.c (see also interfaces/libpq/legacy-pqsignal.c) */
545#ifdef FRONTEND
546#define pqsignal pqsignal_fe
547#else
548#define pqsignal pqsignal_be
549#endif
550
551#define PG_SIG_DFL (pqsigfunc) (pg_funcptr_t) SIG_DFL
552#define PG_SIG_IGN (pqsigfunc) (pg_funcptr_t) SIG_IGN
554extern void pqsignal(int signo, pqsigfunc func);
555
556/* port/quotes.c */
557extern char *escape_single_quotes_ascii(const char *src);
558
559/* common/wait_error.c */
560extern char *wait_result_to_str(int exitstatus);
561extern bool wait_result_is_signal(int exit_status, int signum);
564
565/*
566 * Interfaces that we assume all Unix system have. We retain individual macros
567 * for better documentation.
568 *
569 * For symlink-related functions, there is often no need to test these macros,
570 * because we provided basic support on Windows that can work with absolute
571 * paths to directories. Code that wants to test for complete symlink support
572 * (including relative paths and non-directories) should be conditional on
573 * HAVE_READLINK or HAVE_SYMLINK.
574 */
575#ifndef WIN32
576#define HAVE_GETRLIMIT 1
577#define HAVE_POLL 1
578#define HAVE_POLL_H 1
579#define HAVE_READLINK 1
580#define HAVE_SETSID 1
581#define HAVE_SHM_OPEN 1
582#define HAVE_SYMLINK 1
583#endif
584
585#endif /* PG_PORT_H */
#define SIGNAL_ARGS
Definition c.h:1462
#define pg_attribute_printf(f, a)
Definition c.h:268
Datum arg
Definition elog.c:1323
char my_exec_path[MAXPGPATH]
Definition globals.c:83
const char * str
FILE * output
static struct @177 value
static char * encoding
Definition initdb.c:139
static char * lc_numeric
Definition initdb.c:144
static char * lc_monetary
Definition initdb.c:143
int b
Definition isn.c:74
int a
Definition isn.c:73
const void size_t len
static char * argv0
Definition pg_ctl.c:94
static char * filename
Definition pg_dumpall.c:133
static char buf[DEFAULT_XLOG_SEG_SIZE]
void cleanup_path(char *path)
Definition path.c:258
#define pqsignal
Definition port.h:548
void get_share_path(const char *my_exec_path, char *ret_path)
Definition path.c:919
char * wait_result_to_str(int exitstatus)
Definition wait_error.c:33
int find_my_exec(const char *argv0, char *retpath)
Definition exec.c:161
char * strsep(char **stringp, const char *delim)
Definition strsep.c:50
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)
Definition path.c:973
void get_locale_path(const char *my_exec_path, char *ret_path)
Definition path.c:982
int wait_result_to_exit_code(int exit_status)
Definition wait_error.c:138
void join_path_components(char *ret_path, const char *head, const char *tail)
Definition path.c:286
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)
Definition path.c:1009
void pg_usleep(long microsec)
Definition signal.c:53
int pg_mkdir_p(char *path, int omode)
Definition pgmkdirp.c:57
bool get_home_path(char *ret_path)
Definition path.c:1022
void get_include_path(const char *my_exec_path, char *ret_path)
Definition path.c:937
int pg_strfromd(char *str, size_t count, int precision, double value)
Definition snprintf.c:1276
void(* pqsigfunc)(SIGNAL_ARGS)
Definition port.h:553
bool pg_strong_random(void *buf, size_t len)
bool path_is_prefix_of_path(const char *path1, const char *path2)
Definition path.c:654
int validate_exec(const char *path)
Definition exec.c:89
char * last_dir_separator(const char *filename)
Definition path.c:145
char * pipe_read_line(char *cmd)
Definition exec.c:353
int pg_strcasecmp(const char *s1, const char *s2)
bool wait_result_is_signal(int exit_status, int signum)
Definition wait_error.c:102
void pgfnames_cleanup(char **filenames)
Definition pgfnames.c:85
void * bsearch_arg(const void *key, const void *base0, size_t nmemb, size_t size, int(*compar)(const void *, const void *, void *), void *arg)
Definition bsearch_arg.c:55
bool path_is_safe_for_extraction(const char *path)
Definition path.c:637
char * escape_single_quotes_ascii(const char *src)
Definition quotes.c:33
bool wait_result_is_any_signal(int exit_status, bool include_command_not_found)
Definition wait_error.c:121
bool path_is_relative_and_below_cwd(const char *path)
Definition path.c:604
char * pg_inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size)
void get_lib_path(const char *my_exec_path, char *ret_path)
Definition path.c:964
const char * pg_strsignal(int signum)
Definition pgstrsignal.c:39
char * first_path_var_separator(const char *pathlist)
Definition path.c:127
char * pg_strerror_r(int errnum, char *buf, size_t buflen)
Definition strerror.c:46
int(* qsort_arg_comparator)(const void *a, const void *b, void *arg)
Definition port.h:498
int int int int int int pg_fprintf(FILE *stream, const char *fmt,...) pg_attribute_printf(2
void canonicalize_path(char *path)
Definition path.c:337
int pg_qsort_strcmp(const void *a, const void *b)
Definition qsort.c:19
void get_parent_directory(char *path)
Definition path.c:1085
int pg_check_dir(const char *dir)
Definition pgcheckdir.c:33
bool pg_set_noblock(pgsocket sock)
Definition noblock.c:25
bool pg_set_block(pgsocket sock)
Definition noblock.c:49
unsigned char pg_toupper(unsigned char ch)
int pg_localeconv_r(const char *lc_monetary, const char *lc_numeric, struct lconv *output)
void explicit_bzero(void *buf, size_t len)
int int int int pg_sprintf(char *str, const char *fmt,...) pg_attribute_printf(2
void get_etc_path(const char *my_exec_path, char *ret_path)
Definition path.c:928
void canonicalize_path_enc(char *path, int encoding)
Definition path.c:344
int pclose_check(FILE *stream)
Definition exec.c:392
void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg)
int pgsocket
Definition port.h:29
void set_pglocale_pgservice(const char *argv0, const char *app)
Definition exec.c:430
void pg_strong_random_init(void)
int inet_aton(const char *cp, struct in_addr *addr)
Definition inet_aton.c:58
bool path_contains_parent_reference(const char *path)
Definition path.c:577
void make_native_path(char *filename)
Definition path.c:236
static unsigned char pg_ascii_tolower(unsigned char ch)
Definition port.h:189
char * make_absolute_path(const char *path)
Definition path.c:824
unsigned char pg_tolower(unsigned char ch)
char * mkdtemp(char *path)
Definition mkdtemp.c:286
unsigned int socklen_t
Definition port.h:40
const char * get_progname(const char *argv0)
Definition path.c:669
char * first_dir_separator(const char *filename)
Definition path.c:110
int timingsafe_bcmp(const void *b1, const void *b2, size_t n)
bool rmtree(const char *path, bool rmtopdir)
Definition rmtree.c:50
void get_doc_path(const char *my_exec_path, char *ret_path)
Definition path.c:991
int find_other_exec(const char *argv0, const char *target, const char *versionstr, char *retpath)
Definition exec.c:311
static unsigned char pg_ascii_toupper(unsigned char ch)
Definition port.h:178
int pg_get_encoding_from_locale(const char *ctype, bool write_message)
Definition chklocale.c:301
char * pg_strerror(int errnum)
Definition strerror.c:35
int int int int int int int int pg_printf(const char *fmt,...) pg_attribute_printf(1
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)
Definition path.c:1000
void get_pkginclude_path(const char *my_exec_path, char *ret_path)
Definition path.c:946
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
void qsort_interruptible(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg)
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)
Definition strlcat.c:34
bool has_drive_prefix(const char *path)
Definition path.c:94
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition strlcpy.c:45
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
void get_includeserver_path(const char *my_exec_path, char *ret_path)
Definition path.c:955
char ** pgfnames(const char *path)
Definition pgfnames.c:37
void pg_localeconv_free(struct lconv *lconv)
off_t pgoff_t
Definition port.h:422
int getpeereid(int sock, uid_t *uid, gid_t *gid)
Definition getpeereid.c:33
static int fb(int x)
char * s1
char * s2
static int cmp(const chr *x, const chr *y, size_t len)
float pg_strtof(const char *nptr, char **endptr)
Definition strtof.c:30
const char * type
int gid_t
Definition win32_port.h:235
int pgreadlink(const char *path, char *buf, size_t size)
int pgsymlink(const char *oldpath, const char *newpath)
int uid_t
Definition win32_port.h:234