r705 - in trunk/varnish-cache: bin/varnishd include lib/libvarnish

des at projects.linpro.no des at projects.linpro.no
Mon Aug 7 07:49:17 CEST 2006


Author: des
Date: 2006-08-07 07:49:17 +0200 (Mon, 07 Aug 2006)
New Revision: 705

Added:
   trunk/varnish-cache/include/cli_common.h
   trunk/varnish-cache/lib/libvarnish/cli_common.c
Removed:
   trunk/varnish-cache/bin/varnishd/common_cli.c
   trunk/varnish-cache/bin/varnishd/common_cli.h
Modified:
   trunk/varnish-cache/bin/varnishd/Makefile.am
   trunk/varnish-cache/include/Makefile.am
   trunk/varnish-cache/lib/libvarnish/Makefile.am
Log:
Move common_cli.[ch] out of varnishd, and rename them to cli_common.[ch].

Modified: trunk/varnish-cache/bin/varnishd/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/varnishd/Makefile.am	2006-08-07 05:47:30 UTC (rev 704)
+++ trunk/varnish-cache/bin/varnishd/Makefile.am	2006-08-07 05:49:17 UTC (rev 705)
@@ -26,7 +26,6 @@
 	cache_vrt.c \
 	cache_vrt_acl.c \
 	cache_vrt_re.c \
-	common_cli.c \
 	hash_simple_list.c \
 	hash_classic.c \
 	mgt_child.c \
@@ -43,7 +42,6 @@
 noinst_HEADERS = \
 	cache.h \
 	common.h \
-	common_cli.h \
 	hash_slinger.h \
 	heritage.h \
 	mgt.h \

Deleted: trunk/varnish-cache/bin/varnishd/common_cli.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/common_cli.c	2006-08-07 05:47:30 UTC (rev 704)
+++ trunk/varnish-cache/bin/varnishd/common_cli.c	2006-08-07 05:49:17 UTC (rev 705)
@@ -1,137 +0,0 @@
-/*
- * $Id: cli_event.c 466 2006-07-12 23:30:49Z phk $
- */
-
-#include <errno.h>
-#include <assert.h>
-#include <poll.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/uio.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <time.h>
-#include <signal.h>
-
-#include <sys/wait.h>
-
-#include "sbuf.h"
-
-#include "cli.h"
-#include "cli_priv.h"
-#include "common_cli.h"
-
-void
-cli_out(struct cli *cli, const char *fmt, ...)
-{
-	va_list ap;
-
-	va_start(ap, fmt);
-	sbuf_vprintf(cli->sb, fmt, ap);
-	va_end(ap);
-}
-
-void
-cli_param(struct cli *cli)
-{
-
-	cli->result = CLIS_PARAM;
-	cli_out(cli, "Parameter error, use \"help [command]\" for more info.\n");
-}
-
-void
-cli_result(struct cli *cli, unsigned res)
-{
-
-	cli->result = res;
-}
-
-int
-cli_writeres(int fd, struct cli *cli)
-{
-	int i, l;
-	struct iovec iov[3];
-	char res[CLI_LINE0_LEN + 2];	/*
-					 * NUL + one more so we can catch
-					 * any misformats by snprintf
-					 */
-
-	i = snprintf(res, sizeof res,
-	    "%-3d %-8d\n", cli->result, sbuf_len(cli->sb));
-	assert(i == CLI_LINE0_LEN);
-	iov[0].iov_base = (void*)(uintptr_t)res;
-	iov[1].iov_base = (void*)(uintptr_t)sbuf_data(cli->sb);
-	iov[2].iov_base = (void*)(uintptr_t)"\n";
-	for (l = i = 0; i < 3; i++) {
-		iov[i].iov_len = strlen(iov[i].iov_base);
-		l += iov[i].iov_len;
-	}
-	i = writev(fd, iov, 3);
-	return (i != l);
-}
-
-static int
-read_tmo(int fd, void *ptr, unsigned len, double tmo)
-{
-	int i;
-	struct pollfd pfd;
-
-	pfd.fd = fd;
-	pfd.events = POLLIN;
-	i = poll(&pfd, 1, (int)(tmo * 1e3));
-	if (i == 0) {
-		errno = ETIMEDOUT;
-		return (-1);
-	}
-	return (read(fd, ptr, len));
-}
-
-int
-cli_readres(int fd, unsigned *status, char **ptr, double tmo)
-{
-	char res[CLI_LINE0_LEN];	/* For NUL */
-	int i, j;
-	unsigned u, v;
-	char *p;
-
-	i = read_tmo(fd, res, CLI_LINE0_LEN, tmo);
-	if (i < 0)
-		return (i);
-	assert(i == CLI_LINE0_LEN);	/* XXX: handle */
-	assert(res[3] == ' ');
-	assert(res[CLI_LINE0_LEN - 1] == '\n');
-	j = sscanf(res, "%u %u\n", &u, &v);
-	assert(j == 2);
-	if (status != NULL)
-		*status = u;
-	p = malloc(v + 1);
-	assert(p != NULL);
-	i = read_tmo(fd, p, v + 1, tmo);
-	if (i < 0) {
-		free(p);
-		return (i);
-	}
-	assert(i == v + 1);
-	assert(p[v] == '\n');
-	p[v] = '\0';
-	if (ptr == NULL)
-		free(p);
-	else
-		*ptr = p;
-	return (0);
-}
-
-/*--------------------------------------------------------------------*/
-
-void
-cli_func_ping(struct cli *cli, char **av, void *priv)
-{
-	time_t t;
-
-	(void)priv;
-	(void)av;
-	t = time(NULL);
-	cli_out(cli, "PONG %ld", t);
-}

