1 /* SPDX-License-Identifier: LGPL-2.1+ */
7 typedef struct BusWaitForUnits BusWaitForUnits
;
9 typedef enum BusWaitForUnitsState
{
10 BUS_WAIT_SUCCESS
, /* Nothing to wait for anymore and nothing failed */
11 BUS_WAIT_FAILURE
, /* dito, but something failed */
12 BUS_WAIT_RUNNING
, /* Still something to wait for */
13 _BUS_WAIT_FOR_UNITS_STATE_MAX
,
14 _BUS_WAIT_FOR_UNITS_STATE_INVALID
= -1,
15 } BusWaitForUnitsState
;
17 typedef enum BusWaitForUnitsFlags
{
18 BUS_WAIT_FOR_MAINTENANCE_END
= 1 << 0, /* Wait until the unit is no longer in maintenance state */
19 BUS_WAIT_FOR_INACTIVE
= 1 << 1, /* Wait until the unit is back in inactive or dead state */
20 BUS_WAIT_NO_JOB
= 1 << 2, /* Wait until there's no more job pending */
21 BUS_WAIT_REFFED
= 1 << 3, /* The unit is already reffed with RefUnit() */
22 } BusWaitForUnitsFlags
;
24 typedef void (*bus_wait_for_units_ready_callback
)(BusWaitForUnits
*d
, BusWaitForUnitsState state
, void *userdata
);
25 typedef void (*bus_wait_for_units_unit_callback
)(BusWaitForUnits
*d
, const char *unit_path
, bool good
, void *userdata
);
27 int bus_wait_for_units_new(sd_bus
*bus
, BusWaitForUnits
**ret
);
28 BusWaitForUnits
* bus_wait_for_units_free(BusWaitForUnits
*d
);
30 BusWaitForUnitsState
bus_wait_for_units_state(BusWaitForUnits
*d
);
31 void bus_wait_for_units_set_ready_callback(BusWaitForUnits
*d
, bus_wait_for_units_ready_callback callback
, void *userdata
);
32 int bus_wait_for_units_add_unit(BusWaitForUnits
*d
, const char *unit
, BusWaitForUnitsFlags flags
, bus_wait_for_units_unit_callback callback
, void *userdata
);
33 int bus_wait_for_units_run(BusWaitForUnits
*d
);
35 DEFINE_TRIVIAL_CLEANUP_FUNC(BusWaitForUnits
*, bus_wait_for_units_free
);