chiark / gitweb /
prefork: Allow script not to be set
[chiark-utils.git] / cprogs / cgi-fcgi-interp.c
index 96a78ce8ce4a213c1cf7244381846ebefb86a4d5..1c160e29c35bd6a2f4b8e6adb263c6013e2d958b 100644 (file)
@@ -1,6 +1,11 @@
 /*
  * "Interpreter" that you can put in #! like this
  *   #!/usr/bin/cgi-fcgi-interp [<options>] <interpreter>
+ *
+ * Usages:
+ *   cgi-fcgi-interp  [<option> ..] <interpreter>  <script> [<ignored> ...]
+ *   cgi-fcgi-interp  [<option>,..],<interpreter>  <script> [<ignored> ...]
+ *   cgi-fcgi-interp '[<option> ..] <interpreter>' <script> [<ignored> ...]
  */
 /*
  * cgi-fcgi-interp.[ch] - Convenience wrapper for cgi-fcgi
 
 #include "prefork.h"
 
+#define STAGE2_VAR "CHIARKUTILS_CGIFCGIINTERP_STAGE2"
+
 static const char *stage2;
 
+const char our_name[] = "cgi-fcgi-interp";
+
 const struct cmdinfo cmdinfos[]= {
   { "help",   0, .call=of_help                                         },
   { 0, 'g',   1,                    .sassignto= &ident                 },
@@ -165,7 +174,7 @@ static void queue_alarm(void);
 static void start_logging(void);
 static void await_something(void);
 
-int main(int argc, const char *const *argv) {
+int main(int unused_argc, const char *const *argv) {
   int r;
 
   stage2 = getenv(STAGE2_VAR);
@@ -185,7 +194,8 @@ int main(int argc, const char *const *argv) {
     if (r) diee("close saved stderr fd");
   }
 
-  script = process_opts(argc, argv);
+  process_opts(&argv);
+  if (!script) badusage("need script argument");
 
   if (!stage2) {