pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Giffin <david@agent911.com>
To: Ken J. Wright <ken@ori-ind.com>
Cc: pgsql-interfaces@postgreSQL.org
Subject: Re: [INTERFACES] Win32 interface
Date: Thu, 2 Sep 1999 14:57:49 -0700 (PDT)
Message-ID: <Pine.BSF.4.05.9909021448040.64764-100000@central.agent911.com> (raw)
In-Reply-To: <3.0.32.19990902134214.008e3100@ren.cncware.com>



Yep I'm using the PQconnectDB("host=blah user=blah dbname=blah");

I noticed that psql.c uses the PQsetdbLogin maybe I should switch to that
function if this one is broken? Would have to parse a little extra but..

Here is the snippet... my char *dbname comes in the form of:
 host=hostname;dbname=database;port=portnum


int
pg_login(struct dbi *dbi, char *dbname, char *user, char *pass)
{
	char *connect;
	char *source;
	char *dest;
	char *src;
	int mem;
	int sourcelen;
	mem    = strlen(dbname);
	source = malloc(mem + 10);
	if (user && pass) {
		mem += strlen(user) + strlen(pass);
	} else if (user) {
		mem += strlen(user);
	}
	src =	dbname;
	dest = source;  
	while (*src) {
		if (*src != ';') {
			*dest++ = *src++;
			continue;		
		}
		*dest++ = ' ';
		src++;
	}
  	*dest = '\0';
  	if (LOG_LEVEL >= 3) {
		fprintf(stderr,"pg_login: source -> %s\n",source);
	}
	sourcelen = strlen(source); 
	if (user && pass) {
		connect = malloc(sourcelen+strlen(user)+strlen(pass)+13);
		sprintf(connect,"%s user=%s pass=%s",source, user, pass);
	} else if (user) {
		connect = malloc(sourcelen+strlen(user) + 7);
		sprintf(connect,"%s user=%s",source, user);
	} else {
	connect = malloc(sourcelen + 1);
	sprintf(connect,"%s",source);	}
  	if (LOG_LEVEL >= 2) {
		fprintf(stderr,"pg_login: %s\n",connect);
	}
	dbi->conn = PQconnectdb(connect);
<SNIP>


On Thu, 2 Sep 1999, Ken J. Wright wrote:

> At 14:02 09/02/1999 -0700, David Giffin wrote:
> >
> >I'm trying to use the postgresql win32 interface to connect ot a UNIX
> >host. I'm using PQconnectDB() to get the connection. Each time I try to
> >connect it says unknown host name:
> >
> >connectDB() --  unknown hostname: mobile
> >
> >reguardless of specifying the ip address or the complete host name. Any
> >ideas??
> 
> are you using the proper parameter string? 
> PQconnectDB('host=hostname dbname=databasename user=username')
> 
> Otherwise maybe send code snippet to look at?
> 
> Ken
> 




view thread (12+ messages)  latest in thread

Message-ID: <Pine.BSF.4.05.9909021448040.64764-100000@central.agent911.com>
Permalink:  ../Pine.BSF.4.05.9909021448040.64764-100000@central.agent911.com/
Also on:    postgresql.org/message-id/Pine.BSF.4.05.9909021448040.64764-100000@central.agent911.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-interfaces@postgresql.org
  Cc: david@agent911.com, ken@ori-ind.com
  Subject: Re: [INTERFACES] Win32 interface
  In-Reply-To: <Pine.BSF.4.05.9909021448040.64764-100000@central.agent911.com>
  References: <3.0.32.19990902134214.008e3100@ren.cncware.com> <Pine.BSF.4.05.9909021448040.64764-100000@central.agent911.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox