[master] d5015d7 Rename cli.h to vcli.h and allow it to export the varnishapi VCLI convenience functions unless this is disabled with a #define.

Poul-Henning Kamp phk at varnish-cache.org
Mon Jun 6 10:54:08 CEST 2011


commit d5015d742f5344cea8ae8297c0509e95cc152ee5
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jun 6 08:53:27 2011 +0000

    Rename cli.h to vcli.h and allow it to export the varnishapi VCLI
    convenience functions unless this is disabled with a #define.

diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c
index d52c363..baa4048 100644
--- a/bin/varnishadm/varnishadm.c
+++ b/bin/varnishadm/varnishadm.c
@@ -41,7 +41,7 @@
 #include <editline/readline.h>
 #endif
 
-#include "cli.h"
+#include "vcli.h"
 #include "cli_common.h"
 #include "libvarnish.h"
 #include "varnishapi.h"
diff --git a/bin/varnishd/cache_acceptor.c b/bin/varnishd/cache_acceptor.c
index f11ae54..2b3f87e 100644
--- a/bin/varnishd/cache_acceptor.c
+++ b/bin/varnishd/cache_acceptor.c
@@ -41,7 +41,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#include "cli.h"
+#include "vcli.h"
 #include "cli_priv.h"
 #include "cache.h"
 #include "cache_waiter.h"
diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c
index c6cf637..d62cac6 100644
--- a/bin/varnishd/cache_ban.c
+++ b/bin/varnishd/cache_ban.c
@@ -51,7 +51,7 @@
 
 #include <pcre.h>
 
-#include "cli.h"
+#include "vcli.h"
 #include "vend.h"
 #include "cli_priv.h"
 #include "cache.h"
diff --git a/bin/varnishd/cache_cli.c b/bin/varnishd/cache_cli.c
index 915f269..387dffb 100644
--- a/bin/varnishd/cache_cli.c
+++ b/bin/varnishd/cache_cli.c
@@ -43,7 +43,7 @@
 #include <unistd.h>
 #include <poll.h>
 
-#include "cli.h"
+#include "vcli.h"
 #include "cli_priv.h"
 #include "cli_common.h"
 #include "cli_serve.h"
diff --git a/bin/varnishd/cache_vcl.c b/bin/varnishd/cache_vcl.c
index 444006d..49f3fbb 100644
--- a/bin/varnishd/cache_vcl.c
+++ b/bin/varnishd/cache_vcl.c
@@ -39,7 +39,7 @@
 #include <stdlib.h>
 #include <dlfcn.h>
 
-#include "cli.h"
+#include "vcli.h"
 #include "cli_priv.h"
 #include "vcl.h"
 #include "cache.h"
diff --git a/bin/varnishd/mgt_child.c b/bin/varnishd/mgt_child.c
index 2a9d826..2664931 100644
--- a/bin/varnishd/mgt_child.c
+++ b/bin/varnishd/mgt_child.c
@@ -46,7 +46,7 @@
 #include "mgt.h"
 #include "vsm.h"
 #include "heritage.h"
-#include "cli.h"
+#include "vcli.h"
 #include "cli_priv.h"
 #include "mgt_cli.h"
 #include "vev.h"
diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c
index d3a0c67..e31f3f8 100644
--- a/bin/varnishd/mgt_cli.c
+++ b/bin/varnishd/mgt_cli.c
@@ -47,7 +47,7 @@
 #endif
 
 #include "cli_priv.h"
-#include "cli.h"
+#include "vcli.h"
 #include "vsb.h"
 #include "cli_common.h"
 #include "cli_serve.h"
diff --git a/bin/varnishd/mgt_param.c b/bin/varnishd/mgt_param.c
index 4142197..1caa563 100644
--- a/bin/varnishd/mgt_param.c
+++ b/bin/varnishd/mgt_param.c
@@ -40,7 +40,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "cli.h"
+#include "vcli.h"
 #include "cli_priv.h"
 #include "cli_common.h"
 #include "mgt.h"
