Debian Codegraph @

src/shared/bus-wait-for-units.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "shared-forward.h"
5
6 typedef struct BusWaitForUnits BusWaitForUnits;
7
8 typedef enum BusWaitForUnitsState {
9 BUS_WAIT_SUCCESS, /* Nothing to wait for anymore and nothing failed */
10 BUS_WAIT_FAILURE, /* ditto, but something failed */
11 BUS_WAIT_RUNNING, /* Still something to wait for */
12 _BUS_WAIT_FOR_UNITS_STATE_MAX,
13 _BUS_WAIT_FOR_UNITS_STATE_INVALID = -EINVAL,
14 } BusWaitForUnitsState;
15
16 typedef enum BusWaitForUnitsFlags {
17 BUS_WAIT_FOR_MAINTENANCE_END = 1 << 0, /* Wait until the unit is no longer in maintenance state */
18 BUS_WAIT_FOR_INACTIVE = 1 << 1, /* Wait until the unit is back in inactive or dead state */
19 BUS_WAIT_NO_JOB = 1 << 2, /* Wait until there's no more job pending */
20 BUS_WAIT_REFFED = 1 << 3, /* The unit is already reffed with RefUnit() */
21 _BUS_WAIT_FOR_TARGET = BUS_WAIT_FOR_MAINTENANCE_END|BUS_WAIT_FOR_INACTIVE|BUS_WAIT_NO_JOB,
22 } BusWaitForUnitsFlags;
23
24 typedef void (*bus_wait_for_units_unit_callback_t)(BusWaitForUnits *d, const char *unit_path, bool good, void *userdata);
25
26 int bus_wait_for_units_new(sd_bus *bus, BusWaitForUnits **ret);
27
28 BusWaitForUnits* bus_wait_for_units_free(BusWaitForUnits *d);
29 DEFINE_TRIVIAL_CLEANUP_FUNC(BusWaitForUnits*, bus_wait_for_units_free);
30
31 int bus_wait_for_units_add_unit(
32 BusWaitForUnits *d,
33 const char *unit,
34 BusWaitForUnitsFlags flags,
35 bus_wait_for_units_unit_callback_t callback,
36 void *userdata);
37
38 int bus_wait_for_units_run(BusWaitForUnits *d);
39 BusWaitForUnitsState bus_wait_for_units_state(BusWaitForUnits *d);