# define _sd_packed_ __attribute__((packed))
#endif
-#ifndef _sd_stringify
-# define _sd_xstringify(x) #x
-# define _sd_stringify(x) _sd_xstringify(x)
+#ifndef _SD_STRINGIFY
+# define _SD_XSTRINGIFY(x) #x
+# define _SD_STRINGIFY(x) _SD_XSTRINGIFY(x)
+#endif
+
+#ifndef _SD_BEGIN_DECLARATIONS
+# ifdef __cplusplus
+# define _SD_BEGIN_DECLARATIONS \
+ extern "C" { \
+ struct __useless_struct_to_allow_trailing_semicolon__
+# else
+# define _SD_BEGIN_DECLARATIONS \
+ struct __useless_struct_to_allow_trailing_semicolon__
+# endif
+#endif
+
+#ifndef _SD_END_DECLARATIONS
+# ifdef __cplusplus
+# define _SD_END_DECLARATIONS \
+ } \
+ struct __useless_struct_to_allow_trailing_semicolon__
+# else
+# define _SD_END_DECLARATIONS \
+ struct __useless_struct_to_allow_trailing_semicolon__
+# endif
#endif
#endif
#include <endian.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "_sd-common.h"
+
+_SD_BEGIN_DECLARATIONS;
/* Types of message */
#define SD_BUS_ERROR_INVALID_SIGNATURE "org.freedesktop.DBus.Error.InvalidSignature"
#define SD_BUS_ERROR_INCONSISTENT_MESSAGE "org.freedesktop.DBus.Error.InconsistentMessage"
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
#endif
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "_sd-common.h"
+
+_SD_BEGIN_DECLARATIONS;
typedef struct sd_bus_vtable sd_bus_vtable;
.type = _SD_BUS_VTABLE_END, \
}
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
#endif
#include "sd-memfd.h"
#include "_sd-common.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+_SD_BEGIN_DECLARATIONS;
/* Types */
&(x).bytes[8], &(x).bytes[9], &(x).bytes[10], &(x).bytes[11], \
&(x).bytes[12], &(x).bytes[13], &(x).bytes[14], &(x).bytes[15]
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
#endif
#include <inttypes.h>
#include <signal.h>
+#include "_sd-common.h"
+
/*
Why is this better than pure epoll?
- Handles signals and child PIDs
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
+_SD_BEGIN_DECLARATIONS;
typedef struct sd_event sd_event;
typedef struct sd_event_source sd_event_source;
int sd_event_source_get_signal(sd_event_source *s);
int sd_event_source_get_child_pid(sd_event_source *s, pid_t *pid);
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
#endif
#include <inttypes.h>
#include <string.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "_sd-common.h"
+
+_SD_BEGIN_DECLARATIONS;
/* 128 Bit ID APIs. See sd-id128(3) for more information. */
#define SD_ID128_NULL ((sd_id128_t) { .qwords = { 0, 0 }})
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
#endif
#include "sd-id128.h"
#include "_sd-common.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Journal APIs. See sd-journal(3) for more information. */
+_SD_BEGIN_DECLARATIONS;
+
/* Write to daemon */
int sd_journal_print(int priority, const char *format, ...) _sd_printf_(2, 3);
int sd_journal_printv(int priority, const char *format, va_list ap) _sd_printf_(2, 0);
/* implicitly add code location to messages sent, if this is enabled */
#ifndef SD_JOURNAL_SUPPRESS_LOCATION
-#define sd_journal_print(priority, ...) sd_journal_print_with_location(priority, "CODE_FILE=" __FILE__, "CODE_LINE=" _sd_stringify(__LINE__), __func__, __VA_ARGS__)
-#define sd_journal_printv(priority, format, ap) sd_journal_printv_with_location(priority, "CODE_FILE=" __FILE__, "CODE_LINE=" _sd_stringify(__LINE__), __func__, format, ap)
-#define sd_journal_send(...) sd_journal_send_with_location("CODE_FILE=" __FILE__, "CODE_LINE=" _sd_stringify(__LINE__), __func__, __VA_ARGS__)
-#define sd_journal_sendv(iovec, n) sd_journal_sendv_with_location("CODE_FILE=" __FILE__, "CODE_LINE=" _sd_stringify(__LINE__), __func__, iovec, n)
-#define sd_journal_perror(message) sd_journal_perror_with_location("CODE_FILE=" __FILE__, "CODE_LINE=" _sd_stringify(__LINE__), __func__, message)
+#define sd_journal_print(priority, ...) sd_journal_print_with_location(priority, "CODE_FILE=" __FILE__, "CODE_LINE=" _SD_STRINGIFY(__LINE__), __func__, __VA_ARGS__)
+#define sd_journal_printv(priority, format, ap) sd_journal_printv_with_location(priority, "CODE_FILE=" __FILE__, "CODE_LINE=" _SD_STRINGIFY(__LINE__), __func__, format, ap)
+#define sd_journal_send(...) sd_journal_send_with_location("CODE_FILE=" __FILE__, "CODE_LINE=" _SD_STRINGIFY(__LINE__), __func__, __VA_ARGS__)
+#define sd_journal_sendv(iovec, n) sd_journal_sendv_with_location("CODE_FILE=" __FILE__, "CODE_LINE=" _SD_STRINGIFY(__LINE__), __func__, iovec, n)
+#define sd_journal_perror(message) sd_journal_perror_with_location("CODE_FILE=" __FILE__, "CODE_LINE=" _SD_STRINGIFY(__LINE__), __func__, message)
#endif
#define SD_JOURNAL_FOREACH_UNIQUE(j, data, l) \
for (sd_journal_restart_unique(j); sd_journal_enumerate_unique((j), &(data), &(l)) > 0; )
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
#endif
#include <sys/types.h>
#include <inttypes.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "_sd-common.h"
/*
* A few points:
* See sd-login(3) for more information.
*/
+_SD_BEGIN_DECLARATIONS;
+
/* Get session from PID. Note that 'shared' processes of a user are
* not attached to a session, but only attached to a user. This will
* return an error for system processes and 'shared' processes of a
/* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */
int sd_login_monitor_get_timeout(sd_login_monitor *m, uint64_t *timeout_usec);
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
#endif
#include <sys/types.h>
#include <stdio.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "_sd-common.h"
+
+_SD_BEGIN_DECLARATIONS;
typedef struct sd_memfd sd_memfd;
int sd_memfd_get_size(sd_memfd *m, uint64_t *sz);
int sd_memfd_set_size(sd_memfd *m, uint64_t sz);
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
#endif
***/
#include "sd-id128.h"
+#include "_sd-common.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+_SD_BEGIN_DECLARATIONS;
/* Hey! If you add a new message here, you *must* also update the
* message catalog with an appropriate explanation */
#define SD_MESSAGE_BOOTCHART SD_ID128_MAKE(9f,26,aa,56,2c,f4,40,c2,b1,6c,77,3d,04,79,b5,18)
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
#endif
#include <inttypes.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "_sd-common.h"
+
+_SD_BEGIN_DECLARATIONS;
typedef struct sd_rtnl sd_rtnl;
typedef struct sd_rtnl_message sd_rtnl_message;
int sd_rtnl_message_append(sd_rtnl_message *m, unsigned short type, const void *data);
int sd_rtnl_message_read(sd_rtnl_message *m, unsigned short *type, void **data);
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
#endif
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "_sd-common.h"
+
+_SD_BEGIN_DECLARATIONS;
const char *sd_utf8_is_valid(const char *s);
const char *sd_ascii_is_valid(const char *s);
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
#endif