00001
00013 #ifndef BORIS_H
00014 #define BORIS_H
00015
00016
00017
00018 struct channel;
00019 struct channel_member;
00020 struct freelist_entry;
00021
00022
00023
00024
00025 #include "plugin.h"
00026 #include "list.h"
00027
00028
00029
00030
00031
00033 #define NR(x) (sizeof(x)/sizeof*(x))
00034
00036 #define ROUNDUP(a,n) (((a)+(n)-1)/(n)*(n))
00037
00039 #define ROUNDDOWN(a,n) ((a)-((a)%(n)))
00040
00041 #define B_LOG_ASSERT 0
00042 #define B_LOG_CRIT 1
00043 #define B_LOG_ERROR 2
00044 #define B_LOG_WARN 3
00045 #define B_LOG_INFO 4
00046 #define B_LOG_TODO 5
00047 #define B_LOG_DEBUG 6
00048 #define B_LOG_TRACE 7
00050
00051 #define DOMAIN_USER "users"
00052 #define DOMAIN_ROOM "rooms"
00053 #define DOMAIN_CHARACTER "chars"
00054
00056 #define ID_MAX 32767
00057
00058
00059
00060
00061
00065 struct attr_entry {
00066 LIST_ENTRY(struct attr_entry) list;
00067 char *name;
00068 char *value;
00069 };
00070
00075 LIST_HEAD(struct attr_list, struct attr_entry);
00076
00080 enum value_type {
00081 VALUE_TYPE_STRING,
00082 VALUE_TYPE_UINT,
00083 };
00084
00088 struct description_string {
00089 char *short_str;
00090 char *long_str;
00091 };
00092
00096 LIST_HEAD(struct freelist_listhead, struct freelist_entry);
00097
00102 struct freelist {
00103
00104 struct freelist_listhead global;
00105 };
00106
00114 struct channel_member {
00115 void (*send)(struct channel_member *cm, struct channel *ch, const char *msg);
00116 void *p;
00117 };
00118
00119
00120
00121
00122
00123 extern void (*b_log)(int priority, const char *domain, const char *fmt, ...);
00124 extern struct plugin_fdb_interface fdb;
00125
00126 int service_detach_log(void (*log)(int priority, const char *domain, const char *fmt, ...));
00127 void service_attach_log(void (*log)(int priority, const char *domain, const char *fmt, ...));
00128 void service_detach_fdb(const struct plugin_basic_class *cls);
00129 void service_attach_fdb(const struct plugin_basic_class *cls, const struct plugin_fdb_interface *interface);
00130 void service_detach_room(const struct plugin_basic_class *cls);
00131 void service_attach_room(const struct plugin_basic_class *cls, const struct plugin_room_interface *interface);
00132 void service_detach_character(const struct plugin_basic_class *cls);
00133 void service_attach_character(const struct plugin_basic_class *cls, const struct plugin_character_interface *interface);
00134 void service_detach_channel(const struct plugin_basic_class *cls);
00135 void service_attach_channel(const struct plugin_basic_class *cls, const struct plugin_channel_interface *interface);
00136
00137 struct attr_entry *attr_find(struct attr_list *al, const char *name);
00138 int attr_add(struct attr_list *al, const char *name, const char *value);
00139 void attr_list_free(struct attr_list *al);
00140
00141 int parse_uint(const char *name, const char *value, unsigned *uint_p);
00142 int parse_str(const char *name, const char *value, char **str_p);
00143 int parse_attr(const char *name, const char *value, struct attr_list *al);
00144 int value_set(const char *value, enum value_type type, void *p);
00145 const char *value_get(enum value_type type, void *p);
00146
00147 void freelist_init(struct freelist *fl);
00148 void freelist_free(struct freelist *fl);
00149 long freelist_alloc(struct freelist *fl, unsigned count);
00150 void freelist_pool(struct freelist *fl, unsigned ofs, unsigned count);
00151 int freelist_thwack(struct freelist *fl, unsigned ofs, unsigned count);
00152 #ifndef NTEST
00153 void freelist_test(void);
00154 #endif
00155
00156 #endif