Header And Logo

PostgreSQL
| The world's most advanced open source database.

variables.h

Go to the documentation of this file.
00001 /*
00002  * psql - the PostgreSQL interactive terminal
00003  *
00004  * Copyright (c) 2000-2013, PostgreSQL Global Development Group
00005  *
00006  * src/bin/psql/variables.h
00007  */
00008 #ifndef VARIABLES_H
00009 #define VARIABLES_H
00010 
00011 /*
00012  * This implements a sort of variable repository. One could also think of it
00013  * as a cheap version of an associative array. In each one of these
00014  * datastructures you can store name/value pairs.  There can also be an
00015  * "assign hook" function that is called whenever the variable's value is
00016  * changed.
00017  *
00018  * An "unset" operation causes the hook to be called with newval == NULL.
00019  *
00020  * Note: if value == NULL then the variable is logically unset, but we are
00021  * keeping the struct around so as not to forget about its hook function.
00022  */
00023 typedef void (*VariableAssignHook) (const char *newval);
00024 
00025 struct _variable
00026 {
00027     char       *name;
00028     char       *value;
00029     VariableAssignHook assign_hook;
00030     struct _variable *next;
00031 };
00032 
00033 typedef struct _variable *VariableSpace;
00034 
00035 VariableSpace CreateVariableSpace(void);
00036 const char *GetVariable(VariableSpace space, const char *name);
00037 
00038 bool        ParseVariableBool(const char *val);
00039 int ParseVariableNum(const char *val,
00040                  int defaultval,
00041                  int faultval,
00042                  bool allowtrail);
00043 int GetVariableNum(VariableSpace space,
00044                const char *name,
00045                int defaultval,
00046                int faultval,
00047                bool allowtrail);
00048 
00049 void        PrintVariables(VariableSpace space);
00050 
00051 bool        SetVariable(VariableSpace space, const char *name, const char *value);
00052 bool        SetVariableAssignHook(VariableSpace space, const char *name, VariableAssignHook hook);
00053 bool        SetVariableBool(VariableSpace space, const char *name);
00054 bool        DeleteVariable(VariableSpace space, const char *name);
00055 
00056 #endif   /* VARIABLES_H */