static void dumpSource(FILE * of, IBlk * b) { ITreeNode_traverse( __ucast__(IBlk, ITreeNode, b), dumpBlk, __true, ITreeNode_both_order, (__uint)of ); }
/* dynamic configuration support of ICBlk */ FBD_API __bool ICBlk_add_blk(ICBlk * _this, IBlk * b) { ITreeNode *t1; ITreeNode *t2; IBlk * me; me = __ucast__(ICBlk, IBlk, _this); if( IBlk_subblk(me, &b->uuid)) { // Already exists return __false; } t1 = __ucast2__(ICBlk, IBlk, ITreeNode, _this); t2 = __ucast__(IBlk, ITreeNode, b); if( !ITreeNode_mount(t1, t2, __true)) { return __false; } me->h.u1.n_subblocks++; return __true; }
FBD_API struct cblk_link_t * ICBlk_link_by_id(ICBlk *cblk, __u16 id) { PRTK_LIST_ENTRY li; if(id > __ucast__(ICBlk, IBlk, cblk)->h.u2.n_links) { return 0; } li = cblk->links.Flink; while(id--) { li = li->Flink; assert(li!=&cblk->links); } return SAFE_CONTAINING_RECORD(li, struct cblk_link_t, sibling); }
static int UTILS_API _e_file( const char * szBaseDir, const char * szFullPath, const char * szRelativePath, const void * pvSearchContext ) { IBlk * blk; char buf[128]; IFileStream *fs; IF8Stream *s; int roffset; fs = IFileStream_from_file(szFullPath, "rb"); if(!fs){ return 1; } s = __ucast__(IFileStream, IF8Stream, (fs)); blk = IBlk_from_stream(s); if(!blk){ __delete__(fs); return 1; } roffset = __vcall__(s, tell, (s)); load_res_stream(s); probe_blk_resources(blk); fprintf(fdb, "%d=%s,%c%c,%s", count, IBlk_class_name(blk), blk->h.magic >> 8, blk->h.magic & 0xff, szRelativePath ); f8_uuid_to_string(&blk->h.uuid, buf, sizeof(buf)); fprintf(fdb, ",%s", buf); fprintf(fdb, ",%d", roffset); fprintf(fdb, "\n"); delete_blk(blk); __delete__(fs); count++; return 1; }
KPROXY_API f8_bool kproxy_init(int leakDetect) { ITcpAdapter *a; _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); _CrtSetBreakAlloc(leakDetect); /* initialize and start kernel */ ex_init(); /* KERN_F_ENABLE_INPUT */ x_buffer = (char *)__malloc__(LARGE_BUF_SIZE); x_buf_len = LARGE_BUF_SIZE; b_ShellExit = __false; __new__(ITcpAdapter, a); proxy_adapter = __ucast__(ITcpAdapter, IKAdapter, a); sections = ke_get_blk(proxy_adapter->kernel, 0); assert(sections->uuid == BLK_ID_ROOT); create_resource(§ions->uuid); create_f8_uuid(§ions->h.uuid); create_resource(§ions->h.uuid); memset(fileName, 0 , sizeof(fileName)); g_shell = shell_create(commands); reset_reg_map(); init_blklib(); init_clipboard(); g_bDirty = __false; init_network(RTK_INIT_AS_SERVER, 0); vbus = connect_vbus(0xf8, VBUS_CONNECT_AS_SERVER, sr, 0); return __true; }
ICBlk * ICBlk_from_stream (IF8Stream * s) { ICBlk * blk; IBlk * b; blk = mm_alloc(g_hBlkHeap, sizeof(ICBlk), 0); if(!blk) { return 0; } __create__(ICBlk, blk); b = __ucast__(ICBlk, IBlk, blk); if(!__vcall__(b, load, (b, s))) { delete_blk(b); return 0; } return blk; }
/* remove a connection */ FBD_API __bool ICBlk_unlink(struct cblk_link_t * lk) { IBlk * me; me = parent_blk(lk->t.pin->blk); assert(me->h.magic == CBLK_MAGIC); assert(me == __ucast__(ICBlk, IBlk, lk->blk)); IBlk_disconnect(lk->t.pin); RtkRemoveEntryList(&lk->sibling); me->h.u2.n_links--; // assert(me->h.u2.n_links >= 0); #ifdef F8_CONFIGURATOR unload_resource(&lk->uuid); #endif mm_free(g_hBlkHeap, lk); return __true; }
/* import a resource from disk, and if the resource has already been loaded, increment its reference count. 2005/6/24 the load_from_disk branch is obsolete. */ F8RES_API __bool load_resource( const f8_uuid * id ) { RESMAP::iterator it; it = g_Resources.find(*id); if(it != g_Resources.end()){ it->second.refcount++; return __true; } return __false; #if 0 IFileStream *fs; IF8Stream * str; char buf[43]; f8_uuid_to_string(id, buf, sizeof(buf)); strcat(buf, ".res"); fs = IFileStream_from_file(buf, "rb"); if(!fs){ return __false; } str = __ucast__(IFileStream, IF8Stream, fs); h = _load_res_stream(str); if(h){ if(*id != h->id){ /* error in library */ unload_resource(&h->id); h = 0; } } __delete__(fs); return h? __true : __false; #endif }
static __inline IBlk * _extract_blk(IMemStream * _s) { IF8Stream * s; s = __ucast__(IMemStream, IF8Stream, _s); return IBlk_from_stream(s); }