]> mj.ucw.cz Git - libucw.git/commitdiff
Added functions for moving attributes in the chain.
authorMartin Mares <mj@ucw.cz>
Wed, 26 Mar 2003 20:03:40 +0000 (20:03 +0000)
committerMartin Mares <mj@ucw.cz>
Wed, 26 Mar 2003 20:03:40 +0000 (20:03 +0000)
lib/object.c
lib/object.h

index 6f047863086bd508c4c8242d10895fd3c86a1d3b..fb957bd7e61169271226a5689738e30f8a7fc8ae 100644 (file)
@@ -244,3 +244,43 @@ obj_insert_attr(struct odes *o, struct oattr *first, struct oattr *after, byte *
   after->same = b;
   return b;
 }
+
+void
+obj_move_attr_to_head(struct odes *o, uns x)
+{
+  struct oattr *a, **z;
+
+  z = &o->attrs;
+  while (a = *z)
+    {
+      if (a->attr == x)
+       {
+         *z = a->next;
+         a->next = o->attrs;
+         o->attrs = a;
+         break;
+       }
+      z = &a->next;
+    }
+}
+
+void
+obj_move_attr_to_tail(struct odes *o, uns x)
+{
+  struct oattr *a, **z;
+
+  z = &o->attrs;
+  while (a = *z)
+    {
+      if (a->attr == x)
+       {
+         *z = a->next;
+         while (*z)
+           z = &(*z)->next;
+         *z = a;
+         a->next = NULL;
+         break;
+       }
+      z = &a->next;
+    }
+}
index c1a91798291492b6a8d38a64071f3bb92f9f2a16..34d2e71d9aa36dfba85a6e69587bc6ef3e505523 100644 (file)
@@ -41,5 +41,7 @@ struct oattr *obj_set_attr_num(struct odes *, uns, uns);
 struct oattr *obj_add_attr(struct odes *, uns, byte *);
 struct oattr *obj_prepend_attr(struct odes *, uns, byte *);
 struct oattr *obj_insert_attr(struct odes *o, struct oattr *first, struct oattr *after, byte *v);
+void obj_move_attr_to_head(struct odes *o, uns);
+void obj_move_attr_to_tail(struct odes *o, uns);
 
 #endif