2 * psql - the PostgreSQL interactive terminal
4 * Copyright (c) 2000-2008, PostgreSQL Global Development Group
12 * This implements a sort of variable repository. One could also think of it
13 * as a cheap version of an associative array. In each one of these
14 * datastructures you can store name/value pairs. There can also be an
15 * "assign hook" function that is called whenever the variable's value is
18 * An "unset" operation causes the hook to be called with newval == NULL.
20 * Note: if value == NULL then the variable is logically unset, but we are
21 * keeping the struct around so as not to forget about its hook function.
23 typedef void (*VariableAssignHook
) (const char *newval
);
29 VariableAssignHook assign_hook
;
30 struct _variable
*next
;
33 typedef struct _variable
*VariableSpace
;
35 /* Allowed chars in a variable's name */
36 #define VALID_VARIABLE_CHARS "abcdefghijklmnopqrstuvwxyz"\
37 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789_"
39 VariableSpace
CreateVariableSpace(void);
40 const char *GetVariable(VariableSpace space
, const char *name
);
42 bool ParseVariableBool(const char *val
);
43 int ParseVariableNum(const char *val
,
47 int GetVariableNum(VariableSpace space
,
53 void PrintVariables(VariableSpace space
);
55 bool SetVariable(VariableSpace space
, const char *name
, const char *value
);
56 bool SetVariableAssignHook(VariableSpace space
, const char *name
, VariableAssignHook hook
);
57 bool SetVariableBool(VariableSpace space
, const char *name
);
58 bool DeleteVariable(VariableSpace space
, const char *name
);
60 #endif /* VARIABLES_H */