postgresql/src/bin/psql/variables.h

57 lines
1.7 KiB
C
Raw Normal View History

2000-01-19 00:30:24 +01:00
/*
* psql - the PostgreSQL interactive terminal
*
* Copyright (c) 2000-2016, 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
*/
#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
* 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.
*/
typedef void (*VariableAssignHook) (const char *newval);
1999-11-05 00:14:30 +01:00
struct _variable
{
char *name;
char *value;
VariableAssignHook assign_hook;
1999-11-05 00:14:30 +01:00
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);
bool ParseVariableBool(const char *value, const char *name);
int ParseVariableNum(const char *val,
int defaultval,
int faultval,
bool allowtrail);
2003-08-04 02:43:34 +02:00
int GetVariableNum(VariableSpace space,
const char *name,
2003-08-04 02:43:34 +02:00
int defaultval,
int faultval,
bool allowtrail);
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 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);
#endif /* VARIABLES_H */