]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-*.h: clean up exported (or to-be-exported) header files
authorLennart Poettering <lennart@poettering.net>
Sat, 24 Oct 2015 21:42:56 +0000 (23:42 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 24 Oct 2015 21:42:56 +0000 (23:42 +0200)
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.

21 files changed:
src/libsystemd-network/sd-dhcp-server.c
src/libsystemd-network/sd-dhcp6-client.c
src/libsystemd-network/sd-ipv4acd.c
src/libsystemd-network/sd-ipv4ll.c
src/libsystemd-network/sd-pppoe.c
src/libsystemd-network/test-dhcp6-client.c
src/network/networkd-dhcp6.c
src/systemd/sd-device.h
src/systemd/sd-dhcp-client.h
src/systemd/sd-dhcp-lease.h
src/systemd/sd-dhcp-server.h
src/systemd/sd-dhcp6-client.h
src/systemd/sd-dhcp6-lease.h
src/systemd/sd-hwdb.h
src/systemd/sd-ipv4acd.h
src/systemd/sd-ipv4ll.h
src/systemd/sd-lldp.h
src/systemd/sd-ndisc.h
src/systemd/sd-path.h
src/systemd/sd-pppoe.h
src/systemd/sd-resolve.h

index 39afffc72c15ae6458e6c281cbe77574a134353b..52f7579c5e7ef942b06afa1b15c0d6eef09f6e1e 100644 (file)
@@ -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;
index cb8b0713f4e20ea39d8a75b2ade50645e4d71d30..d4d4b771d941c517670c0953263e2623f61e5417 100644 (file)
@@ -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);
 
index ae9805bfaa47c2db1b7e6482bcc827f9fab8995b..d2ad5f75a42aa43247f5c680c3a813fec46499d7 100644 (file)
@@ -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;
index 0d025768a91095705421d78d5ad4a68c2920d58f..68ec58da901a274cc925efb61fcc79f4e4e316d4 100644 (file)
@@ -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);
index 87e3ce4b1da53127d813051aed481262e75abdc9..7456b3218a6c3fa4b13137e40c5a74fe99abae56 100644 (file)
@@ -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"
index fdf8d2ef898d309c2dd55c641d8c5a7d68de4bc9..4872567894ecbe3d19090abe4a4e11e5f042d2c2 100644 (file)
@@ -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__);
index 623359def62c9d6b5ba5c2d5900acfe8fa074641..c3332bb1ac40fe95dafa69818350e9c0e562a116 100644 (file)
@@ -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);
 
index 38cb2a1102800d58dcf458cd91b97a90b833b428..fc117258213499350c0ebcce6d3888c980e3ef17 100644 (file)
@@ -24,7 +24,7 @@
 ***/
 
 #include <sys/types.h>
-#include <stdint.h>
+#include <inttypes.h>
 
 #include "_sd-common.h"
 
index 4291fb7ebcb6b82ef1bc52ab0a12b15faf673b93..c0146158f3798fa1909652993bfb57d3466232d7 100644 (file)
   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
index ed5bceecdd8b9c7ccab681e83907d724bdbe17f4..38222594e7bd90d18eede4e6d3e7588e5bd6b079 100644 (file)
   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
index 4b0c7a18526804e7c9f622abb7f7699f66ebc0c1..55bceb1ea59a8d57ee957f89fa1c92fe2b8a383e 100644 (file)
   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
index e95d758815315378cdce5ad5876816200b4ebbbf..13182a481d92f3ba7f9282f7b705e79d742758ad 100644 (file)
   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
index dc3df3bbf7b803ae30fa1a427972ac882bd3dccb..3fc0ee4bed3719617634d6e4eabe2166ff2ffeb8 100644 (file)
   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
index 3c44b981d68030700161c74ba13748d59bae25fa..49269a073ae1ffa27115b95e3c4a7e3215be89a0 100644 (file)
@@ -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
index adcb2c7b920144f2d7abe51bd3a5577fa9f8652e..6337d614525046d624736e0c4e2ae5421d75bc8a 100644 (file)
   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
index cc85140acdd54b1142edd41f6348383fa8e3cd3f..2949f1dfb284de3ce7ba61ac10f11d2cb7a1cdf1 100644 (file)
   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
index e9abdf349f028244f46dc1f1dfa0a3f69493b4cc..31651ce132f2af0c7dcb77b70ed0a62eea119551 100644 (file)
@@ -1,5 +1,8 @@
 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
 
+#ifndef foosdlldphfoo
+#define foosdlldphfoo
+
 /***
   This file is part of systemd.
 
   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
index 83575c69084636ce6cbcd98bd4c8c8461e0a279d..570e1741d68e3927222b20afa4931a7227646afb 100644 (file)
   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
index e238c0ce2039ccd1a98ec0a821f919d6ce28b550..32803036332fd83f5b844f3a04f81182cd081203 100644 (file)
 
 #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
index 90878ffa27b761712e01c3caf9686e071570ff11..80d9fc2862c85cef733dae9f4d7a4ee64ced9294 100644 (file)
   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
index 80c5852e455dde8fb8bb280f0487a4af31f9621a..82c4b39efe1ab3434b5143f9955737f075456772 100644 (file)
   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;