manager.c revision 6091827530d6dd43479d6709fb6e9f745c11e900
/*-*- Mode: C; c-basic-offset: 8 -*-*/
#include <assert.h>
#include <errno.h>
#include "manager.h"
#include "hashmap.h"
#include "macro.h"
#include "strv.h"
Manager* manager_new(void) {
Manager *m;
return NULL;
goto fail;
goto fail;
goto fail;
goto fail;
return m;
fail:
manager_free(m);
return NULL;
}
void manager_free(Manager *m) {
Name *n;
assert(m);
while ((n = hashmap_first(m->names)))
name_free(n);
hashmap_free(m->names);
hashmap_free(m->jobs);
/* FIXME: This is incomplete */
hashmap_free(m->jobs_to_add);
set_free(m->jobs_to_remove);
free(m);
}
void *state;
int r;
assert(m);
/* Check for conflicts, first against the jobs we shall
* create */
return -EEXIST;
return -EEXIST;
return r;
}
}
return -ENOMEM;
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
}
if (_ret)
return 0;
fail:
return r;
}
assert(m);
}
assert(m);
}
char **n;
NameType t;
if ((t = name_type_from_string(*n)) == _NAME_TYPE_INVALID)
return -EINVAL;
continue;
}
return -EINVAL;
}
return 0;
}
static int fragment_load(Name *n) {
assert(n);
/*... */
return 0;
}
assert(s);
/*... */
return 0;
}
static int fstab_load(Name *n) {
assert(n);
/*... */
return 0;
}
static int snapshot_load(Snapshot *s) {
assert(s);
/*... */
return 0;
}
int r;
return 0;
if ((r = detect_type(name)) < 0)
return r;
/* Load a .service file */
if ((r = fragment_load(name)) == 0)
goto finish;
/* Load a classic init script */
if (r == -ENOENT)
goto finish;
if ((r = fstab_load(name)) == 0)
goto finish;
goto finish;
} else {
if ((r = fragment_load(name)) == 0)
goto finish;
}
return r;
return 0;
}
static int dispatch_load_queue(Manager *m) {
assert(m);
/* Dispatches the load queue. Takes a name from the queue and
* tries to load its data until the queue is empty */
while ((meta = m->load_queue)) {
}
return 0;
}
NameType t;
int r;
assert(m);
/* This will load the service information files, but not actually
* start any services or anything */
goto finish;
return -EINVAL;
return -ENOMEM;
return -ENOMEM;
}
return r;
}
/* At this point the new entry is created and linked. However,
* not loaded. Now load this entry and all its dependencies
* recursively */
return 0;
}