/* Local patched datapath (gateway routers) need zones assigned. */ HMAP_FOR_EACH(pd, hmap_node, patched_datapaths) { if (!pd->local) { continue; } char *dnat = alloc_nat_zone_key(pd->port_binding, "dnat"); char *snat = alloc_nat_zone_key(pd->port_binding, "snat"); sset_add(&all_users, dnat); sset_add(&all_users, snat); free(dnat); free(snat); }
int moto_use(MotoEnv *env, char *usename) { char *libpath; libpath = mxdl_find(usename); if (libpath == NULL) { mman_track(env->mpool, libpath); return -1; } if(!sset_contains(env->uses,usename) ) { int i; Enumeration* e; MotoExtension* mx = mxdl_load(usename); sset_add(env->uses,moto_strdup(env,usename)) ; /* Track the MotoExtension in the mpool */ mman_trackf(env->mpool,mx,(void(*)(void *))mext_free); /* Collect all the new includes required by this extension */ for (i = 0; i < mx->includeCount; i++) sset_add(env->includes,mx->includes[i]); e = mext_getFunctions(mx); while(enum_hasNext(e)) { MotoFunction* mfn = enum_next(e); /* Track the MotoFunction in the mpool */ mman_trackf(env->mpool,mfn,(void(*)(void *))mfn_free); /* Add the function to the ftable */ ftab_add(env->ftable, mfn->motoname, mfn); /* Define a new type if need be */ if (mfn->deftype != NULL) { if (mttab_get(env->types, mfn->deftype,0) == NULL) { mttab_add(env->types, mfn->deftype,'\1'); } } } enum_free(e); } free(libpath); return 0; }
const struct json * ovsdb_parser_member(struct ovsdb_parser *parser, const char *name, enum ovsdb_parser_types types) { struct json *value; if (!parser->json) { return NULL; } value = shash_find_data(json_object(parser->json), name); if (!value) { if (!(types & OP_OPTIONAL)) { ovsdb_parser_raise_error(parser, "Required '%s' member is missing.", name); } return NULL; } if (((int) value->type >= 0 && value->type < JSON_N_TYPES && types & (1u << value->type)) || (types & OP_ID && value->type == JSON_STRING && ovsdb_parser_is_id(value->u.string))) { sset_add(&parser->used, name); return value; } else { ovsdb_parser_raise_error(parser, "Type mismatch for member '%s'.", name); return NULL; } }
/* Registers 'file' to be unlinked when the program terminates via exit() or a * fatal signal. */ void fatal_signal_add_file_to_unlink(const char *file) { if (!added_hook) { added_hook = true; fatal_signal_add_hook(unlink_files, cancel_files, NULL, true); } sset_add(&files, file); }
static void update_ct_zones(struct sset *lports, struct hmap *patched_datapaths, struct simap *ct_zones, unsigned long *ct_zone_bitmap) { struct simap_node *ct_zone, *ct_zone_next; int scan_start = 1; struct patched_datapath *pd; const char *user; struct sset all_users = SSET_INITIALIZER(&all_users); SSET_FOR_EACH(user, lports) { sset_add(&all_users, user); }
/* Registers 'file' to be unlinked when the program terminates via exit() or a * fatal signal. */ void fatal_signal_add_file_to_unlink(const char *file) { fatal_signal_init(); ovs_mutex_lock(&mutex); if (!added_hook) { added_hook = true; fatal_signal_add_hook(unlink_files, cancel_files, NULL, true); } sset_add(&files, file); ovs_mutex_unlock(&mutex); }
MotoEnv * moto_createEnv(int flags,char* filename) { MotoEnv *env = (MotoEnv *)emalloc(sizeof(MotoEnv)); env->flags = flags; env->filename = filename; if (flags & MMAN_LEVEL1_FLAG) { env->mman_level = 1; } else if (flags & MMAN_LEVEL2_FLAG) { env->mman_level = 2; } else { env->mman_level = 0; } env->mpool = mpool_create(2048); env->valpool = opool_createWithExt( (void*(*)())moto_createEmptyVal, NULL, NULL, NULL, env, 10 ); env->bufpool = opool_create( (void*(*)())buf_createDefault, (void(*)(void*))buf_free, (void(*)(void*))buf_clear, NULL, 10 ); env->stkpool = opool_create( (void*(*)())stack_createDefault, (void(*)(void*))stack_free, NULL, NULL, 10 ); env->fcache = stab_createDefault(); env->tree = moto_createTree(); env->ptrs = hset_createDefault(); env->out = buf_create(DEFAULT_BUF_SIZE); env->err = buf_create(DEFAULT_BUF_SIZE); env->types = stab_createDefault(); env->cdefs = stab_createDefault(); env->ccdef = NULL; env->globals = stab_createDefault(); env->frames = vec_createDefault(); env->ftable = ftab_create(); env->scope = stack_createDefault(); env->rxcache = stab_createDefault(); env->uses = sset_createDefault(); mttab_addBuiltInType(env, "boolean"); mttab_addBuiltInType(env, "byte"); mttab_addBuiltInType(env, "char"); mttab_addBuiltInType(env, "int"); mttab_addBuiltInType(env, "long"); mttab_addBuiltInType(env, "float"); mttab_addBuiltInType(env, "double"); mttab_addBuiltInType(env, "void"); /* Special symbol for the void type */ mttab_addBuiltInType(env, "null"); /* Special symbol for null type */ mttab_addBuiltInType(env, "Object"); mttab_addBuiltInType(env, "String"); mttab_addBuiltInType(env, "Exception"); mttab_addBuiltInType(env, "Regex"); /* compiler extras */ env->includes = sset_createDefault(); sset_add(env->includes, "<stdio.h>"); sset_add(env->includes, "\"mxarr.h\""); sset_add(env->includes, "\"stringbuffer.h\""); sset_add(env->includes, "\"excpfn.h\""); sset_add(env->includes, "\"mman.h\""); sset_add(env->includes, "\"runtime.h\""); sset_add(env->includes, "\"cdx_function.h\""); env->fdefs = htab_createDefault(); env->adefs = htab_createDefault(); env->constantPool = buf_createDefault(); env->constantCount = 0; env->fcodebuffer = buf_createDefault(); env->curScopeID = 0; env->scopeIDStack = istack_createDefault(); env->frameindex = -1; /* error stuff */ env->errs = sset_createDefault(); env->meta.filename = env->filename; env->meta.caller = NULL; env->meta.macroname = NULL; env->meta.lineno = 1; env->errflag = 0; return env; }