Add support for preloading lua modules. This is useful both when
providing lua bindings to applications based on librazor and when
producing static binaries using librazor (where otherwise the lua
POSIX library would need to be included as an additional dynamic
object).
2 * Copyright (C) 2009 J. Ali Harlow <ali@juiblex.co.uk>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "razor-internal.h"
28 struct hashtable table;
30 static int test_key(const char *key)
34 value = hashtable_insert(&table, key);
35 if (value == invalid) {
37 "%s: hashtable_insert returned invalid value\n", key);
39 } else if (value >= pool.size) {
40 fprintf(stderr, "%s: hashtable_insert returned value outside "
43 } else if (pool.size - value <= strlen(key) ||
44 strcmp(pool.data + value, key)) {
45 fprintf(stderr, "%s: value returned by hashtable_insert does "
46 "not match key\n", key);
48 } else if (hashtable_lookup(&table, key) != value) {
49 fprintf(stderr, "%s: hashtable_lookup didn't return expected "
52 } else if (hashtable_tokenize(&table, key) != value) {
53 fprintf(stderr, "%s: hashtable_tokenize didn't return expected "
60 int main(int argc, char *argv[])
65 hashtable_init(&table, &pool);
66 invalid = hashtable_lookup(&table, "non-existant");
68 errors += test_key("key1");
69 errors += test_key("key2");
71 hashtable_release(&table);