sd-*.h: clean up exported (or to-be-exported) header files
Exported header files should not include internal headers. Fix that. Exported header files should not use the bool type. So far we opted to stick to C89 for exported headers, and hence use "int" for bools in them. Continue to do so. Exported header files should have #include lines for everything they use including inttypes.h and sys/types.h, so that they may be included in any order. Exported header files should have C++ guards, hence add them. Exported header files should not use gcc extensions like #pragma once, get rid of it.
This commit is contained in:
parent
00229fe48f
commit
04c0136989
|
@ -94,7 +94,7 @@ int sd_dhcp_server_configure_pool(sd_dhcp_server *server, struct in_addr *addres
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool sd_dhcp_server_is_running(sd_dhcp_server *server) {
|
||||
int sd_dhcp_server_is_running(sd_dhcp_server *server) {
|
||||
assert_return(server, false);
|
||||
|
||||
return !!server->receive_message;
|
||||
|
|
|
@ -206,9 +206,8 @@ int sd_dhcp6_client_set_duid(
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sd_dhcp6_client_set_information_request(sd_dhcp6_client *client, bool enabled) {
|
||||
int sd_dhcp6_client_set_information_request(sd_dhcp6_client *client, int enabled) {
|
||||
assert_return(client, -EINVAL);
|
||||
|
||||
assert_return(IN_SET(client->state, DHCP6_STATE_STOPPED), -EBUSY);
|
||||
|
||||
client->information_request = enabled;
|
||||
|
@ -216,7 +215,7 @@ int sd_dhcp6_client_set_information_request(sd_dhcp6_client *client, bool enable
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sd_dhcp6_client_get_information_request(sd_dhcp6_client *client, bool *enabled) {
|
||||
int sd_dhcp6_client_get_information_request(sd_dhcp6_client *client, int *enabled) {
|
||||
assert_return(client, -EINVAL);
|
||||
assert_return(enabled, -EINVAL);
|
||||
|
||||
|
|
|
@ -468,7 +468,7 @@ int sd_ipv4acd_set_address(sd_ipv4acd *ll, const struct in_addr *address){
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool sd_ipv4acd_is_running(sd_ipv4acd *ll) {
|
||||
int sd_ipv4acd_is_running(sd_ipv4acd *ll) {
|
||||
assert_return(ll, false);
|
||||
|
||||
return ll->state != IPV4ACD_STATE_INIT;
|
||||
|
|
|
@ -227,7 +227,7 @@ int sd_ipv4ll_set_address_seed(sd_ipv4ll *ll, unsigned seed) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool sd_ipv4ll_is_running(sd_ipv4ll *ll) {
|
||||
int sd_ipv4ll_is_running(sd_ipv4ll *ll) {
|
||||
assert_return(ll, false);
|
||||
|
||||
return sd_ipv4acd_is_running(ll->acd);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "event-util.h"
|
||||
#include "random-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "sparse-endian.h"
|
||||
#include "string-util.h"
|
||||
#include "utf8.h"
|
||||
#include "util.h"
|
||||
|
|
|
@ -700,7 +700,7 @@ int dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) {
|
|||
static int test_client_solicit(sd_event *e) {
|
||||
sd_dhcp6_client *client;
|
||||
usec_t time_now = now(clock_boottime_or_monotonic());
|
||||
bool val = true;
|
||||
int val = true;
|
||||
|
||||
if (verbose)
|
||||
printf("* %s\n", __FUNCTION__);
|
||||
|
|
|
@ -166,8 +166,7 @@ static void dhcp6_handler(sd_dhcp6_client *client, int event, void *userdata) {
|
|||
}
|
||||
|
||||
int dhcp6_configure(Link *link, bool inf_req) {
|
||||
int r;
|
||||
bool information_request;
|
||||
int r, information_request;
|
||||
|
||||
assert_return(link, -EINVAL);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
***/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "_sd-common.h"
|
||||
|
||||
|
|
|
@ -22,12 +22,18 @@
|
|||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <inttypes.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "sd-event.h"
|
||||
#include "sd-dhcp-lease.h"
|
||||
|
||||
#include "_sd-common.h"
|
||||
|
||||
_SD_BEGIN_DECLARATIONS;
|
||||
|
||||
enum {
|
||||
SD_DHCP_CLIENT_EVENT_STOP = 0,
|
||||
SD_DHCP_CLIENT_EVENT_IP_ACQUIRE = 1,
|
||||
|
@ -72,4 +78,6 @@ int sd_dhcp_client_attach_event(sd_dhcp_client *client, sd_event *event, int pri
|
|||
int sd_dhcp_client_detach_event(sd_dhcp_client *client);
|
||||
sd_event *sd_dhcp_client_get_event(sd_dhcp_client *client);
|
||||
|
||||
_SD_END_DECLARATIONS;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,8 +23,14 @@
|
|||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <inttypes.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "_sd-common.h"
|
||||
|
||||
_SD_BEGIN_DECLARATIONS;
|
||||
|
||||
typedef struct sd_dhcp_lease sd_dhcp_lease;
|
||||
struct sd_dhcp_route;
|
||||
|
@ -52,4 +58,6 @@ int sd_dhcp_lease_get_vendor_specific(sd_dhcp_lease *lease, const void **data, s
|
|||
int sd_dhcp_lease_get_client_id(sd_dhcp_lease *lease, const void **client_id, size_t *client_id_len);
|
||||
int sd_dhcp_lease_get_timezone(sd_dhcp_lease *lease, const char **timezone);
|
||||
|
||||
_SD_END_DECLARATIONS;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,10 +23,13 @@
|
|||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "sd-event.h"
|
||||
#include "_sd-common.h"
|
||||
|
||||
_SD_BEGIN_DECLARATIONS;
|
||||
|
||||
typedef struct sd_dhcp_server sd_dhcp_server;
|
||||
|
||||
|
@ -39,7 +42,7 @@ int sd_dhcp_server_attach_event(sd_dhcp_server *client, sd_event *event, int pri
|
|||
int sd_dhcp_server_detach_event(sd_dhcp_server *client);
|
||||
sd_event *sd_dhcp_server_get_event(sd_dhcp_server *client);
|
||||
|
||||
bool sd_dhcp_server_is_running(sd_dhcp_server *server);
|
||||
int sd_dhcp_server_is_running(sd_dhcp_server *server);
|
||||
|
||||
int sd_dhcp_server_start(sd_dhcp_server *server);
|
||||
int sd_dhcp_server_stop(sd_dhcp_server *server);
|
||||
|
@ -55,4 +58,6 @@ int sd_dhcp_server_set_default_lease_time(sd_dhcp_server *server, uint32_t t);
|
|||
|
||||
int sd_dhcp_server_forcerenew(sd_dhcp_server *server);
|
||||
|
||||
_SD_END_DECLARATIONS;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,13 +22,17 @@
|
|||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "sd-event.h"
|
||||
|
||||
#include "sd-dhcp6-lease.h"
|
||||
|
||||
#include "_sd-common.h"
|
||||
|
||||
_SD_BEGIN_DECLARATIONS;
|
||||
|
||||
enum {
|
||||
SD_DHCP6_CLIENT_EVENT_STOP = 0,
|
||||
SD_DHCP6_CLIENT_EVENT_RESEND_EXPIRE = 10,
|
||||
|
@ -49,10 +53,8 @@ int sd_dhcp6_client_set_mac(sd_dhcp6_client *client, const uint8_t *addr,
|
|||
size_t addr_len, uint16_t arp_type);
|
||||
int sd_dhcp6_client_set_duid(sd_dhcp6_client *client, uint16_t type, uint8_t *duid,
|
||||
size_t duid_len);
|
||||
int sd_dhcp6_client_set_information_request(sd_dhcp6_client *client,
|
||||
bool enabled);
|
||||
int sd_dhcp6_client_get_information_request(sd_dhcp6_client *client,
|
||||
bool *enabled);
|
||||
int sd_dhcp6_client_set_information_request(sd_dhcp6_client *client, int enabled);
|
||||
int sd_dhcp6_client_get_information_request(sd_dhcp6_client *client, int *enabled);
|
||||
int sd_dhcp6_client_set_request_option(sd_dhcp6_client *client,
|
||||
uint16_t option);
|
||||
|
||||
|
@ -68,4 +70,6 @@ sd_dhcp6_client *sd_dhcp6_client_ref(sd_dhcp6_client *client);
|
|||
sd_dhcp6_client *sd_dhcp6_client_unref(sd_dhcp6_client *client);
|
||||
int sd_dhcp6_client_new(sd_dhcp6_client **ret);
|
||||
|
||||
_SD_END_DECLARATIONS;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,8 +23,13 @@
|
|||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "_sd-common.h"
|
||||
|
||||
_SD_BEGIN_DECLARATIONS;
|
||||
|
||||
typedef struct sd_dhcp6_lease sd_dhcp6_lease;
|
||||
|
||||
void sd_dhcp6_lease_reset_address_iter(sd_dhcp6_lease *lease);
|
||||
|
@ -42,4 +47,6 @@ int sd_dhcp6_lease_get_ntp_fqdn(sd_dhcp6_lease *lease, char ***ntp_fqdn);
|
|||
sd_dhcp6_lease *sd_dhcp6_lease_ref(sd_dhcp6_lease *lease);
|
||||
sd_dhcp6_lease *sd_dhcp6_lease_unref(sd_dhcp6_lease *lease);
|
||||
|
||||
_SD_END_DECLARATIONS;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -39,9 +39,11 @@ int sd_hwdb_get(sd_hwdb *hwdb, const char *modalias, const char *key, const char
|
|||
int sd_hwdb_seek(sd_hwdb *hwdb, const char *modalias);
|
||||
int sd_hwdb_enumerate(sd_hwdb *hwdb, const char **key, const char **value);
|
||||
|
||||
/* the inverse condition avoids ambiguity of danling 'else' after the macro */
|
||||
/* the inverse condition avoids ambiguity of dangling 'else' after the macro */
|
||||
#define SD_HWDB_FOREACH_PROPERTY(hwdb, modalias, key, value) \
|
||||
if (sd_hwdb_seek(hwdb, modalias) < 0) { } \
|
||||
else while (sd_hwdb_enumerate(hwdb, &(key), &(value)) > 0)
|
||||
|
||||
_SD_END_DECLARATIONS;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,11 +23,13 @@
|
|||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <netinet/in.h>
|
||||
#include <net/ethernet.h>
|
||||
|
||||
#include "sd-event.h"
|
||||
#include "_sd-common.h"
|
||||
|
||||
_SD_BEGIN_DECLARATIONS;
|
||||
|
||||
enum {
|
||||
SD_IPV4ACD_EVENT_STOP = 0,
|
||||
|
@ -45,11 +47,13 @@ int sd_ipv4acd_set_callback(sd_ipv4acd *ll, sd_ipv4acd_cb_t cb, void *userdata);
|
|||
int sd_ipv4acd_set_mac(sd_ipv4acd *ll, const struct ether_addr *addr);
|
||||
int sd_ipv4acd_set_index(sd_ipv4acd *ll, int interface_index);
|
||||
int sd_ipv4acd_set_address(sd_ipv4acd *ll, const struct in_addr *address);
|
||||
bool sd_ipv4acd_is_running(sd_ipv4acd *ll);
|
||||
int sd_ipv4acd_is_running(sd_ipv4acd *ll);
|
||||
int sd_ipv4acd_start(sd_ipv4acd *ll);
|
||||
int sd_ipv4acd_stop(sd_ipv4acd *ll);
|
||||
sd_ipv4acd *sd_ipv4acd_ref(sd_ipv4acd *ll);
|
||||
sd_ipv4acd *sd_ipv4acd_unref(sd_ipv4acd *ll);
|
||||
int sd_ipv4acd_new (sd_ipv4acd **ret);
|
||||
|
||||
_SD_END_DECLARATIONS;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,11 +22,13 @@
|
|||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <netinet/in.h>
|
||||
#include <net/ethernet.h>
|
||||
|
||||
#include "sd-event.h"
|
||||
#include "_sd-common.h"
|
||||
|
||||
_SD_BEGIN_DECLARATIONS;
|
||||
|
||||
enum {
|
||||
SD_IPV4LL_EVENT_STOP = 0,
|
||||
|
@ -45,11 +47,13 @@ int sd_ipv4ll_set_mac(sd_ipv4ll *ll, const struct ether_addr *addr);
|
|||
int sd_ipv4ll_set_index(sd_ipv4ll *ll, int interface_index);
|
||||
int sd_ipv4ll_set_address(sd_ipv4ll *ll, const struct in_addr *address);
|
||||
int sd_ipv4ll_set_address_seed(sd_ipv4ll *ll, unsigned seed);
|
||||
bool sd_ipv4ll_is_running(sd_ipv4ll *ll);
|
||||
int sd_ipv4ll_is_running(sd_ipv4ll *ll);
|
||||
int sd_ipv4ll_start(sd_ipv4ll *ll);
|
||||
int sd_ipv4ll_stop(sd_ipv4ll *ll);
|
||||
sd_ipv4ll *sd_ipv4ll_ref(sd_ipv4ll *ll);
|
||||
sd_ipv4ll *sd_ipv4ll_unref(sd_ipv4ll *ll);
|
||||
int sd_ipv4ll_new (sd_ipv4ll **ret);
|
||||
|
||||
_SD_END_DECLARATIONS;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
#ifndef foosdlldphfoo
|
||||
#define foosdlldphfoo
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
|
@ -20,11 +23,13 @@
|
|||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <net/ethernet.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "sd-event.h"
|
||||
#include "_sd-common.h"
|
||||
|
||||
_SD_BEGIN_DECLARATIONS;
|
||||
|
||||
enum {
|
||||
SD_LLDP_EVENT_UPDATE_INFO = 0,
|
||||
|
@ -74,3 +79,7 @@ sd_lldp_packet *sd_lldp_packet_unref(sd_lldp_packet *tlv);
|
|||
int sd_lldp_packet_get_destination_type(sd_lldp_packet *tlv, int *dest);
|
||||
|
||||
int sd_lldp_get_packets(sd_lldp *lldp, sd_lldp_packet ***tlvs);
|
||||
|
||||
_SD_END_DECLARATIONS;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,9 +22,13 @@
|
|||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <net/ethernet.h>
|
||||
|
||||
#include "sd-event.h"
|
||||
#include "_sd-common.h"
|
||||
|
||||
_SD_BEGIN_DECLARATIONS;
|
||||
|
||||
enum {
|
||||
SD_NDISC_EVENT_ROUTER_ADVERTISMENT_NONE = 0,
|
||||
|
@ -68,4 +72,6 @@ int sd_ndisc_router_discovery_start(sd_ndisc *nd);
|
|||
be16toh((address).s6_addr16[6]), \
|
||||
be16toh((address).s6_addr16[7])
|
||||
|
||||
_SD_END_DECLARATIONS;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "_sd-common.h"
|
||||
|
||||
_SD_BEGIN_DECLARATIONS;
|
||||
|
||||
enum {
|
||||
/* Temporary files */
|
||||
SD_PATH_TEMPORARY = 0x0ULL,
|
||||
|
@ -84,4 +88,6 @@ enum {
|
|||
int sd_path_home(uint64_t type, const char *suffix, char **path);
|
||||
int sd_path_search(uint64_t type, const char *suffix, char ***paths);
|
||||
|
||||
_SD_END_DECLARATIONS;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <net/ethernet.h>
|
||||
|
||||
#include "sd-event.h"
|
||||
#include "_sd-common.h"
|
||||
|
||||
#include "sparse-endian.h"
|
||||
_SD_BEGIN_DECLARATIONS;
|
||||
|
||||
enum {
|
||||
SD_PPPOE_EVENT_RUNNING = 0,
|
||||
|
@ -50,4 +50,6 @@ sd_pppoe *sd_pppoe_ref(sd_pppoe *ppp);
|
|||
sd_pppoe *sd_pppoe_unref(sd_pppoe *ppp);
|
||||
int sd_pppoe_new (sd_pppoe **ret);
|
||||
|
||||
_SD_END_DECLARATIONS;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,12 +22,13 @@
|
|||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <inttypes.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "_sd-common.h"
|
||||
#include "sd-event.h"
|
||||
#include "_sd-common.h"
|
||||
|
||||
_SD_BEGIN_DECLARATIONS;
|
||||
|
||||
|
|
Loading…
Reference in New Issue