condition: introduce generic function type for condition_to_string()-like functions

Let's add a typedef for a function type we use at multiple places.
This commit is contained in:
Lennart Poettering
2020-05-15 15:50:09 +02:00
parent 7f19247b5e
commit dce719f6c1
2 changed files with 15 additions and 7 deletions
+9 -3
View File
@@ -779,7 +779,12 @@ int condition_test(Condition *c) {
return b;
}
bool condition_test_list(Condition *first, const char *(*to_string)(ConditionType t), condition_test_logger_t logger, void *userdata) {
bool condition_test_list(
Condition *first,
condition_to_string_t to_string,
condition_test_logger_t logger,
void *userdata) {
Condition *c;
int triggered = -1;
@@ -828,9 +833,10 @@ bool condition_test_list(Condition *first, const char *(*to_string)(ConditionTyp
return triggered != 0;
}
void condition_dump(Condition *c, FILE *f, const char *prefix, const char *(*to_string)(ConditionType t)) {
void condition_dump(Condition *c, FILE *f, const char *prefix, condition_to_string_t to_string) {
assert(c);
assert(f);
assert(to_string);
prefix = strempty(prefix);
@@ -844,7 +850,7 @@ void condition_dump(Condition *c, FILE *f, const char *prefix, const char *(*to_
condition_result_to_string(c->result));
}
void condition_dump_list(Condition *first, FILE *f, const char *prefix, const char *(*to_string)(ConditionType t)) {
void condition_dump_list(Condition *first, FILE *f, const char *prefix, condition_to_string_t to_string) {
Condition *c;
LIST_FOREACH(conditions, c, first)