1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-24 21:34:08 +03:00

unit: Move UnitLoadState definitions from core/unit.c to shared/unit-name.c

This makes it possible to use them from systemctl without linking
against the core.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2012-07-10 17:18:09 +02:00 committed by Lennart Poettering
parent bcbe497e5a
commit f69614f811
4 changed files with 24 additions and 24 deletions

View File

@ -2746,16 +2746,6 @@ int unit_add_mount_links(Unit *u) {
return 0; return 0;
} }
static const char* const unit_load_state_table[_UNIT_LOAD_STATE_MAX] = {
[UNIT_STUB] = "stub",
[UNIT_LOADED] = "loaded",
[UNIT_ERROR] = "error",
[UNIT_MERGED] = "merged",
[UNIT_MASKED] = "masked"
};
DEFINE_STRING_TABLE_LOOKUP(unit_load_state, UnitLoadState);
static const char* const unit_active_state_table[_UNIT_ACTIVE_STATE_MAX] = { static const char* const unit_active_state_table[_UNIT_ACTIVE_STATE_MAX] = {
[UNIT_ACTIVE] = "active", [UNIT_ACTIVE] = "active",
[UNIT_RELOADING] = "reloading", [UNIT_RELOADING] = "reloading",

View File

@ -28,7 +28,6 @@
typedef struct Unit Unit; typedef struct Unit Unit;
typedef struct UnitVTable UnitVTable; typedef struct UnitVTable UnitVTable;
typedef enum UnitType UnitType; typedef enum UnitType UnitType;
typedef enum UnitLoadState UnitLoadState;
typedef enum UnitActiveState UnitActiveState; typedef enum UnitActiveState UnitActiveState;
typedef enum UnitDependency UnitDependency; typedef enum UnitDependency UnitDependency;
typedef struct UnitRef UnitRef; typedef struct UnitRef UnitRef;
@ -43,16 +42,6 @@ typedef struct UnitStatusMessageFormats UnitStatusMessageFormats;
#include "install.h" #include "install.h"
#include "unit-name.h" #include "unit-name.h"
enum UnitLoadState {
UNIT_STUB,
UNIT_LOADED,
UNIT_ERROR,
UNIT_MERGED,
UNIT_MASKED,
_UNIT_LOAD_STATE_MAX,
_UNIT_LOAD_STATE_INVALID = -1
};
enum UnitActiveState { enum UnitActiveState {
UNIT_ACTIVE, UNIT_ACTIVE,
UNIT_RELOADING, UNIT_RELOADING,
@ -549,9 +538,6 @@ void unit_ref_unset(UnitRef *ref);
int unit_add_one_mount_link(Unit *u, Mount *m); int unit_add_one_mount_link(Unit *u, Mount *m);
int unit_add_mount_links(Unit *u); int unit_add_mount_links(Unit *u);
const char *unit_load_state_to_string(UnitLoadState i);
UnitLoadState unit_load_state_from_string(const char *s);
const char *unit_active_state_to_string(UnitActiveState i); const char *unit_active_state_to_string(UnitActiveState i);
UnitActiveState unit_active_state_from_string(const char *s); UnitActiveState unit_active_state_from_string(const char *s);

View File

@ -48,6 +48,16 @@ static const char* const unit_type_table[_UNIT_TYPE_MAX] = {
DEFINE_STRING_TABLE_LOOKUP(unit_type, UnitType); DEFINE_STRING_TABLE_LOOKUP(unit_type, UnitType);
static const char* const unit_load_state_table[_UNIT_LOAD_STATE_MAX] = {
[UNIT_STUB] = "stub",
[UNIT_LOADED] = "loaded",
[UNIT_ERROR] = "error",
[UNIT_MERGED] = "merged",
[UNIT_MASKED] = "masked"
};
DEFINE_STRING_TABLE_LOOKUP(unit_load_state, UnitLoadState);
bool unit_name_is_valid(const char *n, bool template_ok) { bool unit_name_is_valid(const char *n, bool template_ok) {
const char *e, *i, *at; const char *e, *i, *at;

View File

@ -27,6 +27,7 @@
#define UNIT_NAME_MAX 256 #define UNIT_NAME_MAX 256
typedef enum UnitType UnitType; typedef enum UnitType UnitType;
typedef enum UnitLoadState UnitLoadState;
enum UnitType { enum UnitType {
UNIT_SERVICE = 0, UNIT_SERVICE = 0,
@ -43,9 +44,22 @@ enum UnitType {
_UNIT_TYPE_INVALID = -1 _UNIT_TYPE_INVALID = -1
}; };
enum UnitLoadState {
UNIT_STUB,
UNIT_LOADED,
UNIT_ERROR,
UNIT_MERGED,
UNIT_MASKED,
_UNIT_LOAD_STATE_MAX,
_UNIT_LOAD_STATE_INVALID = -1
};
const char *unit_type_to_string(UnitType i); const char *unit_type_to_string(UnitType i);
UnitType unit_type_from_string(const char *s); UnitType unit_type_from_string(const char *s);
const char *unit_load_state_to_string(UnitLoadState i);
UnitLoadState unit_load_state_from_string(const char *s);
int unit_name_to_instance(const char *n, char **instance); int unit_name_to_instance(const char *n, char **instance);
char* unit_name_to_prefix(const char *n); char* unit_name_to_prefix(const char *n);
char* unit_name_to_prefix_and_instance(const char *n); char* unit_name_to_prefix_and_instance(const char *n);