Lucas De Marchi | 586fc30 | 2011-11-21 14:35:35 -0200 | [diff] [blame] | 1 | #ifndef _LIBKMOD_PRIVATE_H_ |
| 2 | #define _LIBKMOD_PRIVATE_H_ |
| 3 | |
| 4 | #include <stdbool.h> |
| 5 | #include <syslog.h> |
| 6 | |
| 7 | #include "libkmod.h" |
| 8 | |
| 9 | static inline void __attribute__((always_inline, format(printf, 2, 3))) |
| 10 | kmod_log_null(struct kmod_ctx *ctx, const char *format, ...) {} |
| 11 | |
| 12 | #define kmod_log_cond(ctx, prio, arg...) \ |
| 13 | do { \ |
| 14 | if (kmod_get_log_priority(ctx) >= prio) \ |
| 15 | kmod_log(ctx, prio, __FILE__, __LINE__, __FUNCTION__, ## arg);\ |
| 16 | } while (0) |
| 17 | |
| 18 | #ifdef ENABLE_LOGGING |
| 19 | # ifdef ENABLE_DEBUG |
| 20 | # define dbg(ctx, arg...) kmod_log_cond(ctx, LOG_DEBUG, ## arg) |
| 21 | # else |
| 22 | # define dbg(ctx, arg...) kmod_log_null(ctx, ## arg) |
| 23 | # endif |
| 24 | # define info(ctx, arg...) kmod_log_cond(ctx, LOG_INFO, ## arg) |
| 25 | # define err(ctx, arg...) kmod_log_cond(ctx, LOG_ERR, ## arg) |
| 26 | #else |
| 27 | # define dbg(ctx, arg...) kmod_log_null(ctx, ## arg) |
| 28 | # define info(ctx, arg...) kmod_log_null(ctx, ## arg) |
| 29 | # define err(ctx, arg...) kmod_log_null(ctx, ## arg) |
| 30 | #endif |
| 31 | |
| 32 | #define KMOD_EXPORT __attribute__ ((visibility("default"))) |
| 33 | |
| 34 | void kmod_log(struct kmod_ctx *ctx, |
| 35 | int priority, const char *file, int line, const char *fn, |
| 36 | const char *format, ...) __attribute__((format(printf, 6, 7))); |
| 37 | |
Lucas De Marchi | 6924e47 | 2011-11-22 05:38:28 -0200 | [diff] [blame^] | 38 | struct list_node { |
| 39 | struct list_node *next, *prev; |
| 40 | }; |
| 41 | |
| 42 | struct kmod_list { |
| 43 | struct list_node node; |
| 44 | void *data; |
| 45 | }; |
| 46 | |
| 47 | struct kmod_list *kmod_list_append(struct kmod_list *list, void *data); |
| 48 | struct kmod_list *kmod_list_prepend(struct kmod_list *list, void *data); |
| 49 | struct kmod_list *kmod_list_remove(struct kmod_list *list); |
| 50 | struct kmod_list *kmod_list_remove_data(struct kmod_list *list, |
| 51 | const void *data); |
| 52 | |
Lucas De Marchi | 586fc30 | 2011-11-21 14:35:35 -0200 | [diff] [blame] | 53 | #endif |