Centralize daemon option processing and usage.
[sliver-openvswitch.git] / include / daemon.h
index d7273e0..94d369a 100644 (file)
 #ifndef DAEMON_H
 #define DAEMON_H 1
 
+#include <stdbool.h>
+
+#define DAEMON_LONG_OPTIONS                         \
+        {"detach",      no_argument, 0, 'D'},       \
+        {"force",       no_argument, 0, 'f'},       \
+        {"pidfile",     optional_argument, 0, 'P'}
+
+#define DAEMON_OPTION_HANDLERS                  \
+        case 'D':                               \
+            set_detach();                       \
+            break;                              \
+                                                \
+        case 'P':                               \
+            set_pidfile(optarg);                \
+            break;                              \
+                                                \
+        case 'f':                               \
+            ignore_existing_pidfile();          \
+            break;
+
 char *make_pidfile_name(const char *name);
 void set_pidfile(const char *name);
+const char *get_pidfile(void);
 void set_detach(void);
 void daemonize(void);
+void die_if_already_running(void);
+void ignore_existing_pidfile(void);
+void daemon_usage(void);
 
 #endif /* daemon.h */