14#include "../dlib/dlib.h"
25 char *label = strtok(line,
":");
27 if (label == NULL || strlen(label) == 0) {
28 MSG(
"Missing action label, ignoring '%s'\n", line);
34 char *cmd = strtok(NULL,
"");
36 if (cmd == NULL || strlen(cmd) == 0) {
37 MSG(
"Missing action command, ignoring '%s'\n", line);
55 for (
int i = 0; i < n; i++) {
85 snprintf(pid, 64,
"%d", (
int) getpid());
87 MSG(
"Running action '%s': %s\n", action->
label, action->
cmd);
91 MSG(
"Cannot run action '%s', fork failed: %s\n",
92 action->
label, strerror(errno));
98 setenv(
"DILLO_PID", pid, 1);
102 int ret = system(action->
cmd);
104 MSG(
"Cannot run '%s': %s\n", action->
cmd, strerror(errno));
106 }
else if (ret != 0) {
107 MSG(
"Command exited with '%d': %s\n", ret, action->
cmd);
Dlist * a_Actions_page_get(void)
int a_Actions_run(Action *action)
void actions_parse(Dlist **actions, Dlist *pref_actions)
static Dlist * page_actions
Dlist * a_Actions_link_get(void)
void a_Actions_init(void)
void action_parse(Dlist *actions, char *line)
static Dlist * link_actions
char * dStrdup(const char *s)
Dlist * dList_new(int size)
Create a new empty list.
int dList_length(Dlist *lp)
For completing the ADT.
void * dList_nth_data(Dlist *lp, int n0)
Return the nth data item, NULL when not found or 'n0' is out of range.
void * dMalloc(size_t size)
void dList_append(Dlist *lp, void *data)
Append a data item to the list.
DilloPrefs prefs
Global Data.