static File * lookup_window_logfile (int fd) { FILE * x = NULL; static struct epic_loadfile elf; static File retval = {0 , &elf, NULL}; Window * w; if (fd == -1) x = irclog_fp; else if ((w = get_window_by_refnum(fd))) x = w->log_fp; else return NULL; retval.elf->fp = x; /* XXX Should be a file */ retval.next = NULL; return &retval; }
static void p_channel(char *from, char **ArgList) { char *channel; char *user, *host; struct channel *chan = NULL; struct whowas_list *whowas = NULL; int its_me = 0; if (!strcmp(ArgList[0], "0")) { fake(); return; } channel = ArgList[0]; message_from(channel, LOG_CRAP); malloc_strcpy(&joined_nick, from); if (!my_stricmp(from, get_server_nickname(from_server))) { int refnum; Window *old_window = curr_scr_win; int switched = 0; if (!in_join_list(channel, from_server)) add_to_join_list(channel, from_server, curr_scr_win->refnum); else { if (curr_scr_win->refnum != (refnum = get_win_from_join_list(channel, from_server))) { switched = 1; set_current_window(get_window_by_refnum(refnum)); } } if (*channel != '+') send_to_server(SERVER(from_server), "MODE %s\r\nMODE %s b", channel, channel, channel); (void) do_hook(JOIN_ME_LIST, "%s", channel); its_me = 1; chan = add_channel(channel, from_server); if (*channel == '+') { got_info(channel, from_server, GOTBANS); got_info(channel, from_server, GOTMODE); } if (switched) set_current_window(old_window); } else { int op = 0, vo = 0; char *c; /* * Workaround for gratuitous protocol change in ef2.9 */ if ((c = strchr(channel, '\007'))) { for (*c++ = 0; *c; c++) { if (*c == 'o') op = 1; else if (*c == 'v') vo = 1; } } chan = add_to_channel(channel, from, from_server, op, vo, FromUserHost, NULL, NULL); } flush_mode_all(chan); user = m_strdup(FromUserHost); host = strchr(user, '@'); *host++ = '\0'; if (check_ignore(from, FromUserHost, channel, IGNORE_JOINS | IGNORE_CRAP, NULL) != IGNORED && chan) { irc_server *irc_serv = NULL; char *tmp2 = NULL; if (get_int_var(AUTO_NSLOOKUP_VAR) && isdigit(*(host + strlen(host) - 1))) tmp2 = do_nslookup(host); message_from(channel, LOG_CRAP); if ((whowas = check_whosplitin_buffer(from, FromUserHost, channel, 0)) && (irc_serv = check_split_server(whowas->server1))) { if (do_hook(LLOOK_JOIN_LIST, "%s %s", irc_serv->name, irc_serv->link)) put_it("%s", convert_output_format(get_format(FORMAT_NETJOIN_FSET), "%s %s %s %d", update_clock(GET_TIME), irc_serv->name, irc_serv->link, 0)); remove_split_server(whowas->server1); } if (do_hook(JOIN_LIST, "%s %s %s", from, channel, tmp2 ? tmp2 : FromUserHost ? FromUserHost : "UnKnown")) { put_it("%s", convert_output_format(get_format(FORMAT_JOIN_FSET), "%s %s %s %s", update_clock(GET_TIME), from, tmp2 ? tmp2 : FromUserHost ? FromUserHost : "UnKnown", channel)); } message_from(NULL, LOG_CRAP); } set_input_prompt(curr_scr_win, get_string_var(INPUT_PROMPT_VAR), 0); update_all_status(curr_scr_win, NULL, 0); notify_mark(from, user, host, 1); new_free(&user); }
/* * ExecuteTimers: checks to see if any currently pending timers have * gone off, and if so, execute them, delete them, etc, setting the * current_exec_timer, so that we can't remove the timer while its * still executing. * * changed the behavior: timers will not hook while we are waiting. */ void ExecuteTimers (void) { Timeval right_now; Timer * current, *next; int old_from_server = from_server; get_time(&right_now); while (PendingTimers && time_diff(right_now, PendingTimers->time) < 0) { int old_refnum; old_refnum = current_window->refnum; current = PendingTimers; unlink_timer(current); /* Reschedule the timer if necessary */ if (current->events < 0 || (current->events != 1)) { next = clone_timer(current); if (next->events != -1) next->events--; next->time = time_add(next->time, next->interval); schedule_timer(next); } if (current->domain == SERVER_TIMER) { if (!is_server_valid(current->domref)) { if (current->cancelable) goto advance; /* Otherwise, pretend you were a "GENERAL" type */ } else { from_server = current->domref; make_window_current_by_refnum( get_winref_by_servref(from_server)); } } else if (current->domain == WINDOW_TIMER) { if (!get_window_by_refnum(current->domref)) { if (current->cancelable) goto advance; /* Otherwise, pretend you were a "GENERAL" type */ } else { make_window_current_by_refnum(current->domref); from_server = current_window->server; } } else { /* General timers focus on the current window. */ if (current_window) { if (current_window->server != from_server) from_server = current_window->server; } else { if (from_server != NOSERV) make_window_current_by_refnum( get_winref_by_servref(from_server)); } } /* * If a callback function was registered, then * we use it. If no callback function was registered, * then we call the lambda function. */ get_time(&right_now); now = right_now; if (current->callback) (*current->callback)(current->callback_data); else call_lambda_command("TIMER", current->command, current->subargs); from_server = old_from_server; make_window_current_by_refnum(old_refnum); advance: delete_timer(current); } }