Fri Dec 23 09:20:57 PST 2005
- Previous message: [Slony1-commit] By cbbrowne: Fix comment per dcramer's comments on mailing list
- Next message: [Slony1-commit] By xfade: Reword drop node purpose, as discussed on IRC with Darcy.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Log Message:
-----------
Use pgport to find the share path. [Hiroshi Saito]
Modified Files:
--------------
slony1-engine/src/slonik:
Makefile (r1.21 -> r1.22)
slonik.c (r1.54 -> r1.55)
-------------- next part --------------
Index: slonik.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slonik/slonik.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -Lsrc/slonik/slonik.c -Lsrc/slonik/slonik.c -u -w -r1.54 -r1.55
--- src/slonik/slonik.c
+++ src/slonik/slonik.c
@@ -23,10 +23,6 @@
#else
#define sleep(x) Sleep(x*1000)
#define vsnprintf _vsnprintf
-#ifdef PGSHARE
-#undef PGSHARE
-#endif
-#define PGSHARE "share"
#define INT64_FORMAT "%I64d"
#endif
#include <errno.h>
@@ -45,7 +41,11 @@
SlonikScript *parser_script = NULL;
int parser_errors = 0;
int current_try_level;
-char m_pgshare[1024];
+
+#ifdef WIN32
+static char myfull_path[MAXPGPATH];
+#endif
+static char share_path[MAXPGPATH];
/*
* Local functions
@@ -115,58 +115,6 @@
}
-#ifdef WIN32
-/*
- * Attempt to locate share directory. Will add to path of exe,
- * except when the exe is in a "bin" directory, in which case
- * it goes to ../share.
- * This is a very simple view of things - perhaps it needs to be
- * expanded? If so there is more complete code available in the
- * PostgreSQL backend that could be adapted.
- */
-char *
-get_sharepath(const char *path)
-{
- int i;
- char *result;
-
- result = (char *)malloc(MAX_PATH + 1);
- if (!result)
- {
- printf("memory allocation failure.\n");
- exit(1);
- }
-
- memcpy(result, path, strlen(path));
-
- for (i = strlen(path); i >= 0; i--)
- {
- if ((path[i] == '/') || (path[i] == '\\'))
- break;
- result[i] = '\0';
- }
-
- if (!result[0])
- {
- /* Nothing left, so assume subdir of current */
- strcpy(result, PGSHARE);
- return result;
- }
-
- /* Check if directory of exe is "bin" */
- if (strlen(result) >= 3 &&
- !strncasecmp(result + i - 3, "bin", 3) &&
- (result[i] == '/' || result[i] == '\\'))
- {
- /* Strip off bin directory */
- result[i - 3] = 0;
- }
-
- strcat(result, PGSHARE);
- return result;
-}
-#endif
-
/* ----------
* main
* ----------
@@ -200,10 +148,20 @@
if (parser_errors)
usage();
#ifndef WIN32
- strcpy(m_pgshare, PGSHARE);
+ strcpy(share_path, PGSHARE);
#else
- /* This begins to look for share. */
- strcpy(m_pgshare, get_sharepath(argv[0]));
+ /*
+ * We need to find a share directory like PostgreSQL.
+ */
+ if (find_my_exec(argv[0],myfull_path) < 0)
+ {
+ printf("full path was unacquirable. '%s'\n", argv[0]);
+ return -1;
+ }
+ else
+ {
+ get_share_path(myfull_path, share_path);
+ }
#endif
if (optind < argc)
{
@@ -1942,15 +1900,15 @@
/* Load schema, DB version specific */
db_notice_silent = true;
if (load_sql_script(stmt, adminfo,
- "%s/xxid.v%d%d.sql", m_pgshare, use_major, use_minor) < 0
+ "%s/xxid.v%d%d.sql", share_path, use_major, use_minor) < 0
|| load_sql_script(stmt, adminfo,
- "%s/slony1_base.sql", m_pgshare) < 0
+ "%s/slony1_base.sql", share_path) < 0
|| load_sql_script(stmt, adminfo,
- "%s/slony1_base.v%d%d.sql", m_pgshare, use_major, use_minor) < 0
+ "%s/slony1_base.v%d%d.sql", share_path, use_major, use_minor) < 0
|| load_sql_script(stmt, adminfo,
- "%s/slony1_funcs.sql", m_pgshare) < 0
+ "%s/slony1_funcs.sql", share_path) < 0
|| load_sql_script(stmt, adminfo,
- "%s/slony1_funcs.v%d%d.sql", m_pgshare, use_major, use_minor) < 0)
+ "%s/slony1_funcs.v%d%d.sql", share_path, use_major, use_minor) < 0)
{
db_notice_silent = false;
dstring_free(&query);
@@ -2031,9 +1989,9 @@
/* Load schema, DB version specific */
db_notice_silent = true;
if (load_sql_script(stmt, adminfo,
- "%s/slony1_funcs.sql", m_pgshare) < 0
+ "%s/slony1_funcs.sql", share_path) < 0
|| load_sql_script(stmt, adminfo,
- "%s/slony1_funcs.v%d%d.sql", m_pgshare, use_major, use_minor) < 0)
+ "%s/slony1_funcs.v%d%d.sql", share_path, use_major, use_minor) < 0)
{
db_notice_silent = false;
return -1;
Index: Makefile
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slonik/Makefile,v
retrieving revision 1.21
retrieving revision 1.22
diff -Lsrc/slonik/Makefile -Lsrc/slonik/Makefile -u -w -r1.21 -r1.22
--- src/slonik/Makefile
+++ src/slonik/Makefile
@@ -22,9 +22,11 @@
ifeq ($(PORTNAME), win)
PROG = slonik.exe
+LDFLAG = $(LDFLAG) -lpgport
endif
ifeq ($(PORTNAME), win32)
PROG = slonik.exe
+LDFLAG = $(LDFLAG) -lpgport
endif
OBJS = \
- Previous message: [Slony1-commit] By cbbrowne: Fix comment per dcramer's comments on mailing list
- Next message: [Slony1-commit] By xfade: Reword drop node purpose, as discussed on IRC with Darcy.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list