Ejemplo n.º 1
0
static int  list_wildstrcmp(List *item1, char *str)
{
    if (wild_match(item1->name, str) || wild_match(str, item1->name))
        return 0;
    else
        return 1;
}
Ejemplo n.º 2
0
int check_channel_match(char *tmp, char *channel)
{
	char *p, *q, *chan = NULL;
	int wmatch = 0;
	if (!tmp || !channel)
		return 0;
	if (*channel == '*' && (strlen(channel)==1))
		return 1;
	q = chan = alloca(strlen(tmp)+1);
	strcpy(chan, tmp);

	while ((p = next_in_comma_list(chan, &chan)))
	{
		if (!p || !*p)
			break;
		if (*p == '!'  && wild_match(p+1, channel))
		{
			wmatch = 0;
			break;
		}
		if (!my_stricmp(p, channel))
		{
			wmatch = strlen(channel);
			break;
		}
		else if ((wmatch = wild_match(p, channel)))
			break;
	}
	return wmatch;
}
Ejemplo n.º 3
0
long elementTransmutation(char *name, long type) 
{
  long i;
  for (i=0; i<transmutationSpecs; i++) {
    if (transmutationSpec[i].exclude && wild_match(name, transmutationSpec[i].exclude))
      continue;
    if (transmutationSpec[i].name && !wild_match(name, transmutationSpec[i].name))
      continue;
    if (transmutationSpec[i].type && !wild_match(entity_name[type], transmutationSpec[i].type))
      continue;
    return transmutationSpec[i].newType;
  }
  return -1;
}
Ejemplo n.º 4
0
void sync_nicklist(UserList *added, int type)
{
ChannelList *chan;
NickList *nick;
int i;
char *check;
	check = clear_server_flags(added->host);	
	for (i = 0; i < server_list_size(); i ++)
	{
		for (chan = get_server_channels(i); chan; chan = chan->next)
		{
			for (nick = next_nicklist(chan, NULL); nick; nick = next_nicklist(chan, nick))
			{
				if (wild_match(check, nick->host))
				{
					if (type) 
					{
						nick->userlist = added;
						check_auto(chan->channel, nick, chan);
					}
					else 
						nick->userlist = NULL;	
				}
			}
		}
	}
}
Ejemplo n.º 5
0
static inline void wset_variable_casedef(Window *win, char *name, int cnt, int var_index, char *args)
{
Window *tmp = NULL;
int count = 0;
int c, i;
	if (!name)
	{
		for (cnt +=var_index; var_index < cnt; var_index++)
			set_wset_var_value(win, var_index, args);
		return;
	}
	while ((traverse_all_windows(&tmp)))
	{
		c = cnt;
		i = var_index;
		if (*name == '*')
		{
			for (c += i; i < c; i++)
				set_wset_var_value(tmp, i, empty_string);
			count++;
		}
		else if ((tmp->name && wild_match(name, tmp->name)) || (tmp->refnum == my_atol(name)) ) 
		{
			for (c += i; i < c; i++)
				set_wset_var_value(tmp, i, empty_string);
			count++;
		}
	}
	if (!count)
		say("No such window name [%s]", name);
}
Ejemplo n.º 6
0
/* Returns true if user matches one of the masklist -- drummer
 */
