{ Configuration miscdata(datadir + "u7misc.data", "misc");  Configuration::KeyTypeList om; miscdata.getsubkeys(om, "misc/offset_munge");  Configuration::KeyTypeList st; miscdata.getsubkeys(st, "misc/size_type");   for(typeof(st.begin()) k=st.begin(); k!=st.end(); ++k) { bool munge_offset=false;   for(typeof(om.begin()) m=om.begin(); m!=om.end(); ++m) if(m->first.size()-1==k->first.size()) if(m->first.compare(0, m->first.size()-1, k->first, 0, k->first.size())==0) munge_offset=true;   pair<unsigned int, bool> tsm_tmp(strtol(k->second.c_str(), 0, 0), munge_offset); type_size_map.insert(pair<string, pair<unsigned int, bool> >(k->first, tsm_tmp)); } }
init_misc(datadir);
void init_usecodetables(const Configuration &config, const UCOptions &options){	const string datadir(get_datadir(config, options));		{		Configuration miscdata(datadir + "u7misc.data", "misc");			Configuration::KeyTypeList om;		miscdata.getsubkeys(om, "misc/offset_munge");				Configuration::KeyTypeList st;		miscdata.getsubkeys(st, "misc/size_type");				// For each size type (small/long/byte/etc.)		for(typeof(st.begin()) k=st.begin(); k!=st.end(); ++k)		{			bool munge_offset=false;						/* ... we need to find out if we should munge it's parameter				that is, it's some sort of goto target (like offset) or such */			for(typeof(om.begin()) m=om.begin(); m!=om.end(); ++m)				if(m->first.size()-1==k->first.size())					if(m->first.compare(0, m->first.size()-1, k->first, 0, k->first.size())==0)						munge_offset=true;						// once we've got it, add it to the map			pair<unsigned int, bool> tsm_tmp(strtol(k->second.c_str(), 0, 0), munge_offset);			type_size_map.insert(pair<string, pair<unsigned int, bool> >(k->first, tsm_tmp));		}	}		Configuration opdata(datadir + "u7opcodes.data", "opcodes");		vector<string> keys = opdata.listkeys("opcodes");			#if 1	for(vector<string>::iterator key=keys.begin(); key!=keys.end(); ++key)	{		if((*key)[0]!='!')		{			Configuration::KeyTypeList ktl;					opdata.getsubkeys(ktl, *key);					if(ktl.size())			{				unsigned int i = strtol(key->substr(key->find_first_of("0")).c_str(), 0, 0);				opcode_table_data[i] = UCOpcodeData(i, ktl);			}		}	}		#else		string ucxtroot(datadir + "opcodes.txt");	std::ifstream file;	try	{		U7open(file, ucxtroot.c_str(), true);	} catch (const file_open_exception& e)	{		cerr << e.what() << ". exiting." << endl;		exit(1);	}		std::string s;	while(!file.eof())	{		getline(file, s);		if(s.size() && s[0]=='>')		{			UCOpcodeData uco(str2vec(s));			assert(uco.opcode<MAX_NO_OPCODES);			opcode_table_data[uco.opcode] = uco;		}		}	file.close();	#endif		/* Create an {opcode, parameter_index} array of all opcodes that		execute a 'jump' statement */	for(std::vector<UCOpcodeData>::iterator op=opcode_table_data.begin(); op!=opcode_table_data.end(); op++)	{		for(unsigned int i=0; i<op->param_sizes.size(); i++)		{			if(op->param_sizes[i].second==true) // this is a calculated offset			{				opcode_jumps.push_back(std::pair<unsigned int, unsigned int>(op->opcode, i+1)); // parameters are stored as base 1			}		}	}		#if 0	std::cout << "Calculated Opcode pairs:" << std::endl;	for(std::vector<std::pair<unsigned int, unsigned int> >::iterator i=opcode_jumps.begin(); i!=opcode_jumps.end(); i++)		std::cout << setw(4) << i->first << '\t' << setw(4) << i->second << std::endl;	#endif}