mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
nominatim refactoring
This commit is contained in:
37
nominatim/postgresql.c
Normal file
37
nominatim/postgresql.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "postgresql.h"
|
||||
|
||||
const char *build_conninfo(const char *db, const char *username, const char *password, const char *host, const char *port)
|
||||
{
|
||||
static char conninfo[1024];
|
||||
|
||||
conninfo[0]='\0';
|
||||
strcat(conninfo, "dbname='");
|
||||
strcat(conninfo, db);
|
||||
strcat(conninfo, "'");
|
||||
|
||||
if (username) {
|
||||
strcat(conninfo, " user='");
|
||||
strcat(conninfo, username);
|
||||
strcat(conninfo, "'");
|
||||
}
|
||||
if (password) {
|
||||
strcat(conninfo, " password='");
|
||||
strcat(conninfo, password);
|
||||
strcat(conninfo, "'");
|
||||
}
|
||||
if (host) {
|
||||
strcat(conninfo, " host='");
|
||||
strcat(conninfo, host);
|
||||
strcat(conninfo, "'");
|
||||
}
|
||||
if (port) {
|
||||
strcat(conninfo, " port='");
|
||||
strcat(conninfo, port);
|
||||
strcat(conninfo, "'");
|
||||
}
|
||||
|
||||
return conninfo;
|
||||
}
|
||||
Reference in New Issue
Block a user