PageRenderTime 52ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/src/common/config_info.c

https://bitbucket.org/adunstan/pgdevel
C | 205 lines | 153 code | 30 blank | 22 comment | 2 complexity | 4b627c0680c15bed74133343eb5252c8 MD5 | raw file
Possible License(s): AGPL-3.0
  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. #ifndef FRONTEND
  17. #include "postgres.h"
  18. #else
  19. #include "postgres_fe.h"
  20. #endif
  21. #include "common/config_info.h"
  22. /*
  23. * get_configdata(const char *my_exec_path, size_t *configdata_len)
  24. *
  25. * Get configure-time constants. The caller is responsible
  26. * for pfreeing the result.
  27. */
  28. ConfigData *
  29. get_configdata(const char *my_exec_path, size_t *configdata_len)
  30. {
  31. ConfigData *configdata;
  32. char path[MAXPGPATH];
  33. char *lastsep;
  34. int i = 0;
  35. /* Adjust this to match the number of items filled below */
  36. *configdata_len = 23;
  37. configdata = (ConfigData *) palloc(*configdata_len * sizeof(ConfigData));
  38. configdata[i].name = pstrdup("BINDIR");
  39. strlcpy(path, my_exec_path, sizeof(path));
  40. lastsep = strrchr(path, '/');
  41. if (lastsep)
  42. *lastsep = '\0';
  43. cleanup_path(path);
  44. configdata[i].setting = pstrdup(path);
  45. i++;
  46. configdata[i].name = pstrdup("DOCDIR");
  47. get_doc_path(my_exec_path, path);
  48. cleanup_path(path);
  49. configdata[i].setting = pstrdup(path);
  50. i++;
  51. configdata[i].name = pstrdup("HTMLDIR");
  52. get_html_path(my_exec_path, path);
  53. cleanup_path(path);
  54. configdata[i].setting = pstrdup(path);
  55. i++;
  56. configdata[i].name = pstrdup("INCLUDEDIR");
  57. get_include_path(my_exec_path, path);
  58. cleanup_path(path);
  59. configdata[i].setting = pstrdup(path);
  60. i++;
  61. configdata[i].name = pstrdup("PKGINCLUDEDIR");
  62. get_pkginclude_path(my_exec_path, path);
  63. cleanup_path(path);
  64. configdata[i].setting = pstrdup(path);
  65. i++;
  66. configdata[i].name = pstrdup("INCLUDEDIR-SERVER");
  67. get_includeserver_path(my_exec_path, path);
  68. cleanup_path(path);
  69. configdata[i].setting = pstrdup(path);
  70. i++;
  71. configdata[i].name = pstrdup("LIBDIR");
  72. get_lib_path(my_exec_path, path);
  73. cleanup_path(path);
  74. configdata[i].setting = pstrdup(path);
  75. i++;
  76. configdata[i].name = pstrdup("PKGLIBDIR");
  77. get_pkglib_path(my_exec_path, path);
  78. cleanup_path(path);
  79. configdata[i].setting = pstrdup(path);
  80. i++;
  81. configdata[i].name = pstrdup("LOCALEDIR");
  82. get_locale_path(my_exec_path, path);
  83. cleanup_path(path);
  84. configdata[i].setting = pstrdup(path);
  85. i++;
  86. configdata[i].name = pstrdup("MANDIR");
  87. get_man_path(my_exec_path, path);
  88. cleanup_path(path);
  89. configdata[i].setting = pstrdup(path);
  90. i++;
  91. configdata[i].name = pstrdup("SHAREDIR");
  92. get_share_path(my_exec_path, path);
  93. cleanup_path(path);
  94. configdata[i].setting = pstrdup(path);
  95. i++;
  96. configdata[i].name = pstrdup("SYSCONFDIR");
  97. get_etc_path(my_exec_path, path);
  98. cleanup_path(path);
  99. configdata[i].setting = pstrdup(path);
  100. i++;
  101. configdata[i].name = pstrdup("PGXS");
  102. get_pkglib_path(my_exec_path, path);
  103. strlcat(path, "/pgxs/src/makefiles/pgxs.mk", sizeof(path));
  104. cleanup_path(path);
  105. configdata[i].setting = pstrdup(path);
  106. i++;
  107. configdata[i].name = pstrdup("CONFIGURE");
  108. #ifdef VAL_CONFIGURE
  109. configdata[i].setting = pstrdup(VAL_CONFIGURE);
  110. #else
  111. configdata[i].setting = pstrdup(_("not recorded"));
  112. #endif
  113. i++;
  114. configdata[i].name = pstrdup("CC");
  115. #ifdef VAL_CC
  116. configdata[i].setting = pstrdup(VAL_CC);
  117. #else
  118. configdata[i].setting = pstrdup(_("not recorded"));
  119. #endif
  120. i++;
  121. configdata[i].name = pstrdup("CPPFLAGS");
  122. #ifdef VAL_CPPFLAGS
  123. configdata[i].setting = pstrdup(VAL_CPPFLAGS);
  124. #else
  125. configdata[i].setting = pstrdup(_("not recorded"));
  126. #endif
  127. i++;
  128. configdata[i].name = pstrdup("CFLAGS");
  129. #ifdef VAL_CFLAGS
  130. configdata[i].setting = pstrdup(VAL_CFLAGS);
  131. #else
  132. configdata[i].setting = pstrdup(_("not recorded"));
  133. #endif
  134. i++;
  135. configdata[i].name = pstrdup("CFLAGS_SL");
  136. #ifdef VAL_CFLAGS_SL
  137. configdata[i].setting = pstrdup(VAL_CFLAGS_SL);
  138. #else
  139. configdata[i].setting = pstrdup(_("not recorded"));
  140. #endif
  141. i++;
  142. configdata[i].name = pstrdup("LDFLAGS");
  143. #ifdef VAL_LDFLAGS
  144. configdata[i].setting = pstrdup(VAL_LDFLAGS);
  145. #else
  146. configdata[i].setting = pstrdup(_("not recorded"));
  147. #endif
  148. i++;
  149. configdata[i].name = pstrdup("LDFLAGS_EX");
  150. #ifdef VAL_LDFLAGS_EX
  151. configdata[i].setting = pstrdup(VAL_LDFLAGS_EX);
  152. #else
  153. configdata[i].setting = pstrdup(_("not recorded"));
  154. #endif
  155. i++;
  156. configdata[i].name = pstrdup("LDFLAGS_SL");
  157. #ifdef VAL_LDFLAGS_SL
  158. configdata[i].setting = pstrdup(VAL_LDFLAGS_SL);
  159. #else
  160. configdata[i].setting = pstrdup(_("not recorded"));
  161. #endif
  162. i++;
  163. configdata[i].name = pstrdup("LIBS");
  164. #ifdef VAL_LIBS
  165. configdata[i].setting = pstrdup(VAL_LIBS);
  166. #else
  167. configdata[i].setting = pstrdup(_("not recorded"));
  168. #endif
  169. i++;
  170. configdata[i].name = pstrdup("VERSION");
  171. configdata[i].setting = pstrdup("PostgreSQL " PG_VERSION);
  172. i++;
  173. Assert(i == *configdata_len);
  174. return configdata;
  175. }