1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
/*
* ion/ioncore/reginfo.c
*
* Copyright (c) Tuomo Valkonen 1999-2007.
*
* See the included file LICENSE for details.
*/
#include <string.h>
#include <ctype.h>
#include "common.h"
#include "region.h"
#include <libtu/objp.h>
#include "attach.h"
#include "reginfo.h"
static WRegClassInfo *reg_class_infos;
/*{{{ Registration */
bool ioncore_register_regclass(ClassDescr *descr, WRegionLoadCreateFn *lc_fn)
{
WRegClassInfo *info;
if(descr==NULL)
return FALSE;
info=ALLOC(WRegClassInfo);
if(info==NULL)
return FALSE;
info->descr=descr;
info->lc_fn=lc_fn;
LINK_ITEM(reg_class_infos, info, next, prev);
return TRUE;
}
void ioncore_unregister_regclass(ClassDescr *descr)
{
WRegClassInfo *info;
for(info=reg_class_infos; info!=NULL; info=info->next){
if(descr==info->descr){
UNLINK_ITEM(reg_class_infos, info, next, prev);
free(info);
return;
}
}
}
/*}}}*/
/*{{{ Lookup */
WRegClassInfo *ioncore_lookup_regclass(const char *name, bool inheriting_ok)
{
WRegClassInfo *info;
ClassDescr *descr;
if(name==NULL)
return NULL;
for(info=reg_class_infos; info!=NULL; info=info->next){
for(descr=info->descr;
descr!=NULL;
descr=(inheriting_ok ? descr->ancestor : NULL)){
if(strcmp(descr->name, name)==0){
if(info->lc_fn!=NULL)
return info;
}
}
}
return NULL;
}
/*}}}*/
|