path: root/src/genrc.h
authorSergey Poznyakoff <>2018-05-15 05:50:08 (GMT)
committer Sergey Poznyakoff <>2018-05-15 06:05:31 (GMT)
commitb5f4388a2da1b94ce8c8e45a990fd51b2f52dae4 (patch) (side-by-side diff)
tree28bcf8cf313309636357c470faed4456837db7c8 /src/genrc.h
Initial commit
Diffstat (limited to 'src/genrc.h') (more/less context) (ignore whitespace changes)
1 files changed, 137 insertions, 0 deletions
diff --git a/src/genrc.h b/src/genrc.h
new file mode 100644
index 0000000..f782fd5
--- a/dev/null
+++ b/src/genrc.h
@@ -0,0 +1,137 @@
+#include <config.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <signal.h>
+#include <limits.h>
+#include <errno.h>
+#include <string.h>
+#include <regex.h>
+#include <ctype.h>
+#include <sys/time.h>
+#include <sys/select.h>
+#include <sys/wait.h>
+#include "grecs.h"
+#include "wordsplit.h"
+void setprogname(char const *s);
+void genrc_error(char const *fmt, ...);
+void usage_error(char const *fmt, ...);
+void system_error(int ec, char const *fmt, ...);
+#define xmalloc grecs_malloc
+#define xzalloc grecs_zalloc
+#define xcalloc grecs_calloc
+#define xrealloc grecs_realloc
+#define xstrdup grecs_strdup
+#define SHELL "/bin/sh"
+pid_t file_read_pid(char const *filename);
+typedef struct transform *TRANSFORM;
+char *transform_string(TRANSFORM tf, const char *input);
+char *transform_string_if_match(TRANSFORM tf, const char *input);
+TRANSFORM compile_transform_expr(const char *expr, int cflags);
+struct pidlist {
+ pid_t *pidv;
+ size_t pidc;
+ size_t pidn;
+typedef struct pidlist PIDLIST;
+void pidlist_init(PIDLIST *);
+void pidlist_free(PIDLIST *);
+void pidlist_clear(PIDLIST *plist);
+void pidlist_add(PIDLIST *, pid_t);
+ssize_t pidlist_index(PIDLIST *plist, pid_t p);
+int pidlist_member(PIDLIST *plist, pid_t p);
+int pidlist_remove(PIDLIST *plist, size_t i);
+void pidlist_kill(PIDLIST *plist, int sig);
+pid_t strtopid(char const *str);
+int pid_is_running(pid_t pid);
+enum {
+ MATCH_REGEX, /* extended POSIX regexp match (default) */
+ MATCH_PCRE, /* PCRE match (not implemented) */
+ MATCH_GLOB, /* glob pattern match */
+ MATCH_EXACT, /* exact match */
+enum {
+ PROCF_ICASE = 0x01, /* ignore case */
+ PROCF_ALL = 0x02, /* use all pids */
+ PROCF_CMDLINE = 0x04, /* match against entire command line */
+ PROCF_EXE = 0x08 /* match against executable name */
+#define PROCF_DEFAULT 0
+struct procscanbuf {
+ int match; /* match type */
+ int flags; /* match flags */
+ void *pattern;
+typedef struct procscanbuf *PROCSCANBUF;
+PROCSCANBUF procscan_init(char const *pattern, char const *flagstr);
+void procscan_free(PROCSCANBUF buf);
+int procscan_match(PROCSCANBUF buf, char const *arg);
+void match_exact_init(PROCSCANBUF buf, char const *pattern);
+void match_exact_free(PROCSCANBUF buf);
+int match_exact(PROCSCANBUF buf, char const *arg);
+void match_glob_init(PROCSCANBUF buf, char const *pattern);
+void match_glob_free(PROCSCANBUF buf);
+int match_glob(PROCSCANBUF buf, char const *arg);
+void match_regex_init(PROCSCANBUF buf, char const *pattern);
+void match_regex_free(PROCSCANBUF buf);
+int match_regex(PROCSCANBUF buf, char const *arg);
+void match_pcre_init(PROCSCANBUF buf, char const *pattern);
+void match_pcre_free(PROCSCANBUF buf);
+int match_pcre(PROCSCANBUF buf, char const *arg);
+struct genrc_pid_closure {
+ char const *name;
+ int (*pid)(struct genrc_pid_closure *, PIDLIST *);
+typedef struct genrc_pid_closure GENRC_PID_CLOSURE;
+GENRC_PID_CLOSURE *get_pid_closure(char const *str);
+int get_pid_list(GENRC_PID_CLOSURE *, PIDLIST *);
+GENRC_PID_CLOSURE *genrc_pid_file_init(int argc, char **argv);
+GENRC_PID_CLOSURE *genrc_pid_config_init(int argc, char **argv);
+GENRC_PID_CLOSURE *genrc_pid_grep_init(int argc, char **argv);
+GENRC_PID_CLOSURE *genrc_pid_proc_init(int argc, char **argv);
+GENRC_PID_CLOSURE *genrc_pid_ps_init(int argc, char **argv);
+extern char *genrc_command;
+extern char *genrc_program;
+extern char *genrc_pid_from;
+extern unsigned genrc_timeout;
+extern int genrc_no_reload;
+extern int genrc_signal_reload;
+extern int genrc_signal_stop;
+extern GENRC_PID_CLOSURE *genrc_pid_closure;
+extern char *genrc_pidfile;
+int sentinel(void);
+int com_start(void);
+int com_status(void);
+int com_stop(void);
+int com_restart(void);
+int com_reload(void);

Return to:

Send suggestions and report system problems to the System administrator.