2003-05-15 18:35:30 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* port.h
|
|
|
|
* Header for /port compatibility functions.
|
|
|
|
*
|
2003-08-04 04:40:20 +02:00
|
|
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
2003-05-15 18:35:30 +02:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
2003-08-08 06:52:22 +02:00
|
|
|
* $Id: port.h,v 1.11 2003/08/08 04:52:22 momjian Exp $
|
2003-05-15 18:35:30 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2003-06-24 02:44:29 +02:00
|
|
|
#if !defined(_MSC_VER) && !defined(__BORLANDC__)
|
2003-06-14 16:35:42 +02:00
|
|
|
/* for thread.c */
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <netdb.h>
|
2003-06-24 02:44:29 +02:00
|
|
|
#endif
|
2003-06-14 16:35:42 +02:00
|
|
|
|
2003-05-15 18:35:30 +02:00
|
|
|
/* Portable path handling for Unix/Win32 */
|
2003-08-08 06:52:22 +02:00
|
|
|
extern bool is_absolute_path(const char *filename);
|
|
|
|
extern char *first_path_separator(const char *filename);
|
|
|
|
extern char *last_path_separator(const char *filename);
|
|
|
|
extern char *get_progname(char *argv0);
|
|
|
|
|
|
|
|
extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
|
2003-05-15 18:35:30 +02:00
|
|
|
|
|
|
|
#if defined(bsdi) || defined(netbsd)
|
2003-08-08 06:52:22 +02:00
|
|
|
extern int fseeko(FILE *stream, off_t offset, int whence);
|
|
|
|
extern off_t ftello(FILE *stream);
|
2003-05-15 18:35:30 +02:00
|
|
|
#endif
|
|
|
|
|
2003-05-16 03:57:52 +02:00
|
|
|
#ifdef WIN32
|
2003-05-15 18:35:30 +02:00
|
|
|
/*
|
|
|
|
* Win32 doesn't have reliable rename/unlink during concurrent access
|
|
|
|
*/
|
2003-05-16 03:57:52 +02:00
|
|
|
#ifndef FRONTEND
|
2003-08-08 06:52:22 +02:00
|
|
|
extern int pgrename(const char *from, const char *to);
|
|
|
|
extern int pgunlink(const char *path);
|
2003-08-04 02:43:34 +02:00
|
|
|
|
2003-05-15 18:35:30 +02:00
|
|
|
#define rename(from, to) pgrename(from, to)
|
|
|
|
#define unlink(path) pgunlink(path)
|
|
|
|
#endif
|
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int copydir(char *fromdir, char *todir);
|
|
|
|
|
2003-05-16 06:59:24 +02:00
|
|
|
/* Last parameter not used */
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int gettimeofday(struct timeval * tp, struct timezone * tzp);
|
2003-05-16 03:57:52 +02:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2003-05-15 18:35:30 +02:00
|
|
|
/*
|
|
|
|
* Win32 requires a special close for sockets and pipes, while on Unix
|
|
|
|
* close() does them all.
|
|
|
|
*/
|
2003-08-04 02:43:34 +02:00
|
|
|
#define closesocket close
|
2003-05-15 18:35:30 +02:00
|
|
|
#endif
|
2003-08-04 02:43:34 +02:00
|
|
|
|
2003-05-15 18:35:30 +02:00
|
|
|
/*
|
|
|
|
* Default "extern" declarations or macro substitutes for library routines.
|
|
|
|
* When necessary, these routines are provided by files in src/port/.
|
|
|
|
*/
|
|
|
|
#ifndef HAVE_CRYPT
|
2003-05-16 03:57:52 +02:00
|
|
|
extern char *crypt(const char *key, const char *setting);
|
2003-05-15 18:35:30 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_FSEEKO
|
|
|
|
#define fseeko(a, b, c) fseek((a), (b), (c))
|
|
|
|
#define ftello(a) ftell((a))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_GETOPT
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int getopt(int nargc, char *const * nargv, const char *ostr);
|
2003-05-15 18:35:30 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_ISINF
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int isinf(double x);
|
2003-05-15 18:35:30 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(HAVE_GETHOSTNAME) && defined(KRB4)
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int gethostname(char *name, int namelen);
|
2003-05-15 18:35:30 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_RINT
|
|
|
|
extern double rint(double x);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_INET_ATON
|
2003-06-12 10:15:29 +02:00
|
|
|
#if !defined(_MSC_VER) && !defined(__BORLANDC__)
|
2003-08-04 02:43:34 +02:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
2003-06-12 10:15:29 +02:00
|
|
|
#endif
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int inet_aton(const char *cp, struct in_addr * addr);
|
2003-05-15 18:35:30 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_STRCASECMP
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int strcasecmp(char *s1, char *s2);
|
2003-05-15 18:35:30 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_STRDUP
|
|
|
|
extern char *strdup(char const *);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_RANDOM
|
|
|
|
extern long random(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_SRANDOM
|
|
|
|
extern void srandom(unsigned int seed);
|
|
|
|
#endif
|
2003-06-14 16:35:42 +02:00
|
|
|
|
|
|
|
/* thread.h */
|
|
|
|
extern char *pqStrerror(int errnum, char *strerrbuf, size_t buflen);
|
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int pqGetpwuid(uid_t uid, struct passwd * resultbuf, char *buffer,
|
|
|
|
size_t buflen, struct passwd ** result);
|
2003-06-14 16:35:42 +02:00
|
|
|
|
|
|
|
extern int pqGethostbyname(const char *name,
|
2003-08-04 02:43:34 +02:00
|
|
|
struct hostent * resbuf,
|
|
|
|
char *buf, size_t buflen,
|
|
|
|
struct hostent ** result,
|
|
|
|
int *herrno);
|