* more details.
*
* You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <postgresql/libpq-fe.h>
* this file are called in order to allow the DB to be initialized ready
* for access.
*/
-struct onak_dbctx *keydb_pg_init(bool readonly)
+struct onak_dbctx *keydb_pg_init(struct onak_db_config *dbcfg, bool readonly)
{
struct onak_dbctx *dbctx;
PGconn *dbconn;
if (dbctx == NULL) {
return NULL;
}
+ dbctx->config = dbcfg;
- dbconn = PQsetdbLogin(config.pg_dbhost, // host
+ dbconn = PQsetdbLogin(dbcfg->hostname, // host
NULL, // port
NULL, // options
NULL, // tty
- config.pg_dbname, // database
- config.pg_dbuser, //login
- config.pg_dbpass); // password
+ dbcfg->location, // database
+ dbcfg->username, //login
+ dbcfg->password); // password
if (PQstatus(dbconn) == CONNECTION_BAD) {
logthing(LOGTHING_CRITICAL, "Connection to database failed.");