Module: sip-router Branch: janakj/postgres Commit: e39877fe6b11335e47719791bdda74f73b62bbf4 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e39877fe...
Author: Maxim Sobolev sobomax@sippysoft.com Committer: Maxim Sobolev sobomax@sippysoft.com Date: Mon Dec 6 13:02:10 2004 +0000
Change DSN parser a bit, so that it's possible to specify path to the unix domain socket for communication with DB server. Consider everything after '@' but before the last '/' to be host name (currently everything after '@' but before first '/' is considered hostname), so that in the case of the socket in the /foo/bar directory, one can specify DSN as follows:
postgres://username:password@/foo/bar/name_of_table
No response from: lgfausak@august.net
---
modules/db_postgres/db_utils.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/modules/db_postgres/db_utils.c b/modules/db_postgres/db_utils.c index d5febbb..69e722e 100644 --- a/modules/db_postgres/db_utils.c +++ b/modules/db_postgres/db_utils.c @@ -77,7 +77,9 @@ int parse_sql_url(char* _url, char** _user, char** _pass,
at = strchr(slash, '@');
- db_slash = strchr(slash, '/'); + db_slash = strrchr(slash, '/'); + if (db_slash <= at) + db_slash = NULL; if (db_slash) { *db_slash++ = '\0'; *_db = trim(db_slash);