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