PageRenderTime 67ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/src/common/config_info.c

http://github.com/postgres/postgres
C | 201 lines | 149 code | 30 blank | 22 comment | 2 complexity | 7d0e0427329b58dd9ba5d29a6fded8dc 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-2020, 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. configdata[i].setting = pstrdup(CONFIGURE_ARGS);
  109. i++;
  110. configdata[i].name = pstrdup("CC");
  111. #ifdef VAL_CC
  112. configdata[i].setting = pstrdup(VAL_CC);
  113. #else
  114. configdata[i].setting = pstrdup(_("not recorded"));
  115. #endif
  116. i++;
  117. configdata[i].name = pstrdup("CPPFLAGS");
  118. #ifdef VAL_CPPFLAGS
  119. configdata[i].setting = pstrdup(VAL_CPPFLAGS);
  120. #else
  121. configdata[i].setting = pstrdup(_("not recorded"));
  122. #endif
  123. i++;
  124. configdata[i].name = pstrdup("CFLAGS");
  125. #ifdef VAL_CFLAGS
  126. configdata[i].setting = pstrdup(VAL_CFLAGS);
  127. #else
  128. configdata[i].setting = pstrdup(_("not recorded"));
  129. #endif
  130. i++;
  131. configdata[i].name = pstrdup("CFLAGS_SL");
  132. #ifdef VAL_CFLAGS_SL
  133. configdata[i].setting = pstrdup(VAL_CFLAGS_SL);
  134. #else
  135. configdata[i].setting = pstrdup(_("not recorded"));
  136. #endif
  137. i++;
  138. configdata[i].name = pstrdup("LDFLAGS");
  139. #ifdef VAL_LDFLAGS
  140. configdata[i].setting = pstrdup(VAL_LDFLAGS);
  141. #else
  142. configdata[i].setting = pstrdup(_("not recorded"));
  143. #endif
  144. i++;
  145. configdata[i].name = pstrdup("LDFLAGS_EX");
  146. #ifdef VAL_LDFLAGS_EX
  147. configdata[i].setting = pstrdup(VAL_LDFLAGS_EX);
  148. #else
  149. configdata[i].setting = pstrdup(_("not recorded"));
  150. #endif
  151. i++;
  152. configdata[i].name = pstrdup("LDFLAGS_SL");
  153. #ifdef VAL_LDFLAGS_SL
  154. configdata[i].setting = pstrdup(VAL_LDFLAGS_SL);
  155. #else
  156. configdata[i].setting = pstrdup(_("not recorded"));
  157. #endif
  158. i++;
  159. configdata[i].name = pstrdup("LIBS");
  160. #ifdef VAL_LIBS
  161. configdata[i].setting = pstrdup(VAL_LIBS);
  162. #else
  163. configdata[i].setting = pstrdup(_("not recorded"));
  164. #endif
  165. i++;
  166. configdata[i].name = pstrdup("VERSION");
  167. configdata[i].setting = pstrdup("PostgreSQL " PG_VERSION);
  168. i++;
  169. Assert(i == *configdata_len);
  170. return configdata;
  171. }