aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-misc.c
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1998-01-26 01:42:53 +0000
committerMarc G. Fournier <scrappy@hub.org>1998-01-26 01:42:53 +0000
commitd5bbe2aca55bc833e38c768d7f82c129b8b70c83 (patch)
tree47f4e1ecb3277869bb276e5433df335d920d1baf /src/interfaces/libpq/fe-misc.c
parent91d983aa1140e3ae109684ff7c916583ed059e0e (diff)
downloadpostgresql-d5bbe2aca55bc833e38c768d7f82c129b8b70c83.tar.gz
postgresql-d5bbe2aca55bc833e38c768d7f82c129b8b70c83.zip
From: Phil Thompson <phil@river-bank.demon.co.uk>
I've completed the patch to fix the protocol and authentication issues I was discussing a couple of weeks ago. The particular changes are: - the protocol has a version number - network byte order is used throughout - the pg_hba.conf file is used to specify what method is used to authenticate a frontend (either password, ident, trust, reject, krb4 or krb5) - support for multiplexed backends is removed - appropriate changes to man pages - the -a switch to many programs to specify an authentication service no longer has any effect - the libpq.so version number has changed to 1.1 The new backend still supports the old protocol so old interfaces won't break.
Diffstat (limited to 'src/interfaces/libpq/fe-misc.c')
-rw-r--r--src/interfaces/libpq/fe-misc.c48
1 files changed, 12 insertions, 36 deletions
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index 9f5fd907b54..d1c18ee05ae 100644
--- a/src/interfaces/libpq/fe-misc.c
+++ b/src/interfaces/libpq/fe-misc.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.8 1997/09/08 21:55:44 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.9 1998/01/26 01:42:36 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -51,38 +51,28 @@ pqGetc(FILE *fin, FILE *debug)
int
pqPutnchar(const char *s, int len, FILE *f, FILE *debug)
{
- if (f == NULL)
- return 1;
-
if (debug)
fprintf(debug, "To backend> %s\n", s);
- if (fwrite(s, 1, len, f) != len)
- return 1;
-
- return 0;
+ return (pqPutNBytes(s, len, f) == EOF ? 1 : 0);
}
/* --------------------------------------------------------------------- */
/* pqGetnchar:
- get a string of exactly len length from stream f
+ get a string of exactly len bytes in buffer s (which must be 1 byte
+ longer) from stream f and terminate it with a '\0'.
*/
int
pqGetnchar(char *s, int len, FILE *f, FILE *debug)
{
- int cnt;
-
- if (f == NULL)
- return 1;
+ int status;
- cnt = fread(s, 1, len, f);
- s[cnt] = '\0';
- /* mjl: actually needs up to len+1 bytes, is this okay? XXX */
+ status = pqGetNBytes(s, len, f);
if (debug)
fprintf(debug, "From backend (%d)> %s\n", len, s);
- return 0;
+ return (status == EOF ? 1 : 0);
}
/* --------------------------------------------------------------------- */
@@ -92,21 +82,14 @@ pqGetnchar(char *s, int len, FILE *f, FILE *debug)
int
pqGets(char *s, int len, FILE *f, FILE *debug)
{
- int c;
- const char *str = s;
-
- if (f == NULL)
- return 1;
+ int status;
- while (len-- && (c = getc(f)) != EOF && c)
- *s++ = c;
- *s = '\0';
- /* mjl: actually needs up to len+1 bytes, is this okay? XXX */
+ status = pqGetString(s, len, f);
if (debug)
- fprintf(debug, "From backend> \"%s\"\n", str);
+ fprintf(debug, "From backend> \"%s\"\n", s);
- return 0;
+ return (status == EOF ? 1 : 0);
}
/* --------------------------------------------------------------------- */
@@ -173,20 +156,13 @@ pqGetInt(int *result, int bytes, FILE *f, FILE *debug)
int
pqPuts(const char *s, FILE *f, FILE *debug)
{
- if (f == NULL)
+ if (pqPutString(s, f) == EOF)
return 1;
- if (fputs(s, f) == EOF)
- return 1;
-
- fputc('\0', f); /* important to send an ending \0 since
- * backend expects it */
fflush(f);
if (debug)
- {
fprintf(debug, "To backend> %s\n", s);
- }
return 0;
}