void chk_ftab(char *value, FTAB *ftab) { ftab_clear(ftab); char *ptr1, *saveptr1 = NULL; errno = 0; for(ptr1 = strtok_r(value, ";", &saveptr1); (ptr1); ptr1 = strtok_r(NULL, ";", &saveptr1)) { FILTER d; memset(&d, 0, sizeof(d)); char *caid_end_ptr = strchr(ptr1, ':'); // caid_end_ptr + 1 -> headers if(!caid_end_ptr) continue; caid_end_ptr[0] = '\0'; d.caid = a2i(ptr1, 4); if (!d.caid || errno == EINVAL) { errno = 0; continue; } ptr1 = caid_end_ptr + 1; // -> headers char *ident_ptr, *saveident_ptr = NULL; for(ident_ptr = strtok_r(ptr1, ",", &saveident_ptr); ident_ptr && d.nprids < ARRAY_SIZE(d.prids); ident_ptr = strtok_r(NULL, ",", &saveident_ptr)) { uint32_t ident = a2i(ident_ptr, 4); if (errno == EINVAL) { errno = 0; continue; } d.prids[d.nprids++] = ident; } if (d.nprids) ftab_add(ftab, &d); } }
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; }