summaryrefslogtreecommitdiff
path: root/accel-pppd/cli
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2014-11-22 08:56:40 +0300
committerDmitry Kozlov <xeb@mail.ru>2014-11-22 08:56:40 +0300
commit81ca3923a29ea9b67f7291be23b210019546aa5f (patch)
treefcebf0d426665b4f06e01168f27cd8f9ab8c50d8 /accel-pppd/cli
parent830c399cf126f6bf1e8dfa1ad919a3ce8e346c5d (diff)
downloadaccel-ppp-81ca3923a29ea9b67f7291be23b210019546aa5f.tar.gz
accel-ppp-81ca3923a29ea9b67f7291be23b210019546aa5f.zip
remove trailing whitespaces
Diffstat (limited to 'accel-pppd/cli')
-rw-r--r--accel-pppd/cli/cli.c8
-rw-r--r--accel-pppd/cli/show_sessions.c4
-rw-r--r--accel-pppd/cli/std_cmd.c20
-rw-r--r--accel-pppd/cli/tcp.c18
-rw-r--r--accel-pppd/cli/telnet.c52
5 files changed, 51 insertions, 51 deletions
diff --git a/accel-pppd/cli/cli.c b/accel-pppd/cli/cli.c
index 8b5f5165..7d440727 100644
--- a/accel-pppd/cli/cli.c
+++ b/accel-pppd/cli/cli.c
@@ -49,7 +49,7 @@ void __export cli_register_simple_cmd2(
c = malloc(sizeof(*c));
memset(c, 0, sizeof(*c));
-
+
c->exec = exec;
c->help = help;
c->hdr_len = hdr_len;
@@ -57,7 +57,7 @@ void __export cli_register_simple_cmd2(
for (i = 0; i < hdr_len; i++)
c->hdr[i] = va_arg(ap, char *);
-
+
list_add_tail(&c->entry, &simple_cmd_list);
va_end(ap);
@@ -319,7 +319,7 @@ out_found:
static void load_config(void)
{
const char *opt;
-
+
if (conf_cli_passwd)
_free(conf_cli_passwd);
opt = conf_get_opt("cli", "password");
@@ -327,7 +327,7 @@ static void load_config(void)
conf_cli_passwd = _strdup(opt);
else
conf_cli_passwd = NULL;
-
+
if (conf_cli_prompt && conf_cli_prompt != def_cli_prompt)
_free(conf_cli_prompt);
opt = conf_get_opt("cli", "prompt");
diff --git a/accel-pppd/cli/show_sessions.c b/accel-pppd/cli/show_sessions.c
index 84ccb70b..6a6732b3 100644
--- a/accel-pppd/cli/show_sessions.c
+++ b/accel-pppd/cli/show_sessions.c
@@ -103,7 +103,7 @@ static void free_row(struct row_t *row)
static void insert_row(struct list_head *list, struct row_t *row)
{
struct row_t *row2, *row3;
-
+
row3 = NULL;
list_for_each_entry(row2, list, entry) {
if (strcmp(row->order_key, row2->order_key) <= 0) {
@@ -213,7 +213,7 @@ static int show_ses_exec(const char *cmd, char * const *f, int f_cnt, void *cli)
col->hidden = 1;
list_add_tail(&col->entry, &c_list);
}
-
+
if (order_key && !order_key_f) {
col = _malloc(sizeof(*col));
col->column = order_key;
diff --git a/accel-pppd/cli/std_cmd.c b/accel-pppd/cli/std_cmd.c
index 84a7711c..38e6a8b6 100644
--- a/accel-pppd/cli/std_cmd.c
+++ b/accel-pppd/cli/std_cmd.c
@@ -113,7 +113,7 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli)
pcre *re;
const char *pcre_err;
int pcre_offset;
-
+
if (f_cnt == 5) {
if (!strcmp(f[4], "hard"))
hard = 1;
@@ -121,7 +121,7 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli)
return CLI_CMD_SYNTAX;
} else if (f_cnt != 4)
return CLI_CMD_SYNTAX;
-
+
re = pcre_compile2(f[3], 0, NULL, &pcre_err, &pcre_offset, NULL);
if (!re) {
cli_sendv(cli, "match: %s at %i\r\n", pcre_err, pcre_offset);
@@ -140,9 +140,9 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli)
triton_context_call(ses->ctrl->ctx, (triton_event_func)__terminate_soft, ses);
}
pthread_rwlock_unlock(&ses_lock);
-
+
pcre_free(re);
-
+
return CLI_CMD_OK;
}
@@ -151,7 +151,7 @@ static int terminate_exec2(int key, char * const *f, int f_cnt, void *cli)
struct ap_session *ses;
int hard = 0;
in_addr_t ipaddr = 0;
-
+
if (f_cnt == 4) {
if (!strcmp(f[3], "hard"))
hard = 1;
@@ -159,10 +159,10 @@ static int terminate_exec2(int key, char * const *f, int f_cnt, void *cli)
return CLI_CMD_SYNTAX;
} else if (f_cnt != 3)
return CLI_CMD_SYNTAX;
-
+
if (key == 1)
ipaddr = inet_addr(f[2]);
-
+
pthread_rwlock_rdlock(&ses_lock);
list_for_each_entry(ses, &ses_list, entry) {
switch (key) {
@@ -205,7 +205,7 @@ static int terminate_exec(const char *cmd, char * const *fields, int fields_cnt,
if (fields_cnt == 1)
return CLI_CMD_SYNTAX;
-
+
if (!strcmp(fields[1], "match") && fields_cnt > 3 && !strcmp(fields[2], "username"))
return terminate_exec1(fields, fields_cnt, client);
else if (!strcmp(fields[1], "username"))
@@ -220,7 +220,7 @@ static int terminate_exec(const char *cmd, char * const *fields, int fields_cnt,
return terminate_exec2(4, fields, fields_cnt, client);
else if (strcmp(fields[1], "all"))
return CLI_CMD_SYNTAX;
-
+
if (fields_cnt == 3) {
if (!strcmp(fields[2], "hard"))
hard = 1;
@@ -228,7 +228,7 @@ static int terminate_exec(const char *cmd, char * const *fields, int fields_cnt,
return CLI_CMD_SYNTAX;
} else if (fields_cnt != 2)
return CLI_CMD_SYNTAX;
-
+
pthread_rwlock_rdlock(&ses_lock);
list_for_each_entry(ses, &ses_list, entry) {
if (hard)
diff --git a/accel-pppd/cli/tcp.c b/accel-pppd/cli/tcp.c
index 9f60cbf3..2a6bfdee 100644
--- a/accel-pppd/cli/tcp.c
+++ b/accel-pppd/cli/tcp.c
@@ -94,7 +94,7 @@ static int cli_client_send(struct cli_client_t *tcln, const void *_buf, int size
if (cln->disconnect)
return -1;
-
+
if (!list_empty(&cln->xmit_queue)) {
b = _malloc(sizeof(*b) + size);
b->size = size;
@@ -197,10 +197,10 @@ static int cln_write(struct triton_md_handler_t *h)
{
struct tcp_client_t *cln = container_of(h, typeof(*cln), hnd);
int k;
-
+
if (!cln->xmit_buf)
return 0;
-
+
while (1) {
for (; cln->xmit_pos < cln->xmit_buf->size; cln->xmit_pos += k) {
k = write(cln->hnd.fd, cln->xmit_buf->buf + cln->xmit_pos, cln->xmit_buf->size - cln->xmit_pos);
@@ -312,7 +312,7 @@ static void start_server(const char *host, int port)
log_emerg("cli: tcp: failed to create server socket: %s\n", strerror(errno));
return;
}
-
+
fcntl(serv_hnd.fd, F_SETFD, fcntl(serv_hnd.fd, F_GETFD) | FD_CLOEXEC);
memset(&addr, 0, sizeof(addr));
@@ -323,7 +323,7 @@ static void start_server(const char *host, int port)
else
addr.sin_addr.s_addr = htonl(INADDR_ANY);
- setsockopt(serv_hnd.fd, SOL_SOCKET, SO_REUSEADDR, &serv_hnd.fd, 4);
+ setsockopt(serv_hnd.fd, SOL_SOCKET, SO_REUSEADDR, &serv_hnd.fd, 4);
if (bind (serv_hnd.fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) {
log_emerg("cli: tcp: failed to bind socket: %s\n", strerror(errno));
close(serv_hnd.fd);
@@ -341,7 +341,7 @@ static void start_server(const char *host, int port)
close(serv_hnd.fd);
return;
}
-
+
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = inet_addr(host);
@@ -383,15 +383,15 @@ static void init(void)
port = atoi(d + 1);
if (port <= 0)
goto err_fmt;
-
+
load_config();
temp_buf = malloc(RECV_BUF_SIZE);
start_server(host, port);
-
+
triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
-
+
return;
err_fmt:
log_emerg("cli: tcp: invalid format\n");
diff --git a/accel-pppd/cli/telnet.c b/accel-pppd/cli/telnet.c
index cece88ee..de2f39ff 100644
--- a/accel-pppd/cli/telnet.c
+++ b/accel-pppd/cli/telnet.c
@@ -142,7 +142,7 @@ static int telnet_send(struct telnet_client_t *cln, const void *_buf, int size)
if (cln->disconnect)
return -1;
-
+
if (!list_empty(&cln->xmit_queue)) {
b = _malloc(sizeof(*b) + size);
b->size = size;
@@ -212,10 +212,10 @@ static int send_password_request(struct telnet_client_t *cln)
if (telnet_send(cln, buf0, sizeof(buf0)))
return -1;
-
+
if (telnet_send(cln, buf1, sizeof(buf1)))
return -1;
-
+
return 0;
}
@@ -240,10 +240,10 @@ static int send_cmdline_tail(struct telnet_client_t *cln, int corr)
return -1;
memset(temp_buf, '\b', cln->cmdline_len - cln->cmdline_pos - corr);
-
+
if (telnet_send(cln, temp_buf, cln->cmdline_len - cln->cmdline_pos - corr))
return -1;
-
+
return 0;
}
@@ -276,7 +276,7 @@ static int telnet_input_char(struct telnet_client_t *cln, uint8_t c)
if (c == '\n')
return 0;
-
+
if (c == '\r') {
cln->cmdline[cln->cmdline_len] = 0;
@@ -304,14 +304,14 @@ static int telnet_input_char(struct telnet_client_t *cln, uint8_t c)
b->size = cln->cmdline_len;
list_add(&b->entry, cln->history.next);
cln->history_pos = cln->history.next;
-
+
if (conf_verbose == 2)
log_info2("cli: %s: %s\n", inet_ntoa(cln->addr.sin_addr), cln->cmdline);
if (cli_process_cmd(&cln->cli_client))
return -1;
}
-
+
cln->cmdline_pos = 0;
cln->cmdline_len = 0;
@@ -346,7 +346,7 @@ static int telnet_input_char(struct telnet_client_t *cln, uint8_t c)
if (c != SE)
return 0;
}
-
+
cln->telcmd = 0;
} else if (cln->esc) {
if (cln->cmdline_pos2 == RECV_BUF_SIZE - 1) {
@@ -360,7 +360,7 @@ static int telnet_input_char(struct telnet_client_t *cln, uint8_t c)
if (cln->cmdline_pos2 - cln->cmdline_len != 2)
return 0;
-
+
cln->esc = 0;
if (cln->auth) {
@@ -413,14 +413,14 @@ static int telnet_input_char(struct telnet_client_t *cln, uint8_t c)
if (cln->cmdline_pos) {
if (cln->cmdline_pos < cln->cmdline_len) {
memmove(cln->cmdline + cln->cmdline_pos - 1, cln->cmdline + cln->cmdline_pos, cln->cmdline_len - cln->cmdline_pos);
-
+
cln->cmdline[cln->cmdline_len - 1] = ' ';
-
+
if (telnet_send(cln, "\b", 1))
return -1;
-
+
cln->cmdline_pos--;
-
+
if (send_cmdline_tail(cln, 0))
return -1;
} else {
@@ -459,7 +459,7 @@ static int telnet_input_char(struct telnet_client_t *cln, uint8_t c)
return -1;
}
}
-
+
if (cln->cmdline_pos < cln->cmdline_len) {
if (send_cmdline_tail(cln, 0))
return -1;
@@ -585,9 +585,9 @@ static int serv_read(struct triton_md_handler_t *h)
list_add(&b2->entry, conn->history.next);
}
pthread_mutex_unlock(&history_lock);
-
+
conn->history_pos = conn->history.next;
-
+
conn->cli_client.cmdline = conn->cmdline;
conn->cli_client.send = cli_client_send;
conn->cli_client.sendv = cli_client_sendv;
@@ -649,7 +649,7 @@ static void start_server(const char *host, int port)
log_emerg("cli: telnet: failed to create server socket: %s\n", strerror(errno));
return;
}
-
+
fcntl(serv_hnd.fd, F_SETFD, fcntl(serv_hnd.fd, F_GETFD) | FD_CLOEXEC);
memset(&addr, 0, sizeof(addr));
@@ -660,7 +660,7 @@ static void start_server(const char *host, int port)
else
addr.sin_addr.s_addr = htonl(INADDR_ANY);
- setsockopt(serv_hnd.fd, SOL_SOCKET, SO_REUSEADDR, &serv_hnd.fd, 4);
+ setsockopt(serv_hnd.fd, SOL_SOCKET, SO_REUSEADDR, &serv_hnd.fd, 4);
if (bind (serv_hnd.fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) {
log_emerg("cli: telnet: failed to bind socket: %s\n", strerror(errno));
close(serv_hnd.fd);
@@ -678,7 +678,7 @@ static void start_server(const char *host, int port)
close(serv_hnd.fd);
return;
}
-
+
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = inet_addr(host);
@@ -715,7 +715,7 @@ static void load_history_file(void)
f = fopen(conf_history_file, "r");
if (!f)
return;
-
+
while (fgets((char *)temp_buf, RECV_BUF_SIZE, f)) {
b = _malloc(sizeof(*b) + strlen((char *)temp_buf) + 1);
b->p_buf = NULL;
@@ -747,12 +747,12 @@ static void init(void)
opt = conf_get_opt("cli", "telnet");
if (!opt)
return;
-
+
host = strdup(opt);
d = strstr(host, ":");
if (!d)
goto err_fmt;
-
+
*d = 0;
port = atoi(d + 1);
if (port <= 0)
@@ -770,11 +770,11 @@ static void init(void)
load_history_file();
start_server(host, port);
-
+
atexit(save_history_file);
-
+
triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
-
+
return;
err_fmt:
log_emerg("cli: telnet: invalid format\n");