* port.h
* Header for src/port/ compatibility functions.
*
- * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/port.h
extern char *first_dir_separator(const char *filename);
extern char *last_dir_separator(const char *filename);
-extern char *first_path_separator(const char *pathlist);
+extern char *first_path_var_separator(const char *pathlist);
extern void join_path_components(char *ret_path,
const char *head, const char *tail);
extern void canonicalize_path(char *path);
* By making this a macro we avoid needing to include path.c in libpq.
*/
#ifndef WIN32
+#define IS_DIR_SEP(ch) ((ch) == '/')
+
#define is_absolute_path(filename) \
( \
- ((filename)[0] == '/') \
+ IS_DIR_SEP((filename)[0]) \
)
#else
+#define IS_DIR_SEP(ch) ((ch) == '/' || (ch) == '\\')
+
+/*
+ * On Win32, a drive letter _not_ followed by a slash, e.g. 'E:abc', is
+ * relative to the cwd on that drive, or the drive's root directory
+ * if that drive has no cwd. Because the path itself cannot tell us
+ * which is the case, we have to assume the worst, i.e. that it is not
+ * absolute; this check is done by IS_DIR_SEP(filename[2]).
+ */
#define is_absolute_path(filename) \
( \
- ((filename)[0] == '/') || \
- (filename)[0] == '\\' || \
+ IS_DIR_SEP((filename)[0]) || \
(isalpha((unsigned char) ((filename)[0])) && (filename)[1] == ':' && \
- ((filename)[2] == '\\' || (filename)[2] == '/')) \
+ IS_DIR_SEP((filename)[2])) \
)
#endif
#ifdef printf
#undef printf
#endif
+/*
+ * Versions of libintl >= 0.18? try to replace setlocale() with a macro
+ * to their own versions. Remove the macro, if it exists, because it
+ * ends up calling the wrong version when the backend and libintl use
+ * different versions of msvcrt.
+ */
+#if defined(setlocale) && defined(WIN32)
+#undef setlocale
+#endif
extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
extern int
*/
#if defined(WIN32) && !defined(__CYGWIN__)
extern int pgsymlink(const char *oldpath, const char *newpath);
+extern int pgreadlink(const char *path, char *buf, size_t size);
+extern bool pgwin32_is_junction(char *path);
#define symlink(oldpath, newpath) pgsymlink(oldpath, newpath)
+#define readlink(path, buf, size) pgreadlink(path, buf, size)
#endif
-extern void copydir(char *fromdir, char *todir, bool recurse);
-
extern bool rmtree(const char *path, bool rmtopdir);
/*
#define fopen(a,b) pgwin32_fopen(a,b)
#endif
+#ifndef popen
#define popen(a,b) _popen(a,b)
+#endif
+#ifndef pclose
#define pclose(a) _pclose(a)
+#endif
/* New versions of MingW have gettimeofday, old mingw and msvc don't */
#ifndef HAVE_GETTIMEOFDAY
qsort_arg_comparator cmp, void *arg);
/* port/chklocale.c */
-extern int pg_get_encoding_from_locale(const char *ctype);
+extern int pg_get_encoding_from_locale(const char *ctype, bool write_message);
+
+/* port/inet_net_ntop.c */
+extern char *inet_net_ntop(int af, const void *src, int bits,
+ char *dst, size_t size);
+
+/* port/pgcheckdir.c */
+extern int pg_check_dir(const char *dir);
+
+/* port/pgmkdirp.c */
+extern int pg_mkdir_p(char *path, int omode);
#endif /* PG_PORT_H */