LCOV - code coverage report
Current view: top level - src/common - config_info.c (source / functions) Coverage Total Hit
Test: PostgreSQL 19beta1 Lines: 100.0 % 104 104
Test Date: 2026-06-03 02:16:23 Functions: 100.0 % 1 1
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /*-------------------------------------------------------------------------
       2              :  *
       3              :  * config_info.c
       4              :  *      Common code for pg_config output
       5              :  *
       6              :  *
       7              :  * Portions Copyright (c) 1996-2026, 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          558 : get_configdata(const char *my_exec_path, size_t *configdata_len)
      34              : {
      35              :     ConfigData *configdata;
      36              :     char        path[MAXPGPATH];
      37              :     char       *lastsep;
      38          558 :     int         i = 0;
      39              : 
      40              :     /* Adjust this to match the number of items filled below */
      41          558 :     *configdata_len = 23;
      42          558 :     configdata = palloc_array(ConfigData, *configdata_len);
      43              : 
      44          558 :     configdata[i].name = pstrdup("BINDIR");
      45          558 :     strlcpy(path, my_exec_path, sizeof(path));
      46          558 :     lastsep = strrchr(path, '/');
      47          558 :     if (lastsep)
      48          558 :         *lastsep = '\0';
      49          558 :     cleanup_path(path);
      50          558 :     configdata[i].setting = pstrdup(path);
      51          558 :     i++;
      52              : 
      53          558 :     configdata[i].name = pstrdup("DOCDIR");
      54          558 :     get_doc_path(my_exec_path, path);
      55          558 :     cleanup_path(path);
      56          558 :     configdata[i].setting = pstrdup(path);
      57          558 :     i++;
      58              : 
      59          558 :     configdata[i].name = pstrdup("HTMLDIR");
      60          558 :     get_html_path(my_exec_path, path);
      61          558 :     cleanup_path(path);
      62          558 :     configdata[i].setting = pstrdup(path);
      63          558 :     i++;
      64              : 
      65          558 :     configdata[i].name = pstrdup("INCLUDEDIR");
      66          558 :     get_include_path(my_exec_path, path);
      67          558 :     cleanup_path(path);
      68          558 :     configdata[i].setting = pstrdup(path);
      69          558 :     i++;
      70              : 
      71          558 :     configdata[i].name = pstrdup("PKGINCLUDEDIR");
      72          558 :     get_pkginclude_path(my_exec_path, path);
      73          558 :     cleanup_path(path);
      74          558 :     configdata[i].setting = pstrdup(path);
      75          558 :     i++;
      76              : 
      77          558 :     configdata[i].name = pstrdup("INCLUDEDIR-SERVER");
      78          558 :     get_includeserver_path(my_exec_path, path);
      79          558 :     cleanup_path(path);
      80          558 :     configdata[i].setting = pstrdup(path);
      81          558 :     i++;
      82              : 
      83          558 :     configdata[i].name = pstrdup("LIBDIR");
      84          558 :     get_lib_path(my_exec_path, path);
      85          558 :     cleanup_path(path);
      86          558 :     configdata[i].setting = pstrdup(path);
      87          558 :     i++;
      88              : 
      89          558 :     configdata[i].name = pstrdup("PKGLIBDIR");
      90          558 :     get_pkglib_path(my_exec_path, path);
      91          558 :     cleanup_path(path);
      92          558 :     configdata[i].setting = pstrdup(path);
      93          558 :     i++;
      94              : 
      95          558 :     configdata[i].name = pstrdup("LOCALEDIR");
      96          558 :     get_locale_path(my_exec_path, path);
      97          558 :     cleanup_path(path);
      98          558 :     configdata[i].setting = pstrdup(path);
      99          558 :     i++;
     100              : 
     101          558 :     configdata[i].name = pstrdup("MANDIR");
     102          558 :     get_man_path(my_exec_path, path);
     103          558 :     cleanup_path(path);
     104          558 :     configdata[i].setting = pstrdup(path);
     105          558 :     i++;
     106              : 
     107          558 :     configdata[i].name = pstrdup("SHAREDIR");
     108          558 :     get_share_path(my_exec_path, path);
     109          558 :     cleanup_path(path);
     110          558 :     configdata[i].setting = pstrdup(path);
     111          558 :     i++;
     112              : 
     113          558 :     configdata[i].name = pstrdup("SYSCONFDIR");
     114          558 :     get_etc_path(my_exec_path, path);
     115          558 :     cleanup_path(path);
     116          558 :     configdata[i].setting = pstrdup(path);
     117          558 :     i++;
     118              : 
     119          558 :     configdata[i].name = pstrdup("PGXS");
     120          558 :     get_pkglib_path(my_exec_path, path);
     121          558 :     strlcat(path, "/pgxs/src/makefiles/pgxs.mk", sizeof(path));
     122          558 :     cleanup_path(path);
     123          558 :     configdata[i].setting = pstrdup(path);
     124          558 :     i++;
     125              : 
     126          558 :     configdata[i].name = pstrdup("CONFIGURE");
     127          558 :     configdata[i].setting = pstrdup(CONFIGURE_ARGS);
     128          558 :     i++;
     129              : 
     130          558 :     configdata[i].name = pstrdup("CC");
     131              : #ifdef VAL_CC
     132          558 :     configdata[i].setting = pstrdup(VAL_CC);
     133              : #else
     134              :     configdata[i].setting = pstrdup(_("not recorded"));
     135              : #endif
     136          558 :     i++;
     137              : 
     138          558 :     configdata[i].name = pstrdup("CPPFLAGS");
     139              : #ifdef VAL_CPPFLAGS
     140          558 :     configdata[i].setting = pstrdup(VAL_CPPFLAGS);
     141              : #else
     142              :     configdata[i].setting = pstrdup(_("not recorded"));
     143              : #endif
     144          558 :     i++;
     145              : 
     146          558 :     configdata[i].name = pstrdup("CFLAGS");
     147              : #ifdef VAL_CFLAGS
     148          558 :     configdata[i].setting = pstrdup(VAL_CFLAGS);
     149              : #else
     150              :     configdata[i].setting = pstrdup(_("not recorded"));
     151              : #endif
     152          558 :     i++;
     153              : 
     154          558 :     configdata[i].name = pstrdup("CFLAGS_SL");
     155              : #ifdef VAL_CFLAGS_SL
     156          558 :     configdata[i].setting = pstrdup(VAL_CFLAGS_SL);
     157              : #else
     158              :     configdata[i].setting = pstrdup(_("not recorded"));
     159              : #endif
     160          558 :     i++;
     161              : 
     162          558 :     configdata[i].name = pstrdup("LDFLAGS");
     163              : #ifdef VAL_LDFLAGS
     164          558 :     configdata[i].setting = pstrdup(VAL_LDFLAGS);
     165              : #else
     166              :     configdata[i].setting = pstrdup(_("not recorded"));
     167              : #endif
     168          558 :     i++;
     169              : 
     170          558 :     configdata[i].name = pstrdup("LDFLAGS_EX");
     171              : #ifdef VAL_LDFLAGS_EX
     172          558 :     configdata[i].setting = pstrdup(VAL_LDFLAGS_EX);
     173              : #else
     174              :     configdata[i].setting = pstrdup(_("not recorded"));
     175              : #endif
     176          558 :     i++;
     177              : 
     178          558 :     configdata[i].name = pstrdup("LDFLAGS_SL");
     179              : #ifdef VAL_LDFLAGS_SL
     180          558 :     configdata[i].setting = pstrdup(VAL_LDFLAGS_SL);
     181              : #else
     182              :     configdata[i].setting = pstrdup(_("not recorded"));
     183              : #endif
     184          558 :     i++;
     185              : 
     186          558 :     configdata[i].name = pstrdup("LIBS");
     187              : #ifdef VAL_LIBS
     188          558 :     configdata[i].setting = pstrdup(VAL_LIBS);
     189              : #else
     190              :     configdata[i].setting = pstrdup(_("not recorded"));
     191              : #endif
     192          558 :     i++;
     193              : 
     194          558 :     configdata[i].name = pstrdup("VERSION");
     195          558 :     configdata[i].setting = pstrdup("PostgreSQL " PG_VERSION);
     196          558 :     i++;
     197              : 
     198              :     Assert(i == *configdata_len);
     199              : 
     200          558 :     return configdata;
     201              : }
        

Generated by: LCOV version 2.0-1