#include "path-util.h"
#include "sleep-config.h"
#include "stdio-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "time-util.h"
return mfree(sc);
}
+
+static const char* const sleep_operation_table[_SLEEP_OPERATION_MAX] = {
+ [SLEEP_SUSPEND] = "suspend",
+ [SLEEP_HIBERNATE] = "hibernate",
+ [SLEEP_HYBRID_SLEEP] = "hybrid-sleep",
+ [SLEEP_SUSPEND_THEN_HIBERNATE] = "suspend-then-hibernate",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(sleep_operation, SleepOperation);
#include <linux/fiemap.h>
#include "time-util.h"
+typedef enum SleepOperation {
+ SLEEP_SUSPEND,
+ SLEEP_HIBERNATE,
+ SLEEP_HYBRID_SLEEP,
+ SLEEP_SUSPEND_THEN_HIBERNATE,
+ _SLEEP_OPERATION_MAX,
+ _SLEEP_OPERATION_INVALID = -EINVAL,
+} SleepOperation;
+
typedef struct SleepConfig {
bool allow_suspend; /* AllowSuspend */
bool allow_hibernate; /* AllowHibernation */
int can_sleep(const char *verb);
int can_sleep_disk(char **types);
int can_sleep_state(char **types);
+
+const char* sleep_operation_to_string(SleepOperation s) _const_;
+SleepOperation sleep_operation_from_string(const char *s) _pure_;