1 /* common stuff for cgi-fcgi-interp and prefork-interp */
16 #include <sys/types.h>
18 #include <sys/utsname.h>
19 #include <sys/socket.h>
30 #include <nettle/sha.h>
33 #include "timespeccmp.h"
36 #define STAGE2_VAR "CHIARKUTILS_CGIFCGIINTERP_STAGE2"
38 extern const char *interp, *ident;
39 extern int numservers, debugmode;
40 extern int check_interval;
42 extern struct sha256_ctx identsc;
44 extern const char our_name[];
47 extern const char *run_base, *script, *socket_path, *lock_path;
48 extern const char *run_base_mkdir_p;
51 bool find_run_base_var_run(void);
52 void find_socket_path(void);
54 bool stab_isnewer(const struct stat *a, const struct stat *b);
55 void stab_mtimenow(struct stat *out);
56 int acquire_lock(void);
57 bool check_garbage_vs(const struct stat *started);
58 bool check_garbage(void);
59 void tidy_garbage(void);
61 extern const struct cmdinfo cmdinfos[];
63 // returns script pathname
64 const char *process_opts(int argc, const char *const *argv);
66 void vmsgcore(int estatus, int errnoval, const char *fmt, va_list al);
68 #define DEF_MSG(func, attrs, estatus, errnoval, after) \
69 static void func(const char *fmt, ...) \
70 __attribute__((unused, format(printf,1,2))) attrs; \
71 static void func(const char *fmt, ...) { \
74 vmsgcore(estatus,errnoval,fmt,al); \
78 DEF_MSG(warninge, /*empty*/, 0, errno, { });
79 DEF_MSG(warning , /*empty*/, 0, 0, { });
81 #define DEF_DIE(func, errnoval) \
82 DEF_MSG(func, __attribute__((noreturn)), 127, errnoval, { abort(); })
89 void fusagemessage(FILE *f);
90 void usagemessage(void);
91 void of_help(const struct cmdinfo *ci, const char *val);
92 void of_iassign(const struct cmdinfo *ci, const char *val);
93 void ident_addstring(const struct cmdinfo *ci, const char *string);
94 void off_ident_addenv(const struct cmdinfo *ci, const char *name);