STAILQ -> TAILQ
This commit is contained in:
parent
7a6112d3b0
commit
53401cd35f
@ -57,9 +57,9 @@ typedef struct plugin
|
|||||||
char *name;
|
char *name;
|
||||||
void *handle;
|
void *handle;
|
||||||
int (*hook)(RC_HOOK, const char *);
|
int (*hook)(RC_HOOK, const char *);
|
||||||
STAILQ_ENTRY(plugin) entries;
|
TAILQ_ENTRY(plugin) entries;
|
||||||
} PLUGIN;
|
} PLUGIN;
|
||||||
STAILQ_HEAD(, plugin) plugins;
|
TAILQ_HEAD(, plugin) plugins;
|
||||||
|
|
||||||
#ifndef __FreeBSD__
|
#ifndef __FreeBSD__
|
||||||
dlfunc_t dlfunc(void * __restrict handle, const char * __restrict symbol)
|
dlfunc_t dlfunc(void * __restrict handle, const char * __restrict symbol)
|
||||||
@ -87,7 +87,7 @@ void rc_plugin_load(void)
|
|||||||
if (rc_in_plugin)
|
if (rc_in_plugin)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
STAILQ_INIT(&plugins);
|
TAILQ_INIT(&plugins);
|
||||||
|
|
||||||
if (! (dp = opendir(RC_PLUGINDIR)))
|
if (! (dp = opendir(RC_PLUGINDIR)))
|
||||||
return;
|
return;
|
||||||
@ -112,7 +112,7 @@ void rc_plugin_load(void)
|
|||||||
plugin->name = xstrdup(d->d_name);
|
plugin->name = xstrdup(d->d_name);
|
||||||
plugin->handle = h;
|
plugin->handle = h;
|
||||||
plugin->hook = fptr;
|
plugin->hook = fptr;
|
||||||
STAILQ_INSERT_TAIL(&plugins, plugin, entries);
|
TAILQ_INSERT_TAIL(&plugins, plugin, entries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir(dp);
|
closedir(dp);
|
||||||
@ -159,7 +159,7 @@ void rc_plugin_run(RC_HOOK hook, const char *value)
|
|||||||
sigemptyset(&empty);
|
sigemptyset(&empty);
|
||||||
sigfillset(&full);
|
sigfillset(&full);
|
||||||
|
|
||||||
STAILQ_FOREACH(plugin, &plugins, entries) {
|
TAILQ_FOREACH(plugin, &plugins, entries) {
|
||||||
/* We create a pipe so that plugins can affect our environment
|
/* We create a pipe so that plugins can affect our environment
|
||||||
* vars, which in turn influence our scripts. */
|
* vars, which in turn influence our scripts. */
|
||||||
if (pipe(pfd) == -1) {
|
if (pipe(pfd) == -1) {
|
||||||
@ -236,15 +236,15 @@ void rc_plugin_run(RC_HOOK hook, const char *value)
|
|||||||
|
|
||||||
void rc_plugin_unload(void)
|
void rc_plugin_unload(void)
|
||||||
{
|
{
|
||||||
PLUGIN *plugin = STAILQ_FIRST(&plugins);
|
PLUGIN *plugin = TAILQ_FIRST(&plugins);
|
||||||
PLUGIN *next;
|
PLUGIN *next;
|
||||||
|
|
||||||
while (plugin) {
|
while (plugin) {
|
||||||
next = STAILQ_NEXT(plugin, entries);
|
next = TAILQ_NEXT(plugin, entries);
|
||||||
dlclose(plugin->handle);
|
dlclose(plugin->handle);
|
||||||
free(plugin->name);
|
free(plugin->name);
|
||||||
free(plugin);
|
free(plugin);
|
||||||
plugin = next;
|
plugin = next;
|
||||||
}
|
}
|
||||||
STAILQ_INIT(&plugins);
|
TAILQ_INIT(&plugins);
|
||||||
}
|
}
|
||||||
|
@ -94,9 +94,9 @@ typedef struct scheduleitem
|
|||||||
} type;
|
} type;
|
||||||
int value;
|
int value;
|
||||||
struct scheduleitem *gotoitem;
|
struct scheduleitem *gotoitem;
|
||||||
STAILQ_ENTRY(scheduleitem) entries;
|
TAILQ_ENTRY(scheduleitem) entries;
|
||||||
} SCHEDULEITEM;
|
} SCHEDULEITEM;
|
||||||
STAILQ_HEAD(, scheduleitem) schedule;
|
TAILQ_HEAD(, scheduleitem) schedule;
|
||||||
|
|
||||||
extern const char *applet;
|
extern const char *applet;
|
||||||
static char *changeuser;
|
static char *changeuser;
|
||||||
@ -105,15 +105,15 @@ extern char **environ;
|
|||||||
|
|
||||||
static void free_schedulelist(void)
|
static void free_schedulelist(void)
|
||||||
{
|
{
|
||||||
SCHEDULEITEM *s1 = STAILQ_FIRST(&schedule);
|
SCHEDULEITEM *s1 = TAILQ_FIRST(&schedule);
|
||||||
SCHEDULEITEM *s2;
|
SCHEDULEITEM *s2;
|
||||||
|
|
||||||
while (s1) {
|
while (s1) {
|
||||||
s2 = STAILQ_NEXT(s1, entries);
|
s2 = TAILQ_NEXT(s1, entries);
|
||||||
free(s1);
|
free(s1);
|
||||||
s1 = s2;
|
s1 = s2;
|
||||||
}
|
}
|
||||||
STAILQ_INIT(&schedule);
|
TAILQ_INIT(&schedule);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cleanup(void)
|
static void cleanup(void)
|
||||||
@ -229,12 +229,12 @@ static void parse_schedule(const char *string, int timeout)
|
|||||||
item->type = SC_SIGNAL;
|
item->type = SC_SIGNAL;
|
||||||
item->value = timeout;
|
item->value = timeout;
|
||||||
item->gotoitem = NULL;
|
item->gotoitem = NULL;
|
||||||
STAILQ_INSERT_TAIL(&schedule, item, entries);
|
TAILQ_INSERT_TAIL(&schedule, item, entries);
|
||||||
|
|
||||||
item = xmalloc(sizeof(*item));
|
item = xmalloc(sizeof(*item));
|
||||||
item->type = SC_TIMEOUT;
|
item->type = SC_TIMEOUT;
|
||||||
item->gotoitem = NULL;
|
item->gotoitem = NULL;
|
||||||
STAILQ_INSERT_TAIL(&schedule, item, entries);
|
TAILQ_INSERT_TAIL(&schedule, item, entries);
|
||||||
if (string) {
|
if (string) {
|
||||||
if (sscanf(string, "%d", &item->value) != 1)
|
if (sscanf(string, "%d", &item->value) != 1)
|
||||||
eerrorx("%s: invalid timeout value in schedule", applet);
|
eerrorx("%s: invalid timeout value in schedule", applet);
|
||||||
@ -258,7 +258,7 @@ static void parse_schedule(const char *string, int timeout)
|
|||||||
string = slash ? slash + 1 : NULL;
|
string = slash ? slash + 1 : NULL;
|
||||||
|
|
||||||
item = parse_schedule_item(buffer);
|
item = parse_schedule_item(buffer);
|
||||||
STAILQ_INSERT_TAIL(&schedule, item, entries);
|
TAILQ_INSERT_TAIL(&schedule, item, entries);
|
||||||
if (item->type == SC_FOREVER) {
|
if (item->type == SC_FOREVER) {
|
||||||
if (repeatat)
|
if (repeatat)
|
||||||
eerrorx("%s: invalid schedule, `forever' "
|
eerrorx("%s: invalid schedule, `forever' "
|
||||||
@ -274,7 +274,7 @@ static void parse_schedule(const char *string, int timeout)
|
|||||||
item->type = SC_GOTO;
|
item->type = SC_GOTO;
|
||||||
item->value = 0;
|
item->value = 0;
|
||||||
item->gotoitem = repeatat;
|
item->gotoitem = repeatat;
|
||||||
STAILQ_INSERT_TAIL(&schedule, item, entries);
|
TAILQ_INSERT_TAIL(&schedule, item, entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -360,7 +360,7 @@ static int run_stop_schedule(const char *const *argv, const char *cmd,
|
|||||||
const char *pidfile, uid_t uid,
|
const char *pidfile, uid_t uid,
|
||||||
bool quiet, bool verbose, bool test)
|
bool quiet, bool verbose, bool test)
|
||||||
{
|
{
|
||||||
SCHEDULEITEM *item = STAILQ_FIRST(&schedule);
|
SCHEDULEITEM *item = TAILQ_FIRST(&schedule);
|
||||||
int nkilled = 0;
|
int nkilled = 0;
|
||||||
int tkilled = 0;
|
int tkilled = 0;
|
||||||
int nrunning = 0;
|
int nrunning = 0;
|
||||||
@ -442,7 +442,7 @@ static int run_stop_schedule(const char *const *argv, const char *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (item)
|
if (item)
|
||||||
item = STAILQ_NEXT(item, entries);
|
item = TAILQ_NEXT(item, entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test || (tkilled > 0 && nrunning == 0))
|
if (test || (tkilled > 0 && nrunning == 0))
|
||||||
@ -602,7 +602,7 @@ int start_stop_daemon(int argc, char **argv)
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
STAILQ_INIT(&schedule);
|
TAILQ_INIT(&schedule);
|
||||||
atexit(cleanup);
|
atexit(cleanup);
|
||||||
|
|
||||||
signal_setup(SIGINT, handle_signal);
|
signal_setup(SIGINT, handle_signal);
|
||||||
@ -824,7 +824,7 @@ int start_stop_daemon(int argc, char **argv)
|
|||||||
if (stop) {
|
if (stop) {
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if (! STAILQ_FIRST(&schedule)) {
|
if (! TAILQ_FIRST(&schedule)) {
|
||||||
if (test || oknodo)
|
if (test || oknodo)
|
||||||
parse_schedule("0", sig);
|
parse_schedule("0", sig);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user