postgresql/src/bin/psql/variables.h

66 lines
2.0 KiB
C
Raw Normal View History

2000-01-19 00:30:24 +01:00
/*
* psql - the PostgreSQL interactive terminal
*
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
2000-01-19 00:30:24 +01:00
*
* $PostgreSQL: pgsql/src/bin/psql/variables.h,v 1.18 2006/03/05 15:58:52 momjian Exp $
2000-01-19 00:30:24 +01:00
*/
/*
* This implements a sort of variable repository. One could also think of it
* as cheap version of an associative array. In each one of these
* datastructures you can store name/value pairs.
*/
#ifndef VARIABLES_H
#define VARIABLES_H
#define VALID_VARIABLE_CHARS "abcdefghijklmnopqrstuvwxyz"\
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789_"
1999-11-05 00:14:30 +01:00
struct _variable
{
char *name;
char *value;
struct _variable *next;
};
1999-11-05 00:14:30 +01:00
typedef struct _variable *VariableSpace;
VariableSpace CreateVariableSpace(void);
1999-11-05 00:14:30 +01:00
const char *GetVariable(VariableSpace space, const char *name);
2003-08-04 02:43:34 +02:00
bool GetVariableBool(VariableSpace space, const char *name);
bool VariableEquals(VariableSpace space, const char name[], const char *opt);
/* Read numeric variable, or defaultval if it is not set, or faultval if its
2003-08-04 02:43:34 +02:00
* value is not a valid numeric string. If allowtrail is false, this will
* include the case where there are trailing characters after the number.
*/
2003-08-04 02:43:34 +02:00
int GetVariableNum(VariableSpace space,
const char name[],
int defaultval,
int faultval,
bool allowtrail);
2003-08-04 02:43:34 +02:00
/* Find value of variable <name> among NULL-terminated list of alternative
* options. Returns VAR_NOTSET if the variable was not set, VAR_NOTFOUND
* if its value did not occur in the list of options, or the number of the
* matching option. The first option is 1, the second is 2 and so on.
*/
2003-08-04 02:43:34 +02:00
enum
{
VAR_NOTSET = 0, VAR_NOTFOUND = -1};
int
SwitchVariable(VariableSpace space, const char name[],
const char *opt,...);
2003-08-04 02:43:34 +02:00
void PrintVariables(VariableSpace space);
2003-08-04 02:43:34 +02:00
bool SetVariable(VariableSpace space, const char *name, const char *value);
bool SetVariableBool(VariableSpace space, const char *name);
bool DeleteVariable(VariableSpace space, const char *name);
#endif /* VARIABLES_H */