aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/variables.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/psql/variables.c')
-rw-r--r--src/bin/psql/variables.c45
1 files changed, 14 insertions, 31 deletions
diff --git a/src/bin/psql/variables.c b/src/bin/psql/variables.c
index 35f84aefdcc..6b4c42786e7 100644
--- a/src/bin/psql/variables.c
+++ b/src/bin/psql/variables.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/variables.c,v 1.10 2003/03/20 06:43:35 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/variables.c,v 1.11 2003/06/28 00:12:40 tgl Exp $
*/
#include "postgres_fe.h"
#include "variables.h"
@@ -33,8 +33,6 @@ CreateVariableSpace(void)
return ptr;
}
-
-
const char *
GetVariable(VariableSpace space, const char *name)
{
@@ -59,14 +57,19 @@ GetVariable(VariableSpace space, const char *name)
return NULL;
}
-
-
bool
GetVariableBool(VariableSpace space, const char *name)
{
- return GetVariable(space, name) != NULL ? true : false;
-}
+ const char *val;
+ val = GetVariable(space, name);
+ if (val == NULL)
+ return false; /* not set -> assume "off" */
+ if (strcmp(val, "off") == 0)
+ return false;
+ /* for backwards compatibility, anything except "off" is taken as "true" */
+ return true;
+}
bool
VariableEquals(VariableSpace space, const char name[], const char value[])
@@ -76,7 +79,6 @@ VariableEquals(VariableSpace space, const char name[], const char value[])
return var && (strcmp(var, value) == 0);
}
-
int
GetVariableNum(VariableSpace space,
const char name[],
@@ -103,7 +105,6 @@ GetVariableNum(VariableSpace space,
return result;
}
-
int
SwitchVariable(VariableSpace space, const char name[], const char *opt, ...)
{
@@ -117,17 +118,16 @@ SwitchVariable(VariableSpace space, const char name[], const char *opt, ...)
va_start(args, opt);
for (result=1; opt && (strcmp(var, opt) != 0); result++)
opt = va_arg(args,const char *);
-
- if (!opt) result = var_notfound;
+ if (!opt)
+ result = VAR_NOTFOUND;
va_end(args);
}
else
- result = var_notset;
+ result = VAR_NOTSET;
return result;
}
-
void
PrintVariables(VariableSpace space)
{
@@ -136,7 +136,6 @@ PrintVariables(VariableSpace space)
printf("%s = '%s'\n", ptr->name, ptr->value);
}
-
bool
SetVariable(VariableSpace space, const char *name, const char *value)
{
@@ -176,16 +175,12 @@ SetVariable(VariableSpace space, const char *name, const char *value)
return previous->next->value ? true : false;
}
-
-
bool
SetVariableBool(VariableSpace space, const char *name)
{
- return SetVariable(space, name, "");
+ return SetVariable(space, name, "on");
}
-
-
bool
DeleteVariable(VariableSpace space, const char *name)
{
@@ -217,15 +212,3 @@ DeleteVariable(VariableSpace space, const char *name)
return true;
}
-
-
-
-void
-DestroyVariableSpace(VariableSpace space)
-{
- if (!space)
- return;
-
- DestroyVariableSpace(space->next);
- free(space);
-}