Adjust get_*_path functions to be limited to MAXPGPATH.
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.81 2004/05/24 02:47:44 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.82 2004/05/25 01:00:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* startup error messages to be localized.
*/
+ set_pglocale(argv[0], "postgres");
+
#ifdef WIN32
/*
* Windows uses codepages rather than the environment, so we work around
setlocale(LC_NUMERIC, "C");
setlocale(LC_TIME, "C");
-#ifdef ENABLE_NLS
- bindtextdomain("postgres", LOCALEDIR);
- textdomain("postgres");
-#endif
-
/*
* Skip permission checks if we're just trying to do --help or
* --version; otherwise root will get unhelpful failure messages from
* Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD.
*
- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.32 2004/05/18 03:36:36 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.33 2004/05/25 01:00:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static bool chklocale(const char *locale);
static void setlocales(void);
static void usage(const char *progname);
-static void init_nls(void);
+static void init_nls(const char *argv0);
/*
* Initialized NLS if enabled.
*/
static void
-init_nls(void)
+init_nls(const char *argv0)
{
-#ifdef ENABLE_NLS
- setlocale(LC_ALL, "");
- bindtextdomain("initdb", LOCALEDIR);
- textdomain("initdb");
-#endif
+ set_pglocale(argv0, "initdb");
}
* environment */
char *subdirs[] =
{"global", "pg_xlog", "pg_clog", "base", "base/1"};
- init_nls();
+ init_nls(argv[0]);
progname = get_progname(argv[0]);
#
# Copyright (c) 1998-2002, PostgreSQL Global Development Group
#
-# $PostgreSQL: pgsql/src/bin/pg_controldata/Makefile,v 1.7 2004/04/30 20:01:39 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_controldata/Makefile,v 1.8 2004/05/25 01:00:23 momjian Exp $
#
#-------------------------------------------------------------------------
override CPPFLAGS += -DFRONTEND
-OBJS= pg_controldata.o pg_crc.o
+OBJS= pg_controldata.o pg_crc.o exec.o
all: submake-libpgport pg_controldata
pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
rm -f $@ && $(LN_S) $< .
+exec.c: % : $(top_srcdir)/src/port/%
+ rm -f $@ && $(LN_S) $< .
+
install: all installdirs
$(INSTALL_PROGRAM) pg_controldata$(X) $(DESTDIR)$(bindir)/pg_controldata$(X)
rm -f $(DESTDIR)$(bindir)/pg_controldata$(X)
clean distclean maintainer-clean:
- rm -f pg_controldata$(X) pg_controldata.o pg_crc.o pg_crc.c
+ rm -f pg_controldata$(X) pg_controldata.o pg_crc.o pg_crc.c exec.c
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
* licence: BSD
*
- * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.15 2004/05/12 13:38:43 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.16 2004/05/25 01:00:23 momjian Exp $
*/
#include "postgres.h"
char *strftime_fmt = "%c";
const char *progname;
- setlocale(LC_ALL, "");
-#ifdef ENABLE_NLS
- bindtextdomain("pg_controldata", LOCALEDIR);
- textdomain("pg_controldata");
-#endif
+ set_pglocale(argv[0], "pg_controldata");
progname = get_progname(argv[0]);
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
-# $PostgreSQL: pgsql/src/bin/pg_dump/Makefile,v 1.51 2004/05/24 01:01:37 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_dump/Makefile,v 1.52 2004/05/25 01:00:24 momjian Exp $
#
#-------------------------------------------------------------------------
OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \
pg_backup_files.o pg_backup_null.o pg_backup_tar.o \
- dumputils.o
-PG_DUMPALL_OBJS = exec.o
+ dumputils.o exec.o
EXTRA_OBJS = $(top_builddir)/src/backend/parser/keywords.o
pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
$(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
-pg_dumpall: pg_dumpall.o dumputils.o $(PG_DUMPALL_OBJS) $(libpq_builddir)/libpq.a
- $(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(PG_DUMPALL_OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
+pg_dumpall: pg_dumpall.o dumputils.o exec.o $(libpq_builddir)/libpq.a
+ $(CC) $(CFLAGS) pg_dumpall.o dumputils.o exec.o $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
# We need our own build of exec.c so it gets made with -DFRONTEND
exec.c: % : $(top_srcdir)/src/port/%
rm -f $(addprefix $(DESTDIR)$(bindir)/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X))
clean distclean maintainer-clean:
- rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) $(PG_DUMPALL_OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o exec.c
+ rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o exec.c
* by PostgreSQL
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.370 2004/03/24 03:06:08 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.371 2004/05/25 01:00:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
};
int optindex;
-#ifdef ENABLE_NLS
- setlocale(LC_ALL, "");
- bindtextdomain("pg_dump", LOCALEDIR);
- textdomain("pg_dump");
-#endif
+ set_pglocale(argv[0], "pg_dump");
g_verbose = false;
* Portions Copyright (c) 1994, Regents of the University of California
*
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.34 2004/05/19 21:21:26 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.35 2004/05/25 01:00:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int optindex;
-#ifdef ENABLE_NLS
- setlocale(LC_ALL, "");
- bindtextdomain("pg_dump", LOCALEDIR);
- textdomain("pg_dump");
-#endif
+ set_pglocale(argv[0], "pg_dump");
progname = get_progname(argv[0]);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.56 2004/04/22 02:39:10 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.57 2004/05/25 01:00:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{NULL, 0, NULL, 0}
};
-#ifdef ENABLE_NLS
- setlocale(LC_ALL, "");
- bindtextdomain("pg_dump", LOCALEDIR);
- textdomain("pg_dump");
-#endif
+ set_pglocale(argv[0], "pg_dump");
opts = NewRestoreOptions();
#
# Copyright (c) 1998-2002, PostgreSQL Global Development Group
#
-# $PostgreSQL: pgsql/src/bin/pg_resetxlog/Makefile,v 1.9 2004/05/24 01:01:37 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/pg_resetxlog/Makefile,v 1.10 2004/05/25 01:00:25 momjian Exp $
#
#-------------------------------------------------------------------------
override CPPFLAGS += -DFRONTEND
-OBJS= pg_resetxlog.o pg_crc.o dirmod.o
+OBJS= pg_resetxlog.o pg_crc.o dirmod.o exec.o
all: submake-libpgport pg_resetxlog
pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
rm -f $@ && $(LN_S) $< .
+exec.c: % : $(top_srcdir)/src/port/%
+ rm -f $@ && $(LN_S) $< .
+
install: all installdirs
$(INSTALL_PROGRAM) pg_resetxlog$(X) $(DESTDIR)$(bindir)/pg_resetxlog$(X)
rm -f $(DESTDIR)$(bindir)/pg_resetxlog$(X)
clean distclean maintainer-clean:
- rm -f pg_resetxlog$(X) pg_crc.c dirmod.c $(OBJS)
+ rm -f pg_resetxlog$(X) pg_crc.c dirmod.c exec.c $(OBJS)
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.18 2004/05/12 13:38:44 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.19 2004/05/25 01:00:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int fd;
char path[MAXPGPATH];
- setlocale(LC_ALL, "");
-#ifdef ENABLE_NLS
- bindtextdomain("pg_resetxlog", LOCALEDIR);
- textdomain("pg_resetxlog");
-#endif
+ set_pglocale(argv[0], "pg_resetxlog");
progname = get_progname(argv[0]);
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.93 2004/05/17 14:35:33 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.94 2004/05/25 01:00:26 momjian Exp $
*/
#include "postgres_fe.h"
char *password = NULL;
bool need_pass;
- setlocale(LC_ALL, "");
-#ifdef ENABLE_NLS
- bindtextdomain("psql", LOCALEDIR);
- textdomain("psql");
-#endif
+ set_pglocale(argv[0], "psql");
pset.progname = get_progname(argv[0]);
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
-# $PostgreSQL: pgsql/src/bin/scripts/Makefile,v 1.26 2004/04/26 17:40:48 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/scripts/Makefile,v 1.27 2004/05/25 01:00:27 momjian Exp $
#
#-------------------------------------------------------------------------
PROGRAMS = createdb createlang createuser dropdb droplang dropuser clusterdb vacuumdb
-override CPPFLAGS := -I$(top_srcdir)/src/bin/pg_dump -I$(top_srcdir)/src/bin/psql -I$(libpq_srcdir) $(CPPFLAGS)
+override CPPFLAGS := -DFRONTEND -I$(top_srcdir)/src/bin/pg_dump -I$(top_srcdir)/src/bin/psql -I$(libpq_srcdir) $(CPPFLAGS)
all: submake-libpq submake-backend $(PROGRAMS)
%: %.o
$(CC) $(CFLAGS) $^ $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
-createdb: createdb.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
-createlang: createlang.o common.o print.o mbprint.o
-createuser: createuser.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
-dropdb: dropdb.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
-droplang: droplang.o common.o print.o mbprint.o
-dropuser: dropuser.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
-clusterdb: clusterdb.o common.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
-vacuumdb: vacuumdb.o common.o
+createdb: createdb.o common.o exec.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
+createlang: createlang.o common.o exec.o print.o mbprint.o
+createuser: createuser.o common.o exec.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
+dropdb: dropdb.o common.o exec.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
+droplang: droplang.o common.o exec.o print.o mbprint.o
+dropuser: dropuser.o common.o exec.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
+clusterdb: clusterdb.o common.o exec.o dumputils.o $(top_builddir)/src/backend/parser/keywords.o
+vacuumdb: vacuumdb.o common.o exec.o
+
+exec.c: % : $(top_srcdir)/src/port/%
+ rm -f $@ && $(LN_S) $< .
dumputils.c: % : $(top_srcdir)/src/bin/pg_dump/%
rm -f $@ && $(LN_S) $< .
clean distclean maintainer-clean:
- rm -f $(addsuffix $(X), $(PROGRAMS)) $(addsuffix .o, $(PROGRAMS)) common.o dumputils.o print.o mbprint.o dumputils.c print.c mbprint.c
+ rm -f $(addsuffix $(X), $(PROGRAMS)) $(addsuffix .o, $(PROGRAMS)) common.o dumputils.o print.o mbprint.o dumputils.c exec.c print.c mbprint.c
*
* Portions Copyright (c) 2002-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.6 2004/05/12 13:38:46 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.7 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
char *table = NULL;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "clusterdb", help);
while ((c = getopt_long(argc, argv, "h:p:U:Weqd:at:", long_options, &optindex)) != -1)
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.7 2004/04/19 17:42:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.8 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* Initialized NLS if enabled.
*/
void
-init_nls(void)
+init_nls(const char *argv0)
{
-#ifdef ENABLE_NLS
- setlocale(LC_ALL, "");
- bindtextdomain("pgscripts", LOCALEDIR);
- textdomain("pgscripts");
-#endif
+ set_pglocale(argv0, "pgscripts");
}
const char *get_user_name(const char *progname);
#define _(x) gettext((x))
-void init_nls(void);
+void init_nls(const char *argv0);
typedef void (*help_handler) (const char *);
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/createdb.c,v 1.8 2004/05/12 13:38:47 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/createdb.c,v 1.9 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
PGresult *result;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "createdb", help);
while ((c = getopt_long(argc, argv, "h:p:U:WeqO:D:T:E:", long_options, &optindex)) != -1)
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.9 2004/05/12 13:38:47 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.10 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
PGresult *result;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "createlang", help);
while ((c = getopt_long(argc, argv, "lh:p:U:Wd:L:e", long_options, &optindex)) != -1)
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.10 2004/05/12 13:38:48 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.11 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
PGresult *result;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "createuser", help);
while ((c = getopt_long(argc, argv, "h:p:U:WeqaAdDi:PEN", long_options, &optindex)) != -1)
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/dropdb.c,v 1.9 2004/05/12 13:38:48 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/dropdb.c,v 1.10 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
PGresult *result;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "dropdb", help);
while ((c = getopt_long(argc, argv, "h:p:U:Weqi", long_options, &optindex)) != -1)
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.8 2004/05/12 13:38:48 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.9 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
PGresult *result;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "droplang", help);
while ((c = getopt_long(argc, argv, "lh:p:U:Wd:e", long_options, &optindex)) != -1)
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/dropuser.c,v 1.8 2004/05/12 13:38:48 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/dropuser.c,v 1.9 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
PGresult *result;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "dropuser", help);
while ((c = getopt_long(argc, argv, "h:p:U:Weqi", long_options, &optindex)) != -1)
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.6 2004/05/12 13:38:48 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.7 2004/05/25 01:00:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool verbose = false;
progname = get_progname(argv[0]);
- init_nls();
+ init_nls(argv[0]);
handle_help_version_opts(argc, argv, "vacuumdb", help);
while ((c = getopt_long(argc, argv, "h:p:U:Weqd:zat:fv", long_options, &optindex)) != -1)
* 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.37 2004/05/21 16:06:22 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/port.h,v 1.38 2004/05/25 01:00:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern void get_include_path(const char *my_exec_path, char *ret_path);
extern void get_pkginclude_path(const char *my_exec_path, char *ret_path);
extern void get_pkglib_path(const char *my_exec_path, char *ret_path);
+extern void get_locale_path(const char *my_exec_path, char *ret_path);
+extern void set_pglocale(const char *argv0, const char *app);
/*
* is_absolute_path
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.105 2004/03/15 10:41:26 ishii Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.106 2004/05/25 01:00:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (!already_bound)
{
already_bound = 1;
+ /* No relocatable lookup here because the binary could be anywhere */
bindtextdomain("libpq", LOCALEDIR);
}
# with broken/missing library files.
# IDENTIFICATION
-# $PostgreSQL: pgsql/src/port/Makefile,v 1.13 2004/05/22 02:15:08 tgl Exp $
+# $PostgreSQL: pgsql/src/port/Makefile,v 1.14 2004/05/25 01:00:30 momjian Exp $
#
#-------------------------------------------------------------------------
echo "#define INCLUDEDIR \"$(includedir)\"" >>$@
echo "#define PKGINCLUDEDIR \"$(pkgincludedir)\"" >>$@
echo "#define PKGLIBDIR \"$(pkglibdir)\"" >>$@
+ echo "#define LOCALEDIR \"$(localedir)\"" >>$@
clean distclean maintainer-clean:
rm -f libpgport.a $(LIBOBJS) pg_config_paths.h
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/port/path.c,v 1.11 2004/05/21 20:56:50 tgl Exp $
+ * $PostgreSQL: pgsql/src/port/path.c,v 1.12 2004/05/25 01:00:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
void
get_share_path(const char *my_exec_path, char *ret_path)
{
+ char path[MAXPGPATH];
+
if (relative_path(PGBINDIR, PGSHAREDIR))
{
- StrNCpy(ret_path, my_exec_path, MAXPGPATH);
- trim_directory(ret_path); /* trim off binary */
- trim_directory(ret_path); /* trim off /bin */
- strcat(ret_path, "/share"); /* add /share */
+ StrNCpy(path, my_exec_path, MAXPGPATH);
+ trim_directory(path); /* trim off binary */
+ trim_directory(path); /* trim off /bin */
+ snprintf(ret_path, MAXPGPATH, "%s/share", path);
}
else
StrNCpy(ret_path, PGSHAREDIR, MAXPGPATH);
void
get_etc_path(const char *my_exec_path, char *ret_path)
{
+ char path[MAXPGPATH];
+
if (relative_path(PGBINDIR, SYSCONFDIR))
{
- StrNCpy(ret_path, my_exec_path, MAXPGPATH);
- trim_directory(ret_path);
- trim_directory(ret_path);
- strcat(ret_path, "/etc");
+ StrNCpy(path, my_exec_path, MAXPGPATH);
+ trim_directory(path);
+ trim_directory(path);
+ snprintf(ret_path, MAXPGPATH, "%s/etc", path);
}
else
StrNCpy(ret_path, SYSCONFDIR, MAXPGPATH);
void
get_include_path(const char *my_exec_path, char *ret_path)
{
+ char path[MAXPGPATH];
+
if (relative_path(PGBINDIR, INCLUDEDIR))
{
- StrNCpy(ret_path, my_exec_path, MAXPGPATH);
- trim_directory(ret_path);
- trim_directory(ret_path);
- strcat(ret_path, "/include");
+ StrNCpy(path, my_exec_path, MAXPGPATH);
+ trim_directory(path);
+ trim_directory(path);
+ snprintf(ret_path, MAXPGPATH, "%s/include", path);
}
else
StrNCpy(ret_path, INCLUDEDIR, MAXPGPATH);
void
get_pkginclude_path(const char *my_exec_path, char *ret_path)
{
+ char path[MAXPGPATH];
+
if (relative_path(PGBINDIR, PKGINCLUDEDIR))
{
- StrNCpy(ret_path, my_exec_path, MAXPGPATH);
- trim_directory(ret_path);
- trim_directory(ret_path);
- strcat(ret_path, "/include");
+ StrNCpy(path, my_exec_path, MAXPGPATH);
+ trim_directory(path);
+ trim_directory(path);
+ snprintf(ret_path, MAXPGPATH, "%s/include", path);
}
else
StrNCpy(ret_path, PKGINCLUDEDIR, MAXPGPATH);
void
get_pkglib_path(const char *my_exec_path, char *ret_path)
{
+ char path[MAXPGPATH];
+
if (relative_path(PGBINDIR, PKGLIBDIR))
{
- StrNCpy(ret_path, my_exec_path, MAXPGPATH);
- trim_directory(ret_path);
- trim_directory(ret_path);
- strcat(ret_path, "/lib");
+ StrNCpy(path, my_exec_path, MAXPGPATH);
+ trim_directory(path);
+ trim_directory(path);
+ snprintf(ret_path, MAXPGPATH, "%s/lib", path);
}
else
StrNCpy(ret_path, PKGLIBDIR, MAXPGPATH);
+/*
+ * get_locale_path
+ *
+ * Return locale path, either relative to /bin or hardcoded
+ */
+void
+get_locale_path(const char *my_exec_path, char *ret_path)
+{
+ char path[MAXPGPATH];
+
+ if (relative_path(PGBINDIR, LOCALEDIR))
+ {
+ StrNCpy(path, my_exec_path, MAXPGPATH);
+ trim_directory(path);
+ trim_directory(path);
+ snprintf(ret_path, MAXPGPATH, "%s/share/locale", path);
+ }
+ else
+ StrNCpy(ret_path, LOCALEDIR, MAXPGPATH);
+}
+
+
+
+/*
+ * set_pglocale
+ *
+ * Set application-specific locale
+ *
+ * This function takes an argv[0] rather than a full path.
+ */
+void
+set_pglocale(const char *argv0, const char *app)
+{
+#ifdef ENABLE_NLS
+ char path[MAXPGPATH];
+ char my_exec_path[MAXPGPATH];
+
+ setlocale(LC_ALL, "");
+ if (find_my_exec(argv0, my_exec_path) < 0)
+ return;
+
+ get_locale_path(argv0, path);
+ bindtextdomain(app, path);
+ textdomain(app);
+#endif
+}
+
+
+
/*
* relative_path
*