]>
git.ipfire.org Git - thirdparty/kmod.git/blob - libkmod/libkmod-private.h
1 #ifndef _LIBKMOD_PRIVATE_H_
2 #define _LIBKMOD_PRIVATE_H_
11 static __always_inline
__printf_format(2, 3) void
12 kmod_log_null(struct kmod_ctx
*ctx
, const char *format
, ...) {}
14 #define kmod_log_cond(ctx, prio, arg...) \
16 if (kmod_get_log_priority(ctx) >= prio) \
17 kmod_log(ctx, prio, __FILE__, __LINE__, __FUNCTION__, ## arg);\
22 # define DBG(ctx, arg...) kmod_log_cond(ctx, LOG_DEBUG, ## arg)
24 # define DBG(ctx, arg...) kmod_log_null(ctx, ## arg)
26 # define INFO(ctx, arg...) kmod_log_cond(ctx, LOG_INFO, ## arg)
27 # define ERR(ctx, arg...) kmod_log_cond(ctx, LOG_ERR, ## arg)
29 # define DBG(ctx, arg...) kmod_log_null(ctx, ## arg)
30 # define INFO(ctx, arg...) kmod_log_null(ctx, ## arg)
31 # define ERR(ctx, arg...) kmod_log_null(ctx, ## arg)
34 #define KMOD_EXPORT __attribute__ ((visibility("default")))
36 void kmod_log(struct kmod_ctx
*ctx
,
37 int priority
, const char *file
, int line
, const char *fn
,
38 const char *format
, ...) __attribute__((format(printf
, 6, 7)));
41 struct list_node
*next
, *prev
;
45 struct list_node node
;
49 struct kmod_list
*kmod_list_append(struct kmod_list
*list
, const void *data
) __must_check
;
50 struct kmod_list
*kmod_list_prepend(struct kmod_list
*list
, const void *data
) __must_check
;
51 struct kmod_list
*kmod_list_remove(struct kmod_list
*list
);
52 struct kmod_list
*kmod_list_remove_data(struct kmod_list
*list
,
53 const void *data
) __must_check
;
54 struct kmod_list
*kmod_list_remove_n_latest(struct kmod_list
*list
,
55 unsigned int n
) __must_check
;
58 const char *kmod_get_dirname(const struct kmod_ctx
*ctx
) __attribute__((nonnull(1)));
59 int kmod_lookup_alias_from_config(struct kmod_ctx
*ctx
, const char *name
, struct kmod_list
**list
);
60 int kmod_lookup_alias_from_symbols_file(struct kmod_ctx
*ctx
, const char *name
, struct kmod_list
**list
);
61 int kmod_lookup_alias_from_aliases_file(struct kmod_ctx
*ctx
, const char *name
, struct kmod_list
**list
);
62 int kmod_lookup_alias_from_moddep_file(struct kmod_ctx
*ctx
, const char *name
, struct kmod_list
**list
);
64 /* libkmod-config.c */
66 struct kmod_list
*aliases
;
67 struct kmod_list
*blacklists
;
69 int kmod_parse_config_file(struct kmod_ctx
*ctx
, const char *filename
, struct kmod_config
*config
);
70 int kmod_parse_config(struct kmod_ctx
*ctx
, struct kmod_config
*config
);
71 void kmod_free_config(struct kmod_ctx
*ctx
, struct kmod_config
*config
);
72 const char *kmod_alias_get_name(const struct kmod_list
*l
);
73 const char *kmod_alias_get_modname(const struct kmod_list
*l
);
75 /* libkmod-module.c */
76 int kmod_module_parse_dep(struct kmod_module
*mod
, char *line
);
79 char *getline_wrapped(FILE *fp
, unsigned int *linenum
);
80 char *underscores(struct kmod_ctx
*ctx
, char *s
);
81 #define streq(a, b) (strcmp((a), (b)) == 0)
82 bool startswith(const char *s
, const char *prefix
);