const struct magic_realm *lookup_realm(const char *name) { struct magic_realm *realm = realms; while (realm) { if (!my_stricmp(name, realm->name)) { return realm; } realm = realm->next; } /* Fail horribly */ quit_fmt("Failed to find %s magic realm", name); return realm; }
static void p_pong(char *from, char **ArgList) { int is_server = 0; int i; if (!ArgList[0]) return; is_server = match("*.*", ArgList[0]); if (in_server_ping && is_server) ; { int old_from_server = from_server; for (i = 0; i < number_of_servers; i++) { if ((!my_stricmp(ArgList[0], get_server_name(i)) || !my_stricmp(ArgList[0], get_server_itsname(i))) && is_server_connected(i)) { int old_lag = server_list[i].lag; from_server = i; server_list[i].lag = time(NULL) - server_list[i].lag_time; in_server_ping--; if (old_lag != server_list[i].lag) status_update(1); from_server = old_from_server; return; } } from_server = old_from_server; } if (check_ignore(from, FromUserHost, NULL, IGNORE_PONGS | IGNORE_CRAP, NULL) != IGNORED) { if (!is_server) return; if (!ArgList[1]) say("%s: PONG received from %s", ArgList[0], from); else say("%s: PING received from %s %s", ArgList[0], from, ArgList[1]); } }
bool lookup( const char *the_name ) { YEditFile **file; long current_index = the_list.current_index( ); the_list.jump_to( 0 ); while( ( file = the_list.next( ) ) != NULL ) if( my_stricmp( ( *file )->name( ), the_name ) == 0 ) { the_list.previous( ); return true; } the_list.jump_to( current_index ); return false; }
melee_effect_handler_f melee_handler_for_blow_effect(const char *name) { static const struct effect_handler_s { const char *name; melee_effect_handler_f function; } effect_handlers[] = { { "NONE", melee_effect_handler_NONE }, { "HURT", melee_effect_handler_HURT }, { "POISON", melee_effect_handler_POISON }, { "DISENCHANT", melee_effect_handler_DISENCHANT }, { "DRAIN_CHARGES", melee_effect_handler_DRAIN_CHARGES }, { "EAT_GOLD", melee_effect_handler_EAT_GOLD }, { "EAT_ITEM", melee_effect_handler_EAT_ITEM }, { "EAT_FOOD", melee_effect_handler_EAT_FOOD }, { "EAT_LIGHT", melee_effect_handler_EAT_LIGHT }, { "ACID", melee_effect_handler_ACID }, { "ELEC", melee_effect_handler_ELEC }, { "FIRE", melee_effect_handler_FIRE }, { "COLD", melee_effect_handler_COLD }, { "BLIND", melee_effect_handler_BLIND }, { "CONFUSE", melee_effect_handler_CONFUSE }, { "TERRIFY", melee_effect_handler_TERRIFY }, { "PARALYZE", melee_effect_handler_PARALYZE }, { "LOSE_STR", melee_effect_handler_LOSE_STR }, { "LOSE_INT", melee_effect_handler_LOSE_INT }, { "LOSE_WIS", melee_effect_handler_LOSE_WIS }, { "LOSE_DEX", melee_effect_handler_LOSE_DEX }, { "LOSE_CON", melee_effect_handler_LOSE_CON }, { "LOSE_ALL", melee_effect_handler_LOSE_ALL }, { "SHATTER", melee_effect_handler_SHATTER }, { "EXP_10", melee_effect_handler_EXP_10 }, { "EXP_20", melee_effect_handler_EXP_20 }, { "EXP_40", melee_effect_handler_EXP_40 }, { "EXP_80", melee_effect_handler_EXP_80 }, { "HALLU", melee_effect_handler_HALLU }, { NULL, NULL }, }; const struct effect_handler_s *current = effect_handlers; while (current->name != NULL && current->function != NULL) { if (my_stricmp(name, current->name) == 0) return current->function; current++; } return NULL; }
/* * logical_to_index: converts a logical process name to it's approriate index * in the process list, or -1 if not found */ static int logical_to_index (const char *logical) { Process *proc; int i; for (i = 0; i < process_list_size; i++) { if (!(proc = process_list[i]) || !proc->logical) continue; if (!my_stricmp(proc->logical, logical)) return i; } return -1; }
/* * get_timer - Return a schedule Timer using its refname. * * Arguments: * ref - A Timer refname (timer->ref, from /TIMER -REF) * (a) ref must not be NULL or an empty string. * * Return Value: * NULL - No scheduled timer exists by that name * non-NULL - A Scheduled Timer by the given name. * (a) You must _NOT_ change a Scheduled Timer unless * you unlink_timer() it first. * (b) The best practice for changing a Scheduled Timer: * 1) x = get_timer(); * 2) y = clone_timer(x); * 3) unlink_timer(x); * 4) <make changes to y> * 5) schedule_timer(y); * 6) delete_timer(x); */ static Timer *get_timer (const char *ref) { Timer *tmp; /* 'ref' must be a non-empty string */ if (!ref || !*ref) return NULL; for (tmp = PendingTimers; tmp; tmp = tmp->next) { if (!my_stricmp(tmp->ref, ref)) return tmp; } return NULL; }
/* * Recursively adds sections to the tree of sections */ static void insert_section(ini_section *r, ini_section *n) { assert(r); assert(n); if(my_stricmp(r->name, n->name) < 0) { if(!r->left) r->left = n; else insert_section(r->left, n); } else { if(!r->right) r->right = n; else insert_section(r->right, n); } }
static void for_fe_cmd (int argc, char **argv, const char *subargs) { char *var, *list, *cmds; char *next, *real_list, *x; if (!subargs) subargs = empty_string; if ((my_stricmp(argv[1], "in")) || (argc != 4)) { my_error("Usage: /FOR var IN (list) {commands}"); return; } var = argv[0]; list = argv[2]; cmds = argv[3]; if (*cmds == '{') cmds++; if (*list == '(') list++; x = real_list = expand_alias(list, subargs); will_catch_break_exceptions++; will_catch_continue_exceptions++; while (real_list && *real_list) { next = next_func_arg(real_list, &real_list); add_local_alias(var, next, 0); runcmds(cmds, subargs); if (break_exception) { break_exception = 0; break; } if (continue_exception) continue_exception = 0; /* Dont continue here! */ if (return_exception) break; if (system_exception) break; } will_catch_break_exceptions--; will_catch_continue_exceptions--; new_free(&x); }
void ison_notify(char *AskedFor, char *AreOn) { char *NextAsked; char *NextGot; NextGot = next_arg(AreOn, &AreOn); while ((NextAsked = next_arg(AskedFor, &AskedFor)) != NULL) { if (NextGot && !my_stricmp(NextAsked, NextGot)) { notify_mark(NextAsked, NULL, 1, 1); NextGot = next_arg(AreOn, &AreOn); } else notify_mark(NextAsked, NULL, 0, 1); } dispatch_notify_userhosts(); }
static int is_logical_unique (char *logical) { Process *proc; int i; if (!logical) return 1; for (i = 0; i < process_list_size; i++) { if (!(proc = process_list[i]) || !proc->logical) continue; if (!my_stricmp(proc->logical, logical)) return 0; } return 1; }
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 inline void cset_variable_casedef(char *channel, int cnt, int var_index, char *args) { ChannelList *chan = NULL; int tmp, tmp2; int count = 0; if (current_window->server != -1) { for (chan = get_server_channels(current_window->server); chan; chan = chan->next) { tmp = var_index; tmp2 = cnt; if (wild_match(channel, chan->channel)) { for (tmp2 += tmp; tmp < tmp2; tmp++) set_cset_var_value(chan->csets, tmp, empty_string); count++; } } } /* if (!count) */ { CSetList *c = NULL; if (!count) check_cset_queue(channel, 1); for (c = cset_queue; c; c = c->next) { tmp = var_index; tmp2 = cnt; if (!my_stricmp(channel, c->channel) || wild_match(channel, c->channel)) { for (tmp2 +=tmp; tmp < tmp2; tmp++) set_cset_var_value(c, tmp, empty_string); count++; } } if (!count) say("CSET_VARIABLE: No match in cset queue for %s", channel); return; } }
static Logfile * get_log_by_desc (const char *desc) { Logfile *log; if (is_number(desc)) { int number = atol(desc); for (log = logfiles; log; log = log->next) if (log->refnum == number) return log; } else { for (log = logfiles; log; log = log->next) if (!my_stricmp(log->name, desc)) return log; } return NULL; }
/** * Returns the numeric equivalent tval of the textual tval `name`. */ int tval_find_idx(const char *name) { size_t i = 0; unsigned int r; char *mod_name; if (sscanf(name, "%u", &r) == 1) return r; mod_name = de_armour(name); for (i = 0; i < N_ELEMENTS(tval_names); i++) { if (!my_stricmp(mod_name, tval_names[i].name)) { string_free(mod_name); return tval_names[i].tval; } } string_free(mod_name); return -1; }
static inline void cset_variable_case1(char *channel, int var_index, char *args) { ChannelList *chan = NULL; int tmp = 0; int count = 0; /* * implement a queue for channels that don't exist... later... * go home if user doesn't have any channels. */ if (current_window->server != -1) { for (chan = get_server_channels(current_window->server); chan; chan = chan->next) { tmp = var_index; if (wild_match(channel, chan->channel)) { set_cset_var_value(chan->csets, tmp, args); count++; } } } /* no channel match. lets check the queue */ /* if (!count)*/ { CSetList *c = NULL; if (!count) check_cset_queue(channel, 1); for (c = cset_queue; c; c = c->next) { tmp = var_index; if (!my_stricmp(channel, c->channel) || wild_match(channel, c->channel)) { set_cset_var_value(c, tmp, args); count++; } } if (!count) say("CSET_VARIABLE: No match in cset queue for %s", channel); } }
int pub_proc(char *which, char *str, char **unused) { char *loc, *nick, *chan, *cmd, *serv; unsigned short port = 0; if(qbx_on == 0) return 1; loc = LOCAL_COPY(str); nick = next_arg(loc, &loc); chan = next_arg(loc, &loc); cmd = next_arg(loc, &loc); if(cmd && *cmd != '!') return 1; if(my_stricmp(cmd, Q3A_COMMAND) && my_stricmp(cmd, Q2_COMMAND) && my_stricmp(cmd, QW_COMMAND)) return 1; serv = next_arg(loc, &loc); if(serv == NULL) { privmsg(chan, "%s: Give me a server to query", nick); return 1; } if(querying == 1) { privmsg(chan, "%s: A query is already in progress", nick); return 1; } if(strchr(serv, ':')) { serv = strtok(serv, ":"); port = atoi(strtok(NULL, "")); } else port = 0; strncpy(q_chan, chan, 256); if(!my_stricmp(cmd, Q3A_COMMAND)) { /* quake3 server (my fav =) */ if(port == 0) port = Q3A_GAME_PORT; query_q_server(serv, port, 3); return 1; } else if(!my_stricmp(cmd, Q2_COMMAND)) { /* quake2 server */ if(port == 0) port = Q2_GAME_PORT; query_q_server(serv, port, 2); return 1; } else if(!my_stricmp(cmd, QW_COMMAND)) { /* quakeworld server */ if(port == 0) port = QW_GAME_PORT; query_q_server(serv, port, 1); return 1; } return 1; }
/** * Handle a "-d<dir>=<path>" option. * * Sets any of angband's special directories to <path>. * * The "<path>" can be any legal path for the given system, and should * not end in any special path separator (i.e. "/tmp" or "~/.ang-info"). */ static void change_path(const char *info) { char *info_copy = NULL; char *path = NULL; char *dir = NULL; unsigned int i = 0; char dirpath[512]; if (!info || !info[0]) quit_fmt("Try '-d<dir>=<path>'.", info); info_copy = string_make(info); path = strtok(info_copy, "="); dir = strtok(NULL, "="); for (i = 0; i < N_ELEMENTS(change_path_values); i++) { if (my_stricmp(path, change_path_values[i].name) == 0) { #ifdef SETGID if (!change_path_values[i].setgid_ok) quit_fmt("Can't redefine path to %s dir on multiuser setup", path); #endif string_free(*change_path_values[i].path); *change_path_values[i].path = string_make(dir); /* the directory may not exist and may need to be created. */ path_build(dirpath, sizeof(dirpath), dir, ""); if (!dir_create(dirpath)) quit_fmt("Cannot create '%s'", dirpath); string_free(info_copy); return; } } quit_fmt("Unrecognised -d paramater %s", path); }
int get_field_type_by_name( const char *name ) { if( my_stricmp( name, "INT" ) == 0 || my_stricmp( name, "INTEGER" ) == 0 || my_stricmp( name, "TINYINT" ) == 0 || my_stricmp( name, "LONGINT" ) == 0 || my_stricmp( name, "SMALLINT" ) == 0 ) { return FIELD_TYPE_INTEGER; } else if( my_stricmp( name, "FLOAT" ) == 0 || my_stricmp( name, "DOUBLE" ) == 0 || my_stricmp( name, "SINGLE" ) == 0 || my_stricmp( name, "DECIMAL" ) == 0 || my_stricmp( name, "REAL" ) == 0 ) { return FIELD_TYPE_DOUBLE; } else if( my_stricmp( name, "BLOB" ) == 0 || my_stricmp( name, "BINARY" ) == 0 || my_stricmp( name, "VARBINARY" ) == 0 ) { return FIELD_TYPE_BLOB; } return FIELD_TYPE_CHAR; }
/* * help_me: The big one. The help procedure that handles working out * what was actually requested, sets up the paused topic list if it is * needed, does pretty much all the hard work. */ static void help_me (char *topics, char *args) { char * ptr; glob_t g; int entries = 0, cnt, i, cols; Stat stat_buf; char path[BIG_BUFFER_SIZE+1]; int help_paused_first_call = 0; char * help_paused_path = (char *) 0; char * help_paused_name = (char *) 0; char * temp; char tmp[BIG_BUFFER_SIZE+1]; char buffer[BIG_BUFFER_SIZE+1]; char * pattern = NULL; strlcpy(help_topic_list, topics, sizeof help_topic_list); ptr = get_string_var(HELP_PATH_VAR); snprintf(path, sizeof path, "%s/%s", ptr, topics); for (ptr = path; (ptr = strchr(ptr, ' '));) *ptr = '/'; /* * first we check access to the help dir, whinge if we can't, then * work out we need to ask them for more help, else we check the * args list, and do the stuff */ if (help_show_directory) { help_show_paused_topic(paused_topic, empty_string); help_show_directory = 0; } finished_help_paging = 0; if (access(path, R_OK|X_OK)) { help_put_it(no_help, "*** Cannot access help directory!"); set_help_screen((Screen *) 0); return; } this_arg = next_arg(args, &args); if (!this_arg && *help_topic_list && get_int_var(HELP_PROMPT_VAR)) { if ((temp = strrchr(help_topic_list, ' ')) != NULL) *temp = '\0'; else *help_topic_list = '\0'; snprintf(tmp, sizeof tmp, "%s%sHelp? ", help_topic_list, *help_topic_list ? " " : empty_string); if (!dumb_mode) add_wait_prompt(tmp, help_me, help_topic_list, WAIT_PROMPT_LINE, 1); return; } if (!this_arg) { set_help_screen((Screen *) 0); return; } create_help_window(); if (!help_window) return; /* * This is just a bogus while loop which is intended to allow * the user to do '/help alias expressions' without having to * include a slash inbetween the topic and subtopic. * * If all goes well, we 'break' at the bottom of the loop. */ while (this_arg) { entries = 0; if (!*this_arg) help_topic(path, NULL); if (strcmp(this_arg, "?") == 0) { this_arg = empty_string; if (!dont_pause_topic) dont_pause_topic = 1; } /* * entry_size is set to the width of the longest help topic * (adjusted for compression extensions, of course.) */ entry_size = 0; /* * Gather up the names of the files in the help directory. */ { size_t size; #ifndef HAVE_FCHDIR char opath[MAXPATHLEN + 1]; getcwd(opath, MAXPATHLEN); #else int cwd = open(".", O_RDONLY); #endif size = strlen(path) + 2 + strlen(this_arg) + 3; chdir(path); pattern = alloca(size); snprintf(pattern, size, "%s*", this_arg); #ifdef GLOB_INSENSITIVE bsd_glob(pattern, GLOB_INSENSITIVE, NULL, &g); #else bsd_glob(pattern, 0, NULL, &g); #endif #ifndef HAVE_FCHDIR chdir(opath); #else fchdir(cwd); close(cwd); #endif } for (i = 0; i < g.gl_matchc; i++) { char *tmp2 = g.gl_pathv[i]; int len = strlen(tmp2); if (!end_strcmp(tmp2, ".gz", 3)) len -= 3; entry_size = (len > entry_size) ? len : entry_size; } /* * Right here we need to check for an 'exact match'. * An 'exact match' would be sitting in gl_pathv[0], * and it is 'exact' if it is identical to what we are * looking for, or if it is the same except that it has * a compression extension on it */ if (g.gl_matchc > 1) { char *str1 = g.gl_pathv[0]; const char *str2 = this_arg; int len1 = strlen(str1); int len2 = strlen(str2); if (len1 == len2 && !my_stricmp(str1, str2)) entries = 1; else if (len1 - 3 == len2 && !my_strnicmp(str1, str2, len2) && !end_strcmp(str1, ".gz", 3)) entries = 1; else if (len1 - 2 == len2 && !my_strnicmp(str1, str2, len2) && !end_strcmp(str1, ".Z", 2)) entries = 1; else if (len1 - 2 == len2 && !my_strnicmp(str1, str2, len2) && !end_strcmp(str1, ".z", 2)) entries = 1; } if (!*help_topic_list) dont_pause_topic = 1; /* reformatted */ /* * entries: -1 means something really died, 0 means there * was no help, 1, means it wasn't a directory, and so to * show the help file, and the default means to add the * stuff to the paused topic list.. */ if (!entries) entries = g.gl_matchc; switch (entries) { case -1: { help_put_it(no_help, "*** Error during help function: %s", strerror(errno)); set_help_screen(NULL); if (help_paused_first_call) { help_topic(help_paused_path, help_paused_name); help_paused_first_call = 0; new_free(&help_paused_path); new_free(&help_paused_name); } message_from(NULL, LOG_CRAP); return; } case 0: { help_put_it(this_arg, "*** No help available on %s: Use ? for list of topics", this_arg); if (!get_int_var(HELP_PROMPT_VAR)) { set_help_screen(NULL); break; } snprintf(tmp, sizeof tmp, "%s%sHelp? ", help_topic_list, *help_topic_list ? " " : empty_string); if (!dumb_mode) add_wait_prompt(tmp, help_me, help_topic_list, WAIT_PROMPT_LINE, 1); if (help_paused_first_call) { help_topic(help_paused_path, help_paused_name); help_paused_first_call = 0; new_free(&help_paused_path); new_free(&help_paused_name); } break; } case 1: { snprintf(tmp, sizeof tmp, "%s/%s", path, g.gl_pathv[0]); stat(tmp, &stat_buf); if (stat_buf.st_mode & S_IFDIR) { strlcpy(path, tmp, sizeof path); if (*help_topic_list) strlcat(help_topic_list, " ", sizeof help_topic_list); strlcat(help_topic_list, g.gl_pathv[0], sizeof help_topic_list); if (!(this_arg = next_arg(args, &args))) { help_paused_first_call = 1; malloc_strcpy(&help_paused_path, path); malloc_strcpy(&help_paused_name, g.gl_pathv[0]); dont_pause_topic = -1; this_arg = "?"; } bsd_globfree(&g); continue; } else { help_topic(path, g.gl_pathv[0]); finished_help_paging = 0; break; } } default: { help_show_directory = 1; strlcpy(paused_topic, help_topic_list, sizeof paused_topic); help_pause_add_line("*** %s choices:", help_topic_list); entry_size += 2; cols = (current_term->TI_cols - 10) / entry_size; strlcpy(buffer, empty_string, sizeof(buffer)); cnt = 0; for (i = 0; i < entries; i++) { if (!end_strcmp(g.gl_pathv[i], ".gz", 3)) chop(g.gl_pathv[i], 3); strlcat(buffer, g.gl_pathv[i], sizeof buffer); /* * Since we already know how many columns each * line will contain, we check to see if we have * accumulated that many entries. If we have, we * output the line to the screen. */ if (++cnt == cols) { help_pause_add_line("%s", buffer); *buffer = 0; cnt = 0; } /* * If we have not finished this line, then we have * to pad the name length out to the expected width. * 'entry_size' is the column width. We also have * do adjust for compression extension. */ else strextend(buffer, ' ', entry_size - strlen(g.gl_pathv[i])); } help_pause_add_line("%s", buffer); if (help_paused_first_call) { help_topic(help_paused_path, help_paused_name); help_paused_first_call = 0; new_free(&help_paused_path); new_free(&help_paused_name); } if (dont_pause_topic == 1) { help_show_paused_topic(paused_topic, empty_string); help_show_directory = 0; } break; } } /* end of reformatting */ bsd_globfree(&g); break; } /* * This one is for when there was never a topic and the prompt * never got a topic.. and help_screen was never reset.. * phone, jan 1993. */ if (!*help_topic_list && finished_help_paging) set_help_screen((Screen *) 0); message_from(NULL, LOG_CRAP); }
void userhost_ban(UserhostItem *stuff, char *nick1, char *args) { char *temp; char *str= NULL; char *channel; ChannelList *c = NULL; NickList *n = NULL; char *ob = "-o+b"; char *b = "+b"; char *host = NULL, *nick = NULL, *user = NULL, *chan = NULL; WhowasList *whowas = NULL; int f**k = 0; int set_ignore = 0; channel = next_arg(args, &args); temp = next_arg(args, &args); f**k = !my_stricmp("F**K", args); set_ignore = !my_stricmp("BKI", args); if (!stuff || !stuff->nick || !nick1 || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick1)) { if (nick1 && channel && (whowas = check_whowas_nick_buffer(nick1, channel, 0))) { nick = whowas->nicklist->nick; user = m_strdup(clear_server_flags(whowas->nicklist->host)); host = strchr(user, '@'); *host++ = 0; bitchsay("Using WhoWas info for ban of %s ", nick1); n = whowas->nicklist; } else if (nick1) { bitchsay("No match for the %s of %s on %s", f**k ? "F**k":"Ban", nick1, channel); return; } } else { nick = stuff->nick; user = m_strdup(clear_server_flags(stuff->user)); host = stuff->host; } if (!(my_stricmp(nick, get_server_nickname(from_server)))) { bitchsay("Try to kick yourself again!!"); new_free(&user); return; } if (is_on_channel(channel, from_server, nick)) chan = channel; c = lookup_channel(channel, from_server, 0); if (c && !n) n = find_nicklist_in_channellist(nick, c, 0); send_to_server("MODE %s %s %s %s", channel, chan ? ob : b, chan?nick:empty_string, ban_it(nick, user, host, (n && n->ip)?n->ip:NULL)); if (f**k) { malloc_sprintf(&str, "%s!*%s@%s %s 3 Auto-Shit", nick, user, host, channel); #ifdef WANT_USERLIST add_shit(NULL, str, NULL, NULL); #endif new_free(&str); } else if (set_ignore) ignore_nickname(ban_it("*", user, host, NULL) , IGNORE_ALL, 0); new_free(&user); }
int BX_flood_prot (char *nick, char *userhost, char *type, int ctcp_type, int ignoretime, char *channel) { ChannelList *chan; NickList *Nick; char tmp[BIG_BUFFER_SIZE+1]; char *uh; int old_window_display; int kick_on_flood = 1; if ((ctcp_type == CDCC_FLOOD || ctcp_type == CTCP_FLOOD || ctcp_type == CTCP_ACTION_FLOOD) && !get_int_var(CTCP_FLOOD_PROTECTION_VAR)) return 0; else if (!get_int_var(FLOOD_PROTECTION_VAR)) return 0; else if (!my_stricmp(nick, get_server_nickname(from_server))) return 0; switch (ctcp_type) { case WALL_FLOOD: case MSG_FLOOD: break; case NOTICE_FLOOD: break; case PUBLIC_FLOOD: if (channel) { if ((chan = lookup_channel(channel, from_server, 0))) { kick_on_flood = get_cset_int_var(chan->csets, PUBFLOOD_CSET); if (kick_on_flood && (Nick = find_nicklist_in_channellist(nick, chan, 0))) { if (chan->have_op && (!Nick->userlist || (Nick->userlist && !(Nick->userlist->flags & ADD_FLOOD)))) if (!nick_isop(Nick) || get_cset_int_var(chan->csets, KICK_OPS_CSET)) send_to_server("KICK %s %s :\002%s\002 flooder", chan->channel, nick, type); } } } break; case CTCP_FLOOD: case CTCP_ACTION_FLOOD: check_ctcp_ban_flood(channel, nick); default: if (get_int_var(FLOOD_KICK_VAR) && kick_on_flood && channel) { for (chan = get_server_channels(from_server); chan; chan = chan->next) { if (chan->have_op && (Nick = find_nicklist_in_channellist(nick, chan, 0))) { if ((!Nick->userlist || (Nick->userlist && !(Nick->userlist->flags & ADD_FLOOD)))) if (!nick_isop(Nick) || get_cset_int_var(chan->csets, KICK_OPS_CSET)) send_to_server("KICK %s %s :\002%s\002 flooder", chan->channel, nick, type); } } } } if (!ignoretime) return 0; uh = clear_server_flags(userhost); sprintf(tmp, "*!*%s", uh); old_window_display = window_display; window_display = 0; ignore_nickname(tmp, ignore_type(type, strlen(type)), 0); window_display = old_window_display; sprintf(tmp, "%d ^IGNORE *!*%s NONE", ignoretime, uh); timercmd("TIMER", tmp, NULL, NULL); bitchsay("Auto-ignoring %s for %d minutes [\002%s\002 flood]", nick, ignoretime/60, type); return 1; }
/* * $logctl(NEW) * $logctl(REFNUMS [ACTIVE|INACTIVE|ALL]) * $logctl(REFNUM log-desc) * $logctl(ADD log-desc [target]) * $logctl(DELETE log-desc [target]) * $logctl(GET <refnum> [LIST]) * $logctl(SET <refnum> [ITEM] [VALUE]) * $logctl(MATCH [pattern]) * $logctl(PMATCH [pattern]) * * [LIST] and [ITEM] are one of the following * REFNUM The refnum for the log (GET only) * NAME The logical name for the log * FILENAME The filename this log writes to * SERVER The server this log associates with (-1 for any) * TARGETS All of the targets for this log * LEVEL The Lastlog Level for this log * REWRITE The rewrite rule for this log * MANGLE The mangle rule for this log * STATUS 1 if log is on, 0 if log is off. * TYPE Either "TARGET", "WINDOW", or "SERVER" */ char *logctl (char *input) { char *refstr; char *listc; int val; Logfile *log; GET_FUNC_ARG(listc, input); if (!my_strnicmp(listc, "NEW", 3)) { log = new_logfile(); RETURN_INT(log->refnum); } else if (!my_strnicmp(listc, "LAST_CREATED", 12)) { RETURN_INT(last_logref); } else if (!my_strnicmp(listc, "REFNUMS", 7)) { char * retval = NULL; int active; GET_FUNC_ARG(refstr, input); if (!my_stricmp(refstr, "ACTIVE")) active = 1; else if (!my_stricmp(refstr, "INACTIVE")) active = 0; else if (!my_stricmp(refstr, "ALL")) active = -1; else RETURN_EMPTY; for (log = logfiles; log; log = log->next) { if (active != -1 && active != log->active) continue; malloc_strcat_word(&retval, space, ltoa(log->refnum), DWORD_NO); } RETURN_MSTR(retval); } else if (!my_strnicmp(listc, "REFNUM", 6)) { GET_FUNC_ARG(refstr, input); if (!(log = get_log_by_desc(refstr))) RETURN_EMPTY; RETURN_INT(log->refnum); } else if (!my_strnicmp(listc, "ADD", 2)) { GET_FUNC_ARG(refstr, input); if (!(log = get_log_by_desc(refstr))) RETURN_EMPTY; logfile_add(log, &input); RETURN_INT(1); } else if (!my_strnicmp(listc, "DELETE", 2)) { GET_FUNC_ARG(refstr, input); if (!(log = get_log_by_desc(refstr))) RETURN_EMPTY; logfile_remove(log, &input); RETURN_INT(1); } else if (!my_strnicmp(listc, "GET", 2)) { GET_FUNC_ARG(refstr, input); if (!(log = get_log_by_desc(refstr))) RETURN_EMPTY; GET_FUNC_ARG(listc, input); if (!my_strnicmp(listc, "REFNUM", 3)) { RETURN_INT(log->refnum); } else if (!my_strnicmp(listc, "NAME", 3)) { RETURN_STR(log->name); } else if (!my_strnicmp(listc, "FILENAME", 3)) { RETURN_STR(log->filename); } else if (!my_strnicmp(listc, "SERVER", 3)) { RETURN_INT(log->servref); } else if (!my_strnicmp(listc, "TARGETS", 3)) { char *ret = logfile_get_targets(log); RETURN_MSTR(ret); } else if (!my_strnicmp(listc, "LEVEL", 3)) { const char *ret = mask_to_str(&log->mask); RETURN_STR(ret); } else if (!my_strnicmp(listc, "REWRITE", 3)) { RETURN_STR(log->rewrite); } else if (!my_strnicmp(listc, "MANGLE", 3)) { RETURN_STR(log->mangle_desc); } else if (!my_strnicmp(listc, "STATUS", 3)) { RETURN_INT(log->active); } else if (!my_strnicmp(listc, "TYPE", 3)) { RETURN_STR(logtype[log->type]); } else if (!my_strnicmp(listc, "ACTIVITY", 1)) { RETURN_INT(log->activity); } } else if (!my_strnicmp(listc, "SET", 1)) { GET_FUNC_ARG(refstr, input); if (!(log = get_log_by_desc(refstr))) RETURN_EMPTY; GET_FUNC_ARG(listc, input); if (!my_strnicmp(listc, "NAME", 3)) { logfile_name(log, &input); RETURN_INT(1); } else if (!my_strnicmp(listc, "FILENAME", 3)) { logfile_filename(log, &input); RETURN_INT(1); } else if (!my_strnicmp(listc, "SERVER", 3)) { logfile_server(log, &input); RETURN_INT(1); } else if (!my_strnicmp(listc, "TARGETS", 3)) { clean_log_targets(log); logfile_add(log, &input); RETURN_INT(1); } else if (!my_strnicmp(listc, "LEVEL", 3)) { logfile_level(log, &input); RETURN_INT(1); } else if (!my_strnicmp(listc, "REWRITE", 3)) { logfile_rewrite(log, &input); RETURN_INT(1); } else if (!my_strnicmp(listc, "MANGLE", 3)) { logfile_mangle(log, &input); RETURN_INT(1); } else if (!my_strnicmp(listc, "STATUS", 3)) { GET_INT_ARG(val, input); if (val) logfile_on(log, &input); else logfile_off(log, &input); RETURN_INT(1); } else if (!my_strnicmp(listc, "TYPE", 3)) { logfile_type(log, &input); RETURN_INT(1); } else if (!my_strnicmp(listc, "ACTIVITY", 1)) { logfile_activity(log, &input); RETURN_INT(1); } } else if (!my_strnicmp(listc, "MATCH", 1)) { RETURN_EMPTY; /* Not implemented for now. */ } else if (!my_strnicmp(listc, "PMATCH", 1)) { RETURN_EMPTY; /* Not implemented for now. */ } else if (!my_strnicmp(listc, "CURRENT", 1)) { RETURN_INT(current_log_refnum); } else RETURN_EMPTY; RETURN_EMPTY; }
void userhost_unban(UserhostItem *stuff, char *nick1, char *args) { char *tmp; ChannelList *chan; char *channel = NULL; BanList *bans; char *host = NULL; char *ip_str = NULL; WhowasList *whowas = NULL; NickList *n = NULL; int count = 0; int old_server = from_server; if (!stuff || !stuff->nick || !nick1 || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick1)) { if (nick1 && (whowas = check_whowas_nick_buffer(nick1, args, 0))) { malloc_sprintf(&host, "%s!%s", whowas->nicklist->nick, whowas->nicklist->host); bitchsay("Using WhoWas info for unban of %s ", nick1); n = whowas->nicklist; } else if (nick1) { bitchsay("No match for the unban of %s on %s", nick1, args); return; } if (!nick1) return; } else { tmp = clear_server_flags(stuff->user); malloc_sprintf(&host, "%s!%s@%s",stuff->nick, tmp, stuff->host); } channel = next_arg(args, &args); if (args && *args) from_server = atoi(args); if (!(chan = prepare_command(&from_server, channel, NEED_OP))) { new_free(&host); return; } if (!n) n = find_nicklist_in_channellist(stuff->nick, chan, 0); if (n && n->ip) { size_t len = strlen(n->nick)+strlen(n->host)+strlen(n->ip)+10; ip_str = alloca(len); *ip_str = 0; strmopencat(ip_str, len, stuff->nick, "!", stuff->user, "@", n->ip, NULL); } for (bans = chan->bans; bans; bans = bans->next) { if (!bans->sent_unban && (wild_match(bans->ban, host) || (ip_str && wild_match(bans->ban, ip_str))) ) { add_mode(chan, "b", 0, bans->ban, NULL, get_int_var(NUM_BANMODES_VAR)); bans->sent_unban++; count++; } } flush_mode_all(chan); if (!count) bitchsay("No match for Unban of %s on %s", nick1, args); new_free(&host); from_server = old_server; }
static int list_stricmp(List *item1, char *str) { return my_stricmp(item1->name, str); }
static void p_privmsg(char *from, char **Args) { int level, list_type, flood_type, log_type, no_flood = 1, do_beep = 1; unsigned char ignore_type; char *ptr = NULL, *to; char *high; struct channel *channel = NULL; struct nick_list *tmpnick = NULL; if (!from) return; PasteArgs(Args, 1); to = Args[0]; ptr = Args[1]; if (!to || !ptr) { fake(); return; } doing_privmsg = 1; if (is_channel(to) && im_on_channel(to)) { message_from(to, LOG_MSG); malloc_strcpy(&public_nick, from); log_type = LOG_PUBLIC; ignore_type = IGNORE_PUBLIC; flood_type = PUBLIC_FLOOD; if (!is_on_channel(to, from_server, from)) list_type = PUBLIC_MSG_LIST; else { if (is_current_channel(to, from_server, 0)) list_type = PUBLIC_LIST; else list_type = PUBLIC_OTHER_LIST; channel = lookup_channel(to, from_server, CHAN_NOUNLINK); if (channel) tmpnick = find_nicklist_in_channellist(from, channel, 0); } } else { message_from(from, LOG_MSG); flood_type = MSG_FLOOD; if (my_stricmp(to, get_server_nickname(from_server))) { log_type = LOG_WALL; ignore_type = IGNORE_WALLS; list_type = MSG_GROUP_LIST; } else { log_type = LOG_MSG; ignore_type = IGNORE_MSGS; list_type = MSG_LIST; } } switch (check_ignore(from, FromUserHost, to, ignore_type, ptr)) { case IGNORED: if ((list_type == MSG_LIST) && 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)); doing_privmsg = 0; return; case HIGHLIGHTED: high = highlight_char; break; case CHANNEL_GREP: high = highlight_char; break; default: high = empty_str; break; } ptr = do_ctcp(from, to, ptr); if (!ptr || !*ptr) { doing_privmsg = 0; return; } level = set_lastlog_msg_level(log_type); if (flood_type == PUBLIC_FLOOD) { int blah = 0; if (is_other_flood(channel, tmpnick, PUBLIC_FLOOD, &blah)) { no_flood = 0; flood_prot(tmpnick->nick, FromUserHost, "PUBLIC", flood_type, get_int_var(PUBFLOOD_TIME_VAR), channel->channel); } } else no_flood = check_flooding(from, flood_type, ptr, NULL); { switch (list_type) { case PUBLIC_MSG_LIST: logmsg(LOG_PUBLIC, from, ptr, 0); if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr)) put_it("%s", convert_output_format(get_format(FORMAT_PUBLIC_MSG_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost, to, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr)); break; case MSG_GROUP_LIST: logmsg(LOG_PUBLIC, from, ptr, 0); if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr)) put_it("%s", convert_output_format(get_format(FORMAT_MSG_GROUP_FSET), "%s %s %s %s", update_clock(GET_TIME), from, to, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr)); break; case MSG_LIST: { if (!no_flood) break; malloc_strcpy(&recv_nick, from); if (away_set) { do_beep = 0; beep_em(get_int_var(BEEP_WHEN_AWAY_VAR)); set_int_var(MSGCOUNT_VAR, get_int_var(MSGCOUNT_VAR) + 1); } logmsg(LOG_MSG, from, ptr, 0); addtabkey(from, "msg"); if (do_hook(list_type, "%s %s", from, ptr)) put_it("%s", convert_output_format(get_format(FORMAT_MSG_FSET), "%s %s %s %s", update_clock(GET_TIME), from, FromUserHost, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr)); if (from_server > -1 && get_server_away(from_server) && get_int_var(SEND_AWAY_MSG_VAR)) { send_to_server(SERVER(from_server), "NOTICE %s :%s", from, stripansicodes(convert_output_format (get_format(FORMAT_SEND_AWAY_FSET), "%l %l %s", time(NULL), server_list[from_server].awaytime, get_int_var(MSGLOG_VAR) ? "On" : "Off"))); } break; } case PUBLIC_LIST:{ logmsg(LOG_PUBLIC, from, ptr, 0); if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr)) put_it("%s", convert_output_format(get_format(FORMAT_PUBLIC_FSET), "%s %s %s %s", update_clock(GET_TIME), from, to, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr)); break; } case PUBLIC_OTHER_LIST:{ logmsg(LOG_PUBLIC, from, ptr, 0); if (no_flood && do_hook(list_type, "%s %s %s", from, to, ptr)) put_it("%s", convert_output_format(get_format(FORMAT_PUBLIC_OTHER_FSET), "%s %s %s %s", update_clock(GET_TIME), from, to, get_int_var(MIRCS_VAR) ? mircansi(ptr) : ptr)); break; } /* case */ } /* switch */ } if (beep_on_level & log_type && do_beep) beep_em(1); set_lastlog_msg_level(level); message_from(NULL, LOG_CRAP); doing_privmsg = 0; }
static int add_list_stricmp(List *item1, List *item2) { return my_stricmp(item1->name, item2->name); }
static void p_kick(char *from, char **ArgList) { char *channel, *who, *comment; char *chankey = NULL; struct channel *chan = NULL; struct nick_list *tmpnick = NULL; int t = 0; channel = ArgList[0]; who = ArgList[1]; comment = ArgList[2] ? ArgList[2] : "(no comment)"; if ((chan = lookup_channel(channel, from_server, CHAN_NOUNLINK))) tmpnick = find_nicklist_in_channellist(from, chan, 0); message_from(channel, LOG_CRAP); if (channel && who && chan) { if (!my_stricmp(who, get_server_nickname(from_server))) { Window *window = chan->window; if (chan->key) malloc_strcpy(&chankey, chan->key); if (get_int_var(AUTO_REJOIN_VAR)) { send_to_server(SERVER(from_server), "JOIN %s %s", channel, chankey ? chankey : empty_str); add_to_join_list(channel, from_server, window ? window->refnum : 0); } new_free(&chankey); remove_channel(channel, from_server); update_all_status(curr_scr_win, NULL, 0); update_input(UPDATE_ALL); if (do_hook(KICK_LIST, "%s %s %s %s", who, from, channel, comment ? comment : empty_str)) put_it("%s", convert_output_format(get_format(FORMAT_KICK_USER_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, channel, who, comment)); } else { int itsme = 0; itsme = !my_stricmp(get_server_nickname(from_server), from) ? 1 : 0; if ((check_ignore(from, FromUserHost, channel, IGNORE_KICKS | IGNORE_CRAP, NULL) != IGNORED) && do_hook(KICK_LIST, "%s %s %s %s", who, from, channel, comment)) put_it("%s", convert_output_format(get_format(FORMAT_KICK_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, channel, who, comment)); if (!itsme) { struct nick_list *f_nick = NULL; f_nick = find_nicklist_in_channellist(who, chan, 0); if (chan->chop && tmpnick && is_other_flood(chan, tmpnick, KICK_FLOOD, &t)) { if (get_int_var(KICK_ON_KICKFLOOD_VAR) > get_int_var(DEOP_ON_KICKFLOOD_VAR)) send_to_server(SERVER(from_server), "MODE %s -o %s", chan->channel, from); else if (!f_nick->kickcount++) send_to_server(SERVER(from_server), "KICK %s %s :\002Mass kick detected - (%d kicks in %dsec%s)\002", chan->channel, from, get_int_var(KICK_ON_KICKFLOOD_VAR), t, plural(t)); } } remove_from_channel(channel, who, from_server, 0, NULL); } } update_all_status(curr_scr_win, NULL, 0); message_from(NULL, LOG_CRAP); }
static void p_mode(char *from, char **ArgList) { char *channel; char *line; int flag; struct channel *chan = NULL; char buffer[BIG_BUFFER_SIZE + 1]; char *smode; #ifdef COMPRESS_MODES char *tmpbuf = NULL; #endif PasteArgs(ArgList, 1); channel = ArgList[0]; line = ArgList[1]; smode = strchr(from, '.'); flag = check_ignore(from, FromUserHost, channel, (smode ? IGNORE_SMODES : IGNORE_MODES) | IGNORE_CRAP, NULL); message_from(channel, LOG_CRAP); if (channel && line) { strcpy(buffer, line); if (get_int_var(MODE_STRIPPER_VAR)) strip_modes(from, channel, line); if (is_channel(channel)) { #ifdef COMPRESS_MODES chan = (struct channel *) find_in_list((struct list **) &server_list[from_server].chan_list, channel, 0); if (get_int_var(COMPRESS_MODES_VAR)) { tmpbuf = compress_modes(from_server, channel, line); if (tmpbuf) strcpy(line, tmpbuf); else goto end_p_mode; } #endif /* CDE handle mode protection here instead of later */ update_channel_mode(from, channel, from_server, buffer, chan); if (flag != IGNORED && do_hook(MODE_LIST, "%s %s %s", from, channel, line)) put_it("%s", convert_output_format(get_format(smode ? FORMAT_SMODE_FSET : FORMAT_MODE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, smode ? "*" : FromUserHost, channel, line)); } else { if (flag != IGNORED && do_hook(MODE_LIST, "%s %s %s", from, channel, line)) { if (!my_stricmp(from, channel)) { if (!my_stricmp(from, get_server_nickname(from_server))) put_it("%s", convert_output_format(get_format(FORMAT_USERMODE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, "*", channel, line)); else put_it("%s", convert_output_format(get_format(FORMAT_USERMODE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, smode ? "*" : FromUserHost, channel, line)); } else put_it("%s", convert_output_format(get_format(FORMAT_MODE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, smode ? "*" : FromUserHost, channel, line)); } update_user_mode(line); } #ifdef COMPRESS_MODES end_p_mode: #endif update_all_status(curr_scr_win, NULL, 0); } message_from(NULL, LOG_CRAP); }
CSetList *create_csets_for_channel(char *channel) { CSetList *tmp; #ifdef VAR_DEBUG int i; for (i = 1; i < NUMBER_OF_CSETS - 1; i++) if (strcmp(cset_array[i-1].name, cset_array[i].name) >= 0) ircpanic("Variable [%d] (%s) is out of order.", i, cset_array[i].name); #endif if (check_cset_queue(channel, 0)) { if ((tmp = (CSetList *)find_in_list((List **)&cset_queue, channel, 0))) return tmp; for (tmp = cset_queue; tmp; tmp = tmp->next) if (!my_stricmp(tmp->channel, channel) || wild_match(tmp->channel, channel)) return tmp; } tmp = (CSetList *) new_malloc(sizeof(CSetList)); /* use default settings. */ tmp->set_aop = get_int_var(AOP_VAR); tmp->set_annoy_kick = get_int_var(ANNOY_KICK_VAR); tmp->set_ainv = get_int_var(AINV_VAR); tmp->set_auto_join_on_invite = get_int_var(AUTO_JOIN_ON_INVITE_VAR); tmp->set_auto_rejoin = get_int_var(AUTO_REJOIN_VAR); tmp->set_bantime = get_int_var(BANTIME_VAR); tmp->compress_modes = get_int_var(COMPRESS_MODES_VAR); tmp->bitch_mode = get_int_var(BITCH_VAR); tmp->channel_log = 0; tmp->log_level = m_strdup("ALL"); set_msglog_channel_level(cset_array, tmp); #if defined(WINNT) || defined(__EMX__) tmp->channel_log_file = m_sprintf("~/bx-conf/%s.log", channel+1); #else tmp->channel_log_file = m_sprintf("~/.BitchX/%s.log", channel+1); #endif tmp->set_joinflood = get_int_var(JOINFLOOD_VAR); tmp->set_joinflood_time = get_int_var(JOINFLOOD_TIME_VAR); tmp->set_ctcp_flood_ban = get_int_var(CTCP_FLOOD_BAN_VAR); tmp->set_deop_on_deopflood = get_int_var(DEOP_ON_DEOPFLOOD_VAR); tmp->set_deop_on_kickflood = get_int_var(DEOP_ON_KICKFLOOD_VAR); tmp->set_deopflood = get_int_var(DEOPFLOOD_VAR); tmp->set_deopflood_time = get_int_var(DEOPFLOOD_TIME_VAR); tmp->set_hacking = get_int_var(HACKING_VAR); tmp->set_kick_on_deopflood = get_int_var(KICK_ON_DEOPFLOOD_VAR); tmp->set_kick_on_joinflood = get_int_var(KICK_ON_JOINFLOOD_VAR); tmp->set_kick_on_kickflood = get_int_var(KICK_ON_KICKFLOOD_VAR); tmp->set_kick_on_nickflood = get_int_var(KICK_ON_NICKFLOOD_VAR); tmp->set_kick_on_pubflood = get_int_var(KICK_ON_PUBFLOOD_VAR); tmp->set_kickflood = get_int_var(KICKFLOOD_VAR); tmp->set_kickflood_time = get_int_var(KICKFLOOD_TIME_VAR); tmp->set_kick_ops = get_int_var(KICK_OPS_VAR); tmp->set_nickflood = get_int_var(NICKFLOOD_VAR); tmp->set_nickflood_time = get_int_var(NICKFLOOD_TIME_VAR); tmp->set_pubflood = get_int_var(PUBFLOOD_VAR); tmp->set_pubflood_time = get_int_var(PUBFLOOD_TIME_VAR); tmp->set_pubflood_ignore = 60; tmp->set_userlist = get_int_var(USERLIST_VAR); tmp->set_shitlist = get_int_var(SHITLIST_VAR); tmp->set_lamelist = get_int_var(LAMELIST_VAR); tmp->set_lame_ident = get_int_var(LAMEIDENT_VAR); tmp->set_kick_if_banned = get_int_var(KICK_IF_BANNED_VAR); tmp->set_auto_limit = get_int_var(AUTO_LIMIT_VAR); malloc_strcpy(&tmp->chanmode, get_string_var(CHANMODE_VAR)); malloc_strcpy(&tmp->channel, channel); return tmp; }
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); }