summaryrefslogtreecommitdiff
path: root/job.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-01-19 00:22:34 +0100
committerLennart Poettering <lennart@poettering.net>2010-01-19 00:22:34 +0100
commita66d02c3290008d50b2b52f84cfbf46a546ba831 (patch)
treeba2c64f260e8a256c93f5b722dc926d2343b15ca /job.c
parent4609154d5513108478f603ff1589e486c001daa9 (diff)
add functions for dumping server state
Diffstat (limited to 'job.c')
-rw-r--r--job.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/job.c b/job.c
index 689908aeb4..87bcd289d9 100644
--- a/job.c
+++ b/job.c
@@ -60,3 +60,31 @@ void job_free(Job *j) {
/* Free data and next 'smaller' objects */
free(j);
}
+
+void job_dump(Job *j, FILE*f) {
+
+ static const char* const job_type_table[_JOB_TYPE_MAX] = {
+ [JOB_START] = "START",
+ [JOB_STOP] = "STOP",
+ [JOB_VERIFY_STARTED] = "VERIFY_STARTED",
+ [JOB_RELOAD] = "RELOAD",
+ [JOB_RESTART] = "RESTART",
+ [JOB_TRY_RESTART] = "TRY_RESTART",
+ [JOB_RESTART_FINISH] = "RESTART_FINISH"
+ };
+
+ static const char* const job_state_table[_JOB_STATE_MAX] = {
+ [JOB_WAITING] = "WAITING",
+ [JOB_RUNNING] = "RUNNING",
+ [JOB_DONE] = "DONE"
+ };
+
+ assert(j);
+ assert(f);
+
+ fprintf(f, "Job %u: %s → %s in state %s\n",
+ j->id,
+ name_id(j->name),
+ job_type_table[j->type],
+ job_state_table[j->state]);
+}