bool ismasked(masklist *m, const char *username)
{
  for (; m && m->mask[0]; m = m->next)
    if (wild_match(m->mask, (char *) username))
      return 1;
  return 0;
}
Ejemplo n.º 7
0
CSetList *check_cset_queue(char *channel, int add)
{
	CSetList *c = NULL;
	int found = 0;
	if (!strchr(channel, '*') && !(c = (CSetList *)find_in_list((List **)&cset_queue, channel, 0)))
	{
		if (!add) 
		{
			for (c = cset_queue; c; c = c->next)
				if (!my_stricmp(c->channel, channel) || wild_match(c->channel, channel))
					return c;
			return NULL;
		}
		c = create_csets_for_channel(channel);
		add_to_list((List **)&cset_queue, (List *)c);
		found++;
	}
	if (c)
		return c;
	if (add && !found)
	{
		for (c = cset_queue; c; c = c->next)
			if (!my_stricmp(c->channel, channel))
				return c;
		c = create_csets_for_channel(channel);
		c->next = cset_queue;
		cset_queue = c;
		return c;
	}
	return NULL;
}
Ejemplo n.º 8
0
char *	function_xdebug (char *word)
{
	char	*ret = NULL, *free_str = NULL;
	const char	*mask = NULL;
	int	cnt;
	size_t	clue = 0;

	mask = next_arg(word, &word);
	mask = mask && *mask ? mask : star;

	for (cnt = 0; opts[cnt].command; cnt++)
	{
		if (!~opts[cnt].flag) {
			continue;
		} else if (!wild_match(mask,opts[cnt].command)) {
			continue;
		} else if (x_debug & opts[cnt].flag) {
			malloc_strcat_wordlist_c(&ret, space, "+", &clue);
		} else {
			malloc_strcat_wordlist_c(&ret, space, "-", &clue);
		}
		malloc_strcat_c(&ret, opts[cnt].command, &clue);
	}

	if (word && *word)
		malloc_strcat_wordlist_c(&ret, space,
			free_str = function_xdebug(word), &clue);
	new_free(&free_str);
	malloc_strcat_c(&ret, "", &clue);
	return ret;
}
Ejemplo n.º 9
0
main()
{
    char s[100], wt[100], *nt;
    long i;

    do {
        queryn("template: ", wt, 100);
        if (has_wildcards(wt))
            printf("template has wildcards\n");
        chop_nl(wt);
        if (is_blank(wt))
            break;
        nt = expand_ranges(wt);
        printf("expanded template: %s\n", nt);
        do {
            queryn("string: ", s, 100);
            chop_nl(s);
            if (s[0]=='q')
                break;
            if ((i=wild_match(s, nt)))
                printf("%s is matched by %s--return value %ld\n", s, wt, i);
            else
                printf("%s is not matched by %s\n", s, wt);
            } while (1);
        } while (1);
    }
Ejemplo n.º 10
0
/* Returns true if user matches one of the masklist -- drummer
 */
static int ismasked(masklist *m, char *user)
{
  for (; m && m->mask[0]; m = m->next)
    if (wild_match(m->mask, user))
      return 1;
  return 0;
}
Ejemplo n.º 11
0
/*
 * history_match: using wild_match(), this finds the latest match in the
 * history file and returns it as the function result.  Returns null if there
 * is no match.  Note that this sticks a '*' at the end if one is not already
 * there. 
 */
static char *history_match(char *match)
{
    char *ptr;
    char *match_str = NULL;

    if (*(match + strlen(match) - 1) == '*')
	malloc_strcpy(&match_str, match);
    else {
	match_str = new_malloc(strlen(match) + 2);
	strcpy(match_str, match);
	strcat(match_str, "*");
    }
    if (get_int_var(HISTORY_VAR)) {
	if ((last_dir == -1) || (tmp == (History *) NULL))
	    tmp = command_history_head;
	else
	    tmp = tmp->next;
	for (; tmp; tmp = tmp->next) {
	    ptr = tmp->stuff;
	    while (ptr && strchr(get_string_var(CMDCHARS_VAR), *ptr))
		ptr++;

	    if (wild_match(match_str, ptr)) {
		new_free(&match_str);
		last_dir = PREV;
		return (tmp->stuff);
	    }
	}
    }
    last_dir = -1;
    new_free(&match_str);
    return NULL;
}
Ejemplo n.º 12
0
static inline void wset_variable_noargs(Window *win, char *name)
{
Window *tmp = NULL;
int var_index = 0;
	if (!name)
	{
		for (var_index = 0; var_index < NUMBER_OF_WSETS; var_index++)
			set_wset_var_value(win, var_index, empty_string);
	} 
	else
	{
		int count = 0;
		while ((traverse_all_windows(&tmp)))
		{
			if (*name == '*')
			{
				for (var_index = 0; var_index < NUMBER_OF_WSETS; var_index++)
					set_wset_var_value(tmp, var_index, empty_string);
				count++;
			}
			else if ((tmp->name && wild_match(name, tmp->name)) || (tmp->refnum == my_atol(name)))
			{
				for (var_index = 0; var_index < NUMBER_OF_WSETS; var_index++)
					set_wset_var_value(tmp, var_index, empty_string);
				count++;
			}
		}
		if (!count)
			say("No such window name [%s]", name);
	}
}
Ejemplo n.º 13
0
static inline void wset_variable_case1(Window *win, char *name, int var_index, char *args)
{
Window *tmp = NULL;
int count = 0;
int i;
	if (!name)
	{
		set_wset_var_value(win, var_index, args);
		return;
	}
	while ((traverse_all_windows(&tmp)))
	{
		i = var_index;
		if (*name == '*')
		{
			set_wset_var_value(tmp, i, args);
			count++;
		}
		else if ((tmp->name && wild_match(name, tmp->name)) || (tmp->refnum == my_atol(name)))
		{
			set_wset_var_value(tmp, i, args);
			count++;
		}
	}
	if (!count)
		say("No such window name [%s]", name);
}
Ejemplo n.º 14
0
void setupTransmuteElements(NAMELIST_TEXT *nltext, RUN *run, 
			 LINE_LIST *beamline)
{
  long i, j, newType;
  /* process the namelist text */
  set_namelist_processing_flags(STICKY_NAMELIST_DEFAULTS);
  set_print_namelist_flags(0);
  if (processNamelist(&transmute_elements, nltext)==NAMELIST_ERROR)
    bombElegant(NULL, NULL);
  if (echoNamelists) print_namelist(stdout, &transmute_elements);

  if (clear_all) {
    clearTransmutationSpecs();
    if (!name && !type)
      return;
  }
  if (disable)
    return;

  if (!new_type)
    bombElegant("new_type must be given", NULL);
  str_toupper(new_type);
  j = -1;
  for (i=0; i<N_TYPES; i++) {
    if (strncmp(entity_name[i], new_type, strlen(new_type))==0) {
      if (j>=0) 
        bombElegant("new_type matches more than one element type", NULL);
      j = i;
    }
  }
  if (j==-1)
    bombElegant("new_type does not match a known element type", NULL);
  newType = j;
  
  if (!name || !strlen(name))
    bombElegant("no name given", NULL);
  str_toupper(name);
  if (has_wildcards(name) && strchr(name, '-'))
    name = expand_ranges(name);
  if (type) {
    str_toupper(type);
    if (has_wildcards(type) && strchr(type, '-'))
      type = expand_ranges(type);
    for (i=0; i<N_TYPES; i++)
      if (wild_match(entity_name[i], type))
	break;
    if (i==N_TYPES) {
      fprintf(stderr, "type pattern %s does not match any known type", type);
      exitElegant(1);
    }
  }
  if (exclude) {
    str_toupper(exclude);
    if (has_wildcards(exclude) && strchr(exclude, '-'))
      exclude = expand_ranges(exclude);
  }
  
  addTransmutationSpec(name, type, exclude, newType);
}
Ejemplo n.º 15
0
static int
star (char *string, char *pattern)
{
  while (wild_match (string, pattern) == 0)
    if (*++string == '\0')
      return 0;
  return 1;
}
Ejemplo n.º 16
0
/* returns true if user matches one of the masklist -- drummer */
static int ismasked(masklist *m, char *user)
{
  while (m && m->mask[0]) {
    if (wild_match(m->mask, user))
      return 1;
    m = m->next;
  }
  return 0;
}
Ejemplo n.º 17
0
/* Determines if the Nick matches the nick!user@host mask given. */
int nick_match(NickList *nick, char *mask)
{
    int match = 0;
    char *nuh = m_3dup(nick->nick, "!", nick->host);

    match = wild_match(mask, nuh);
    new_free(&nuh);

    return match;
}
Ejemplo n.º 18
0
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;
	}

}
Ejemplo n.º 19
0
int securesoho_copy(const char *src, const char *dst){
	char dirname[256], basename[256];
	DIR *sdir;
	struct dirent *sdirent;

	if(!src || !dst) {
		fprintf(stderr, "%s:%d The src:0x%p or dst:%p is NULL\n", __FUNCTION__, __LINE__, src, dst);
		return -1;
	}
	
	if (path_split(src, dirname, basename) < 0){
		fprintf(stderr, "%s:%d, Failed to get the dirname and basename\n", __FUNCTION__, __LINE__);
		return -1;
	}

	if (is_wildcard(dirname)){
		fprintf(stderr, "%s:%d Don't support wildcard for directory\n", __FUNCTION__, __LINE__);
		return -1;
	}
	//FIXME: to make simple, we just consider following situaltion
	//The source file are wildcard string
	//The dest are directory
	if (!is_wildcard(src)){
		if (is_dir(dst)){
			char fullpath[512];
			sprintf(fullpath, "%s/%s", dst, basename);
			return file_copy(src, fullpath);
		}else{
			return file_copy(src, dst);	
		}
	}


	sdir = opendir(dirname);
	if(NULL == sdir) {
		fprintf(stderr, "%s:%d Failed to open dir:%s\n", __FUNCTION__, __LINE__, dirname);
		return -1;	
	}
	while((sdirent = readdir(sdir)) != NULL){
		if (is_dir(sdirent->d_name)) {
			continue;
		}
		if (wild_match(basename, sdirent->d_name)){
			char sfile[512], dfile[512];
			sprintf(dfile, "%s/%s", dst, sdirent->d_name);
			sprintf(sfile, "%s/%s", dirname, sdirent->d_name);
			file_copy(sfile, dfile);
		}
	}
	if(sdir) 
		closedir(sdir);

	return 0;
}
Ejemplo n.º 20
0
banlrec *Banlist_match(char *ban, chanrec *chan)
{
	banlrec	*bl;

	for(bl=Banlist->banlist; bl!=NULL; bl=bl->next)
	{
		if(bl->chan == NULL)
		{
			if(wild_match(bl->ban,ban) || wild_match(ban,bl->ban))
				return bl;
		}
		else if(isequal(bl->chan->name,chan->name))
		{
			if(wild_match(bl->ban,ban) || wild_match(ban,bl->ban))
				return bl;
		}
	}
		

	return NULL;
}
Ejemplo n.º 21
0
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);
	}
}
Ejemplo n.º 22
0
char *get_fset(char *str)
{
	int i;
	char *ret = NULL;
	IrcVariable *ptr;
	FsetNumber *tmp;
	if (!str || !*str)
		return get_all_fset();
	for (i = 0; i < NUMBER_OF_FSET; i++)
		if (wild_match(str, fset_array[i].name))
			m_s3cat(&ret, space, fset_array[i].name);
	for (i = 0; i < ext_fset_list.max; i++)
	{
		ptr = ext_fset_list.list[i];
		if (wild_match(str, ptr->name))
			m_s3cat(&ret, space, ptr->name);
	}
	for (tmp = numeric_fset; tmp; tmp = tmp->next)
		if (wild_match(str, ltoa(tmp->numeric)))
			m_s3cat(&ret, space, ltoa(tmp->numeric));
	return ret ? ret : m_strdup(empty_string);
}
Ejemplo n.º 23
0
void check_hack(char *nick, ChannelList *channel, NickList *ThisNick, char *from)
{
#ifdef WANT_USERLIST
UserList *userptr = NULL;
ShitList *shitptr = NULL;
#endif
WhowasList *check_op = NULL;

int	flag;

	if (from && *from && !strchr(from, '.'))
		return;

	if (!channel || !are_you_opped(channel->channel) || !nick || !ThisNick || wild_match(nick, get_server_nickname(from_server)))
		return;
	if (!(flag = get_cset_int_var(channel->csets, HACKING_CSET)))
		return;
	if ((ThisNick->sent_deop) && (now - ThisNick->sent_deop_time < 10))
		return;

#ifdef WANT_USERLIST
	userptr = ThisNick->userlist;
	shitptr = ThisNick->shitlist;
#endif
	check_op = check_whosplitin_buffer(nick, ThisNick->host, channel->channel, 0);
	if (check_op && check_op->has_ops)
		return;
		
#ifdef WANT_USERLIST
	if ( !userptr || (userptr && !check_channel_match(userptr->channels, channel->channel)) ||
		(shitptr && check_channel_match(shitptr->channels, channel->channel)))
#endif
	{
		switch(flag)
		{
			case 1:
			case 3:
				if (is_chanop(channel->channel, nick))
					add_mode(channel, "o", 0, nick, NULL, get_int_var(NUM_OPMODES_VAR));
				ThisNick->sent_deop++;
				ThisNick->sent_deop_time = now;
			case 2:
				if (flag != 1)
					bitchsay("NetHack detected on %s by %s!%s", channel->channel, nick, ThisNick->host); 
			case 0:
			default:
				break;
		}
	}
}
Ejemplo n.º 24
0
static inline void cset_variable_noargs(char *channel)
{
	int var_index = 0;
	ChannelList *chan = NULL; 
	int count = 0;

	if (current_window->server != -1)
	{
		for (chan = get_server_channels(current_window->server); chan; chan = chan->next) 
		{
			if (wild_match(channel, chan->channel)) 
			{	
				for (var_index = 0; var_index < NUMBER_OF_CSETS; var_index++)
					set_cset_var_value(chan->csets, var_index, empty_string);
				count++;
			}
		}
	}
/*	if (!count) */
	{
		CSetList *c = NULL;
		if (!count)
			check_cset_queue(channel, 1);
		for (c = cset_queue; c; c = c->next)
		{
			if (!wild_match(channel, c->channel))
				continue;
			for (var_index = 0; var_index < NUMBER_OF_CSETS; var_index++)
				set_cset_var_value(c, var_index, empty_string);
			count++;
		}
		if (!count)
			say("CSET_VARIABLE: No match in cset queue for %s", channel ? channel : empty_string);
		return;
	}

}
Ejemplo n.º 25
0
/* Returns 1 if the user u has an note ignore which
 * matches from
 */
