Rename find_my_binary/find_other_binary to
find_my_exec/find_other_exec(). Remove passing of progname to these functions as they can find that out from argv[0], which they already have. Make get_progname return const char *, and update all progname variables to be const char *.
This commit is contained in:
parent
3bfd4d9284
commit
b1ffacddfc
|
@ -37,7 +37,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.384 2004/05/12 03:48:42 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.385 2004/05/12 13:38:39 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
*
|
*
|
||||||
|
@ -172,7 +172,7 @@ int MaxBackends;
|
||||||
int ReservedBackends;
|
int ReservedBackends;
|
||||||
|
|
||||||
|
|
||||||
static char *progname = NULL;
|
static const char *progname = NULL;
|
||||||
|
|
||||||
/* The socket(s) we're listening to. */
|
/* The socket(s) we're listening to. */
|
||||||
#define MAXLISTEN 10
|
#define MAXLISTEN 10
|
||||||
|
@ -412,7 +412,7 @@ PostmasterMain(int argc, char *argv[])
|
||||||
|
|
||||||
*original_extraoptions = '\0';
|
*original_extraoptions = '\0';
|
||||||
|
|
||||||
progname = argv[0];
|
progname = get_progname(argv[0]);
|
||||||
|
|
||||||
IsPostmasterEnvironment = true;
|
IsPostmasterEnvironment = true;
|
||||||
|
|
||||||
|
@ -692,7 +692,7 @@ PostmasterMain(int argc, char *argv[])
|
||||||
/*
|
/*
|
||||||
* On some systems our dynloader code needs the executable's pathname.
|
* On some systems our dynloader code needs the executable's pathname.
|
||||||
*/
|
*/
|
||||||
if (find_my_binary(pg_pathname, argv[0], "postgres") < 0)
|
if (find_my_exec(pg_pathname, argv[0]) < 0)
|
||||||
ereport(FATAL,
|
ereport(FATAL,
|
||||||
(errmsg("%s: could not locate postgres executable",
|
(errmsg("%s: could not locate postgres executable",
|
||||||
progname)));
|
progname)));
|
||||||
|
@ -3222,7 +3222,7 @@ CreateOptsFile(int argc, char *argv[])
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (find_my_binary(fullprogname, argv[0], "postmaster") < 0)
|
if (find_my_exec(fullprogname, argv[0]) < 0)
|
||||||
{
|
{
|
||||||
elog(LOG, "could not locate postmaster");
|
elog(LOG, "could not locate postmaster");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.403 2004/05/11 21:57:14 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.404 2004/05/12 13:38:40 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* this is the "main" module of the postgres backend and
|
* this is the "main" module of the postgres backend and
|
||||||
|
@ -2083,7 +2083,7 @@ assign_max_stack_depth(int newval, bool doit, GucSource source)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(char *progname)
|
usage(const char *progname)
|
||||||
{
|
{
|
||||||
printf(gettext("%s is the PostgreSQL stand-alone backend. It is not\nintended to be used by normal users.\n\n"), progname);
|
printf(gettext("%s is the PostgreSQL stand-alone backend. It is not\nintended to be used by normal users.\n\n"), progname);
|
||||||
|
|
||||||
|
@ -2649,7 +2649,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||||
* On some systems our dynloader code needs the executable's
|
* On some systems our dynloader code needs the executable's
|
||||||
* pathname. (If under postmaster, this was done already.)
|
* pathname. (If under postmaster, this was done already.)
|
||||||
*/
|
*/
|
||||||
if (find_my_binary(pg_pathname, argv[0], "postgres") < 0)
|
if (find_my_exec(pg_pathname, argv[0]) < 0)
|
||||||
ereport(FATAL,
|
ereport(FATAL,
|
||||||
(errmsg("%s: could not locate postgres executable",
|
(errmsg("%s: could not locate postgres executable",
|
||||||
argv[0])));
|
argv[0])));
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
* Portions taken from FreeBSD.
|
* Portions taken from FreeBSD.
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.27 2004/05/11 21:57:14 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.28 2004/05/12 13:38:42 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -93,7 +93,7 @@ bool show_setting = false;
|
||||||
|
|
||||||
|
|
||||||
/* internal vars */
|
/* internal vars */
|
||||||
char *progname;
|
const char *progname;
|
||||||
char *postgres;
|
char *postgres;
|
||||||
char *encodingid = "0";
|
char *encodingid = "0";
|
||||||
char *bki_file;
|
char *bki_file;
|
||||||
|
@ -1932,7 +1932,7 @@ main(int argc, char *argv[])
|
||||||
sprintf(pgdenv, "PGDATA=%s", pg_data);
|
sprintf(pgdenv, "PGDATA=%s", pg_data);
|
||||||
putenv(pgdenv);
|
putenv(pgdenv);
|
||||||
|
|
||||||
if ((ret = find_other_binary(backendbin, argv[0], progname, "postgres",
|
if ((ret = find_other_exec(backendbin, argv[0], "postgres",
|
||||||
PG_VERSIONSTR)) < 0)
|
PG_VERSIONSTR)) < 0)
|
||||||
{
|
{
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
|
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
|
||||||
* licence: BSD
|
* licence: BSD
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.14 2004/03/22 15:34:22 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.15 2004/05/12 13:38:43 momjian Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ main(int argc, char *argv[])
|
||||||
char ckpttime_str[128];
|
char ckpttime_str[128];
|
||||||
char sysident_str[32];
|
char sysident_str[32];
|
||||||
char *strftime_fmt = "%c";
|
char *strftime_fmt = "%c";
|
||||||
char *progname;
|
const char *progname;
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
#ifdef ENABLE_NLS
|
#ifdef ENABLE_NLS
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.31 2004/05/11 21:57:14 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.32 2004/05/12 13:38:44 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -39,7 +39,7 @@ int optreset;
|
||||||
#define PG_VERSIONSTR "pg_dump (PostgreSQL) " PG_VERSION "\n"
|
#define PG_VERSIONSTR "pg_dump (PostgreSQL) " PG_VERSION "\n"
|
||||||
|
|
||||||
|
|
||||||
static char *progname;
|
static const char *progname;
|
||||||
|
|
||||||
static void help(void);
|
static void help(void);
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = find_other_binary(pg_dump_bin, argv[0], progname, "pg_dump",
|
if ((ret = find_other_exec(pg_dump_bin, argv[0], "pg_dump",
|
||||||
PG_VERSIONSTR)) < 0)
|
PG_VERSIONSTR)) < 0)
|
||||||
{
|
{
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.17 2004/03/22 16:46:28 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.18 2004/05/12 13:38:44 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -75,7 +75,7 @@ static ControlFileData ControlFile; /* pg_control values */
|
||||||
static uint32 newXlogId,
|
static uint32 newXlogId,
|
||||||
newXlogSeg; /* ID/Segment of new XLOG segment */
|
newXlogSeg; /* ID/Segment of new XLOG segment */
|
||||||
static bool guessed = false; /* T if we had to guess at any values */
|
static bool guessed = false; /* T if we had to guess at any values */
|
||||||
static char *progname;
|
static const char *progname;
|
||||||
|
|
||||||
static bool ReadControlFile(void);
|
static bool ReadControlFile(void);
|
||||||
static void GuessControlValues(void);
|
static void GuessControlValues(void);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
|
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.17 2004/03/21 22:29:11 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.18 2004/05/12 13:38:45 momjian Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef SETTINGS_H
|
#ifndef SETTINGS_H
|
||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
|
@ -42,7 +42,7 @@ typedef struct _psqlSettings
|
||||||
* loop */
|
* loop */
|
||||||
bool cur_cmd_interactive;
|
bool cur_cmd_interactive;
|
||||||
|
|
||||||
char *progname; /* in case you renamed psql */
|
const char *progname; /* in case you renamed psql */
|
||||||
char *inputfile; /* for error reporting */
|
char *inputfile; /* for error reporting */
|
||||||
unsigned lineno; /* also for error reporting */
|
unsigned lineno; /* also for error reporting */
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
|
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.105 2004/05/07 00:24:58 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.106 2004/05/12 13:38:46 momjian Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
|
@ -428,7 +428,7 @@ static char *dequote_file_name(char *text, char quote_char);
|
||||||
void
|
void
|
||||||
initialize_readline(void)
|
initialize_readline(void)
|
||||||
{
|
{
|
||||||
rl_readline_name = pset.progname;
|
rl_readline_name = (char *)pset.progname;
|
||||||
rl_attempted_completion_function = (void *) psql_completion;
|
rl_attempted_completion_function = (void *) psql_completion;
|
||||||
|
|
||||||
rl_basic_word_break_characters = "\t\n@$><=;|&{( ";
|
rl_basic_word_break_characters = "\t\n@$><=;|&{( ";
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* Portions Copyright (c) 2002-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 2002-2003, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.5 2004/01/01 19:27:15 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.6 2004/05/12 13:38:46 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -43,7 +43,7 @@ main(int argc, char *argv[])
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
char *progname;
|
const char *progname;
|
||||||
int optindex;
|
int optindex;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/scripts/createdb.c,v 1.7 2004/01/01 19:27:15 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/scripts/createdb.c,v 1.8 2004/05/12 13:38:47 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -37,7 +37,7 @@ main(int argc, char *argv[])
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
char *progname;
|
const char *progname;
|
||||||
int optindex;
|
int optindex;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.8 2004/03/19 18:58:07 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.9 2004/05/12 13:38:47 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -33,7 +33,7 @@ main(int argc, char *argv[])
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
char *progname;
|
const char *progname;
|
||||||
int optindex;
|
int optindex;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.9 2004/01/09 00:15:11 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.10 2004/05/12 13:38:48 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -39,7 +39,7 @@ main(int argc, char *argv[])
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
char *progname;
|
const char *progname;
|
||||||
int optindex;
|
int optindex;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/scripts/dropdb.c,v 1.8 2004/01/01 19:27:15 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/scripts/dropdb.c,v 1.9 2004/05/12 13:38:48 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -32,7 +32,7 @@ main(int argc, char *argv[])
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
char *progname;
|
const char *progname;
|
||||||
int optindex;
|
int optindex;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.7 2004/03/19 18:58:07 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.8 2004/05/12 13:38:48 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -34,7 +34,7 @@ main(int argc, char *argv[])
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
char *progname;
|
const char *progname;
|
||||||
int optindex;
|
int optindex;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/scripts/dropuser.c,v 1.7 2004/01/01 19:27:15 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/scripts/dropuser.c,v 1.8 2004/05/12 13:38:48 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -32,7 +32,7 @@ main(int argc, char *argv[])
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
char *progname;
|
const char *progname;
|
||||||
int optindex;
|
int optindex;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.5 2004/01/01 19:27:15 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.6 2004/05/12 13:38:48 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -48,7 +48,7 @@ main(int argc, char *argv[])
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
char *progname;
|
const char *progname;
|
||||||
int optindex;
|
int optindex;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/port.h,v 1.29 2004/05/11 21:57:15 momjian Exp $
|
* $PostgreSQL: pgsql/src/include/port.h,v 1.30 2004/05/12 13:38:48 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -25,12 +25,11 @@ extern bool is_absolute_path(const char *filename);
|
||||||
extern char *first_path_separator(const char *filename);
|
extern char *first_path_separator(const char *filename);
|
||||||
extern char *last_path_separator(const char *filename);
|
extern char *last_path_separator(const char *filename);
|
||||||
extern void canonicalize_path(char *path);
|
extern void canonicalize_path(char *path);
|
||||||
extern char *get_progname(char *argv0);
|
extern const char *get_progname(const char *argv0);
|
||||||
|
|
||||||
/* Portable way to find binaries */
|
/* Portable way to find binaries */
|
||||||
extern int find_my_binary(char *full_path, const char *argv0,
|
extern int find_my_exec(char *full_path, const char *argv0);
|
||||||
const char *binary_name);
|
extern int find_other_exec(char *retpath, const char *argv0,
|
||||||
extern int find_other_binary(char *retpath, const char *argv0, const char *progname,
|
|
||||||
char const *target, const char *versionstr);
|
char const *target, const char *versionstr);
|
||||||
|
|
||||||
#if defined(__CYGWIN__) || defined(WIN32)
|
#if defined(__CYGWIN__) || defined(WIN32)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.85 2004/01/28 20:43:03 tgl Exp $ */
|
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.86 2004/05/12 13:38:48 momjian Exp $ */
|
||||||
|
|
||||||
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
|
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
|
||||||
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
|
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
|
||||||
|
@ -119,7 +119,7 @@ main(int argc, char *const argv[])
|
||||||
verbose = false,
|
verbose = false,
|
||||||
out_option = 0;
|
out_option = 0;
|
||||||
struct _include_path *ip;
|
struct _include_path *ip;
|
||||||
char *progname;
|
const char *progname;
|
||||||
|
|
||||||
progname = get_progname(argv[0]);
|
progname = get_progname(argv[0]);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/port/exec.c,v 1.1 2004/05/11 21:57:15 momjian Exp $
|
* $PostgreSQL: pgsql/src/port/exec.c,v 1.2 2004/05/12 13:38:49 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -165,7 +165,7 @@ validate_exec(char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* find_my_binary -- find an absolute path to a valid executable
|
* find_my_exec -- find an absolute path to a valid executable
|
||||||
*
|
*
|
||||||
* The reason we have to work so hard to find an absolute path is that
|
* The reason we have to work so hard to find an absolute path is that
|
||||||
* on some platforms we can't do dynamic loading unless we know the
|
* on some platforms we can't do dynamic loading unless we know the
|
||||||
|
@ -177,13 +177,14 @@ validate_exec(char *path)
|
||||||
* non-threaded binaries, not in library routines.
|
* non-threaded binaries, not in library routines.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
find_my_binary(char *full_path, const char *argv0, const char *binary_name)
|
find_my_exec(char *full_path, const char *argv0)
|
||||||
{
|
{
|
||||||
char buf[MAXPGPATH + 2];
|
char buf[MAXPGPATH + 2];
|
||||||
char *p;
|
char *p;
|
||||||
char *path,
|
char *path,
|
||||||
*startp,
|
*startp,
|
||||||
*endp;
|
*endp;
|
||||||
|
const char *binary_name = get_progname(argv0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First try: use the binary that's located in the
|
* First try: use the binary that's located in the
|
||||||
|
@ -273,14 +274,14 @@ find_my_binary(char *full_path, const char *argv0, const char *binary_name)
|
||||||
* Find our binary directory, then make sure the "target" executable
|
* Find our binary directory, then make sure the "target" executable
|
||||||
* is the proper version.
|
* is the proper version.
|
||||||
*/
|
*/
|
||||||
int find_other_binary(char *retpath, const char *argv0, const char *progname,
|
int find_other_exec(char *retpath, const char *argv0,
|
||||||
char const *target, const char *versionstr)
|
char const *target, const char *versionstr)
|
||||||
{
|
{
|
||||||
char cmd[MAXPGPATH];
|
char cmd[MAXPGPATH];
|
||||||
char line[100];
|
char line[100];
|
||||||
FILE *pgver;
|
FILE *pgver;
|
||||||
|
|
||||||
if (find_my_binary(retpath, argv0, progname) < 0)
|
if (find_my_exec(retpath, argv0) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Trim off program name and keep just directory */
|
/* Trim off program name and keep just directory */
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/port/path.c,v 1.6 2004/05/11 21:57:15 momjian Exp $
|
* $PostgreSQL: pgsql/src/port/path.c,v 1.7 2004/05/12 13:38:49 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -113,8 +113,8 @@ canonicalize_path(char *path)
|
||||||
/*
|
/*
|
||||||
* Extracts the actual name of the program as called.
|
* Extracts the actual name of the program as called.
|
||||||
*/
|
*/
|
||||||
char *
|
const char *
|
||||||
get_progname(char *argv0)
|
get_progname(const char *argv0)
|
||||||
{
|
{
|
||||||
if (!last_path_separator(argv0))
|
if (!last_path_separator(argv0))
|
||||||
return argv0;
|
return argv0;
|
||||||
|
|
Loading…
Reference in New Issue