fastevent.h 1.57 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/* Icecast
 *
 * This program is distributed under the GNU General Public License, version 2.
 * A copy of this license is included with this source.
 *
 * Copyright 2018,      Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
 */

#ifndef __FASTEVENT_H__
#define __FASTEVENT_H__

12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
/* Add all conditions when to enable fast events here. */
#if 1
#define FASTEVENT_ENABLED
#endif

#include <stdarg.h>
#include <refobject.h>

typedef enum {
    FASTEVENT_TYPE_SLOWEVENT = 0,
    FASTEVENT_TYPE__END /* must be last element */
} fastevent_type_t;

typedef enum {
    FASTEVENT_DATATYPE_NONE = 0,
    FASTEVENT_DATATYPE_EVENT,
    FASTEVENT_DATATYPE_CLIENT,
    FASTEVENT_DATATYPE_CONNECTION
} fastevent_datatype_t;

typedef int fastevent_flag_t;
#define FASTEVENT_FLAG_NONE                     ((fastevent_flag_t)0x0000)
#define FASTEVENT_FLAG_MODIFICATION_ALLOWED     ((fastevent_flag_t)0x0001)

typedef void (*fastevent_cb_t)(const void *userdata, fastevent_type_t type, fastevent_flag_t flags, fastevent_datatype_t datatype, va_list ap);
typedef void (*fastevent_freecb_t)(void **userdata);

#ifdef FASTEVENT_ENABLED
int fastevent_initialize(void);
int fastevent_shutdown(void);
refobject_t fastevent_register(fastevent_type_t type, fastevent_cb_t cb, fastevent_freecb_t freecb, void *userdata);
void fastevent_emit(fastevent_type_t type, fastevent_flag_t flags, fastevent_datatype_t datatype, ...);
#else
#define fastevent_initialize() 0
#define fastevent_shutdown() 0
#define fastevent_register(type,cb,freecb,userdata) REFOBJECT_NULL
#define fastevent_emit(type,flags,datatype,...)
#endif

51
#endif