1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/*-------------------------------------------------------------------------
* help_config.c
*
* Displays available options under grand unified configuration scheme
*
* Options whose flag bits are set to GUC_NO_SHOW_ALL, GUC_NOT_IN_SAMPLE,
* or GUC_DISALLOW_IN_FILE are not displayed, unless the user specifically
* requests that variable by name
*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/help_config.c,v 1.10 2004/05/26 15:07:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include <float.h>
#include <limits.h>
#include <unistd.h>
#include "utils/guc.h"
#include "utils/guc_tables.h"
#include "utils/help_config.h"
/*
* This union allows us to mix the numerous different types of structs
* that we are organizing.
*/
typedef union
{
struct config_generic generic;
struct config_bool bool;
struct config_real real;
struct config_int integer;
struct config_string string;
} mixedStruct;
static void printMixedStruct(mixedStruct *structToPrint);
static bool displayStruct(mixedStruct *structToDisplay);
int
GucInfoMain(void)
{
int i;
struct config_generic **guc_vars = get_guc_variables();
int numOpts = GetNumConfigOptions();
/* Initialize the guc_variables[] array */
build_guc_variables();
for (i = 0; i < numOpts; i++)
{
mixedStruct *var = (mixedStruct *) guc_vars[i];
if (displayStruct(var))
printMixedStruct(var);
}
return 0;
}
/*
* This function will return true if the struct passed to it
* should be displayed to the user.
*/
static bool
displayStruct(mixedStruct *structToDisplay)
{
return !(structToDisplay->generic.flags & (GUC_NO_SHOW_ALL |
GUC_NOT_IN_SAMPLE |
GUC_DISALLOW_IN_FILE));
}
/*
* This function prints out the generic struct passed to it. It will print out
* a different format, depending on what the user wants to see.
*/
static void
printMixedStruct(mixedStruct *structToPrint)
{
printf("%s\t%s\t%s\t",
structToPrint->generic.name,
GucContext_Names[structToPrint->generic.context],
gettext(config_group_names[structToPrint->generic.group]));
switch (structToPrint->generic.vartype)
{
case PGC_BOOL:
printf("BOOLEAN\t%s\t\t\t",
(structToPrint->bool.reset_val == 0) ?
"FALSE" : "TRUE");
break;
case PGC_INT:
printf("INTEGER\t%d\t%d\t%d\t",
structToPrint->integer.reset_val,
structToPrint->integer.min,
structToPrint->integer.max);
break;
case PGC_REAL:
printf("REAL\t%g\t%g\t%g\t",
structToPrint->real.reset_val,
structToPrint->real.min,
structToPrint->real.max);
break;
case PGC_STRING:
printf("STRING\t%s\t\t\t",
structToPrint->string.boot_val);
break;
default:
fprintf(stderr, "internal error: unrecognized run-time parameter type\n");
break;
}
printf("%s\t%s\n",
(structToPrint->generic.short_desc == NULL) ? "" : gettext(structToPrint->generic.short_desc),
(structToPrint->generic.long_desc == NULL) ? "" : gettext(structToPrint->generic.long_desc));
}
|