Format Android protector C code

This commit is contained in:
Andy Wang 2020-10-17 11:11:15 +01:00
parent 36bf0c919f
commit c6d6f40021
1 changed files with 42 additions and 45 deletions

View File

@ -19,9 +19,8 @@ package main
int fd[n]; \ int fd[n]; \
} }
int int ancil_send_fds_with_buffer(int sock, const int *fds, unsigned n_fds,
ancil_send_fds_with_buffer(int sock, const int *fds, unsigned n_fds, void *buffer) void *buffer) {
{
struct msghdr msghdr; struct msghdr msghdr;
char nothing = '!'; char nothing = '!';
struct iovec nothing_ptr; struct iovec nothing_ptr;
@ -46,22 +45,20 @@ package main
return (sendmsg(sock, &msghdr, 0) >= 0 ? 0 : -1); return (sendmsg(sock, &msghdr, 0) >= 0 ? 0 : -1);
} }
int int ancil_send_fd(int sock, int fd) {
ancil_send_fd(int sock, int fd)
{
ANCIL_FD_BUFFER(1) buffer; ANCIL_FD_BUFFER(1) buffer;
return (ancil_send_fds_with_buffer(sock, &fd, 1, &buffer)); return (ancil_send_fds_with_buffer(sock, &fd, 1, &buffer));
} }
void void set_timeout(int sock) {
set_timeout(int sock)
{
struct timeval tv; struct timeval tv;
tv.tv_sec = 3; tv.tv_sec = 3;
tv.tv_usec = 0; tv.tv_usec = 0;
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval)); setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,
setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(struct timeval)); sizeof(struct timeval));
setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv,
sizeof(struct timeval));
} }
*/ */
import "C" import "C"