1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* IWYU pragma: always_keep */
#include <errno.h> /* IWYU pragma: export */
#include <inttypes.h> /* IWYU pragma: export */
#include <limits.h> /* IWYU pragma: export */
#include <paths.h> /* IWYU pragma: export */
#include <stdarg.h> /* IWYU pragma: export */
#include <stdbool.h> /* IWYU pragma: export */
#include <stddef.h> /* IWYU pragma: export */
#include <stdint.h> /* IWYU pragma: export */
#include <sys/types.h> /* IWYU pragma: export */
#include <uchar.h> /* IWYU pragma: export */
#include "assert-util.h" /* IWYU pragma: export */
#include "cleanup-util.h" /* IWYU pragma: export */
#include "macro.h" /* IWYU pragma: export */
/* Generic types */
typedef uint64_t usec_t;
typedef uint64_t nsec_t;
/* Libc/Linux forward declarations */
struct dirent;
struct ether_addr;
struct fiemap;
struct file_handle;
struct glob_t;
struct group;
struct icmp6_hdr;
struct in_addr;
struct in6_addr;
struct inotify_event;
struct iovec;
struct msghdr;
struct passwd;
struct pollfd;
struct rlimit;
struct sgrp;
struct shadow;
struct signalfd_siginfo;
struct siphash;
struct sockaddr;
struct spwd;
struct stat;
struct statfs;
struct statx_timestamp;
struct statx;
struct termios;
struct tm;
struct ucred;
/* To forward declare FILE and DIR, we have to declare the internal struct names for them. Since these are
* used for C++ symbol name mangling, they're effectively part of the ABI and won't actually change. */
typedef struct _IO_FILE FILE;
typedef struct __dirstream DIR;
/* 3rd-party library forward declarations */
enum bpf_map_type;
struct fdisk_context;
struct fdisk_table;
struct crypt_device;
/* basic/ forward declarations */
typedef void (*hash_func_t)(const void *p, struct siphash *state);
typedef int (*compare_func_t)(const void *a, const void *b);
typedef compare_func_t comparison_fn_t;
typedef int (*comparison_userdata_fn_t)(const void *, const void *, void *);
struct hash_ops;
struct hw_addr_data;
struct in_addr_data;
struct iovec_wrapper;
union in_addr_union;
union sockaddr_union;
typedef enum CGroupFlags CGroupFlags;
typedef enum CGroupMask CGroupMask;
typedef enum ChaseFlags ChaseFlags;
typedef enum ExtractFlags ExtractFlags;
typedef enum Glyph Glyph;
typedef enum ImageClass ImageClass;
typedef enum JobMode JobMode;
typedef enum RuntimeScope RuntimeScope;
typedef enum TimestampStyle TimestampStyle;
typedef enum UnitActiveState UnitActiveState;
typedef enum UnitDependency UnitDependency;
typedef struct Hashmap Hashmap;
typedef struct HashmapBase HashmapBase;
typedef struct IteratedCache IteratedCache;
typedef struct Iterator Iterator;
typedef struct OrderedHashmap OrderedHashmap;
typedef struct OrderedSet OrderedSet;
typedef struct Set Set;
typedef struct dual_timestamp dual_timestamp;
typedef struct triple_timestamp triple_timestamp;
typedef struct LockFile LockFile;
typedef struct PidRef PidRef;
typedef struct Prioq Prioq;
typedef struct RateLimit RateLimit;
typedef struct SocketAddress SocketAddress;
/* libsystemd/ and libsystemd-network/ forward declarations */
typedef void (*_sd_destroy_t)(void *userdata);
typedef union sd_id128 sd_id128_t;
typedef struct sd_event sd_event;
typedef struct sd_event_source sd_event_source;
typedef int (*sd_event_handler_t)(sd_event_source *s, void *userdata);
typedef int (*sd_event_io_handler_t)(sd_event_source *s, int fd, uint32_t revents, void *userdata);
typedef int (*sd_event_time_handler_t)(sd_event_source *s, uint64_t usec, void *userdata);
typedef int (*sd_event_signal_handler_t)(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata);
typedef int (*sd_event_inotify_handler_t)(sd_event_source *s, const struct inotify_event *event, void *userdata);
typedef _sd_destroy_t sd_event_destroy_t;
enum ENUM_TYPE_S64(sd_json_format_flags_t);
enum ENUM_TYPE_S64(sd_json_dispatch_flags_t);
enum ENUM_TYPE_S64(sd_json_variant_type_t);
enum ENUM_TYPE_S64(sd_json_parse_flags_t);
typedef enum sd_json_format_flags_t sd_json_format_flags_t;
typedef enum sd_json_dispatch_flags_t sd_json_dispatch_flags_t;
typedef enum sd_json_variant_type_t sd_json_variant_type_t;
typedef enum sd_json_parse_flags_t sd_json_parse_flags_t;
typedef struct sd_json_variant sd_json_variant;
typedef struct sd_bus sd_bus;
typedef struct sd_bus_error sd_bus_error;
typedef struct sd_bus_error_map sd_bus_error_map;
typedef struct sd_bus_message sd_bus_message;
typedef struct sd_bus_slot sd_bus_slot;
typedef struct sd_bus_creds sd_bus_creds;
typedef struct sd_bus_track sd_bus_track;
typedef struct sd_bus_vtable sd_bus_vtable;
typedef int (*sd_bus_message_handler_t)(sd_bus_message *m, void *userdata, sd_bus_error *ret_error);
typedef int (*sd_bus_property_get_t)(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *ret_error);
typedef int (*sd_bus_property_set_t)(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *value, void *userdata, sd_bus_error *ret_error);
typedef int (*sd_bus_object_find_t)(sd_bus *bus, const char *path, const char *interface, void *userdata, void **ret_found, sd_bus_error *ret_error);
typedef int (*sd_bus_node_enumerator_t)(sd_bus *bus, const char *prefix, void *userdata, char ***ret_nodes, sd_bus_error *ret_error);
typedef int (*sd_bus_track_handler_t)(sd_bus_track *track, void *userdata);
typedef _sd_destroy_t sd_bus_destroy_t;
enum ENUM_TYPE_S64(sd_device_action_t);
typedef enum sd_device_action_t sd_device_action_t;
typedef struct sd_device sd_device;
typedef struct sd_device_enumerator sd_device_enumerator;
typedef struct sd_device_monitor sd_device_monitor;
typedef struct sd_netlink sd_netlink;
typedef struct sd_netlink_message sd_netlink_message;
typedef struct sd_netlink_slot sd_netlink_slot;
typedef int (*sd_netlink_message_handler_t)(sd_netlink *nl, sd_netlink_message *m, void *userdata);
typedef _sd_destroy_t sd_netlink_destroy_t;
typedef struct sd_network_monitor sd_network_monitor;
enum ENUM_TYPE_S64(sd_dhcp_lease_server_type_t);
enum ENUM_TYPE_S64(sd_lldp_rx_event_t);
enum ENUM_TYPE_S64(sd_lldp_multicast_mode_t);
enum ENUM_TYPE_S64(sd_ndisc_event_t);
typedef enum sd_dhcp_lease_server_type_t sd_dhcp_lease_server_type_t;
typedef enum sd_lldp_rx_event_t sd_lldp_rx_event_t;
typedef enum sd_lldp_multicast_mode_t sd_lldp_multicast_mode_t;
typedef enum sd_ndisc_event_t sd_ndisc_event_t;
typedef struct sd_ipv4ll sd_ipv4ll;
typedef struct sd_dhcp_client sd_dhcp_client;
typedef struct sd_dhcp_lease sd_dhcp_lease;
typedef struct sd_dhcp_route sd_dhcp_route;
typedef struct sd_dns_resolver sd_dns_resolver;
typedef struct sd_dhcp_server sd_dhcp_server;
typedef struct sd_ndisc sd_ndisc;
typedef struct sd_radv sd_radv;
typedef struct sd_dhcp6_client sd_dhcp6_client;
typedef struct sd_dhcp6_lease sd_dhcp6_lease;
typedef struct sd_lldp_tx sd_lldp_tx;
typedef struct sd_lldp_rx sd_lldp_rx;
typedef struct sd_lldp_neighbor sd_lldp_neighbor;
typedef struct ICMP6Packet ICMP6Packet;
enum ENUM_TYPE_S64(sd_varlink_method_flags_t);
enum ENUM_TYPE_S64(sd_varlink_interface_flags_t);
enum ENUM_TYPE_S64(sd_varlink_symbol_type_t);
enum ENUM_TYPE_S64(sd_varlink_field_type_t);
enum ENUM_TYPE_S64(sd_varlink_field_direction_t);
enum ENUM_TYPE_S64(sd_varlink_field_flags_t);
enum ENUM_TYPE_S64(sd_varlink_idl_format_flags_t);
enum ENUM_TYPE_S64(sd_varlink_reply_flags_t);
enum ENUM_TYPE_S64(sd_varlink_server_flags_t);
enum ENUM_TYPE_S64(sd_varlink_invocation_flags_t);
typedef enum sd_varlink_method_flags_t sd_varlink_method_flags_t;
typedef enum sd_varlink_interface_flags_t sd_varlink_interface_flags_t;
typedef enum sd_varlink_symbol_type_t sd_varlink_symbol_type_t;
typedef enum sd_varlink_field_type_t sd_varlink_field_type_t;
typedef enum sd_varlink_field_direction_t sd_varlink_field_direction_t;
typedef enum sd_varlink_field_flags_t sd_varlink_field_flags_t;
typedef enum sd_varlink_idl_format_flags_t sd_varlink_idl_format_flags_t;
typedef enum sd_varlink_reply_flags_t sd_varlink_reply_flags_t;
typedef enum sd_varlink_server_flags_t sd_varlink_server_flags_t;
typedef enum sd_varlink_invocation_flags_t sd_varlink_invocation_flags_t;
typedef struct sd_varlink sd_varlink;
typedef struct sd_varlink_server sd_varlink_server;
typedef struct sd_varlink_field sd_varlink_field;
typedef struct sd_varlink_symbol sd_varlink_symbol;
typedef struct sd_varlink_interface sd_varlink_interface;
typedef struct sd_journal sd_journal;
typedef struct sd_resolve sd_resolve;
typedef struct sd_resolve_query sd_resolve_query;
typedef struct sd_hwdb sd_hwdb;
/* shared/ forward declarations */
typedef int (*copy_progress_bytes_t)(uint64_t n_bytes, void *userdata);
typedef int (*copy_progress_path_t)(const char *path, const struct stat *st, void *userdata);
struct local_address;
struct in_addr_prefix;
struct in_addr_full;
typedef enum AskPasswordFlags AskPasswordFlags;
typedef enum BootEntryTokenType BootEntryTokenType;
typedef enum BusPrintPropertyFlags BusPrintPropertyFlags;
typedef enum BusTransport BusTransport;
typedef enum CatFlags CatFlags;
typedef enum CertificateSourceType CertificateSourceType;
typedef enum DnsCacheMode DnsCacheMode;
typedef enum DnsOverTlsMode DnsOverTlsMode;
typedef enum DnssecMode DnssecMode;
typedef enum Fido2EnrollFlags Fido2EnrollFlags;
typedef enum KeySourceType KeySourceType;
typedef enum LabelFixFlags LabelFixFlags;
typedef enum MountInNamespaceFlags MountInNamespaceFlags;
typedef enum NamePolicy NamePolicy;
typedef enum OutputFlags OutputFlags;
typedef enum OutputMode OutputMode;
typedef enum PagerFlags PagerFlags;
typedef enum PatternCompileCase PatternCompileCase;
typedef enum RemoveFlags RemoveFlags;
typedef enum ResolveSupport ResolveSupport;
typedef enum TPM2Flags TPM2Flags;
typedef enum Tpm2Support Tpm2Support;
typedef enum Tpm2UserspaceEventType Tpm2UserspaceEventType;
typedef enum UnitFileFlags UnitFileFlags;
typedef enum UnitFilePresetMode UnitFilePresetMode;
typedef enum UnitFileState UnitFileState;
typedef enum UnitType UnitType;
typedef enum UserDBFlags UserDBFlags;
typedef enum UserRecordLoadFlags UserRecordLoadFlags;
typedef enum UserStorage UserStorage;
typedef struct Bitmap Bitmap;
typedef struct BPFProgram BPFProgram;
typedef struct BusObjectImplementation BusObjectImplementation;
typedef struct CalendarSpec CalendarSpec;
typedef struct Condition Condition;
typedef struct ConfigSection ConfigSection;
typedef struct ConfigTableItem ConfigTableItem;
typedef struct CPUSet CPUSet;
typedef struct FDSet FDSet;
typedef struct Fido2HmacSalt Fido2HmacSalt;
typedef struct FirewallContext FirewallContext;
typedef struct GroupRecord GroupRecord;
typedef struct Image Image;
typedef struct ImagePolicy ImagePolicy;
typedef struct InstallInfo InstallInfo;
typedef struct LookupPaths LookupPaths;
typedef struct LoopDevice LoopDevice;
typedef struct MountOptions MountOptions;
typedef struct OpenFile OpenFile;
typedef struct Pkcs11EncryptedKey Pkcs11EncryptedKey;
typedef struct Table Table;
typedef struct Tpm2Context Tpm2Context;
typedef struct Tpm2Handle Tpm2Handle;
typedef struct Tpm2PCRValue Tpm2PCRValue;
typedef struct UnitInfo UnitInfo;
typedef struct UserRecord UserRecord;
typedef struct VeritySettings VeritySettings;
/* Constants */
/* We duplicate various commonly used constants here so we can keep most static inline functions without
* having to include the full header that provides these constants. */
#define AT_FDCWD -100
#define AT_EMPTY_PATH 0x1000
#define AT_SYMLINK_FOLLOW 0x400
#define AT_SYMLINK_NOFOLLOW 0x100
#define MODE_INVALID ((mode_t) -1)
#define UID_INVALID ((uid_t) -1)
#define GID_INVALID ((gid_t) -1)
#define USEC_INFINITY ((usec_t) UINT64_MAX)
#define NSEC_INFINITY ((nsec_t) UINT64_MAX)
/* MAX_ERRNO is defined as 4095 in linux/err.h. We use the same value here. */
#define ERRNO_MAX 4095
|