Beispiel #1
0
/*
 * Convert interface names to IDs
 * Args: Pointer to engine output filter, pointer to initialized interface list
 * Returns: -1 on failure, 0 on success
 */
int name2id(sfilter_t *filter)
{
    unsigned int id;
    sf_rule_t *rptr;
    struct srclist *sptr;

    if (!filter)
        return(0);

    if (filter->type == FILTER) {
        for (rptr=filter->rules;rptr;rptr=rptr->next) {
            if (rptr->src.name == NULL)
                continue;
            if (!(id=namelookup(rptr->src.name))) {
                logwarn("Unknown interface \'%s\' in filter rules",rptr->src.name);
                return(-1);
            }
            free(rptr->src.name);
            rptr->src.id=id;
        }
        return(0);
    }
    
    for (rptr=filter->rules;rptr;rptr=rptr->next)
        for (sptr=rptr->info.source;sptr;sptr=sptr->next) {
            if (!(id=namelookup(sptr->src.name))) {
               logwarn("Unknown interface \'%s\' in failover rules",sptr->src.name);
                return(-1);
            }
            free(sptr->src.name);
            sptr->src.id=id;
        }
    return(0);
}
Beispiel #2
0
int symboltable::addSymbol(const char* newsymbol)
{
	int id = nextid++;
	string s = string(newsymbol);
	suppresserrors = true;
	symtableentry* e = namelookup(s);
	suppresserrors = false;
	if (e) {
		return e->id;
	}
	symtableentry* ste = new symtableentry(id, s);
	symbols.push_back(ste);
	return ste->id;
}