Include mod_xrandr instead of using submodules
[notion/jeffpc.git] / ioncore / reginfo.c
blob24e75d0ae75218a895728358aa85e75d18db6f23
1 /*
2 * ion/ioncore/reginfo.c
4 * Copyright (c) Tuomo Valkonen 1999-2009.
6 * See the included file LICENSE for details.
7 */
9 #include <string.h>
10 #include <ctype.h>
12 #include "common.h"
13 #include "region.h"
14 #include <libtu/objp.h>
15 #include "attach.h"
16 #include "reginfo.h"
19 static WRegClassInfo *reg_class_infos;
22 /*{{{ Registration */
25 bool ioncore_register_regclass(ClassDescr *descr, WRegionLoadCreateFn *lc_fn)
27 WRegClassInfo *info;
29 if(descr==NULL)
30 return FALSE;
32 info=ALLOC(WRegClassInfo);
33 if(info==NULL)
34 return FALSE;
36 info->descr=descr;
37 info->lc_fn=lc_fn;
38 LINK_ITEM(reg_class_infos, info, next, prev);
40 return TRUE;
44 void ioncore_unregister_regclass(ClassDescr *descr)
46 WRegClassInfo *info;
48 for(info=reg_class_infos; info!=NULL; info=info->next){
49 if(descr==info->descr){
50 UNLINK_ITEM(reg_class_infos, info, next, prev);
51 free(info);
52 return;
58 /*}}}*/
61 /*{{{ Lookup */
64 WRegClassInfo *ioncore_lookup_regclass(const char *name, bool inheriting_ok)
66 WRegClassInfo *info;
67 ClassDescr *descr;
69 if(name==NULL)
70 return NULL;
72 for(info=reg_class_infos; info!=NULL; info=info->next){
73 for(descr=info->descr;
74 descr!=NULL;
75 descr=(inheriting_ok ? descr->ancestor : NULL)){
77 if(strcmp(descr->name, name)==0){
78 if(info->lc_fn!=NULL)
79 return info;
83 return NULL;
87 /*}}}*/