mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
982 B
47 lines
982 B
12 years ago
|
/*
|
||
|
* Utilities
|
||
|
*/
|
||
|
|
||
|
#ifndef __DUK_UTIL_H
|
||
|
#define __DUK_UTIL_H 1
|
||
|
|
||
|
#include "duk_bittypes.h"
|
||
|
|
||
|
#define DUK_UTIL_MIN_HASH_PRIME 17 /* must match genhashsizes.py */
|
||
|
|
||
|
#define DUK_UTIL_GET_HASH_PROBE_STEP(hash) (duk_util_probe_steps[(hash) & 0x1f])
|
||
|
|
||
|
/*
|
||
|
* Bitstream decoder
|
||
|
*/
|
||
|
|
||
|
struct duk_bitdecoder_ctx {
|
||
|
duk_u8 *data;
|
||
|
duk_u32 offset;
|
||
|
duk_u32 length;
|
||
|
duk_u32 currval;
|
||
|
duk_u32 currbits;
|
||
|
};
|
||
|
|
||
|
/*
|
||
|
* Prototypes
|
||
|
*/
|
||
|
|
||
|
/* Note: assumes that duk_util_probe_steps size is 32 */
|
||
|
extern duk_u8 duk_util_probe_steps[32];
|
||
|
|
||
|
duk_u32 duk_util_hashbytes(duk_u8 *data, duk_u32 len, duk_u32 seed);
|
||
|
|
||
|
duk_u32 duk_util_get_hash_prime(duk_u32 size);
|
||
|
|
||
|
duk_u32 duk_bd_decode(duk_bitdecoder_ctx *ctx, int bits);
|
||
|
int duk_bd_decode_flag(duk_bitdecoder_ctx *ctx);
|
||
|
|
||
|
void duk_util_base64_encode(const unsigned char *src, unsigned char *dst, size_t len);
|
||
|
|
||
|
duk_u32 duk_util_tinyrandom_get_bits(duk_hthread *thr, int n);
|
||
|
double duk_util_tinyrandom_get_double(duk_hthread *thr);
|
||
|
|
||
|
#endif /* __DUK_UTIL_H */
|
||
|
|