summaryrefslogtreecommitdiffstats
path: root/sys/objdir.h
blob: 4ef6d04575f1b197f6eecac31389c0a85138e3f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef _JOVE_SYS_OBJDIR_H
#define _JOVE_SYS_OBJDIR_H 1

#include "api/obj.h"
#include "hal/obj.h"

int objdir_new(jove_owned_obj_t *untyped_obj);
/*Returns the n'th entry of the object directory passed.
 * If the passed object is not an objdir, returns NULL and sets errno to EBADOBJ.
 * If the passed entry index is out of bounds, returns NULL and sets errno to EOOB.*/
jove_owned_obj_t *objdir_getlocal(jove_obj_t *objdir_obj, uint16_t entry);
jove_owned_obj_t *objdir_getlocal_locked(jove_owned_obj_t *objdir, objpath_part_t entry);
jove_obj_t objdir_peeklocal(jove_obj_t *objdir_obj, uint16_t entry);

/*Recursively seeks through an object directory for an object following the passed
 * path variable.
 * If the path length is zero, returns the passed object.
 * If the passed object is not an objdir, returns NULL and sets errno to EBADOBJ.
 * If any object excluding the object at the end of the path is not an objdir,
 * returns NULL and sets errno to EBADOBJ.
 * If any entry in the path is out of bounds, returns NULL and sets errno to EBADOBJ.*/
jove_owned_obj_t *objdir_getobj(jove_obj_t *objdir_obj, const uint16_t *path, size_t path_len);
jove_owned_obj_t *objdir_getobj_locked(jove_owned_obj_t *objdir,
                                       const objpath_part_t *path,
                                       size_t path_len);

bool objdir_compare(jove_obj_t *objdir_obj, objpath_part_t entry, jove_obj_t *obj);
void objdir_swapobj(jove_owned_obj_t *a, jove_owned_obj_t *b);

#endif