TLIBAPI void TDestroy(TAPTR handle) { if (handle) TCALLHOOKPKT(&((struct THandle *) handle)->thn_Hook, handle, TMSG_DESTROY); }
TLIBAPI TAPTR TGetNextEntry(struct THandle *handle) { if (handle) return (TAPTR) TCALLHOOKPKT(&handle->thn_Hook, handle, TMSG_GETNEXTENTRY); return TNULL; }
LOCAL void exec_returnmsg(TEXECBASE *exec, TAPTR mem, TUINT status) { struct TMessage *msg = TGETMSGPTR(mem); struct TMsgPort *replyport = msg->tmsg_RPort; if (replyport) { TAPTR hal = exec->texb_HALBase; THALLock(hal, &replyport->tmp_Lock); TAddTail(&replyport->tmp_MsgList, (struct TNode *) msg); msg->tmsg_Flags = status; if (replyport->tmp_Hook) TCALLHOOKPKT(replyport->tmp_Hook, replyport, (TTAG) msg); THALUnlock(hal, &replyport->tmp_Lock); THALSignal(hal, &replyport->tmp_SigTask->tsk_Thread, replyport->tmp_Signal); } else { exec_Free(exec, mem); /* free one-way msg transparently */ TDBPRINTF(TDB_TRACE,("message returned to memory manager\n")); } }
TLIBAPI void TDestroyList(struct TList *list) { struct TNode *nextnode, *node = list->tlh_Head; while ((nextnode = node->tln_Succ)) { TREMOVE(node); TCALLHOOKPKT(&((struct THandle *) node)->thn_Hook, node, TMSG_DESTROY); node = nextnode; } }
static THOOKENTRY TTAG teklib_destroyiface(struct THook *h, TAPTR obj, TTAG msg) { if (msg == TMSG_DESTROY) { struct TInterface *iface = obj; struct TModule *mod = iface->tif_Module; if (mod->tmd_Flags & TMODF_QUERYIFACE) TCALLHOOKPKT(&mod->tmd_Handle.thn_Hook, iface, TMSG_DROPIFACE); } return 0; }
TLIBAPI TBOOL TForEachTag(struct TTagItem *taglist, struct THook *hook) { TBOOL complete = TFALSE; if (hook) { complete = TTRUE; while (taglist && complete) { switch ((TUINT) taglist->tti_Tag) { case TTAG_DONE: return complete; case TTAG_MORE: taglist = (struct TTagItem *) taglist->tti_Value; break; case TTAG_SKIP: taglist += 1 + (TINT) taglist->tti_Value; break; case TTAG_GOSUB: complete = TForEachTag((struct TTagItem *) taglist->tti_Value, hook); taglist++; break; default: complete = (TBOOL) TCALLHOOKPKT(hook, taglist, TMSG_FOREACHTAG); case TTAG_IGNORE: taglist++; break; } } } return TFALSE; }
static TBOOL scanpathtolist(struct THook *hook, TSTRPTR path, TSTRPTR name) { WIN32_FIND_DATA fd; TBOOL success = TTRUE; HANDLE hfd = FindFirstFile(path, &fd); if (hfd != INVALID_HANDLE_VALUE) { TINT l, pl = strlen(name); struct THALScanModMsg msg; do { l = strlen(fd.cFileName); if (l < pl + TEKHOST_EXTLEN) continue; if (strcmp(fd.cFileName + l - TEKHOST_EXTLEN, TEKHOST_EXTSTR)) continue; if (strncmp(fd.cFileName, name, pl)) continue; msg.tsmm_Name = fd.cFileName; msg.tsmm_Length = l - TEKHOST_EXTLEN; msg.tsmm_Flags = 0; success = (TBOOL) TCALLHOOKPKT(hook, TNULL, (TTAG) &msg); #if 0 if (l >= pl + 4) { if (!strncmp(fd.cFileName, name, pl)) { success = (*callb)(userdata, fd.cFileName, l - 4); } } #endif } while (success && FindNextFile(hfd, &fd)); FindClose(hfd); } return success; }
static void init_tek_destroy(TAPTR apptask) { TAPTR exec, exectask, boot; struct TEKlibInit *init; exec = TGetExecBase(apptask); exectask = TExecFindTask(exec, TTASKNAME_EXEC); init = TExecGetInitData(exec, exectask); boot = init->tli_BootHnd; init_destroyatom(exec, init->tli_AtomUnique, "sys.unique"); init_destroyatom(exec, init->tli_AtomRetValP, "sys.returnvalue"); init_destroyatom(exec, init->tli_AtomProgName, "sys.progname"); init_destroyatom(exec, init->tli_AtomArgs, "sys.arguments"); init_destroyatom(exec, init->tli_AtomArgV, "sys.argv"); init_destroyatom(exec, init->tli_AtomInitMods, "sys.imods"); /* deinitializations in basetask: */ TExecDoExec(init->tli_ExecBase, TEXEC_CMD_EXIT, TNULL); TExecSignal(init->tli_ExecBase, init->tli_ExecTask, TTASK_SIG_ABORT); TExecSignal(init->tli_ExecBase, init->tli_IOTask, TTASK_SIG_ABORT); TDESTROY(init->tli_ExecTask); TDESTROY(init->tli_IOTask); TCALLHOOKPKT(&init->tli_OrgAppTaskHook, apptask, TNULL); init_closeexecmodule(init); init_closehalmodule(init); TEKlib_FreeVec(boot, init->tli_ProgDir); TEKlib_FreeVec(boot, init->tli_SysDir); TEKlib_FreeVec(boot, init->tli_ModDir); TEKlib_Free(boot, init, sizeof(struct TEKlibInit)); TEKlib_Exit(boot); }
LOCAL TUINT exec_sendmsg(TEXECBASE *TExecBase, struct TTask *task, struct TMsgPort *port, TAPTR mem) { TAPTR hal = TExecBase->texb_HALBase; struct TMessage *msg = TGETMSGPTR(mem); TAPTR reply; /* replyport is task's syncport */ msg->tmsg_RPort = &task->tsk_SyncPort; /* sender is local address space */ msg->tmsg_Sender = TNULL; THALLock(hal, &port->tmp_Lock); TAddTail(&port->tmp_MsgList, (struct TNode *) msg); msg->tmsg_Flags = TMSG_STATUS_SENT | TMSGF_QUEUED; if (port->tmp_Hook) TCALLHOOKPKT(port->tmp_Hook, port, (TTAG) msg); THALUnlock(hal, &port->tmp_Lock); THALSignal(hal, &port->tmp_SigTask->tsk_Thread, port->tmp_Signal); for (;;) { THALWait(TExecBase->texb_HALBase, task->tsk_SyncPort.tmp_Signal); reply = TGetMsg(msg->tmsg_RPort); if (reply) { TUINT status = msg->tmsg_Flags; TDBASSERT(99, reply == mem); msg->tmsg_Flags = 0; return status; } TDBPRINTF(TDB_FAIL,("signal on syncport, no message!\n")); } }
TLIBAPI void TDestroy(struct THandle *handle) { if (handle) TCALLHOOKPKT(&handle->thn_Hook, handle, TMSG_DESTROY); }