util.h (1449B)
1 /* See LICENSE for copyright information */ 2 3 #ifndef _UTIL_H 4 #define _UTIL_H 5 #ifndef _LIMITS_H 6 #include <limits.h> 7 #endif 8 9 #ifndef _TYPES_H 10 #include <sys/types.h> 11 #endif 12 13 #ifndef VERSION 14 #define VERSION "git" 15 #endif 16 17 typedef struct service { 18 char name[NAME_MAX]; 19 char sysdir[PATH_MAX]; 20 char rundir[PATH_MAX]; 21 char pidfile[PATH_MAX]; 22 char syspidfile[PATH_MAX]; 23 char svfile[PATH_MAX]; 24 char svrundir[PATH_MAX]; 25 char lockfile[PATH_MAX]; 26 } service; 27 28 /* service.c */ 29 service *sv_init(service *sv, char *sv_name); 30 void sv_start(service *sv); 31 int sv_check(service *sv, int force); 32 int sv_writelock(char *file, int sig); 33 34 /* proc.c */ 35 int getsvpid(service *sv); 36 int getsyspid(service *sv); 37 int checkprocess(int pid); 38 int writesvpid(char *file, pid_t pid); 39 40 /* env.c */ 41 char *getenv_fallback(char *name, char *fallback); 42 void *setenv_fallback(char *name, char *fallback); 43 44 /* io.c */ 45 void die(const char *msg, ...); 46 47 /* enprintf.c */ 48 void enprintf(int, const char *, ...); 49 void eprintf(const char *, ...); 50 void weprintf(const char *, ...); 51 52 /* strtonum.c */ 53 long long strtonum(const char *, long long, long long, const char **); 54 long long enstrtonum(int, const char *, long long, long long); 55 long long estrtonum(const char *, long long, long long); 56 57 /* mkdirp.c */ 58 int mkdirp(const char *path); 59 60 /* estrlcpy.c */ 61 size_t strlcpy(char *, const char *, size_t); 62 size_t estrlcpy(char *, const char *, size_t); 63 64 /* rm.c */ 65 int rm_rf(char *path); 66 67 #endif