stated
state.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Mark Heily <mark@heily.com>
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef _STATE_H_
18 #define _STATE_H_
19 
25 #include <sys/stat.h>
26 
34 int state_init(int abi_version, int flags);
35 
41 void state_atexit(void);
42 
50 int state_bind(const char *name);
51 
59 int state_unbind(const char *name);
60 
67 int state_subscribe(const char *name);
68 
74 int state_unsubscribe(const char *name);
75 
86 int state_publish(const char *name, const char *state, size_t len);
87 
98 ssize_t state_check(char **key, char **value);
99 
108 int state_get(const char *key, char **value);
109 
135 int state_get_event_fd(void);
136 
150 #if defined(__block) && defined(dispatch_queue_t)
151 void state_dispatch(char *name, dispatch_queue_t queue, void (^block)(void));
152 #endif
153 
159 #ifdef dispatch_queue_t
160 void state_dispatch_f(char *name, dispatch_queue_t queue, void *context, void (*func)(void *));
161 #endif
162 
163 
170 int state_openlog(const char *logfile);
171 
177 int state_closelog(void);
178 
179 #endif /* _STATE_H */
ssize_t state_check(char **key, char **value)
Check for pending notifications, and return the current state.
int state_publish(const char *name, const char *state, size_t len)
Publish a notification about name and update the state.
int state_unbind(const char *name)
Stop publishing information about
int state_bind(const char *name)
Acquire the ability to publish notifications about a name
void state_atexit(void)
Free all resources used by the state notification mechanism.
int state_init(int abi_version, int flags)
Initialize the state notification mechanism.
int state_openlog(const char *logfile)
Submit a block to be executed when one or more state change notifications are pending.
int state_get_event_fd(void)
Get a file descriptor that can be monitored for readability.
int state_get(const char *key, char **value)
Get the current state of a .
int state_closelog(void)
Close the logfile.
int state_subscribe(const char *name)
Subscribe to notifications about a name.
int state_unsubscribe(const char *name)
Stop subscribing to notifications about