Пример #1
0
static Logfile *	logfile_rewrite (Logfile *log, char **args)
{
        char *arg = new_next_arg(*args, args);

	if (!log)
	{
		say("REWRITE: You need to specify a logfile first");
		return NULL;
	}

	malloc_strcpy(&log->rewrite, arg);
	return log;
}
Пример #2
0
void
foreach(u_char *command, u_char *args, u_char *subargs)
{
	u_char	*struc = NULL,
		*ptr,
		*body = NULL,
		*var = NULL;
	u_char	**sublist;
	int	total;
	int	i;
	int	slen;

	if ((ptr = new_next_arg(args, &args)) == NULL)
	{
		yell("FOREACH: missing structure expression");
		return;
	}
	malloc_strcpy(&struc, ptr);
	malloc_strcat(&struc, UP("."));
	upper(struc);
	if ((var = next_arg(args, &args)) == NULL)
	{
		new_free(&struc);
		yell("FOREACH: missing variable");
		return;
	}
	while (isspace(*args))
		args++;
	if ((body = next_expr(&args, '{')) == NULL)	/* } */
	{
		new_free(&struc);
		yell("FOREACH: missing statement");
		return;
	}
	sublist = match_alias(struc, &total, VAR_ALIAS);
	slen = my_strlen(struc);
	for (i = 0; i < total; i++)
	{
		unsigned	display;

		display = set_display_off();
		add_alias(VAR_ALIAS, var, sublist[i]+slen);
		set_display(display);
		parse_line(NULL, body, subargs ?
		    subargs : empty_string(), 0, 0, 0);
		new_free(&sublist[i]);
	}
	new_free(&sublist);
	new_free(&struc);
}
Пример #3
0
static Logfile *	logfile_level (Logfile *log, char **args)
{
        char *arg = new_next_arg(*args, args);
	char *rejects = NULL;

	if (!log)
	{
		say("LEVEL: You need to specify a logfile first");
		return NULL;
	}

	if (str_to_mask(&log->mask, arg, &rejects))
		standard_level_warning("/LOG LEVEL", &rejects);
	return log;
}
Пример #4
0
void amsg(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg) {
	char *nick,*nnick,*loc;
	
	CHECK_TOC_ONLINE();
	
	/* loc = msg, nick = username to send msg to */
	loc = LOCAL_COPY(args);
	nick = new_next_arg(loc, &loc);
	
	REQUIRED_ARG(nick,command,helparg);
	
	if ( nick[0] == '#' ) {
		struct buddy_chat *b;
		nick++;
		REQUIRED_ARG(nick,command,helparg);
		b = (struct buddy_chat *) find_buddy_chat(nick);
		if ( ! b ) {
			statusprintf("Error not on buddy chat %s", nick);
			return;
		}
		/* chatprintf("sent msg %s to buddy chat %s",loc,nick); */
		serv_chat_send(b->id,loc);
	} else {
		char *ruser,*rnick;
		nnick = (char *) malloc(strlen(nick)+10);
		rnick = rm_space(nick);
		ruser = rm_space(get_dllstring_var("aim_user"));
		sprintf(nnick,"%s@AIM",rnick);
		msgprintf("%s", cparse(fget_string_var(FORMAT_SEND_MSG_FSET), 
			"%s %s %s %s",update_clock(GET_TIME), 
			nnick, ruser, loc));
		serv_send_im(nick,loc);
		RemoveFromLLByKey(msgdthem,rnick);
		AddToLL(msgdthem,rnick,NULL);
#ifdef BITCHX_PATCH
		tks.list = 0;
		tks.pos = -1;
#endif		
		free(rnick); free(ruser);
	}	
	
	debug_printf("sending msg to %s '%s'",nick,loc);	
	return;
}
Пример #5
0
static Logfile *	logfile_server (Logfile *log, char **args)
{
        char *arg = new_next_arg(*args, args);

	if (!log)
	{
		say("SERVER: You need to specify a logfile first");
		return NULL;
	}

	if (!my_strnicmp(arg, "ALL", 1))
		log->servref = NOSERV;
	else if (!is_number(arg))
		say("/LOG SERVER: The log's server needs to be a number or ALL");
	else
		log->servref = str_to_servref(arg);

	return log;
}
Пример #6
0
static Logfile *	logfile_type (Logfile *log, char **args)
{
        char *arg = new_next_arg(*args, args);

	if (!log)
	{
		say("TYPE: You need to specify a logfile first");
		return NULL;
	}

	clean_log_targets(log);
	if (!my_strnicmp(arg, "SERVER", 1))
		log->type = LOG_SERVERS;
	else if (!my_strnicmp(arg, "WINDOW", 1))
		log->type = LOG_WINDOWS;
	else if (!my_strnicmp(arg, "TARGET", 1))
		log->type = LOG_TARGETS;
	else
		say("TYPE: Unknown type of log");

	return log;
}
Пример #7
0
void abl(IrcCommandDll *intp, char *command, char *args, char *subargs,char *helparg) {
	char *cmd,*loc;
	
	CHECK_TOC_ONLINE();
	
	/* loc = msg, nick = username to send msg to */
	loc = LOCAL_COPY(args);
	cmd = new_next_arg(loc, &loc);
	
	REQUIRED_ARG(cmd,command,helparg);
	
	if  ( ! strcasecmp(cmd,"show" ) ) {
			struct buddy *b;
			LLE tg,tb;
			LL mems;
			for ( TLL(groups,tg) ) {
				mems = ((struct group *) tg->data)->members;
				statusprintf("Group: %s", tg->key);
				for ( TLL(mems,tb) ) {
					b = (struct buddy *)tb->data;
					statusprintf("\t\t%s %d",b->name,b->present);
				}
			}
	} else if ( ! strcasecmp(cmd,"add") ) {
Пример #8
0
void napfile_read(int snum)
{
GetFile *gf;
int rc;
SocketList *s;
	s = get_socket(snum);
	if (!(gf = (GetFile *)get_socketinfo(snum)))
	{
		unsigned char buff[2*BIG_BUFFER_SIZE+1];
		unsigned char fbuff[2*BIG_BUFFER_SIZE+1];
		char *nick, *filename, *args;
		
		alarm(10);
		if ((rc = read(snum, buff, 2 * BIG_BUFFER_SIZE)) < 0)
		{
			alarm(0);
			nap_finished_file(snum, PREMATURE_FINISH);
			return;
		}
		alarm(0);
		buff[rc] = 0;
		args = &buff[0];
		if (!*args || !strcmp(buff, "FILE NOT FOUND") || 
			!strcmp(buff, "INVALID REQUEST") || 
			!strcmp(buff, "FILE NOT REQUESTED"))
		{
			say("Error in napfile_read(%d/%s) %s", snum, (rc == 0) ? strerror(errno) : "", *args ? args : "unknown read");
			nap_finished_file(snum, PREMATURE_FINISH);
			return;
		}

		nick = next_arg(args, &args);
		if ((filename = new_next_arg(args, &args)) && *filename)
		{
			strcpy(fbuff, filename);
			convertnap_unix(fbuff);
		}
		if (!nick || !filename || !*filename || !args || !*args
			|| !(gf = find_in_getfile(0, nick, NULL, fbuff, 0, NAP_UPLOAD))
			|| (gf->write == -1))
		{
			memset(buff, 0, 80);
			if (!gf)
				sprintf(buff, "INVALID REQUEST");

			else
			{
				sprintf(buff, "FILE NOT FOUND");
				break_from_list((List **)&transfer_struct, (List *)gf);
				gf->socket = snum;
				if (gf->write == -1)
				{
					send_ncommand(CMDS_REMOVEFILE, "%s", fbuff);
					say("Unable to open [%s]", fbuff);
				}
				else
				{
					close(gf->write);
					gf->write = -1;
				}
			}
			write(snum, buff, strlen(buff));
			nap_finished_file(snum, PREMATURE_FINISH);
			return;
		}
		gf->resume = my_atol(next_arg(args, &args));
		if (gf->resume >= gf->filesize)
		{
			break_from_list((List **)&transfer_struct, (List *)gf);
			close(gf->write);
			gf->write = -1;
			nap_finished_file(snum, PREMATURE_FINISH);
			return;
		}
		if (gf->socket != -1)
		{
			put_it("ERROR gf->socket != -1 %d %s %s", snum, nick, filename);
			break_from_list((List **)&transfer_struct, (List *)gf);
			close(gf->write);
			gf->write = -1;
			nap_finished_file(snum, PREMATURE_FINISH);
			return;
		}
		gf->socket = snum;
		lseek(gf->write, SEEK_SET, gf->resume);
		set_socketinfo(snum, gf);
		memset(buff, 0, 80);
		sprintf(buff, "%lu", gf->filesize);
		write(snum, buff, strlen(buff));
		s->func_write = s->func_read;
		s->is_write = s->is_read;
		if (do_hook(NAPSEND_LIST, "%s %s %lu \"%s\"", gf->resume ? "RESUME":"SEND", gf->nick, gf->filesize, gf->filename) && !get_int_var(QUIET_SENDS_VAR))
			put_it("* %sing file to %s [%s] (%s)", gf->resume ? "Resum" : "Send", gf->nick, base_name(gf->filename), longcomma(gf->filesize));
		set_non_blocking(snum);
		build_status(current_window, NULL, 0);
		send_ncommand(CMDS_UPDATE_SEND1, NULL);
		return;
	} else if (!gf->starttime)
		gf->starttime = now;
	s->func_write = s->func_read = napfile_sendfile;
	napfile_sendfile(snum);
}
Пример #9
0
/*
 * wild_match: calculate the "value" of str when matched against pattern.
 * The "value" of a string is always zero if it is not matched by the pattern.
 * In all cases where the string is matched by the pattern, then the "value"
 * of the match is 1 plus the number of non-wildcard characters in "str".
 *
 * \\[ and \\] handling done by Jeremy Nelson
 */
int BX_wild_match (const char *p, const char *str)
{
	/*
	 * Is there a \[ in the pattern to be expanded? 
	 * 
	 * This stuff here just reduces the \[ \] set into a series of
	 * one-simpler patterns and then recurses over the options.
	 */
	if (strstr(p, "\\["))
	{
		char *pattern, *ptr, *ptr2, *arg, *placeholder;
		int nest = 0;

		/*
		 * Only make the copy if we're going to be tearing it apart.
		 */
		pattern = LOCAL_COPY(p);

		/*
		 * We will have to null this out, but not until we've used it
		 */
		placeholder = ptr = ptr2 = strstr(pattern, "\\[");

		/*
		 * Look for the matching \].
		 */
		do
		{
			switch (ptr[1]) 
			{
					/* step over it and add to nest */
				case '[' :  ptr2 = ptr + 2 ;
					    nest++;
					    break;
					/* step over it and remove nest */
				case ']' :  ptr2 = ptr + 2;
					    nest--;
					    break;
				default:
					    ptr2 = ptr + 2;
					    break;
			}
		}
		while (nest && (ptr = strchr(ptr2, '\\')));

		/*
		 * Right now, we know that ptr points to a \] or to a NULL.
		 * Remember that '&&' short circuits and that ptr will
		 * not be set to NULL if (nest) is zero.
		 */
		if (ptr)
		{
			int best_total = 0;

			*ptr = 0;
			ptr += 2;
			*placeholder = 0;
			placeholder += 2;

			/* 
			 * grab words ("" sets or space words) one at a time
			 * and attempt to match all of them.  The best value
			 * matched is the one used.
			 */
			while ((arg = new_next_arg(placeholder, &placeholder)))
			{
				int tmpval;
				char my_buff[BIG_BUFFER_SIZE + 1];

				strlcpy(my_buff, pattern, BIG_BUFFER_SIZE);
				strlcat(my_buff, arg, BIG_BUFFER_SIZE);
				strlcat(my_buff, ptr, BIG_BUFFER_SIZE);

				/*
				 * The total_explicit we return is whatever
				 * sub-pattern has the highest total_explicit
				 */
				if ((tmpval = wild_match(my_buff, str)))
				{
					if (tmpval > best_total)
						best_total = tmpval;
				}
			}

			return best_total; /* end of expansion section */
		}

		/*
		 * Possibly an unmatched \[ \] set.  Just wing it.
		 */
		else
			return new_match(pattern, str);
	}

	/*
	 * Trivial case -- No \[ \] sets, just do the match.
	 */
	else
		return new_match(p, str);
}
Пример #10
0
	
	if  ( ! strcasecmp(cmd,"show" ) ) {
			struct buddy *b;
			LLE tg,tb;
			LL mems;
			for ( TLL(groups,tg) ) {
				mems = ((struct group *) tg->data)->members;
				statusprintf("Group: %s", tg->key);
				for ( TLL(mems,tb) ) {
					b = (struct buddy *)tb->data;
					statusprintf("\t\t%s %d",b->name,b->present);
				}
			}
	} else if ( ! strcasecmp(cmd,"add") ) {
		char *buddy,*group;
		group = new_next_arg(loc, &loc);
		REQUIRED_ARG(group,command,helparg);

		if ( ! VALID_ARG(loc) ) {
	        	buddy = group;
	        	group = (char *) malloc(strlen("Buddies")+2);
        		strcpy(group,"Buddies");
		} else {
		        buddy = new_next_arg(loc,&loc);
		}

		if ( user_add_buddy(group,buddy) > 0 ) {
			statusprintf("Added buddy %s to group %s",buddy,group);
		} else {
        		statusprintf("%s is already in your buddy list",buddy);
		}	       
Пример #11
0
int	parse_mangle (const char *value, int nvalue, char **rv)
{
	char	*str1, *str2;
	char	*copy;
	char	*nv = NULL;

	if (rv)
		*rv = NULL;

	if (!value)
		return 0;

	copy = LOCAL_COPY(value);

	while ((str1 = new_next_arg(copy, &copy)))
	{
		while (*str1 && (str2 = next_in_comma_list(str1, &str1)))
		{
			     if (!my_strnicmp(str2, "ALL_OFF", 4))
				nvalue |= STRIP_ALL_OFF;
			else if (!my_strnicmp(str2, "-ALL_OFF", 5))
				nvalue &= ~(STRIP_ALL_OFF);
			else if (!my_strnicmp(str2, "ALL", 3))
				nvalue = (0x7FFFFFFF ^ (MANGLE_ESCAPES) ^ (STRIP_OTHER) ^ (STRIP_UNPRINTABLE));
			else if (!my_strnicmp(str2, "-ALL", 4))
				nvalue = 0;
			else if (!my_strnicmp(str2, "ALT_CHAR", 3))
				nvalue |= STRIP_ALT_CHAR;
			else if (!my_strnicmp(str2, "-ALT_CHAR", 4))
				nvalue &= ~(STRIP_ALT_CHAR);
			else if (!my_strnicmp(str2, "ANSI", 2))
				nvalue |= NORMALIZE;
			else if (!my_strnicmp(str2, "-ANSI", 3))
				nvalue &= ~(NORMALIZE);
			else if (!my_strnicmp(str2, "BLINK", 2))
				nvalue |= STRIP_BLINK;
			else if (!my_strnicmp(str2, "-BLINK", 3))
				nvalue &= ~(STRIP_BLINK);
			else if (!my_strnicmp(str2, "BOLD", 2))
				nvalue |= STRIP_BOLD;
			else if (!my_strnicmp(str2, "-BOLD", 3))
				nvalue &= ~(STRIP_BOLD);
			else if (!my_strnicmp(str2, "COLOR", 1))
				nvalue |= STRIP_COLOR;
			else if (!my_strnicmp(str2, "-COLOR", 2))
				nvalue &= ~(STRIP_COLOR);
			else if (!my_strnicmp(str2, "ESCAPE", 1))
				nvalue |= MANGLE_ESCAPES;
			else if (!my_strnicmp(str2, "-ESCAPE", 2))
				nvalue &= ~(MANGLE_ESCAPES);
			else if (!my_strnicmp(str2, "ND_SPACE", 2))
				nvalue |= STRIP_ND_SPACE;
			else if (!my_strnicmp(str2, "-ND_SPACE", 3))
				nvalue &= ~(STRIP_ND_SPACE);
			else if (!my_strnicmp(str2, "NORMALIZE", 3))
				nvalue |= NORMALIZE;
			else if (!my_strnicmp(str2, "-NORMALIZE", 4))
				nvalue &= ~(NORMALIZE);
			else if (!my_strnicmp(str2, "NONE", 2))
				nvalue = 0;
			else if (!my_strnicmp(str2, "OTHER", 2))
				nvalue |= STRIP_OTHER;
			else if (!my_strnicmp(str2, "-OTHER", 3))
				nvalue &= ~(STRIP_OTHER);
			else if (!my_strnicmp(str2, "REVERSE", 2))
				nvalue |= STRIP_REVERSE;
			else if (!my_strnicmp(str2, "-REVERSE", 3))
				nvalue &= ~(STRIP_REVERSE);
			else if (!my_strnicmp(str2, "UNDERLINE", 3))
				nvalue |= STRIP_UNDERLINE;
			else if (!my_strnicmp(str2, "-UNDERLINE", 4))
				nvalue &= ~(STRIP_UNDERLINE);
			else if (!my_strnicmp(str2, "UNPRINTABLE", 3))
				nvalue |= STRIP_UNPRINTABLE;
			else if (!my_strnicmp(str2, "-UNPRINTABLE", 4))
				nvalue &= ~(STRIP_UNPRINTABLE);
		}
	}

	if (rv)
	{
		if (nvalue & MANGLE_ESCAPES)
			malloc_strcat_wordlist(&nv, space, "ESCAPE");
		if (nvalue & NORMALIZE)
			malloc_strcat_wordlist(&nv, space, "NORMALIZE");
		if (nvalue & STRIP_COLOR)
			malloc_strcat_wordlist(&nv, space, "COLOR");
		if (nvalue & STRIP_REVERSE)
			malloc_strcat_wordlist(&nv, space, "REVERSE");
		if (nvalue & STRIP_UNDERLINE)
			malloc_strcat_wordlist(&nv, space, "UNDERLINE");
		if (nvalue & STRIP_BOLD)
			malloc_strcat_wordlist(&nv, space, "BOLD");
		if (nvalue & STRIP_BLINK)
			malloc_strcat_wordlist(&nv, space, "BLINK");
		if (nvalue & STRIP_ALT_CHAR)
			malloc_strcat_wordlist(&nv, space, "ALT_CHAR");
		if (nvalue & STRIP_ND_SPACE)
			malloc_strcat_wordlist(&nv, space, "ND_SPACE");
		if (nvalue & STRIP_ALL_OFF)
			malloc_strcat_wordlist(&nv, space, "ALL_OFF");
		if (nvalue & STRIP_UNPRINTABLE)
			malloc_strcat_wordlist(&nv, space, "UNPRINTABLE");
		if (nvalue & STRIP_OTHER)
			malloc_strcat_wordlist(&nv, space, "OTHER");

		*rv = nv;
	}

	return nvalue;
}
Пример #12
0
/* 
 * TODO: add some kind of error reporting here
 */
void play(char *inFileStr)
{
char *f;
long totalframes = 0;
long tseconds = 0;
struct AUDIO_HEADER header;
int bitrate, fs, g, cnt = 0;

	while ((f = new_next_arg(inFileStr, &inFileStr)))
	{
		if (!f || !*f)
			return;	
		if ((in_file=fopen(f,"r"))==NULL) 
		{
			if (!do_hook(MODULE_LIST, "AMP ERROR open %s", f))
				put_it("Could not open file: %s\n", f);
			continue;
		}



		filesize = file_size(f);
		initialise_globals();

		if ((g=gethdr(&header))!=0) 
		{
			report_header_error(g);
			continue;
		}

		if (header.protection_bit==0) 
			getcrc();

		if (setup_audio(&header)!=0) 
		{
			yell("Cannot set up audio. Exiting");
			continue;
		}
	
		filesize -= sizeof(header);

		switch (header.layer)
		{
			case 1:
			{
				if (layer3_frame(&header,cnt)) 
				{
					yell(" error. blip.");
					continue;
				}
				break;
			} 
			case 2:
			{
				if (layer2_frame(&header,cnt)) 
				{
					yell(" error. blip.");
					continue;
				}
				break;
			}
			default:
				continue;
		}

		bitrate=t_bitrate[header.ID][3-header.layer][header.bitrate_index];
	       	fs=t_sampling_frequency[header.ID][header.sampling_frequency];

	        if (header.ID) 
        		framesize=144000*bitrate/fs;
	       	else 
       			framesize=72000*bitrate/fs;



		totalframes = (filesize / (framesize + 1)) - 1;
		tseconds = (totalframes * 1152/
		    t_sampling_frequency[header.ID][header.sampling_frequency]);
                
		if (A_AUDIO_PLAY)
		{
			char *p = strrchr(f, '/');
			if (!p) p = f; else p++;
			if (!do_hook(MODULE_LIST, "AMP PLAY %lu %lu %s", tseconds, filesize, p))
				bitchsay("Playing: %s\n", p);
		}

		/*
		 * 
		 */
		if (!(fseek(in_file, 0, SEEK_END)))
		{
			char id3_tag[256];
			if (!fseek(in_file, -128, SEEK_END) && (fread(id3_tag,128, 1, in_file) == 1))
			{
				if (!strncmp(id3_tag, "TAG", 3))
					print_id3_tag(in_file, id3_tag);
			}
			fseek(in_file,0,SEEK_SET);
		}
		decodeMPEG(&header);
		do_hook(MODULE_LIST, "AMP CLOSE %s", f);
		close_audio();
		fclose(in_file);
	}
}
Пример #13
0
int	parse_mangle (char *value, int nvalue, char **rv)
{
	char	*str1, *str2;
	char	*copy;
	char	*nv = NULL;

	if (rv)
		*rv = NULL;

	if (!value)
		return 0;

	copy = LOCAL_COPY(value);

	while ((str1 = new_next_arg(copy, &copy)))
	{
		while (*str1 && (str2 = next_in_comma_list(str1, &str1)))
		{
			     if (!my_strnicmp(str2, "ALL_OFF", 4))
				nvalue |= STRIP_ALL_OFF;
			else if (!my_strnicmp(str2, "-ALL_OFF", 5))
				nvalue &= ~(STRIP_ALL_OFF);
			else if (!my_strnicmp(str2, "ALL", 3))
				nvalue = (0x7FFFFFFF - (MANGLE_ESCAPES));
			else if (!my_strnicmp(str2, "-ALL", 4))
				nvalue = 0;
			else if (!my_strnicmp(str2, "ANSI", 2))
				nvalue |= MANGLE_ANSI_CODES;
			else if (!my_strnicmp(str2, "-ANSI", 3))
				nvalue &= ~(MANGLE_ANSI_CODES);
			else if (!my_strnicmp(str2, "BLINK", 2))
				nvalue |= STRIP_BLINK;
			else if (!my_strnicmp(str2, "-BLINK", 3))
				nvalue &= ~(STRIP_BLINK);
			else if (!my_strnicmp(str2, "BOLD", 2))
				nvalue |= STRIP_BOLD;
			else if (!my_strnicmp(str2, "-BOLD", 3))
				nvalue &= ~(STRIP_BOLD);
			else if (!my_strnicmp(str2, "COLOR", 1))
				nvalue |= STRIP_COLOR;
			else if (!my_strnicmp(str2, "-COLOR", 2))
				nvalue &= ~(STRIP_COLOR);
			else if (!my_strnicmp(str2, "ESCAPE", 1))
				nvalue |= MANGLE_ESCAPES;
			else if (!my_strnicmp(str2, "-ESCAPE", 2))
				nvalue &= ~(MANGLE_ESCAPES);
			else if (!my_strnicmp(str2, "ND_SPACE", 2))
				nvalue |= STRIP_ND_SPACE;
			else if (!my_strnicmp(str2, "-ND_SPACE", 3))
				nvalue &= ~(STRIP_ND_SPACE);
			else if (!my_strnicmp(str2, "NONE", 2))
				nvalue = 0;
			else if (!my_strnicmp(str2, "REVERSE", 2))
				nvalue |= STRIP_REVERSE;
			else if (!my_strnicmp(str2, "-REVERSE", 3))
				nvalue &= ~(STRIP_REVERSE);
			else if (!my_strnicmp(str2, "ROM_CHAR", 2))
				nvalue |= STRIP_ROM_CHAR;
			else if (!my_strnicmp(str2, "-ROM_CHAR", 3))
				nvalue &= ~(STRIP_ROM_CHAR);
			else if (!my_strnicmp(str2, "UNDERLINE", 1))
				nvalue |= STRIP_UNDERLINE;
			else if (!my_strnicmp(str2, "-UNDERLINE", 2))
				nvalue &= ~(STRIP_UNDERLINE);
		}
	}

	if (rv)
	{
		if (nvalue & MANGLE_ESCAPES)
			m_s3cat(&nv, comma, "ESCAPE");
		if (nvalue & MANGLE_ANSI_CODES)
			m_s3cat(&nv, comma, "ANSI");
		if (nvalue & STRIP_COLOR)
			m_s3cat(&nv, comma, "COLOR");
		if (nvalue & STRIP_REVERSE)
			m_s3cat(&nv, comma, "REVERSE");
		if (nvalue & STRIP_UNDERLINE)
			m_s3cat(&nv, comma, "UNDERLINE");
		if (nvalue & STRIP_BOLD)
			m_s3cat(&nv, comma, "BOLD");
		if (nvalue & STRIP_BLINK)
			m_s3cat(&nv, comma, "BLINK");
		if (nvalue & STRIP_ROM_CHAR)
			m_s3cat(&nv, comma, "ROM_CHAR");
		if (nvalue & STRIP_ND_SPACE)
			m_s3cat(&nv, comma, "ND_SPACE");
		if (nvalue & STRIP_ALL_OFF)
			m_s3cat(&nv, comma, "ALL_OFF");

		*rv = nv;
	}

	return nvalue;
}
Пример #14
0
int parse_debug(char *value, int nvalue, char **rv)
{
	char	*str1, *str2;
	char	 *copy;
	char	*nv = NULL;

	if (rv)
		*rv = NULL;

	if  (!value)
		return 0;

	copy = alloca(strlen(value) + 1);
	strcpy(copy, value);
	
	while ((str1 = new_next_arg(copy, &copy)))
	{
		while (*str1 && (str2 = next_in_comma_list(str1, &str1)))
		{
			if (!my_strnicmp(str2, "ALL", 3))
				nvalue = (0x7F - (DEBUG_TCL));
			else if (!my_strnicmp(str2, "-ALL", 4))
				nvalue = 0;
			else if (!my_strnicmp(str2, "COMMANDS", 4))
				nvalue |= DEBUG_COMMANDS;
			else if (!my_strnicmp(str2, "-COMMANDS", 4))
				nvalue &= ~(DEBUG_COMMANDS);
			else if (!my_strnicmp(str2, "EXPANSIONS", 4))
				nvalue |= DEBUG_EXPANSIONS;
			else if (!my_strnicmp(str2, "-EXPANSIONS", 4))
				nvalue &= ~(DEBUG_EXPANSIONS);
			else if (!my_strnicmp(str2, "TCL", 3))
				nvalue |= DEBUG_TCL;
			else if (!my_strnicmp(str2, "-TCL", 3))
				nvalue &= ~(DEBUG_TCL);
			else if (!my_strnicmp(str2, "ALIAS", 3))
				nvalue |= DEBUG_CMDALIAS;
			else if (!my_strnicmp(str2, "-ALIAS", 3))
				nvalue &= ~(DEBUG_CMDALIAS);
			else if (!my_strnicmp(str2, "HOOK", 3))
				nvalue |= DEBUG_HOOK;
			else if (!my_strnicmp(str2, "-HOOK", 3))
				nvalue &= ~(DEBUG_HOOK);
			else if (!my_strnicmp(str2, "VARIABLES", 3))
				nvalue |= DEBUG_VARIABLE;
			else if (!my_strnicmp(str2, "-VARIABLES", 3))
				nvalue &= ~(DEBUG_VARIABLE);
			else if (!my_strnicmp(str2, "FUNCTIONS", 3))
				nvalue |= DEBUG_FUNC;
			else if (!my_strnicmp(str2, "-FUNCTIONS", 3))
				nvalue &= ~(DEBUG_FUNC);
			else if (!my_strnicmp(str2, "STRUCTURES", 3))
				nvalue |= DEBUG_STRUCTURES;
			else if (!my_strnicmp(str2, "-STRUCTURES", 3))
				nvalue &= ~(DEBUG_STRUCTURES);
		}
	}
	if (rv)
	{
		if (nvalue & DEBUG_COMMANDS)
			m_s3cat(&nv, comma, "COMMANDS");
		if (nvalue & DEBUG_EXPANSIONS)
			m_s3cat(&nv, comma, "EXPANSIONS");
		if (nvalue & DEBUG_TCL)
			m_s3cat(&nv, comma, "TCL");
		if (nvalue & DEBUG_CMDALIAS)
			m_s3cat(&nv, comma, "ALIAS");
		if (nvalue & DEBUG_HOOK)
			m_s3cat(&nv, comma, "HOOK");
		if (nvalue & DEBUG_VARIABLE)
			m_s3cat(&nv, comma, "VARIABLES");
		if (nvalue & DEBUG_FUNC)
			m_s3cat(&nv, comma, "FUNCTIONS");
		if (nvalue & DEBUG_STRUCTURES)
			m_s3cat(&nv, comma, "STRUCTURES");
		*rv = nv;
	}
	return nvalue;
}