mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2024-11-13 00:24:29 +00:00
compiles again on win32, trashed mhash
git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@338 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
parent
449fdbd6b7
commit
e393e112f4
8 changed files with 625 additions and 44 deletions
49
libs/md4lib.h
Normal file
49
libs/md4lib.h
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* This is an OpenSSL-compatible implementation of the RSA Data Security,
|
||||||
|
* Inc. MD4 Message-Digest Algorithm.
|
||||||
|
*
|
||||||
|
* Written by Solar Designer <solar@openwall.com> in 2001, and placed in
|
||||||
|
* the public domain. See md4.c for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MD4_H
|
||||||
|
#define MD4_H
|
||||||
|
|
||||||
|
struct hash_method {
|
||||||
|
const char *name;
|
||||||
|
/* Number of bytes that must be allocated for context */
|
||||||
|
unsigned int context_size;
|
||||||
|
/* Number of bytes that must be allocated for result()'s digest */
|
||||||
|
unsigned int digest_size;
|
||||||
|
|
||||||
|
void (*init)(void *context);
|
||||||
|
void (*loop)(void *context, const void *data, size_t size);
|
||||||
|
void (*result)(void *context, unsigned char *digest_r);
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct hash_method *hash_method_lookup(const char *name);
|
||||||
|
|
||||||
|
/* NULL-terminated list of all hash methods */
|
||||||
|
extern const struct hash_method *hash_methods[];
|
||||||
|
|
||||||
|
typedef unsigned int uint_fast32_t;
|
||||||
|
|
||||||
|
#define MD4_RESULTLEN (128/8)
|
||||||
|
|
||||||
|
struct md4_context {
|
||||||
|
uint_fast32_t lo, hi;
|
||||||
|
uint_fast32_t a, b, c, d;
|
||||||
|
unsigned char buffer[64];
|
||||||
|
uint_fast32_t block[MD4_RESULTLEN];
|
||||||
|
};
|
||||||
|
|
||||||
|
void md4_init(struct md4_context *ctx);
|
||||||
|
void md4_update(struct md4_context *ctx, const void *data, size_t size);
|
||||||
|
void md4_final(struct md4_context *ctx, unsigned char result[MD4_RESULTLEN]);
|
||||||
|
|
||||||
|
void md4_get_digest(const void *data, size_t size,
|
||||||
|
unsigned char result[MD4_RESULTLEN]);
|
||||||
|
|
||||||
|
extern const struct hash_method hash_method_md4;
|
||||||
|
|
||||||
|
#endif
|
296
libs/md5lib/md4.c
Normal file
296
libs/md5lib/md4.c
Normal file
|
@ -0,0 +1,296 @@
|
||||||
|
/*
|
||||||
|
* MD4 (RFC-1320) message digest.
|
||||||
|
* Modified from MD5 code by Andrey Panin <pazke@donpac.ru>
|
||||||
|
*
|
||||||
|
* Written by Solar Designer <solar@openwall.com> in 2001, and placed in
|
||||||
|
* the public domain. There's absolutely no warranty.
|
||||||
|
*
|
||||||
|
* This differs from Colin Plumb's older public domain implementation in
|
||||||
|
* that no 32-bit integer data type is required, there's no compile-time
|
||||||
|
* endianness configuration, and the function prototypes match OpenSSL's.
|
||||||
|
* The primary goals are portability and ease of use.
|
||||||
|
*
|
||||||
|
* This implementation is meant to be fast, but not as fast as possible.
|
||||||
|
* Some known optimizations are not included to reduce source code size
|
||||||
|
* and avoid compile-time configuration.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "../stdint.msvc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "md4lib.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The basic MD4 functions.
|
||||||
|
*/
|
||||||
|
#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
|
||||||
|
#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
|
||||||
|
#define H(x, y, z) ((x) ^ (y) ^ (z))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The MD4 transformation for all four rounds.
|
||||||
|
*/
|
||||||
|
#define STEP(f, a, b, c, d, x, s) \
|
||||||
|
(a) += f((b), (c), (d)) + (x); \
|
||||||
|
(a) = ((a) << (s)) | ((a) >> (32 - (s)))
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SET reads 4 input bytes in little-endian byte order and stores them
|
||||||
|
* in a properly aligned word in host byte order.
|
||||||
|
*
|
||||||
|
* The check for little-endian architectures which tolerate unaligned
|
||||||
|
* memory accesses is just an optimization. Nothing will break if it
|
||||||
|
* doesn't work.
|
||||||
|
*/
|
||||||
|
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
|
||||||
|
#define SET(n) \
|
||||||
|
(*(const uint_fast32_t *)&ptr[(n) * 4])
|
||||||
|
#define GET(n) \
|
||||||
|
SET(n)
|
||||||
|
#else
|
||||||
|
#define SET(n) \
|
||||||
|
(ctx->block[(n)] = \
|
||||||
|
(uint_fast32_t)ptr[(n) * 4] | \
|
||||||
|
((uint_fast32_t)ptr[(n) * 4 + 1] << 8) | \
|
||||||
|
((uint_fast32_t)ptr[(n) * 4 + 2] << 16) | \
|
||||||
|
((uint_fast32_t)ptr[(n) * 4 + 3] << 24))
|
||||||
|
#define GET(n) \
|
||||||
|
(ctx->block[(n)])
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This processes one or more 64-byte data blocks, but does NOT update
|
||||||
|
* the bit counters. There're no alignment requirements.
|
||||||
|
*/
|
||||||
|
static const void *body(struct md4_context *ctx, const void *data, size_t size)
|
||||||
|
{
|
||||||
|
const unsigned char *ptr;
|
||||||
|
uint32_t a, b, c, d;
|
||||||
|
uint32_t saved_a, saved_b, saved_c, saved_d;
|
||||||
|
|
||||||
|
ptr = data;
|
||||||
|
|
||||||
|
a = ctx->a;
|
||||||
|
b = ctx->b;
|
||||||
|
c = ctx->c;
|
||||||
|
d = ctx->d;
|
||||||
|
|
||||||
|
do {
|
||||||
|
saved_a = a;
|
||||||
|
saved_b = b;
|
||||||
|
saved_c = c;
|
||||||
|
saved_d = d;
|
||||||
|
|
||||||
|
/* Round 1 */
|
||||||
|
STEP(F, a, b, c, d, SET( 0), 3);
|
||||||
|
STEP(F, d, a, b, c, SET( 1), 7);
|
||||||
|
STEP(F, c, d, a, b, SET( 2), 11);
|
||||||
|
STEP(F, b, c, d, a, SET( 3), 19);
|
||||||
|
|
||||||
|
STEP(F, a, b, c, d, SET( 4), 3);
|
||||||
|
STEP(F, d, a, b, c, SET( 5), 7);
|
||||||
|
STEP(F, c, d, a, b, SET( 6), 11);
|
||||||
|
STEP(F, b, c, d, a, SET( 7), 19);
|
||||||
|
|
||||||
|
STEP(F, a, b, c, d, SET( 8), 3);
|
||||||
|
STEP(F, d, a, b, c, SET( 9), 7);
|
||||||
|
STEP(F, c, d, a, b, SET(10), 11);
|
||||||
|
STEP(F, b, c, d, a, SET(11), 19);
|
||||||
|
|
||||||
|
STEP(F, a, b, c, d, SET(12), 3);
|
||||||
|
STEP(F, d, a, b, c, SET(13), 7);
|
||||||
|
STEP(F, c, d, a, b, SET(14), 11);
|
||||||
|
STEP(F, b, c, d, a, SET(15), 19);
|
||||||
|
/* Round 2 */
|
||||||
|
STEP(G, a, b, c, d, GET( 0) + 0x5A827999, 3);
|
||||||
|
STEP(G, d, a, b, c, GET( 4) + 0x5A827999, 5);
|
||||||
|
STEP(G, c, d, a, b, GET( 8) + 0x5A827999, 9);
|
||||||
|
STEP(G, b, c, d, a, GET(12) + 0x5A827999, 13);
|
||||||
|
|
||||||
|
STEP(G, a, b, c, d, GET( 1) + 0x5A827999, 3);
|
||||||
|
STEP(G, d, a, b, c, GET( 5) + 0x5A827999, 5);
|
||||||
|
STEP(G, c, d, a, b, GET( 9) + 0x5A827999, 9);
|
||||||
|
STEP(G, b, c, d, a, GET(13) + 0x5A827999, 13);
|
||||||
|
|
||||||
|
STEP(G, a, b, c, d, GET( 2) + 0x5A827999, 3);
|
||||||
|
STEP(G, d, a, b, c, GET( 6) + 0x5A827999, 5);
|
||||||
|
STEP(G, c, d, a, b, GET(10) + 0x5A827999, 9);
|
||||||
|
STEP(G, b, c, d, a, GET(14) + 0x5A827999, 13);
|
||||||
|
|
||||||
|
STEP(G, a, b, c, d, GET( 3) + 0x5A827999, 3);
|
||||||
|
STEP(G, d, a, b, c, GET( 7) + 0x5A827999, 5);
|
||||||
|
STEP(G, c, d, a, b, GET(11) + 0x5A827999, 9);
|
||||||
|
STEP(G, b, c, d, a, GET(15) + 0x5A827999, 13);
|
||||||
|
/* Round 3 */
|
||||||
|
STEP(H, a, b, c, d, GET( 0) + 0x6ED9EBA1, 3);
|
||||||
|
STEP(H, d, a, b, c, GET( 8) + 0x6ED9EBA1, 9);
|
||||||
|
STEP(H, c, d, a, b, GET( 4) + 0x6ED9EBA1, 11);
|
||||||
|
STEP(H, b, c, d, a, GET(12) + 0x6ED9EBA1, 15);
|
||||||
|
|
||||||
|
STEP(H, a, b, c, d, GET( 2) + 0x6ED9EBA1, 3);
|
||||||
|
STEP(H, d, a, b, c, GET(10) + 0x6ED9EBA1, 9);
|
||||||
|
STEP(H, c, d, a, b, GET( 6) + 0x6ED9EBA1, 11);
|
||||||
|
STEP(H, b, c, d, a, GET(14) + 0x6ED9EBA1, 15);
|
||||||
|
|
||||||
|
STEP(H, a, b, c, d, GET( 1) + 0x6ED9EBA1, 3);
|
||||||
|
STEP(H, d, a, b, c, GET( 9) + 0x6ED9EBA1, 9);
|
||||||
|
STEP(H, c, d, a, b, GET( 5) + 0x6ED9EBA1, 11);
|
||||||
|
STEP(H, b, c, d, a, GET(13) + 0x6ED9EBA1, 15);
|
||||||
|
|
||||||
|
STEP(H, a, b, c, d, GET( 3) + 0x6ED9EBA1, 3);
|
||||||
|
STEP(H, d, a, b, c, GET(11) + 0x6ED9EBA1, 9);
|
||||||
|
STEP(H, c, d, a, b, GET( 7) + 0x6ED9EBA1, 11);
|
||||||
|
STEP(H, b, c, d, a, GET(15) + 0x6ED9EBA1, 15);
|
||||||
|
|
||||||
|
a += saved_a;
|
||||||
|
b += saved_b;
|
||||||
|
c += saved_c;
|
||||||
|
d += saved_d;
|
||||||
|
|
||||||
|
ptr += 64;
|
||||||
|
} while (size -= 64);
|
||||||
|
|
||||||
|
ctx->a = a;
|
||||||
|
ctx->b = b;
|
||||||
|
ctx->c = c;
|
||||||
|
ctx->d = d;
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void md4_init(struct md4_context *ctx)
|
||||||
|
{
|
||||||
|
ctx->a = 0x67452301;
|
||||||
|
ctx->b = 0xefcdab89;
|
||||||
|
ctx->c = 0x98badcfe;
|
||||||
|
ctx->d = 0x10325476;
|
||||||
|
|
||||||
|
ctx->lo = 0;
|
||||||
|
ctx->hi = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void md4_update(struct md4_context *ctx, const void *data, size_t size)
|
||||||
|
{
|
||||||
|
/* @UNSAFE */
|
||||||
|
uint_fast32_t saved_lo;
|
||||||
|
unsigned long used, free;
|
||||||
|
|
||||||
|
saved_lo = ctx->lo;
|
||||||
|
if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
|
||||||
|
ctx->hi++;
|
||||||
|
ctx->hi += size >> 29;
|
||||||
|
|
||||||
|
used = saved_lo & 0x3f;
|
||||||
|
|
||||||
|
if (used) {
|
||||||
|
free = 64 - used;
|
||||||
|
|
||||||
|
if (size < free) {
|
||||||
|
memcpy(&ctx->buffer[used], data, size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(&ctx->buffer[used], data, free);
|
||||||
|
data = (const unsigned char *) data + free;
|
||||||
|
size -= free;
|
||||||
|
body(ctx, ctx->buffer, 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size >= 64) {
|
||||||
|
data = body(ctx, data, size & ~(unsigned long)0x3f);
|
||||||
|
size &= 0x3f;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(ctx->buffer, data, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void md4_final(struct md4_context *ctx, unsigned char result[MD4_RESULTLEN])
|
||||||
|
{
|
||||||
|
/* @UNSAFE */
|
||||||
|
unsigned long used, free;
|
||||||
|
|
||||||
|
used = ctx->lo & 0x3f;
|
||||||
|
|
||||||
|
ctx->buffer[used++] = 0x80;
|
||||||
|
|
||||||
|
free = 64 - used;
|
||||||
|
|
||||||
|
if (free < 8) {
|
||||||
|
memset(&ctx->buffer[used], 0, free);
|
||||||
|
body(ctx, ctx->buffer, 64);
|
||||||
|
used = 0;
|
||||||
|
free = 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&ctx->buffer[used], 0, free - 8);
|
||||||
|
|
||||||
|
ctx->lo <<= 3;
|
||||||
|
ctx->buffer[56] = ctx->lo;
|
||||||
|
ctx->buffer[57] = ctx->lo >> 8;
|
||||||
|
ctx->buffer[58] = ctx->lo >> 16;
|
||||||
|
ctx->buffer[59] = ctx->lo >> 24;
|
||||||
|
ctx->buffer[60] = ctx->hi;
|
||||||
|
ctx->buffer[61] = ctx->hi >> 8;
|
||||||
|
ctx->buffer[62] = ctx->hi >> 16;
|
||||||
|
ctx->buffer[63] = ctx->hi >> 24;
|
||||||
|
|
||||||
|
body(ctx, ctx->buffer, 64);
|
||||||
|
|
||||||
|
result[0] = ctx->a;
|
||||||
|
result[1] = ctx->a >> 8;
|
||||||
|
result[2] = ctx->a >> 16;
|
||||||
|
result[3] = ctx->a >> 24;
|
||||||
|
result[4] = ctx->b;
|
||||||
|
result[5] = ctx->b >> 8;
|
||||||
|
result[6] = ctx->b >> 16;
|
||||||
|
result[7] = ctx->b >> 24;
|
||||||
|
result[8] = ctx->c;
|
||||||
|
result[9] = ctx->c >> 8;
|
||||||
|
result[10] = ctx->c >> 16;
|
||||||
|
result[11] = ctx->c >> 24;
|
||||||
|
result[12] = ctx->d;
|
||||||
|
result[13] = ctx->d >> 8;
|
||||||
|
result[14] = ctx->d >> 16;
|
||||||
|
result[15] = ctx->d >> 24;
|
||||||
|
|
||||||
|
memset(ctx, 0, sizeof(*ctx));
|
||||||
|
}
|
||||||
|
|
||||||
|
void md4_get_digest(const void *data, size_t size,
|
||||||
|
unsigned char result[MD4_RESULTLEN])
|
||||||
|
{
|
||||||
|
struct md4_context ctx;
|
||||||
|
|
||||||
|
md4_init(&ctx);
|
||||||
|
md4_update(&ctx, data, size);
|
||||||
|
md4_final(&ctx, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void hash_method_init_md4(void *context)
|
||||||
|
{
|
||||||
|
md4_init(context);
|
||||||
|
}
|
||||||
|
static void hash_method_loop_md4(void *context, const void *data, size_t size)
|
||||||
|
{
|
||||||
|
md4_update(context, data, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void hash_method_result_md4(void *context, unsigned char *result_r)
|
||||||
|
{
|
||||||
|
md4_final(context, result_r);
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct hash_method hash_method_md4 = {
|
||||||
|
"md4",
|
||||||
|
sizeof(struct md4_context),
|
||||||
|
MD4_RESULTLEN,
|
||||||
|
|
||||||
|
hash_method_init_md4,
|
||||||
|
hash_method_loop_md4,
|
||||||
|
hash_method_result_md4
|
||||||
|
};
|
|
@ -147,6 +147,10 @@
|
||||||
Name="src"
|
Name="src"
|
||||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\md4.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\md5lib.c"
|
RelativePath=".\md5lib.c"
|
||||||
>
|
>
|
||||||
|
@ -156,6 +160,10 @@
|
||||||
Name="include"
|
Name="include"
|
||||||
Filter="h;hpp;hxx;hm;inl"
|
Filter="h;hpp;hxx;hm;inl"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\md4.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\md5lib.h"
|
RelativePath="..\md5lib.h"
|
||||||
>
|
>
|
||||||
|
|
247
libs/stdint.msvc.h
Normal file
247
libs/stdint.msvc.h
Normal file
|
@ -0,0 +1,247 @@
|
||||||
|
// ISO C9x compliant stdint.h for Microsoft Visual Studio
|
||||||
|
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
|
||||||
|
//
|
||||||
|
// Copyright (c) 2006-2008 Alexander Chemeris
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer in the
|
||||||
|
// documentation and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// 3. The name of the author may be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _MSC_VER // [
|
||||||
|
#error "Use this header only with Microsoft Visual C++ compilers!"
|
||||||
|
#endif // _MSC_VER ]
|
||||||
|
|
||||||
|
#ifndef _MSC_STDINT_H_ // [
|
||||||
|
#define _MSC_STDINT_H_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
|
||||||
|
// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
|
||||||
|
// or compiler give many errors like this:
|
||||||
|
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
# include <wchar.h>
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Define _W64 macros to mark types changing their size, like intptr_t.
|
||||||
|
#ifndef _W64
|
||||||
|
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
|
||||||
|
# define _W64 __w64
|
||||||
|
# else
|
||||||
|
# define _W64
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// 7.18.1 Integer types
|
||||||
|
|
||||||
|
// 7.18.1.1 Exact-width integer types
|
||||||
|
|
||||||
|
// Visual Studio 6 and Embedded Visual C++ 4 doesn't
|
||||||
|
// realize that, e.g. char has the same size as __int8
|
||||||
|
// so we give up on __intX for them.
|
||||||
|
#if (_MSC_VER < 1300)
|
||||||
|
typedef signed char int8_t;
|
||||||
|
typedef signed short int16_t;
|
||||||
|
typedef signed int int32_t;
|
||||||
|
typedef unsigned char uint8_t;
|
||||||
|
typedef unsigned short uint16_t;
|
||||||
|
typedef unsigned int uint32_t;
|
||||||
|
#else
|
||||||
|
typedef signed __int8 int8_t;
|
||||||
|
typedef signed __int16 int16_t;
|
||||||
|
typedef signed __int32 int32_t;
|
||||||
|
typedef unsigned __int8 uint8_t;
|
||||||
|
typedef unsigned __int16 uint16_t;
|
||||||
|
typedef unsigned __int32 uint32_t;
|
||||||
|
#endif
|
||||||
|
typedef signed __int64 int64_t;
|
||||||
|
typedef unsigned __int64 uint64_t;
|
||||||
|
|
||||||
|
|
||||||
|
// 7.18.1.2 Minimum-width integer types
|
||||||
|
typedef int8_t int_least8_t;
|
||||||
|
typedef int16_t int_least16_t;
|
||||||
|
typedef int32_t int_least32_t;
|
||||||
|
typedef int64_t int_least64_t;
|
||||||
|
typedef uint8_t uint_least8_t;
|
||||||
|
typedef uint16_t uint_least16_t;
|
||||||
|
typedef uint32_t uint_least32_t;
|
||||||
|
typedef uint64_t uint_least64_t;
|
||||||
|
|
||||||
|
// 7.18.1.3 Fastest minimum-width integer types
|
||||||
|
typedef int8_t int_fast8_t;
|
||||||
|
typedef int16_t int_fast16_t;
|
||||||
|
typedef int32_t int_fast32_t;
|
||||||
|
typedef int64_t int_fast64_t;
|
||||||
|
typedef uint8_t uint_fast8_t;
|
||||||
|
typedef uint16_t uint_fast16_t;
|
||||||
|
typedef uint32_t uint_fast32_t;
|
||||||
|
typedef uint64_t uint_fast64_t;
|
||||||
|
|
||||||
|
// 7.18.1.4 Integer types capable of holding object pointers
|
||||||
|
#ifdef _WIN64 // [
|
||||||
|
typedef signed __int64 intptr_t;
|
||||||
|
typedef unsigned __int64 uintptr_t;
|
||||||
|
#else // _WIN64 ][
|
||||||
|
typedef _W64 signed int intptr_t;
|
||||||
|
typedef _W64 unsigned int uintptr_t;
|
||||||
|
#endif // _WIN64 ]
|
||||||
|
|
||||||
|
// 7.18.1.5 Greatest-width integer types
|
||||||
|
typedef int64_t intmax_t;
|
||||||
|
typedef uint64_t uintmax_t;
|
||||||
|
|
||||||
|
|
||||||
|
// 7.18.2 Limits of specified-width integer types
|
||||||
|
|
||||||
|
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
|
||||||
|
|
||||||
|
// 7.18.2.1 Limits of exact-width integer types
|
||||||
|
#define INT8_MIN ((int8_t)_I8_MIN)
|
||||||
|
#define INT8_MAX _I8_MAX
|
||||||
|
#define INT16_MIN ((int16_t)_I16_MIN)
|
||||||
|
#define INT16_MAX _I16_MAX
|
||||||
|
#define INT32_MIN ((int32_t)_I32_MIN)
|
||||||
|
#define INT32_MAX _I32_MAX
|
||||||
|
#define INT64_MIN ((int64_t)_I64_MIN)
|
||||||
|
#define INT64_MAX _I64_MAX
|
||||||
|
#define UINT8_MAX _UI8_MAX
|
||||||
|
#define UINT16_MAX _UI16_MAX
|
||||||
|
#define UINT32_MAX _UI32_MAX
|
||||||
|
#define UINT64_MAX _UI64_MAX
|
||||||
|
|
||||||
|
// 7.18.2.2 Limits of minimum-width integer types
|
||||||
|
#define INT_LEAST8_MIN INT8_MIN
|
||||||
|
#define INT_LEAST8_MAX INT8_MAX
|
||||||
|
#define INT_LEAST16_MIN INT16_MIN
|
||||||
|
#define INT_LEAST16_MAX INT16_MAX
|
||||||
|
#define INT_LEAST32_MIN INT32_MIN
|
||||||
|
#define INT_LEAST32_MAX INT32_MAX
|
||||||
|
#define INT_LEAST64_MIN INT64_MIN
|
||||||
|
#define INT_LEAST64_MAX INT64_MAX
|
||||||
|
#define UINT_LEAST8_MAX UINT8_MAX
|
||||||
|
#define UINT_LEAST16_MAX UINT16_MAX
|
||||||
|
#define UINT_LEAST32_MAX UINT32_MAX
|
||||||
|
#define UINT_LEAST64_MAX UINT64_MAX
|
||||||
|
|
||||||
|
// 7.18.2.3 Limits of fastest minimum-width integer types
|
||||||
|
#define INT_FAST8_MIN INT8_MIN
|
||||||
|
#define INT_FAST8_MAX INT8_MAX
|
||||||
|
#define INT_FAST16_MIN INT16_MIN
|
||||||
|
#define INT_FAST16_MAX INT16_MAX
|
||||||
|
#define INT_FAST32_MIN INT32_MIN
|
||||||
|
#define INT_FAST32_MAX INT32_MAX
|
||||||
|
#define INT_FAST64_MIN INT64_MIN
|
||||||
|
#define INT_FAST64_MAX INT64_MAX
|
||||||
|
#define UINT_FAST8_MAX UINT8_MAX
|
||||||
|
#define UINT_FAST16_MAX UINT16_MAX
|
||||||
|
#define UINT_FAST32_MAX UINT32_MAX
|
||||||
|
#define UINT_FAST64_MAX UINT64_MAX
|
||||||
|
|
||||||
|
// 7.18.2.4 Limits of integer types capable of holding object pointers
|
||||||
|
#ifdef _WIN64 // [
|
||||||
|
# define INTPTR_MIN INT64_MIN
|
||||||
|
# define INTPTR_MAX INT64_MAX
|
||||||
|
# define UINTPTR_MAX UINT64_MAX
|
||||||
|
#else // _WIN64 ][
|
||||||
|
# define INTPTR_MIN INT32_MIN
|
||||||
|
# define INTPTR_MAX INT32_MAX
|
||||||
|
# define UINTPTR_MAX UINT32_MAX
|
||||||
|
#endif // _WIN64 ]
|
||||||
|
|
||||||
|
// 7.18.2.5 Limits of greatest-width integer types
|
||||||
|
#define INTMAX_MIN INT64_MIN
|
||||||
|
#define INTMAX_MAX INT64_MAX
|
||||||
|
#define UINTMAX_MAX UINT64_MAX
|
||||||
|
|
||||||
|
// 7.18.3 Limits of other integer types
|
||||||
|
|
||||||
|
#ifdef _WIN64 // [
|
||||||
|
# define PTRDIFF_MIN _I64_MIN
|
||||||
|
# define PTRDIFF_MAX _I64_MAX
|
||||||
|
#else // _WIN64 ][
|
||||||
|
# define PTRDIFF_MIN _I32_MIN
|
||||||
|
# define PTRDIFF_MAX _I32_MAX
|
||||||
|
#endif // _WIN64 ]
|
||||||
|
|
||||||
|
#define SIG_ATOMIC_MIN INT_MIN
|
||||||
|
#define SIG_ATOMIC_MAX INT_MAX
|
||||||
|
|
||||||
|
#ifndef SIZE_MAX // [
|
||||||
|
# ifdef _WIN64 // [
|
||||||
|
# define SIZE_MAX _UI64_MAX
|
||||||
|
# else // _WIN64 ][
|
||||||
|
# define SIZE_MAX _UI32_MAX
|
||||||
|
# endif // _WIN64 ]
|
||||||
|
#endif // SIZE_MAX ]
|
||||||
|
|
||||||
|
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
|
||||||
|
#ifndef WCHAR_MIN // [
|
||||||
|
# define WCHAR_MIN 0
|
||||||
|
#endif // WCHAR_MIN ]
|
||||||
|
#ifndef WCHAR_MAX // [
|
||||||
|
# define WCHAR_MAX _UI16_MAX
|
||||||
|
#endif // WCHAR_MAX ]
|
||||||
|
|
||||||
|
#define WINT_MIN 0
|
||||||
|
#define WINT_MAX _UI16_MAX
|
||||||
|
|
||||||
|
#endif // __STDC_LIMIT_MACROS ]
|
||||||
|
|
||||||
|
|
||||||
|
// 7.18.4 Limits of other integer types
|
||||||
|
|
||||||
|
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
|
||||||
|
|
||||||
|
// 7.18.4.1 Macros for minimum-width integer constants
|
||||||
|
|
||||||
|
#define INT8_C(val) val##i8
|
||||||
|
#define INT16_C(val) val##i16
|
||||||
|
#define INT32_C(val) val##i32
|
||||||
|
#define INT64_C(val) val##i64
|
||||||
|
|
||||||
|
#define UINT8_C(val) val##ui8
|
||||||
|
#define UINT16_C(val) val##ui16
|
||||||
|
#define UINT32_C(val) val##ui32
|
||||||
|
#define UINT64_C(val) val##ui64
|
||||||
|
|
||||||
|
// 7.18.4.2 Macros for greatest-width integer constants
|
||||||
|
#define INTMAX_C INT64_C
|
||||||
|
#define UINTMAX_C UINT64_C
|
||||||
|
|
||||||
|
#endif // __STDC_CONSTANT_MACROS ]
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _MSC_STDINT_H_ ]
|
|
@ -36,8 +36,6 @@ several games based on the Quake III Arena engine, in the form of "Q3Map2."
|
||||||
/* dependencies */
|
/* dependencies */
|
||||||
#include "q3map2.h"
|
#include "q3map2.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Random()
|
Random()
|
||||||
returns a pseudorandom number between 0 and 1
|
returns a pseudorandom number between 0 and 1
|
||||||
|
@ -62,33 +60,19 @@ static void ExitQ3Map( void )
|
||||||
free( mapDrawSurfs );
|
free( mapDrawSurfs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int MD4BlockChecksum( void * buffer, int length ) {
|
||||||
|
unsigned char digest[16];
|
||||||
|
int checksum;
|
||||||
|
|
||||||
|
md4_get_digest( buffer, length, digest );
|
||||||
/*
|
/* I suppose it has to be done that way for legacy reasons? */
|
||||||
MD4BlockChecksum()
|
checksum = digest[0] & ( digest[1] << 8 ) & ( digest[2] << 16 ) & ( digest[3] << 24 );
|
||||||
calculates an md4 checksum for a block of data
|
checksum ^= digest[4] & ( digest[5] << 8 ) & ( digest[6] << 16 ) & ( digest[7] << 24 );
|
||||||
*/
|
checksum ^= digest[8] & ( digest[9] << 8 ) & ( digest[10] << 16 ) & ( digest[11] << 24 );
|
||||||
|
checksum ^= digest[12] & ( digest[13] << 8 ) & ( digest[14] << 16 ) & ( digest[15] << 24 );
|
||||||
static int MD4BlockChecksum( void *buffer, int length )
|
|
||||||
{
|
|
||||||
MHASH mh;
|
|
||||||
int digest[ 4 ], checksum;
|
|
||||||
|
|
||||||
|
|
||||||
/* make md4 hash */
|
|
||||||
mh = mhash_init( MHASH_MD4 );
|
|
||||||
if( !mh )
|
|
||||||
Error( "Unable to initialize MD4 hash context" );
|
|
||||||
mhash( mh, buffer, length );
|
|
||||||
mhash_deinit( mh, digest );
|
|
||||||
|
|
||||||
/* xor the bits and return */
|
|
||||||
checksum = digest[ 0 ] ^ digest[ 1 ] ^ digest[ 2 ] ^ digest[ 3 ];
|
|
||||||
return checksum;
|
return checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FixAAS()
|
FixAAS()
|
||||||
resets an aas checksum to match the given BSP
|
resets an aas checksum to match the given BSP
|
||||||
|
|
|
@ -68,6 +68,7 @@ dependencies
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "mathlib.h"
|
#include "mathlib.h"
|
||||||
#include "md5lib.h"
|
#include "md5lib.h"
|
||||||
|
#include "md4lib.h"
|
||||||
#include "ddslib.h"
|
#include "ddslib.h"
|
||||||
|
|
||||||
#include "picomodel.h"
|
#include "picomodel.h"
|
||||||
|
@ -81,7 +82,7 @@ dependencies
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
/* mhash library must be installed locally or system wide - http://mhash.sourceforge.net/ */
|
/* mhash library must be installed locally or system wide - http://mhash.sourceforge.net/ */
|
||||||
#include "mhash.h"
|
//#include "mhash.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories=""$(SolutionDir)\..\mhash-0.9.9\include";"$(SolutionDir)\..\jpeg-6b";"$(SolutionDir)\tools\quake3\common";"$(SolutionDir)\include";"$(SolutionDir)\libs";"$(SolutionDir)\..\STLPort\stlport";"$(SolutionDir)\..\gtk2\include";"$(SolutionDir)\..\gtk2\include\glib-2.0";"$(SolutionDir)\..\gtk2\lib\glib-2.0\include";"$(SolutionDir)\..\libxml2\include""
|
AdditionalIncludeDirectories=""$(SolutionDir)\..\jpeg-6b";"$(SolutionDir)\tools\quake3\common";"$(SolutionDir)\include";"$(SolutionDir)\libs";"$(SolutionDir)\..\STLPort\stlport";"$(SolutionDir)\..\gtk2\include";"$(SolutionDir)\..\gtk2\include\glib-2.0";"$(SolutionDir)\..\gtk2\lib\glib-2.0\include";"$(SolutionDir)\..\libxml2\include""
|
||||||
PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
|
@ -62,8 +62,8 @@
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="libmhash.lib md5lib.lib ddslib.lib l_net.lib mathlib.lib picomodel.lib libjpeg.lib libxml2.lib libpng.lib glib-2.0.lib gobject-2.0.lib Wsock32.lib"
|
AdditionalDependencies="md5lib.lib ddslib.lib l_net.lib mathlib.lib picomodel.lib libjpeg.lib libxml2.lib libpng.lib glib-2.0.lib gobject-2.0.lib Wsock32.lib"
|
||||||
AdditionalLibraryDirectories=""$(SolutionDir)\..\mhash-0.9.9\win32\libmhash\Release";"$(SolutionDir)\..\jpeg-6b";"$(SolutionDir)\..\libxml2\lib";"$(SolutionDir)\..\gtk2\lib";"$(SolutionDir)\build\$(ConfigurationName)\libs""
|
AdditionalLibraryDirectories=""$(SolutionDir)\..\jpeg-6b";"$(SolutionDir)\..\libxml2\lib";"$(SolutionDir)\..\gtk2\lib";"$(SolutionDir)\build\$(ConfigurationName)\libs""
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
StackReserveSize="2097152"
|
StackReserveSize="2097152"
|
||||||
StackCommitSize="2097152"
|
StackCommitSize="2097152"
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalIncludeDirectories=""$(SolutionDir)\..\mhash-0.9.9\include";"$(SolutionDir)\..\jpeg-6b";"$(SolutionDir)\tools\quake3\common";"$(SolutionDir)\include";"$(SolutionDir)\libs";"$(SolutionDir)\..\STLPort\stlport";"$(SolutionDir)\..\gtk2\include";"$(SolutionDir)\..\gtk2\include\glib-2.0";"$(SolutionDir)\..\gtk2\lib\glib-2.0\include";"$(SolutionDir)\..\libxml2\include""
|
AdditionalIncludeDirectories=""$(SolutionDir)\..\jpeg-6b";"$(SolutionDir)\tools\quake3\common";"$(SolutionDir)\include";"$(SolutionDir)\libs";"$(SolutionDir)\..\STLPort\stlport";"$(SolutionDir)\..\gtk2\include";"$(SolutionDir)\..\gtk2\include\glib-2.0";"$(SolutionDir)\..\gtk2\lib\glib-2.0\include";"$(SolutionDir)\..\libxml2\include""
|
||||||
PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
|
||||||
RuntimeLibrary="2"
|
RuntimeLibrary="2"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
|
@ -138,8 +138,8 @@
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="libmhash.lib md5lib.lib ddslib.lib l_net.lib mathlib.lib picomodel.lib libjpeg.lib libxml2.lib libpng.lib glib-2.0.lib gobject-2.0.lib Wsock32.lib"
|
AdditionalDependencies="md5lib.lib ddslib.lib l_net.lib mathlib.lib picomodel.lib libjpeg.lib libxml2.lib libpng.lib glib-2.0.lib gobject-2.0.lib Wsock32.lib"
|
||||||
AdditionalLibraryDirectories=""$(SolutionDir)\..\mhash-0.9.9\win32\libmhash\Release";"$(SolutionDir)\..\jpeg-6b";"$(SolutionDir)\..\libxml2\lib";"$(SolutionDir)\..\gtk2\lib";"$(SolutionDir)\build\$(ConfigurationName)\libs""
|
AdditionalLibraryDirectories=""$(SolutionDir)\..\jpeg-6b";"$(SolutionDir)\..\libxml2\lib";"$(SolutionDir)\..\gtk2\lib";"$(SolutionDir)\build\$(ConfigurationName)\libs""
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
StackReserveSize="2097152"
|
StackReserveSize="2097152"
|
||||||
StackCommitSize="2097152"
|
StackCommitSize="2097152"
|
||||||
|
|
|
@ -408,7 +408,7 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace )
|
||||||
char shader[ MAX_QPATH ];
|
char shader[ MAX_QPATH ];
|
||||||
char *s;
|
char *s;
|
||||||
int loc;
|
int loc;
|
||||||
MHASH mh;
|
md5_state_t mh;
|
||||||
byte digest[ 16 ];
|
byte digest[ 16 ];
|
||||||
char *srcShaderText, temp[ 8192 ], shaderText[ 8192 ]; /* ydnar: fixme (make this bigger?) */
|
char *srcShaderText, temp[ 8192 ], shaderText[ 8192 ]; /* ydnar: fixme (make this bigger?) */
|
||||||
|
|
||||||
|
@ -530,11 +530,9 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make md5 hash of the shader text */
|
/* make md5 hash of the shader text */
|
||||||
mh = mhash_init( MHASH_MD5 );
|
md5_init( &mh );
|
||||||
if( !mh )
|
md5_append( &mh, shaderText, strlen( shaderText ) );
|
||||||
Error( "Unable to initialize MD5 hash context" );
|
md5_finish( &mh, digest );
|
||||||
mhash( mh, shaderText, strlen( shaderText ) );
|
|
||||||
mhash_deinit( mh, digest );
|
|
||||||
|
|
||||||
/* mangle hash into a shader name */
|
/* mangle hash into a shader name */
|
||||||
sprintf( shader, "%s/%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", mapName,
|
sprintf( shader, "%s/%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", mapName,
|
||||||
|
@ -570,7 +568,7 @@ adds a vertexremapshader key/value pair to worldspawn
|
||||||
|
|
||||||
void EmitVertexRemapShader( char *from, char *to )
|
void EmitVertexRemapShader( char *from, char *to )
|
||||||
{
|
{
|
||||||
MHASH mh;
|
md5_state_t mh;
|
||||||
byte digest[ 16 ];
|
byte digest[ 16 ];
|
||||||
char key[ 64 ], value[ 256 ];
|
char key[ 64 ], value[ 256 ];
|
||||||
|
|
||||||
|
@ -584,11 +582,9 @@ void EmitVertexRemapShader( char *from, char *to )
|
||||||
sprintf( value, "%s;%s", from, to );
|
sprintf( value, "%s;%s", from, to );
|
||||||
|
|
||||||
/* make md5 hash */
|
/* make md5 hash */
|
||||||
mh = mhash_init( MHASH_MD5 );
|
md5_init( &mh );
|
||||||
if( !mh )
|
md5_append( &mh, value, strlen( value ) );
|
||||||
Error( "Unable to initialize MD5 hash context" );
|
md5_finish( &mh, digest );
|
||||||
mhash( mh, value, strlen( value ) );
|
|
||||||
mhash_deinit( mh, digest );
|
|
||||||
|
|
||||||
/* make key (this is annoying, as vertexremapshader is precisely 17 characters,
|
/* make key (this is annoying, as vertexremapshader is precisely 17 characters,
|
||||||
which is one too long, so we leave off the last byte of the md5 digest) */
|
which is one too long, so we leave off the last byte of the md5 digest) */
|
||||||
|
|
Loading…
Reference in a new issue