Pull some commonly occurring declarations into a new header file.
authorDavin McCall <davmac@davmac.org>
Fri, 12 Jan 2018 16:17:25 +0000 (16:17 +0000)
committerDavin McCall <davmac@davmac.org>
Fri, 12 Jan 2018 16:17:25 +0000 (16:17 +0000)
Adds a new header file, dinit.h, which includes declarations for some
types and functions exported from dinit.cc.

src/control.h
src/dinit.cc
src/dinit.h [new file with mode: 0644]
src/proc-service.cc
src/service.cc

index 7111d5f159a583c4786b0eab70bfae85f1a59b8a..bf0e3722bae0f80f4f5016f63d310b9a7746f11d 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "dasynq.h"
 
+#include "dinit.h"
 #include "dinit-log.h"
 #include "control-cmds.h"
 #include "service-listener.h"
@@ -18,8 +19,6 @@
 
 // Control connection for dinit
 
-using eventloop_t = dasynq::event_loop<dasynq::null_mutex>;
-
 class control_conn_t;
 class control_conn_watcher;
 
index fd946e7c115f14e9ed01092f16e87d6b57ef3163..105403279ff821a7bfc3e78ad4ccf7367bfcb283 100644 (file)
@@ -18,6 +18,7 @@
 #include <sys/reboot.h>
 #endif
 
+#include "dinit.h"
 #include "dasynq.h"
 #include "service.h"
 #include "control.h"
@@ -49,9 +50,6 @@ static void wait_for_user_input() noexcept;
 
 static void control_socket_cb(eventloop_t *loop, int fd);
 
-void open_control_socket(bool report_ro_failure = true) noexcept;
-void setup_external_log() noexcept;
-
 
 // Variables
 
diff --git a/src/dinit.h b/src/dinit.h
new file mode 100644 (file)
index 0000000..ef6b962
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef DINIT_H_INCLUDED
+#define DINIT_H_INCLUDED 1
+
+#include "dasynq.h"
+
+/*
+ * General Dinit definitions.
+ */
+
+using eventloop_t = dasynq::event_loop<dasynq::null_mutex>;
+
+using clock_type = dasynq::clock_type;
+using rearm = dasynq::rearm;
+using time_val = dasynq::time_val;
+
+void open_control_socket(bool report_ro_failure = true) noexcept;
+void setup_external_log() noexcept;
+
+extern eventloop_t event_loop;
+
+#endif
index 25885d2f99d790f488c6355be5615bc7874b44d2..64341f66caa4eea0ddeb57906b5106127957217d 100644 (file)
@@ -1,6 +1,7 @@
 #include <sys/un.h>
 #include <sys/socket.h>
 
+#include "dinit.h"
 #include "dinit-socket.h"
 #include "dinit-util.h"
 #include "proc-service.h"
  * See proc-service.h header for interface details.
  */
 
-extern eventloop_t event_loop;
-
-using clock_type = dasynq::clock_type;
-using rearm = dasynq::rearm;
-using time_val = dasynq::time_val;
-
 // Given a string and a list of pairs of (start,end) indices for each argument in that string,
 // store a null terminator for the argument. Return a `char *` vector containing the beginning
 // of each argument and a trailing nullptr. (The returned array is invalidated if the string is later modified).
index 8e067199a92fe3eee8e5700a7b24064609b702a7..04149dbc2f5a525651f5f9dda27edac8b5b52eec 100644 (file)
@@ -14,6 +14,7 @@
 #include <unistd.h>
 #include <termios.h>
 
+#include "dinit.h"
 #include "service.h"
 #include "dinit-log.h"
 #include "dinit-socket.h"
  * See service.h for details.
  */
 
-// from dinit.cc:
-void open_control_socket(bool report_ro_failure = true) noexcept;
-void setup_external_log() noexcept;
-
-using clock_type = dasynq::clock_type;
-using rearm = dasynq::rearm;
-using time_val = dasynq::time_val;
-
 // Find the requested service by name
 static service_record * find_service(const std::list<service_record *> & records,
                                     const char *name) noexcept