File tree Expand file tree Collapse file tree 2 files changed +10
-18
lines changed Expand file tree Collapse file tree 2 files changed +10
-18
lines changed Original file line number Diff line number Diff line change 1111#include "macro.h"
1212#include "parse-util.h"
1313#include "proc-cmdline.h"
14+ #include "string-table.h"
1415#include "string-util.h"
1516#include "volatile-util.h"
1617
17- VolatileMode volatile_mode_from_string (const char * s ) {
18- int b ;
19-
20- if (isempty (s ))
21- return _VOLATILE_MODE_INVALID ;
22-
23- b = parse_boolean (s );
24- if (b > 0 )
25- return VOLATILE_YES ;
26- if (b == 0 )
27- return VOLATILE_NO ;
28-
29- if (streq (s , "state" ))
30- return VOLATILE_STATE ;
31-
32- return _VOLATILE_MODE_INVALID ;
33- }
34-
3518int query_volatile_mode (VolatileMode * ret ) {
3619 _cleanup_free_ char * mode = NULL ;
3720 VolatileMode m = VOLATILE_NO ;
@@ -56,3 +39,11 @@ int query_volatile_mode(VolatileMode *ret) {
5639 * ret = m ;
5740 return r ;
5841}
42+
43+ static const char * const volatile_mode_table [_VOLATILE_MODE_MAX ] = {
44+ [VOLATILE_NO ] = "no" ,
45+ [VOLATILE_YES ] = "yes" ,
46+ [VOLATILE_STATE ] = "state" ,
47+ };
48+
49+ DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN (volatile_mode , VolatileMode , VOLATILE_YES );
Original file line number Diff line number Diff line change @@ -16,5 +16,6 @@ typedef enum VolatileMode {
1616} VolatileMode ;
1717
1818VolatileMode volatile_mode_from_string (const char * s );
19+ const char * volatile_mode_to_string (VolatileMode m );
1920
2021int query_volatile_mode (VolatileMode * ret );
You can’t perform that action at this time.
0 commit comments