Beispiel #1
0
ERRCODE Config::save()
{
    std::ofstream configfile;
    std::string setcategory( "Global" ), item, category;
    dictionaryiterator itemiterator;

    if( !isloaded()) returncode( OZ_INI_NO_DICT );

    configfile.open( m_configfilename.c_str());
    if( !configfile.is_open()) returncode( OZ_INI_FAILED_TO_WRITE );

    for( itemiterator = m_dictionary.begin(); itemiterator != 
            m_dictionary.end(); ++itemiterator ) {
        if( splitkey( itemiterator->first, category, item )) {
            if( setcategory != category ) {
                setcategory = category;
                configfile << "[" << category << "]" << std::endl;
            }
            configfile << item << " = " << itemiterator->second << "\n";
            
        } else {
            configfile << itemiterator->first << " = " << 
                itemiterator->second << std::endl;
        }
    }

    configfile.close();
    returncode( OZ_OK );
}
Beispiel #2
0
void anlize(const char *buf, int bufsize, callback deal, void *parm)
{
	int sign = 0;
	const char *bptr = buf;

	while(buf && *buf && buf-bptr <= bufsize)
	{
		char mark[2048] = {0};
		char name[2048];
		char attib[2048];
		char value[2048];

		const char * pstart = mark;
		const char * pend   = mark;
		const char * markend= 0;

		anlizetextbtw(buf, deal, parm);
		anlizemark(mark, 2048, &buf, buf);
		
		if(isnote(mark) > 0)
			continue;
		
		getkey(name, 2048, &pend, pstart);
		if(strlen(name) == 0)
			break;

		deal(MARK_KEY, name, strlen(name), parm);

		while(pend-mark < strlen(mark))
		{
			char tmpatt[2048];
			pstart = pend+1;
			getkey(tmpatt, 2048, &pend, pstart);

			if(splitkey(attib, 2048, value, 2048, 0, tmpatt))
			{
				strcpy(&attib[strlen(attib)+1], value);
				deal(MARK_ATT, attib, strlen(attib)+strlen(value)+1, parm);
			}
			else
				break;
			
			if(pend == 0)
				break;
		}

		markend = anlizetext(name, buf, deal, parm);
		strtolower(name, name);	
		if(!strcmp(name, "script"))
			buf = markend;
	}
}