void gui_setFileSelectionBoxPseudoResources(Widget widget, Var* dvStruct, Narray* publicResources) { int i, cont; char* name; Var* value; #if DEBUG fprintf(stderr, "DEBUG: gui_setFileSelectionBoxPseudoResources(widget = %ld, " "dvStruct = %ld, publicResources = %ld)\n", widget, dvStruct, publicResources); #endif /* Iterate over the struct, extracting any pseudo-resource items that * we set. Delete the items from the struct, and start iterating at the * beginning again. This is not really efficient, but I'm not sure how * else to do it without mucking about with Davinci's structures more than * I'd like to, or keeping track of what has/hasn't been set. */ cont = 1; while (cont && get_struct_count(dvStruct)) { cont = 0; for (i = 0; i < get_struct_count(dvStruct); i++) { get_struct_element(dvStruct, i, &name, &value); if (!strcmp(name, "dirListItemCount")) { /* Extrapolated from dirListItems. */ parse_error("WARNING: ignoring dirListItemCount"); free_var(Narray_delete(V_STRUCT(dvStruct), "dirListItemCount")); cont = 1; break; } if (!strcmp(name, "fileListItemCount")) { /* Extrapolated from fileListItems. */ parse_error("WARNING: ignoring fileListItemCount"); free_var(Narray_delete(V_STRUCT(dvStruct), "fileListItemCount")); cont = 1; break; } if (!strcmp(name, "dirListItems")) { setItems(widget, name, "dirListItemCount", value); free_var(Narray_delete(V_STRUCT(dvStruct), "dirListItems")); Narray_add(publicResources, name, NULL); cont = 1; break; } if (!strcmp(name, "fileListItems")) { setItems(widget, name, "fileListItemCount", value); free_var(Narray_delete(V_STRUCT(dvStruct), "fileListItems")); Narray_add(publicResources, name, NULL); cont = 1; break; } /* ...new comparisons go here. */ } } }
int add_to_list_of_loaded_modules(Var* v) { if (loaded_modules == NULL) { loaded_modules = Narray_create(10); } if (Narray_add(loaded_modules, v->name, v) == -1) { /* this element may already exist */ if (Narray_find(loaded_modules, v->name, NULL) != -1) { parse_error("Module %s is already loaded. Unload+Reload to refresh.", v->name); return 0; } else { parse_error("Probably a mem allocation error while loading module %s.", v->name); return 0; } } if (debug > DEBUG_THRESHOLD) { parse_error("Added module %s to the list of loaded modules.", v->name); } return 1; /* success */ }
Narray* gui_getFileSelectionBoxPublicResources() { Narray* resList; int i, num; num = sizeof(fileSelectionBoxPublicResources) / sizeof(fileSelectionBoxPublicResources[0]); resList = Narray_create(num); for (i = 0; i < num; i++) { Narray_add(resList, (char*)fileSelectionBoxPublicResources[i], NULL); } return resList; }
Narray* gui_getFramePublicResources() { return Narray_create(0); #if 0 Narray *resList; int i, num; num = sizeof(framePublicResources) / sizeof(framePublicResources[0]); resList = Narray_create(num); for (i = 0; i < num; i++) { Narray_add(resList, (char *) framePublicResources[i], NULL); } return resList; #endif }
static vfuncptr add_func_to_module(dvModule* m, vfuncptr func) { vfuncptr old; int i; if (Narray_add(m->functions, func->name, func) == -1) { /* this element may already exist */ if ((i = Narray_find(m->functions, func->name, NULL)) != -1) { Narray_replace(m->functions, i, func, (void**)&old); if (old) { return old; } } else { return NULL; } } return func; }