Toevoegen van de sources die ik vorige keer vergeten was, en nog wat
[projects/chimara/chimara.git] / src / fileref.c
1 #include "fileref.h"
2
3 /* List of streams currently in existence */
4 static GList *fileref_list = NULL;
5
6 /**
7  * glk_fileref_iterate:
8  * @fref: A file reference, or #NULL.
9  * @rockptr: Return location for the next window's rock, or #NULL.
10  *
11  * Iterates over the list of file references; if @fref is #NULL, it returns the
12  * first file reference, otherwise the next file reference after @fref. If 
13  * there are no more, it returns #NULL. The file reference's rock is stored in
14  * @rockptr. If you don't want the rocks to be returned, you may set @rockptr 
15  * to #NULL.
16  *
17  * The order in which file references are returned is arbitrary. The order may
18  * change every time you create or destroy a file reference, invalidating the 
19  * iteration.
20  *
21  * Returns: the next file reference, or #NULL if there are no more.
22  */
23 frefid_t
24 glk_fileref_iterate(frefid_t fref, glui32 *rockptr)
25 {
26         GList *retnode;
27         
28         if(fref == NULL)
29                 retnode = fileref_list;
30         else
31                 retnode = fref->fileref_list->next;
32         frefid_t retval = retnode? (frefid_t)retnode->data : NULL;
33                 
34         /* Store the fileref's rock in rockptr */
35         if(retval && rockptr)
36                 *rockptr = glk_fileref_get_rock(retval);
37                 
38         return retval;
39 }
40
41 /**
42  * glk_fileref_get_rock:
43  * @fref: A file reference.
44  * 
45  * Returns the file reference @fref's rock value.
46  *
47  * Returns: A rock value.
48  */
49 glui32
50 glk_fileref_get_rock(frefid_t fref)
51 {
52         g_return_val_if_fail(fref != NULL, 0);
53         return fref->rock;
54 }