<!--
-$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.265 2004/05/26 18:51:43 momjian Exp $
+$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.266 2004/06/10 22:26:17 momjian Exp $
-->
<Chapter Id="runtime">
</para>
<para>
- The value for <varname>dynamic_library_path</varname> has to be a colon-separated
- list of absolute directory names. If a directory name starts
+ The value for <varname>dynamic_library_path</varname> has to be a
+ list of absolute directory names separated by colon or, in windows
+ environments with semi-colon. If a directory name starts
with the special value <literal>$libdir</literal>, the
compiled-in <productname>PostgreSQL</productname> package
library directory is substituted. This where the modules
example:
<programlisting>
dynamic_library_path = '/usr/local/lib/postgresql:/home/my_project/lib:$libdir'
+</programlisting>
+ or, in a windows environment:
+<programlisting>
+dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
</programlisting>
</para>
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.134 2004/05/26 13:56:45 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.135 2004/06/10 22:26:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (dbpath == NULL || dbpath[0] == '\0')
return NULL;
- if (first_path_separator(dbpath))
+ if (first_dir_separator(dbpath))
{
if (!is_absolute_path(dbpath))
ereport(ERROR,
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.73 2004/05/26 18:35:39 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.74 2004/06/10 22:26:19 momjian Exp $
*
*-------------------------------------------------------------------------
*/
AssertArg(name);
- have_slash = (first_path_separator(name) != NULL);
+ have_slash = (first_dir_separator(name) != NULL);
if (!have_slash)
{
if (name[0] != '$')
return pstrdup(name);
- if ((sep_ptr = first_path_separator(name)) == NULL)
+ if ((sep_ptr = first_dir_separator(name)) == NULL)
sep_ptr = name + strlen(name);
if (strlen("$libdir") != sep_ptr - name ||
size_t baselen;
AssertArg(basename != NULL);
- AssertArg(first_path_separator(basename) == NULL);
+ AssertArg(first_dir_separator(basename) == NULL);
AssertState(Dynamic_library_path != NULL);
p = Dynamic_library_path;
char *mangled;
char *full;
- len = strcspn(p, ":");
-
- if (len == 0)
+ piece = first_path_separator(p);
+ if(piece == p)
ereport(ERROR,
(errcode(ERRCODE_INVALID_NAME),
errmsg("zero-length component in parameter \"dynamic_library_path\"")));
+ if(piece == 0)
+ len = strlen(p);
+ else
+ len = piece - p;
+
piece = palloc(len + 1);
strncpy(piece, p, len);
piece[len] = '\0';
* Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD.
*
- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.36 2004/06/10 16:35:16 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.37 2004/06/10 22:26:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* store binary directory */
strcpy(bin_path, backend_exec);
- *last_path_separator(bin_path) = '\0';
+ *last_dir_separator(bin_path) = '\0';
if (!share_path)
{
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/port.h,v 1.41 2004/06/10 16:35:18 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/port.h,v 1.42 2004/06/10 22:26:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool set_noblock(int sock);
/* Portable path handling for Unix/Win32 */
+
+/* Find the location of the first directory separator, return
+ * NULL if not found.
+ */
+extern char *first_dir_separator(const char *filename);
+
+/* Find the location of the last directory separator, return
+ * NULL if not found.
+ */
+extern char *last_dir_separator(const char *filename);
+
+/* Find the location of the first path separator (i.e. ':' on
+ * Unix, ';' on Windows), return NULL if not found.
+ */
extern char *first_path_separator(const char *filename);
-extern char *last_path_separator(const char *filename);
+
extern void canonicalize_path(char *path);
extern const char *get_progname(const char *argv0);
extern void get_share_path(const char *my_exec_path, char *ret_path);
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.21 2004/03/15 16:27:43 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.22 2004/06/10 22:26:21 momjian Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
*tmp = '\0';
}
- tmp = last_path_separator(dbname + offset);
+ tmp = last_dir_separator(dbname + offset);
if (tmp != NULL) /* database name given */
{
realname = strdup(tmp + 1);
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.87 2004/05/17 14:35:34 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.88 2004/06/10 22:26:23 momjian Exp $ */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
strcpy(input_filename, argv[fnr]);
/* take care of relative paths */
- ptr2ext = last_path_separator(input_filename);
+ ptr2ext = last_dir_separator(input_filename);
ptr2ext = (ptr2ext ? strrchr(ptr2ext, '.') : strrchr(input_filename, '.'));
/* no extension? */
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.273 2004/06/08 13:49:23 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.274 2004/06/10 22:26:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*tmp = '\0';
}
- tmp = last_path_separator(conn->dbName + offset);
+ tmp = last_dir_separator(conn->dbName + offset);
if (tmp != NULL) /* database name given */
{
if (conn->dbName)
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/port/exec.c,v 1.15 2004/05/24 22:35:37 momjian Exp $
+ * $PostgreSQL: pgsql/src/port/exec.c,v 1.16 2004/06/10 22:26:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define _(x) gettext(x)
-/* $PATH (or %PATH%) path separator */
-#ifdef WIN32
-#define PATHSEP ';'
-#else
-#define PATHSEP ':'
-#endif
-
#ifndef S_IRUSR /* XXX [TRH] should be in a header */
#define S_IRUSR S_IREAD
#define S_IWUSR S_IWRITE
* it).
*/
/* Does argv0 have a separator? */
- if ((path = last_path_separator(argv0)))
+ if ((path = last_dir_separator(argv0)))
{
if (*++path == '\0')
{
else
startp = endp + 1;
- endp = strchr(startp, PATHSEP);
+ endp = first_path_separator(startp);
if (!endp)
endp = startp + strlen(startp); /* point to end */
return -1;
/* Trim off program name and keep just directory */
- *last_path_separator(retpath) = '\0';
+ *last_dir_separator(retpath) = '\0';
snprintf(retpath + strlen(retpath), MAXPGPATH - strlen(retpath),
"/%s%s", target, EXE);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/port/path.c,v 1.18 2004/06/08 13:49:23 momjian Exp $
+ * $PostgreSQL: pgsql/src/port/path.c,v 1.19 2004/06/10 22:26:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef WIN32
-#define ISSEP(ch) ((ch) == '/')
+#define IS_DIR_SEP(ch) ((ch) == '/')
#else
-#define ISSEP(ch) ((ch) == '/' || (ch) == '\\')
+#define IS_DIR_SEP(ch) ((ch) == '/' || (ch) == '\\')
+#endif
+
+#ifndef WIN32
+#define IS_PATH_SEP(ch) ((ch) == ':')
+#else
+#define IS_PATH_SEP(ch) ((ch) == ';')
#endif
const static char *relative_path(const char *bin_path, const char *other_path);
/* Move to last of consecutive separators or to null byte */
#define MOVE_TO_SEP_END(p) \
{ \
- while (ISSEP((p)[0]) && (ISSEP((p)[1]) || !(p)[1])) \
+ while (IS_DIR_SEP((p)[0]) && (IS_DIR_SEP((p)[1]) || !(p)[1])) \
(p)++; \
}
snprintf(ret_path, MAXPGPATH, "%s/%s", path, p); \
} while (0)
+/*
+ * first_dir_separator
+ */
+char *
+first_dir_separator(const char *filename)
+{
+ char *p;
+
+ for (p = (char *)filename; *p; p++)
+ if (IS_DIR_SEP(*p))
+ return p;
+ return NULL;
+}
+
/*
* first_path_separator
*/
char *p;
for (p = (char *)filename; *p; p++)
- if (ISSEP(*p))
+ if (IS_PATH_SEP(*p))
return p;
return NULL;
}
-
/*
- * last_path_separator
+ * last_dir_separator
*/
char *
-last_path_separator(const char *filename)
+last_dir_separator(const char *filename)
{
char *p, *ret = NULL;
for (p = (char *)filename; *p; p++)
- if (ISSEP(*p))
+ if (IS_DIR_SEP(*p))
ret = p;
return ret;
}
const char *
get_progname(const char *argv0)
{
- if (!last_path_separator(argv0))
+ if (!last_dir_separator(argv0))
return argv0;
else
- return last_path_separator(argv0) + 1;
+ return last_dir_separator(argv0) + 1;
}
break;
/* Win32 filesystem is case insensitive */
- if ((!ISSEP(*bin_path) || !ISSEP(*other_path)) &&
+ if ((!IS_DIR_SEP(*bin_path) || !IS_DIR_SEP(*other_path)) &&
#ifndef WIN32
*bin_path != *other_path)
#else
#endif
break;
- if (ISSEP(*other_path))
+ if (IS_DIR_SEP(*other_path))
other_sep = other_path + 1; /* past separator */
bin_path++;
return NULL;
/* advance past directory name */
- while (!ISSEP(*bin_path) && *bin_path)
+ while (!IS_DIR_SEP(*bin_path) && *bin_path)
bin_path++;
MOVE_TO_SEP_END(bin_path);
if (path[0] == '\0')
return;
- for (p = path + strlen(path) - 1; ISSEP(*p) && p > path; p--)
+ for (p = path + strlen(path) - 1; IS_DIR_SEP(*p) && p > path; p--)
;
- for (; !ISSEP(*p) && p > path; p--)
+ for (; !IS_DIR_SEP(*p) && p > path; p--)
;
*p = '\0';
return;
/* trim off trailing slashes */
if (p > path)
- for (p--; p >= path && ISSEP(*p); p--)
+ for (p--; p >= path && IS_DIR_SEP(*p); p--)
*p = '\0';
}