Deleted: trunk/varnish-cache/bin/varnishd/common_cli.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/common_cli.h	2006-08-07 05:47:30 UTC (rev 704)
+++ trunk/varnish-cache/bin/varnishd/common_cli.h	2006-08-07 05:49:17 UTC (rev 705)
@@ -1,14 +0,0 @@
-/*
- * $Id$
- */
-
-struct cli {
-	struct sbuf		*sb;
-	enum cli_status_e	result;
-};
-
-int cli_writeres(int fd, struct cli *cli);
-int cli_readres(int fd, unsigned *status, char **ptr, double tmo);
-extern struct cli_proto CLI_cmds[];
-
-cli_func_t cli_func_ping;

Modified: trunk/varnish-cache/include/Makefile.am
===================================================================
--- trunk/varnish-cache/include/Makefile.am	2006-08-07 05:47:30 UTC (rev 704)
+++ trunk/varnish-cache/include/Makefile.am	2006-08-07 05:49:17 UTC (rev 705)
@@ -3,6 +3,7 @@
 noinst_HEADERS = \
 	binary_heap.h \
 	cli.h \
+	cli_common.h \
 	cli_priv.h \
 	compat.h \
 	hash.h \

Copied: trunk/varnish-cache/include/cli_common.h (from rev 668, trunk/varnish-cache/bin/varnishd/common_cli.h)

Modified: trunk/varnish-cache/lib/libvarnish/Makefile.am
===================================================================
--- trunk/varnish-cache/lib/libvarnish/Makefile.am	2006-08-07 05:47:30 UTC (rev 704)
+++ trunk/varnish-cache/lib/libvarnish/Makefile.am	2006-08-07 05:49:17 UTC (rev 705)
@@ -8,6 +8,7 @@
 	argv.c \
 	binary_heap.c \
 	cli.c \
+	cli_common.c \
 	time.c
 
 libvarnish_la_CFLAGS = -include config.h

Copied: trunk/varnish-cache/lib/libvarnish/cli_common.c (from rev 670, trunk/varnish-cache/bin/varnishd/common_cli.c)




More information about the varnish-commit mailing list