Example #1
0
bool NDLocalXmlString::parseLines( vector<string>& vecLines )
{
	if (vecLines.size() < 2) return false;
	m_kMapData.clear();

	bool bOK = true;
	int index = 0;
	while (index < vecLines.size() - 1)
	{
		const string& keyLine = vecLines[ index ];
		const string& valLine = vecLines[ index + 1 ];

		if (isKey(keyLine.c_str()) && isVal(valLine.c_str()))
		{
			index += 2;

			bOK &= addKeyValue( keyLine, valLine );
		}
		else
		{
			index++;

			//bad line!
			logErr( keyLine, valLine );
			bOK = false;
		}
	}

	return bOK;
}
Example #2
0
void CIniFile::parse ( void )
{
	const char *cgroup = "";
	char *eol, *key, *cvalue, *line, *pos, *current;
	int cline = 0;
	
	current = content;
	while (current && *current) {
		++cline;
		line = current;
		if ((current = strchr(line, '\n'))) {
			if (*(current - 1) == '\r') --current;
			*current = '\0';
			++current;
		}
		// clear right blanks
		eol = line + strlen(line);
		eol = line + strlen(line);
		while (eol > line && (*(eol-1) == '\t' || *(eol-1) == ' ')) --eol;
		*eol = '\0';

		// check if a comment line
		if (strchr(";/#", *line)) continue;
		
		// ignore left blanks
		while (*line == ' ' || *line == '\t') ++line;
		
		// check if empty line
		if (*line == '\0') continue;
		
		if (*line == '[') {
			// group
			pos = strchr(line, ']');
			if (!pos) exit(-2);
			*pos = '\0';
			cgroup = (line+1);
			continue;
		}
		pos = strchr(line, '=');
		
		if (!pos) exit(-3); 	
		key = line;
		
		cvalue = pos + 1;
		while (pos > line && (*(pos-1) == ' ' || *(pos-1) == '\t')) --pos;
		*pos = '\0';
	
		while (*cvalue == ' ' || *cvalue == '\t') ++cvalue;
		
		if (*cvalue == '\"' || *cvalue == '"') {
			char cquota = *cvalue;
			++cvalue;
			pos = strchr(cvalue, cquota);
			if (pos) *pos = 0;
			// buscar final de cadena y poner el '\0', siempre que no se escape la misma
		}
		addKeyValue(cgroup, key, cvalue);
	}
}
Example #3
0
// ----------------------------------------------------------------------------
//
void FixtureChannelField::setFixture( Fixture *fixture ) {
    for ( channel_t index=0; index < fixture->getNumChannels(); index++ )
        addKeyValue( index+1, fixture->getChannel(index)->getName() );

    if ( fixture->getChannel( m_channel ) == NULL )
        m_channel = 0;

    setDefaultListValue( m_channel+1 );
}
Example #4
0
// ----------------------------------------------------------------------------
//
AnimationSelectField::AnimationSelectField( LPCSTR field_label ) :
        NumberedListField( field_label )
{
    for ( unsigned index=0; index < DMXTextUI::animEditors.size(); index++ ) {
        AnimationEditor& editor = DMXTextUI::animEditors[index];
        CString label;
        addKeyValue( index+1, editor.m_name );
    }

    setDefaultListValue( 1 );
}
Example #5
0
// ----------------------------------------------------------------------------
//
void SceneAnimationSelectField::selectAnimations( Scene* scene ) 
{
    m_animations = scene->animations();

    for ( unsigned index=0; index < m_animations.size(); index++ ) {
        AbstractAnimation* animation = m_animations[index];
        CString label;
        label.Format( "%s (ID=%lu)", animation->getName(), animation->getUID() );
        addKeyValue( index+1, (LPCSTR)label );
    }

    setDefaultListValue( 1 );
}
Example #6
0
ScenarioInfo::ScenarioInfo(string filename)
{
    this->filename = filename;
    name = filename.substr(9, -4);

    P<ResourceStream> stream = getResourceStream(filename);
    if (!stream) return;

    string key;
    string value;
    while(stream->tell() < stream->getSize())
    {
        string line = stream->readLine().strip();
        // Get the scenario meta-data.
        if (!line.startswith("--"))
            break;
        if (line.startswith("---"))
        {
            line = line.substr(3).strip();
            value = value + "\n" + line;
        }else{
            line = line.substr(2).strip();
            if (line.find(":") < 0)
            {
                key = "";
                continue;
            }
            addKeyValue(key, value);
            key = line.substr(0, line.find(":")).strip();
            value = line.substr(line.find(":") + 1).strip();
        }
    }
    addKeyValue(key, value);
    if (type == "")
        LOG(WARNING) << "No scenario type for: " << filename;
}
Example #7
0
// ----------------------------------------------------------------------------
//
FixtureGroupSelectField::FixtureGroupSelectField( LPCSTR label, Venue* venue ) :
    NumberedListField( label ),
    m_venue( venue )
{
    bool first = true;

    for ( FixtureGroup* group : m_venue->getFixtureGroups() ) {
        addKeyValue( group->getNumber(), group->getName() );

        if ( first ) {
            setDefaultListValue( group->getNumber() );
            first = false;
        }
    }
}
Example #8
0
// ----------------------------------------------------------------------------
//
ChaseSelectField::ChaseSelectField( LPCSTR label, Venue* venue, ChaseNumber default_chase ) :
    NumberedListField( label ),
    m_venue( venue )
{
    if ( default_chase == 0 && venue->isChaseRunning() )
        default_chase = venue->getChase( venue->getRunningChase() )->getChaseNumber();

    ChasePtrArray list = m_venue->getChases();
    for ( ChasePtrArray::iterator it=list.begin(); it != list.end(); ++it )
        addKeyValue( (*it)->getChaseNumber(), (*it)->getName() );

    if ( default_chase == 0 && list.size() > 0 )
        default_chase = list[0]->getChaseNumber();

    setDefaultListValue( default_chase );
}
Example #9
0
// ----------------------------------------------------------------------------
//
FixtureDefSelectField::FixtureDefSelectField( LPCSTR field_label ) :
    NumberedListField( field_label )
{
    UINT index = 1;

    for ( FixtureDefinitionMap::iterator it=FixtureDefinition::FixtureDefinitions.begin();
          it != FixtureDefinition::FixtureDefinitions.end(); it++, index++ ) {
        m_fuid_list.push_back( it->first );
        
        CString label;
        label.Format( "%s %s", it->second.getManufacturer(), it->second.getModel() );
        addKeyValue( index, (LPCSTR)label );
    }

    setDefaultListValue( 1 );
}
Example #10
0
// ----------------------------------------------------------------------------
//
SceneSelectField::SceneSelectField( LPCSTR label, Venue* venue, SceneNumber default_scene, bool include_default ) :
    NumberedListField( label ),
    m_venue( venue ),
    m_include_default( include_default )
{
    ScenePtrArray scenes = m_venue->getScenes();
    sort( scenes.begin(), scenes.end(), SceneSelectField::CompareSceneIDs );

    if ( default_scene == 0 )
        default_scene = m_venue->getScene()->getSceneNumber();
    if ( !m_include_default && default_scene == DEFAULT_SCENE_NUMBER )
        default_scene = 0;

    for ( ScenePtrArray::iterator it=scenes.begin(); it != scenes.end(); ++it ) {
        Scene* scene = (*it);
        if ( m_include_default || scene->getSceneNumber() != DEFAULT_SCENE_NUMBER ) {
            addKeyValue( scene->getSceneNumber(), scene->getName() );
            if ( default_scene == 0 )
                default_scene = scene->getSceneNumber();
        }
    }

    setDefaultListValue( default_scene );
}
Example #11
0
void *be_pg_init()
{
	struct pg_backend *conf;
	char *host, *user, *pass, *dbname, *p, *port, *sslcert, *sslkey;
	char *userquery;
	char **keywords = NULL;
	char **values = NULL;

	_log(LOG_DEBUG, "}}}} POSTGRES");

	host = p_stab("host");
	p = p_stab("port");
	user = p_stab("user");
	pass = p_stab("pass");
	dbname = p_stab("dbname");
	sslcert = p_stab("sslcert");
	sslkey = p_stab("sslkey");

	host = (host) ? host : strdup("");
	port = (p) ? p : strdup("");

	userquery = p_stab("userquery");

	if (!userquery) {
		_fatal("Mandatory option 'userquery' is missing");
		return (NULL);
	}
	if ((conf = (struct pg_backend *)malloc(sizeof(struct pg_backend))) == NULL)
		return (NULL);

	conf->conn = NULL;
	conf->host = host;
	conf->port = port;
	conf->user = user;
	conf->pass = pass;
	conf->dbname = dbname;
	conf->userquery = userquery;
	conf->superquery = p_stab("superquery");
	conf->aclquery = p_stab("aclquery");
	conf->sslcert = sslcert;
	conf->sslkey = sslkey;

	_log(LOG_DEBUG, "HERE: %s", conf->superquery);
	_log(LOG_DEBUG, "HERE: %s", conf->aclquery);

	const uint8_t MAX_KEYS = 7;
	keywords = (char **) calloc(MAX_KEYS + 1, sizeof(char *));
	values = (char **) calloc(MAX_KEYS + 1, sizeof(char *));

	if (conf->host) {
		addKeyValue(keywords, values, "host", conf->host, MAX_KEYS);
	}
	if (conf->port) {
		addKeyValue(keywords, values, "port", conf->port, MAX_KEYS);
	}
	if (conf->dbname) {
		addKeyValue(keywords, values, "dbname", conf->dbname, MAX_KEYS);
	}
	if (conf->user) {
		addKeyValue(keywords, values, "user", conf->user, MAX_KEYS);
	}
	if (conf->pass) {
		addKeyValue(keywords, values, "password", conf->pass, MAX_KEYS);
	}
	if (conf->sslcert) {
		addKeyValue(keywords, values, "sslcert", conf->sslcert, MAX_KEYS);
	}
	if (conf->sslkey) {
		addKeyValue(keywords, values, "sslkey", conf->sslkey, MAX_KEYS);
	}

	conf->conn = PQconnectdbParams(
		(const char * const *)keywords, (const char * const *)values, 0);

	free(keywords);
	free(values);

	if (PQstatus(conf->conn) == CONNECTION_BAD) {
		free(conf);
		_fatal("We were unable to connect to the database");
		return (NULL);
	}

	return ((void *)conf);
}