static void notify_no_command (void) { union string_or_func p; svalue_t *v; if (!command_giver || !command_giver->interactive) return; p = command_giver->interactive->default_err_message; if (command_giver->interactive->iflags & NOTIFY_FAIL_FUNC) { save_command_giver(command_giver); v = call_function_pointer(p.f, 0); restore_command_giver(); free_funp(p.f); if (command_giver && command_giver->interactive) { if (v && v->type == T_STRING) { tell_object(command_giver, v->u.string, SVALUE_STRLEN(v)); } command_giver->interactive->iflags &= ~NOTIFY_FAIL_FUNC; command_giver->interactive->default_err_message.s = 0; } } else { if (p.s) { tell_object(command_giver, p.s, strlen(p.s)); free_string(p.s); command_giver->interactive->default_err_message.s = 0; } else { tell_object(command_giver, default_fail_message, strlen(default_fail_message)); } } }
void clear_notify (object_t * ob) { union string_or_func dem; interactive_t *ip = ob->interactive; dem = ip->default_err_message; if (ip->iflags & NOTIFY_FAIL_FUNC) { free_funp(dem.f); ip->iflags &= ~NOTIFY_FAIL_FUNC; } else if (dem.s) free_string(dem.s); ip->default_err_message.s = 0; }
static void copy_close_callback (int to, int from) { char *s; if (lpc_socks[to].flags & S_CLOSE_FP) { free_funp(lpc_socks[to].close_callback.f); } else if ((s = lpc_socks[to].close_callback.s)) free_string(s); if (lpc_socks[from].flags & S_CLOSE_FP) { lpc_socks[to].flags |= S_CLOSE_FP; lpc_socks[to].close_callback.f = lpc_socks[from].close_callback.f; lpc_socks[to].close_callback.f->hdr.ref++; } else { lpc_socks[to].flags &= ~S_CLOSE_FP; s = lpc_socks[to].close_callback.s = lpc_socks[from].close_callback.s; if (s) ref_string(s); } }
void set_close_callback (int which, svalue_t * cb) { char *s; if (lpc_socks[which].flags & S_CLOSE_FP) { free_funp(lpc_socks[which].close_callback.f); lpc_socks[which].flags &= ~S_CLOSE_FP; } else if ((s = lpc_socks[which].close_callback.s)) free_string(s); if (cb) { if (cb->type == T_FUNCTION) { lpc_socks[which].flags |= S_CLOSE_FP; lpc_socks[which].close_callback.f = cb->u.fp; cb->u.fp->hdr.ref++; } else { lpc_socks[which].close_callback.s = make_shared_string(cb->u.string); } } else lpc_socks[which].close_callback.s = 0; }
void check_reqs() { while (reqs) { int val = reqs->status; if (val != BUSY) { enum atypes type = (reqs->type); reqs->type = done; switch (type) { case aread: handle_read(reqs); break; case awrite: handle_write(reqs); break; #ifdef F_ASYNC_GETDIR case agetdir: handle_getdir(reqs); break; #endif #ifdef F_ASYNC_DB_EXEC case adbexec: handle_db_exec(reqs); break; #endif case done: //must have had an error while handling it before. break; default: fatal("unknown async type\n"); } struct request *here = reqs; reqs = reqs->next; if(!reqs) lastreq = reqs; free_funp(here->fun->f.fp); free_cb(here->fun); free_req(here); } else return; } }