[master] 1e2a2c7f0 Introduce a VUT_Usage() function for consistency

Poul-Henning Kamp phk at FreeBSD.org
Mon Oct 22 07:50:19 UTC 2018


commit 1e2a2c7f08610d624bb92710d63043c691542f75
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Oct 22 07:06:56 2018 +0000

    Introduce a VUT_Usage() function for consistency

diff --git a/include/vut.h b/include/vut.h
index 2528de39b..57eb7c02a 100644
--- a/include/vut.h
+++ b/include/vut.h
@@ -73,6 +73,10 @@ void VUT_Error(struct VUT *, int status, const char *fmt, ...)
 
 int VUT_Arg(struct VUT *, int opt, const char *arg);
 
+//lint -sem(VUT_Usage, r_no)
+void VUT_Usage(const struct VUT *, const struct vopt_spec *,
+    int status) v_noreturn_;
+
 #define VUT_InitProg(argc, argv, spec) VUT_Init(argv[0], argc, argv, spec)
 
 struct VUT * VUT_Init(const char *progname, int argc, char * const *argv,
diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map
index 4cc3b5050..1c8a6ff2b 100644
--- a/lib/libvarnishapi/libvarnishapi.map
+++ b/lib/libvarnishapi/libvarnishapi.map
@@ -140,3 +140,11 @@ LIBVARNISHAPI_2.0 {
     local:
 	*;
 };
+
+LIBVARNISHAPI_2.1 {
+    global:
+	# vut.c
+	VUT_Usage;
+    local:
+	*;
+};
diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c
index 8b3f6ed0e..9c02bf407 100644
--- a/lib/libvarnishapi/vut.c
+++ b/lib/libvarnishapi/vut.c
@@ -452,6 +452,20 @@ VUT_Main(struct VUT *vut)
 
 /**********************************************************************/
 
+void v_noreturn_
+VUT_Usage(const struct VUT *vut, const struct vopt_spec *voc, int status)
+{
+	const char **opt;
+
+	fprintf(stderr, "Usage: %s <options>\n\n", vut->progname);
+	fprintf(stderr, "Options:\n");
+	for (opt = voc->vopt_usage; *opt != NULL; opt += 2)
+		fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1));
+	exit(status);
+}
+
+/**********************************************************************/
+
 
 static void
 print_nobrackets(const char *s)


More information about the varnish-commit mailing list