diff options
author | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2011-12-20 15:09:18 +0100 |
---|---|---|
committer | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2012-05-22 18:44:46 +0200 |
commit | b1030d281dc575742d4e033a89a83a4bc9a4a1b5 (patch) | |
tree | c3b9665a1f1e0f4cc39f6e16038567e6b4fe14d9 /dundee | |
parent | b7001e09888dddeae7201b3de3e1ca7cd21059f6 (diff) | |
download | ofono-b1030d281dc575742d4e033a89a83a4bc9a4a1b5.tar.bz2 |
dundee: Add callback helpers
Diffstat (limited to 'dundee')
-rw-r--r-- | dundee/dundee.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/dundee/dundee.h b/dundee/dundee.h index 4f8aa106..366938e3 100644 --- a/dundee/dundee.h +++ b/dundee/dundee.h @@ -28,6 +28,50 @@ void __dundee_exit(void); +enum dundee_error_type { + DUNDEE_ERROR_TYPE_NO_ERROR = 0, + DUNDEE_ERROR_TYPE_FAILURE, +}; + +struct dundee_error { + enum dundee_error_type type; + int error; +}; + +struct cb_data { + void *cb; + void *data; + void *user; +}; + +static inline struct cb_data *cb_data_new(void *cb, void *data) +{ + struct cb_data *ret; + + ret = g_new0(struct cb_data, 1); + ret->cb = cb; + ret->data = data; + + return ret; +} + +#define CALLBACK_WITH_FAILURE(cb, args...) \ + do { \ + struct dundee_error cb_e; \ + cb_e.type = DUNDEE_ERROR_TYPE_FAILURE; \ + cb_e.error = 0; \ + \ + cb(&cb_e, ##args); \ + } while (0) \ + +#define CALLBACK_WITH_SUCCESS(f, args...) \ + do { \ + struct dundee_error e; \ + e.type = DUNDEE_ERROR_TYPE_NO_ERROR; \ + e.error = 0; \ + f(&e, ##args); \ + } while(0) \ + #include <ofono/log.h> int __ofono_log_init(const char *program, const char *debug, |