]> mj.ucw.cz Git - libucw.git/blob - lib/object.h
Updated version numbers.
[libucw.git] / lib / object.h
1 /*
2  *      Sherlock Library -- Object Functions
3  *
4  *      (c) 1997--2003 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 #ifndef _SHERLOCK_OBJECT_H
11 #define _SHERLOCK_OBJECT_H
12
13 /* FIXME: Buggy objects with long attributes still exist in old databases. Decrease to 1024 one day. */
14 #define MAX_ATTR_SIZE 4096              /* Maximum length an attribute can ever have (including name and trailing 0) */
15
16 struct fastbuf;
17
18 struct odes {                           /* Object description */
19   struct oattr *attrs;
20   struct mempool *pool;
21   struct oattr *cached_attr;
22 };
23
24 struct oattr {                          /* Object attribute */
25   struct oattr *next, *same;
26   byte attr;
27   byte val[1];
28 };
29
30 void obj_dump(struct odes *);
31 struct odes *obj_new(struct mempool *);
32 int obj_read(struct fastbuf *, struct odes *);
33 void obj_write(struct fastbuf *, struct odes *);
34 void obj_write_nocheck(struct fastbuf *, struct odes *);
35 struct oattr *obj_find_attr(struct odes *, uns);
36 struct oattr *obj_find_attr_last(struct odes *, uns);
37 uns obj_del_attr(struct odes *, struct oattr *);
38 byte *obj_find_aval(struct odes *, uns);
39 struct oattr *obj_set_attr(struct odes *, uns, byte *);
40 struct oattr *obj_set_attr_num(struct odes *, uns, uns);
41 struct oattr *obj_add_attr(struct odes *, uns, byte *);
42 struct oattr *obj_prepend_attr(struct odes *, uns, byte *);
43 struct oattr *obj_insert_attr(struct odes *o, struct oattr *first, struct oattr *after, byte *v);
44 void obj_move_attr_to_head(struct odes *o, uns);
45 void obj_move_attr_to_tail(struct odes *o, uns);
46
47 #endif