Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
unique-xids
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
unique-xids
Commits
e974d51f
Commit
e974d51f
authored
Feb 15, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://git.varnish-cache.org/git/varnish-cache
parents
d4441ab2
9764cc4e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
7 deletions
+44
-7
Makefile.am
bin/varnishadm/Makefile.am
+3
-1
varnishadm.c
bin/varnishadm/varnishadm.c
+38
-6
configure.ac
configure.ac
+3
-0
No files found.
bin/varnishadm/Makefile.am
View file @
e974d51f
...
@@ -9,11 +9,13 @@ dist_man_MANS = varnishadm.1
...
@@ -9,11 +9,13 @@ dist_man_MANS = varnishadm.1
varnishadm_SOURCES
=
\
varnishadm_SOURCES
=
\
varnishadm.c
varnishadm.c
varnishadm_CFLAGS
=
@LIBEDIT_CFLAGS@
varnishadm_LDADD
=
\
varnishadm_LDADD
=
\
$(top_builddir)
/lib/libvarnish/libvarnish.la
\
$(top_builddir)
/lib/libvarnish/libvarnish.la
\
$(top_builddir)
/lib/libvarnishapi/libvarnishapi.la
\
$(top_builddir)
/lib/libvarnishapi/libvarnishapi.la
\
$(top_builddir)
/lib/libvarnishcompat/libvarnishcompat.la
\
$(top_builddir)
/lib/libvarnishcompat/libvarnishcompat.la
\
${
PTHREAD_LIBS
}
${
NET_LIBS
}
${
PTHREAD_LIBS
}
${
NET_LIBS
}
@LIBEDIT_LIBS@
varnishadm.1
:
$(top_srcdir)/doc/sphinx/reference/varnishadm.rst
varnishadm.1
:
$(top_srcdir)/doc/sphinx/reference/varnishadm.rst
if
HAVE_RST2MAN
if
HAVE_RST2MAN
...
...
bin/varnishadm/varnishadm.c
View file @
e974d51f
...
@@ -38,9 +38,12 @@ SVNID("$Id$")
...
@@ -38,9 +38,12 @@ SVNID("$Id$")
#include <stdlib.h>
#include <stdlib.h>
#include <unistd.h>
#include <unistd.h>
#include <string.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/socket.h>
#ifdef HAVE_LIBEDIT
#include <editline/readline.h>
#endif
#include "cli.h"
#include "cli.h"
#include "cli_common.h"
#include "cli_common.h"
#include "libvarnish.h"
#include "libvarnish.h"
...
@@ -154,6 +157,19 @@ do_args(int sock, int argc, char * const *argv)
...
@@ -154,6 +157,19 @@ do_args(int sock, int argc, char * const *argv)
exit
(
1
);
exit
(
1
);
}
}
#ifdef HAVE_LIBEDIT
/* Callback for readline, doesn't take a private pointer, so we need
* to have a global variable.
*/
static
int
_line_sock
;
void
send_line
(
char
*
l
)
{
cli_write
(
_line_sock
,
l
);
cli_write
(
_line_sock
,
"
\n
"
);
add_history
(
l
);
}
#endif
/*
/*
* No arguments given, simply pass bytes on stdin/stdout and CLI socket
* No arguments given, simply pass bytes on stdin/stdout and CLI socket
* Send a "banner" to varnish, to provoke a welcome message.
* Send a "banner" to varnish, to provoke a welcome message.
...
@@ -165,6 +181,16 @@ pass(int sock)
...
@@ -165,6 +181,16 @@ pass(int sock)
char
buf
[
1024
];
char
buf
[
1024
];
int
i
,
n
,
m
;
int
i
,
n
,
m
;
#ifdef HAVE_LIBEDIT
_line_sock
=
sock
;
rl_already_prompted
=
1
;
if
(
isatty
(
0
))
{
rl_callback_handler_install
(
"varnish> "
,
send_line
);
}
else
{
rl_callback_handler_install
(
""
,
send_line
);
}
#endif
cli_write
(
sock
,
"banner
\n
"
);
cli_write
(
sock
,
"banner
\n
"
);
fds
[
0
].
fd
=
sock
;
fds
[
0
].
fd
=
sock
;
fds
[
0
].
events
=
POLLIN
;
fds
[
0
].
events
=
POLLIN
;
...
@@ -182,13 +208,21 @@ pass(int sock)
...
@@ -182,13 +208,21 @@ pass(int sock)
exit
(
0
);
exit
(
0
);
}
}
assert
(
n
>
0
);
assert
(
n
>
0
);
/* Get rid of the prompt, kinda hackish */
write
(
1
,
"
\r
\r
"
,
13
);
m
=
write
(
1
,
buf
,
n
);
m
=
write
(
1
,
buf
,
n
);
if
(
n
!=
m
)
{
if
(
n
!=
m
)
{
perror
(
"Write error writing stdout"
);
perror
(
"Write error writing stdout"
);
exit
(
1
);
exit
(
1
);
}
}
#ifdef HAVE_LIBEDIT
rl_forced_update_display
();
#endif
}
}
if
(
fds
[
1
].
revents
&
POLLIN
)
{
if
(
fds
[
1
].
revents
&
POLLIN
)
{
#ifdef HAVE_LIBEDIT
rl_callback_read_char
();
#else
n
=
read
(
fds
[
1
].
fd
,
buf
,
sizeof
buf
);
n
=
read
(
fds
[
1
].
fd
,
buf
,
sizeof
buf
);
if
(
n
==
0
)
{
if
(
n
==
0
)
{
AZ
(
shutdown
(
sock
,
SHUT_WR
));
AZ
(
shutdown
(
sock
,
SHUT_WR
));
...
@@ -196,12 +230,10 @@ pass(int sock)
...
@@ -196,12 +230,10 @@ pass(int sock)
}
else
if
(
n
<
0
)
{
}
else
if
(
n
<
0
)
{
exit
(
0
);
exit
(
0
);
}
else
{
}
else
{
m
=
write
(
sock
,
buf
,
n
);
buf
[
n
]
=
'\0'
;
if
(
n
!=
m
)
{
cli_write
(
sock
,
buf
);
perror
(
"Write error writing CLI socket"
);
exit
(
1
);
}
}
}
#endif
}
}
}
}
}
}
...
...
configure.ac
View file @
e974d51f
...
@@ -121,6 +121,9 @@ fi
...
@@ -121,6 +121,9 @@ fi
AC_SUBST(PCRE_CFLAGS)
AC_SUBST(PCRE_CFLAGS)
AC_SUBST(PCRE_LIBS)
AC_SUBST(PCRE_LIBS)
PKG_CHECK_MODULES([LIBEDIT], [libedit],
[AC_DEFINE([HAVE_LIBEDIT], [1], [Define we have libedit])],
[AC_MSG_WARN([libedit not found, disabling libedit support])])
# Checks for header files.
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_STDC
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment