summaryrefslogtreecommitdiff
path: root/src/shared/sleep-config.h
diff options
context:
space:
mode:
authorZach Smith <z@zxmth.us>2019-05-19 22:43:29 -0700
committerZach Smith <z@zxmth.us>2019-05-30 06:06:16 -0700
commit28ca9c249983cded04a3eb755c1950251c3c3b27 (patch)
tree17f6d64be4cc141957387522c1a9392de6100fff /src/shared/sleep-config.h
parent1bbbefe7a68059eb55d864c3e0e670d00269683a (diff)
downloadsystemd-28ca9c249983cded04a3eb755c1950251c3c3b27.tar.gz
systemd-sleep: refactor sleep config parsing
remove verb from parse refactor required fields checks refactor allow settings
Diffstat (limited to 'src/shared/sleep-config.h')
-rw-r--r--src/shared/sleep-config.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/shared/sleep-config.h b/src/shared/sleep-config.h
index c584f44d39..965fde93a2 100644
--- a/src/shared/sleep-config.h
+++ b/src/shared/sleep-config.h
@@ -4,8 +4,29 @@
#include <linux/fiemap.h>
#include "time-util.h"
+typedef struct SleepConfig {
+ bool allow_suspend; /* AllowSuspend */
+ bool allow_hibernate; /* AllowHibernation */
+ bool allow_s2h; /* AllowSuspendThenHibernate */
+ bool allow_hybrid_sleep; /* AllowHybridSleep */
+
+ char **suspend_modes; /* SuspendMode */
+ char **suspend_states; /* SuspendState */
+ char **hibernate_modes; /* HibernateMode */
+ char **hibernate_states; /* HibernateState */
+ char **hybrid_modes; /* HybridSleepMode */
+ char **hybrid_states; /* HybridSleepState */
+
+ usec_t hibernate_delay_sec; /* HibernateDelaySec */
+} SleepConfig;
+
+void free_sleep_config(SleepConfig *sc);
+DEFINE_TRIVIAL_CLEANUP_FUNC(SleepConfig*, free_sleep_config);
+
+int sleep_settings(const char *verb, const SleepConfig *sleep_config, bool *ret_allow, char ***ret_modes, char ***ret_states);
+
int read_fiemap(int fd, struct fiemap **ret);
-int parse_sleep_config(const char *verb, bool *ret_allow, char ***ret_modes, char ***ret_states, usec_t *ret_delay);
+int parse_sleep_config(SleepConfig **sleep_config);
int find_hibernate_location(char **device, char **type, size_t *size, size_t *used);
int can_sleep(const char *verb);