| 300 | } |
| 301 | |
| 302 | static bool hook_callable(const struct hook_instance *hook, |
| 303 | const char *strfilterfield, |
| 304 | u64 intfilterfield) |
| 305 | { |
| 306 | /* NULL? Skip */ |
| 307 | if (!hook) |
| 308 | return false; |
| 309 | |
| 310 | /* String filters? If there are some we must match one. */ |
| 311 | if (hook->strfilters) { |
| 312 | for (size_t i = 0; i < tal_count(hook->strfilters); i++) { |
| 313 | if (streq(strfilterfield, hook->strfilters[i])) |
| 314 | return true; |
| 315 | } |
| 316 | return false; |
| 317 | } |
| 318 | |
| 319 | /* Integer filters? */ |
| 320 | if (hook->intfilters) { |
| 321 | for (size_t i = 0; i < tal_count(hook->intfilters); i++) { |
| 322 | if (intfilterfield == hook->intfilters[i]) |
| 323 | return true; |
| 324 | } |
| 325 | return false; |
| 326 | } |
| 327 | |
| 328 | /* No filters: always call. */ |
| 329 | return true; |
| 330 | } |
| 331 | |
| 332 | /* Returns true if it finished all the hooks (and thus didn't call anything) */ |
| 333 | static bool plugin_hook_call_next(struct plugin_hook_request *ph_req) |
no outgoing calls
no test coverage detected