aboutsummaryrefslogtreecommitdiffstats
path: root/tools/help2c.sh
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2025-12-24 11:51:47 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2025-12-24 11:51:47 +0000
commit50fd489b3dd53740ac2e2b024244b98967859d7b (patch)
tree883a8488072573993090a00920695e0ee40666f6 /tools/help2c.sh
parent97ed22b1bb075cb539e78fae2169ec56d3e8557b (diff)
downloads6-frontend-50fd489b3dd53740ac2e2b024244b98967859d7b.tar.gz
Save before experimenting with help processing system...
Diffstat (limited to 'tools/help2c.sh')
-rwxr-xr-xtools/help2c.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/help2c.sh b/tools/help2c.sh
new file mode 100755
index 0000000..5ce89e3
--- /dev/null
+++ b/tools/help2c.sh
@@ -0,0 +1,28 @@
+#!/bin/sh -e
+
+if test -z "$1" ; then
+ echo "$0: usage: $0 name < textfile > cfile" 1>&2
+ exit 1
+fi
+
+echo '/* ISC license. */'
+echo
+echo '#include <unistd.h>'
+echo
+echo '#include <skalibs/buffer.h>'
+echo '#include <skalibs/strerr.h>'
+echo
+echo '#include "s6-frontend-internal.h"'
+echo
+echo "void ${1}_help (char const *const *argv)"
+echo '{'
+echo " static char const *const ${1}_help_message ="
+
+sed 's/"/\\"/g; s/^/ "/; s/$/\\n"/'
+
+echo ' ;'
+echo " if (!buffer_putsflush(buffer_1, ${1}_help_message))"
+echo ' strerr_diefu1sys(111, "write to stdout") ;'
+echo ' (void)argv ;'
+echo ' _exit(0) ;'
+echo '}'