aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-misc.c
diff options
context:
space:
mode:
authorBryan Henderson <bryanh@giraffe.netgate.net>1996-12-31 07:29:17 +0000
committerBryan Henderson <bryanh@giraffe.netgate.net>1996-12-31 07:29:17 +0000
commit8fb0ac8898d79d32b6516e604859b7ab3763043c (patch)
treea68efcff4c3786c08c541b7555e5cc96eff7fada /src/interfaces/libpq/fe-misc.c
parente2da92f1c350e3c0c038a3f214b6bbeb441bfab8 (diff)
downloadpostgresql-8fb0ac8898d79d32b6516e604859b7ab3763043c.tar.gz
postgresql-8fb0ac8898d79d32b6516e604859b7ab3763043c.zip
Make error messages more explicit, PQtrace() output more readable.
Diffstat (limited to 'src/interfaces/libpq/fe-misc.c')
-rw-r--r--src/interfaces/libpq/fe-misc.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index 852ceefe9e9..2743cd3ecd6 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.3 1996/11/03 07:14:32 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.4 1996/12/31 07:29:17 bryanh Exp $
*
*-------------------------------------------------------------------------
*/
@@ -35,7 +35,7 @@ pqGetc(FILE* fin, FILE* debug)
c = getc(fin);
if (debug && c != EOF)
- putc(c,debug);
+ fprintf(debug, "From backend> %c\n", c);
return c;
}
@@ -52,6 +52,7 @@ pqPutnchar(const char* s, int len, FILE *f, FILE *debug)
if (f == NULL)
return 1;
+ if (debug) fputs("To backend>", debug);
while (len--) {
status = fputc(*s,f);
if (debug)
@@ -60,6 +61,7 @@ pqPutnchar(const char* s, int len, FILE *f, FILE *debug)
if (status == EOF)
return 1;
}
+ if (debug) fputc('\n', debug);
return 0;
}
@@ -79,7 +81,7 @@ pqGetnchar(char* s, int len, FILE *f, FILE *debug)
*s = '\0';
if (debug) {
- fputs(s,debug);
+ fprintf(debug, "From backend> %s\n", s);
}
return 0;
}
@@ -100,7 +102,7 @@ pqGets(char* s, int len, FILE *f, FILE *debug)
*s = '\0';
if (debug) {
- fputs(s,debug);
+ fprintf(debug, "From backend> %s\n", s);
}
return 0;
}
@@ -114,22 +116,24 @@ pqGets(char* s, int len, FILE *f, FILE *debug)
returns 0 if successful, 1 otherwise
*/
int
-pqPutInt(int i, int bytes, FILE* f, FILE *debug)
+pqPutInt(const int integer, int bytes, FILE* f, FILE *debug)
{
+ int i;
int status;
+ i = integer;
+
if (bytes > 4)
bytes = 4;
while (bytes--) {
status = fputc(i & 0xff, f);
- if (debug)
- fputc(i & 0xff, debug);
i >>= 8;
if (status == EOF) {
return 1;
}
}
+ if (debug) fprintf(debug, "To backend (#)> %d\n", integer);
return 0;
}
@@ -163,7 +167,7 @@ pqGetInt(int* result, int bytes, FILE* f, FILE *debug)
*result = n;
if (debug)
- fprintf(debug,"%d",*result);
+ fprintf(debug,"From backend (#)> %d\n",*result);
return 0;
}
@@ -181,7 +185,7 @@ pqPuts(const char* s, FILE *f, FILE *debug)
fflush(f);
if (debug) {
- fputs(s,debug);
+ fprintf(debug, "To backend> %s\n", s);
}
return 0;
}
@@ -195,3 +199,5 @@ pqFlush(FILE *f, FILE *debug)
if (debug)
fflush(debug);
}
+
+