00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef MUXEVENT_H
00016 #define MUXEVENT_H
00017
00018
00019
00020
00021
00022
00023
00024 #define FLAG_FREE_DATA 1
00025 #define FLAG_FREE_DATA2 2
00026 #define FLAG_ZOMBIE 4
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 typedef struct my_event_type {
00044 char flags;
00045 void (*function) (struct my_event_type *);
00046 void *data;
00047 void *data2;
00048 int tick;
00049 char type;
00050 struct my_event_type *next;
00051 struct my_event_type *next_in_main;
00052 struct my_event_type *prev_in_main;
00053 struct my_event_type *prev_in_type;
00054 struct my_event_type *next_in_type;
00055 } MUXEVENT;
00056
00057
00058 extern int muxevent_tick;
00059
00060 #include "p.event.h"
00061
00062
00063
00064
00065 #define muxevent_add_simple_arg(time,func,data) muxevent_add(time,0,0,func,data, NULL)
00066 #define muxevent_add_simple_noarg(time,func) muxevent_add(time,0,0,func,NULL, NULL)
00067
00068
00069
00070
00071
00072
00073 #define REMOVE_FROM_LIST(a,c,b) if (a == b ) a = b->c; else { MUXEVENT *t; \
00074 for (t=a;t->c != b;t=t->c); t->c = b->c; }
00075 #define REMOVE_FROM_BIDIR_LIST(a,c,d,b) if (b->c) b->c->d = b->d; \
00076 if (b->d) b->d->c = b->c; if (a==b) { a=b->d; if (a) a->c=NULL; }
00077
00078 #define ADD_TO_LIST_HEAD(a,c,b) b->c = a ; a = b
00079 #define ADD_TO_BIDIR_LIST_HEAD(a,c,d,b) b->d=a ; if (a) a->c = b ; a=b ; \
00080 b->c=NULL
00081
00082
00083
00084
00085
00086 #ifdef DEBUG
00087 #define debug(a...) printf(##a)
00088 #else
00089 #define debug(a...)
00090 #endif
00091
00092 void muxevent_add(int time, int flags, int type, void (*func) (MUXEVENT *),
00093 void *data, void *data2);
00094 void muxevent_gothru_type_data(int type, void *data, void (*func) (MUXEVENT *));
00095 void event_gothru_type(int type, void (*func) (MUXEVENT *));
00096
00097
00098
00099
00100
00101 #endif