void list_sa(__u32 spi) { if (spi == 0) { sadb_t::iterator i = sadb.find(spi); for (i = sadb.begin(); i != sadb.end(); ++i) print_sa(stdout, &i->second); } else { struct mipsa *sa = find_sa(spi); if (sa) print_sa(stdout, sa); else printf("no spi (%u) found in sadb\n", spi); } }
void save_sadb() { FILE *fp = fopen_ex(MIPSADB_CONF, "w"); sadb_t::iterator i; for (i = sadb.begin(); i != sadb.end(); ++i) { print_sa(fp, &i->second); } fclose_ex(fp); }
static int print(mexico::Ast* ast, mexico::Log* log, const char* namelist_name) { int retval = 0; if(!ast) MEXICO_FATAL("!ast"); switch(ast->nodetype) { case 'L': //< namelist list case ',': //< inside a list retval = print(ast->l, log, namelist_name); if(!retval) /// Go down the subtree only if we haven't found the namelist retval = print(ast->r, log, namelist_name); break; case '&': //< a namelist #ifndef NEBUG if('S' != ast->l->nodetype) MEXICO_FATAL("ast->l->nodetype == %c, expected S", ast->l->nodetype); #endif if(std::string(namelist_name) == ast->l->s) retval = print(ast->r, log, namelist_name); break; case '=': #ifndef NEBUG if('S' != ast->l->nodetype) MEXICO_FATAL("ast->l->nodetype == %c, expected S", ast->l->nodetype); #endif print_sa(ast->l->s.c_str(), ast->r, log); retval = 1; break; /// Should never see these in this function case 'I': case 'F': case 'S': case 'B': default: MEXICO_FATAL("bad node %c", ast->nodetype); goto ftn_exit; } ftn_exit: return retval; }