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