int match_note_ignore(struct userrec *u, char *from)
{
  char **ignores;
  int ignoresn, i;

  ignoresn = get_note_ignores(u, &ignores);
  if (!ignoresn)
    return 0;
  for (i = 0; i < ignoresn; i++)
    if (wild_match(ignores[i], from)) {
      nfree(ignores[0]);
      nfree(ignores);
      return 1;
    }
  nfree(ignores[0]);            /* Free the string buffer       */
  nfree(ignores);               /* Free the ptr array           */
  return 0;
}
Ejemplo n.º 26
0
ShitList *nickinshit(char *niq, char *uh)
{
	char theuh[BIG_BUFFER_SIZE+1];
register ShitList *thisptr = shitlist_list;
	char *u;
	

	
	if (!uh || !niq)
		return NULL;
	u = clear_server_flags(uh);
	sprintf(theuh, "%s!%s", niq, u);
	while (thisptr)
	{
		if (!strcmp(thisptr->filter, theuh) || (/*wild_match(theuh, thisptr->filter) || */wild_match(thisptr->filter, theuh))) 
			return(thisptr);
		thisptr = thisptr->next;
	}
	return NULL;
}
Ejemplo n.º 27
0
static bool hosts_set(struct userrec *u, struct user_entry *e, void *buf)
{
  if (!buf || !strcasecmp((const char *) buf, "none")) {
    /* When the bot crashes, it's in this part, not in the 'else' part */
    list_type_kill(e->u.list);
    e->u.list = NULL;
  } else {
    char *host = (char *) buf, *p = strchr(host, ',');
    struct list_type **t;

    /* Can't have ,'s in hostmasks */
    while (p) {
      *p = '?';
      p = strchr(host, ',');
    }
    /* fred1: check for redundant hostmasks with
     * controversial "superpenis" algorithm ;) */
    /* I'm surprised Raistlin hasn't gotten involved in this controversy */
    t = &(e->u.list);
    while (*t) {
      if (wild_match(host, (*t)->extra)) {
	struct list_type *listu;

	listu = *t;
	*t = (*t)->next;
	if (listu->extra)
	  free(listu->extra);
	free(listu);
      } else
	t = &((*t)->next);
    }
    *t = (struct list_type *) my_calloc(1, sizeof(struct list_type));

    (*t)->next = NULL;
    (*t)->extra = strdup(host);
  }
  return 1;
}
Ejemplo n.º 28
0
void sync_shitlist(ShitList *added, int type)
{
ChannelList *chan;
NickList *nick;
int i;
char tmp[BIG_BUFFER_SIZE+1];
char *check;
	
	for (i = 0; i < server_list_size(); i ++)
	{
		for (chan = get_server_channels(i); chan; chan = chan->next)
		{
			for (nick = next_nicklist(chan, NULL); nick; nick = next_nicklist(chan, nick))
			{
				check = clear_server_flags(nick->host);
				sprintf(tmp, "%s!%s", nick->nick, check);
				if (wild_match(added->filter, tmp))
				{
					if (type) 
					{
						nick->shitlist = added;
						check_auto(chan->channel, nick, chan);
					}
					else
					{
						BanList *b = NULL;
						nick->shitlist = NULL;
						if ((b = ban_is_on_channel(tmp, chan)) && !eban_is_on_channel(tmp, chan))
							add_mode(chan, "b", 0, b->ban, NULL, get_int_var(NUM_BANMODES_VAR));
					}
				}
			}
			flush_mode_all(chan);
		}
	}
}
Ejemplo n.º 29
0
void parse_notice(char *from, char **Args)
{
	int	type;
	char	*to,
		*high = empty_string,
		*target,
		*line;

	NickList *nick = NULL;	
	ChannelList *tmpc = NULL;
	char *newline = NULL;

		
	PasteArgs(Args, 1);
	to = Args[0];
	line = Args[1];
	if (!to || !line)
		return;
	if (!*to)
	{
		put_it("*** obsolete notice recieved. [%s]", line+1);
		return;
	}

	if (!from || !*from || !strcmp(get_server_itsname(from_server), from))
	{
		parse_server_notice(from, line);
		return;
	}


	
	if (is_channel(to))
	{
		target = to;
		type = PUBLIC_NOTICE_LIST;
		if ((tmpc = lookup_channel(to, from_server, CHAN_NOUNLINK)))
			nick = find_nicklist_in_channellist(from, tmpc, 0);
	}
	else
	{
		target = from;
		type = NOTICE_LIST;
	}

	update_stats(NOTICELIST, to, nick, tmpc, 0);		

	set_display_target(target, LOG_NOTICE);
	doing_notice = 1;

	if ((check_ignore_notice(from, to, IGNORE_NOTICES, line, &high) == IGNORED))
		goto notice_cleanup;

	if (!check_flooding(from, NOTICE_FLOOD, line, NULL))
		goto notice_cleanup;

	if (!strchr(from, '.'))
	{
		notify_mark(from, FromUserHost, 1, 0);
		line = do_notice_ctcp(from, to, line);
		if (!*line)
			goto notice_cleanup;
	}
		
	if (sed && !do_hook(ENCRYPTED_NOTICE_LIST, "%s %s %s", from, to, line))
	{
#if 0
		put_it("%s", convert_output_format(fget_string_var(FORMAT_ENCRYPTED_NOTICE_FSET), "%s %s %s %s", update_clock(GET_TIME), from, FromUserHost, line));
#endif
		sed = 0;
		goto notice_cleanup;
	}

	
	{
		char *free_me = NULL;
		char *s;
		free_me = newline = stripansi(line);
		if (wild_match("[*Wall*", line))
		{
			char *channel = NULL, *p, *q;
			q = p = next_arg(newline, &newline);
			if ((p = strchr(p, '/')))
			{
				p++;
				if (*p && *p == '\002')
					p++;
				channel = m_strdup(p);
				if ((p = strchr(channel, ']')))
					*p++ = 0;
				q = channel;
				if (*q && q[strlen(q)-1] == '\002')
					q[strlen(q)-1] = 0;
			} 
			if (channel && *channel)
				set_display_target(channel, LOG_WALL);
			else
				set_display_target(target, LOG_WALL);
			if (do_hook(type, "%s %s", from, line))
			{
				s = convert_output_format(fget_string_var(FORMAT_BWALL_FSET), "%s %s %s %s %s", update_clock(GET_TIME), q, from, FromUserHost, newline);
				if (tmpc)
					add_to_log(tmpc->msglog_fp, now, s, logfile_line_mangler);
				put_it("%s", s);
			}
			add_last_type(&last_wall[0], 1, from, FromUserHost, NULL, line);
			logmsg(LOG_WALL, from, 0, "%s", line);
/*			addtabkey(from, "wall", 0);*/
			new_free(&channel);
		}
		else
		{
			if (type == PUBLIC_NOTICE_LIST)
			{
				s = convert_output_format(fget_string_var(check_auto_reply(line)?FORMAT_PUBLIC_NOTICE_AR_FSET:FORMAT_PUBLIC_NOTICE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost, to, newline);
				if (do_hook(type, "%s %s %s", from, to, line))
					put_it("%s", s);
			}
			else
			{
				s = convert_output_format(fget_string_var(FORMAT_NOTICE_FSET), "%s %s %s %s", update_clock(GET_TIME), from, FromUserHost, newline);
				if (do_hook(type, "%s %s", from, line))
					put_it("%s", s);

			}
			if (tmpc)
				add_to_log(tmpc->msglog_fp, now, s, logfile_line_mangler);
			logmsg(LOG_NOTICE, from, 0, "%s", line);
			add_last_type(&last_notice[0], MAX_LAST_MSG, from, FromUserHost, to, line);
		}
		new_free(&free_me);
	}

 notice_cleanup:
	if (beep_on_level & LOG_NOTICE)
		beep_em(1);
	reset_display_target();
	doing_notice = 0;
}
Ejemplo n.º 30
0
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;
}