Skip to content

Commit

Permalink
Merge pull request #49 from beordle/fix_compile_error
Browse files Browse the repository at this point in the history
fix compile error
  • Loading branch information
beordle authored May 21, 2024
2 parents 93064c4 + 3db3589 commit 1c50461
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 25 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 2.8)
project(termtunnel C)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_C_STANDARD 11)
if (CMAKE_HOST_WIN32)
set(WINDOWS 1)
Expand Down
2 changes: 1 addition & 1 deletion src/agentcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ int server_call_agent(int32_t method, char *strbuf) {
thread_arg_pass_t *tmp = malloc(sizeof(thread_arg_pass_t));
tmp->method = method;
tmp->strbuf = strdup(strbuf);
sys_thread_new("call_send", call_send_request, tmp, DEFAULT_THREAD_STACKSIZE,
sys_thread_new("call_send", (lwip_thread_fn)call_send_request, tmp, DEFAULT_THREAD_STACKSIZE,
DEFAULT_THREAD_PRIO);
return 0;
}
4 changes: 2 additions & 2 deletions src/fileexchange.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ int file_send_start(char *src_path, char *dst_path) {
// uv_async_send(pe->exchange_notify);
}
log_info("file_send_start2");
sys_thread_new("file_send", file_send_request, (void *)pe,
sys_thread_new("file_send", (lwip_thread_fn)file_send_request, (void *)pe,
DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
return 0;
}
Expand Down Expand Up @@ -217,7 +217,7 @@ int file_recv_start(char *src_path, char *dst_path) {
strcpy(pe->src_path, src_path);
strcpy(pe->dst_path, dst_path);
log_debug("file_recv_start");
sys_thread_new("file_recv", file_recv_request, (void *)pe,
sys_thread_new("file_recv", (lwip_thread_fn)file_recv_request, (void *)pe,
DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
return 0;
}
17 changes: 9 additions & 8 deletions src/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ queue_t *q;
void uvloop_process_income(uv_async_t *handle) {
// log_info("process income queue\n");
frame_data *f;
int dry = handle->data;
size_t dry = (size_t)handle->data;
if (!dry) {
return;
}
Expand Down Expand Up @@ -139,7 +139,7 @@ int vnet_notify_to_libuv(char *buf, size_t size) {
f->len = size;
queue_put(q, f);
// log_info("add queue");
data_income_notify.data = 1; // set dry
data_income_notify.data = (void*)1; // set dry
int r = uv_async_send(&data_income_notify);
return 0;
}
Expand All @@ -151,7 +151,7 @@ int libuv_add_vnet_notify() {
return 0;
}
added = true;
data_income_notify.data = 1;
data_income_notify.data = (void*)1;
int r = uv_async_init(uv_default_loop(), &data_income_notify,
uvloop_process_income);
log_info("libuv_add_vnet_notify %d", r);
Expand Down Expand Up @@ -377,7 +377,7 @@ void find_a_packet(char *buf, ssize_t len) {
}

int push_data() {
data_income_notify.data = 1;
data_income_notify.data = (void*)1;
return uv_async_send(&data_income_notify);
}

Expand Down Expand Up @@ -451,11 +451,12 @@ void send_exit_message(uv_async_t *handle) {
//free(handle); // TODO
}

void pty_process_on_exit(int exitcode) {
int pty_process_on_exit(int exitcode) {
// TODO 模拟信号错误
// tell client our exitcode.
async_process_exit->data = (int)exitcode;
async_process_exit->data = (void*)exitcode;
uv_async_send(async_process_exit);
return 0;
}

void server(int argc, const char *argv[]) {
Expand Down Expand Up @@ -532,7 +533,7 @@ int call_bootstrap_get_args(get_args_callback bootstrap_args_ready) {
uv_async_t *s = malloc(sizeof(uv_async_t));
uv_async_init(uv_default_loop(), s, (uv_async_cb)bootstrap_args_ready);
pthread_t p;
pthread_create(&p, NULL, bootstrap_get_args, s);
pthread_create(&p, NULL, (void*)bootstrap_get_args, s);
pthread_detach(p);
return 0;
}
Expand All @@ -556,7 +557,7 @@ void server_handle_client_packet(int64_t type, char *buf, ssize_t len) {
}
case COMMAND_GET_ARGS: {

call_bootstrap_get_args(get_args_done_callback);
call_bootstrap_get_args((void*)get_args_done_callback);
//comm_write_packet_to_cli(COMMAND_TTY_PLAIN_DATA, "11", 2);
break;
}
Expand Down
8 changes: 4 additions & 4 deletions src/portforward.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ int pipe_lwip_socket_and_socket_pair(int lwip_fd, int fd) {
*(array) = lwip_fd;
*(array + 1) = fd;
pthread_t worker2;
pthread_create(&worker2, NULL, &loop_socket_to_lwipsocket, (void *)array);
pthread_create(&worker2, NULL, (void*)&loop_socket_to_lwipsocket, (void *)array);
loop_lwipsocket_to_socket((void *)array);
pthread_join(worker2, NULL);
log_info("lwip ip pair %d %d", lwip_fd, fd);
Expand Down Expand Up @@ -289,9 +289,9 @@ static void portforward_service_handler(port_listen_t *pe) {
child_pe->port = pe->port;
child_pe->local_fd = new_sd;
if (pe->port == 0) { // socks/http proxy
pthread_create(worker, NULL, &portforward_transparent_server_pipe, (void *)child_pe);
pthread_create(worker, NULL, (void*)&portforward_transparent_server_pipe, (void *)child_pe);
} else {
pthread_create(worker, NULL, &portforward_static_server_pipe, (void *)child_pe);
pthread_create(worker, NULL, (void*)&portforward_static_server_pipe, (void *)child_pe);
}

} else {
Expand Down Expand Up @@ -354,7 +354,7 @@ int portforward_static_start(char *src_host, uint16_t src_port, char *dst_host,
// TODO(jdz) agent监听模式,cli暂时无法获取结果
}

sys_thread_new("portforward_static", portforward_service_handler, (void *)pe,
sys_thread_new("portforward_static", (lwip_thread_fn)portforward_service_handler, (void *)pe,
DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
return 0;

Expand Down
4 changes: 2 additions & 2 deletions src/pty.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ int do_waitpid(pid_t childpid) {
pid_t wait_id = 0;
do {
errno = 0;
wait_id = waitpid(childpid, &status, NULL);
wait_id = waitpid(childpid, &status, 0);

if (wait_id < 0 && errno == EINTR) {
wait_id = 0;
Expand Down Expand Up @@ -179,7 +179,7 @@ int pty_run(int argc, char *argv[], tell_exitcode_callback *cb) {
(thread_pass_arg_t *)malloc(sizeof(thread_pass_arg_t));
temp->cb_func = cb;
temp->process_pid = pid;
pthread_create(&thr, NULL, do_waitpid_wrap, temp);
pthread_create(&thr, NULL, (void*)do_waitpid_wrap, temp);
pthread_detach(thr);
}
free(name);
Expand Down
6 changes: 3 additions & 3 deletions src/repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,13 @@ actionfinder_t action_table[] = {
{"remote_listen", portforward_func, "port forward bind on remote host",
"remote_listen [remote_host] [remote_port] [local_host] [local_port]\n"
"when local_port==0, the service listen on remote_port will be a "
"socks5+http proxy server.", NULL},
"socks5+http proxy server.", 0},
{"upload", upload_func, "upload a file", "usage", FLAG_ONESHOT},
{"rz", upload_func, "alias upload", "usage", FLAG_ONESHOT},
{"download", download_func, "download a file", "usage", FLAG_ONESHOT},
{"sz", download_func, "alias download", "usage", FLAG_ONESHOT},
{"help", help_func, "view help manpage", "usage", FLAG_ONESHOT},
{"exit", exit_func, "exit application", "usage", NULL},
{"exit", exit_func, "exit application", "usage", 0},
};

int help_func(int argc, char **argv) {
Expand Down Expand Up @@ -596,7 +596,7 @@ void interact_run(int _in, int _out) {
int cc = read(STDIN_FILENO, ibuf, BUFSIZ);
CHECK(cc > 0, "cc>0");
if (cc < 0) {
log_trace("error %s", strerror("read"));
log_trace("read error %s", strerror(errno));
exit(EXIT_FAILURE);
}
send_binary(_out, COMMAND_TTY_PLAIN_DATA, ibuf, cc);
Expand Down
10 changes: 5 additions & 5 deletions src/vnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,17 +326,17 @@ void *vnet_init(callback_t cb) {

if (get_state_mode() == MODE_AGENT_PROCESS) {
// pass
sys_thread_new("file_receiver", file_receiver_start, NULL,
sys_thread_new("file_receiver", (lwip_thread_fn)file_receiver_start, NULL,
DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
sys_thread_new("file_sender", file_sender_start, NULL,
sys_thread_new("file_sender", (lwip_thread_fn)file_sender_start, NULL,
DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
sys_thread_new("agentcall_server", agentcall_server_start, NULL,
sys_thread_new("agentcall_server", (lwip_thread_fn)agentcall_server_start, NULL,
DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
}
sys_thread_new("portforward_static_server",
portforward_static_remote_server_start, NULL,
(lwip_thread_fn)portforward_static_remote_server_start, NULL,
DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
sys_thread_new("socksproxy_server", socksproxy_remote_start, NULL,
sys_thread_new("socksproxy_server", (lwip_thread_fn)socksproxy_remote_start, NULL,
DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);

return &g_netif;
Expand Down

0 comments on commit 1c50461

Please sign in to comment.