mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-28 00:01:51 +02:00
Fix some portability problems (get it to compile, at least, on HP's cc)
This commit is contained in:
parent
aa6970efff
commit
77f27d5ec3
@ -30,7 +30,8 @@
|
|||||||
* hadn't seen his code).
|
* hadn't seen his code).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <postgres.h>
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "px-crypt.h"
|
#include "px-crypt.h"
|
||||||
#define __set_errno(v)
|
#define __set_errno(v)
|
||||||
|
|
||||||
@ -38,13 +39,6 @@
|
|||||||
#define __set_errno(val) errno = (val)
|
#define __set_errno(val) errno = (val)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef __CONST
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define __CONST __const
|
|
||||||
#else
|
|
||||||
#define __CONST
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
#define BF_ASM 0 /* 1 */
|
#define BF_ASM 0 /* 1 */
|
||||||
#define BF_SCALE 1
|
#define BF_SCALE 1
|
||||||
@ -373,7 +367,7 @@ static unsigned char BF_atoi64[0x60] = {
|
|||||||
(dst) = tmp; \
|
(dst) = tmp; \
|
||||||
}
|
}
|
||||||
|
|
||||||
static int BF_decode(BF_word *dst, __CONST char *src, int size)
|
static int BF_decode(BF_word *dst, const char *src, int size)
|
||||||
{
|
{
|
||||||
unsigned char *dptr = (unsigned char *)dst;
|
unsigned char *dptr = (unsigned char *)dst;
|
||||||
unsigned char *end = dptr + size;
|
unsigned char *end = dptr + size;
|
||||||
@ -397,7 +391,7 @@ static int BF_decode(BF_word *dst, __CONST char *src, int size)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BF_encode(char *dst, __CONST BF_word *src, int size)
|
static void BF_encode(char *dst, const BF_word *src, int size)
|
||||||
{
|
{
|
||||||
unsigned char *sptr = (unsigned char *)src;
|
unsigned char *sptr = (unsigned char *)src;
|
||||||
unsigned char *end = sptr + size;
|
unsigned char *end = sptr + size;
|
||||||
@ -536,9 +530,9 @@ extern void _BF_body_r(BF_ctx *ctx);
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void BF_set_key(__CONST char *key, BF_key expanded, BF_key initial)
|
static void BF_set_key(const char *key, BF_key expanded, BF_key initial)
|
||||||
{
|
{
|
||||||
__CONST char *ptr = key;
|
const char *ptr = key;
|
||||||
int i, j;
|
int i, j;
|
||||||
BF_word tmp;
|
BF_word tmp;
|
||||||
|
|
||||||
@ -556,7 +550,7 @@ static void BF_set_key(__CONST char *key, BF_key expanded, BF_key initial)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *_crypt_blowfish_rn(__CONST char *key, __CONST char *setting,
|
char *_crypt_blowfish_rn(const char *key, const char *setting,
|
||||||
char *output, int size)
|
char *output, int size)
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
|
@ -58,18 +58,13 @@
|
|||||||
* alignment).
|
* alignment).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <postgres.h>
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "px-crypt.h"
|
#include "px-crypt.h"
|
||||||
|
|
||||||
/* for ntohl/htonl */
|
/* for ntohl/htonl */
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
|
||||||
/* We can't always assume gcc */
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define INLINE inline
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define _PASSWORD_EFMT1 '_'
|
#define _PASSWORD_EFMT1 '_'
|
||||||
|
|
||||||
static uint8 IP[64] = {
|
static uint8 IP[64] = {
|
||||||
@ -200,7 +195,7 @@ static uint32 comp_maskl[8][128],
|
|||||||
static uint32 old_rawkey0,
|
static uint32 old_rawkey0,
|
||||||
old_rawkey1;
|
old_rawkey1;
|
||||||
|
|
||||||
static INLINE int
|
static inline int
|
||||||
ascii_to_bin(char ch)
|
ascii_to_bin(char ch)
|
||||||
{
|
{
|
||||||
if (ch > 'z')
|
if (ch > 'z')
|
||||||
@ -611,6 +606,7 @@ do_des(uint32 l_in, uint32 r_in, uint32 * l_out, uint32 * r_out, int count)
|
|||||||
static int
|
static int
|
||||||
des_cipher(const char *in, char *out, long salt, int count)
|
des_cipher(const char *in, char *out, long salt, int count)
|
||||||
{
|
{
|
||||||
|
uint32 buffer[2];
|
||||||
uint32 l_out,
|
uint32 l_out,
|
||||||
r_out,
|
r_out,
|
||||||
rawl,
|
rawl,
|
||||||
@ -622,13 +618,20 @@ des_cipher(const char *in, char *out, long salt, int count)
|
|||||||
|
|
||||||
setup_salt(salt);
|
setup_salt(salt);
|
||||||
|
|
||||||
rawl = ntohl(*((uint32 *) in)++);
|
/* copy data to avoid assuming input is word-aligned */
|
||||||
rawr = ntohl(*((uint32 *) in));
|
memcpy(buffer, in, sizeof(buffer));
|
||||||
|
|
||||||
|
rawl = ntohl(buffer[0]);
|
||||||
|
rawr = ntohl(buffer[1]);
|
||||||
|
|
||||||
retval = do_des(rawl, rawr, &l_out, &r_out, count);
|
retval = do_des(rawl, rawr, &l_out, &r_out, count);
|
||||||
|
|
||||||
*((uint32 *) out)++ = htonl(l_out);
|
buffer[0] = htonl(l_out);
|
||||||
*((uint32 *) out) = htonl(r_out);
|
buffer[1] = htonl(r_out);
|
||||||
|
|
||||||
|
/* copy data to avoid assuming output is word-aligned */
|
||||||
|
memcpy(out, buffer, sizeof(buffer));
|
||||||
|
|
||||||
return (retval);
|
return (retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,19 +10,13 @@
|
|||||||
* may not be compiled always. -- marko
|
* may not be compiled always. -- marko
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <postgres.h>
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "px-crypt.h"
|
#include "px-crypt.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifndef __set_errno
|
#ifndef __set_errno
|
||||||
#define __set_errno(val) errno = (val)
|
#define __set_errno(val) (errno = (val))
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef __CONST
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define __CONST __const
|
|
||||||
#else
|
|
||||||
#define __CONST
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef unsigned int BF_word;
|
typedef unsigned int BF_word;
|
||||||
@ -31,7 +25,7 @@ unsigned char _crypt_itoa64[64 + 1] =
|
|||||||
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
char *_crypt_gensalt_traditional_rn(unsigned long count,
|
char *_crypt_gensalt_traditional_rn(unsigned long count,
|
||||||
__CONST char *input, int size, char *output, int output_size)
|
const char *input, int size, char *output, int output_size)
|
||||||
{
|
{
|
||||||
if (size < 2 || output_size < 2 + 1 || (count && count != 25)) {
|
if (size < 2 || output_size < 2 + 1 || (count && count != 25)) {
|
||||||
if (output_size > 0) output[0] = '\0';
|
if (output_size > 0) output[0] = '\0';
|
||||||
@ -47,7 +41,7 @@ char *_crypt_gensalt_traditional_rn(unsigned long count,
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *_crypt_gensalt_extended_rn(unsigned long count,
|
char *_crypt_gensalt_extended_rn(unsigned long count,
|
||||||
__CONST char *input, int size, char *output, int output_size)
|
const char *input, int size, char *output, int output_size)
|
||||||
{
|
{
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
|
|
||||||
@ -80,7 +74,7 @@ char *_crypt_gensalt_extended_rn(unsigned long count,
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *_crypt_gensalt_md5_rn(unsigned long count,
|
char *_crypt_gensalt_md5_rn(unsigned long count,
|
||||||
__CONST char *input, int size, char *output, int output_size)
|
const char *input, int size, char *output, int output_size)
|
||||||
{
|
{
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
|
|
||||||
@ -121,7 +115,7 @@ char *_crypt_gensalt_md5_rn(unsigned long count,
|
|||||||
static unsigned char BF_itoa64[64 + 1] =
|
static unsigned char BF_itoa64[64 + 1] =
|
||||||
"./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
"./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
|
||||||
static void BF_encode(char *dst, __CONST BF_word *src, int size)
|
static void BF_encode(char *dst, const BF_word *src, int size)
|
||||||
{
|
{
|
||||||
unsigned char *sptr = (unsigned char *)src;
|
unsigned char *sptr = (unsigned char *)src;
|
||||||
unsigned char *end = sptr + size;
|
unsigned char *end = sptr + size;
|
||||||
@ -154,7 +148,7 @@ static void BF_encode(char *dst, __CONST BF_word *src, int size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *_crypt_gensalt_blowfish_rn(unsigned long count,
|
char *_crypt_gensalt_blowfish_rn(unsigned long count,
|
||||||
__CONST char *input, int size, char *output, int output_size)
|
const char *input, int size, char *output, int output_size)
|
||||||
{
|
{
|
||||||
if (size < 16 || output_size < 7 + 22 + 1 ||
|
if (size < 16 || output_size < 7 + 22 + 1 ||
|
||||||
(count && (count < 4 || count > 31))) {
|
(count && (count < 4 || count > 31))) {
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: internal.c,v 1.4 2001/08/21 00:42:41 momjian Exp $
|
* $Id: internal.c,v 1.5 2001/10/15 19:12:48 tgl Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ int_sha1_update(PX_MD * h, const uint8 * data, uint dlen)
|
|||||||
{
|
{
|
||||||
SHA1_CTX *ctx = (SHA1_CTX *) h->p.ptr;
|
SHA1_CTX *ctx = (SHA1_CTX *) h->p.ptr;
|
||||||
|
|
||||||
SHA1Update(ctx, (const char *)data, dlen);
|
SHA1Update(ctx, data, dlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -87,12 +87,14 @@ _rserv_log_()
|
|||||||
if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event))
|
if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event))
|
||||||
newtuple = CurrentTriggerData->tg_newtuple;
|
newtuple = CurrentTriggerData->tg_newtuple;
|
||||||
|
|
||||||
|
#ifndef PG_FUNCTION_INFO_V1
|
||||||
/*
|
/*
|
||||||
* Setting CurrentTriggerData to NULL prevents direct calls to trigger
|
* Setting CurrentTriggerData to NULL prevents direct calls to trigger
|
||||||
* functions in queries. Normally, trigger functions have to be called
|
* functions in queries. Normally, trigger functions have to be called
|
||||||
* by trigger manager code only.
|
* by trigger manager code only.
|
||||||
*/
|
*/
|
||||||
CurrentTriggerData = NULL;
|
CurrentTriggerData = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Connect to SPI manager */
|
/* Connect to SPI manager */
|
||||||
if ((ret = SPI_connect()) < 0)
|
if ((ret = SPI_connect()) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user