*
* Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.6 1999/10/24 20:42:27 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.7 1999/10/25 03:07:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
void ShutdownXLOG(void);
void CreateCheckPoint(bool shutdown);
-char XLogDir[MAXPGPATH+1];
-char ControlFilePath[MAXPGPATH+1];
+char XLogDir[MAXPGPATH];
+char ControlFilePath[MAXPGPATH];
uint32 XLOGbuffers = 0;
XLogRecPtr MyLastRecPtr = {0, 0};
bool StopIfError = false;
#define XLogFileSize (XLogLastSeg * XLogSegSize)
#define XLogFileName(path, log, seg) \
- sprintf(path, "%.*s%c%08X%08X", \
- MAXPGPATH, XLogDir, SEP_CHAR, log, seg)
+ snprintf(path, MAXPGPATH, "%s%c%08X%08X", \
+ XLogDir, SEP_CHAR, log, seg)
#define PrevBufIdx(curridx) \
((curridx == 0) ? XLogCtl->XLogCacheBlck : (curridx - 1))
static int
XLogFileInit(uint32 log, uint32 seg)
{
- char path[MAXPGPATH+1];
+ char path[MAXPGPATH];
int fd;
XLogFileName(path, log, seg);
static int
XLogFileOpen(uint32 log, uint32 seg, bool econt)
{
- char path[MAXPGPATH+1];
+ char path[MAXPGPATH];
int fd;
XLogFileName(path, log, seg);
readId++;
}
{
- char path[MAXPGPATH+1];
+ char path[MAXPGPATH];
XLogFileName(path, readId, readSeg);
unlink(path);
* Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.69 1999/10/06 21:58:02 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.70 1999/10/25 03:07:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*/
if (IsUnderPostmaster || xloginit)
{
- sprintf(XLogDir, "%s%cpg_xlog", DataDir, SEP_CHAR);
- sprintf(ControlFilePath, "%s%cpg_control", DataDir, SEP_CHAR);
+ snprintf(XLogDir, MAXPGPATH, "%s%cpg_xlog",
+ DataDir, SEP_CHAR);
+ snprintf(ControlFilePath, MAXPGPATH, "%s%cpg_control",
+ DataDir, SEP_CHAR);
}
if (IsUnderPostmaster && xloginit)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.41 1999/09/24 00:24:17 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.42 1999/10/25 03:07:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
{
Oid db_id;
int4 user_id;
- char buf[512];
+ char buf[MAXPGPATH + 100];
char *lp,
- loc[512];
+ loc[MAXPGPATH];
/*
* If this call returns, the database does not exist and we're allowed
{
if (*(dbpath + strlen(dbpath) - 1) == SEP_CHAR)
*(dbpath + strlen(dbpath) - 1) = '\0';
- snprintf(loc, 512, "%s%c%s", dbpath, SEP_CHAR, dbname);
+ snprintf(loc, sizeof(loc), "%s%c%s", dbpath, SEP_CHAR, dbname);
}
else
strcpy(loc, dbname);
if (mkdir(lp, S_IRWXU) != 0)
elog(ERROR, "Unable to create database directory '%s'", lp);
- snprintf(buf, 512, "%s %s%cbase%ctemplate1%c* %s",
+ snprintf(buf, sizeof(buf), "%s %s%cbase%ctemplate1%c* '%s'",
COPY_CMD, DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR, lp);
system(buf);
- snprintf(buf, 512,
+ snprintf(buf, sizeof(buf),
"insert into pg_database (datname, datdba, encoding, datpath)"
" values ('%s', '%d', '%d', '%s');", dbname, user_id, encoding,
loc);
int4 user_id;
Oid db_id;
char *path,
- dbpath[MAXPGPATH + 1],
- buf[MAXPGPATH + 50];
+ dbpath[MAXPGPATH],
+ buf[MAXPGPATH + 100];
Relation pgdbrel;
HeapScanDesc pgdbscan;
ScanKeyData key;
bool use_super;
char *userName;
text *dbtext;
- char path[MAXPGPATH + 1];
+ char path[MAXPGPATH];
userName = GetPgUserName();
utup = SearchSysCacheTuple(USENAME,
stop_vacuum(char *dbpath, char *dbname)
{
#ifdef NOT_USED
- char filename[MAXPGPATH + 1];
+ char filename[MAXPGPATH];
FILE *fp;
int pid;
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqcomm.c,v 1.85 1999/10/23 03:13:22 tgl Exp $
+ * $Id: pqcomm.c,v 1.86 1999/10/25 03:07:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* Stream functions are used for vanilla TCP connection protocol.
*/
-static char sock_path[MAXPGPATH + 1] = "";
+static char sock_path[MAXPGPATH];
+
/* StreamDoUnlink()
* Shutdown routine for backend connection
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.126 1999/10/08 05:36:58 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.127 1999/10/25 03:07:45 tgl Exp $
*
* NOTES
*
/*
* Default Values
*/
-static char Execfile[MAXPATHLEN] = "";
+static char Execfile[MAXPGPATH];
static int ServerSock_INET = INVALID_SOCK; /* stream socket server */
/*
* Set by the -o option
*/
-static char ExtraOptions[MAXPATHLEN] = "";
+static char ExtraOptions[MAXPGPATH];
/*
* These globals control the behavior of the postmaster in case some
}
else
{
- char path[MAXPATHLEN];
+ char path[MAXPGPATH];
FILE *fp;
- sprintf(path, "%s%cbase%ctemplate1%cpg_class",
+ snprintf(path, sizeof(path), "%s%cbase%ctemplate1%cpg_class",
DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR);
#ifndef __CYGWIN32__
fp = AllocateFile(path, "r");
case 'b':
/* Set the backend executable file to use. */
if (!ValidateBinary(optarg))
- strcpy(Execfile, optarg);
+ StrNCpy(Execfile, optarg, MAXPGPATH);
else
{
fprintf(stderr, "%s: invalid backend \"%s\"\n",
{
char *av[ARGV_SIZE * 2];
int ac = 0;
- char execbuf[MAXPATHLEN];
+ char execbuf[MAXPGPATH];
char debugbuf[ARGV_SIZE];
char protobuf[ARGV_SIZE];
char dbbuf[ARGV_SIZE];
* ----------------
*/
- StrNCpy(execbuf, Execfile, MAXPATHLEN);
+ StrNCpy(execbuf, Execfile, MAXPGPATH);
av[ac++] = execbuf;
/*
{
char *av[ARGV_SIZE * 2];
int ac = 0;
- char execbuf[MAXPATHLEN];
+ char execbuf[MAXPGPATH];
char nbbuf[ARGV_SIZE];
char dbbuf[ARGV_SIZE];
StreamClose(ServerSock_UNIX);
#endif
- StrNCpy(execbuf, Execfile, MAXPATHLEN);
+ StrNCpy(execbuf, Execfile, MAXPGPATH);
av[ac++] = execbuf;
av[ac++] = "-d";
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.56 1999/10/06 06:38:04 inoue Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.57 1999/10/25 03:07:47 tgl Exp $
*
*-------------------------------------------------------------------------
*/
else
/* this is work arround only !!! */
{
- char dbpath[MAXPGPATH + 1];
+ char dbpath[MAXPGPATH];
Oid id;
char *tmpPath;
else
/* this is work arround only !!! */
{
- char dbpath[MAXPGPATH + 1];
+ char dbpath[MAXPGPATH];
Oid id;
char *tmpPath;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.135 1999/10/23 03:13:22 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.136 1999/10/25 03:07:48 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
* ----------------
*/
-/*static bool EnableRewrite = true; , never changes why have it*/
CommandDest whereToSendOutput = Debug;
/* Define status buffer needed by PS_SET_STATUS */
static int ShowStats;
static bool IsEmptyQuery = false;
-char relname[80]; /* current relation name */
-
/* note: these declarations had better match tcopprot.h */
DLLIMPORT sigjmp_buf Warn_restart;
static bool EchoQuery = false; /* default don't echo */
time_t tim;
-char pg_pathname[256];
+char pg_pathname[MAXPGPATH];
FILE *StatFp;
/* ----------------
proc_exit(1);
}
BaseInit();
- sprintf(XLogDir, "%s%cpg_xlog", DataDir, SEP_CHAR);
- sprintf(ControlFilePath, "%s%cpg_control", DataDir, SEP_CHAR);
+ snprintf(XLogDir, MAXPGPATH, "%s%cpg_xlog",
+ DataDir, SEP_CHAR);
+ snprintf(ControlFilePath, MAXPGPATH, "%s%cpg_control",
+ DataDir, SEP_CHAR);
StartupXLOG();
}
SetCharSet();
#endif
+ /* On some systems our dynloader code needs the executable's pathname */
if (FindExec(pg_pathname, argv[0], "postgres") < 0)
elog(FATAL, "%s: could not locate executable, bailing out...",
argv[0]);
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.135 $ $Date: 1999/10/23 03:13:22 $\n");
+ puts("$Revision: 1.136 $ $Date: 1999/10/25 03:07:48 $\n");
}
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/filename.c,v 1.22 1999/07/17 20:17:55 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/filename.c,v 1.23 1999/10/25 03:07:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* (shexpand)
*/
- str = (char *) palloc(MAXPATHLEN * sizeof(*str));
+ str = (char *) palloc(MAXPGPATH);
str[0] = '\0';
if (file[0] == '~')
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.49 1999/10/06 21:58:09 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.50 1999/10/25 03:07:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
if (OutputFileName[0])
{
- OutputFileName[MAXPGPATH - 1] = '\0';
if ((fd = open(OutputFileName, O_CREAT | O_APPEND | O_WRONLY,
0666)) < 0)
elog(FATAL, "DebugFileOpen: open of %s: %m",
fd = fileno(stderr);
if (fcntl(fd, F_GETFD, 0) < 0)
{
- sprintf(OutputFileName, "%s/pg.errors.%d", DataDir, (int) MyProcPid);
+ snprintf(OutputFileName, MAXPGPATH, "%s%cpg.errors.%d",
+ DataDir, SEP_CHAR, (int) MyProcPid);
fd = open(OutputFileName, O_CREAT | O_APPEND | O_WRONLY, 0666);
}
if (fd < 0)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.51 1999/10/06 21:58:10 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.52 1999/10/25 03:07:51 tgl Exp $
*
* NOTES
* InitPostgres() is the function called from PostgresMain
InitMyDatabaseInfo(char *name)
{
char *path,
- myPath[MAXPGPATH + 1];
+ myPath[MAXPGPATH];
SetDatabaseName(name);
GetRawDatabaseInfo(name, &MyDatabaseId, myPath);
VerifySystemDatabase()
{
char *reason;
-
/* Failure reason returned by some function. NULL if no failure */
int fd;
- char errormsg[1000];
+ char errormsg[MAXPGPATH+100];
errormsg[0] = '\0';
#else
if ((fd = open(DataDir, O_RDONLY | O_DIROPEN, 0)) == -1)
#endif
- sprintf(errormsg, "Database system does not exist. "
- "PGDATA directory '%s' not found.\n\tNormally, you "
- "create a database system by running initdb.",
- DataDir);
+ snprintf(errormsg, sizeof(errormsg),
+ "Database system does not exist. "
+ "PGDATA directory '%s' not found.\n\tNormally, you "
+ "create a database system by running initdb.",
+ DataDir);
else
{
close(fd);
ValidatePgVersion(DataDir, &reason);
if (reason != NULL)
- sprintf(errormsg,
- "InitPostgres could not validate that the database"
- " system version is compatible with this level of"
- " Postgres.\n\tYou may need to run initdb to create"
- " a new database system.\n\t%s", reason);
+ snprintf(errormsg, sizeof(errormsg),
+ "InitPostgres could not validate that the database"
+ " system version is compatible with this level of"
+ " Postgres.\n\tYou may need to run initdb to create"
+ " a new database system.\n\t%s", reason);
}
if (errormsg[0] != '\0')
elog(FATAL, errormsg);
/* Failure reason returned by some function. NULL if no failure */
char *reason;
int fd;
- char errormsg[1000];
+ char errormsg[MAXPGPATH+100];
name = DatabaseName;
myPath = DatabasePath;
#else
if ((fd = open(myPath, O_RDONLY | O_DIROPEN, 0)) == -1)
#endif
- sprintf(errormsg,
- "Database '%s' does not exist."
- "\n\tWe know this because the directory '%s' does not exist."
- "\n\tYou can create a database with the SQL command"
- " CREATE DATABASE.\n\tTo see what databases exist,"
- " look at the subdirectories of '%s/base/'.",
- name, myPath, DataDir);
+ snprintf(errormsg, sizeof(errormsg),
+ "Database '%s' does not exist."
+ "\n\tWe know this because the directory '%s' does not exist."
+ "\n\tYou can create a database with the SQL command"
+ " CREATE DATABASE.\n\tTo see what databases exist,"
+ " look at the subdirectories of '%s/base/'.",
+ name, myPath, DataDir);
else
{
close(fd);
ValidatePgVersion(myPath, &reason);
if (reason != NULL)
- sprintf(errormsg,
- "InitPostgres could not validate that the database"
- " version is compatible with this level of Postgres"
- "\n\teven though the database system as a whole"
- " appears to be at a compatible level."
- "\n\tYou may need to recreate the database with SQL"
- " commands DROP DATABASE and CREATE DATABASE."
- "\n\t%s", reason);
+ snprintf(errormsg, sizeof(errormsg),
+ "InitPostgres could not validate that the database"
+ " version is compatible with this level of Postgres"
+ "\n\teven though the database system as a whole"
+ " appears to be at a compatible level."
+ "\n\tYou may need to recreate the database with SQL"
+ " commands DROP DATABASE and CREATE DATABASE."
+ "\n\t%s", reason);
else
{
rc = chdir(myPath);
if (rc < 0)
- sprintf(errormsg,
- "InitPostgres unable to change "
- "current directory to '%s', errno = %s (%d).",
- myPath, strerror(errno), errno);
+ snprintf(errormsg, sizeof(errormsg),
+ "InitPostgres unable to change "
+ "current directory to '%s', errno = %s (%d).",
+ myPath, strerror(errno), errno);
else
errormsg[0] = '\0';
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.30 1999/09/24 00:25:04 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.31 1999/10/25 03:07:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
{
Oid dbowner,
dbid;
- char dbpath[MAXPGPATH + 1];
+ char dbpath[MAXPGPATH];
text *dbtext;
Relation dbrel;
owner = palloc(sizeof(Oid));
*owner = dbowner;
- path = palloc(strlen(dbpath) + 1);
- strcpy(path, dbpath);
+ path = pstrdup(dbpath); /* doesn't do the right thing! */
return FALSE;
} /* GetDatabaseInfo() */
char *
ExpandDatabasePath(char *dbpath)
{
- char *path;
+ char buf[MAXPGPATH];
char *cp;
- char buf[MAXPGPATH + 1];
+ char *envvar;
+ int len;
+
+ if (strlen(dbpath) >= MAXPGPATH)
+ return NULL; /* ain't gonna fit nohow */
/* leading path delimiter? then already absolute path */
if (*dbpath == SEP_CHAR)
{
#ifdef ALLOW_ABSOLUTE_DBPATHS
cp = strrchr(dbpath, SEP_CHAR);
- strncpy(buf, dbpath, (cp - dbpath));
- sprintf(&buf[cp - dbpath], "%cbase%c%s", SEP_CHAR, SEP_CHAR, (cp + 1));
+ len = cp - dbpath;
+ strncpy(buf, dbpath, len);
+ snprintf(&buf[len], MAXPGPATH-len, "%cbase%c%s",
+ SEP_CHAR, SEP_CHAR, (cp + 1));
#else
return NULL;
#endif
}
/* path delimiter somewhere? then has leading environment variable */
- else if (strchr(dbpath, SEP_CHAR) != NULL)
+ else if ((cp = strchr(dbpath, SEP_CHAR)) != NULL)
{
- cp = strchr(dbpath, SEP_CHAR);
- strncpy(buf, dbpath, (cp - dbpath));
- buf[cp - dbpath] = '\0';
- path = getenv(buf);
+ len = cp - dbpath;
+ strncpy(buf, dbpath, len);
+ buf[len] = '\0';
+ envvar = getenv(buf);
/*
* problem getting environment variable? let calling routine
* handle it
*/
- if (path == NULL)
- return path;
+ if (envvar == NULL)
+ return envvar;
- sprintf(buf, "%s%cbase%c%s", path, SEP_CHAR, SEP_CHAR, (cp + 1));
+ snprintf(buf, sizeof(buf), "%s%cbase%c%s",
+ envvar, SEP_CHAR, SEP_CHAR, (cp + 1));
}
- /* no path delimiter? then add the default path prefixes */
else
- sprintf(buf, "%s%cbase%c%s", DataDir, SEP_CHAR, SEP_CHAR, dbpath);
-
- path = palloc(strlen(buf) + 1);
- strcpy(path, buf);
+ {
+ /* no path delimiter? then add the default path prefix */
+ snprintf(buf, sizeof(buf), "%s%cbase%c%s",
+ DataDir, SEP_CHAR, SEP_CHAR, dbpath);
+ }
- return path;
+ return pstrdup(buf);
} /* ExpandDatabasePath() */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.193 1999/10/23 01:31:32 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.194 1999/10/25 03:07:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include <windows.h>
#include <io.h>
#else
-#include <sys/param.h> /* for MAXPATHLEN */
#include <sys/ioctl.h>
#include <unistd.h>
#endif
#define open(x,y,z) _open(x,y,z)
#define strcasecmp(x,y) stricmp(x,y)
#define pqsignal(x,y)
-#define MAXPATHLEN MAX_PATH
#define R_OK 0
/* getopt is not in the standard includes on Win32 */
bool from;
/* The direction of the copy is from a file to a table. */
- char file[MAXPATHLEN + 1];
+ char file[MAXPGPATH];
/* The pathname of the file from/to which we copy */
char table[NAMEDATALEN];
/* #define NO_SECURITY */
/* #define OLD_REWRITE */
+/*
+ * MAXPGPATH: standard size of a pathname buffer in Postgres (hence,
+ * maximum usable pathname length is one less).
+ *
+ * We'd use a standard system header symbol for this, if there weren't
+ * so many to choose from: MAXPATHLEN, _POSIX_PATH_MAX, MAX_PATH, PATH_MAX
+ * are all defined by different "standards", and often have different
+ * values on the same platform! So we just punt and use a reasonably
+ * generous setting here.
+ */
+#define MAXPGPATH 1024
+
/*
*------------------------------------------------------------------------
* The following is set using configure.
-#include <limits.h> /* For _POSIX_PATH_MAX */
-
-#ifndef MAXPATHLEN
-#define MAXPATHLEN _POSIX_PATH_MAX
-#endif
-
#ifndef NOFILE
#define NOFILE NOFILES_MIN
#endif
#define NEED_SIG_JMP
#define USES_WINSOCK
#define NOFILE 100
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 250
-#endif
*
* Copyright (c) 1995, Regents of the University of California
*
- * $Id: postgres.h,v 1.27 1999/10/23 03:13:30 tgl Exp $
+ * $Id: postgres.h,v 1.28 1999/10/25 03:07:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* 2) varlena and array types
* 3) TransactionId and CommandId
* 4) genbki macros used by catalog/pg_xxx.h files
- * 5) random CSIGNBIT, MAXPGPATH, STATUS macros
+ * 5) random stuff
*
* ----------------------------------------------------------------
*/
/* msb for char */
#define CSIGNBIT (0x80)
-/* this should probably be somewhere else */
-#define MAXPGPATH 128
-
#define STATUS_OK (0)
#define STATUS_ERROR (-1)
#define STATUS_NOT_FOUND (-2)
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: dynamic_loader.h,v 1.12 1999/07/15 23:04:21 momjian Exp $
+ * $Id: dynamic_loader.h,v 1.13 1999/10/25 03:07:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#define DYNAMIC_LOADER_H
#include <sys/types.h>
-#include <sys/param.h> /* For MAXPATHLEN */
/* we need this include because port files use them */
#include "postgres.h"
typedef struct df_files
{
- char filename[MAXPATHLEN]; /* Full pathname of file */
+ char filename[MAXPGPATH]; /* Full pathname of file */
dev_t device; /* Device file is on */
ino_t inode; /* Inode number of file */
void *handle; /* a handle for pg_dl* functions */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.45 1999/10/22 23:14:50 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.46 1999/10/25 03:07:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
-#ifndef PATH_MAX
-#include <sys/param.h>
-#define PATH_MAX MAXPATHLEN
-#endif
-
#include "miscadmin.h"
#include "nodes/parsenodes.h"
#include "nodes/pg_list.h"
<incl>[^ \t\n]+ { /* got the include file name */
struct _yy_buffer *yb;
struct _include_path *ip;
- char inc_file[PATH_MAX];
+ char inc_file[MAXPGPATH];
yb = mm_alloc(sizeof(struct _yy_buffer));
yyin = NULL;
for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next)
{
- if (strlen(ip->path) + strlen(yytext) + 3 > PATH_MAX)
+ if (strlen(ip->path) + strlen(yytext) + 3 > MAXPGPATH)
{
fprintf(stderr, "Error: Path %s/%s is too long in line %d, skipping.\n", ip->path, yytext, yylineno);
continue;
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.33 1999/08/31 01:37:36 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.34 1999/10/25 03:08:00 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*/
if (realm = getenv("PGREALM"))
{
- char tktbuf[MAXPATHLEN];
+ char tktbuf[MAXPGPATH];
(void) sprintf(tktbuf, "%s@%s", tkt_string(), realm);
krb_set_tkt_string(tktbuf);
krb5_error_code code;
char *realm,
*defname;
- char tktbuf[MAXPATHLEN];
+ char tktbuf[MAXPGPATH];
static krb5_ccache ccache = (krb5_ccache) NULL;
if (ccache)
#define FALSE ((BOOL)0)
#endif
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#else
-#define MAXPATHLEN 255
-#endif
DWORD
GetPrivateProfileString(char *theSection, // section name
size_t theReturnBufferLength, // byte length of return buffer
char *theIniFileName) // pathname of ini file to search
{
- char buf[MAXPATHLEN+1];
+ char buf[MAXPGPATH];
char* ptr = 0;
FILE* aFile = 0;
size_t aLength;
if( ptr == NULL)
{
- if( MAXPATHLEN < j )
- theIniFileName[MAXPATHLEN] = '\0';
+ if( MAXPGPATH-1 < j )
+ theIniFileName[MAXPGPATH-1] = '\0';
sprintf(buf,"%s",theIniFileName);
}
* the file won't be found and thus the default value will be
* returned.
*/
- if( MAXPATHLEN < strlen(ptr) + j )
+ if( MAXPGPATH-1 < strlen(ptr) + j )
{
- if( MAXPATHLEN < strlen(ptr) )
- ptr[MAXPATHLEN] = '\0';
+ if( MAXPGPATH-1 < strlen(ptr) )
+ ptr[MAXPGPATH-1] = '\0';
else
- theIniFileName[MAXPATHLEN-strlen(ptr)] = '\0';
+ theIniFileName[MAXPGPATH-1-strlen(ptr)] = '\0';
}
sprintf( buf, "%s/%s",ptr,theIniFileName );
char *theBuffer, // input buffer
char *theIniFileName) // pathname of ini file to write
{
- char buf[MAXPATHLEN+1];
+ char buf[MAXPGPATH];
char* ptr = 0;
FILE* aFile = 0;
size_t aLength;
if( ptr == NULL)
{
- if( MAXPATHLEN < j )
- theIniFileName[MAXPATHLEN] = '\0';
+ if( MAXPGPATH-1 < j )
+ theIniFileName[MAXPGPATH-1] = '\0';
sprintf(buf,"%s",theIniFileName);
}
// the file won't be found and thus the default value will be
// returned.
//
- if( MAXPATHLEN < strlen(ptr) + j )
+ if( MAXPGPATH-1 < strlen(ptr) + j )
{
- if( MAXPATHLEN < strlen(ptr) )
- ptr[MAXPATHLEN] = '\0';
+ if( MAXPGPATH-1 < strlen(ptr) )
+ ptr[MAXPGPATH-1] = '\0';
else
- theIniFileName[MAXPATHLEN-strlen(ptr)] = '\0';
+ theIniFileName[MAXPGPATH-1-strlen(ptr)] = '\0';
}
sprintf( buf, "%s/%s",ptr,theIniFileName );
// Constants ---------------------------------------------------------------
#define MIN(x,y) ((x) < (y) ? (x) : (y))
-#define MAXPATHLEN (255+1) // Max path length
#define MAXKEYLEN (15+1) // Max keyword length
#define MAXDESC (255+1) // Max description length
#define MAXDSNAME (32+1) // Max data source name length
LPCSTR lpszStart;
char aszKey[MAXKEYLEN];
int cbKey;
-char value[MAXPATHLEN];
+char value[MAXPGPATH];
memset(&lpsetupdlg->ci, 0, sizeof(ConnInfo));
// lpsetupdlg->aAttr[iElement].fSupplied = TRUE;
- _fmemcpy(value, lpszStart, MIN(lpsz-lpszStart+1, MAXPATHLEN));
+ _fmemcpy(value, lpszStart, MIN(lpsz-lpszStart+1, MAXPGPATH));
mylog("aszKey='%s', value='%s'\n", aszKey, value);
{
if (hwndParent)
{
- char szBuf[MAXPATHLEN];
- char szMsg[MAXPATHLEN];
+ char szBuf[MAXPGPATH];
+ char szMsg[MAXPGPATH];
LoadString(s_hModule, IDS_BADDSN, szBuf, sizeof(szBuf));
wsprintf(szMsg, szBuf, lpszDSN);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/utils/Attic/version.c,v 1.12 1999/07/17 20:18:55 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/utils/Attic/version.c,v 1.13 1999/10/25 03:08:03 tgl Exp $
*
- * NOTES
- * XXX eventually, should be able to handle version identifiers
- * of length != 4.
- *
- * STANDALONE CODE - do not use error routines as this code is linked with
- * stuff that does not cinterface.a
+ * STANDALONE CODE - do not use error routines as this code is not linked
+ * with any...
*-------------------------------------------------------------------------
*/
#include <sys/types.h>
Destructively change "filepathbuf" to contain the concatenation of "path"
and the name of the version file name.
----------------------------------------------------------------------------*/
- if (strlen(path) > (MAXPGPATH - sizeof(PG_VERFILE) - 1))
+ if ((strlen(path) + 1 + strlen(PG_VERFILE)) >= MAXPGPATH)
*filepathbuf = '\0';
else
sprintf(filepathbuf, "%s%c%s", path, SEP_CHAR, PG_VERFILE);
we can't tell), and return a pointer to that space as <*reason_p>.
-----------------------------------------------------------------------------*/
int fd;
- char version[4];
- char full_path[MAXPGPATH + 1];
+ int nread;
+ char myversion[32];
+ char version[32];
+ char full_path[MAXPGPATH];
PathSetVersionFilePath(path, full_path);
+ sprintf(myversion, "%s.%s\n", PG_RELEASE, PG_VERSION);
+
#ifndef __CYGWIN32__
if ((fd = open(full_path, O_RDONLY, 0)) == -1)
#else
if ((fd = open(full_path, O_RDONLY | O_BINARY, 0)) == -1)
#endif
{
- *reason_p = malloc(200);
+ *reason_p = malloc(100 + strlen(full_path));
sprintf(*reason_p, "File '%s' does not exist or no read permission.", full_path);
}
else
{
- if (read(fd, version, 4) < 4 ||
- !isascii(version[0]) || !isdigit(version[0]) ||
- version[1] != '.' ||
- !isascii(version[2]) || !isdigit(version[2]) ||
- version[3] != '\n')
+ nread = read(fd, version, sizeof(version)-1);
+ if (nread < 4 ||
+ !isdigit(version[0]) ||
+ version[nread-1] != '\n')
{
-
- *reason_p = malloc(200);
+ *reason_p = malloc(100 + strlen(full_path));
sprintf(*reason_p, "File '%s' does not have a valid format "
"for a PG_VERSION file.", full_path);
}
else
{
- if (version[2] != PG_VERSION[0] ||
- version[0] != PG_RELEASE[0])
+ version[nread] = '\0';
+ if (strcmp(version, myversion) != 0)
{
- *reason_p = malloc(200);
+ *reason_p = malloc(200 + strlen(full_path));
sprintf(*reason_p,
- "Version number in file '%s' should be %s.%s, "
- "not %c.%c.",
- full_path,
- PG_RELEASE, PG_VERSION, version[0], version[2]);
+ "Version number in file '%s' should be %s, "
+ "not %s.",
+ full_path, myversion, version);
}
else
*reason_p = NULL;
return *reason_p = NULL.
---------------------------------------------------------------------------*/
int fd;
- char version[4];
- char full_path[MAXPGPATH + 1];
+ char version[32];
+ char full_path[MAXPGPATH];
PathSetVersionFilePath(path, full_path);
+ sprintf(version, "%s.%s\n", PG_RELEASE, PG_VERSION);
+
#ifndef __CYGWIN32__
fd = open(full_path, O_WRONLY | O_CREAT | O_EXCL, 0666);
#else
{
int rc; /* return code from some function we call */
- version[0] = PG_RELEASE[0];
- version[1] = '.';
- version[2] = PG_VERSION[0];
- version[3] = '\n';
- rc = write(fd, version, 4);
- if (rc != 4)
+ rc = write(fd, version, strlen(version));
+ if (rc != strlen(version))
{
*reason_p = malloc(100 + strlen(full_path));
sprintf(*reason_p,