]> mj.ucw.cz Git - libucw.git/blob - lib/object.h
When processing the `-S' option, work on a copy, so that the command
[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 #define MAX_ATTR_SIZE 1024              /* Maximum length an attribute can ever have (including name and trailing 0) */
14
15 struct fastbuf;
16
17 struct odes {                           /* Object description */
18   struct oattr *attrs;
19   struct mempool *pool;
20   struct oattr *cached_attr;
21 };
22
23 struct oattr {                          /* Object attribute */
24   struct oattr *next, *same;
25   byte attr;
26   byte val[1];
27 };
28
29 void obj_dump(struct odes *);
30 struct odes *obj_new(struct mempool *);
31 int obj_read(struct fastbuf *, struct odes *);
32 void obj_read_multi(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