static struct ldap_object_node * parse_element_tag(xmlNodePtr curr_node, struct ldap_object_node **objs, struct ldap_attr_node **attrs, struct idinfo *ids) { struct ldap_object_node *obj; char *n, *normalized; struct idval *v; int need_cn = 1; dbg_printf("Trying to parse element tag\n"); n = (char *)xmlGetProp(curr_node, (xmlChar *)"name"); normalized = normalize_name(n); v = id_find(ids, normalized, OBJ, 0); if (!v) { v = zalloc(sizeof(*v)); v->name = normalized; v->rawname = n; v->type = OBJ; id_insert(ids, v); } obj = find_obj(*objs, v->name); if (!obj) { obj = zalloc(sizeof(*obj)); obj->name = v->name; obj->idval = v; obj->next = *objs; *objs = obj; dbg_printf("New object class %s \n",obj->name); } find_optional_attributes(curr_node->xmlChildrenNode, 0, obj, attrs, ids); find_required_attributes(curr_node->xmlChildrenNode, obj, attrs, ids); if (find_meta_attr_byname(obj->required_attrs, "name") || find_meta_attr_byname(obj->required_attrs, "cn")) { need_cn = 0; } if (need_cn && (find_meta_attr_byname(obj->optional_attrs, "name") || find_meta_attr_byname(obj->optional_attrs, "cn"))) { need_cn = 0; } if (need_cn) { dbg_printf("Object class might %s need 'MUST ( cn )' for proper LDIF\n", obj->name); obj->need_cn = 1; } return obj; }
static struct ldap_attr_node * get_attr(xmlNodePtr curr_node, struct ldap_attr_node **attrs, struct idinfo *ids) { struct ldap_attr_node *n; struct idval *v; char *name, *normalized; name = (char *)xmlGetProp(curr_node, (xmlChar *)"name"); normalized = normalize_name((const char *)name); n = find_attr_byname(*attrs, normalized); if (n) { free(normalized); return n; } n = zalloc(sizeof(*n)); v = id_find(ids, normalized, ATTR, 0); if (!v) { v = zalloc(sizeof(*v)); v->name = normalized; v->type = ATTR; v->rawname = (char *)name; id_insert(ids, v); } else { free(normalized); } n->idval = v; n->name = n->idval->name; dbg_printf("Lookin for data type for %s\n", n->name); find_data_match_fn(curr_node->xmlChildrenNode, &n->ldap_equality, &n->ldap_syntax); n->next = *attrs; *attrs = n; return n; }
/** * gts_object_new: * @klass: a #GtsObjectClass. * * Returns: a new initialized object of class @klass. */ GtsObject * gts_object_new (GtsObjectClass * klass) { GtsObject * object; g_return_val_if_fail (klass != NULL, NULL); object = g_malloc0 (klass->info.object_size); object->klass = klass; gts_object_init (object, klass); #ifdef DEBUG_IDENTITY id_insert (object); #ifdef DEBUG_LEAKS fprintf (stderr, "new %s %p->%d\n", klass->info.name, object, id (object)); #endif #endif return object; }
/** * gts_object_clone: * @object: a #GtsObject. * * Calls the clone method of @object. The call to this function will fail * if no clone method exists for the given object. * * Returns: a new object clone of @object. */ GtsObject * gts_object_clone (GtsObject * object) { GtsObject * clone; g_return_val_if_fail (object != NULL, NULL); g_return_val_if_fail (object->klass->clone, NULL); clone = g_malloc0 (object->klass->info.object_size); clone->klass = object->klass; object_init (clone); (* object->klass->clone) (clone, object); #ifdef DEBUG_IDENTITY id_insert (clone); #ifdef DEBUG_LEAKS fprintf (stderr, "clone %s %p->%d\n", clone->klass->info.name, clone, id (clone)); #endif #endif return clone; }