char *get_help_topic(char *args, int helpfunc) { char *new_comm = NULL; int found = 0, i; char *others = NULL; new_comm = LOCAL_COPY(args); for (i = 0; helpfunc ? script_help[i] : help_index[i]; i++) { if (!my_strnicmp(helpfunc?script_help[i]->title:help_index[i]->title, new_comm, strlen(new_comm))) { int j; char *text = NULL; if (found++) { m_s3cat(&others, " , ", helpfunc?script_help[i]->title:help_index[i]->title); continue; } if (args && *args && do_hook(HELPTOPIC_LIST, "%s", args)) put_it("%s",convert_output_format("$G \002$0\002: Help on Topic: \002$1\002", version, args)); for (j = 0; ; j++) { if (helpfunc && (script_help[i] && script_help[i]->contents[j])) text = script_help[i]->contents[j]; else if (!helpfunc && (help_index[i] && help_index[i]->contents[j])) text = help_index[i]->contents[j]; else break; if (text && do_hook(HELPSUBJECT_LIST, "%s %s", new_comm, text)) { in_chelp++; put_it("%s", convert_output_format(text, NULL)); in_chelp--; } } text = helpfunc ?script_help[i]->relates:help_index[i]->relates; if (text && do_hook(HELPTOPIC_LIST, "%s", text)) put_it("%s", convert_output_format(text, NULL)); } else if (found) break; } if (!found) { if (do_hook(HELPTOPIC_LIST, "%s", args)) bitchsay("No help on %s", args); } if (others && found) { if (do_hook(HELPTOPIC_LIST, "%d %s", found, others)) put_it("Other %d subjects: %s", found - 1, others); } new_free(&others); if (helpfunc) return m_strdup(empty_string); return NULL; }
int show_wholeft_hashtable(WhowasWrapList *cptr, time_t ltime, int *total, int *hook, char *list) { int count, count2; WhowasList *ptr; for (count = 0; count < WHOWASLIST_HASHSIZE; count++) { if (cptr->NickListTable[count].links == 0) continue; for (ptr = (WhowasList *) cptr->NickListTable[count].list, count2 = 1; ptr; count2++, ptr = ptr->next) { if (ptr->server1/* && ptr->server2*/) { if (!(*total)++ && (*hook = do_hook(WHOLEFT_HEADER_LIST, "%s %s %s %s %s %s", "Nick", "Host", "Channel", "Time", "Server", "Server"))) put_it("%s", convert_output_format(fget_string_var(FORMAT_WHOLEFT_HEADER_FSET), NULL)); if (do_hook(WHOLEFT_LIST, "%s %s %s %ld %s %s", ptr->nicklist->nick, ptr->nicklist->host, ptr->channel, ltime-ptr->time, ptr->server1?ptr->server1:"Unknown", ptr->server2?ptr->server2:"Unknown")) put_it("%s", convert_output_format(fget_string_var(FORMAT_WHOLEFT_USER_FSET), "%s %s %s %l %s", ptr->nicklist->nick, ptr->nicklist->host, ptr->channel, (long)ltime-ptr->time, ptr->server1?ptr->server1:empty_string)); } } } if (*total) do_hook(WHOLEFT_FOOTER_LIST, "%s", "End of WhoLeft"); return *hook; }
/* in response to a TOPIC message from the server */ static void p_topic(char *from, char **ArgList) { struct channel *tmp; if (!ArgList[1]) { fake(); return; } tmp = lookup_channel(ArgList[0], from_server, CHAN_NOUNLINK); malloc_strcpy(&tmp->topic, ArgList[1]); if (check_ignore(from, FromUserHost, tmp->channel, IGNORE_TOPICS | IGNORE_CRAP, NULL) != IGNORED) { message_from(ArgList[0], LOG_CRAP); if (do_hook(TOPIC_LIST, "%s %s %s", from, ArgList[0], ArgList[1])) { if (ArgList[1] && *ArgList[1]) { if (get_format(FORMAT_TOPIC_CHANGE_HEADER_FSET)) put_it("%s", convert_output_format(get_format(FORMAT_TOPIC_CHANGE_HEADER_FSET), "%s %s %s %s", update_clock(GET_TIME), from, ArgList[0], ArgList[1])); put_it("%s", convert_output_format(get_format(FORMAT_TOPIC_CHANGE_FSET), "%s %s %s %s", update_clock(GET_TIME), from, ArgList[0], ArgList[1])); } else put_it("%s", convert_output_format(get_format(FORMAT_TOPIC_UNSET_FSET), "%s %s %s", update_clock(GET_TIME), from, ArgList[0])); } message_from(NULL, LOG_CRAP); } update_all_status(curr_scr_win, NULL, 0); }
void funny_mode(char *from, char **ArgList) { char *mode, *channel; ChannelList *chan = NULL; if (!ArgList[0]) return; channel = ArgList[0]; mode = ArgList[1]; PasteArgs(ArgList, 1); if((channel && in_join_list(channel, from_server)) || get_chan_from_join_list(from_server)) { if (!channel) channel = get_chan_from_join_list(from_server); update_channel_mode(from, channel, from_server, mode, chan); update_all_status(current_window, NULL, 0); got_info(channel, from_server, GOTMODE); } else { if (channel) { set_display_target(channel, LOG_CRAP); if (do_hook(current_numeric, "%s %s %s", from, channel, mode)) put_it("%s", convert_output_format(fget_string_var(FORMAT_MODE_CHANNEL_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, *FromUserHost ? FromUserHost:"ÿ", channel, mode)); reset_display_target(); } else { if (do_hook(current_numeric, "%s %s", from, mode)) put_it("%s", convert_output_format(fget_string_var(FORMAT_MODE_CHANNEL_FSET), "%s %s %s %s", update_clock(GET_TIME), from, *FromUserHost ? FromUserHost:"ÿ", mode)); } } }
static void parse_server_notice(char *from, char *line) { int flag = 0; int up_status = 0; const char *f; f = from; if (!f || !*f) if (!(f = get_server_itsname(from_server))) f = get_server_name(from_server); if (*line != '*' && *line != '#' && strncmp(line, "MOTD ", 4)) flag = 1; else flag = 0; if (do_hook(SERVER_NOTICE_LIST, flag?"%s *** %s":"%s %s", f, line)) { #ifdef WANT_OPERVIEW if (handle_oper_vision(f, line, &up_status)) reset_display_target(); else #endif if (strstr(line, "***")) { set_display_target(NULL, LOG_SNOTE); #ifdef WANT_OPERVIEW if (get_int_var(OV_VAR) && !(get_server_ircop_flags(from_server) & SERVER_CRAP)) goto done1; #endif if (do_hook(SERVER_NOTICE_LIST, flag ? "%s *** %s" : "%s %s", f, line)) { char *for_; for_ = next_arg(line,&line); serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_FSET), "%s %s %s", update_clock(GET_TIME), f, stripansicodes(line))); add_last_type(&last_servermsg[0], MAX_LAST_MSG, NULL, NULL, NULL, line); } } else { set_display_target(NULL, LOG_SNOTE); #ifdef WANT_OPERVIEW if (get_int_var(OV_VAR) && !(get_server_ircop_flags(from_server) & SERVER_CRAP)) goto done1; #endif if (do_hook(SERVER_NOTICE_LIST, flag ? "%s *** %s" : "%s %s", f, line)) serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_FSET), "%s %s %s", update_clock(GET_TIME), f, stripansicodes(line))); add_last_type(&last_servermsg[0], MAX_LAST_MSG, NULL, NULL, NULL, line); } } if (up_status) update_all_status(current_window, NULL, 0); done1: reset_display_target(); }
/* list interface info */ static void iface_callback(void *data, struct iflist *list) { if (list == NULL && errno == 0) { put_it("%s", convert_output_format("%G Unable to find anything!", NULL, NULL)); } else if (list == NULL) { yell("Error fetching interface info: %s", strerror(errno)); } else { int i; say("Current hostnames available:"); for (i = 1; list; list = list->ifi_next, i++) { put_it("%s", convert_output_format("%K[%W$[3]0%K] %B$1 %g[%c$2%g]", "%d %s %s", i, list->ifi_host, list->ifi_name)); } } }
static void set_fset_var_value(int var_index, char *name, char *value) { IrcVariable *var = NULL; if (name) var = find_ext_fset_var(name); if (!var) var = &(fset_array[var_index]); switch (var->type) { case STR_TYPE_VAR: { if (value) { if (*value) malloc_strcpy(&(var->string), value); else { put_it("%s", convert_output_format(fget_string_var(FORMAT_SET_FSET), "%s %s", var->name, var->string?var->string:empty_string)); return; } } else new_free(&(var->string)); if (var->func) (var->func) (current_window, var->string, 0); say("Value of %s set to %s", var->name, var->string ? var->string : "<EMPTY>"); } break; default: say("FSET_type not supported"); } }
int Encrypt_Init(IrcCommandDll **intp, Function_ptr *global_table) { int i, j; char buffer[BIG_BUFFER_SIZE+1]; initialize_module("encrypt"); add_module_proc(ALIAS_PROC, "encrypt", "MENCODE", NULL, 0, 0, func_encode, NULL); add_module_proc(ALIAS_PROC, "encrypt", "MDECODE", NULL, 0, 0, func_decode, NULL); encode_string = (char *)new_malloc(512); for (i = 1, j = 255; i <= 255; i++, j--) { switch (i) { case 27: case 127: case 255: encode_string[i-1] = i; break; default: encode_string[i-1] = j; break; } } sprintf(buffer, "$0+%s by panasync - $2 $3", encode_version); fset_string_var(FORMAT_VERSION_FSET, buffer); put_it("%s", convert_output_format("$G $0 v$1 by panasync. Based on suicide's Abot script.", "%s %s", encode_version, ENCODE_VERSION)); return 0; }
static void p_part(char *from, char **ArgList) { char *channel; if (!from || !*from) return; channel = ArgList[0]; PasteArgs(ArgList, 1); message_from(channel, LOG_CRAP); in_on_who = 1; if ((check_ignore(from, FromUserHost, channel, IGNORE_PARTS | IGNORE_CRAP, NULL) != IGNORED) && do_hook(LEAVE_LIST, "%s %s %s %s", from, channel, FromUserHost, ArgList[1] ? ArgList[1] : empty_str)) put_it("%s", convert_output_format(get_format(FORMAT_LEAVE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost, channel, ArgList[1] ? ArgList[1] : empty_str)); if (!my_stricmp(from, get_server_nickname(from_server))) { remove_channel(channel, from_server); remove_from_mode_list(channel, from_server); remove_from_join_list(channel, from_server); set_input_prompt(curr_scr_win, get_string_var(INPUT_PROMPT_VAR), 0); } else { remove_from_channel(channel, from, from_server, 0, NULL); } update_all_status(curr_scr_win, NULL, 0); update_input(UPDATE_ALL); message_from(NULL, LOG_CRAP); in_on_who = 0; }
void serversay(int save, int from_server, const char *format, ...) { Window *old_target_window = target_window; char servername[200]; int len = 0; char *out = NULL; if (get_int_var(OV_VAR)) target_window = get_window_by_name("OPER_VIEW"); if (window_display && format) { va_list args; va_start (args, format); vsnprintf(putbuf, LARGE_BIG_BUFFER_SIZE, format, args); va_end(args); strmcpy(servername, convert_output_format(get_string_var(SERVER_PROMPT_VAR), "%s", ov_server(from_server)?ov_server(from_server):empty_string), 79); len = strlen(putbuf); out = alloca(strlen(servername)+len+5); len = strlen(servername); strcpy(out, servername); out[len] = ' '; out[len+1] = 0; strcat(out, putbuf); if (*out) put_echo(out); } target_window = old_target_window; if (save && out) add_last_type(&last_servermsg[0], MAX_LAST_MSG, NULL, NULL, NULL, out); }
static void set_wset_var_value(Window *win, int var_index, char *value) { WSetArray *var; var = &(wset_array[var_index]); switch (var->type) { case STR_TYPE_VAR: { char **val = NULL; if ((val = get_wset_str_var_address(win->wset, var_index))) { if (value) { if (*value) malloc_strcpy(val, value); else { put_it("%s", convert_output_format(fget_string_var(FORMAT_SET_FSET), "%s %s", var->name, *val?*val:empty_string)); return; } } else new_free(val); if (var->func) (var->func) (win, *val, 0); say("Value of %s set to %s", var->name, *val ? *val : "<EMPTY>"); } } break; default: say("WSET_type not supported"); } }
void funny_print_widelist(void) { int i; char buffer1[BIG_BUFFER_SIZE]; char buffer2[BIG_BUFFER_SIZE]; char *ptr; if (!wide_list) return; if (funny_flags & FUNNY_NAME) qsort((void *) wide_list, wl_elements, sizeof(WideList *), (int (*) (const void *, const void *)) funny_widelist_names); else if (funny_flags & FUNNY_USERS) qsort((void *) wide_list, wl_elements, sizeof(WideList *), (int (*) (const void *, const void *)) funny_widelist_users); set_display_target(NULL, LOG_CRAP); *buffer1 = '\0'; for (i = 1; i < wl_elements; i++) { sprintf(buffer2, "%s(%d) ", wide_list[i]->channel, wide_list[i]->users); ptr = strchr(buffer1, '\0'); if (strlen(buffer1) + strlen(buffer2) > current_term->TI_cols - 5) { if (do_hook(WIDELIST_LIST, "%s", buffer1)) put_it("%s", convert_output_format(fget_string_var(FORMAT_WIDELIST_FSET), "%s %s", update_clock(GET_TIME), buffer1)); *buffer1 = 0; strcat(buffer1, buffer2); } else strcpy(ptr, buffer2); } if (*buffer1 && do_hook(WIDELIST_LIST, "%s", buffer1)) put_it("%s", convert_output_format(fget_string_var(FORMAT_WIDELIST_FSET), "%s %s", update_clock(GET_TIME), buffer1)); reset_display_target(); for (i = 0; i < wl_elements; i++) { new_free(&wide_list[i]->channel); new_free((char **)&wide_list[i]); } new_free((char **)&wide_list); wl_elements = wl_size = 0; }
static void p_silence(char *from, char **ArgList) { char *target = ArgList[0]; char *mag = target++; if (do_hook(SILENCE_LIST, "%c %s", *mag, target)) put_it("%s", convert_output_format(get_format(FORMAT_SILENCE_FSET), "%s %c %s", update_clock(GET_TIME), *mag, target)); }
void print_ircop_flags(int server) { long flag; char *buffer = NULL; flag = get_server_ircop_flags(server); buffer = ircop_flags_to_str(flag); put_it("%s", convert_output_format("$G %bOper%BView%n: $0-", "%s", *buffer ? flag == -1 ? "ALL" : buffer : "NONE")); new_free(&buffer); }
void get_help_topic(const char *args, int helpfunc) { int found = 0, i; char *others = NULL; struct chelp_index *index = helpfunc ? &script_help : &bitchx_help; size_t arglen = strlen(args); for (i = 0; i < index->size; i++) { if (!my_strnicmp(index->entries[i].title, args, arglen)) { int j; char *text = NULL; if (found++) { m_s3cat(&others, " , ", index->entries[i].title); continue; } if (do_hook(HELPTOPIC_LIST, "%s", index->entries[i].title)) put_it("%s", convert_output_format("$G \002$0\002: Help on Topic: \002$1-\002", "%s %s", version, index->entries[i].title)); for (j = 0; (text = index->entries[i].contents[j]) != NULL; j++) { if (do_hook(HELPSUBJECT_LIST, "%s , %s", index->entries[i].title, text)) { in_chelp++; put_it("%s", convert_output_format(text, NULL)); in_chelp--; } } text = index->entries[i].relates; if (text && do_hook(HELPTOPIC_LIST, "%s", text)) put_it("%s", convert_output_format(text, NULL)); } else if (found) break; } if (!found) { if (do_hook(HELPTOPIC_LIST, "%s", args)) bitchsay("No help on %s", args); } if (others && found) { if (do_hook(HELPTOPIC_LIST, "%d %s", found, others)) put_it("Other %d subjects: %s", found - 1, others); } new_free(&others); }
static inline void fset_variable_noargs(char *name) { int var_index = 0; FsetNumber *tmp; for (var_index = 0; var_index < NUMBER_OF_FSET; var_index++) set_fset_var_value(var_index, NULL, empty_string); for (var_index = 0; var_index < ext_fset_list.max; var_index++) set_fset_var_value(var_index, (*ext_fset_list.list[var_index]).name, empty_string); for (tmp = numeric_fset; tmp; tmp = tmp->next) put_it("%s", convert_output_format(fget_string_var(FORMAT_SET_FSET), "%d %s", tmp->numeric, tmp->format)); }
static inline void fset_variable_casedef(char *name, int cnt, int var_index, char *args) { FsetNumber *tmp; for (cnt += var_index; var_index < cnt; var_index++) set_fset_var_value(var_index, NULL, args); if (!is_number(name)) return; for (tmp = numeric_fset; tmp; tmp = tmp->next) if (my_atol(name) == tmp->numeric) put_it("%s", convert_output_format(fget_string_var(FORMAT_SET_FSET), "%d %s", tmp->numeric, tmp->format)); }
static void set_cset_var_value(CSetList *tmp, int var_index, char *value) { char *rest; CSetArray *var; var = &(cset_array[var_index]); switch (var->type) { case BOOL_TYPE_VAR: if (value && *value && (value = next_arg(value, &rest))) { if (do_boolean(value, (int *)get_cset_int_var_address(tmp, var_index))) { say("Value must be either ON, OFF, or TOGGLE"); break; } if (var->func) var->func(var, tmp); put_it("%s", convert_output_format(fget_string_var(FORMAT_CSET_FSET), "%s %s %s", var->name, tmp->channel, get_cset_int_var(tmp, var_index)?var_settings[ON] : var_settings[OFF])); } else put_it("%s", convert_output_format(fget_string_var(FORMAT_CSET_FSET), "%s %s %s", var->name, tmp->channel, get_cset_int_var(tmp, var_index)?var_settings[ON] : var_settings[OFF])); break; case INT_TYPE_VAR: if (value && *value && (value = next_arg(value, &rest))) { int val; if (!is_number(value)) { say("Value of %s must be numeric!", var->name); break; } if ((val = atoi(value)) < 0) { say("Value of %s must be greater than 0", var->name); break; } set_cset_int_var(tmp, var_index, val); if (var->func) var->func(var, tmp); put_it("%s", convert_output_format(fget_string_var(FORMAT_CSET_FSET), "%s %s %d", var->name, tmp->channel, get_cset_int_var(tmp, var_index))); } else put_it("%s", convert_output_format(fget_string_var(FORMAT_CSET_FSET), "%s %s %d", var->name, tmp->channel, get_cset_int_var(tmp, var_index))); break; case STR_TYPE_VAR: if (value && *value) { set_cset_str_var(tmp, var_index, value); if (var->func) var->func(var, tmp); put_it("%s", convert_output_format(fget_string_var(FORMAT_CSET_FSET), "%s %s %s", var->name, tmp->channel, get_cset_str_var(tmp, var_index) )); } else put_it("%s", convert_output_format(fget_string_var(FORMAT_CSET_FSET), "%s %s %s", var->name, tmp->channel, (char *)get_cset_str_var(tmp, var_index))); } }
void print_funny_names(char *line) { register char *t; int count = 0; char buffer[BIG_BUFFER_SIZE+1]; char special = '\0'; int cols = get_int_var(NAMES_COLUMNS_VAR); if (!cols) cols = 1; if (line && *line) { *buffer = 0; t = next_arg(line, &line); do { if (!count && fget_string_var(FORMAT_NAMES_BANNER_FSET)) strcpy(buffer, convert_output_format(fget_string_var(FORMAT_NAMES_BANNER_FSET), NULL, NULL)); if (*t == '@' || *t == '+' || *t == '~' || *t == '-') { special = *t; if (special == '+') strcat(buffer, convert_output_format(fget_string_var(FORMAT_NAMES_VOICECOLOR_FSET),"%c %s", special, ++t)); else strcat(buffer, convert_output_format(fget_string_var(FORMAT_NAMES_OPCOLOR_FSET),"%c %s", special, ++t)); } else strcat(buffer, convert_output_format(fget_string_var(FORMAT_NAMES_NICKCOLOR_FSET), "$ %s", t)); strcat(buffer, space); if (count++ >= (cols - 1)) { put_it("%s", buffer); *buffer = 0; count = 0; } } while ((t = next_arg(line, &line))); if (buffer) put_it("%s", buffer); } }
/* * set_input_prompt: sets a prompt that will be displayed in the input * buffer. This prompt cannot be backspaced over, etc. It's a prompt. * Setting the prompt to null uses no prompt */ void set_input_prompt(Window * win, char *prompt, int unused) { if (prompt) { if (input_prompt && !strcmp(prompt, input_prompt)) return; malloc_strcpy(&input_prompt, convert_output_format(prompt, NULL, NULL)); } else { if (!input_prompt) return; malloc_strcpy(&input_prompt, empty_str); } update_input(UPDATE_ALL); }
void input_msgreply(char dumb, char *dumber) { char *cmdchar; char *line, *cmd, *t; char *snick; NickTab *nick = NULL; int got_space = 0; if (!(cmdchar = get_string_var(CMDCHARS_VAR))) cmdchar = DEFAULT_CMDCHARS; t = line = m_strdup(get_input()); if (t) got_space = strchr(t, ' ') ? 1 : 0; cmd = next_arg(line, &line); snick = next_arg(line, &line); if ((cmd && *cmd == *cmdchar && got_space) || !cmd) { if (cmd && *cmd == *cmdchar) cmd++; if (in_completion == STATE_NORMAL && snick) strncpy(new_nick, snick, sizeof(new_nick) - 1); if ((nick = getnextnick(new_nick, input_lastmsg, snick))) { if (nick->nick && *(nick->nick)) { snick = nick->nick; malloc_strcpy(&input_lastmsg, nick->nick); } } if (nick) { char *tmp = NULL; input_clear_line('\0', NULL); if (get_fset_var(FORMAT_NICK_MSG_FSET)) malloc_strcpy(&tmp, stripansicodes(convert_output_format (get_fset_var(FORMAT_NICK_MSG_FSET), "%s%s %s %s", cmdchar, nick->type ? nick->type : cmd ? cmd : "msg", nick->nick, line ? line : empty_str))); else malloc_sprintf(&tmp, "%s%s %s %s", cmdchar, nick->type ? nick->type : cmd ? cmd : "msg", nick->nick, line ? line : empty_str); set_input(tmp); new_free(&tmp); } else command_completion(0, NULL); } else command_completion(0, NULL); update_input(UPDATE_ALL); new_free(&t); }
int Identd_Init(IrcCommandDll **intp, Function_ptr *global_table) { #if !defined(__EMX__) && !defined(WINNT) if (getuid() && geteuid()) { return -1; } #endif initialize_module("Identd"); add_module_proc(VAR_PROC, MODULENAME, "identd", NULL, BOOL_TYPE_VAR, 0, NULL, NULL); add_module_proc(VAR_PROC, MODULENAME, "identd_user", NULL, STR_TYPE_VAR, 0, NULL, NULL); put_it("%s", convert_output_format("$G $0 v$1 by panasync", "%s %s", MODULENAME, "0.01")); return start_identd(); }
void show_whowas_hashtable(WhowasWrapList *cptr, char *list) { int count, count2 = 1; WhowasList *ptr; say("WhoWas %s Cache Stats: %lu hits %lu links %lu unlinks", list, cptr->total_hits, cptr->total_links, cptr->total_unlinks); for (count = 0; count < WHOWASLIST_HASHSIZE; count++) { if (cptr->NickListTable[count].links == 0) continue; for (ptr = (WhowasList *) cptr->NickListTable[count].list; ptr; count2++, ptr = ptr->next) put_it("%s", convert_output_format("%K[%W$[3]0%K] %Y$[10]1 %W$2%G!%c$3", "%d %s %s %s", count2, ptr->channel, ptr->nicklist->nick, ptr->nicklist->host)); } }
void add_autonick_input(char *nick, char *line) { char *tmp1 = NULL; input_clear_line('\0', NULL); if ((do_hook(AR_REPLY_LIST, "%s", nick))) { if (get_fset_var(FORMAT_NICK_AUTO_FSET)) malloc_strcpy(&tmp1, stripansicodes(convert_output_format (get_fset_var(FORMAT_NICK_AUTO_FSET), "%s %s", nick, line ? line : empty_str))); else malloc_sprintf(&tmp1, "%s: %s", nick, line); set_input(tmp1); new_free(&tmp1); } update_input(UPDATE_ALL); }
static void p_quit(char *from, char **ArgList) { int one_prints = 0; char *chan = NULL; char *Reason; int netsplit = 0; int ignore; PasteArgs(ArgList, 0); if (ArgList[0]) { Reason = ArgList[0]; netsplit = check_split(from, Reason, chan); } else Reason = "?"; ignore = check_ignore(from, FromUserHost, NULL, (netsplit ? IGNORE_SPLITS : IGNORE_QUITS) | IGNORE_ALL, NULL); for (chan = walk_channels(from, 1, from_server); chan; chan = walk_channels(from, 0, -1)) { if (ignore != IGNORED) { message_from(chan, LOG_CRAP); if (do_hook(CHANNEL_SIGNOFF_LIST, "%s %s %s", chan, from, Reason)) one_prints = 1; message_from(NULL, LOG_CURRENT); } } if (one_prints) { chan = what_channel(from, from_server); ignore = check_ignore(from, FromUserHost, chan, (netsplit ? IGNORE_SPLITS : IGNORE_QUITS) | IGNORE_ALL, NULL); message_from(chan, LOG_CRAP); if ((ignore != IGNORED) && do_hook(SIGNOFF_LIST, "%s %s", from, Reason) && !netsplit) put_it("%s", convert_output_format(get_format(FORMAT_CHANNEL_SIGNOFF_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost, chan, Reason)); message_from(NULL, LOG_CURRENT); } if (!netsplit) check_orig_nick(from); notify_mark(from, NULL, NULL, 0); remove_from_channel(NULL, from, from_server, netsplit, Reason); message_from(NULL, LOG_CRAP); update_all_status(curr_scr_win, NULL, 0); }
static void p_nick(char *from, char **ArgList) { int one_prints = 0, ign = 0, its_me = 0; struct channel *chan; char *line; line = ArgList[0]; if (!my_stricmp(from, get_server_nickname(from_server))) { accept_server_nickname(from_server, line); its_me = 1; user_changing_nickname = 0; } ign = check_ignore(from, FromUserHost, NULL, IGNORE_NICKS | IGNORE_CRAP, NULL); for (chan = server_list[from_server].chan_list; chan; chan = chan->next) { message_from(chan->channel, LOG_CRAP); if (ign != IGNORED && do_hook(CHANNEL_NICK_LIST, "%s %s %s", chan->channel, from, line)) one_prints = 1; } if (one_prints) { if (its_me) { message_from(NULL, LOG_CRAP); } else message_from(what_channel(from, from_server), LOG_CRAP); if (ign != IGNORED && do_hook(NICKNAME_LIST, "%s %s", from, line)) put_it("%s", convert_output_format(get_format (its_me ? FORMAT_NICKNAME_USER_FSET : im_on_channel(what_channel(from, from_server)) ? FORMAT_NICKNAME_FSET : FORMAT_NICKNAME_OTHER_FSET), "%s %s %s %s", update_clock(GET_TIME), from, "-", line)); } rename_nick(from, line, from_server); if (!its_me) { char *user, *host; user = m_strdup(FromUserHost); host = strchr(user, '@'); *host++ = '\0'; notify_mark(from, user, host, 0); notify_mark(line, user, host, 1); new_free(&user); } }
static void p_kill(char *from, char **ArgList) { char sc[20]; int port; int local = 0; port = get_server_port(from_server); if (ArgList[1] && strstr(ArgList[1], get_server_name(from_server))) if (!strchr(from, '.')) local = 1; snprintf(sc, 19, "+%i %d", from_server, port); close_server(from_server, empty_str); clean_whois_queue(); window_check_servers(); set_input_prompt(curr_scr_win, get_string_var(INPUT_PROMPT_VAR), 0); if (strchr(from, '.')) { say("Server [%s] has rejected you (probably due to a nick collision)", from); t_parse_command("SERVER", NULL); } else { if (local && get_int_var(NEXT_SERVER_ON_LOCAL_KILL_VAR)) { int i = from_server + 1; if (i >= number_of_servers) i = 0; snprintf(sc, 19, "+%i", i); from_server = -1; } if (do_hook(DISCONNECT_LIST, "Killed by %s (%s)", from, ArgList[1] ? ArgList[1] : "(No Reason Given)")) put_it("%s", convert_output_format(get_format(FORMAT_KILL_FSET), "%s %s", update_clock(GET_TIME), ArgList[1] ? ArgList[1] : "You have been Killed")); if (get_int_var(AUTO_RECONNECT_VAR)) t_parse_command("SERVER", NULL); } update_all_status(curr_scr_win, NULL, 0); }
static void p_wallops(char *from, char **ArgList) { char *line; int from_server = strchr(from, '.') ? 1 : 0; if (!(line = PasteArgs(ArgList, 0))) { fake(); return; } if (from_server || check_flooding(from, WALLOP_FLOOD, line, NULL)) { /* The old server check, don't use the whois stuff for servers */ int level; char *high; switch (check_ignore(from, FromUserHost, NULL, IGNORE_WALLOPS, NULL)) { case (IGNORED): return; case (HIGHLIGHTED): high = highlight_char; break; default: high = empty_str; break; } message_from(from, LOG_WALLOP); level = set_lastlog_msg_level(LOG_WALLOP); if (do_hook(WALLOP_LIST, "%s %c %s", from, from_server ? 'S' : '*', line)) put_it("%s", convert_output_format(get_format(from_server ? FORMAT_WALLOP_FSET : FORMAT_WALL_FSET), "%s %s %s %s", update_clock(GET_TIME), from, from_server ? "!" : "*", line)); if (beep_on_level & LOG_WALLOP) beep_em(1); set_lastlog_msg_level(level); message_from(NULL, LOG_CRAP); } }
static void p_invite(char *from, char **ArgList) { char *high; switch (check_ignore(from, FromUserHost, ArgList[1] ? ArgList[1] : NULL, IGNORE_INVITES, NULL)) { case IGNORED: if (get_int_var(SEND_IGNORE_MSG_VAR)) send_to_server(SERVER(from_server), "NOTICE %s :%s is ignoring you", from, get_server_nickname(from_server)); return; case HIGHLIGHTED: high = highlight_char; break; default: high = empty_str; break; } if (ArgList[0] && ArgList[1]) { struct channel *chan = NULL; struct whowas_chan_list *w_chan = NULL; message_from(from, LOG_CRAP); malloc_strcpy(&invite_channel, ArgList[1]); if (check_flooding(from, INVITE_FLOOD, ArgList[1], NULL) && do_hook(INVITE_LIST, "%s %s", from, ArgList[1])) { put_it("%s", convert_output_format(get_format(FORMAT_INVITE_FSET), "%s %s %s", update_clock(GET_TIME), from, ArgList[1])); } if (!(chan = lookup_channel(invite_channel, from_server, 0))) if ((w_chan = check_whowas_chan_buffer(invite_channel, 0))) chan = w_chan->channellist; if (chan && get_int_var(AUTO_REJOIN_VAR) && invite_channel) { if (!in_join_list(invite_channel, from_server)) send_to_server(SERVER(from_server), "JOIN %s %s", invite_channel, ArgList[2] ? ArgList[2] : ""); } malloc_strcpy(&recv_nick, from); } }
static int handle_oper_vision(const char *from, char *cline, int *up_status) { char *fr, *for_, *temp, *temp2; char *p; int done_one = 0; char *line; unsigned long flags; int dcount; p = fr = for_ = temp = temp2 = NULL; if (from_server == -1 || !(flags = get_server_ircop_flags(from_server))) return 0; line = LOCAL_COPY(cline); if (!strncmp(line, "*** Notice -- ", 13)) line += 14, dcount = 14; else if (!strncmp(line, "*** \002Notice\002 --", 15)) line += 16, dcount = 16; done_one++; /* [ss]!irc.cs.cmu.edu D-line active for think[[email protected]] */ set_display_target(NULL, LOG_SNOTE); if (!strncmp(line, "Received KILL message for ", 26)) { char *q = line + 26; int loc_check = 0; for_ = next_arg(q, &q); if (!end_strcmp(for_, ".", 1)) chop(for_, 1); q += 5; fr = next_arg(q, &q); q += 6; check_orig_nick(for_); if (strchr(fr, '.')) { nick_collisions++; if (!(flags & NICK_COLLIDE)) goto done; serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_NICK_COLLISION_FSET), "%s %s %s %s", update_clock(GET_TIME), fr, for_, q)); } else { oper_kills++; if (!(flags & NICK_KILL)) goto done; if ((temp2 = next_arg(q, &q))) loc_check = charcount(temp2, '!'); if (q && *q) q++; chop(q, 1); if (loc_check <= 2) serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_KILL_LOCAL_FSET), "%s %s %s %s", update_clock(GET_TIME), fr, for_, q)); else serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_KILL_FSET), "%s %s %s %s", update_clock(GET_TIME), fr, for_, q)); } (*up_status)++; } else if (!strncmp(line, "Nick collision on", 17) || !strncmp(line, "Nick change collision on", 24)) { #if 0 irc.BitchX.com *** Notice -- Nick collision on nickserv(irc.distracted.net <- irc.distracted.net[[email protected]])(both killed) [BitchX] Nick collision llision killed on #endif nick_collisions++; if (!(flags & NICK_COLLIDE)) goto done; if (!strncmp(line+5, "change", 6)) p = line + 24; else p = line + 18; serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_NICK_COLLISION_FSET), "%s %s", update_clock(GET_TIME), p)); (*up_status)++; } else if (!strncmp(line, "IP# Mismatch:", 13)) { if (!(flags & IP_MISMATCH)) goto done; for_ = line + 14; serversay(1, from_server, "%s", convert_output_format(" IP Mismatch %C$1-", "%s %s", update_clock(GET_TIME), for_)); } else if (!strncmp(line, "Hacked ops on opless channel:", 29)) { if (!(flags & HACK_OPS)) goto done; for_ = line + 29; serversay(1, from_server, "%s", convert_output_format(" Hacked ops on $0", "%s", for_)); } else if (!strncmp(line, "connect failure:", 16)) { client_connects++; client_exits++; if (!(flags & SERVER_CRAP)) goto done; for_ = line + 16; serversay(1, from_server, "%s", convert_output_format(" Connect failure %K[%n$0-%K]", "%s", for_)); } else if (!strncmp(line, "Identd response differs", 22)) { if (!(flags & IDENTD)) goto done; for_ = line + 24; serversay(1, from_server, "%s", convert_output_format(" Identd response differs %K[%C$1-%K]", "%s %s", update_clock(GET_TIME), for_)); } else if (!strncmp(line, "Fake: ", 6)) /* MODE */ { serv_fakes++; if (!(flags & FAKE_MODE)) goto done; p = line + 6; if ((fr = next_arg(p, &temp))) { if (lookup_channel(fr, from_server, CHAN_NOUNLINK)) serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_FAKE_FSET), "%s %s %s", update_clock(GET_TIME), fr, temp)); else serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_FAKE_FSET), "%s %s %s", update_clock(GET_TIME), fr, temp)); } } else if (!strncmp(line, "Unauthorized connection from",28)) { serv_unauth++; if (!(flags & UNAUTHS)) goto done; for_ = line + 28; serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_UNAUTH_FSET), "%s %s", update_clock(GET_TIME), for_)); } else if (!strncmp(line, "Too many connections from",25)) { serv_unauth++; if (!(flags & TOO_MANY)) goto done; for_ = line + 25; serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_UNAUTH_FSET), "%s %s", update_clock(GET_TIME), for_)); } else if (strstr(line, "Entering high-traffic mode -") || !strncmp(line, "still high-traffic mode -", 25)) { char *q; serv_split++; if (!(flags & TRAFFIC)) goto done; if (!strncmp(line, "Entering", 8)) { p = line + 28; for_ = next_arg(p, &p); q = temp2 = p; if (temp2) { chop(temp2, 1); q = temp2+2; } } else if (!strncmp(line+10, "Entering", 8)) { p = line + 38; for_ = next_arg(p, &p); q = temp2 = p; if (temp2) { chop(temp2, 1); q = temp2+2; } } else { p = line + 25; for_ = next_arg(p, &p); q = temp2 = p; if (temp2) { chop(temp2, 1); q = temp2+2; } } serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_TRAFFIC_HIGH_FSET), "%s %s %s", update_clock(GET_TIME), for_, q)); } else if (!strncmp(line, "Resuming standard operation", 27)) { serv_rejoin++; if (!(flags & TRAFFIC)) goto done; p = line + 27; for_ = next_arg(p, &p); if (for_ && *for_ == '-') for_ = next_arg(p, &p); temp = next_arg(p, &temp2); serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_TRAFFIC_NORM_FSET), "%s %s %s %s", update_clock(GET_TIME), for_, temp, temp2)); } else if (wild_match("% is rehashing Server config*", line)) { serv_rehash++; if (!(flags & REHASH)) goto done; p = line; for_ = next_arg(p, &p); serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_REHASH_FSET), "%s %s", update_clock(GET_TIME), for_)); } else if (wild_match("% added K-Line for *", line)) { char *serv = NULL; serv_klines++; if (!(flags & KLINE)) goto done; p = line; for_ = next_arg(p, &p); if (!strncmp(p, "from", 4)) { next_arg(p, &p); serv = next_arg(p, &p); } p += 17; temp2 = next_arg(p, &temp); if (++temp2) chop(temp2, 1); if (serv) serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_GLINE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), for_, temp2, serv, temp)); else serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_KLINE_FSET), "%s %s %s %s", update_clock(GET_TIME), for_, temp2, temp)); } else if (!strncmp(line, "Rejecting vlad/joh/com bot:", 27) || !strncmp(line+14, "Rejecting eggdrop bot:", 20) || !strncmp(line, "Rejecting ojnk/annoy bot", 24)) { client_bot++; if (!(flags & POSSIBLE_BOT)) goto done; p = line + 10; temp2 = next_arg(p, &p); for_ = p + 4; serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_BOT_FSET), "%s %s %s", update_clock(GET_TIME), for_, temp2)); } else if (!strncmp(line, "Possible bot ", 13)) { client_bot++; if (!(flags & POSSIBLE_BOT)) goto done; p = line + 13; for_ = next_arg(p, &p); if ((temp2 = next_arg(p, &p))) chop(temp2, 1); serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_BOT_FSET), "%s %s %s", update_clock(GET_TIME), for_, temp2)); } else if (wild_match("Possible % bot *", line)) { char *possible = NULL; client_bot++; if (!(flags & POSSIBLE_BOT)) goto done; p = line; possible = next_arg(p, &p); next_arg(p, &p); for_ = next_arg(p, &p); if ((temp2 = next_arg(p, &p))) { chop(temp2, 1); *temp2 = ' '; } serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_BOT1_FSET), "%s %s %s %s", update_clock(GET_TIME), possible?possible:"Unknown", for_, temp2)); } else if (wild_match("% % is now operator*", line)) { oper_requests++; if (!(flags & OPER_MODE)) goto done; p = line; fr = next_arg(p, &p); if ((temp2 = next_arg(p, &p))) { chop(temp2, 1); if (*temp2 == '(') *temp2 = ' '; } serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_OPER_FSET), "%s %s %s", update_clock(GET_TIME), fr, temp2)); } else if (!strncmp(line, "Received SQUIT", 14)) { serv_squits++; if (!(flags & SQUIT)) goto done; p = line + 14; fr = next_arg(p, &p); p += 5; for_ = next_arg(p, &temp2); if (temp2) { chop(temp2, 1); if (*temp2 == '(') temp2++; } serversay(1, from_server, "%s", convert_output_format(" SQUIT of $1 from $2 %K[%R$3-%K]", "%s %s %s %s", update_clock(GET_TIME), for_, fr, temp2)); } else if (!strncmp(line, "Received SERVER", 15)) { serv_squits++; if (!(flags & SERVER_CONNECT)) goto done; p = line + 15; fr = next_arg(p, &p); p += 5; for_ = next_arg(p, &temp2); if (temp2) { chop(temp2, 1); if (*temp2 == '(') temp2++; } serversay(1, from_server, "%s", convert_output_format(" Received SERVER %c$1%n from %c$2%n %K[%W$3-%K]", "%s %s %s %s", update_clock(GET_TIME), fr, for_, temp2)); } else if (!strncmp(line, "Sending SQUIT", 13)) { serv_squits++; if (!(flags & SQUIT)) goto done; p = line + 13; fr = next_arg(p, &temp2); if (temp2) { chop(temp2, 1); if (*temp2 == '(') temp2++; } serversay(1, from_server, "%s", convert_output_format(" Sending SQUIT %c$1%n %K[%R$2-%K]", "%s %s %s", update_clock(GET_TIME), fr, temp2)); } else if (!strncmp(line, "Sending SERVER", 14)) { serv_squits++; if (!(flags & SERVER_CONNECT)) goto done; p = line + 14; fr = next_arg(p, &temp2); if (temp2) { chop(temp2, 1); if (*temp2 == '(') temp2++; } serversay(1, from_server, "%s", convert_output_format(" Sending SERVER %c$1%n %K[%W$2-%K]", "%s %s %s", update_clock(GET_TIME), fr, temp2)); } else if (!strncmp(line, "WALLOPS :Remote CONNECT", 23)) { serv_connects++; if (!(flags & SERVER_CONNECT)) goto done; p = line + 23; for_ = next_arg(p, &p); fr = next_arg(p, &p); next_arg(p, &temp2); serversay(1, from_server, "%s", convert_output_format(" Remote Connect of $1:$2 from $3", "%s %s %s %s", update_clock(GET_TIME), for_, fr, temp2)); } else if (!strncmp(line, "Client connecting", 17) || !strncmp(line, "Client exiting", 14)) { char *q = strchr(line, ':'); char *port = empty_string; int conn = !strncmp(line+7, "connect", 7) ? 1 : 0; int dalnet = 0, ircnet = 0; if (strlen(line) >= 19 && line[18] == ':') q = NULL; else dalnet = (q == NULL); if (!dalnet) { if ((q = strchr(q + 1, ' '))) { q++; if (conn) ircnet = !strcmp(q, "is "); else ircnet = !strcmp(q, "was "); } } if (conn) client_connects++; else client_exits++; if (!(flags & CLIENT_CONNECT)) goto done; p = line; next_arg(p, &p); next_arg(p, &p); if (ircnet) { for_ = LOCAL_COPY(p); fr = LOCAL_COPY(p); temp = LOCAL_COPY(p); temp2 = LOCAL_COPY(p); if (conn) sscanf(p, "%s is %s from %s", for_, fr, temp); else sscanf(p, "%s was %s from %s", for_, fr, temp); q = p; sprintf(q, "%s@%s", fr, temp); if (!conn) { port = strstr(temp2, "reason:"); port += 8; } } else if (dalnet && !conn) { for_ = next_arg(p, &p); q = temp2 = p; if (temp2) { chop(temp2, 1); q = temp2+1; } } else if (conn && dalnet) { next_arg(p, &p); next_arg(p, &p); port = next_arg(p, &p); if (!(for_ = next_arg(p, &p))) for_ = port; { q = temp2 = p; chop(port, 1); if (temp2) { chop(temp2, 1); q = temp2+1; } } } else /* hybrid */ { for_ = q; if ((q = strchr(q, ' '))) { *q = 0; q += 2; } if ((port = strchr(q, ' '))) { *port = 0; port++; chop(q, 1); } } serversay(1, from_server, "%s", convert_output_format(fget_string_var(conn ? FORMAT_SERVER_NOTICE_CLIENT_CONNECT_FSET : FORMAT_SERVER_NOTICE_CLIENT_EXIT_FSET), "%s %s %s %s", update_clock(GET_TIME), for_, q ? q : empty_string, port ? port : empty_string)); } else if (!strncmp(line, "Terminating client for excess", 29)) { char *q; client_floods++; if (!(flags & TERM_FLOOD)) goto done; p = line + 29; for_ = next_arg(p, &p); q = temp2 = p; if (temp2) { chop(temp2, 1); q = temp2+1; } serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_CLIENT_TERM_FSET), "%s %s %s", update_clock(GET_TIME), for_, q)); } else if (!strncmp(line, "Invalid username:"******"%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_CLIENT_INVALID_FSET), "%s %s %s", update_clock(GET_TIME), for_, temp2)); } else if (!strncmp(line, "STATS ", 6)) { stats_req++; if (!(flags & STATS_REQUEST)) goto done; p = line + 6; temp = next_arg(p, &p); p += 12; for_ = next_arg(p, &p); if ( (temp2 = ++p) ) chop(temp2, 1); serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_STATS_FSET), "%s %s %s %s", update_clock(GET_TIME), temp, for_, temp2)); } else if (!strncmp(line, "Nick flooding detected by:", 26)) { if (!(flags & NICK_FLOODING)) goto done; p = line + 26; serversay(1, from_server, "%s", convert_output_format(" Nick Flooding %K[%B$1-%K]", "%s %s", update_clock(GET_TIME), for_)); } else if (!strncmp(line, "Kill line active for", 20) || !strncmp(line+14, "K-line active for", 17)) { if (!(flags & KILL_ACTIVE)) goto done; if (!strncmp(line + 14,"Kill", 4)) for_ = line + 20; else for_ = line + 17; serversay(1, from_server, "%s", convert_output_format(" Kill line for $1 active", "%s %s", update_clock(GET_TIME), for_)); } else { if (!(flags & SERVER_CRAP)) goto done; serversay(1, from_server, "%s", convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_FSET), "%s %s %s", update_clock(GET_TIME), from, stripansicodes(line))); add_last_type(&last_servermsg[0], MAX_LAST_MSG, NULL, NULL, NULL, line); } done: reset_display_target(); return done_one; }