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