1 /*-------------------------------------------------------------------------
4 * Header for /port compatibility functions.
6 * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
9 * $Id: port.h,v 1.14 2003/09/13 14:49:51 momjian Exp $
11 *-------------------------------------------------------------------------
14 #if !defined(_MSC_VER) && !defined(__BORLANDC__)
20 /* Portable path handling for Unix/Win32 */
21 extern bool is_absolute_path(const char *filename);
22 extern char *first_path_separator(const char *filename);
23 extern char *last_path_separator(const char *filename);
24 extern char *get_progname(char *argv0);
26 extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
28 #if defined(bsdi) || defined(netbsd)
29 extern int fseeko(FILE *stream, off_t offset, int whence);
30 extern off_t ftello(FILE *stream);
35 * Win32 doesn't have reliable rename/unlink during concurrent access
38 extern int pgrename(const char *from, const char *to);
39 extern int pgunlink(const char *path);
41 #define rename(from, to) pgrename(from, to)
42 #define unlink(path) pgunlink(path)
45 extern int copydir(char *fromdir, char *todir);
47 /* Last parameter not used */
48 extern int gettimeofday(struct timeval * tp, struct timezone * tzp);
53 * Win32 requires a special close for sockets and pipes, while on Unix
54 * close() does them all.
56 #define closesocket close
60 * Default "extern" declarations or macro substitutes for library routines.
61 * When necessary, these routines are provided by files in src/port/.
64 extern char *crypt(const char *key, const char *setting);
68 #define fseeko(a, b, c) fseek((a), (b), (c))
69 #define ftello(a) ftell((a))
73 extern int getopt(int nargc, char *const * nargv, const char *ostr);
77 extern int isinf(double x);
80 #if !defined(HAVE_GETHOSTNAME) && defined(KRB4)
81 extern int gethostname(char *name, int namelen);
85 extern double rint(double x);
88 #ifndef HAVE_INET_ATON
89 #if !defined(_MSC_VER) && !defined(__BORLANDC__)
90 #include <netinet/in.h>
91 #include <arpa/inet.h>
93 extern int inet_aton(const char *cp, struct in_addr * addr);
96 #ifndef HAVE_STRCASECMP
97 extern int strcasecmp(char *s1, char *s2);
101 extern char *strdup(char const *);
105 extern long random(void);
109 extern void srandom(unsigned int seed);
113 extern char *pqStrerror(int errnum, char *strerrbuf, size_t buflen);
116 extern int pqGetpwuid(uid_t uid, struct passwd * resultbuf, char *buffer,
117 size_t buflen, struct passwd **result);
120 extern int pqGethostbyname(const char *name,
121 struct hostent *resultbuf,
122 char *buffer, size_t buflen,
123 struct hostent **result,