Fix obsolete comment regarding FSM truncation.
[PostgreSQL.git] / src / bin / psql / variables.h
blob5db604b0fc548822f805d0d33ab75123f2763e6f
1 /*
2 * psql - the PostgreSQL interactive terminal
4 * Copyright (c) 2000-2008, PostgreSQL Global Development Group
6 * $PostgreSQL$
7 */
8 #ifndef VARIABLES_H
9 #define VARIABLES_H
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
16 * changed.
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);
25 struct _variable
27 char *name;
28 char *value;
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,
44 int defaultval,
45 int faultval,
46 bool allowtrail);
47 int GetVariableNum(VariableSpace space,
48 const char *name,
49 int defaultval,
50 int faultval,
51 bool allowtrail);
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 */