mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-27 00:46:13 -05:00
style: format code for consistency and readability
This commit is contained in:
4 files changed
+37
-23
No files matched your search
@@ -0,0 +1,6 @@
|
||||
BasedOnStyle: LLVM
|
||||
IndentWidth: 8
|
||||
TabWidth: 8
|
||||
UseTab: Always
|
||||
ColumnLimit: 80
|
||||
BreakBeforeBraces: Linux
|
||||
@@ -8,5 +8,9 @@ end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[{*.c,*.h}]
|
||||
indent_style = tab
|
||||
indent_size = 8
|
||||
|
||||
[{Makefile,Makefile.in}]
|
||||
indent_style = tab
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <openconnect.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <openconnect.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "vpn.h"
|
||||
|
||||
@@ -15,14 +15,16 @@ static const char *g_vpnc_interface;
|
||||
static vpn_connected_callback on_vpn_connected;
|
||||
|
||||
/* Validate the peer certificate */
|
||||
static int validate_peer_cert(__attribute__((unused)) void *_vpninfo, const char *reason)
|
||||
static int validate_peer_cert(__attribute__((unused)) void *_vpninfo,
|
||||
const char *reason)
|
||||
{
|
||||
INFO("Accepting the server certificate though %s", reason);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Print progress messages */
|
||||
static void print_progress(__attribute__((unused)) void *_vpninfo, int level, const char *format, ...)
|
||||
static void print_progress(__attribute__((unused)) void *_vpninfo, int level,
|
||||
const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
@@ -39,7 +41,8 @@ static void print_progress(__attribute__((unused)) void *_vpninfo, int level, co
|
||||
|
||||
static void setup_tun_handler(void *_vpninfo)
|
||||
{
|
||||
int ret = openconnect_setup_tun_device(_vpninfo, g_vpnc_script, g_vpnc_interface);
|
||||
int ret = openconnect_setup_tun_device(_vpninfo, g_vpnc_script,
|
||||
g_vpnc_interface);
|
||||
if (!ret) {
|
||||
on_vpn_connected(g_cmd_pipe_fd, g_user_data);
|
||||
}
|
||||
@@ -68,7 +71,9 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
INFO("NO_DTLS: %d", options->no_dtls);
|
||||
INFO("DPD_INTERVAL: %d", options->dpd_interval);
|
||||
|
||||
vpninfo = openconnect_vpninfo_new(options->user_agent, validate_peer_cert, NULL, NULL, print_progress, NULL);
|
||||
vpninfo =
|
||||
openconnect_vpninfo_new(options->user_agent, validate_peer_cert,
|
||||
NULL, NULL, print_progress, NULL);
|
||||
|
||||
if (!vpninfo) {
|
||||
ERROR("openconnect_vpninfo_new failed");
|
||||
@@ -87,7 +92,8 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
|
||||
if (options->certificate) {
|
||||
INFO("Setting client certificate: %s", options->certificate);
|
||||
openconnect_set_client_cert(vpninfo, options->certificate, options->sslkey);
|
||||
openconnect_set_client_cert(vpninfo, options->certificate,
|
||||
options->sslkey);
|
||||
}
|
||||
|
||||
if (options->key_password) {
|
||||
@@ -95,7 +101,8 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
}
|
||||
|
||||
if (options->csd_wrapper) {
|
||||
openconnect_setup_csd(vpninfo, options->csd_uid, 1, options->csd_wrapper);
|
||||
openconnect_setup_csd(vpninfo, options->csd_uid, 1,
|
||||
options->csd_wrapper);
|
||||
}
|
||||
|
||||
if (options->mtu > 0) {
|
||||
@@ -135,7 +142,8 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
openconnect_set_setup_tun_handler(vpninfo, setup_tun_handler);
|
||||
|
||||
while (1) {
|
||||
int ret = openconnect_mainloop(vpninfo, options->reconnect_timeout, 10);
|
||||
int ret = openconnect_mainloop(vpninfo,
|
||||
options->reconnect_timeout, 10);
|
||||
|
||||
if (ret) {
|
||||
INFO("openconnect_mainloop returned %d, exiting", ret);
|
||||
@@ -155,6 +163,7 @@ void vpn_disconnect()
|
||||
INFO("Stopping VPN connection: %d", g_cmd_pipe_fd);
|
||||
|
||||
if (write(g_cmd_pipe_fd, &cmd, 1) < 0) {
|
||||
ERROR("Failed to write to command pipe, VPN connection may not be stopped");
|
||||
ERROR("Failed to write to command pipe, VPN connection may not "
|
||||
"be stopped");
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
#include <openconnect.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <openconnect.h>
|
||||
|
||||
typedef void (*vpn_connected_callback)(int cmd_pipe_fd, void *user_data);
|
||||
|
||||
typedef struct vpn_options
|
||||
{
|
||||
typedef struct vpn_options {
|
||||
void *user_data;
|
||||
const char *server;
|
||||
const char *cookie;
|
||||
@@ -43,9 +42,8 @@ static char *format_message(const char *format, va_list args)
|
||||
int len = vsnprintf(NULL, 0, format, args_copy);
|
||||
va_end(args_copy);
|
||||
|
||||
char *buffer = (char*)malloc(len + 1);
|
||||
if (buffer == NULL)
|
||||
{
|
||||
char *buffer = (char *)malloc(len + 1);
|
||||
if (buffer == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -63,12 +61,9 @@ static void _log(int level, ...)
|
||||
|
||||
va_end(args);
|
||||
|
||||
if (message == NULL)
|
||||
{
|
||||
if (message == NULL) {
|
||||
vpn_log(PRG_ERR, "Failed to format log message");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
vpn_log(level, message);
|
||||
free(message);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user