chiark / gitweb /
prefork-interp: add copyright licences
[chiark-utils.git] / cprogs / prefork.h
index a7e1b8373e83b19a12a71c8c61a00c4eda7ee999..eaaf172ec51532383726f8112eb86a6beef0f992 100644 (file)
@@ -1,4 +1,9 @@
 /* common stuff for cgi-fcgi-interp and prefork-interp */
+/*
+ * Copyright 2016-2022 Ian Jackson and contributors to chiark-utils
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ * There is NO WARRANTY.
+ */
 
 #ifndef PREFORK_H
 #define PREFORK_H
 #include "timespeccmp.h"
 
 #define MINHEXHASH 33
-#define STAGE2_VAR "CHIARKUTILS_CGIFCGIINTERP_STAGE2"
-
-extern const char *interp, *ident;
-extern int numservers, debugmode;
-extern int check_interval;
 
+extern const char *interp, *ident, *script, *socket_path, *lock_path;
+extern bool logging;
 extern struct sha256_ctx identsc;
+extern const char *run_base;
 
 extern const char our_name[];
 
-extern uid_t us;
-extern const char *run_base, *script, *socket_path, *lock_path;
-extern const char *run_base_mkdir_p;
-extern bool logging;
-
 bool find_run_base_var_run(void);
 void find_socket_path(void);
 
-bool stab_isnewer(const struct stat *a, const struct stat *b);
-void stab_mtimenow(struct stat *out);
 int acquire_lock(void);
-bool check_garbage_vs(const struct stat *started);
-bool check_garbage(void);
-void tidy_garbage(void);
+int flock_file(const char *lock_path);
 
 extern const struct cmdinfo cmdinfos[];
+#define PREFORK_CMDINFOS \
+  { "help",   0, .call=of_help                                         }, \
+  { 0, 'g',   1,                    .sassignto= &ident                 }, \
+  { 0, 'G',   1, .call= off_ident_addstring                            }, \
+  { 0, 'E',   1, .call= off_ident_addenv                               },
 
-// returns script pathname
-const char *process_opts(int argc, const char *const *argv);
+void process_opts(const char *const **argv_io);
 
 void vmsgcore(int estatus, int errnoval, const char *fmt, va_list al);
 
@@ -76,13 +74,13 @@ void vmsgcore(int estatus, int errnoval, const char *fmt, va_list al);
   }
 
 DEF_MSG(warninge, /*empty*/, 0, errno, { });
-DEF_MSG(warning , /*empty*/, 0, 0,     { });
+DEF_MSG(warning , /*empty*/, 0, -1,    { });
 
 #define DEF_DIE(func, errnoval) \
   DEF_MSG(func, __attribute__((noreturn)), 127, errnoval, { abort(); })
 
 DEF_DIE(diee, errno)
-DEF_DIE(die,  0)
+DEF_DIE(die,  -1)
 
 #define MAX_OPTS 5
 
@@ -90,7 +88,18 @@ void fusagemessage(FILE *f);
 void usagemessage(void);
 void of_help(const struct cmdinfo *ci, const char *val);
 void of_iassign(const struct cmdinfo *ci, const char *val);
-void ident_addstring(const struct cmdinfo *ci, const char *string);
+void ident_addinit(void);
+bool stabs_same_inode(struct stat *a, struct stat *b);
+void ident_addstring(char key, const char *string);
+
+void off_ident_addstring(const struct cmdinfo *ci, const char *name);
 void off_ident_addenv(const struct cmdinfo *ci, const char *name);
 
+void ident_add_key_byte(char key);
+
+#define IDENT_ADD_OBJ(key, obj) do{                            \
+    ident_add_key_byte(key);                                   \
+    sha256_update(&identsc, sizeof((obj)), (void*)&obj);       \
+  }while(0)
+
 #endif /*PREFORK_H*/