Add address feature

This commit is contained in:
Nick Peng
2018-06-26 00:09:11 +08:00
parent 7e60b9bc72
commit 06bc0b1642
10 changed files with 1343 additions and 73 deletions

View File

@@ -77,7 +77,6 @@ errout:
freeaddrinfo(result);
}
return -1;
}
int parse_ip(const char *value, char *ip, int *port)
@@ -144,7 +143,7 @@ int set_fd_nonblock(int fd, int nonblock)
return -1;
}
flags = (nonblock) ? (flags | O_NONBLOCK) : (flags & ~O_NONBLOCK);
flags = (nonblock) ? (flags | O_NONBLOCK) : (flags & ~O_NONBLOCK);
ret = fcntl(fd, F_SETFL, flags);
if (ret == -1) {
return -1;
@@ -152,3 +151,18 @@ int set_fd_nonblock(int fd, int nonblock)
return 0;
}
char *reverse_string(char *output, char *input, int len)
{
char *begin = output;
len--;
while (len >= 0) {
*output = *(input + len);
output++;
len--;
}
*output = 0;
return begin;
}