diff --git a/bin/varnishd/mgt_vcc.c b/bin/varnishd/mgt_vcc.c
index d1b3e57..9e204bc 100644
--- a/bin/varnishd/mgt_vcc.c
+++ b/bin/varnishd/mgt_vcc.c
@@ -44,7 +44,7 @@
 #include "vsb.h"
 
 #include "libvcl.h"
-#include "cli.h"
+#include "vcli.h"
 #include "cli_priv.h"
 #include "cli_common.h"
 
diff --git a/bin/varnishd/storage_persistent.c b/bin/varnishd/storage_persistent.c
index 28d1de2..a4ba598 100644
--- a/bin/varnishd/storage_persistent.c
+++ b/bin/varnishd/storage_persistent.c
@@ -48,7 +48,7 @@
 #include "stevedore.h"
 #include "hash_slinger.h"
 #include "vsha256.h"
-#include "cli.h"
+#include "vcli.h"
 #include "cli_priv.h"
 #include "vend.h"
 
diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c
index d15964c..9dae7d3 100644
--- a/bin/varnishd/varnishd.c
+++ b/bin/varnishd/varnishd.c
@@ -55,7 +55,7 @@
 #include "vpf.h"
 #include "vsha256.h"
 
-#include "cli.h"
+#include "vcli.h"
 #include "cli_priv.h"
 #include "cli_common.h"
 
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index 3863c64..e0f7c21 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -46,7 +46,7 @@
 #include "miniobj.h"
 #include "libvarnish.h"
 #include "varnishapi.h"
-#include "cli.h"
+#include "vcli.h"
 #include "cli_common.h"
 #include "vss.h"
 #include "vsb.h"
diff --git a/include/Makefile.am b/include/Makefile.am
index 6835d0f..10ebd81 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -3,6 +3,7 @@
 pkginclude_HEADERS = \
 	vsm.h \
 	vsl.h \
+	vcli.h \
 	vsl_tags.h \
 	vsc_fields.h \
 	vsc_all.h \
@@ -12,7 +13,6 @@ pkginclude_HEADERS = \
 nobase_noinst_HEADERS = \
 	ban_vars.h \
 	binary_heap.h \
-	cli.h \
 	cli_common.h \
 	cli_priv.h \
 	cli_serve.h \
