1wofi-map(3)                Library Functions Manual                wofi-map(3)
2
3
4

NAME

6       wofi - Map API functions and documentation
7
8

DESCRIPTION

10       The functions documented here are used for interacting with wofi's con‐
11       fig and map. They are defined in map.h.
12
13

MAP FUNCTIONS

15       The following functions are used to interact with a struct map*
16
17
18       struct map* map_init(void)
19              Allocates and returns a new string map. String maps only support
20              string values.
21
22
23       struct map* map_init_void(void)
24              Allocates and returns a new void map. A void map supports values
25              of any type.
26
27
28       void map_free(struct map* map)
29              Frees the provided map and all it's keys. Values are only  freed
30              if it is a string map.
31
32
33       bool map_put(struct map* map, const char* key, char* value)
34              Returns true if the given map is a string map, otherwise returns
35              false and prints a message to stderr.
36
37              struct map* map - The map to insert into.
38
39              const char* key - The key to store the value under. This key  is
40              given to strdup() before being saved and will be freed when run‐
41              ning map_free().
42
43              char* value - The  value  to  store.  This  value  is  given  to
44              strdup()  before  being  saved  and  will  be freed when running
45              map_free(). If the value  is  NULL  it  will  not  be  given  to
46              strdup().
47
48
49       bool map_put_void(struct map* map, const char* key, void* value)
50              Returns  true  if the given map is a void map, otherwise returns
51              false and prints a message to stderr.
52
53              struct map* map - The map to insert into.
54
55              const char* key - The key to store the value under. This key  is
56              given to strdup() before being saved and will be freed when run‐
57              ning map_free().
58
59              void* value - The value to store. This pointer is stored in  the
60              map,  it  is on the caller to free this and it will not be freed
61              when running map_free().
62
63
64       void* map_get(struct map* map, const char* key)
65              Returns the value stored under key or NULL  if  no  key  exists.
66              NULL  can also be returned if it was stored there with map_put()
67              or map_put_void().
68
69              struct map* map - The map to get the value from.
70
71              const char* key - The key to lookup.
72
73
74       bool map_contains(struct map* map, const char* key)
75              Returns true if the key exists, false otherwise. This is  imple‐
76              mented as a value != NULL check so a NULL value is considered to
77              not exist.
78
79              struct map* map - The map to check against.
80
81              const char* key - The key to check for.
82
83
84       size_t map_size(struct map* map)
85              Returns the number of entries in this map.
86
87              struct map* map - The map to get the size of.
88
89
90
91                                                                   wofi-map(3)
Impressum