Commit c4e53a14 authored by Marc G. Fournier's avatar Marc G. Fournier

Fixes for:

Here are a few minor fixes to Postgres95.  Mostly I have added const
to some of the char pointers.  There was also a missing header file
and a place where it looks like "==" was used when "=" was meant.
I also changed some variables from Pfin and Pfout tp pfin and pfout
because the latter shadow global variables and that just seems like
an unsafe practice which I like to avoid.

Submitted by:  "D'Arcy J.M. Cain" <darcy@druid.druid.com>
parent fd3b8299
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.3 1996/07/27 02:27:55 scrappy Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.4 1996/08/06 16:16:42 scrappy Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -162,16 +162,16 @@ pg_krb4_authname(char* PQerrormsg) ...@@ -162,16 +162,16 @@ pg_krb4_authname(char* PQerrormsg)
* (canonicalized to omit all domain suffixes). * (canonicalized to omit all domain suffixes).
*/ */
static int static int
pg_krb4_sendauth(char* PQerrormsg, int sock, pg_krb4_sendauth(const char* PQerrormsg, int sock,
struct sockaddr_in *laddr, struct sockaddr_in *laddr,
struct sockaddr_in *raddr, struct sockaddr_in *raddr,
char *hostname) const char *hostname)
{ {
long krbopts = 0; /* one-way authentication */ long krbopts = 0; /* one-way authentication */
KTEXT_ST clttkt; KTEXT_ST clttkt;
int status; int status;
char hostbuf[MAXHOSTNAMELEN]; char hostbuf[MAXHOSTNAMELEN];
char *realm = getenv("PGREALM"); /* NULL == current realm */ const char *realm = getenv("PGREALM"); /* NULL == current realm */
if (!hostname || !(*hostname)) { if (!hostname || !(*hostname)) {
if (gethostname(hostbuf, MAXHOSTNAMELEN) < 0) if (gethostname(hostbuf, MAXHOSTNAMELEN) < 0)
...@@ -227,7 +227,7 @@ pg_krb4_sendauth(char* PQerrormsg, int sock, ...@@ -227,7 +227,7 @@ pg_krb4_sendauth(char* PQerrormsg, int sock,
* and we can't afford to punt. * and we can't afford to punt.
*/ */
static char * static char *
pg_an_to_ln(char *aname) pg_an_to_ln(const char *aname)
{ {
char *p; char *p;
...@@ -246,7 +246,7 @@ pg_an_to_ln(char *aname) ...@@ -246,7 +246,7 @@ pg_an_to_ln(char *aname)
* *
*/ */
static int static int
krb5_ccache pg_krb5_init() krb5_ccache pg_krb5_init(void)
{ {
krb5_error_code code; krb5_error_code code;
char *realm, *defname; char *realm, *defname;
...@@ -287,8 +287,8 @@ krb5_ccache pg_krb5_init() ...@@ -287,8 +287,8 @@ krb5_ccache pg_krb5_init()
* *
* We obtain this information by digging around in the ticket file. * We obtain this information by digging around in the ticket file.
*/ */
static char * static const char *
pg_krb5_authname(char* PQerrormsg) pg_krb5_authname(const char* PQerrormsg)
{ {
krb5_ccache ccache; krb5_ccache ccache;
krb5_principal principal; krb5_principal principal;
...@@ -335,15 +335,15 @@ pg_krb5_authname(char* PQerrormsg) ...@@ -335,15 +335,15 @@ pg_krb5_authname(char* PQerrormsg)
* in the PGREALM (or local) database. This is probably a bad assumption. * in the PGREALM (or local) database. This is probably a bad assumption.
*/ */
static int static int
pg_krb5_sendauth(char* PQerrormsg,int sock, pg_krb5_sendauth(const char* PQerrormsg,int sock,
struct sockaddr_in *laddr, struct sockaddr_in *laddr,
struct sockaddr_in *raddr, struct sockaddr_in *raddr,
char *hostname) const char *hostname)
{ {
char servbuf[MAXHOSTNAMELEN + 1 + char servbuf[MAXHOSTNAMELEN + 1 +
sizeof(PG_KRB_SRVNAM)]; sizeof(PG_KRB_SRVNAM)];
char *hostp; const char *hostp;
char *realm; const char *realm;
krb5_error_code code; krb5_error_code code;
krb5_principal client, server; krb5_principal client, server;
krb5_ccache ccache; krb5_ccache ccache;
...@@ -430,7 +430,7 @@ pg_krb5_sendauth(char* PQerrormsg,int sock, ...@@ -430,7 +430,7 @@ pg_krb5_sendauth(char* PQerrormsg,int sock,
* fe_sendauth -- client demux routine for outgoing authentication information * fe_sendauth -- client demux routine for outgoing authentication information
*/ */
int int
fe_sendauth(MsgType msgtype, Port *port, char *hostname, char* PQerrormsg) fe_sendauth(MsgType msgtype, Port *port, const char *hostname, const char* PQerrormsg)
{ {
switch (msgtype) { switch (msgtype) {
#ifdef KRB4 #ifdef KRB4
...@@ -474,7 +474,7 @@ fe_sendauth(MsgType msgtype, Port *port, char *hostname, char* PQerrormsg) ...@@ -474,7 +474,7 @@ fe_sendauth(MsgType msgtype, Port *port, char *hostname, char* PQerrormsg)
static pg_authsvc = -1; static pg_authsvc = -1;
void void
fe_setauthsvc(char *name, char* PQerrormsg) fe_setauthsvc(const char *name, char* PQerrormsg)
{ {
int i; int i;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: fe-auth.h,v 1.1.1.1 1996/07/09 06:22:17 scrappy Exp $ * $Id: fe-auth.h,v 1.2 1996/08/06 16:16:44 scrappy Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
#define DEFAULT_CLIENT_AUTHSVC "kerberos" #define DEFAULT_CLIENT_AUTHSVC "kerberos"
#endif /* KRB4 || KRB5 */ #endif /* KRB4 || KRB5 */
extern int fe_sendauth(MsgType msgtype, Port *port, char *hostname, char* PQerromsg); extern int fe_sendauth(MsgType msgtype, Port *port, const char *hostname, const char* PQerromsg);
extern void fe_setauthsvc(char *name, char* PQerrormsg); extern void fe_setauthsvc(const char *name, char* PQerrormsg);
#define PG_KRB4_VERSION "PGVER4.1" /* at most KRB_SENDAUTH_VLEN chars */ #define PG_KRB4_VERSION "PGVER4.1" /* at most KRB_SENDAUTH_VLEN chars */
#define PG_KRB5_VERSION "PGVER5.1" #define PG_KRB5_VERSION "PGVER5.1"
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.4 1996/07/23 03:35:12 scrappy Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.5 1996/08/06 16:16:45 scrappy Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
standard function? (My, my. Touchy today, are we?) */ standard function? (My, my. Touchy today, are we?) */
static static
char * char *
strdup(char *string) strdup(const char *string)
{ {
char *nstr; char *nstr;
...@@ -64,10 +64,10 @@ static void closePGconn(PGconn *conn); ...@@ -64,10 +64,10 @@ static void closePGconn(PGconn *conn);
* ---------------- * ----------------
*/ */
PGconn* PGconn*
PQsetdb(char *pghost, char* pgport, char* pgoptions, char* pgtty, char* dbName) PQsetdb(const char *pghost, const char* pgport, const char* pgoptions, const char* pgtty, const char* dbName)
{ {
PGconn *conn; PGconn *conn;
char *tmp; const char *tmp;
conn = (PGconn*)malloc(sizeof(PGconn)); conn = (PGconn*)malloc(sizeof(PGconn));
......
This diff is collapsed.
...@@ -11,13 +11,14 @@ ...@@ -11,13 +11,14 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.1.1.1 1996/07/09 06:22:17 scrappy Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.2 1996/08/06 16:16:48 scrappy Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "libpq-fe.h"
/* pqGetc: /* pqGetc:
get a character from stream f get a character from stream f
...@@ -41,7 +42,7 @@ pqGetc(FILE* fin, FILE* debug) ...@@ -41,7 +42,7 @@ pqGetc(FILE* fin, FILE* debug)
returns 1 if there was an error, 0 otherwise. returns 1 if there was an error, 0 otherwise.
*/ */
int int
pqPutnchar(char* s, int len, FILE *f, FILE *debug) pqPutnchar(const char* s, int len, FILE *f, FILE *debug)
{ {
int status; int status;
...@@ -165,7 +166,7 @@ pqGetInt(int* result, int bytes, FILE* f, FILE *debug) ...@@ -165,7 +166,7 @@ pqGetInt(int* result, int bytes, FILE* f, FILE *debug)
int int
pqPuts(char* s, FILE *f, FILE *debug) pqPuts(const char* s, FILE *f, FILE *debug)
{ {
if (f == NULL) if (f == NULL)
return 1; return 1;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: libpq-fe.h,v 1.5 1996/07/31 18:40:12 scrappy Exp $ * $Id: libpq-fe.h,v 1.6 1996/08/06 16:16:50 scrappy Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -45,7 +45,7 @@ typedef enum { ...@@ -45,7 +45,7 @@ typedef enum {
} ExecStatusType; } ExecStatusType;
/* string descriptions of the ExecStatusTypes */ /* string descriptions of the ExecStatusTypes */
extern char* pgresStatus[]; extern const char* pgresStatus[];
/* /*
* POSTGRES backend dependent Constants. * POSTGRES backend dependent Constants.
...@@ -144,8 +144,8 @@ typedef struct _PQprintOpt PQprintOpt; ...@@ -144,8 +144,8 @@ typedef struct _PQprintOpt PQprintOpt;
/* === in fe-connect.c === */ /* === in fe-connect.c === */
/* make a new client connection to the backend */ /* make a new client connection to the backend */
extern PGconn* PQsetdb(char* pghost, char* pgport, char* pgoptions, extern PGconn* PQsetdb(const char* pghost, const char* pgport, const char* pgoptions,
char* pgtty, char* dbName); const char* pgtty, const char* dbName);
/* close the current connection and free the PGconn data structure */ /* close the current connection and free the PGconn data structure */
extern void PQfinish(PGconn* conn); extern void PQfinish(PGconn* conn);
/* close the current connection and restablish a new one with the same /* close the current connection and restablish a new one with the same
...@@ -163,19 +163,19 @@ extern void PQtrace(PGconn *conn, FILE* debug_port); ...@@ -163,19 +163,19 @@ extern void PQtrace(PGconn *conn, FILE* debug_port);
extern void PQuntrace(PGconn *conn); extern void PQuntrace(PGconn *conn);
/* === in fe-exec.c === */ /* === in fe-exec.c === */
extern PGresult* PQexec(PGconn* conn, char* query); extern PGresult* PQexec(PGconn* conn, const char* query);
extern int PQgetline(PGconn *conn, char* string, int length); extern int PQgetline(PGconn *conn, char* string, int length);
extern int PQendcopy(PGconn *conn); extern int PQendcopy(PGconn *conn);
extern void PQputline(PGconn *conn, char* string); extern void PQputline(PGconn *conn, const char* string);
extern ExecStatusType PQresultStatus(PGresult* res); extern ExecStatusType PQresultStatus(PGresult* res);
extern int PQntuples(PGresult *res); extern int PQntuples(PGresult *res);
extern int PQnfields(PGresult *res); extern int PQnfields(PGresult *res);
extern char* PQfname(PGresult *res, int field_num); extern char* PQfname(PGresult *res, int field_num);
extern int PQfnumber(PGresult *res, char* field_name); extern int PQfnumber(PGresult *res, const char* field_name);
extern Oid PQftype(PGresult *res, int field_num); extern Oid PQftype(PGresult *res, int field_num);
extern int2 PQfsize(PGresult *res, int field_num); extern int2 PQfsize(PGresult *res, int field_num);
extern char* PQcmdStatus(PGresult *res); extern char* PQcmdStatus(PGresult *res);
extern char* PQoidStatus(PGresult *res); extern const char* PQoidStatus(PGresult *res);
extern char* PQgetvalue(PGresult *res, int tup_num, int field_num); extern char* PQgetvalue(PGresult *res, int tup_num, int field_num);
extern int PQgetlength(PGresult *res, int tup_num, int field_num); extern int PQgetlength(PGresult *res, int tup_num, int field_num);
extern void PQclear(PGresult* res); extern void PQclear(PGresult* res);
...@@ -183,7 +183,7 @@ extern void PQclear(PGresult* res); ...@@ -183,7 +183,7 @@ extern void PQclear(PGresult* res);
extern void PQdisplayTuples(PGresult *res, extern void PQdisplayTuples(PGresult *res,
FILE *fp, /* where to send the output */ FILE *fp, /* where to send the output */
int fillAlign, /* pad the fields with spaces */ int fillAlign, /* pad the fields with spaces */
char *fieldSep, /* field separator */ const char *fieldSep, /* field separator */
int printHeader, /* display headers? */ int printHeader, /* display headers? */
int quiet); int quiet);
extern void PQprintTuples(PGresult* res, extern void PQprintTuples(PGresult* res,
...@@ -207,7 +207,7 @@ extern PGresult* PQfn(PGconn* conn, ...@@ -207,7 +207,7 @@ extern PGresult* PQfn(PGconn* conn,
int nargs); int nargs);
/* === in fe-auth.c === */ /* === in fe-auth.c === */
extern MsgType fe_getauthsvc(char* PQerrormsg); extern MsgType fe_getauthsvc(char* PQerrormsg);
extern void fe_setauthsvc(char *name, char* PQerrormsg); extern void fe_setauthsvc(const char *name, char* PQerrormsg);
extern char *fe_getauthname(char* PQerrormsg); extern char *fe_getauthname(char* PQerrormsg);
/* === in fe-misc.c === */ /* === in fe-misc.c === */
...@@ -217,8 +217,8 @@ extern char *fe_getauthname(char* PQerrormsg); ...@@ -217,8 +217,8 @@ extern char *fe_getauthname(char* PQerrormsg);
*/ */
extern int pqGets(char* s, int maxlen, FILE* stream, FILE* debug); extern int pqGets(char* s, int maxlen, FILE* stream, FILE* debug);
extern int pqGetnchar(char* s, int maxlen, FILE* stream, FILE* debug); extern int pqGetnchar(char* s, int maxlen, FILE* stream, FILE* debug);
extern int pqPutnchar(char* s, int maxlen, FILE* stream, FILE* debug); extern int pqPutnchar(const char* s, int maxlen, FILE* stream, FILE* debug);
extern int pqPuts(char* s, FILE* stream, FILE* debug ); extern int pqPuts(const char* s, FILE* stream, FILE* debug );
extern int pqGetc(FILE* stream, FILE *debug); extern int pqGetc(FILE* stream, FILE *debug);
/* get a n-byte integer from the stream into result */ /* get a n-byte integer from the stream into result */
/* returns 0 if successful */ /* returns 0 if successful */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment