Commit 66572d21 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Dridi Boukelmoune

Monday morning flexelinting

parent 4c10ca24
......@@ -73,7 +73,7 @@
} while (0)
static double timeout = 5;
static double timeout = 5; // XXX should be settable by arg ?
static void
cli_write(int sock, const char *s)
......@@ -192,7 +192,7 @@ send_line(char *l)
cli_write(_line_sock, l);
cli_write(_line_sock, "\n");
if (*l)
add_history(l);
AZ(add_history(l));
rl_callback_handler_install("varnish> ", send_line);
} else {
RL_EXIT(0);
......@@ -234,6 +234,29 @@ varnishadm_completion (const char *text, int start, int end)
return (matches);
}
static void
pass_answer(int fd)
{
unsigned u, status;
char *answer = NULL;
u = VCLI_ReadResult(fd, &status, &answer, timeout);
if (u) {
if (status == CLIS_COMMS)
RL_EXIT(0);
if (answer)
fprintf(stderr, "%s\n", answer);
RL_EXIT(1);
}
printf("%u\n", status);
if (answer) {
printf("%s\n", answer);
free(answer);
}
(void)fflush(stdout);
}
/*
* No arguments given, simply pass bytes on stdin/stdout and CLI socket
* Send a "banner" to varnish, to provoke a welcome message.
......@@ -242,7 +265,6 @@ static void
interactive(int sock)
{
struct pollfd fds[2];
char buf[1024];
int i;
char *answer = NULL;
unsigned u, status;
......@@ -293,25 +315,8 @@ interactive(int sock)
assert(i > 0);
if (fds[0].revents & POLLIN) {
/* Get rid of the prompt, kinda hackish */
u = write(1, "\r \r", 13);
u = VCLI_ReadResult(fds[0].fd, &status, &answer,
timeout);
if (u) {
if (status == CLIS_COMMS)
RL_EXIT(0);
if (answer)
fprintf(stderr, "%s\n", answer);
RL_EXIT(1);
}
bprintf(buf, "%u\n", status);
u = write(1, buf, strlen(buf));
if (answer) {
u = write(1, answer, strlen(answer));
u = write(1, "\n", 1);
free(answer);
answer = NULL;
}
printf("\r \r");
pass_answer(fds[0].fd);
rl_forced_update_display();
}
if (fds[1].revents & POLLIN) {
......@@ -329,8 +334,6 @@ pass(int sock)
struct pollfd fds[2];
char buf[1024];
int i;
char *answer = NULL;
unsigned u, status;
ssize_t n;
fds[0].fd = sock;
......@@ -343,26 +346,8 @@ pass(int sock)
continue;
}
assert(i > 0);
if (fds[0].revents & POLLIN) {
u = VCLI_ReadResult(fds[0].fd, &status, &answer,
timeout);
if (u) {
if (status == CLIS_COMMS)
RL_EXIT(0);
if (answer)
fprintf(stderr, "%s\n", answer);
RL_EXIT(1);
}
bprintf(buf, "%u\n", status);
u = write(1, buf, strlen(buf));
if (answer) {
u = write(1, answer, strlen(answer));
u = write(1, "\n", 1);
free(answer);
answer = NULL;
}
}
if (fds[0].revents & POLLIN)
pass_answer(fds[0].fd);
if (fds[1].revents & POLLIN || fds[1].revents & POLLHUP) {
n = read(fds[1].fd, buf, sizeof buf - 1);
if (n == 0) {
......@@ -392,8 +377,8 @@ usage(int status)
static int
n_arg_sock(const char *n_arg, const char *t_arg)
{
char *T_arg = NULL, *T_start = NULL;
char *S_arg = NULL;
char *T_arg, *T_start;
char *S_arg;
struct vsm *vsm;
char *p;
int sock;
......
......@@ -784,7 +784,9 @@ ved_stripgzip(struct req *req, const struct boc *boc)
ecx->l_crc += ilen;
}
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------
* Straight through without processing.
*/
static int v_matchproto_(vdp_fini_f)
ved_vdp_fini(struct req *req, void **priv)
......
......@@ -140,6 +140,7 @@ base64_decode(const enum encoding dec, char *restrict const buf,
unsigned u = 0, term = 0;
int n = 0;
size_t len = SIZE_MAX;
const char *s;
AN(buf);
AN(alpha);
......@@ -149,7 +150,7 @@ base64_decode(const enum encoding dec, char *restrict const buf,
len = inlen;
for (int i = 0; len > 0 && i < strings->n; i++) {
const char *s = strings->p[i];
s = strings->p[i];
if (s == NULL)
continue;
......@@ -159,7 +160,7 @@ base64_decode(const enum encoding dec, char *restrict const buf,
}
while (*s && len) {
while (n < 4) {
char b = alpha->i64[(unsigned) *s++];
char b = alpha->i64[(uint8_t) *s++];
u <<= 6;
if (b == ILL) {
errno = EINVAL;
......@@ -170,7 +171,7 @@ base64_decode(const enum encoding dec, char *restrict const buf,
term++;
continue;
}
u |= (unsigned) b;
u |= (uint8_t) b;
if (--len == 0)
break;
if (!*s)
......
......@@ -181,6 +181,8 @@ xyzzy_obj_opt__init(VRT_CTX,
if (args->valid_s)
AN(args->s);
(void)args->valid_b;
(void)args->b;
AN(op);
AZ(*op);
......
......@@ -42,10 +42,8 @@ enum healthy_e {
};
enum resolve_e {
_RESOLVE_E_INVALID = 0,
#define VMODENUM(x) x,
#include "tbl_resolve.h"
_RESOLVE_E_MAX
};
struct vbitmap;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment