summaryrefslogtreecommitdiffstats
path: root/sys/objdir.h
blob: 54e9618b6182a9c28d6e640a69efd03f6d8bda44 (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
#ifndef _JOVE_SYS_OBJDIR_H
#define _JOVE_SYS_OBJDIR_H 1

#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_owned_obj_t *objdir_obj, uint16_t entry);
/*Same as objdir_getlocal except does not block if entry obj is taken.*/
jove_owned_obj_t *objdir_trygetlocal(jove_owned_obj_t *objdir_obj, uint16_t entry);
jove_obj_t objdir_peeklocal(jove_owned_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_owned_obj_t *objdir_obj, const uint16_t *path, size_t path_len);
/*Same as objdir_getobj but does not block if child objects are locked.*/
jove_owned_obj_t *objdir_trygetobj(jove_owned_obj_t *objdir_obj, const uint16_t *path, size_t path_len);


#endif