Audacious  $Id:Doxyfile42802007-03-2104:39:00Znenolod$
hook.h
Go to the documentation of this file.
1 /*
2  * hook.h
3  * Copyright 2011 John Lindgren
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions, and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions, and the following disclaimer in the documentation
13  * provided with the distribution.
14  *
15  * This software is provided "as is" and without any warranty, express or
16  * implied. In no event shall the authors be liable for any damages arising from
17  * the use of this software.
18  */
19 
20 #ifndef LIBAUDCORE_HOOK_H
21 #define LIBAUDCORE_HOOK_H
22 
23 typedef void (* HookFunction) (void * data, void * user);
24 
25 /* Adds <func> to the list of functions to be called when the hook <name> is
26  * triggered. */
27 void hook_associate (const char * name, HookFunction func, void * user);
28 
29 /* Removes all instances matching <func> and <user> from the list of functions
30  * to be called when the hook <name> is triggered. If <user> is NULL, all
31  * instances matching <func> are removed. */
32 void hook_dissociate_full (const char * name, HookFunction func, void * user);
33 
34 #define hook_dissociate(n, f) hook_dissociate_full (n, f, NULL)
35 
36 /* Triggers the hook <name>. */
37 void hook_call (const char * name, void * data);
38 
39 /* Schedules a call of the hook <name> from the program's main loop, to be
40  * executed in <time> milliseconds. If <destroy> is not NULL, it will be called
41  * on <data> after the hook is called. */
42 void event_queue_full (int time, const char * name, void * data, void (* destroy) (void *));
43 
44 #define event_queue(n, d) event_queue_full (0, n, d, NULL)
45 
46 /* Cancels pending hook calls matching <name> and <data>. If <data> is NULL,
47  * all hook calls matching <name> are canceled. */
48 void event_queue_cancel (const char * name, void * data);
49 
50 #endif /* LIBAUDCORE_HOOK_H */