From 6ce467dc134478dd876013c76a36d60a068f55ad Mon Sep 17 00:00:00 2001 From: Sascha Schumann Date: Mon, 21 Aug 2000 10:10:31 +0000 Subject: [PATCH] Get rid of php_global.h and the associated data types UINT4/_POINTER. We use php_uint32 now globally. Also removed K&R support from md5.[ch]. --- ext/icap/php_icap.c | 6 +-- ext/mcal/php_mcal.c | 6 +-- ext/standard/md5.c | 79 ++++++++++++--------------------------- ext/standard/md5.h | 12 +++--- ext/standard/php_global.h | 54 -------------------------- 5 files changed, 36 insertions(+), 121 deletions(-) delete mode 100644 ext/standard/php_global.h diff --git a/ext/icap/php_icap.c b/ext/icap/php_icap.c index 45e6aadff1..8e5b4f8b47 100644 --- a/ext/icap/php_icap.c +++ b/ext/icap/php_icap.c @@ -47,7 +47,7 @@ #include "php_icap.h" #include "modules.h" #include "ext/standard/info.h" -#include "ext/standard/php_global.h" +#include "ext/standard/basic_functions.h" #ifdef PHP_WIN32 #include "winsock.h" #endif @@ -64,7 +64,7 @@ typedef struct php_icap_le_struct { typedef struct cal_list { -UINT4 uid; +php_uint32 uid; struct cal_list *next; } cal_list_t; @@ -904,7 +904,7 @@ void cc_searched (unsigned long cal_uid) } -void cc_appended(UINT4 uid) +void cc_appended(php_uint32 uid) { } diff --git a/ext/mcal/php_mcal.c b/ext/mcal/php_mcal.c index c56cfbe895..070096b427 100644 --- a/ext/mcal/php_mcal.c +++ b/ext/mcal/php_mcal.c @@ -47,7 +47,7 @@ #include "php_mcal.h" #include "modules.h" #include "ext/standard/info.h" -#include "ext/standard/php_global.h" +#include "ext/standard/basic_functions.h" #ifdef PHP_WIN32 #include "winsock.h" #endif @@ -65,7 +65,7 @@ typedef struct _php_mcal_le_struct { typedef struct cal_list { - UINT4 uid; + php_uint32 uid; struct cal_list *next; } cal_list_t; @@ -1595,7 +1595,7 @@ void cc_searched (unsigned long cal_uid) } } -void cc_appended(UINT4 uid) +void cc_appended(php_uint32 uid) { } diff --git a/ext/standard/md5.c b/ext/standard/md5.c index 6cb896806b..64bfeb0549 100644 --- a/ext/standard/md5.c +++ b/ext/standard/md5.c @@ -104,13 +104,9 @@ PHP_NAMED_FUNCTION(php_if_md5) #define S43 15 #define S44 21 -static void MD5Transform PROTO_LIST((UINT4[4], const unsigned char[64])); -static void Encode PROTO_LIST - ((unsigned char *, UINT4 *, unsigned int)); -static void Decode PROTO_LIST - ((UINT4 *, const unsigned char *, unsigned int)); -static void MD5_memcpy PROTO_LIST((_POINTER, _POINTER, unsigned int)); -static void MD5_memset PROTO_LIST((_POINTER, int, unsigned int)); +static void MD5Transform(php_uint32[4], const unsigned char[64]); +static void Encode(unsigned char *, php_uint32 *, unsigned int); +static void Decode(php_uint32 *, const unsigned char *, unsigned int); static unsigned char PADDING[64] = { @@ -134,22 +130,22 @@ static unsigned char PADDING[64] = Rotation is separate from addition to prevent recomputation. */ #define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) += F ((b), (c), (d)) + (x) + (php_uint32)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) += G ((b), (c), (d)) + (x) + (php_uint32)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) += H ((b), (c), (d)) + (x) + (php_uint32)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) += I ((b), (c), (d)) + (x) + (php_uint32)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } @@ -180,18 +176,18 @@ void PHP_MD5Update(PHP_MD5_CTX * context, const unsigned char *input, index = (unsigned int) ((context->count[0] >> 3) & 0x3F); /* Update number of bits */ - if ((context->count[0] += ((UINT4) inputLen << 3)) - < ((UINT4) inputLen << 3)) + if ((context->count[0] += ((php_uint32) inputLen << 3)) + < ((php_uint32) inputLen << 3)) context->count[1]++; - context->count[1] += ((UINT4) inputLen >> 29); + context->count[1] += ((php_uint32) inputLen >> 29); partLen = 64 - index; /* Transform as many times as possible. */ if (inputLen >= partLen) { - MD5_memcpy - ((_POINTER) & context->buffer[index], (_POINTER) input, partLen); + memcpy + ((unsigned char*) & context->buffer[index], (unsigned char*) input, partLen); MD5Transform(context->state, context->buffer); for (i = partLen; i + 63 < inputLen; i += 64) @@ -202,8 +198,8 @@ void PHP_MD5Update(PHP_MD5_CTX * context, const unsigned char *input, i = 0; /* Buffer remaining input */ - MD5_memcpy - ((_POINTER) & context->buffer[index], (_POINTER) & input[i], + memcpy + ((unsigned char*) & context->buffer[index], (unsigned char*) & input[i], inputLen - i); } @@ -232,16 +228,16 @@ void PHP_MD5Final(unsigned char digest[16], PHP_MD5_CTX * context) /* Zeroize sensitive information. */ - MD5_memset((_POINTER) context, 0, sizeof(*context)); + memset((unsigned char*) context, 0, sizeof(*context)); } /* MD5 basic transformation. Transforms state based on block. */ static void MD5Transform(state, block) -UINT4 state[4]; +php_uint32 state[4]; const unsigned char block[64]; { - UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; + php_uint32 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; Decode(x, block, 64); @@ -323,15 +319,15 @@ const unsigned char block[64]; state[3] += d; /* Zeroize sensitive information. */ - MD5_memset((_POINTER) x, 0, sizeof(x)); + memset((unsigned char*) x, 0, sizeof(x)); } -/* Encodes input (UINT4) into output (unsigned char). Assumes len is +/* Encodes input (php_uint32) into output (unsigned char). Assumes len is a multiple of 4. */ static void Encode(output, input, len) unsigned char *output; -UINT4 *input; +php_uint32 *input; unsigned int len; { unsigned int i, j; @@ -344,46 +340,19 @@ unsigned int len; } } -/* Decodes input (unsigned char) into output (UINT4). Assumes len is +/* Decodes input (unsigned char) into output (php_uint32). Assumes len is a multiple of 4. */ static void Decode(output, input, len) -UINT4 *output; +php_uint32 *output; const unsigned char *input; unsigned int len; { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((UINT4) input[j]) | (((UINT4) input[j + 1]) << 8) | - (((UINT4) input[j + 2]) << 16) | (((UINT4) input[j + 3]) << 24); -} - -/* Note: Replace "for loop" with standard memcpy if possible. - */ - -static void MD5_memcpy(output, input, len) -_POINTER output; -_POINTER input; -unsigned int len; -{ - unsigned int i; - - for (i = 0; i < len; i++) - output[i] = input[i]; -} - -/* Note: Replace "for loop" with standard memset if possible. - */ -static void MD5_memset(output, value, len) -_POINTER output; -int value; -unsigned int len; -{ - unsigned int i; - - for (i = 0; i < len; i++) - ((char *) output)[i] = (char) value; + output[i] = ((php_uint32) input[j]) | (((php_uint32) input[j + 1]) << 8) | + (((php_uint32) input[j + 2]) << 16) | (((php_uint32) input[j + 3]) << 24); } /* diff --git a/ext/standard/md5.h b/ext/standard/md5.h index 5edd374302..42a812be21 100644 --- a/ext/standard/md5.h +++ b/ext/standard/md5.h @@ -45,18 +45,18 @@ documentation and/or software. */ -#include "php_global.h" +#include "ext/standard/basic_functions.h" /* MD5 context. */ typedef struct { - UINT4 state[4]; /* state (ABCD) */ - UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ + php_uint32 state[4]; /* state (ABCD) */ + php_uint32 count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } PHP_MD5_CTX; -void PHP_MD5Init PROTO_LIST((PHP_MD5_CTX *)); -void PHP_MD5Update PROTO_LIST((PHP_MD5_CTX *, const unsigned char *, unsigned int)); -void PHP_MD5Final PROTO_LIST((unsigned char[16], PHP_MD5_CTX *)); +void PHP_MD5Init(PHP_MD5_CTX *); +void PHP_MD5Update(PHP_MD5_CTX *, const unsigned char *, unsigned int); +void PHP_MD5Final(unsigned char[16], PHP_MD5_CTX *); PHP_NAMED_FUNCTION(php_if_md5); diff --git a/ext/standard/php_global.h b/ext/standard/php_global.h deleted file mode 100644 index 0c361056ba..0000000000 --- a/ext/standard/php_global.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Rasmus Lerdorf | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -/* GLOBAL.H - RSAREF types and constants - */ - -/* PROTOTYPES should be set to one if and only if the compiler supports - function argument prototyping. - The following makes PROTOTYPES default to 0 if it has not already - been defined with C compiler flags. - */ -#ifndef PROTOTYPES -#define PROTOTYPES 1 /* PHP has prototypes everywhere */ -#endif - -/* _POINTER defines a generic pointer type */ -typedef unsigned char *_POINTER; - -/* UINT2 defines a two byte word */ -typedef unsigned short int UINT2; - -/* UINT4 defines a four byte word */ -#if SIZEOF_INT == 4 -typedef unsigned int UINT4; -#elif SIZEOF_LONG == 4 -typedef unsigned long UINT4; -#endif - -/* PROTO_LIST is defined depending on how PROTOTYPES is defined above. - If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it - returns an empty list. - */ -#if PROTOTYPES -#define PROTO_LIST(list) list -#else -#define PROTO_LIST(list) () -#endif -- 2.40.0