/Users/deen/code/yugabyte-db/src/postgres/src/common/config_info.c
Line | Count | Source (jump to first uncovered line) |
1 | | /*------------------------------------------------------------------------- |
2 | | * |
3 | | * config_info.c |
4 | | * Common code for pg_config output |
5 | | * |
6 | | * |
7 | | * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group |
8 | | * Portions Copyright (c) 1994, Regents of the University of California |
9 | | * |
10 | | * |
11 | | * IDENTIFICATION |
12 | | * src/common/config_info.c |
13 | | * |
14 | | *------------------------------------------------------------------------- |
15 | | */ |
16 | | |
17 | | #ifndef FRONTEND |
18 | | #include "postgres.h" |
19 | | #else |
20 | | #include "postgres_fe.h" |
21 | | #endif |
22 | | |
23 | | #include "common/config_info.h" |
24 | | |
25 | | |
26 | | /* |
27 | | * get_configdata(const char *my_exec_path, size_t *configdata_len) |
28 | | * |
29 | | * Get configure-time constants. The caller is responsible |
30 | | * for pfreeing the result. |
31 | | */ |
32 | | ConfigData * |
33 | | get_configdata(const char *my_exec_path, size_t *configdata_len) |
34 | 2 | { |
35 | 2 | ConfigData *configdata; |
36 | 2 | char path[MAXPGPATH]; |
37 | 2 | char *lastsep; |
38 | 2 | int i = 0; |
39 | | |
40 | | /* Adjust this to match the number of items filled below */ |
41 | 2 | *configdata_len = 23; |
42 | 2 | configdata = (ConfigData *) palloc(*configdata_len * sizeof(ConfigData)); |
43 | | |
44 | 2 | configdata[i].name = pstrdup("BINDIR"); |
45 | 2 | strlcpy(path, my_exec_path, sizeof(path)); |
46 | 2 | lastsep = strrchr(path, '/'); |
47 | 2 | if (lastsep) |
48 | 2 | *lastsep = '\0'; |
49 | 2 | cleanup_path(path); |
50 | 2 | configdata[i].setting = pstrdup(path); |
51 | 2 | i++; |
52 | | |
53 | 2 | configdata[i].name = pstrdup("DOCDIR"); |
54 | 2 | get_doc_path(my_exec_path, path); |
55 | 2 | cleanup_path(path); |
56 | 2 | configdata[i].setting = pstrdup(path); |
57 | 2 | i++; |
58 | | |
59 | 2 | configdata[i].name = pstrdup("HTMLDIR"); |
60 | 2 | get_html_path(my_exec_path, path); |
61 | 2 | cleanup_path(path); |
62 | 2 | configdata[i].setting = pstrdup(path); |
63 | 2 | i++; |
64 | | |
65 | 2 | configdata[i].name = pstrdup("INCLUDEDIR"); |
66 | 2 | get_include_path(my_exec_path, path); |
67 | 2 | cleanup_path(path); |
68 | 2 | configdata[i].setting = pstrdup(path); |
69 | 2 | i++; |
70 | | |
71 | 2 | configdata[i].name = pstrdup("PKGINCLUDEDIR"); |
72 | 2 | get_pkginclude_path(my_exec_path, path); |
73 | 2 | cleanup_path(path); |
74 | 2 | configdata[i].setting = pstrdup(path); |
75 | 2 | i++; |
76 | | |
77 | 2 | configdata[i].name = pstrdup("INCLUDEDIR-SERVER"); |
78 | 2 | get_includeserver_path(my_exec_path, path); |
79 | 2 | cleanup_path(path); |
80 | 2 | configdata[i].setting = pstrdup(path); |
81 | 2 | i++; |
82 | | |
83 | 2 | configdata[i].name = pstrdup("LIBDIR"); |
84 | 2 | get_lib_path(my_exec_path, path); |
85 | 2 | cleanup_path(path); |
86 | 2 | configdata[i].setting = pstrdup(path); |
87 | 2 | i++; |
88 | | |
89 | 2 | configdata[i].name = pstrdup("PKGLIBDIR"); |
90 | 2 | get_pkglib_path(my_exec_path, path); |
91 | 2 | cleanup_path(path); |
92 | 2 | configdata[i].setting = pstrdup(path); |
93 | 2 | i++; |
94 | | |
95 | 2 | configdata[i].name = pstrdup("LOCALEDIR"); |
96 | 2 | get_locale_path(my_exec_path, path); |
97 | 2 | cleanup_path(path); |
98 | 2 | configdata[i].setting = pstrdup(path); |
99 | 2 | i++; |
100 | | |
101 | 2 | configdata[i].name = pstrdup("MANDIR"); |
102 | 2 | get_man_path(my_exec_path, path); |
103 | 2 | cleanup_path(path); |
104 | 2 | configdata[i].setting = pstrdup(path); |
105 | 2 | i++; |
106 | | |
107 | 2 | configdata[i].name = pstrdup("SHAREDIR"); |
108 | 2 | get_share_path(my_exec_path, path); |
109 | 2 | cleanup_path(path); |
110 | 2 | configdata[i].setting = pstrdup(path); |
111 | 2 | i++; |
112 | | |
113 | 2 | configdata[i].name = pstrdup("SYSCONFDIR"); |
114 | 2 | get_etc_path(my_exec_path, path); |
115 | 2 | cleanup_path(path); |
116 | 2 | configdata[i].setting = pstrdup(path); |
117 | 2 | i++; |
118 | | |
119 | 2 | configdata[i].name = pstrdup("PGXS"); |
120 | 2 | get_pkglib_path(my_exec_path, path); |
121 | 2 | strlcat(path, "/pgxs/src/makefiles/pgxs.mk", sizeof(path)); |
122 | 2 | cleanup_path(path); |
123 | 2 | configdata[i].setting = pstrdup(path); |
124 | 2 | i++; |
125 | | |
126 | 2 | configdata[i].name = pstrdup("CONFIGURE"); |
127 | 2 | #ifdef VAL_CONFIGURE |
128 | 2 | configdata[i].setting = pstrdup(VAL_CONFIGURE); |
129 | | #else |
130 | | configdata[i].setting = pstrdup(_("not recorded")); |
131 | | #endif |
132 | 2 | i++; |
133 | | |
134 | 2 | configdata[i].name = pstrdup("CC"); |
135 | 2 | #ifdef VAL_CC |
136 | 2 | configdata[i].setting = pstrdup(VAL_CC); |
137 | | #else |
138 | | configdata[i].setting = pstrdup(_("not recorded")); |
139 | | #endif |
140 | 2 | i++; |
141 | | |
142 | 2 | configdata[i].name = pstrdup("CPPFLAGS"); |
143 | 2 | #ifdef VAL_CPPFLAGS |
144 | 2 | configdata[i].setting = pstrdup(VAL_CPPFLAGS); |
145 | | #else |
146 | | configdata[i].setting = pstrdup(_("not recorded")); |
147 | | #endif |
148 | 2 | i++; |
149 | | |
150 | 2 | configdata[i].name = pstrdup("CFLAGS"); |
151 | 2 | #ifdef VAL_CFLAGS |
152 | 2 | configdata[i].setting = pstrdup(VAL_CFLAGS); |
153 | | #else |
154 | | configdata[i].setting = pstrdup(_("not recorded")); |
155 | | #endif |
156 | 2 | i++; |
157 | | |
158 | 2 | configdata[i].name = pstrdup("CFLAGS_SL"); |
159 | 2 | #ifdef VAL_CFLAGS_SL |
160 | 2 | configdata[i].setting = pstrdup(VAL_CFLAGS_SL); |
161 | | #else |
162 | | configdata[i].setting = pstrdup(_("not recorded")); |
163 | | #endif |
164 | 2 | i++; |
165 | | |
166 | 2 | configdata[i].name = pstrdup("LDFLAGS"); |
167 | 2 | #ifdef VAL_LDFLAGS |
168 | 2 | configdata[i].setting = pstrdup(VAL_LDFLAGS); |
169 | | #else |
170 | | configdata[i].setting = pstrdup(_("not recorded")); |
171 | | #endif |
172 | 2 | i++; |
173 | | |
174 | 2 | configdata[i].name = pstrdup("LDFLAGS_EX"); |
175 | 2 | #ifdef VAL_LDFLAGS_EX |
176 | 2 | configdata[i].setting = pstrdup(VAL_LDFLAGS_EX); |
177 | | #else |
178 | | configdata[i].setting = pstrdup(_("not recorded")); |
179 | | #endif |
180 | 2 | i++; |
181 | | |
182 | 2 | configdata[i].name = pstrdup("LDFLAGS_SL"); |
183 | 2 | #ifdef VAL_LDFLAGS_SL |
184 | 2 | configdata[i].setting = pstrdup(VAL_LDFLAGS_SL); |
185 | | #else |
186 | | configdata[i].setting = pstrdup(_("not recorded")); |
187 | | #endif |
188 | 2 | i++; |
189 | | |
190 | 2 | configdata[i].name = pstrdup("LIBS"); |
191 | 2 | #ifdef VAL_LIBS |
192 | 2 | configdata[i].setting = pstrdup(VAL_LIBS); |
193 | | #else |
194 | | configdata[i].setting = pstrdup(_("not recorded")); |
195 | | #endif |
196 | 2 | i++; |
197 | | |
198 | 2 | configdata[i].name = pstrdup("VERSION"); |
199 | 2 | configdata[i].setting = pstrdup("PostgreSQL " PG_VERSION); |
200 | 2 | i++; |
201 | | |
202 | 2 | Assert(i == *configdata_len); |
203 | | |
204 | 0 | return configdata; |
205 | 2 | } Unexecuted instantiation: get_configdata Line | Count | Source | 34 | 2 | { | 35 | 2 | ConfigData *configdata; | 36 | 2 | char path[MAXPGPATH]; | 37 | 2 | char *lastsep; | 38 | 2 | int i = 0; | 39 | | | 40 | | /* Adjust this to match the number of items filled below */ | 41 | 2 | *configdata_len = 23; | 42 | 2 | configdata = (ConfigData *) palloc(*configdata_len * sizeof(ConfigData)); | 43 | | | 44 | 2 | configdata[i].name = pstrdup("BINDIR"); | 45 | 2 | strlcpy(path, my_exec_path, sizeof(path)); | 46 | 2 | lastsep = strrchr(path, '/'); | 47 | 2 | if (lastsep) | 48 | 2 | *lastsep = '\0'; | 49 | 2 | cleanup_path(path); | 50 | 2 | configdata[i].setting = pstrdup(path); | 51 | 2 | i++; | 52 | | | 53 | 2 | configdata[i].name = pstrdup("DOCDIR"); | 54 | 2 | get_doc_path(my_exec_path, path); | 55 | 2 | cleanup_path(path); | 56 | 2 | configdata[i].setting = pstrdup(path); | 57 | 2 | i++; | 58 | | | 59 | 2 | configdata[i].name = pstrdup("HTMLDIR"); | 60 | 2 | get_html_path(my_exec_path, path); | 61 | 2 | cleanup_path(path); | 62 | 2 | configdata[i].setting = pstrdup(path); | 63 | 2 | i++; | 64 | | | 65 | 2 | configdata[i].name = pstrdup("INCLUDEDIR"); | 66 | 2 | get_include_path(my_exec_path, path); | 67 | 2 | cleanup_path(path); | 68 | 2 | configdata[i].setting = pstrdup(path); | 69 | 2 | i++; | 70 | | | 71 | 2 | configdata[i].name = pstrdup("PKGINCLUDEDIR"); | 72 | 2 | get_pkginclude_path(my_exec_path, path); | 73 | 2 | cleanup_path(path); | 74 | 2 | configdata[i].setting = pstrdup(path); | 75 | 2 | i++; | 76 | | | 77 | 2 | configdata[i].name = pstrdup("INCLUDEDIR-SERVER"); | 78 | 2 | get_includeserver_path(my_exec_path, path); | 79 | 2 | cleanup_path(path); | 80 | 2 | configdata[i].setting = pstrdup(path); | 81 | 2 | i++; | 82 | | | 83 | 2 | configdata[i].name = pstrdup("LIBDIR"); | 84 | 2 | get_lib_path(my_exec_path, path); | 85 | 2 | cleanup_path(path); | 86 | 2 | configdata[i].setting = pstrdup(path); | 87 | 2 | i++; | 88 | | | 89 | 2 | configdata[i].name = pstrdup("PKGLIBDIR"); | 90 | 2 | get_pkglib_path(my_exec_path, path); | 91 | 2 | cleanup_path(path); | 92 | 2 | configdata[i].setting = pstrdup(path); | 93 | 2 | i++; | 94 | | | 95 | 2 | configdata[i].name = pstrdup("LOCALEDIR"); | 96 | 2 | get_locale_path(my_exec_path, path); | 97 | 2 | cleanup_path(path); | 98 | 2 | configdata[i].setting = pstrdup(path); | 99 | 2 | i++; | 100 | | | 101 | 2 | configdata[i].name = pstrdup("MANDIR"); | 102 | 2 | get_man_path(my_exec_path, path); | 103 | 2 | cleanup_path(path); | 104 | 2 | configdata[i].setting = pstrdup(path); | 105 | 2 | i++; | 106 | | | 107 | 2 | configdata[i].name = pstrdup("SHAREDIR"); | 108 | 2 | get_share_path(my_exec_path, path); | 109 | 2 | cleanup_path(path); | 110 | 2 | configdata[i].setting = pstrdup(path); | 111 | 2 | i++; | 112 | | | 113 | 2 | configdata[i].name = pstrdup("SYSCONFDIR"); | 114 | 2 | get_etc_path(my_exec_path, path); | 115 | 2 | cleanup_path(path); | 116 | 2 | configdata[i].setting = pstrdup(path); | 117 | 2 | i++; | 118 | | | 119 | 2 | configdata[i].name = pstrdup("PGXS"); | 120 | 2 | get_pkglib_path(my_exec_path, path); | 121 | 2 | strlcat(path, "/pgxs/src/makefiles/pgxs.mk", sizeof(path)); | 122 | 2 | cleanup_path(path); | 123 | 2 | configdata[i].setting = pstrdup(path); | 124 | 2 | i++; | 125 | | | 126 | 2 | configdata[i].name = pstrdup("CONFIGURE"); | 127 | 2 | #ifdef VAL_CONFIGURE | 128 | 2 | configdata[i].setting = pstrdup(VAL_CONFIGURE); | 129 | | #else | 130 | | configdata[i].setting = pstrdup(_("not recorded")); | 131 | | #endif | 132 | 2 | i++; | 133 | | | 134 | 2 | configdata[i].name = pstrdup("CC"); | 135 | 2 | #ifdef VAL_CC | 136 | 2 | configdata[i].setting = pstrdup(VAL_CC); | 137 | | #else | 138 | | configdata[i].setting = pstrdup(_("not recorded")); | 139 | | #endif | 140 | 2 | i++; | 141 | | | 142 | 2 | configdata[i].name = pstrdup("CPPFLAGS"); | 143 | 2 | #ifdef VAL_CPPFLAGS | 144 | 2 | configdata[i].setting = pstrdup(VAL_CPPFLAGS); | 145 | | #else | 146 | | configdata[i].setting = pstrdup(_("not recorded")); | 147 | | #endif | 148 | 2 | i++; | 149 | | | 150 | 2 | configdata[i].name = pstrdup("CFLAGS"); | 151 | 2 | #ifdef VAL_CFLAGS | 152 | 2 | configdata[i].setting = pstrdup(VAL_CFLAGS); | 153 | | #else | 154 | | configdata[i].setting = pstrdup(_("not recorded")); | 155 | | #endif | 156 | 2 | i++; | 157 | | | 158 | 2 | configdata[i].name = pstrdup("CFLAGS_SL"); | 159 | 2 | #ifdef VAL_CFLAGS_SL | 160 | 2 | configdata[i].setting = pstrdup(VAL_CFLAGS_SL); | 161 | | #else | 162 | | configdata[i].setting = pstrdup(_("not recorded")); | 163 | | #endif | 164 | 2 | i++; | 165 | | | 166 | 2 | configdata[i].name = pstrdup("LDFLAGS"); | 167 | 2 | #ifdef VAL_LDFLAGS | 168 | 2 | configdata[i].setting = pstrdup(VAL_LDFLAGS); | 169 | | #else | 170 | | configdata[i].setting = pstrdup(_("not recorded")); | 171 | | #endif | 172 | 2 | i++; | 173 | | | 174 | 2 | configdata[i].name = pstrdup("LDFLAGS_EX"); | 175 | 2 | #ifdef VAL_LDFLAGS_EX | 176 | 2 | configdata[i].setting = pstrdup(VAL_LDFLAGS_EX); | 177 | | #else | 178 | | configdata[i].setting = pstrdup(_("not recorded")); | 179 | | #endif | 180 | 2 | i++; | 181 | | | 182 | 2 | configdata[i].name = pstrdup("LDFLAGS_SL"); | 183 | 2 | #ifdef VAL_LDFLAGS_SL | 184 | 2 | configdata[i].setting = pstrdup(VAL_LDFLAGS_SL); | 185 | | #else | 186 | | configdata[i].setting = pstrdup(_("not recorded")); | 187 | | #endif | 188 | 2 | i++; | 189 | | | 190 | 2 | configdata[i].name = pstrdup("LIBS"); | 191 | 2 | #ifdef VAL_LIBS | 192 | 2 | configdata[i].setting = pstrdup(VAL_LIBS); | 193 | | #else | 194 | | configdata[i].setting = pstrdup(_("not recorded")); | 195 | | #endif | 196 | 2 | i++; | 197 | | | 198 | 2 | configdata[i].name = pstrdup("VERSION"); | 199 | 2 | configdata[i].setting = pstrdup("PostgreSQL " PG_VERSION); | 200 | 2 | i++; | 201 | | | 202 | 2 | Assert(i == *configdata_len); | 203 | | | 204 | 0 | return configdata; | 205 | 2 | } |
|