예제 #1
0
파일: log.c 프로젝트: Insswer/rathena
int log_config_read(const char* cfgName)
{
	static int count = 0;
	char line[1024], w1[1024], w2[1024];
	FILE *fp;

	if( count++ == 0 )
		log_set_defaults();

	if( ( fp = fopen(cfgName, "r") ) == NULL )
	{
		ShowError("Log configuration file not found at: %s\n", cfgName);
		return 1;
	}

	while( fgets(line, sizeof(line), fp) )
	{
		if( line[0] == '/' && line[1] == '/' )
			continue;

		if( sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) == 2 )
		{
			if( strcmpi(w1, "enable_logs") == 0 )
				log_config.enable_logs = (e_log_pick_type)config_switch(w2);
			else if( strcmpi(w1, "sql_logs") == 0 )
				log_config.sql_logs = (bool)config_switch(w2);
//start of common filter settings
			else if( strcmpi(w1, "rare_items_log") == 0 )
				log_config.rare_items_log = atoi(w2);
			else if( strcmpi(w1, "refine_items_log") == 0 )
				log_config.refine_items_log = atoi(w2);
			else if( strcmpi(w1, "price_items_log") == 0 )
				log_config.price_items_log = atoi(w2);
			else if( strcmpi(w1, "amount_items_log") == 0 )
				log_config.amount_items_log = atoi(w2);
//end of common filter settings
			else if( strcmpi(w1, "log_branch") == 0 )
				log_config.branch = config_switch(w2);
			else if( strcmpi(w1, "log_filter") == 0 )
				log_config.filter = config_switch(w2);
			else if( strcmpi(w1, "log_zeny") == 0 )
				log_config.zeny = config_switch(w2);
			else if( strcmpi( w1, "log_cash" ) == 0 )
				log_config.cash = config_switch( w2 );
			else if( strcmpi(w1, "log_commands") == 0 )
				log_config.commands = config_switch(w2);
			else if( strcmpi(w1, "log_npc") == 0 )
				log_config.npc = config_switch(w2);
			else if( strcmpi(w1, "log_chat") == 0 )
				log_config.chat = config_switch(w2);
			else if( strcmpi(w1, "log_mvpdrop") == 0 )
				log_config.mvpdrop = config_switch(w2);
			else if( strcmpi(w1, "log_chat_woe_disable") == 0 )
				log_config.log_chat_woe_disable = (bool)config_switch(w2);
			else if( strcmpi(w1, "log_branch_db") == 0 )
				safestrncpy(log_config.log_branch, w2, sizeof(log_config.log_branch));
			else if( strcmpi(w1, "log_pick_db") == 0 )
				safestrncpy(log_config.log_pick, w2, sizeof(log_config.log_pick));
			else if( strcmpi(w1, "log_zeny_db") == 0 )
				safestrncpy(log_config.log_zeny, w2, sizeof(log_config.log_zeny));
			else if( strcmpi(w1, "log_mvpdrop_db") == 0 )
				safestrncpy(log_config.log_mvpdrop, w2, sizeof(log_config.log_mvpdrop));
			else if( strcmpi(w1, "log_gm_db") == 0 )
				safestrncpy(log_config.log_gm, w2, sizeof(log_config.log_gm));
			else if( strcmpi(w1, "log_npc_db") == 0 )
				safestrncpy(log_config.log_npc, w2, sizeof(log_config.log_npc));
			else if( strcmpi(w1, "log_chat_db") == 0 )
				safestrncpy(log_config.log_chat, w2, sizeof(log_config.log_chat));
			else if( strcmpi( w1, "log_cash_db" ) == 0 )
				safestrncpy( log_config.log_cash, w2, sizeof( log_config.log_cash ) );
			//support the import command, just like any other config
			else if( strcmpi(w1,"import") == 0 )
				log_config_read(w2);
			else
				ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
		}
	}

	fclose(fp);

	if( --count == 0 )
	{// report final logging state
		const char* target = log_config.sql_logs ? "table" : "file";

		if( log_config.enable_logs && log_config.filter )
		{
			ShowInfo("Logging item transactions to %s '%s'.\n", target, log_config.log_pick);
		}
		if( log_config.branch )
		{
			ShowInfo("Logging monster summon item usage to %s '%s'.\n", target, log_config.log_pick);
		}
		if( log_config.chat )
		{
			ShowInfo("Logging chat to %s '%s'.\n", target, log_config.log_chat);
		}
		if( log_config.commands )
		{
			ShowInfo("Logging commands to %s '%s'.\n", target, log_config.log_gm);
		}
		if( log_config.mvpdrop )
		{
			ShowInfo("Logging MVP monster rewards to %s '%s'.\n", target, log_config.log_mvpdrop);
		}
		if( log_config.npc )
		{
			ShowInfo("Logging 'logmes' messages to %s '%s'.\n", target, log_config.log_npc);
		}
		if( log_config.zeny )
		{
			ShowInfo("Logging Zeny transactions to %s '%s'.\n", target, log_config.log_zeny);
		}
		if( log_config.cash ){
			ShowInfo( "Logging Cash transactions to %s '%s'.\n", target, log_config.log_cash );
		}
	}

	return 0;
}
예제 #2
0
int log_config_read(char *cfgName)
{
    static int count = 0;
    char line[1024], w1[1024], w2[1024];
    FILE *fp;

    if ((count++) == 0)
        log_set_defaults();

    if((fp = fopen(cfgName, "r")) == NULL)
    {
        ShowError("Arquivo de configuracao de Log nao encontrado: %s\n", cfgName);
        return 1;
    }

    while(fgets(line, sizeof(line), fp))
    {
        if(line[0] == '/' && line[1] == '/')
            continue;

        if(sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2)
        {
            if(strcmpi(w1,"enable_logs") == 0) {
                log_config.enable_logs = (log_what)atoi(w2);
                if (log_config.enable_logs&1) //Log everything.
                    log_config.enable_logs = LOG_ALL;
            } else if(strcmpi(w1,"sql_logs") == 0) {
                log_config.sql_logs = (bool)atoi(w2);
//start of common filter settings
            } else if(strcmpi(w1,"rare_items_log") == 0) {
                log_config.rare_items_log = (atoi(w2));
            } else if(strcmpi(w1,"refine_items_log") == 0) {
                log_config.refine_items_log = (atoi(w2));
            } else if(strcmpi(w1,"price_items_log") == 0) {
                log_config.price_items_log = (atoi(w2));
            } else if(strcmpi(w1,"amount_items_log") == 0) {
                log_config.amount_items_log = (atoi(w2));
//end of common filter settings
            } else if(strcmpi(w1,"log_branch") == 0) {
                log_config.branch = (atoi(w2));
            } else if(strcmpi(w1,"log_filter") == 0) {
                log_config.filter = (atoi(w2));
            } else if(strcmpi(w1,"log_zeny") == 0) {
                log_config.zeny = (atoi(w2));
            } else if(strcmpi(w1,"log_gm") == 0) {
                log_config.gm = (atoi(w2));
            } else if(strcmpi(w1,"log_npc") == 0) {
                log_config.npc = (atoi(w2));
            } else if(strcmpi(w1, "log_chat") == 0) {
                log_config.chat = (atoi(w2));
            } else if(strcmpi(w1,"log_mvpdrop") == 0) {
                log_config.mvpdrop = (atoi(w2));
            }
            else if(strcmpi(w1, "log_branch_db") == 0) {
                strcpy(log_config.log_branch_db, w2);
                if(log_config.branch == 1)
                    ShowNotice("Armazenando relatorio de uso de Galho Seco na tabela `%s`\n", w2);
            } else if(strcmpi(w1, "log_pick_db") == 0) {
                strcpy(log_config.log_pick_db, w2);
                if(log_config.filter)
                    ShowNotice("Armazenando relatorio de itens pegos na tabela `%s`\n", w2);
            } else if(strcmpi(w1, "log_zeny_db") == 0) {
                strcpy(log_config.log_zeny_db, w2);
                if(log_config.zeny == 1)
                    ShowNotice("Armazenando relatorio de Zeny na tabela `%s`\n", w2);
            } else if(strcmpi(w1, "log_mvpdrop_db") == 0) {
                strcpy(log_config.log_mvpdrop_db, w2);
                if(log_config.mvpdrop == 1)
                    ShowNotice("Armazenando relatorio de drops de MVPs na tabela `%s`\n", w2);
            } else if(strcmpi(w1, "log_gm_db") == 0) {
                strcpy(log_config.log_gm_db, w2);
                if(log_config.gm > 0)
                    ShowNotice("Armazenando relatorio de uso comandos GM nivel %d na tabela `%s`\n", log_config.gm, w2);
            } else if(strcmpi(w1, "log_npc_db") == 0) {
                strcpy(log_config.log_npc_db, w2);
                if(log_config.npc > 0)
                    ShowNotice("Armazenando relatorio de 'logmes' dos NPCs na tabela `%s`\n", w2);
            } else if(strcmpi(w1, "log_chat_db") == 0) {
                strcpy(log_config.log_chat_db, w2);
                if(log_config.chat > 0)
                    ShowNotice("Armazenando relatorio de mensagens na tabela `%s`\n", w2);
            }

            else if(strcmpi(w1, "log_branch_file") == 0) {
                strcpy(log_config.log_branch, w2);
                if(log_config.branch > 0 && !log_config.sql_logs)
                    ShowNotice("Armazenando relatorio de uso de Galho Seco no arquivo `%s`\n", w2);
            } else if(strcmpi(w1, "log_pick_file") == 0) {
                strcpy(log_config.log_pick, w2);
                if(log_config.filter > 0 && !log_config.sql_logs)
                    ShowNotice("Armazenando relatorio de itens pegos no arquivo `%s`\n", w2);
            } else if(strcmpi(w1, "log_zeny_file") == 0) {
                strcpy(log_config.log_zeny, w2);
                if(log_config.zeny > 0 && !log_config.sql_logs)
                    ShowNotice("Armazenando relatorio de Zeny no arquivo `%s`\n", w2);
            } else if(strcmpi(w1, "log_mvpdrop_file") == 0) {
                strcpy(log_config.log_mvpdrop, w2);
                if(log_config.mvpdrop > 0 && !log_config.sql_logs)
                    ShowNotice("Armazenando relatorio de drops de MVPs no arquivo `%s`\n", w2);
            } else if(strcmpi(w1, "log_gm_file") == 0) {
                strcpy(log_config.log_gm, w2);
                if(log_config.gm > 0 && !log_config.sql_logs)
                    ShowNotice("Armazenando relatorio de uso comandos GM nivel %d no arquivo `%s`\n", log_config.gm, w2);
            } else if(strcmpi(w1, "log_npc_file") == 0) {
                strcpy(log_config.log_npc, w2);
                if(log_config.npc > 0 && !log_config.sql_logs)
                    ShowNotice("Armazenando relatorio de 'logmes' dos NPCs no arquivo `%s`\n", w2);
            } else if(strcmpi(w1, "log_chat_file") == 0) {
                strcpy(log_config.log_chat, w2);
                if(log_config.chat > 0 && !log_config.sql_logs)
                    ShowNotice("Armazenando relatorio de Mensagens no arquivo `%s`\n", w2);
                //support the import command, just like any other config
            } else if(strcmpi(w1,"import") == 0) {
                log_config_read(w2);
            }
        }
    }

    fclose(fp);
    return 0;
}
예제 #3
0
파일: log.c 프로젝트: dbrocom/syncragnarok
int log_config_read(char *cfgName)
{
	static int count = 0;
	char line[1024], w1[1024], w2[1024];
	FILE *fp;

	if ((count++) == 0)
		log_set_defaults();		

	if((fp = fopen(cfgName, "r")) == NULL)
	{
		ShowError("Log configuration file not found at: %s\n", cfgName);
		return 1;
	}	

	while(fgets(line, sizeof(line), fp))
	{
		if(line[0] == '/' && line[1] == '/')
			continue;

		if(sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2)
		{
			if(strcmpi(w1,"enable_logs") == 0) {
				log_config.enable_logs = (log_what)atoi(w2);
				if (log_config.enable_logs&1) //Log everything.
					log_config.enable_logs = LOG_ALL;
			} else if(strcmpi(w1,"sql_logs") == 0) {
				log_config.sql_logs = (bool)atoi(w2);
//start of common filter settings
			} else if(strcmpi(w1,"rare_items_log") == 0) {
				log_config.rare_items_log = (atoi(w2));
			} else if(strcmpi(w1,"refine_items_log") == 0) {
				log_config.refine_items_log = (atoi(w2));
			} else if(strcmpi(w1,"price_items_log") == 0) {
				log_config.price_items_log = (atoi(w2));
			} else if(strcmpi(w1,"amount_items_log") == 0) {
				log_config.amount_items_log = (atoi(w2));
//end of common filter settings
			} else if(strcmpi(w1,"log_branch") == 0) {
				log_config.branch = (atoi(w2));
			} else if(strcmpi(w1,"log_filter") == 0) {
				log_config.filter = (atoi(w2));
			} else if(strcmpi(w1,"log_zeny") == 0) {
				log_config.zeny = (atoi(w2));
			} else if(strcmpi(w1,"log_gm") == 0) {
				log_config.gm = (atoi(w2));
			} else if(strcmpi(w1,"log_npc") == 0) {
				log_config.npc = (atoi(w2));
			} else if(strcmpi(w1, "log_chat") == 0) {
				log_config.chat = (atoi(w2));
			} else if(strcmpi(w1,"log_mvpdrop") == 0) {
				log_config.mvpdrop = (atoi(w2));
			}

#ifndef TXT_ONLY
			else if(strcmpi(w1, "log_branch_db") == 0) {
				strcpy(log_config.log_branch_db, w2);
				if(log_config.branch == 1)
					ShowNotice("Logging Dead Branch Usage to table `%s`\n", w2);
			} else if(strcmpi(w1, "log_pick_db") == 0) {
				strcpy(log_config.log_pick_db, w2);
				if(log_config.filter)
					ShowNotice("Logging Item Picks to table `%s`\n", w2);
			} else if(strcmpi(w1, "log_zeny_db") == 0) {
				strcpy(log_config.log_zeny_db, w2);
				if(log_config.zeny == 1)
					ShowNotice("Logging Zeny to table `%s`\n", w2);
			} else if(strcmpi(w1, "log_mvpdrop_db") == 0) {
				strcpy(log_config.log_mvpdrop_db, w2);
				if(log_config.mvpdrop == 1)
					ShowNotice("Logging MVP Drops to table `%s`\n", w2);
			} else if(strcmpi(w1, "log_gm_db") == 0) {
				strcpy(log_config.log_gm_db, w2);
				if(log_config.gm > 0)
					ShowNotice("Logging GM Level %d Commands to table `%s`\n", log_config.gm, w2);
			} else if(strcmpi(w1, "log_npc_db") == 0) {
				strcpy(log_config.log_npc_db, w2);
				if(log_config.npc > 0)
					ShowNotice("Logging NPC 'logmes' to table `%s`\n", w2);
			} else if(strcmpi(w1, "log_chat_db") == 0) {
				strcpy(log_config.log_chat_db, w2);
				if(log_config.chat > 0)
					ShowNotice("Logging CHAT to table `%s`\n", w2);
			}
#endif

			else if(strcmpi(w1, "log_branch_file") == 0) {
				strcpy(log_config.log_branch, w2);
				if(log_config.branch > 0 && !log_config.sql_logs)
					ShowNotice("Logging Dead Branch Usage to file `%s`\n", w2);
			} else if(strcmpi(w1, "log_pick_file") == 0) {
				strcpy(log_config.log_pick, w2);
				if(log_config.filter > 0 && !log_config.sql_logs)
					ShowNotice("Logging Item Picks to file `%s`\n", w2);
			} else if(strcmpi(w1, "log_zeny_file") == 0) {
				strcpy(log_config.log_zeny, w2);
				if(log_config.zeny > 0 && !log_config.sql_logs)
					ShowNotice("Logging Zeny to file `%s`\n", w2);
			} else if(strcmpi(w1, "log_mvpdrop_file") == 0) {
				strcpy(log_config.log_mvpdrop, w2);
				if(log_config.mvpdrop > 0 && !log_config.sql_logs)
					ShowNotice("Logging MVP Drops to file `%s`\n", w2);
			} else if(strcmpi(w1, "log_gm_file") == 0) {
				strcpy(log_config.log_gm, w2);
				if(log_config.gm > 0 && !log_config.sql_logs)
					ShowNotice("Logging GM Level %d Commands to file `%s`\n", log_config.gm, w2);
			} else if(strcmpi(w1, "log_npc_file") == 0) {
				strcpy(log_config.log_npc, w2);
				if(log_config.npc > 0 && !log_config.sql_logs)
					ShowNotice("Logging NPC 'logmes' to file `%s`\n", w2);
			} else if(strcmpi(w1, "log_chat_file") == 0) {
				strcpy(log_config.log_chat, w2);
				if(log_config.chat > 0 && !log_config.sql_logs)					
					ShowNotice("Logging CHAT to file `%s`\n", w2);
			//support the import command, just like any other config
			} else if(strcmpi(w1,"import") == 0) {
				log_config_read(w2);
			}
		}
	}

	fclose(fp);
	return 0;
}
예제 #4
0
파일: log.c 프로젝트: Gubio/brAthena
int log_config_read(const char* cfgName) {
	static int count = 0;
	char line[1024], w1[1024], w2[1024];
	FILE *fp;

	if( count++ == 0 )
		log_set_defaults();

	if( ( fp = fopen(cfgName, "r") ) == NULL ) {
		ShowError("Log: Arquivo nao encontrado %s\n", cfgName);
		return 1;
	}

	while (fgets(line, sizeof(line), fp)) {
		if (line[0] == '/' && line[1] == '/')
			continue;

		if (sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) == 2) {
			if( strcmpi(w1, "enable_logs") == 0 )
				logs->enable_logs = (bool)config_switch(w2);
			else if( strcmpi(w1, "sql_logs") == 0 )
				logs->config.sql_logs = (bool)config_switch(w2);
//start of common filter settings
			else if( strcmpi(w1, "rare_items_log") == 0 )
				logs->config.rare_items_log = atoi(w2);
			else if( strcmpi(w1, "refine_items_log") == 0 )
				logs->config.refine_items_log = atoi(w2);
			else if( strcmpi(w1, "price_items_log") == 0 )
				logs->config.price_items_log = atoi(w2);
			else if( strcmpi(w1, "amount_items_log") == 0 )
				logs->config.amount_items_log = atoi(w2);
//end of common filter settings
			else if( strcmpi(w1, "log_branch") == 0 )
				logs->config.branch = config_switch(w2);
			else if( strcmpi(w1, "log_filter") == 0 )
				logs->config.filter = config_switch(w2);
			else if( strcmpi(w1, "log_zeny") == 0 )
				logs->config.zeny = config_switch(w2);
			else if( strcmpi(w1, "log_commands") == 0 )
				logs->config.commands = config_switch(w2);
			else if( strcmpi(w1, "log_npc") == 0 )
				logs->config.npc = config_switch(w2);
			else if( strcmpi(w1, "log_chat") == 0 )
				logs->config.chat = config_switch(w2);
			else if( strcmpi(w1, "log_mvpdrop") == 0 )
				logs->config.mvpdrop = config_switch(w2);
			else if( strcmpi(w1, "log_chat_woe_disable") == 0 )
				logs->config.log_chat_woe_disable = (bool)config_switch(w2);
			else if( strcmpi(w1, "log_branch_db") == 0 )
				safestrncpy(logs->config.log_branch, w2, sizeof(logs->config.log_branch));
			else if( strcmpi(w1, "log_pick_db") == 0 )
				safestrncpy(logs->config.log_pick, w2, sizeof(logs->config.log_pick));
			else if( strcmpi(w1, "log_zeny_db") == 0 )
				safestrncpy(logs->config.log_zeny, w2, sizeof(logs->config.log_zeny));
			else if( strcmpi(w1, "log_mvpdrop_db") == 0 )
				safestrncpy(logs->config.log_mvpdrop, w2, sizeof(logs->config.log_mvpdrop));
			else if( strcmpi(w1, "log_gm_db") == 0 )
				safestrncpy(logs->config.log_gm, w2, sizeof(logs->config.log_gm));
			else if( strcmpi(w1, "log_npc_db") == 0 )
				safestrncpy(logs->config.log_npc, w2, sizeof(logs->config.log_npc));
			else if( strcmpi(w1, "log_chat_db") == 0 )
				safestrncpy(logs->config.log_chat, w2, sizeof(logs->config.log_chat));
			
			else if( strcmpi(w1, "log_cards") == 0 )
				logs->config.cards = config_switch(w2);
			else if( strcmpi(w1, "log_buyingstore") == 0 )
				logs->config.buyingstore = config_switch(w2);
			else if( strcmpi(w1, "log_vending") == 0 )
				logs->config.vending = config_switch(w2);
			else if( strcmpi(w1, "log_consume") == 0 )
				logs->config.consume = config_switch(w2);
			else if( strcmpi(w1, "log_mob_pick_drop") == 0 )
				logs->config.mob_pick_drop = config_switch(w2);	
			else if( strcmpi(w1, "log_pc_pick_drop") == 0 )
				logs->config.pc_pick_drop = config_switch(w2);	
			else if( strcmpi(w1, "log_npc_buy_sell") == 0 )
				logs->config.npc_buy_sell = config_switch(w2);
			else if( strcmpi(w1, "log_produce") == 0 )
				logs->config.produce = config_switch(w2);	
			else if( strcmpi(w1, "log_storage") == 0 )
				logs->config.storage = config_switch(w2);	
			else if( strcmpi(w1, "log_gstorage") == 0 )
				logs->config.gstorage = config_switch(w2);	
			else if( strcmpi(w1, "log_get_remove_item") == 0 )
				logs->config.get_rem_item = config_switch(w2);	
			else if( strcmpi(w1, "log_mail") == 0 )
				logs->config.mail = config_switch(w2);
			else if( strcmpi(w1, "log_trade") == 0 )
				logs->config.trade = config_switch(w2);	
			else if( strcmpi(w1, "log_buycash") == 0 )
				logs->config.buycash = config_switch(w2);			
			//support the import command, just like any other config
			else if( strcmpi(w1,"import") == 0 )
				logs->config_read(w2);
			else
				ShowWarning("Opcao desconhecida '%s' no arquivo %s\n", w1, cfgName);
		}
	}

	fclose(fp);

	if( --count == 0 ) {// report final logging state
		const char* target = logs->config.sql_logs ? "table" : "file";

		if( logs->enable_logs && logs->config.filter ) {
			ShowInfo("Registrando transacoes de itens para %s '%s'.\n", target, logs->config.log_pick);
		}
		if( logs->config.branch ) {
			ShowInfo("Registrando invocacoes de monstros para %s '%s'.\n", target, logs->config.log_pick);
		}
		if( logs->config.chat ) {
			ShowInfo("Registrando chat para %s '%s'.\n", target, logs->config.log_chat);
		}
		if( logs->config.commands ) {
			ShowInfo("Registrando comandos para %s '%s'.\n", target, logs->config.log_gm);
		}
		if( logs->config.mvpdrop ) {
			ShowInfo("Registrando drop de MVPs para %s '%s'.\n", target, logs->config.log_mvpdrop);
		}
		if( logs->config.npc ) {
			ShowInfo("Registrando 'logmes' mensagens para %s '%s'.\n", target, logs->config.log_npc);
		}
		if( logs->config.zeny ) {
			ShowInfo("Registrando transacoes de Zeny para %s '%s'.\n", target, logs->config.log_zeny);
		}
		logs->config_done();
	}

	return 0;
}