| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#include "alloc-util.h" |
| 4 |
#include "bus-label.h" |
| 5 |
#include "glyph-util.h" |
| 6 |
#include "string-table.h" |
| 7 |
#include "string-util.h" |
| 8 |
#include "unit-def.h" |
| 9 |
#include "unit-name.h" |
| 10 |
|
| 11 |
char* unit_dbus_path_from_name(const char *name) { |
| 12 |
_cleanup_free_ char *e = NULL; |
| 13 |
|
| 14 |
assert(name); |
| 15 |
|
| 16 |
e = bus_label_escape(name); |
| 17 |
if (!e) |
| 18 |
return NULL; |
| 19 |
|
| 20 |
return strjoin("/org/freedesktop/systemd1/unit/", e); |
| 21 |
} |
| 22 |
|
| 23 |
int unit_name_from_dbus_path(const char *path, char **name) { |
| 24 |
const char *e; |
| 25 |
char *n; |
| 26 |
|
| 27 |
assert(name); |
| 28 |
|
| 29 |
e = startswith(path, "/org/freedesktop/systemd1/unit/"); |
| 30 |
if (!e) |
| 31 |
return -EINVAL; |
| 32 |
|
| 33 |
n = bus_label_unescape(e); |
| 34 |
if (!n) |
| 35 |
return -ENOMEM; |
| 36 |
|
| 37 |
*name = n; |
| 38 |
return 0; |
| 39 |
} |
| 40 |
|
| 41 |
const char* unit_dbus_interface_from_type(UnitType t) { |
| 42 |
|
| 43 |
static const char *const table[_UNIT_TYPE_MAX] = { |
| 44 |
[UNIT_SERVICE] = "org.freedesktop.systemd1.Service", |
| 45 |
[UNIT_SOCKET] = "org.freedesktop.systemd1.Socket", |
| 46 |
[UNIT_TARGET] = "org.freedesktop.systemd1.Target", |
| 47 |
[UNIT_DEVICE] = "org.freedesktop.systemd1.Device", |
| 48 |
[UNIT_MOUNT] = "org.freedesktop.systemd1.Mount", |
| 49 |
[UNIT_AUTOMOUNT] = "org.freedesktop.systemd1.Automount", |
| 50 |
[UNIT_SWAP] = "org.freedesktop.systemd1.Swap", |
| 51 |
[UNIT_TIMER] = "org.freedesktop.systemd1.Timer", |
| 52 |
[UNIT_PATH] = "org.freedesktop.systemd1.Path", |
| 53 |
[UNIT_SLICE] = "org.freedesktop.systemd1.Slice", |
| 54 |
[UNIT_SCOPE] = "org.freedesktop.systemd1.Scope", |
| 55 |
}; |
| 56 |
|
| 57 |
if (t < 0) |
| 58 |
return NULL; |
| 59 |
if (t >= _UNIT_TYPE_MAX) |
| 60 |
return NULL; |
| 61 |
|
| 62 |
return table[t]; |
| 63 |
} |
| 64 |
|
| 65 |
const char* unit_dbus_interface_from_name(const char *name) { |
| 66 |
UnitType t; |
| 67 |
|
| 68 |
t = unit_name_to_type(name); |
| 69 |
if (t < 0) |
| 70 |
return NULL; |
| 71 |
|
| 72 |
return unit_dbus_interface_from_type(t); |
| 73 |
} |
| 74 |
|
| 75 |
const char* unit_type_to_capitalized_string(UnitType t) { |
| 76 |
const char *di = unit_dbus_interface_from_type(t); |
| 77 |
if (!di) |
| 78 |
return NULL; |
| 79 |
|
| 80 |
return ASSERT_PTR(startswith(di, "org.freedesktop.systemd1.")); |
| 81 |
} |
| 82 |
|
| 83 |
static const char* const unit_type_table[_UNIT_TYPE_MAX] = { |
| 84 |
[UNIT_SERVICE] = "service", |
| 85 |
[UNIT_SOCKET] = "socket", |
| 86 |
[UNIT_TARGET] = "target", |
| 87 |
[UNIT_DEVICE] = "device", |
| 88 |
[UNIT_MOUNT] = "mount", |
| 89 |
[UNIT_AUTOMOUNT] = "automount", |
| 90 |
[UNIT_SWAP] = "swap", |
| 91 |
[UNIT_TIMER] = "timer", |
| 92 |
[UNIT_PATH] = "path", |
| 93 |
[UNIT_SLICE] = "slice", |
| 94 |
[UNIT_SCOPE] = "scope", |
| 95 |
}; |
| 96 |
|
| 97 |
DEFINE_STRING_TABLE_LOOKUP(unit_type, UnitType); |
| 98 |
|
| 99 |
static const char* const unit_load_state_table[_UNIT_LOAD_STATE_MAX] = { |
| 100 |
[UNIT_STUB] = "stub", |
| 101 |
[UNIT_LOADED] = "loaded", |
| 102 |
[UNIT_NOT_FOUND] = "not-found", |
| 103 |
[UNIT_BAD_SETTING] = "bad-setting", |
| 104 |
[UNIT_ERROR] = "error", |
| 105 |
[UNIT_MERGED] = "merged", |
| 106 |
[UNIT_MASKED] = "masked", |
| 107 |
}; |
| 108 |
|
| 109 |
DEFINE_STRING_TABLE_LOOKUP(unit_load_state, UnitLoadState); |
| 110 |
|
| 111 |
/* Keep in sync with man/unit-states.xml */ |
| 112 |
static const char* const unit_active_state_table[_UNIT_ACTIVE_STATE_MAX] = { |
| 113 |
[UNIT_ACTIVE] = "active", |
| 114 |
[UNIT_RELOADING] = "reloading", |
| 115 |
[UNIT_INACTIVE] = "inactive", |
| 116 |
[UNIT_FAILED] = "failed", |
| 117 |
[UNIT_ACTIVATING] = "activating", |
| 118 |
[UNIT_DEACTIVATING] = "deactivating", |
| 119 |
[UNIT_MAINTENANCE] = "maintenance", |
| 120 |
[UNIT_REFRESHING] = "refreshing", |
| 121 |
}; |
| 122 |
|
| 123 |
DEFINE_STRING_TABLE_LOOKUP(unit_active_state, UnitActiveState); |
| 124 |
|
| 125 |
static const char* const freezer_state_table[_FREEZER_STATE_MAX] = { |
| 126 |
[FREEZER_RUNNING] = "running", |
| 127 |
[FREEZER_FREEZING] = "freezing", |
| 128 |
[FREEZER_FREEZING_BY_PARENT] = "freezing-by-parent", |
| 129 |
[FREEZER_FROZEN] = "frozen", |
| 130 |
[FREEZER_FROZEN_BY_PARENT] = "frozen-by-parent", |
| 131 |
[FREEZER_THAWING] = "thawing", |
| 132 |
}; |
| 133 |
|
| 134 |
DEFINE_STRING_TABLE_LOOKUP(freezer_state, FreezerState); |
| 135 |
|
| 136 |
/* Maps in-progress freezer states to the corresponding finished state */ |
| 137 |
static const FreezerState freezer_state_finish_table[_FREEZER_STATE_MAX] = { |
| 138 |
[FREEZER_FREEZING] = FREEZER_FROZEN, |
| 139 |
[FREEZER_FREEZING_BY_PARENT] = FREEZER_FROZEN_BY_PARENT, |
| 140 |
[FREEZER_THAWING] = FREEZER_RUNNING, |
| 141 |
|
| 142 |
/* Finished states trivially map to themselves */ |
| 143 |
[FREEZER_RUNNING] = FREEZER_RUNNING, |
| 144 |
[FREEZER_FROZEN] = FREEZER_FROZEN, |
| 145 |
[FREEZER_FROZEN_BY_PARENT] = FREEZER_FROZEN_BY_PARENT, |
| 146 |
}; |
| 147 |
|
| 148 |
FreezerState freezer_state_finish(FreezerState state) { |
| 149 |
assert(state >= 0); |
| 150 |
assert(state < _FREEZER_STATE_MAX); |
| 151 |
|
| 152 |
return freezer_state_finish_table[state]; |
| 153 |
} |
| 154 |
|
| 155 |
FreezerState freezer_state_objective(FreezerState state) { |
| 156 |
FreezerState objective; |
| 157 |
|
| 158 |
objective = freezer_state_finish(state); |
| 159 |
if (objective == FREEZER_FROZEN_BY_PARENT) |
| 160 |
objective = FREEZER_FROZEN; |
| 161 |
|
| 162 |
return objective; |
| 163 |
} |
| 164 |
|
| 165 |
static const char* const unit_marker_table[_UNIT_MARKER_MAX] = { |
| 166 |
[UNIT_MARKER_NEEDS_RELOAD] = "needs-reload", |
| 167 |
[UNIT_MARKER_NEEDS_RESTART] = "needs-restart", |
| 168 |
[UNIT_MARKER_NEEDS_STOP] = "needs-stop", |
| 169 |
[UNIT_MARKER_NEEDS_START] = "needs-start", |
| 170 |
}; |
| 171 |
|
| 172 |
DEFINE_STRING_TABLE_LOOKUP(unit_marker, UnitMarker); |
| 173 |
|
| 174 |
static const char* const automount_state_table[_AUTOMOUNT_STATE_MAX] = { |
| 175 |
[AUTOMOUNT_DEAD] = "dead", |
| 176 |
[AUTOMOUNT_WAITING] = "waiting", |
| 177 |
[AUTOMOUNT_RUNNING] = "running", |
| 178 |
[AUTOMOUNT_FAILED] = "failed", |
| 179 |
}; |
| 180 |
|
| 181 |
DEFINE_STRING_TABLE_LOOKUP(automount_state, AutomountState); |
| 182 |
|
| 183 |
static const char* const device_state_table[_DEVICE_STATE_MAX] = { |
| 184 |
[DEVICE_DEAD] = "dead", |
| 185 |
[DEVICE_TENTATIVE] = "tentative", |
| 186 |
[DEVICE_PLUGGED] = "plugged", |
| 187 |
}; |
| 188 |
|
| 189 |
DEFINE_STRING_TABLE_LOOKUP(device_state, DeviceState); |
| 190 |
|
| 191 |
static const char* const mount_state_table[_MOUNT_STATE_MAX] = { |
| 192 |
[MOUNT_DEAD] = "dead", |
| 193 |
[MOUNT_MOUNTING] = "mounting", |
| 194 |
[MOUNT_MOUNTING_DONE] = "mounting-done", |
| 195 |
[MOUNT_MOUNTED] = "mounted", |
| 196 |
[MOUNT_REMOUNTING] = "remounting", |
| 197 |
[MOUNT_UNMOUNTING] = "unmounting", |
| 198 |
[MOUNT_REMOUNTING_SIGTERM] = "remounting-sigterm", |
| 199 |
[MOUNT_REMOUNTING_SIGKILL] = "remounting-sigkill", |
| 200 |
[MOUNT_UNMOUNTING_SIGTERM] = "unmounting-sigterm", |
| 201 |
[MOUNT_UNMOUNTING_SIGKILL] = "unmounting-sigkill", |
| 202 |
[MOUNT_FAILED] = "failed", |
| 203 |
[MOUNT_CLEANING] = "cleaning", |
| 204 |
}; |
| 205 |
|
| 206 |
DEFINE_STRING_TABLE_LOOKUP(mount_state, MountState); |
| 207 |
|
| 208 |
static const char* const path_state_table[_PATH_STATE_MAX] = { |
| 209 |
[PATH_DEAD] = "dead", |
| 210 |
[PATH_WAITING] = "waiting", |
| 211 |
[PATH_RUNNING] = "running", |
| 212 |
[PATH_FAILED] = "failed", |
| 213 |
}; |
| 214 |
|
| 215 |
DEFINE_STRING_TABLE_LOOKUP(path_state, PathState); |
| 216 |
|
| 217 |
static const char* const scope_state_table[_SCOPE_STATE_MAX] = { |
| 218 |
[SCOPE_DEAD] = "dead", |
| 219 |
[SCOPE_START_CHOWN] = "start-chown", |
| 220 |
[SCOPE_RUNNING] = "running", |
| 221 |
[SCOPE_ABANDONED] = "abandoned", |
| 222 |
[SCOPE_STOP_SIGTERM] = "stop-sigterm", |
| 223 |
[SCOPE_STOP_SIGKILL] = "stop-sigkill", |
| 224 |
[SCOPE_FAILED] = "failed", |
| 225 |
}; |
| 226 |
|
| 227 |
DEFINE_STRING_TABLE_LOOKUP(scope_state, ScopeState); |
| 228 |
|
| 229 |
static const char* const service_state_table[_SERVICE_STATE_MAX] = { |
| 230 |
[SERVICE_DEAD] = "dead", |
| 231 |
[SERVICE_CONDITION] = "condition", |
| 232 |
[SERVICE_START_PRE] = "start-pre", |
| 233 |
[SERVICE_START] = "start", |
| 234 |
[SERVICE_START_POST] = "start-post", |
| 235 |
[SERVICE_RUNNING] = "running", |
| 236 |
[SERVICE_EXITED] = "exited", |
| 237 |
[SERVICE_REFRESH_EXTENSIONS] = "refresh-extensions", |
| 238 |
[SERVICE_REFRESH_CREDENTIALS] = "refresh-credentials", |
| 239 |
[SERVICE_RELOAD] = "reload", |
| 240 |
[SERVICE_RELOAD_SIGNAL] = "reload-signal", |
| 241 |
[SERVICE_RELOAD_NOTIFY] = "reload-notify", |
| 242 |
[SERVICE_RELOAD_POST] = "reload-post", |
| 243 |
[SERVICE_STOP] = "stop", |
| 244 |
[SERVICE_STOP_WATCHDOG] = "stop-watchdog", |
| 245 |
[SERVICE_STOP_SIGTERM] = "stop-sigterm", |
| 246 |
[SERVICE_STOP_SIGKILL] = "stop-sigkill", |
| 247 |
[SERVICE_STOP_POST] = "stop-post", |
| 248 |
[SERVICE_FINAL_WATCHDOG] = "final-watchdog", |
| 249 |
[SERVICE_FINAL_SIGTERM] = "final-sigterm", |
| 250 |
[SERVICE_FINAL_SIGKILL] = "final-sigkill", |
| 251 |
[SERVICE_FAILED] = "failed", |
| 252 |
[SERVICE_DEAD_BEFORE_AUTO_RESTART] = "dead-before-auto-restart", |
| 253 |
[SERVICE_FAILED_BEFORE_AUTO_RESTART] = "failed-before-auto-restart", |
| 254 |
[SERVICE_DEAD_RESOURCES_PINNED] = "dead-resources-pinned", |
| 255 |
[SERVICE_AUTO_RESTART] = "auto-restart", |
| 256 |
[SERVICE_AUTO_RESTART_QUEUED] = "auto-restart-queued", |
| 257 |
[SERVICE_CLEANING] = "cleaning", |
| 258 |
[SERVICE_MOUNTING] = "mounting", |
| 259 |
}; |
| 260 |
|
| 261 |
DEFINE_STRING_TABLE_LOOKUP(service_state, ServiceState); |
| 262 |
|
| 263 |
static const char* const slice_state_table[_SLICE_STATE_MAX] = { |
| 264 |
[SLICE_DEAD] = "dead", |
| 265 |
[SLICE_ACTIVE] = "active", |
| 266 |
}; |
| 267 |
|
| 268 |
DEFINE_STRING_TABLE_LOOKUP(slice_state, SliceState); |
| 269 |
|
| 270 |
static const char* const socket_state_table[_SOCKET_STATE_MAX] = { |
| 271 |
[SOCKET_DEAD] = "dead", |
| 272 |
[SOCKET_START_PRE] = "start-pre", |
| 273 |
[SOCKET_START_OPEN] = "start-open", |
| 274 |
[SOCKET_START_CHOWN] = "start-chown", |
| 275 |
[SOCKET_START_POST] = "start-post", |
| 276 |
[SOCKET_LISTENING] = "listening", |
| 277 |
[SOCKET_DEFERRED] = "deferred", |
| 278 |
[SOCKET_RUNNING] = "running", |
| 279 |
[SOCKET_STOP_PRE] = "stop-pre", |
| 280 |
[SOCKET_STOP_PRE_SIGTERM] = "stop-pre-sigterm", |
| 281 |
[SOCKET_STOP_PRE_SIGKILL] = "stop-pre-sigkill", |
| 282 |
[SOCKET_STOP_POST] = "stop-post", |
| 283 |
[SOCKET_FINAL_SIGTERM] = "final-sigterm", |
| 284 |
[SOCKET_FINAL_SIGKILL] = "final-sigkill", |
| 285 |
[SOCKET_FAILED] = "failed", |
| 286 |
[SOCKET_CLEANING] = "cleaning", |
| 287 |
}; |
| 288 |
|
| 289 |
DEFINE_STRING_TABLE_LOOKUP(socket_state, SocketState); |
| 290 |
|
| 291 |
static const char* const swap_state_table[_SWAP_STATE_MAX] = { |
| 292 |
[SWAP_DEAD] = "dead", |
| 293 |
[SWAP_ACTIVATING] = "activating", |
| 294 |
[SWAP_ACTIVATING_DONE] = "activating-done", |
| 295 |
[SWAP_ACTIVE] = "active", |
| 296 |
[SWAP_DEACTIVATING] = "deactivating", |
| 297 |
[SWAP_DEACTIVATING_SIGTERM] = "deactivating-sigterm", |
| 298 |
[SWAP_DEACTIVATING_SIGKILL] = "deactivating-sigkill", |
| 299 |
[SWAP_FAILED] = "failed", |
| 300 |
[SWAP_CLEANING] = "cleaning", |
| 301 |
}; |
| 302 |
|
| 303 |
DEFINE_STRING_TABLE_LOOKUP(swap_state, SwapState); |
| 304 |
|
| 305 |
static const char* const target_state_table[_TARGET_STATE_MAX] = { |
| 306 |
[TARGET_DEAD] = "dead", |
| 307 |
[TARGET_ACTIVE] = "active", |
| 308 |
}; |
| 309 |
|
| 310 |
DEFINE_STRING_TABLE_LOOKUP(target_state, TargetState); |
| 311 |
|
| 312 |
static const char* const timer_state_table[_TIMER_STATE_MAX] = { |
| 313 |
[TIMER_DEAD] = "dead", |
| 314 |
[TIMER_WAITING] = "waiting", |
| 315 |
[TIMER_RUNNING] = "running", |
| 316 |
[TIMER_ELAPSED] = "elapsed", |
| 317 |
[TIMER_FAILED] = "failed", |
| 318 |
}; |
| 319 |
|
| 320 |
DEFINE_STRING_TABLE_LOOKUP(timer_state, TimerState); |
| 321 |
|
| 322 |
static const char* const unit_dependency_table[_UNIT_DEPENDENCY_MAX] = { |
| 323 |
[UNIT_REQUIRES] = "Requires", |
| 324 |
[UNIT_REQUISITE] = "Requisite", |
| 325 |
[UNIT_WANTS] = "Wants", |
| 326 |
[UNIT_BINDS_TO] = "BindsTo", |
| 327 |
[UNIT_PART_OF] = "PartOf", |
| 328 |
[UNIT_UPHOLDS] = "Upholds", |
| 329 |
[UNIT_REQUIRED_BY] = "RequiredBy", |
| 330 |
[UNIT_REQUISITE_OF] = "RequisiteOf", |
| 331 |
[UNIT_WANTED_BY] = "WantedBy", |
| 332 |
[UNIT_BOUND_BY] = "BoundBy", |
| 333 |
[UNIT_UPHELD_BY] = "UpheldBy", |
| 334 |
[UNIT_CONSISTS_OF] = "ConsistsOf", |
| 335 |
[UNIT_CONFLICTS] = "Conflicts", |
| 336 |
[UNIT_CONFLICTED_BY] = "ConflictedBy", |
| 337 |
[UNIT_BEFORE] = "Before", |
| 338 |
[UNIT_AFTER] = "After", |
| 339 |
[UNIT_ON_SUCCESS] = "OnSuccess", |
| 340 |
[UNIT_ON_SUCCESS_OF] = "OnSuccessOf", |
| 341 |
[UNIT_ON_FAILURE] = "OnFailure", |
| 342 |
[UNIT_ON_FAILURE_OF] = "OnFailureOf", |
| 343 |
[UNIT_TRIGGERS] = "Triggers", |
| 344 |
[UNIT_TRIGGERED_BY] = "TriggeredBy", |
| 345 |
[UNIT_PROPAGATES_RELOAD_TO] = "PropagatesReloadTo", |
| 346 |
[UNIT_RELOAD_PROPAGATED_FROM] = "ReloadPropagatedFrom", |
| 347 |
[UNIT_PROPAGATES_STOP_TO] = "PropagatesStopTo", |
| 348 |
[UNIT_STOP_PROPAGATED_FROM] = "StopPropagatedFrom", |
| 349 |
[UNIT_JOINS_NAMESPACE_OF] = "JoinsNamespaceOf", |
| 350 |
[UNIT_REFERENCES] = "References", |
| 351 |
[UNIT_REFERENCED_BY] = "ReferencedBy", |
| 352 |
[UNIT_IN_SLICE] = "InSlice", |
| 353 |
[UNIT_SLICE_OF] = "SliceOf", |
| 354 |
}; |
| 355 |
|
| 356 |
DEFINE_STRING_TABLE_LOOKUP(unit_dependency, UnitDependency); |
| 357 |
|
| 358 |
void unit_types_list(void) { |
| 359 |
DUMP_STRING_TABLE(unit_dependency, UnitDependency, _UNIT_DEPENDENCY_MAX); |
| 360 |
} |
| 361 |
|
| 362 |
static const char* const notify_access_table[_NOTIFY_ACCESS_MAX] = { |
| 363 |
[NOTIFY_NONE] = "none", |
| 364 |
[NOTIFY_MAIN] = "main", |
| 365 |
[NOTIFY_EXEC] = "exec", |
| 366 |
[NOTIFY_ALL] = "all", |
| 367 |
}; |
| 368 |
|
| 369 |
DEFINE_STRING_TABLE_LOOKUP(notify_access, NotifyAccess); |
| 370 |
|
| 371 |
static const char* const job_mode_table[_JOB_MODE_MAX] = { |
| 372 |
[JOB_FAIL] = "fail", |
| 373 |
[JOB_LENIENT] = "lenient", |
| 374 |
[JOB_REPLACE] = "replace", |
| 375 |
[JOB_REPLACE_IRREVERSIBLY] = "replace-irreversibly", |
| 376 |
[JOB_ISOLATE] = "isolate", |
| 377 |
[JOB_FLUSH] = "flush", |
| 378 |
[JOB_IGNORE_DEPENDENCIES] = "ignore-dependencies", |
| 379 |
[JOB_IGNORE_REQUIREMENTS] = "ignore-requirements", |
| 380 |
[JOB_TRIGGERING] = "triggering", |
| 381 |
[JOB_RESTART_DEPENDENCIES] = "restart-dependencies", |
| 382 |
}; |
| 383 |
|
| 384 |
DEFINE_STRING_TABLE_LOOKUP(job_mode, JobMode); |
| 385 |
|
| 386 |
/* This table maps ExecDirectoryType to the setting it is configured with in the unit */ |
| 387 |
static const char* const exec_directory_type_table[_EXEC_DIRECTORY_TYPE_MAX] = { |
| 388 |
[EXEC_DIRECTORY_RUNTIME] = "RuntimeDirectory", |
| 389 |
[EXEC_DIRECTORY_STATE] = "StateDirectory", |
| 390 |
[EXEC_DIRECTORY_CACHE] = "CacheDirectory", |
| 391 |
[EXEC_DIRECTORY_LOGS] = "LogsDirectory", |
| 392 |
[EXEC_DIRECTORY_CONFIGURATION] = "ConfigurationDirectory", |
| 393 |
}; |
| 394 |
|
| 395 |
DEFINE_STRING_TABLE_LOOKUP(exec_directory_type, ExecDirectoryType); |
| 396 |
|
| 397 |
Glyph unit_active_state_to_glyph(UnitActiveState state) { |
| 398 |
static const Glyph map[_UNIT_ACTIVE_STATE_MAX] = { |
| 399 |
[UNIT_ACTIVE] = GLYPH_BLACK_CIRCLE, |
| 400 |
[UNIT_RELOADING] = GLYPH_CIRCLE_ARROW, |
| 401 |
[UNIT_REFRESHING] = GLYPH_CIRCLE_ARROW, |
| 402 |
[UNIT_INACTIVE] = GLYPH_WHITE_CIRCLE, |
| 403 |
[UNIT_FAILED] = GLYPH_MULTIPLICATION_SIGN, |
| 404 |
[UNIT_ACTIVATING] = GLYPH_BLACK_CIRCLE, |
| 405 |
[UNIT_DEACTIVATING] = GLYPH_BLACK_CIRCLE, |
| 406 |
[UNIT_MAINTENANCE] = GLYPH_WHITE_CIRCLE, |
| 407 |
}; |
| 408 |
|
| 409 |
if (state < 0) |
| 410 |
return _GLYPH_INVALID; |
| 411 |
|
| 412 |
assert(state < _UNIT_ACTIVE_STATE_MAX); |
| 413 |
return map[state]; |
| 414 |
} |