2012-04-23 19:39:44 +01:00
|
|
|
#ifndef HAMMER_INTERNAL__H
|
|
|
|
|
#define HAMMER_INTERNAL__H
|
2012-05-04 21:23:56 +01:00
|
|
|
#include <glib.h>
|
2012-04-23 19:39:44 +01:00
|
|
|
#include "hammer.h"
|
|
|
|
|
|
2012-04-29 01:45:52 +01:00
|
|
|
#define false 0
|
|
|
|
|
#define true 1
|
|
|
|
|
|
2012-05-03 01:58:09 +01:00
|
|
|
typedef struct parser_cache_key {
|
|
|
|
|
input_stream_t input_pos;
|
|
|
|
|
const parser_t *parser;
|
|
|
|
|
} parser_cache_key_t;
|
|
|
|
|
|
2012-05-04 21:23:56 +01:00
|
|
|
typedef unsigned int *charset;
|
|
|
|
|
|
|
|
|
|
static inline charset new_charset() {
|
|
|
|
|
charset cs = g_new0(unsigned int, 256 / sizeof(unsigned int));
|
|
|
|
|
return cs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int charset_isset(charset cs, uint8_t pos) {
|
|
|
|
|
return !!(cs[pos / sizeof(*cs)] & (1 << (pos % sizeof(*cs))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void charset_set(charset cs, uint8_t pos, int val) {
|
|
|
|
|
cs[pos / sizeof(*cs)] =
|
|
|
|
|
val
|
|
|
|
|
? cs[pos / sizeof(*cs)] | (1 << (pos % sizeof(*cs)))
|
|
|
|
|
: cs[pos / sizeof(*cs)] & ~(1 << (pos % sizeof(*cs)));
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-03 01:58:09 +01:00
|
|
|
// TODO(thequux): Set symbol visibility for these functions so that they aren't exported.
|
2012-04-23 19:39:44 +01:00
|
|
|
|
2012-05-03 01:58:09 +01:00
|
|
|
long long read_bits(input_stream_t* state, int count, char signed_p);
|
|
|
|
|
parse_result_t* do_parse(const parser_t* parser, parse_state_t *state);
|
|
|
|
|
void put_cached(parse_state_t *ps, const parser_t *p, parse_result_t *cached);
|
|
|
|
|
guint djbhash(const uint8_t *buf, size_t len);
|
2012-04-23 19:39:44 +01:00
|
|
|
#endif // #ifndef HAMMER_INTERNAL__H
|