38const char *
opensql(
const char *dbname,
const char **table)
40 const char *
host = (
char *) 0;
41 const char *port = (
char *) 0;
42 const char *db =
"ezmlm";
43 const char *
user = (
char *) 0;
44 const char *pw = (
char *) 0;
48 if (
fn.len == ourdb.len && !str_diffn(ourdb.s,
fn.s,
fn.len)) {
50 if (*table) ourtable = *table;
51 else *table = ourtable;
61 switch (openreadlclose(
fn.s,&myp,128)) {
70 if (!stralloc_append(&myp,
"\n"))
return ERR_NOMEM;
72 for (j = 0; j< myp.len; ++j) {
73 if (myp.s[j] ==
'\n') { myp.s[j] =
'\0';
break; }
80 if (myp.s[j = str_chr(myp.s,
':')]) {
83 if (myp.s[j += str_chr(myp.s+j,
':')]) {
86 if (myp.s[j += str_chr(myp.s+j,
':')]) {
89 if (myp.s[j += str_chr(myp.s+j,
':')]) {
92 if (myp.s[j += str_chr(myp.s+j,
':')]) {
103 if (pw && !*pw) pw = (
char *) 0;
104 if (db && !*db) db = (
char *) 0;
105 if (ourtable && !*ourtable) ourtable = (
char *) 0;
107 if (*table) ourtable = *table;
108 else *table = ourtable;
116 if (PQstatus(
pgsql) == CONNECTION_BAD)
117 return PQerrorMessage(
pgsql);