00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _UL_CALLBACKS_H
00034 #define _UL_CALLBACKS_H
00035
00036 #include "ucontact.h"
00037
00038
00039 #define UL_CONTACT_INSERT (1<<0)
00040 #define UL_CONTACT_UPDATE (1<<1)
00041 #define UL_CONTACT_DELETE (1<<2)
00042 #define UL_CONTACT_EXPIRE (1<<3)
00043 #define ULCB_MAX ((1<<4)-1)
00044
00045
00046 typedef void (ul_cb) (ucontact_t *c, int type, void *param);
00047
00048 typedef int (*register_ulcb_t)( int cb_types, ul_cb f, void *param);
00049
00050
00051 struct ul_callback {
00052 int id;
00053 int types;
00054 ul_cb* callback;
00055 void *param;
00056 struct ul_callback* next;
00057 };
00058
00059 struct ulcb_head_list {
00060 struct ul_callback *first;
00061 int reg_types;
00062 };
00063
00064
00065 extern struct ulcb_head_list* ulcb_list;
00066
00067
00068 #define exists_ulcb_type(_types_) \
00069 ( (ulcb_list->reg_types)|(_types_) )
00070
00071
00072 int init_ulcb_list();
00073
00074 void destroy_ulcb_list();
00075
00076
00077
00078 int register_ulcb( int types, ul_cb f, void *param );
00079
00080
00081 static inline void run_ul_callbacks( int type , ucontact_t *c)
00082 {
00083 struct ul_callback *cbp;
00084
00085 for (cbp=ulcb_list->first; cbp; cbp=cbp->next) {
00086 DBG("DBG:usrloc: contact=%p, callback type %d, id %d entered\n",
00087 c, cbp->types, cbp->id );
00088 cbp->callback( c, type, cbp->param );
00089 }
00090 }
00091
00092
00093
00094 #endif