format with .uncrustify.cfg (#1759)

* format with .uncrustify.cfg

format with .uncrustify.cfg

* format with .uncrustify.cfg

* format with .uncrustify.cfg exclude json.* base64.* uthash.h

* format with .uncrustify.cfg exclude json.* base64.* uthash.h
This commit is contained in:
星野ハジメ
2017-10-30 21:28:53 +08:00
committed by Max Lv
parent 26ae365f7b
commit cc1bb4cf62
22 changed files with 501 additions and 419 deletions
+33 -30
View File
@@ -39,15 +39,15 @@
#define CMD_RESRV_LEN 128
static int exit_code;
static struct cork_env *env = NULL;
static struct cork_exec *exec = NULL;
static struct cork_env *env = NULL;
static struct cork_exec *exec = NULL;
static struct cork_subprocess *sub = NULL;
static int
plugin_log__data(struct cork_stream_consumer *vself,
const void *buf, size_t size, bool is_first)
const void *buf, size_t size, bool is_first)
{
size_t bytes_written = fwrite(buf, 1, size, stderr);
size_t bytes_written = fwrite(buf, 1, size, stderr);
/* If there was an error writing to the file, then signal this
* to the producer */
if (bytes_written == size) {
@@ -74,22 +74,23 @@ plugin_log__free(struct cork_stream_consumer *vself)
struct cork_stream_consumer plugin_log = {
.data = plugin_log__data,
.eof = plugin_log__eof,
.eof = plugin_log__eof,
.free = plugin_log__free,
};
static int start_ss_plugin(const char *plugin,
const char *plugin_opts,
const char *remote_host,
const char *remote_port,
const char *local_host,
const char *local_port,
enum plugin_mode mode)
static int
start_ss_plugin(const char *plugin,
const char *plugin_opts,
const char *remote_host,
const char *remote_port,
const char *local_host,
const char *local_port,
enum plugin_mode mode)
{
char *cmd = NULL;
char *cmd = NULL;
size_t plugin_len = strlen(plugin);
size_t cmd_len = plugin_len + CMD_RESRV_LEN;
size_t cmd_len = plugin_len + CMD_RESRV_LEN;
cmd = ss_malloc(cmd_len);
snprintf(cmd, cmd_len, "exec %s", plugin);
@@ -143,13 +144,14 @@ static int start_ss_plugin(const char *plugin,
* Some old obfsproxy will not be supported as it doesn't even support
* "--data-dir" option
*/
static int start_obfsproxy(const char *plugin,
const char *plugin_opts,
const char *remote_host,
const char *remote_port,
const char *local_host,
const char *local_port,
enum plugin_mode mode)
static int
start_obfsproxy(const char *plugin,
const char *plugin_opts,
const char *remote_host,
const char *remote_port,
const char *local_host,
const char *local_port,
enum plugin_mode mode)
{
char *pch;
char *opts_dump;
@@ -168,7 +170,7 @@ static int start_obfsproxy(const char *plugin,
cork_exec_add_param(exec, "--data-dir");
buf_size = 20 + strlen(plugin) + strlen(remote_host)
+ strlen(remote_port) + strlen(local_host) + strlen(local_port);
+ strlen(remote_port) + strlen(local_host) + strlen(local_port);
buf = ss_malloc(buf_size);
snprintf(buf, buf_size, "/tmp/%s_%s:%s_%s:%s", plugin,
remote_host, remote_port, local_host, local_port);
@@ -232,7 +234,7 @@ start_plugin(const char *plugin,
/*
* Add current dir to PATH, so we can search plugin in current dir
*/
env = cork_env_clone_current();
env = cork_env_clone_current();
current_path = cork_env_get(env, "PATH");
if (current_path != NULL) {
#ifdef HAVE_GET_CURRENT_DIR_NAME
@@ -243,7 +245,7 @@ start_plugin(const char *plugin,
if (!getcwd(cwd, PATH_MAX)) {
#endif
new_path_len = strlen(current_path) + strlen(cwd) + 2;
new_path = ss_malloc(new_path_len);
new_path = ss_malloc(new_path_len);
snprintf(new_path, new_path_len, "%s:%s", cwd, current_path);
#ifdef HAVE_GET_CURRENT_DIR_NAME
free(cwd);
@@ -273,11 +275,11 @@ get_local_port()
}
struct sockaddr_in serv_addr;
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
bzero((char *)&serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = INADDR_ANY;
serv_addr.sin_port = 0;
if (bind(sock, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
serv_addr.sin_port = 0;
if (bind(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
return 0;
}
@@ -285,7 +287,7 @@ get_local_port()
if (getsockname(sock, (struct sockaddr *)&serv_addr, &len) == -1) {
return 0;
}
if (close (sock) < 0) {
if (close(sock) < 0) {
return 0;
}
@@ -301,7 +303,8 @@ stop_plugin()
}
}
int is_plugin_running()
int
is_plugin_running()
{
if (sub != NULL) {
return cork_subprocess_is_finished(sub);