Пример #1
0
/* initialize all options at startup */
static void debug_init(void)
{
	char *tgmlog_debug;
	char *tgmlog_conf_file;
	
	//env TGMLOGDEBUG
	if (nb_debug_options != -1) return;  /* already initialized */
	nb_debug_options = 0;
	if ((tgmlog_debug = getenv("TGMLOGDEBUG")))
	{
		if (!strcmp( tgmlog_debug, "help" )) debug_usage();
		parse_options( tgmlog_debug );
	}
	
	//env TGMLOGDEBUG_FORMAT
	tgmlog_dbg_header_format_set(getenv("TGMLOGDEBUG_FORMAT")?getenv("TGMLOGDEBUG_FORMAT"):default_header_format);

	//env TGMLOGDEBUG_CONFFILE
	if ((tgmlog_conf_file = getenv("TGMLOGDEBUG")))
	{
		//todo ...
		//parse_options_file( tgmlog_conf_file );
	}

}
Пример #2
0
void netdebug(int argc, char **argv)
{
	int noblock = 0;
	int clear = 0;
	unsigned int debug = 0;

	do {
		argc--;
		if (strcmp(argv[argc], "-n") == 0)
			noblock = 1;
		else if (strcmp(argv[argc], "-c") == 0)
			clear = 1;
		else if (strcmp(argv[argc], "dev") == 0)
			debug |= NET_DEBUG_DEV;
		else if (strcmp(argv[argc], "l2") == 0)
			debug |= NET_DEBUG_L2;
		else if (strcmp(argv[argc], "arp") == 0)
			debug |= NET_DEBUG_ARP;
		else if (strcmp(argv[argc], "ip") == 0)
			debug |= NET_DEBUG_IP;
		else if (strcmp(argv[argc], "icmp") == 0)
			debug |= NET_DEBUG_ICMP;
		else if (strcmp(argv[argc], "udp") == 0)
			debug |= NET_DEBUG_UDP;
		else if (strcmp(argv[argc], "tcp") == 0)
			debug |= NET_DEBUG_TCP;
		else if (strcmp(argv[argc], "tcpstate") == 0)
			debug |= NET_DEBUG_TCPSTATE;
		else if (strcmp(argv[argc], "all") == 0)
			debug |= NET_DEBUG_ALL;
		else
			return debug_usage();
	} while (argc > 1);

	/* clear debug flags */
	if (clear) {
		if (debug)
			net_debug &= ~debug;
		else
			net_debug = 0;
		return;
	}

	net_debug |= debug;
	if (noblock)
		return;
	/* block mode */
	ferr("enter ^C to exit debug mode\n");
	/* waiting for interrupt signal */
	signal_wait(SIGQUIT);
	net_debug = 0;
	ferr("\nexit debug mode\n");
}