--- parser3/src/classes/math.C 2003/04/25 11:58:20 1.24.2.12.2.13 +++ parser3/src/classes/math.C 2003/11/20 16:34:23 1.36 @@ -8,7 +8,7 @@ Copyright (C) 1996, 1997, 1998, 1999 Theodore Ts'o. */ -static const char* IDENT_MATH_C="$Date: 2003/04/25 11:58:20 $"; +static const char * const IDENT_MATH_C="$Date: 2003/11/20 16:34:23 $"; #include "pa_vmethod_frame.h" #include "pa_common.h" @@ -152,13 +152,17 @@ static void random(void *buffer, size_t #endif } + // methods + +#define MAX_UINT 0xFFFFFFFFu + static inline int _random(uint top) { uint raw; random(&raw, sizeof(raw)); - return int(double(raw) / 0x100000000 * top ); + return int(double(raw) / MAX_UINT * top ); } -#define MAX_UINT 0xFFFFFFFFu + static void _random(Request& r, MethodParams& params) { Value& range=params.as_junction(0, "range must be expression"); double top=r.process_to_value(range).as_double(); @@ -259,7 +263,7 @@ static void _crypt(Request& r, MethodPar if(strncmp(normal_salt, PA_MD5PW_ID, PA_MD5PW_IDLEN) == 0) { const size_t sample_size=120; char *sample_buf=new(PointerFreeGC) char[sample_size]; - PA_MD5Encode((const unsigned char *)password, + pa_MD5Encode((const unsigned char *)password, (const unsigned char *)normal_salt, sample_buf, sample_size); String sample(sample_buf); r.write_pass_lang(sample); @@ -287,9 +291,9 @@ static const char* hex_string(unsigned c unsigned char *src=bytes; unsigned char *end=bytes+size; char *dest=bytes_hex; + static const char *hex=upcase?"0123456789ABCDEF":"0123456789abcdef"; - const char *format=upcase?"%02X":"%02x"; for(; src