diff --git a/include/cli.h b/include/cli.h
deleted file mode 100644
index 3b16877..0000000
--- a/include/cli.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*-
- * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2011 Varnish Software AS
- * All rights reserved.
- *
- * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Public definition of the CLI protocol, part of the published Varnish-API.
- *
- * The overall structure of the protocol is a command-line like
- * "command+arguments" request and a IETF style "number + string" response.
- *
- * Arguments can contain arbitrary sequences of bytes which are encoded
- * in back-slash notation in double-quoted, if necessary.
- */
-
-/*
- * These macros define the common data for requests in the CLI protocol.
- * The fields are:
- *	const char *	request_name
- *	const char *	request_syntax (for short help)
- *	const char *	request_help (for long help)
- *	unsigned	minimum_arguments
- *	unsigned	maximum_arguments
- *
- * If you only want a subset of these fields do this:
- *	#define CLIF145(a,b,c,d,e)	a,d,e
- *	[...]
- *	CLIF145(CLI_URL_QUERY)
- *
- */
-
-#define CLI_URL_QUERY							\
-	"url.query",							\
-	"url.query <url>",						\
-	"\tQuery the cache status of a specific URL.\n"			\
-	    "\tReturns the TTL, size and checksum of the object.",	\
-	1, 1
-
-#define CLI_BAN_URL							\
-	"ban.url",							\
-	"ban.url <regexp>",						\
-	"\tAll objects where the urls matches regexp will be "		\
-	    "marked obsolete.",						\
-	1, 1
-
-#define CLI_BAN								\
-	"ban",								\
-	"ban <field> <operator> <arg> [&& <field> <oper> <arg>]...",	\
-	"\tAll objects where the all the conditions match will be "	\
-	    "marked obsolete.",						\
-	3, UINT_MAX
-
-#define CLI_BAN_LIST							\
-	"ban.list",							\
-	"ban.list",							\
-	"\tList the active bans.",					\
-	0, 0
-
-#define CLI_VCL_LOAD							\
-	"vcl.load",							\
-	"vcl.load <configname> <filename>",				\
-	"\tCompile and load the VCL file under the name provided.",	\
-	2, 2
-
-#define CLI_VCL_INLINE							\
-	"vcl.inline",							\
-	"vcl.inline <configname> <quoted_VCLstring>",			\
-	"\tCompile and load the VCL data under the name provided.",	\
-	2, 2
-
-#define CLI_VCL_DISCARD							\
-	"vcl.discard",							\
-	"vcl.discard <configname>",					\
-	"\tUnload the named configuration (when possible).",		\
-	1, 1
-
-#define CLI_VCL_LIST							\
-	"vcl.list",							\
-	"vcl.list",							\
-	"\tList all loaded configuration.",				\
-	0, 0
-
-#define CLI_VCL_SHOW							\
-	"vcl.show",							\
-	"vcl.show <configname>",					\
-	"\tDisplay the source code for the specified configuration.",	\
-	1, 1
-
-#define CLI_VCL_USE							\
-	"vcl.use",							\
-	"vcl.use <configname>",						\
-	"\tSwitch to the named configuration immediately.",		\
-	1, 1
-
-#define CLI_PARAM_SHOW							\
-	"param.show",							\
-	"param.show [-l] [<param>]",					\
-	"\tShow parameters and their values.",				\
-	0, 2
-
-#define CLI_PARAM_SET							\
-	"param.set",							\
-	"param.set <param> <value>",					\
-	"\tSet parameter value.",					\
-	2,2
-
-#define CLI_SERVER_STOP							\
-	"stop",								\
-	"stop",								\
-	"\tStop the Varnish cache process",				\
-	0, 0
-
-#define CLI_SERVER_START						\
-	"start",							\
-	"start",							\
-	"\tStart the Varnish cache process.",				\
-	0, 0
-
-#define CLI_PING							\
-	"ping",								\
-	"ping [timestamp]",						\
-	"\tKeep connection alive",					\
-	0, 1
-
-#define CLI_HELP							\
-	"help",								\
-	"help [command]",						\
-	"\tShow command/protocol help",					\
-	0, 1
-
-#define CLI_QUIT							\
-	"quit",								\
-	"quit",								\
-	"\tClose connection",						\
-	0, 0
-
-#define CLI_SERVER_STATUS						\
-	"status",							\
-	"status",							\
-	"\tCheck status of Varnish cache process.",			\
-	0, 0
-
-#define CLI_BANNER							\
-	"banner",							\
-	"banner",							\
-	"\tPrint welcome banner.",					\
-	0, 0
-
-#define CLI_AUTH							\
-	"auth",								\
-	"auth response",						\
-	"\tAuthenticate.",						\
-	1, 1
-
-#define CLI_PANIC_SHOW							\
-	"panic.show",							\
-	"panic.show",							\
-	"\tReturn the last panic, if any.",				\
-	0, 0
-
-#define CLI_PANIC_CLEAR							\
-	"panic.clear",							\
-	"panic.clear",							\
-	"\tClear the last panic, if any.",				\
-	0, 0
-
-/*
- * Status/return codes in the CLI protocol
- */
-
-enum VCLI_status_e {
-	CLIS_SYNTAX	= 100,
-	CLIS_UNKNOWN	= 101,
-	CLIS_UNIMPL	= 102,
-	CLIS_TOOFEW	= 104,
-	CLIS_TOOMANY	= 105,
-	CLIS_PARAM	= 106,
-	CLIS_AUTH	= 107,
-	CLIS_OK		= 200,
-	CLIS_CANT	= 300,
-	CLIS_COMMS	= 400,
-	CLIS_CLOSE	= 500
-};
-
-/* Length of first line of response */
-#define CLI_LINE0_LEN	13
-#define CLI_AUTH_RESPONSE_LEN		64	/* 64 hex + NUL */
-
diff --git a/include/cli_common.h b/include/cli_common.h
index 5bad09d..80d680f 100644
--- a/include/cli_common.h
+++ b/include/cli_common.h
@@ -43,9 +43,3 @@ struct cli {
 	struct vlu		*vlu;
 	struct VCLS		*cls;
 };
-
-int VCLI_WriteResult(int fd, unsigned status, const char *result);
-int VCLI_ReadResult(int fd, unsigned *status, char **ptr, double tmo);
-
-void VCLI_AuthResponse(int S_fd, const char *challenge,
-    char reponse[CLI_AUTH_RESPONSE_LEN + 1]);
diff --git a/include/vcli.h b/include/vcli.h
new file mode 100644
index 0000000..cd98f58
--- /dev/null
+++ b/include/vcli.h
@@ -0,0 +1,217 @@
+/*-
+ * Copyright (c) 2006 Verdens Gang AS
+ * Copyright (c) 2006-2011 Varnish Software AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Public definition of the CLI protocol, part of the published Varnish-API.
+ *
+ * The overall structure of the protocol is a command-line like
+ * "command+arguments" request and a IETF style "number + string" response.
+ *
+ * Arguments can contain arbitrary sequences of bytes which are encoded
+ * in back-slash notation in double-quoted, if necessary.
+ */
+
+/*
+ * These macros define the common data for requests in the CLI protocol.
+ * The fields are:
+ *	const char *	request_name
+ *	const char *	request_syntax (for short help)
+ *	const char *	request_help (for long help)
+ *	unsigned	minimum_arguments
+ *	unsigned	maximum_arguments
+ *
+ * If you only want a subset of these fields do this:
+ *	#define CLIF145(a,b,c,d,e)	a,d,e
+ *	[...]
+ *	CLIF145(CLI_URL_QUERY)
+ *
+ */
+
+#define CLI_URL_QUERY							\
+	"url.query",							\
+	"url.query <url>",						\
+	"\tQuery the cache status of a specific URL.\n"			\
+	    "\tReturns the TTL, size and checksum of the object.",	\
+	1, 1
+
+#define CLI_BAN_URL							\
+	"ban.url",							\
+	"ban.url <regexp>",						\
+	"\tAll objects where the urls matches regexp will be "		\
+	    "marked obsolete.",						\
+	1, 1
+
+#define CLI_BAN								\
+	"ban",								\
+	"ban <field> <operator> <arg> [&& <field> <oper> <arg>]...",	\
+	"\tAll objects where the all the conditions match will be "	\
+	    "marked obsolete.",						\
+	3, UINT_MAX
+
+#define CLI_BAN_LIST							\
+	"ban.list",							\
+	"ban.list",							\
+	"\tList the active bans.",					\
+	0, 0
+
+#define CLI_VCL_LOAD							\
+	"vcl.load",							\
+	"vcl.load <configname> <filename>",				\
+	"\tCompile and load the VCL file under the name provided.",	\
+	2, 2
+
+#define CLI_VCL_INLINE							\
+	"vcl.inline",							\
+	"vcl.inline <configname> <quoted_VCLstring>",			\
+	"\tCompile and load the VCL data under the name provided.",	\
+	2, 2
+
+#define CLI_VCL_DISCARD							\
+	"vcl.discard",							\
+	"vcl.discard <configname>",					\
+	"\tUnload the named configuration (when possible).",		\
+	1, 1
+
+#define CLI_VCL_LIST							\
+	"vcl.list",							\
+	"vcl.list",							\
+	"\tList all loaded configuration.",				\
+	0, 0
+
+#define CLI_VCL_SHOW							\
+	"vcl.show",							\
+	"vcl.show <configname>",					\
+	"\tDisplay the source code for the specified configuration.",	\
+	1, 1
+
+#define CLI_VCL_USE							\
+	"vcl.use",							\
+	"vcl.use <configname>",						\
+	"\tSwitch to the named configuration immediately.",		\
+	1, 1
+
+#define CLI_PARAM_SHOW							\
+	"param.show",							\
+	"param.show [-l] [<param>]",					\
+	"\tShow parameters and their values.",				\
+	0, 2
+
+#define CLI_PARAM_SET							\
+	"param.set",							\
+	"param.set <param> <value>",					\
+	"\tSet parameter value.",					\
+	2,2
+
+#define CLI_SERVER_STOP							\
+	"stop",								\
+	"stop",								\
+	"\tStop the Varnish cache process",				\
+	0, 0
+
+#define CLI_SERVER_START						\
+	"start",							\
+	"start",							\
+	"\tStart the Varnish cache process.",				\
+	0, 0
+
+#define CLI_PING							\
+	"ping",								\
+	"ping [timestamp]",						\
+	"\tKeep connection alive",					\
+	0, 1
+
+#define CLI_HELP							\
+	"help",								\
+	"help [command]",						\
+	"\tShow command/protocol help",					\
+	0, 1
+
+#define CLI_QUIT							\
+	"quit",								\
+	"quit",								\
+	"\tClose connection",						\
+	0, 0
+
+#define CLI_SERVER_STATUS						\
+	"status",							\
+	"status",							\
+	"\tCheck status of Varnish cache process.",			\
+	0, 0
+
+#define CLI_BANNER							\
+	"banner",							\
+	"banner",							\
+	"\tPrint welcome banner.",					\
+	0, 0
+
+#define CLI_AUTH							\
+	"auth",								\
+	"auth response",						\
+	"\tAuthenticate.",						\
+	1, 1
+
+#define CLI_PANIC_SHOW							\
+	"panic.show",							\
+	"panic.show",							\
+	"\tReturn the last panic, if any.",				\
+	0, 0
+
+#define CLI_PANIC_CLEAR							\
+	"panic.clear",							\
+	"panic.clear",							\
+	"\tClear the last panic, if any.",				\
+	0, 0
+
+/*
+ * Status/return codes in the CLI protocol
+ */
+
+enum VCLI_status_e {
+	CLIS_SYNTAX	= 100,
+	CLIS_UNKNOWN	= 101,
+	CLIS_UNIMPL	= 102,
+	CLIS_TOOFEW	= 104,
+	CLIS_TOOMANY	= 105,
+	CLIS_PARAM	= 106,
+	CLIS_AUTH	= 107,
+	CLIS_OK		= 200,
+	CLIS_CANT	= 300,
+	CLIS_COMMS	= 400,
+	CLIS_CLOSE	= 500
+};
+
+/* Length of first line of response */
+#define CLI_LINE0_LEN	13
+#define CLI_AUTH_RESPONSE_LEN		64	/* 64 hex + NUL */
+
+#if !defined(VCLI_PROTOCOL_ONLY)
+/* Convenience functions exported in libvarnishapi */
+int VCLI_WriteResult(int fd, unsigned status, const char *result);
+int VCLI_ReadResult(int fd, unsigned *status, char **ptr, double tmo);
+void VCLI_AuthResponse(int S_fd, const char *challenge,
+    char reponse[CLI_AUTH_RESPONSE_LEN + 1]);
+#endif
diff --git a/lib/libvarnish/cli_auth.c b/lib/libvarnish/cli_auth.c
index 35d2ad6..fc66fa7 100644
--- a/lib/libvarnish/cli_auth.c
+++ b/lib/libvarnish/cli_auth.c
@@ -32,8 +32,7 @@
 #include <stdio.h>
 #include <unistd.h>
 
-#include "cli.h"
-#include "cli_common.h"
+#include "vcli.h"
 #include "libvarnish.h"
 #include "vsha256.h"
 
diff --git a/lib/libvarnish/cli_common.c b/lib/libvarnish/cli_common.c
index 7b6c43a..604ab15 100644
--- a/lib/libvarnish/cli_common.c
+++ b/lib/libvarnish/cli_common.c
@@ -46,7 +46,7 @@
 
 #include "libvarnish.h"
 
-#include "cli.h"
+#include "vcli.h"
 #include "cli_priv.h"
 #include "cli_common.h"
 
diff --git a/lib/libvarnish/cli_serve.c b/lib/libvarnish/cli_serve.c
index 621f184..dc4a89b 100644
--- a/lib/libvarnish/cli_serve.c
+++ b/lib/libvarnish/cli_serve.c
@@ -41,7 +41,7 @@
 #include <vqueue.h>
 #include <vsb.h>
 #include <vlu.h>
-#include <cli.h>
+#include <vcli.h>
 #include <cli_priv.h>
 #include <cli_common.h>
 #include <cli_serve.h>



More information about the varnish-commit mailing list