--- /dev/null
+#ifndef KERNEL_H
+#define KERNEL_H
+
+/*
+ This API is the equivalent of a system call API and thereby
+ insulates its user from a GPL implementation.
+*/
+
+#include <platform.h>
+
+/* -------------------------------------------------------------------------- */
+
+PUBLIC CONSOLE k_console;
+PUBLIC char* k_version;
+PUBLIC char* k_ciux;
+PUBLIC void (*k_terminate)(void);
+
+/* -------------------------------------------------------------------------- */
+
+#define NAME_OF_MODULE_LOADED_FN "_module_loaded"
+
+typedef int (*k_module_loaded_fn)(void);
+
+/* -------------------------------------------------------------------------- */
+
+#define NAME_OF_MODULE_TICK_FN "_module_tick"
+
+typedef void (*k_module_tick_fn)(void);
+
+/* -------------------------------------------------------------------------- */
+
+#define NAME_OF_MODULE_EVENT_FN "_module_event"
+
+typedef int (*k_module_event_fn)(void* data);
+
+PUBLIC int k_event_post(char* module, void* data);
+
+/* -------------------------------------------------------------------------- */
+
+typedef void (*k_gl_reshape_event)(int width, int height);
+typedef void (*k_gl_draw_event)(void);
+typedef void (*k_gl_key_event)(unsigned char k, int down);
+PUBLIC void k_gl_register_reshape(k_gl_reshape_event);
+PUBLIC void k_gl_register_draw( k_gl_draw_event);
+PUBLIC void k_gl_register_key( k_gl_key_event);
+PUBLIC void gluxSwapBuffers(void);
+
+/* -------------------------------------------------------------------------- */
+
+#define CRLF "\015\012"
+#define CHAN_LISTEN 1
+#define CHAN_ESTABL 2
+#define CHAN_ANY 3
+
+typedef struct k_channel k_channel;
+typedef struct k_channel_priv k_channel_priv;
+
+typedef int (*k_channel_event)(k_channel* chan,
+ int bufpos,
+ int size);
+
+struct k_channel{ struct k_channel* next;
+
+ char* name;
+ char* listenhost;
+ int listenport;
+ char* banner;
+ k_channel_event rdcallback;
+ k_channel_event wrcallback;
+ void* context;
+ int type;
+ struct in_addr clientip;
+ int linger;
+ k_channel_priv* priv;
+};
+
+PUBLIC char* k_channel_name(char* type, char* ip, int port, char* other);
+PUBLIC k_channel* k_channel_connect_name(char* chanm,
+ k_channel_event rdcallback,
+ k_channel_event wrcallback);
+PUBLIC k_channel* k_channel_get_name(char* chanm);
+PUBLIC void k_channel_show_all(void);
+
+PUBLIC k_channel* k_channel_listen(char* name,
+ int listenport,
+ char* banner,
+ k_channel_event rdcallback,
+ k_channel_event wrcallback,
+ void* context);
+
+PUBLIC k_channel* k_channel_connect(char* name,
+ char* listenhost,
+ int listenport,
+ k_channel_event rdcallback,
+ k_channel_event wrcallback,
+ void* context);
+
+#define FREE_ON_SENT 1
+PUBLIC k_channel* k_channel_send(k_channel* chan,
+ char* base,
+ size_t size,
+ int free);
+
+#define BUFFER_ALREADY_SET -1
+#define BUFFER_FILLED 1
+#define BUFFER_SET 0
+PUBLIC char* k_channel_chop_div( k_channel* chan, char* divider);
+PUBLIC char* k_channel_chop_len( k_channel* chan, size_t size);
+PUBLIC int k_channel_setbuf( k_channel* chan, char* rdbuffer, size_t size);
+PUBLIC char* k_channel_getbuf( k_channel* chan);
+
+PUBLIC void k_channel_close(k_channel* chan);
+
+/* -------------------------------------------------------------------------- */
+
+#define STAT_F 0100000
+#define STAT_D 0040000
+#define STAT_L 0120000
+#define MAX_FILESIZE (1024*1024*1024)
+#define USE_MMAP 0
+#define USE_MALL MAX_FILESIZE
+
+typedef struct k_stat{
+ int type;
+ size_t size;
+ time_t time;
+ mode_t perm;
+} k_stat;
+
+typedef void (*k_file_event)(char* basedir,
+ char* filename,
+ char* data,
+ int usedmmap,
+ k_stat stat,
+ void* context);
+
+PUBLIC void k_file_stat( char* basedir, char* filename,
+ k_file_event callback, void* context);
+PUBLIC void k_file_read( char* basedir, char* filename, size_t msz, size_t size,
+ k_file_event callback, void* context);
+PUBLIC void k_file_write(char* basedir, char* filename, char* data, size_t size,
+ k_file_event callback, void* context);
+PUBLIC void k_dir_list( char* basedir, char* dirname,
+ char* pattern[], char* format[],
+ k_file_event callback, void* context);
+PUBLIC int k_file_sync(char* data, size_t size);
+
+/* -------------------------------------------------------------------------- */
+
+typedef struct k_hashtable{ struct k_hashtable* next; } k_hashtable;
+
+typedef void (*k_hashtable_apply_fn)(void* arg, char* key, void* val);
+
+PUBLIC k_hashtable* k_hashtable_new(char* name, int ignorecase);
+PUBLIC k_hashtable* k_hashtable_dup( k_hashtable* tab);
+PUBLIC k_hashtable* k_hashtable_deep(k_hashtable* tab);
+PUBLIC k_hashtable* k_hashtable_dip( k_hashtable* tab, char* includes[]);
+PUBLIC void k_hashtable_merge( k_hashtable* tab, k_hashtable* tam);
+PUBLIC void k_hashtable_set( k_hashtable* tab, char* key, void* val);
+PUBLIC void k_hashtable_put( k_hashtable* tab, char* key, void* val);
+PUBLIC void k_hashtable_put_dup(k_hashtable* tab, char* key, char* val);
+PUBLIC void k_hashtable_put_int(k_hashtable* tab, char* key, int val);
+PUBLIC void k_hashtable_sub( k_hashtable* tab, char* key, k_hashtable* sub);
+PUBLIC void* k_hashtable_get( k_hashtable* tab, char* key);
+PUBLIC char* k_hashtable_get_dup(k_hashtable* tab, char* key);
+PUBLIC int k_hashtable_get_int(k_hashtable* tab, char* key);
+PUBLIC int k_hashtable_is( k_hashtable* tab, char* key, char* val);
+PUBLIC int k_hashtable_isi( k_hashtable* tab, char* key, char* val);
+PUBLIC int k_hashtable_isn( k_hashtable* tab, char* key, char* val,size_t);
+PUBLIC void k_hashtable_remove( k_hashtable* tab, char* key);
+PUBLIC void* k_hashtable_extract(k_hashtable* tab, char* key);
+PUBLIC void k_hashtable_apply( k_hashtable* tab, k_hashtable_apply_fn, void*);
+PUBLIC void k_hashtable_show( k_hashtable* tab);
+PUBLIC void k_hashtable_show_chars(k_hashtable* tab);
+PUBLIC int k_hashtable_snprintf( k_hashtable* tab, char* buf, size_t size);
+PUBLIC int k_hashtable_snprintf_i(k_hashtable* tab, char* buf, size_t size,
+ char* includes[]);
+PUBLIC int k_hashtable_snprintf_x(k_hashtable* tab, char* buf, size_t size,
+ char* excludes[]);
+PUBLIC void k_hashtable_delete(k_hashtable* tab);
+
+/* -------------------------------------------------------------------------- */
+
+PUBLIC int k_string_matches_pattern(char* string, char* pattern);
+PUBLIC int k_string_ends_with( char* string, char* postfix);
+PUBLIC void k_string_url_decode( char* string);
+
+/* -------------------------------------------------------------------------- */
+
+PUBLIC char* k_time_to_rfc(time_t t);
+PUBLIC char* k_time_to_rfc_relative(int plus);
+PUBLIC time_t k_time_from_rfc(char* s);
+PUBLIC void k_time_get_now(char* buf, size_t size, char* format);
+
+/* -------------------------------------------------------------------------- */
+
+PUBLIC void k_random_bytes(char* buf, size_t size);
+
+/* -------------------------------------------------------------------------- */
+
+PUBLIC void* k_malloc(size_t size);
+PUBLIC void* k_realloc(void* o, size_t size);
+PUBLIC char* k_strdup(char* s);
+PUBLIC void* k_memdup(void* s, size_t size);
+PUBLIC void k_free(void* o);
+
+/* -------------------------------------------------------------------------- */
+
+PUBLIC void k_log_out(char* format, ...);
+PUBLIC void k_log_err(char* format, ...);
+PUBLIC void k_fatal( char* format, ...);
+
+/* -------------------------------------------------------------------------- */
+
+
+#endif
+
+