diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-21 23:03:24 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-21 23:03:24 +0200 |
commit | 6399feba186d29ac3a333001807caa3c905a4244 (patch) | |
tree | 52dba55cf63954ceb917843abcde7c7581509fe7 /src/lib/eiotas_iota.c | |
parent | 2ef4c6d3ff6754a9889b414fca8bddfa4ad8023e (diff) | |
download | edoors-6399feba186d29ac3a333001807caa3c905a4244.zip edoors-6399feba186d29ac3a333001807caa3c905a4244.tar.gz |
implement eiotas_iota_init, eiotas_iota_desinit and eiotas_iota_free
Diffstat (limited to 'src/lib/eiotas_iota.c')
-rw-r--r-- | src/lib/eiotas_iota.c | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/src/lib/eiotas_iota.c b/src/lib/eiotas_iota.c index 1e8e8d8..11560c8 100644 --- a/src/lib/eiotas_iota.c +++ b/src/lib/eiotas_iota.c @@ -21,26 +21,66 @@ #endif #include "eiotas_iota.h" +#include "eiotas_spin.h" +#include "eiotas_room.h" +#include "eiotas_door.h" +#include "eiotas_board.h" #include "eiotas_private.h" -void eiotas_iota_init(Eiotas_Iota *iota, const char *name, Eiotas_Iota *parent, Eiotas_Type type) +int eiotas_iota_init(Eiotas_Iota *iota, const char *name, Eiotas_Iota *parent, Eiotas_Type type) { - // TODO + int ln, lp; + char tmp[MAX_PATH_LENGTH]; + + iota->type = type; + iota->spin = ( parent ? parent->spin : iota ); + iota->parent = parent; + if(parent) { + ln = strlen(name); + lp = eina_stringshare_strlen(parent->path); + if((ln+lp+2)>MAX_PATH_LENGTH) { + ERR("path length %d is > MAX_PATH_LENGTH (%d)",(ln+lp+2),MAX_PATH_LENGTH); + return 1; + } + memcpy(tmp,parent->path,lp); + tmp[lp]='/'; + memcpy((tmp+lp+1),name,ln+1); + iota->name = eina_stringshare_add(name); + iota->path = eina_stringshare_add(tmp); + } else { + iota->name = eina_stringshare_add(name); + iota->path = eina_stringshare_add(name); + } + + return 0; } void eiotas_iota_desinit(Eiotas_Iota *iota) { - // TODO + eina_stringshare_del(iota->name); + eina_stringshare_del(iota->path); } void eiotas_iota_free(Eiotas_Iota *iota) { - // TODO + switch(iota->type) { + case EIOTAS_TYPE_SPIN: + eiotas_spin_free((Eiotas_Spin*)iota); + break; + case EIOTAS_TYPE_ROOM: + eiotas_room_free((Eiotas_Room*)iota); + break; + case EIOTAS_TYPE_DOOR: + eiotas_door_free((Eiotas_Door*)iota); + break; + case EIOTAS_TYPE_BOARD: + eiotas_board_free((Eiotas_Board*)iota); + break; + } } -EAPI void -eiotas_iota_show(Eiotas_Iota *iota) +EAPI void eiotas_iota_show(Eiotas_Iota *iota) { - DBG("Iota(%d) 0x%X : %s (%s) [0x%X])",iota->type,iota,iota->name,iota->path,iota->parent); + DBG("Iota(%d) 0x%X : %s (%s) [0x%X] {0x%X}",iota->type,iota,iota->name,iota->path,iota->parent,iota->spin); } |