/** * This creates a new node in the AVL then returns the created node * so that you might populate it with data. If the key already * exists, then the existing node is returned. * * @param avl the AVL to add a property to. * @param key the key to add to the AVL. * * @return the newly created AVL node. */ PropPtr new_prop(PropPtr *avl, char *key) { PropPtr ret; register PropPtr p = *avl; register int cmp; static short balancep; if (p) { cmp = strcasecmp(key, PropName(p)); if (cmp > 0) { ret = new_prop(&(p->right), key); } else if (cmp < 0) { ret = new_prop(&(p->left), key); } else { balancep = 0; return (p); } if (balancep) { *avl = balance_node(p); } return ret; } else { p = *avl = alloc_propnode(key); balancep = 1; return (p); } }
void obs_category_add_enum_list(obs_category_t cat, const char *name, const char *desc, const char **strings) { struct obs_property *p = new_prop(cat, name, desc, OBS_PROPERTY_ENUM); struct list_data *data = get_property_data(p); data->strings = strings; data->type = OBS_DROPDOWN_LIST; }
void obs_category_add_float(obs_category_t cat, const char *name, const char *desc, double min, double max, double step) { struct obs_property *p = new_prop(cat, name, desc, OBS_PROPERTY_FLOAT); struct float_data *data = get_property_data(p); data->min = min; data->max = max; data->step = step; }
void obs_category_add_int(obs_category_t cat, const char *name, const char *desc, int min, int max, int step) { struct obs_property *p = new_prop(cat, name, desc, OBS_PROPERTY_INT); struct int_data *data = get_property_data(p); data->min = min; data->max = max; data->step = step; }
void obs_category_add_text_list(obs_category_t cat, const char *name, const char *desc, const char **strings, enum obs_dropdown_type type) { struct obs_property *p = new_prop(cat, name, desc, OBS_PROPERTY_TEXT_LIST); struct list_data *data = get_property_data(p); data->strings = strings; data->type = type; }
/* * returns pointer to the new property node. Returns a pointer to an * existing elem of the given name, if one already exists. Returns * NULL if the name given is bad. * root is the pointer to the root propdir node. This is updated in this * routine to point to the new root node of the structure. * path is the name of the property to insert */ PropPtr propdir_new_elem(PropPtr * root, char *path) { PropPtr p; char *n; while (*path && *path == PROPDIR_DELIMITER) path++; if (!*path) return (NULL); n = index(path, PROPDIR_DELIMITER); while (n && *n == PROPDIR_DELIMITER) *(n++) = '\0'; if (n && *n) { /* just another propdir in the path */ p = new_prop(root, path); return (propdir_new_elem(&PropDir(p), n)); } else { /* aha, we are finally to the property itself. */ p = new_prop(root, path); return (p); } }
/* copies properties */ void copy_proplist(dbref obj, PropPtr * nu, PropPtr old) { PropPtr p; if (old) { #ifdef DISKBASE propfetch(obj, old); #endif p = new_prop(nu, PropName(old)); SetPFlagsRaw(p, PropFlagsRaw(old)); switch (PropType(old)) { case PROP_STRTYP: SetPDataStr(p, alloc_string(PropDataStr(old))); break; case PROP_LOKTYP: if (PropFlags(old) & PROP_ISUNLOADED) { SetPDataLok(p, TRUE_BOOLEXP); SetPFlags(p, (PropFlags(p) & ~PROP_ISUNLOADED)); } else { SetPDataLok(p, copy_bool(PropDataLok(old))); } break; case PROP_DIRTYP: SetPDataVal(p, 0); break; case PROP_FLTTYP: SetPDataFVal(p, PropDataFVal(old)); break; default: SetPDataVal(p, PropDataVal(old)); break; } copy_proplist(obj, &PropDir(p), PropDir(old)); copy_proplist(obj, &AVL_LF(p), AVL_LF(old)); copy_proplist(obj, &AVL_RT(p), AVL_RT(old)); /* copy_proplist(obj, nu, AVL_LF(old)); copy_proplist(obj, nu, AVL_RT(old)); */ } }
void obs_category_add_color(obs_category_t cat, const char *name, const char *desc) { new_prop(cat, name, desc, OBS_PROPERTY_COLOR); }
void obs_category_add_path(obs_category_t cat, const char *name, const char *desc) { new_prop(cat, name, desc, OBS_PROPERTY_PATH); }
void obs_category_add_text(obs_category_t cat, const char *name, const char *desc) { new_prop(cat, name, desc, OBS_PROPERTY_TEXT); }