]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic: move JobMode from core
authorGavin Li <gavinli@thegavinli.com>
Fri, 3 Jan 2025 05:46:39 +0000 (00:46 -0500)
committerGavin Li <gavinli@thegavinli.com>
Tue, 21 Jan 2025 04:19:00 +0000 (23:19 -0500)
The JobMode string table functions can be used by utilities for argument
validation.

src/basic/unit-def.c
src/basic/unit-def.h
src/core/job.c
src/core/job.h

index 129d61b99cbc9e57549083d26d34e2c7f42a4457..3be9d16333b9ee6f9d6567064ad76f2bb2480497 100644 (file)
@@ -344,6 +344,20 @@ static const char* const notify_access_table[_NOTIFY_ACCESS_MAX] = {
 
 DEFINE_STRING_TABLE_LOOKUP(notify_access, NotifyAccess);
 
+static const char* const job_mode_table[_JOB_MODE_MAX] = {
+        [JOB_FAIL]                 = "fail",
+        [JOB_REPLACE]              = "replace",
+        [JOB_REPLACE_IRREVERSIBLY] = "replace-irreversibly",
+        [JOB_ISOLATE]              = "isolate",
+        [JOB_FLUSH]                = "flush",
+        [JOB_IGNORE_DEPENDENCIES]  = "ignore-dependencies",
+        [JOB_IGNORE_REQUIREMENTS]  = "ignore-requirements",
+        [JOB_TRIGGERING]           = "triggering",
+        [JOB_RESTART_DEPENDENCIES] = "restart-dependencies",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(job_mode, JobMode);
+
 SpecialGlyph unit_active_state_to_glyph(UnitActiveState state) {
         static const SpecialGlyph map[_UNIT_ACTIVE_STATE_MAX] = {
                 [UNIT_ACTIVE]       = SPECIAL_GLYPH_BLACK_CIRCLE,
index bead8b47ac1773b2bee5da6f34e4c4920efa0265..a9548e2991372841c9dc6d2ab0051acddbf14b54 100644 (file)
@@ -283,6 +283,20 @@ typedef enum NotifyAccess {
         _NOTIFY_ACCESS_INVALID = -EINVAL,
 } NotifyAccess;
 
+typedef enum JobMode {
+        JOB_FAIL,                /* Fail if a conflicting job is already queued */
+        JOB_REPLACE,             /* Replace an existing conflicting job */
+        JOB_REPLACE_IRREVERSIBLY,/* Like JOB_REPLACE + produce irreversible jobs */
+        JOB_ISOLATE,             /* Start a unit, and stop all others */
+        JOB_FLUSH,               /* Flush out all other queued jobs when queueing this one */
+        JOB_IGNORE_DEPENDENCIES, /* Ignore both requirement and ordering dependencies */
+        JOB_IGNORE_REQUIREMENTS, /* Ignore requirement dependencies */
+        JOB_TRIGGERING,          /* Adds TRIGGERED_BY dependencies to the same transaction */
+        JOB_RESTART_DEPENDENCIES,/* A "start" job for the specified unit becomes "restart" for depending units */
+        _JOB_MODE_MAX,
+        _JOB_MODE_INVALID = -EINVAL,
+} JobMode;
+
 char* unit_dbus_path_from_name(const char *name);
 int unit_name_from_dbus_path(const char *path, char **name);
 
@@ -346,4 +360,7 @@ UnitDependency unit_dependency_from_string(const char *s) _pure_;
 const char* notify_access_to_string(NotifyAccess i) _const_;
 NotifyAccess notify_access_from_string(const char *s) _pure_;
 
+const char* job_mode_to_string(JobMode t) _const_;
+JobMode job_mode_from_string(const char *s) _pure_;
+
 SpecialGlyph unit_active_state_to_glyph(UnitActiveState state);
index 8fbbe757feb31d4fa0d55e78073f8ca2f91d8a90..0265e7034986624e299487ca6987aa4ea0ad0fa7 100644 (file)
@@ -1651,20 +1651,6 @@ static const char* const job_type_table[_JOB_TYPE_MAX] = {
 
 DEFINE_STRING_TABLE_LOOKUP(job_type, JobType);
 
-static const char* const job_mode_table[_JOB_MODE_MAX] = {
-        [JOB_FAIL]                 = "fail",
-        [JOB_REPLACE]              = "replace",
-        [JOB_REPLACE_IRREVERSIBLY] = "replace-irreversibly",
-        [JOB_ISOLATE]              = "isolate",
-        [JOB_FLUSH]                = "flush",
-        [JOB_IGNORE_DEPENDENCIES]  = "ignore-dependencies",
-        [JOB_IGNORE_REQUIREMENTS]  = "ignore-requirements",
-        [JOB_TRIGGERING]           = "triggering",
-        [JOB_RESTART_DEPENDENCIES] = "restart-dependencies",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(job_mode, JobMode);
-
 static const char* const job_result_table[_JOB_RESULT_MAX] = {
         [JOB_DONE]        = "done",
         [JOB_CANCELED]    = "canceled",
index f3daf9d094afd57a38947a7bbec6a085705f7907..406eab74ae2f1f6b1597cbbe52e51f832f6bf632 100644 (file)
@@ -14,7 +14,6 @@ typedef struct Job Job;
 typedef struct JobDependency JobDependency;
 typedef enum JobType JobType;
 typedef enum JobState JobState;
-typedef enum JobMode JobMode;
 typedef enum JobResult JobResult;
 typedef struct Manager Manager;
 typedef struct Unit Unit;
@@ -71,20 +70,6 @@ enum JobState {
         _JOB_STATE_INVALID = -EINVAL,
 };
 
-enum JobMode {
-        JOB_FAIL,                /* Fail if a conflicting job is already queued */
-        JOB_REPLACE,             /* Replace an existing conflicting job */
-        JOB_REPLACE_IRREVERSIBLY,/* Like JOB_REPLACE + produce irreversible jobs */
-        JOB_ISOLATE,             /* Start a unit, and stop all others */
-        JOB_FLUSH,               /* Flush out all other queued jobs when queueing this one */
-        JOB_IGNORE_DEPENDENCIES, /* Ignore both requirement and ordering dependencies */
-        JOB_IGNORE_REQUIREMENTS, /* Ignore requirement dependencies */
-        JOB_TRIGGERING,          /* Adds TRIGGERED_BY dependencies to the same transaction */
-        JOB_RESTART_DEPENDENCIES,/* A "start" job for the specified unit becomes "restart" for depending units */
-        _JOB_MODE_MAX,
-        _JOB_MODE_INVALID = -EINVAL,
-};
-
 enum JobResult {
         JOB_DONE,                /* Job completed successfully (or skipped due to an unmet ConditionXYZ=) */
         JOB_CANCELED,            /* Job canceled by a conflicting job installation or by explicit cancel request */
@@ -243,9 +228,6 @@ JobType job_type_from_string(const char *s) _pure_;
 const char* job_state_to_string(JobState t) _const_;
 JobState job_state_from_string(const char *s) _pure_;
 
-const char* job_mode_to_string(JobMode t) _const_;
-JobMode job_mode_from_string(const char *s) _pure_;
-
 const char* job_result_to_string(JobResult t) _const_;
 JobResult job_result_from_string(const char *s) _pure_;