2000-01-19 00:30:24 +01:00
|
|
|
/*
|
|
|
|
* psql - the PostgreSQL interactive terminal
|
|
|
|
*
|
2011-01-01 19:18:15 +01:00
|
|
|
* Copyright (c) 2000-2011, PostgreSQL Global Development Group
|
2000-01-19 00:30:24 +01:00
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/bin/psql/variables.h
|
2000-01-19 00:30:24 +01:00
|
|
|
*/
|
2006-08-29 17:19:51 +02:00
|
|
|
#ifndef VARIABLES_H
|
|
|
|
#define VARIABLES_H
|
2000-01-19 00:30:24 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This implements a sort of variable repository. One could also think of it
|
2006-08-29 17:19:51 +02:00
|
|
|
* as a cheap version of an associative array. In each one of these
|
|
|
|
* datastructures you can store name/value pairs. There can also be an
|
|
|
|
* "assign hook" function that is called whenever the variable's value is
|
|
|
|
* changed.
|
|
|
|
*
|
|
|
|
* An "unset" operation causes the hook to be called with newval == NULL.
|
|
|
|
*
|
|
|
|
* Note: if value == NULL then the variable is logically unset, but we are
|
|
|
|
* keeping the struct around so as not to forget about its hook function.
|
1999-11-04 22:56:02 +01:00
|
|
|
*/
|
2006-08-29 17:19:51 +02:00
|
|
|
typedef void (*VariableAssignHook) (const char *newval);
|
1999-11-04 22:56:02 +01:00
|
|
|
|
1999-11-05 00:14:30 +01:00
|
|
|
struct _variable
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
char *value;
|
2006-08-29 17:19:51 +02:00
|
|
|
VariableAssignHook assign_hook;
|
1999-11-05 00:14:30 +01:00
|
|
|
struct _variable *next;
|
1999-11-04 22:56:02 +01:00
|
|
|
};
|
|
|
|
|
1999-11-05 00:14:30 +01:00
|
|
|
typedef struct _variable *VariableSpace;
|
1999-11-04 22:56:02 +01:00
|
|
|
|
2006-08-29 17:19:51 +02:00
|
|
|
/* Allowed chars in a variable's name */
|
|
|
|
#define VALID_VARIABLE_CHARS "abcdefghijklmnopqrstuvwxyz"\
|
|
|
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789_"
|
1999-11-04 22:56:02 +01:00
|
|
|
|
|
|
|
VariableSpace CreateVariableSpace(void);
|
1999-11-05 00:14:30 +01:00
|
|
|
const char *GetVariable(VariableSpace space, const char *name);
|
2003-03-20 07:43:35 +01:00
|
|
|
|
2006-10-04 02:30:14 +02:00
|
|
|
bool ParseVariableBool(const char *val);
|
2006-08-29 17:19:51 +02:00
|
|
|
int ParseVariableNum(const char *val,
|
|
|
|
int defaultval,
|
|
|
|
int faultval,
|
|
|
|
bool allowtrail);
|
2003-08-04 02:43:34 +02:00
|
|
|
int GetVariableNum(VariableSpace space,
|
2006-08-29 17:19:51 +02:00
|
|
|
const char *name,
|
2003-08-04 02:43:34 +02:00
|
|
|
int defaultval,
|
|
|
|
int faultval,
|
|
|
|
bool allowtrail);
|
2003-03-20 07:43:35 +01:00
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
void PrintVariables(VariableSpace space);
|
2003-03-20 07:43:35 +01:00
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
bool SetVariable(VariableSpace space, const char *name, const char *value);
|
2006-08-29 17:19:51 +02:00
|
|
|
bool SetVariableAssignHook(VariableSpace space, const char *name, VariableAssignHook hook);
|
2003-08-04 02:43:34 +02:00
|
|
|
bool SetVariableBool(VariableSpace space, const char *name);
|
|
|
|
bool DeleteVariable(VariableSpace space, const char *name);
|
1999-11-04 22:56:02 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* VARIABLES_H */
|