diff options
Diffstat (limited to 'src/interfaces/libpq')
| -rw-r--r-- | src/interfaces/libpq/fe-auth.c | 100 | ||||
| -rw-r--r-- | src/interfaces/libpq/fe-auth.h | 3 | ||||
| -rw-r--r-- | src/interfaces/libpq/fe-connect.c | 93 | ||||
| -rw-r--r-- | src/interfaces/libpq/fe-exec.c | 117 | ||||
| -rw-r--r-- | src/interfaces/libpq/fe-lobj.c | 32 | ||||
| -rw-r--r-- | src/interfaces/libpq/fe-misc.c | 97 | ||||
| -rw-r--r-- | src/interfaces/libpq/fe-print.c | 4 | ||||
| -rw-r--r-- | src/interfaces/libpq/libpq-fe.h | 17 | ||||
| -rw-r--r-- | src/interfaces/libpq/libpq-int.h | 39 | ||||
| -rw-r--r-- | src/interfaces/libpq/libpqdll.c | 8 | ||||
| -rw-r--r-- | src/interfaces/libpq/pqexpbuffer.c | 4 | ||||
| -rw-r--r-- | src/interfaces/libpq/pqexpbuffer.h | 9 | ||||
| -rw-r--r-- | src/interfaces/libpq/pqsignal.h | 3 | ||||
| -rw-r--r-- | src/interfaces/libpq/win32.h | 4 |
14 files changed, 248 insertions, 282 deletions
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index 4b4b039910..8cfc1d940f 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -10,7 +10,7 @@ * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.61 2001/09/26 19:54:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.62 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -231,7 +231,6 @@ pg_krb4_sendauth(char *PQerrormsg, int sock, } return STATUS_OK; } - #endif /* KRB4 */ #ifdef KRB5 @@ -405,7 +404,7 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, if (retval == KRB5_SENDAUTH_REJECTED && err_ret) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 5 authentication rejected: %*s\n"), + libpq_gettext("Kerberos 5 authentication rejected: %*s\n"), err_ret->text.length, err_ret->text.data); } else @@ -432,33 +431,34 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, return ret; } - #endif /* KRB5 */ static int pg_local_sendauth(char *PQerrormsg, PGconn *conn) { #if defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || (defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS)) - char buf; + char buf; struct iovec iov; struct msghdr msg; + #ifdef HAVE_STRUCT_CMSGCRED /* Prevent padding */ - char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct cmsgcred)]; + char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct cmsgcred)]; + /* Point to start of first structure */ - struct cmsghdr *cmsg = (struct cmsghdr *)cmsgmem; + struct cmsghdr *cmsg = (struct cmsghdr *) cmsgmem; #endif #ifdef HAVE_STRUCT_SOCKCRED /* Prevent padding */ - char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct sockcred)]; + char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct sockcred)]; + /* Point to start of first structure */ - struct cmsghdr *cmsg = (struct cmsghdr *)cmsgmem; + struct cmsghdr *cmsg = (struct cmsghdr *) cmsgmem; #endif /* - * The backend doesn't care what we send here, but it wants - * exactly one character to force recvmsg() to block and wait - * for us. + * The backend doesn't care what we send here, but it wants exactly + * one character to force recvmsg() to block and wait for us. */ buf = '\0'; iov.iov_base = &buf; @@ -481,13 +481,13 @@ pg_local_sendauth(char *PQerrormsg, PGconn *conn) if (sendmsg(conn->sock, &msg, 0) == -1) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "pg_local_sendauth: sendmsg: %s\n", strerror(errno)); + "pg_local_sendauth: sendmsg: %s\n", strerror(errno)); return STATUS_ERROR; } return STATUS_OK; #else snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("SCM_CRED authentication method not supported\n")); + libpq_gettext("SCM_CRED authentication method not supported\n")); return STATUS_ERROR; #endif } @@ -495,51 +495,51 @@ pg_local_sendauth(char *PQerrormsg, PGconn *conn) static int pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq) { - int ret; - char *crypt_pwd; + int ret; + char *crypt_pwd; /* Encrypt the password if needed. */ switch (areq) { case AUTH_REQ_MD5: - { - char *crypt_pwd2; - - if (!(crypt_pwd = malloc(MD5_PASSWD_LEN+1)) || - !(crypt_pwd2 = malloc(MD5_PASSWD_LEN+1))) - { - perror("malloc"); - return STATUS_ERROR; - } - if (!EncryptMD5(password, conn->pguser, - strlen(conn->pguser), crypt_pwd2)) { - free(crypt_pwd); + char *crypt_pwd2; + + if (!(crypt_pwd = malloc(MD5_PASSWD_LEN + 1)) || + !(crypt_pwd2 = malloc(MD5_PASSWD_LEN + 1))) + { + perror("malloc"); + return STATUS_ERROR; + } + if (!EncryptMD5(password, conn->pguser, + strlen(conn->pguser), crypt_pwd2)) + { + free(crypt_pwd); + free(crypt_pwd2); + return STATUS_ERROR; + } + if (!EncryptMD5(crypt_pwd2 + strlen("md5"), conn->md5Salt, + sizeof(conn->md5Salt), crypt_pwd)) + { + free(crypt_pwd); + free(crypt_pwd2); + return STATUS_ERROR; + } free(crypt_pwd2); - return STATUS_ERROR; + break; } - if (!EncryptMD5(crypt_pwd2 + strlen("md5"), conn->md5Salt, - sizeof(conn->md5Salt), crypt_pwd)) - { - free(crypt_pwd); - free(crypt_pwd2); - return STATUS_ERROR; - } - free(crypt_pwd2); - break; - } case AUTH_REQ_CRYPT: - { - char salt[3]; + { + char salt[3]; - StrNCpy(salt, conn->cryptSalt,3); - crypt_pwd = crypt(password, salt); - break; - } + StrNCpy(salt, conn->cryptSalt, 3); + crypt_pwd = crypt(password, salt); + break; + } case AUTH_REQ_PASSWORD: /* discard const so we can assign it */ - crypt_pwd = (char *)password; + crypt_pwd = (char *) password; break; default: return STATUS_ERROR; @@ -573,13 +573,13 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname, hostname) != STATUS_OK) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 4 authentication failed\n")); + libpq_gettext("Kerberos 4 authentication failed\n")); return STATUS_ERROR; } break; #else snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 4 authentication not supported\n")); + libpq_gettext("Kerberos 4 authentication not supported\n")); return STATUS_ERROR; #endif @@ -590,13 +590,13 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname, hostname) != STATUS_OK) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 5 authentication failed\n")); + libpq_gettext("Kerberos 5 authentication failed\n")); return STATUS_ERROR; } break; #else snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 5 authentication not supported\n")); + libpq_gettext("Kerberos 5 authentication not supported\n")); return STATUS_ERROR; #endif diff --git a/src/interfaces/libpq/fe-auth.h b/src/interfaces/libpq/fe-auth.h index ed8d5b7774..4d99399cb9 100644 --- a/src/interfaces/libpq/fe-auth.h +++ b/src/interfaces/libpq/fe-auth.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: fe-auth.h,v 1.12 2001/01/24 19:43:30 momjian Exp $ + * $Id: fe-auth.h,v 1.13 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,5 +41,4 @@ extern char *fe_getauthname(char *PQerrormsg); #define PG_KRB4_VERSION "PGVER4.1" /* at most KRB_SENDAUTH_VLEN chars */ #define PG_KRB5_VERSION "PGVER5.1" - #endif /* FE_AUTH_H */ diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 8829c69e32..69bd5fa591 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.177 2001/09/06 04:57:30 ishii Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.178 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,13 +59,11 @@ inet_aton(const char *cp, struct in_addr * inp) inp->s_addr = a; return 1; } - #endif #ifdef USE_SSL static SSL_CTX *SSL_context = NULL; - #endif #define NOTIFYLIST_INITIAL_SIZE 10 @@ -99,7 +97,6 @@ static SSL_CTX *SSL_context = NULL; * ---------- */ static const PQconninfoOption PQconninfoOptions[] = { - /* * "authtype" is no longer used, so mark it "don't show". We keep it * in the array so as not to reject conninfo strings from old apps @@ -191,7 +188,7 @@ static int parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage); -/* +/* * Connecting to a Database * * There are now four different ways a user of this API can connect to the @@ -576,7 +573,7 @@ update_db_info(PGconn *conn) /*------- * new style: - * <tcp|unix>:postgresql://server[:port|:/unixsocket/path:] + * <tcp|unix>:postgresql://server[:port|:/unixsocket/path:] * [/db name][?options] *------- */ @@ -601,7 +598,6 @@ update_db_info(PGconn *conn) } else { - /* * Why do we default only this value from the environment * again? @@ -676,7 +672,6 @@ update_db_info(PGconn *conn) return 0; } - #endif /* NOT_USED */ @@ -696,13 +691,13 @@ connectMakeNonblocking(PGconn *conn) #if defined(WIN32) if (ioctlsocket(conn->sock, FIONBIO, &on) != 0) #elif defined(__BEOS__) - if (ioctl(conn->sock, FIONBIO, &on) != 0) + if (ioctl(conn->sock, FIONBIO, &on) != 0) #else if (fcntl(conn->sock, F_SETFL, O_NONBLOCK) < 0) #endif { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not set socket to non-blocking mode: %s\n"), + libpq_gettext("could not set socket to non-blocking mode: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); return 0; } @@ -726,7 +721,7 @@ connectNoDelay(PGconn *conn) sizeof(on)) < 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not set socket to TCP no delay mode: %s\n"), + libpq_gettext("could not set socket to TCP no delay mode: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); return 0; } @@ -746,19 +741,19 @@ connectFailureMessage(PGconn *conn, int errorno) if (conn->raddr.sa.sa_family == AF_UNIX) printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "could not connect to server: %s\n" - "\tIs the server running locally and accepting\n" - "\tconnections on Unix domain socket \"%s\"?\n" - ), + "could not connect to server: %s\n" + "\tIs the server running locally and accepting\n" + "\tconnections on Unix domain socket \"%s\"?\n" + ), SOCK_STRERROR(errorno), conn->raddr.un.sun_path); else printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "could not connect to server: %s\n" - "\tIs the server running on host %s and accepting\n" - "\tTCP/IP connections on port %s?\n" - ), + "could not connect to server: %s\n" + "\tIs the server running on host %s and accepting\n" + "\tTCP/IP connections on port %s?\n" + ), SOCK_STRERROR(errorno), conn->pghost ? conn->pghost @@ -785,7 +780,6 @@ connectDBStart(PGconn *conn) #ifdef USE_SSL StartupPacket np; /* Used to negotiate SSL connection */ char SSLok; - #endif if (!conn) @@ -944,7 +938,7 @@ connectDBStart(PGconn *conn) if (pqPacketSend(conn, (char *) &np, sizeof(StartupPacket)) != STATUS_OK) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not send SSL negotiation packet: %s\n"), + libpq_gettext("could not send SSL negotiation packet: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); goto connect_errReturn; } @@ -966,8 +960,8 @@ connectDBStart(PGconn *conn) if (!SSL_context) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not create SSL context: %s\n"), - ERR_reason_error_string(ERR_get_error())); + libpq_gettext("could not create SSL context: %s\n"), + ERR_reason_error_string(ERR_get_error())); goto connect_errReturn; } } @@ -976,8 +970,8 @@ connectDBStart(PGconn *conn) SSL_connect(conn->ssl) <= 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not establish SSL connection: %s\n"), - ERR_reason_error_string(ERR_get_error())); + libpq_gettext("could not establish SSL connection: %s\n"), + ERR_reason_error_string(ERR_get_error())); goto connect_errReturn; } /* SSL connection finished. Continue to send startup packet */ @@ -1053,7 +1047,6 @@ connectDBComplete(PGconn *conn) for (;;) { - /* * Wait, if necessary. Note that the initial state (just after * PQconnectStart) is to wait for the socket to select for @@ -1134,7 +1127,6 @@ PQconnectPoll(PGconn *conn) /* Get the new data */ switch (conn->status) { - /* * We really shouldn't have been polled in these two cases, * but we can handle it. @@ -1171,9 +1163,9 @@ PQconnectPoll(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "invalid connection state, " - "probably indicative of memory corruption\n" - )); + "invalid connection state, " + "probably indicative of memory corruption\n" + )); goto error_return; } @@ -1261,7 +1253,7 @@ keep_going: /* We will come back to here until there sizeof(StartupPacket)) != STATUS_OK) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not send startup packet: %s\n"), + libpq_gettext("could not send startup packet: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); goto error_return; } @@ -1317,9 +1309,9 @@ keep_going: /* We will come back to here until there { printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "expected authentication request from " - "server, but received %c\n" - ), + "expected authentication request from " + "server, but received %c\n" + ), beresp); goto error_return; } @@ -1404,7 +1396,6 @@ keep_going: /* We will come back to here until there case CONNECTION_AUTH_OK: { - /* * Now we expect to hear from the backend. A ReadyForQuery * message indicates that startup is successful, but we @@ -1489,9 +1480,9 @@ keep_going: /* We will come back to here until there default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "invalid connection state %c, " - "probably indicative of memory corruption\n" - ), + "invalid connection state %c, " + "probably indicative of memory corruption\n" + ), conn->status); goto error_return; } @@ -1549,7 +1540,6 @@ PQsetenvPoll(PGconn *conn) #ifdef MULTIBYTE static const char envname[] = "PGCLIENTENCODING"; - #endif if (conn == NULL || conn->status == CONNECTION_BAD) @@ -1589,9 +1579,9 @@ PQsetenvPoll(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "invalid setenv state %c, " - "probably indicative of memory corruption\n" - ), + "invalid setenv state %c, " + "probably indicative of memory corruption\n" + ), conn->setenv_state); goto error_return; } @@ -1610,7 +1600,6 @@ keep_going: /* We will come back to here until there env = getenv(envname); if (!env || *env == '\0') { - /* * query server encoding if PGCLIENTENCODING is not * specified @@ -1756,7 +1745,7 @@ keep_going: /* We will come back to here until there default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext("invalid state %c, " - "probably indicative of memory corruption\n"), + "probably indicative of memory corruption\n"), conn->setenv_state); goto error_return; } @@ -1793,7 +1782,6 @@ PQsetenv(PGconn *conn) for (;;) { - /* * Wait, if necessary. Note that the initial state (just after * PQsetenvStart) is to wait for the socket to select for writing. @@ -1834,7 +1822,6 @@ PQsetenv(PGconn *conn) flag = PQsetenvPoll(conn); } } - #endif /* NOT_USED */ @@ -1955,11 +1942,12 @@ freePGconn(PGconn *conn) static void closePGconn(PGconn *conn) { - /* Note that the protocol doesn't allow us to send Terminate - messages during the startup phase. */ + /* + * Note that the protocol doesn't allow us to send Terminate messages + * during the startup phase. + */ if (conn->sock >= 0 && conn->status == CONNECTION_OK) { - /* * Try to send "close connection" message to backend. Ignore any * error. Note: this routine used to go to substantial lengths to @@ -2298,7 +2286,6 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage) { if (group_found) { - /* * Finally, we are in the right group and can parse * the line @@ -2507,7 +2494,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage) if (option->keyword == NULL) { printfPQExpBuffer(errorMessage, - libpq_gettext("invalid connection option \"%s\"\n"), + libpq_gettext("invalid connection option \"%s\"\n"), pname); PQconninfoFree(options); free(buf); @@ -2758,14 +2745,13 @@ PQsetClientEncoding(PGconn *conn, const char *encoding) return (status); } -#else /* without multibytle support */ +#else /* without multibytle support */ int PQsetClientEncoding(PGconn *conn, const char *encoding) { return -1; } - #endif #ifdef USE_SSL @@ -2776,7 +2762,6 @@ PQgetssl(PGconn *conn) return NULL; return conn->ssl; } - #endif void diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 2741ec67aa..123d7abd12 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.112 2001/09/14 17:46:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.113 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,31 +67,33 @@ static int getNotice(PGconn *conn); */ size_t -PQescapeString (char *to, const char *from, size_t length) +PQescapeString(char *to, const char *from, size_t length) { const char *source = from; - char *target = to; + char *target = to; unsigned int remaining = length; - while (remaining > 0) { - switch (*source) { - case '\\': - *target = '\\'; - target++; - *target = '\\'; - /* target and remaining are updated below. */ - break; + while (remaining > 0) + { + switch (*source) + { + case '\\': + *target = '\\'; + target++; + *target = '\\'; + /* target and remaining are updated below. */ + break; - case '\'': - *target = '\''; - target++; - *target = '\''; - /* target and remaining are updated below. */ - break; + case '\'': + *target = '\''; + target++; + *target = '\''; + /* target and remaining are updated below. */ + break; - default: - *target = *source; - /* target and remaining are updated below. */ + default: + *target = *source; + /* target and remaining are updated below. */ } source++; target++; @@ -100,7 +102,7 @@ PQescapeString (char *to, const char *from, size_t length) /* Write the terminating NUL character. */ *target = '\0'; - + return target - to; } @@ -117,11 +119,11 @@ PQescapeString (char *to, const char *from, size_t length) unsigned char * PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen) { - unsigned char *vp; - unsigned char *rp; - unsigned char *result; - size_t i; - size_t len; + unsigned char *vp; + unsigned char *rp; + unsigned char *result; + size_t i; + size_t len; /* * empty string has 1 char ('\0') @@ -253,7 +255,7 @@ PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen) * and the Perl5 interface, so maybe it's not so unreasonable. */ -PGresult * +PGresult * PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status) { PGresult *result; @@ -346,7 +348,7 @@ pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary) } /* If there's enough space in the current block, no problem. */ - if (nBytes <= (size_t)res->spaceLeft) + if (nBytes <= (size_t) res->spaceLeft) { space = res->curBlock->space + res->curOffset; res->curOffset += nBytes; @@ -369,7 +371,6 @@ pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary) space = block->space + PGRESULT_BLOCK_OVERHEAD; if (res->curBlock) { - /* * Tuck special block below the active block, so that we don't * have to waste the free space in the active block. @@ -515,7 +516,6 @@ pqClearAsyncResult(PGconn *conn) static void saveErrorResult(PGconn *conn) { - /* * If no old async result, just let PQmakeEmptyPGresult make one. * Likewise if old result is not an error message. @@ -558,7 +558,6 @@ prepareAsyncResult(PGconn *conn) res = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR); else { - /* * Make sure PQerrorMessage agrees with result; it could be * different if we have concatenated messages. @@ -580,7 +579,6 @@ addTuple(PGresult *res, PGresAttValue * tup) { if (res->ntups >= res->tupArrSize) { - /* * Try to grow the array. * @@ -632,7 +630,7 @@ PQsendQuery(PGconn *conn, const char *query) if (!query) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("command string is a null pointer\n")); + libpq_gettext("command string is a null pointer\n")); return 0; } @@ -647,7 +645,7 @@ PQsendQuery(PGconn *conn, const char *query) if (conn->asyncStatus != PGASYNC_IDLE) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("another command is already in progress\n")); + libpq_gettext("another command is already in progress\n")); return 0; } @@ -669,7 +667,6 @@ PQsendQuery(PGconn *conn, const char *query) */ if (pqIsnonblocking(conn)) { - /* * the buffer must have emptied completely before we allow a new * query to be buffered @@ -692,7 +689,6 @@ PQsendQuery(PGconn *conn, const char *query) } else { - /* * the frontend-backend protocol uses 'Q' to designate queries */ @@ -721,7 +717,6 @@ PQsendQuery(PGconn *conn, const char *query) static void handleSendFailure(PGconn *conn) { - /* * Accept any available input data, ignoring errors. Note that if * pqReadData decides the backend has closed the channel, it will @@ -757,7 +752,6 @@ PQconsumeInput(PGconn *conn) */ if (pqReadData(conn) < 0) { - /* * for non-blocking connections try to flush the send-queue * otherwise we may never get a responce for something that may @@ -789,7 +783,6 @@ parseInput(PGconn *conn) */ for (;;) { - /* * Quit if in COPY_OUT state: we expect raw data from the server * until PQendcopy is called. Don't try to parse it according to @@ -860,7 +853,6 @@ parseInput(PGconn *conn) } else { - /* * In BUSY state, we can process everything. */ @@ -929,7 +921,6 @@ parseInput(PGconn *conn) } else { - /* * A new 'T' message is treated as the start of * another PGresult. (It is not clear that this @@ -984,7 +975,7 @@ parseInput(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "unexpected response from server; first received character was \"%c\"\n"), + "unexpected response from server; first received character was \"%c\"\n"), id); /* build an error result holding the error message */ saveErrorResult(conn); @@ -1147,7 +1138,7 @@ getAnotherTuple(PGconn *conn, int binary) vlen = 0; if (tup[i].value == NULL) { - tup[i].value = (char *) pqResultAlloc(result, vlen + 1, (bool)binary); + tup[i].value = (char *) pqResultAlloc(result, vlen + 1, (bool) binary); if (tup[i].value == NULL) goto outOfMemory; } @@ -1228,7 +1219,7 @@ PQisBusy(PGconn *conn) * Returns NULL if and only if no query work remains. */ -PGresult * +PGresult * PQgetResult(PGconn *conn) { PGresult *res; @@ -1246,7 +1237,6 @@ PQgetResult(PGconn *conn) if (pqWait(TRUE, FALSE, conn) || pqReadData(conn) < 0) { - /* * conn->errorMessage has been set by pqWait or pqReadData. We * want to append it to any already-received error message. @@ -1278,7 +1268,7 @@ PQgetResult(PGconn *conn) break; default: printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("unexpected asyncStatus: %d\n"), + libpq_gettext("unexpected asyncStatus: %d\n"), (int) conn->asyncStatus); res = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR); break; @@ -1300,7 +1290,7 @@ PQgetResult(PGconn *conn) * when done with it. */ -PGresult * +PGresult * PQexec(PGconn *conn, const char *query) { PGresult *result; @@ -1328,7 +1318,7 @@ PQexec(PGconn *conn, const char *query) { PQclear(result); printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("COPY state must be terminated first\n")); + libpq_gettext("COPY state must be terminated first\n")); /* restore blocking status */ goto errout; } @@ -1445,7 +1435,7 @@ getNotify(PGconn *conn) * the CALLER is responsible for FREE'ing the structure returned */ -PGnotify * +PGnotify * PQnotifies(PGconn *conn) { Dlelem *e; @@ -1757,7 +1747,7 @@ PQendcopy(PGconn *conn) * ---------------- */ -PGresult * +PGresult * PQfn(PGconn *conn, int fnid, int *result_buf, @@ -1787,9 +1777,9 @@ PQfn(PGconn *conn, return NULL; } - if (pqPuts("F ", conn) != 0 || /* function */ - pqPutInt(fnid, 4, conn) != 0 || /* function id */ - pqPutInt(nargs, 4, conn) != 0) /* # of args */ + if (pqPuts("F ", conn) != 0 || /* function */ + pqPutInt(fnid, 4, conn) != 0 || /* function id */ + pqPutInt(nargs, 4, conn) != 0) /* # of args */ { handleSendFailure(conn); return NULL; @@ -1885,7 +1875,7 @@ PQfn(PGconn *conn, { /* The backend violates the protocol. */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("protocol error: id=0x%x\n"), + libpq_gettext("protocol error: id=0x%x\n"), id); saveErrorResult(conn); conn->inStart = conn->inCursor; @@ -1919,7 +1909,7 @@ PQfn(PGconn *conn, default: /* The backend violates the protocol. */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("protocol error: id=0x%x\n"), + libpq_gettext("protocol error: id=0x%x\n"), id); saveErrorResult(conn); conn->inStart = conn->inCursor; @@ -2007,7 +1997,7 @@ check_field_number(const PGresult *res, int field_num) if (res->noticeHook) { snprintf(noticeBuf, sizeof(noticeBuf), - libpq_gettext("column number %d is out of range 0..%d\n"), + libpq_gettext("column number %d is out of range 0..%d\n"), field_num, res->numAttributes - 1); DONOTICE(res, noticeBuf); } @@ -2029,8 +2019,8 @@ check_tuple_field_number(const PGresult *res, if (res->noticeHook) { snprintf(noticeBuf, sizeof(noticeBuf), - libpq_gettext("row number %d is out of range 0..%d\n"), - tup_num, res->ntups - 1); + libpq_gettext("row number %d is out of range 0..%d\n"), + tup_num, res->ntups - 1); DONOTICE(res, noticeBuf); } return FALSE; @@ -2040,8 +2030,8 @@ check_tuple_field_number(const PGresult *res, if (res->noticeHook) { snprintf(noticeBuf, sizeof(noticeBuf), - libpq_gettext("column number %d is out of range 0..%d\n"), - field_num, res->numAttributes - 1); + libpq_gettext("column number %d is out of range 0..%d\n"), + field_num, res->numAttributes - 1); DONOTICE(res, noticeBuf); } return FALSE; @@ -2152,7 +2142,6 @@ PQcmdStatus(PGresult *res) char * PQoidStatus(const PGresult *res) { - /* * This must be enough to hold the result. Don't laugh, this is better * than what this function used to do. @@ -2188,7 +2177,7 @@ PQoidValue(const PGresult *res) return InvalidOid; #ifdef WIN32 - SetLastError(0); + SetLastError(0); #else errno = 0; #endif @@ -2225,8 +2214,8 @@ PQcmdTuples(PGresult *res) if (res->noticeHook) { snprintf(noticeBuf, sizeof(noticeBuf), - libpq_gettext("could not interpret result from server: %s\n"), - res->cmdStatus); + libpq_gettext("could not interpret result from server: %s\n"), + res->cmdStatus); DONOTICE(res, noticeBuf); } return ""; diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c index 7be372d6a3..99a1724bc1 100644 --- a/src/interfaces/libpq/fe-lobj.c +++ b/src/interfaces/libpq/fe-lobj.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.39 2001/09/17 20:05:47 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.40 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -397,7 +397,7 @@ lo_import(PGconn *conn, const char *filename) if (fd < 0) { /* error */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open file \"%s\": %s\n"), + libpq_gettext("could not open file \"%s\": %s\n"), filename, strerror(errno)); return InvalidOid; } @@ -409,7 +409,7 @@ lo_import(PGconn *conn, const char *filename) if (lobjOid == InvalidOid) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not create large object for file \"%s\"\n"), + libpq_gettext("could not create large object for file \"%s\"\n"), filename); (void) close(fd); return InvalidOid; @@ -419,7 +419,7 @@ lo_import(PGconn *conn, const char *filename) if (lobj == -1) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open large object %u\n"), + libpq_gettext("could not open large object %u\n"), lobjOid); (void) close(fd); return InvalidOid; @@ -434,7 +434,7 @@ lo_import(PGconn *conn, const char *filename) if (tmp < nbytes) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("error while reading file \"%s\"\n"), + libpq_gettext("error while reading file \"%s\"\n"), filename); (void) close(fd); (void) lo_close(conn, lobj); @@ -469,7 +469,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) if (lobj == -1) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open large object %u\n"), lobjId); + libpq_gettext("could not open large object %u\n"), lobjId); return -1; } @@ -480,7 +480,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) if (fd < 0) { /* error */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open file \"%s\": %s\n"), + libpq_gettext("could not open file \"%s\": %s\n"), filename, strerror(errno)); (void) lo_close(conn, lobj); return -1; @@ -495,7 +495,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) if (tmp < nbytes) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("error while writing to file \"%s\"\n"), + libpq_gettext("error while writing to file \"%s\"\n"), filename); (void) lo_close(conn, lobj); (void) close(fd); @@ -599,56 +599,56 @@ lo_initialize(PGconn *conn) if (lobjfuncs->fn_lo_open == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_open\n")); + libpq_gettext("cannot determine OID of function lo_open\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_close == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_close\n")); + libpq_gettext("cannot determine OID of function lo_close\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_creat == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_creat\n")); + libpq_gettext("cannot determine OID of function lo_creat\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_unlink == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_unlink\n")); + libpq_gettext("cannot determine OID of function lo_unlink\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_lseek == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_lseek\n")); + libpq_gettext("cannot determine OID of function lo_lseek\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_tell == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_tell\n")); + libpq_gettext("cannot determine OID of function lo_tell\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_read == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function loread\n")); + libpq_gettext("cannot determine OID of function loread\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_write == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lowrite\n")); + libpq_gettext("cannot determine OID of function lowrite\n")); free(lobjfuncs); return -1; } diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index cb7684e88f..2a75ce43d7 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -25,7 +25,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.57 2001/09/30 16:23:30 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.58 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,16 +59,16 @@ #define DONOTICE(conn,message) \ ((*(conn)->noticeHook) ((conn)->noticeArg, (message))) -static int pqPutBytes(const char *s, size_t nbytes, PGconn *conn); +static int pqPutBytes(const char *s, size_t nbytes, PGconn *conn); /* * pqGetc: - * get a character from the connection + * get a character from the connection * - * All these routines return 0 on success, EOF on error. - * Note that for the Get routines, EOF only means there is not enough - * data in the buffer, not that there is necessarily a hard error. + * All these routines return 0 on success, EOF on error. + * Note that for the Get routines, EOF only means there is not enough + * data in the buffer, not that there is necessarily a hard error. */ int pqGetc(char *result, PGconn *conn) @@ -116,7 +116,6 @@ pqPutBytes(const char *s, size_t nbytes, PGconn *conn) */ if (pqIsnonblocking(conn) && nbytes > avail && pqFlush(conn)) { - /* * even if the flush failed we may still have written some data, * recalculate the size of the send-queue relative to the amount @@ -129,7 +128,7 @@ pqPutBytes(const char *s, size_t nbytes, PGconn *conn) { printfPQExpBuffer(&conn->errorMessage, libpq_gettext("could not flush enough data (space available: %d, space needed %d)\n"), - Max(conn->outBufSize - conn->outCount, 0), nbytes); + Max(conn->outBufSize - conn->outCount, 0), nbytes); return EOF; } /* fixup avail for while loop */ @@ -211,7 +210,7 @@ pqPuts(const char *s, PGconn *conn) /* * pqGetnchar: - * get a string of exactly len bytes in buffer s, no null termination + * get a string of exactly len bytes in buffer s, no null termination */ int pqGetnchar(char *s, size_t len, PGconn *conn) @@ -232,7 +231,7 @@ pqGetnchar(char *s, size_t len, PGconn *conn) /* * pqPutnchar: - * send a string of exactly len bytes, no null termination needed + * send a string of exactly len bytes, no null termination needed */ int pqPutnchar(const char *s, size_t len, PGconn *conn) @@ -248,8 +247,8 @@ pqPutnchar(const char *s, size_t len, PGconn *conn) /* * pgGetInt - * read a 2 or 4 byte integer and convert from network byte order - * to local byte order + * read a 2 or 4 byte integer and convert from network byte order + * to local byte order */ int pqGetInt(int *result, size_t bytes, PGconn *conn) @@ -484,7 +483,7 @@ tryAgain: goto definitelyFailed; #endif printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not receive data from server: %s\n"), + libpq_gettext("could not receive data from server: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); return -1; } @@ -570,7 +569,7 @@ tryAgain2: goto definitelyFailed; #endif printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not receive data from server: %s\n"), + libpq_gettext("could not receive data from server: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); return -1; } @@ -587,9 +586,9 @@ tryAgain2: definitelyFailed: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "server closed the connection unexpectedly\n" - "\tThis probably means the server terminated abnormally\n" - "\tbefore or while processing the request.\n")); + "server closed the connection unexpectedly\n" + "\tThis probably means the server terminated abnormally\n" + "\tbefore or while processing the request.\n")); conn->status = CONNECTION_BAD; /* No more connection to backend */ #ifdef WIN32 closesocket(conn->sock); @@ -647,7 +646,6 @@ pqFlush(PGconn *conn) if (sent < 0) { - /* * Anything except EAGAIN or EWOULDBLOCK is trouble. If it's * EPIPE or ECONNRESET, assume we've lost the backend @@ -672,9 +670,9 @@ pqFlush(PGconn *conn) #endif printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "server closed the connection unexpectedly\n" - "\tThis probably means the server terminated abnormally\n" - "\tbefore or while processing the request.\n")); + "server closed the connection unexpectedly\n" + "\tThis probably means the server terminated abnormally\n" + "\tbefore or while processing the request.\n")); /* * We used to close the socket here, but that's a bad @@ -688,7 +686,7 @@ pqFlush(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not send data to server: %s\n"), + libpq_gettext("could not send data to server: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); /* We don't assume it's a fatal error... */ return EOF; @@ -832,7 +830,6 @@ PQenv2encoding(void) { return 0; } - #endif /* MULTIBYTE */ @@ -840,7 +837,7 @@ PQenv2encoding(void) char * libpq_gettext(const char *msgid) { - static int already_bound = 0; + static int already_bound = 0; if (!already_bound) { @@ -850,7 +847,7 @@ libpq_gettext(const char *msgid) return dgettext("libpq", msgid); } -#endif /* ENABLE_NLS */ +#endif /* ENABLE_NLS */ #ifdef WIN32 /* @@ -860,41 +857,41 @@ libpq_gettext(const char *msgid) * If you can verify this working on win9x or have a solution, let us know, ok? * */ -const char* +const char * winsock_strerror(DWORD eno) { - #define WSSE_MAXLEN (sizeof(winsock_strerror_buf)-1-12) /* 12 == "(0x00000000)" */ - int length; +#define WSSE_MAXLEN (sizeof(winsock_strerror_buf)-1-12) /* 12 == "(0x00000000)" */ + int length; + + /* First try the "system table", this works on Win2k pro */ - /* First try the "system table", this works on Win2k pro */ + if (FormatMessage( + FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + 0, eno, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + winsock_strerror_buf, WSSE_MAXLEN, NULL + )) + goto WSSE_GOODEXIT; - if (FormatMessage( - FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM, - 0,eno,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - winsock_strerror_buf,WSSE_MAXLEN,NULL - )) - goto WSSE_GOODEXIT; + /* That didn't work, let's try the netmsg.dll */ - /* That didn't work, let's try the netmsg.dll */ + if (netmsgModule && + FormatMessage( + FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE, + 0, eno, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + winsock_strerror_buf, WSSE_MAXLEN, NULL + )) + goto WSSE_GOODEXIT; - if (netmsgModule && - FormatMessage( - FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_HMODULE, - 0,eno,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - winsock_strerror_buf,WSSE_MAXLEN,NULL - )) - goto WSSE_GOODEXIT; + /* Everything failed, just tell the user that we don't know the desc */ - /* Everything failed, just tell the user that we don't know the desc */ - - strcat(winsock_strerror_buf,"Socket error, no description available."); + strcat(winsock_strerror_buf, "Socket error, no description available."); WSSE_GOODEXIT: - length = strlen(winsock_strerror_buf); - sprintf(winsock_strerror_buf + (length<WSSE_MAXLEN?length:WSSE_MAXLEN), - "(0x%08X)",eno); + length = strlen(winsock_strerror_buf); + sprintf(winsock_strerror_buf + (length < WSSE_MAXLEN ? length : WSSE_MAXLEN), + "(0x%08X)", eno); - return winsock_strerror_buf; + return winsock_strerror_buf; } #endif diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c index f581260de0..e753e5dd52 100644 --- a/src/interfaces/libpq/fe-print.c +++ b/src/interfaces/libpq/fe-print.c @@ -10,7 +10,7 @@ * didn't really belong there. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.42 2001/03/22 04:01:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.43 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -102,7 +102,6 @@ PQprint(FILE *fout, int ws_row; int ws_col; } screen_size; - #endif nTups = PQntuples(res); @@ -152,7 +151,6 @@ PQprint(FILE *fout, #endif ) { - /* * If we think there'll be more than one screen of output, try * to pipe to the pager program. diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index 02448ef843..de8fa5636e 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-fe.h,v 1.75 2001/09/14 17:46:40 momjian Exp $ + * $Id: libpq-fe.h,v 1.76 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,11 +23,11 @@ extern "C" #include <stdio.h> #ifdef WIN32 - #define SOCK_ERRNO (WSAGetLastError ()) - #define SOCK_STRERROR winsock_strerror +#define SOCK_ERRNO (WSAGetLastError ()) +#define SOCK_STRERROR winsock_strerror #else - #define SOCK_ERRNO errno - #define SOCK_STRERROR strerror +#define SOCK_ERRNO errno +#define SOCK_STRERROR strerror #endif @@ -44,7 +44,6 @@ extern "C" typedef enum { - /* * Although you may decide to change this list in some way, values * which become unused should never be removed, nor should @@ -252,13 +251,13 @@ extern "C" /* === in fe-exec.c === */ /* Quoting strings before inclusion in queries. */ - extern size_t PQescapeString (char *to, const char *from, size_t length); + extern size_t PQescapeString(char *to, const char *from, size_t length); extern unsigned char *PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen); /* Simple synchronous query */ extern PGresult *PQexec(PGconn *conn, const char *query); extern PGnotify *PQnotifies(PGconn *conn); - extern void PQfreeNotify(PGnotify *notify); + extern void PQfreeNotify(PGnotify *notify); /* Interface for multiple-result or asynchronous queries */ extern int PQsendQuery(PGconn *conn, const char *query); @@ -374,7 +373,5 @@ extern "C" #ifdef __cplusplus } - #endif - #endif /* LIBPQ_FE_H */ diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h index 6b088e94d7..26acd3ed83 100644 --- a/src/interfaces/libpq/libpq-int.h +++ b/src/interfaces/libpq/libpq-int.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-int.h,v 1.40 2001/10/03 21:58:28 tgl Exp $ + * $Id: libpq-int.h,v 1.41 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -139,7 +139,7 @@ struct pg_result */ PQnoticeProcessor noticeHook; /* notice/error message processor */ void *noticeArg; - int client_encoding;/* encoding id */ + int client_encoding; /* encoding id */ char *errMsg; /* error message, or NULL if no error */ @@ -160,22 +160,26 @@ struct pg_result /* PGAsyncStatusType defines the state of the query-execution state machine */ typedef enum { - PGASYNC_IDLE, /* nothing's happening, dude */ - PGASYNC_BUSY, /* query in progress */ - PGASYNC_READY, /* result ready for PQgetResult */ - PGASYNC_COPY_IN, /* Copy In data transfer in progress */ - PGASYNC_COPY_OUT /* Copy Out data transfer in progress */ + PGASYNC_IDLE, /* nothing's happening, dude */ + PGASYNC_BUSY, /* query in progress */ + PGASYNC_READY, /* result ready for PQgetResult */ + PGASYNC_COPY_IN,/* Copy In data transfer in progress */ + PGASYNC_COPY_OUT/* Copy Out data transfer in progress */ } PGAsyncStatusType; /* PGSetenvStatusType defines the state of the PQSetenv state machine */ typedef enum { - SETENV_STATE_OPTION_SEND, /* About to send an Environment Option */ - SETENV_STATE_OPTION_WAIT, /* Waiting for above send to complete */ + SETENV_STATE_OPTION_SEND, /* About to send an + * Environment Option */ + SETENV_STATE_OPTION_WAIT, /* Waiting for above send + * to complete */ /* these next two are only used in MULTIBYTE mode */ - SETENV_STATE_ENCODINGS_SEND,/* About to send an "encodings" query */ - SETENV_STATE_ENCODINGS_WAIT,/* Waiting for query to complete */ - SETENV_STATE_IDLE + SETENV_STATE_ENCODINGS_SEND, /* About to send an + * "encodings" query */ + SETENV_STATE_ENCODINGS_WAIT, /* Waiting for query to + * complete */ + SETENV_STATE_IDLE } PGSetenvStatusType; /* large-object-access data ... allocated only if large-object code is used. */ @@ -236,8 +240,8 @@ struct pg_conn /* Miscellaneous stuff */ int be_pid; /* PID of backend --- needed for cancels */ int be_key; /* key of backend --- needed for cancels */ - char md5Salt[4]; /* password salt received from backend */ - char cryptSalt[2]; /* password salt received from backend */ + char md5Salt[4]; /* password salt received from backend */ + char cryptSalt[2]; /* password salt received from backend */ PGlobjfuncs *lobjfuncs; /* private state for large-object access * fns */ @@ -278,7 +282,7 @@ struct pg_conn /* Buffer for receiving various parts of messages */ PQExpBufferData workBuffer; /* expansible string */ - int client_encoding;/* encoding id */ + int client_encoding; /* encoding id */ }; /* String descriptions of the ExecStatusTypes. @@ -345,10 +349,11 @@ extern int pqWriteReady(PGconn *conn); #define pqIsnonblocking(conn) ((conn)->nonblocking) #ifdef ENABLE_NLS -extern char * libpq_gettext(const char *msgid) +extern char * +libpq_gettext(const char *msgid) __attribute__((format_arg(1))); + #else #define libpq_gettext(x) (x) #endif - #endif /* LIBPQ_INT_H */ diff --git a/src/interfaces/libpq/libpqdll.c b/src/interfaces/libpq/libpqdll.c index 1e7d647937..9f9c93d2f9 100644 --- a/src/interfaces/libpq/libpqdll.c +++ b/src/interfaces/libpq/libpqdll.c @@ -14,19 +14,17 @@ DllMain(HINSTANCE hinstDLL, DWORD fdwReason, case DLL_PROCESS_ATTACH: if (WSAStartup(MAKEWORD(1, 1), &wsaData)) { - /* * No really good way to do error handling here, since we * don't know how we were loaded */ return FALSE; } - if (netmsgModule == NULL){ - netmsgModule=LoadLibraryEx("netmsg.dll",NULL,LOAD_LIBRARY_AS_DATAFILE); - } + if (netmsgModule == NULL) + netmsgModule = LoadLibraryEx("netmsg.dll", NULL, LOAD_LIBRARY_AS_DATAFILE); break; case DLL_PROCESS_DETACH: - if (netmsgModule != NULL) + if (netmsgModule != NULL) FreeLibrary(netmsgModule); WSACleanup(); break; diff --git a/src/interfaces/libpq/pqexpbuffer.c b/src/interfaces/libpq/pqexpbuffer.c index 06471ee939..cf565eb9a3 100644 --- a/src/interfaces/libpq/pqexpbuffer.c +++ b/src/interfaces/libpq/pqexpbuffer.c @@ -17,7 +17,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.11 2001/08/17 15:11:15 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.12 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -174,7 +174,6 @@ printfPQExpBuffer(PQExpBuffer str, const char *fmt,...) for (;;) { - /* * Try to format the given string into the available space; but if * there's hardly any space, don't bother trying, just fall @@ -223,7 +222,6 @@ appendPQExpBuffer(PQExpBuffer str, const char *fmt,...) for (;;) { - /* * Try to format the given string into the available space; but if * there's hardly any space, don't bother trying, just fall diff --git a/src/interfaces/libpq/pqexpbuffer.h b/src/interfaces/libpq/pqexpbuffer.h index 0db0806595..9e17b314f7 100644 --- a/src/interfaces/libpq/pqexpbuffer.h +++ b/src/interfaces/libpq/pqexpbuffer.h @@ -18,7 +18,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pqexpbuffer.h,v 1.7 2001/10/03 21:58:28 tgl Exp $ + * $Id: pqexpbuffer.h,v 1.8 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -122,7 +122,8 @@ extern int enlargePQExpBuffer(PQExpBuffer str, size_t needed); * This is a convenience routine that does the same thing as * resetPQExpBuffer() followed by appendPQExpBuffer(). */ -extern void printfPQExpBuffer(PQExpBuffer str, const char *fmt, ...) +extern void +printfPQExpBuffer(PQExpBuffer str, const char *fmt,...) /* This extension allows gcc to check the format string */ __attribute__((format(printf, 2, 3))); @@ -133,7 +134,8 @@ __attribute__((format(printf, 2, 3))); * to str if necessary. This is sort of like a combination of sprintf and * strcat. */ -extern void appendPQExpBuffer(PQExpBuffer str, const char *fmt, ...) +extern void +appendPQExpBuffer(PQExpBuffer str, const char *fmt,...) /* This extension allows gcc to check the format string */ __attribute__((format(printf, 2, 3))); @@ -158,5 +160,4 @@ extern void appendPQExpBufferChar(PQExpBuffer str, char ch); */ extern void appendBinaryPQExpBuffer(PQExpBuffer str, const char *data, size_t datalen); - #endif /* PQEXPBUFFER_H */ diff --git a/src/interfaces/libpq/pqsignal.h b/src/interfaces/libpq/pqsignal.h index 3444bfb70e..b6b167c188 100644 --- a/src/interfaces/libpq/pqsignal.h +++ b/src/interfaces/libpq/pqsignal.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pqsignal.h,v 1.10 2001/02/10 02:31:30 tgl Exp $ + * $Id: pqsignal.h,v 1.11 2001/10/25 05:50:13 momjian Exp $ * * NOTES * This shouldn't be in libpq, but the monitor and some other @@ -23,5 +23,4 @@ typedef void (*pqsigfunc) (int); extern pqsigfunc pqsignal(int signo, pqsigfunc func); - #endif /* PQSIGNAL_H */ diff --git a/src/interfaces/libpq/win32.h b/src/interfaces/libpq/win32.h index 2ba2d842a6..ac6a0ea388 100644 --- a/src/interfaces/libpq/win32.h +++ b/src/interfaces/libpq/win32.h @@ -23,7 +23,7 @@ */ #define crypt(a,b) (a) -#undef EAGAIN /* doesn't apply on sockets */ +#undef EAGAIN /* doesn't apply on sockets */ #undef EINTR #define EINTR WSAEINTR #define EWOULDBLOCK WSAEWOULDBLOCK @@ -36,4 +36,4 @@ static HINSTANCE netmsgModule = NULL; static char winsock_strerror_buf[512]; -const char* winsock_strerror(DWORD eno); +const char *winsock_strerror(DWORD eno); |
