diff options
author | Adam Hamsik <adam.hamsik@chilisys.com> | 2012-08-05 17:07:37 +0400 |
---|---|---|
committer | Adam Hamsik <adam.hamsik@chilisys.com> | 2012-08-05 17:07:37 +0400 |
commit | 361889a2d29414a0277bc2f606e29d9a2067066a (patch) | |
tree | 5804ac202b780b6fbf7fa36cd614a67e66d9e7a3 | |
parent | 025840930b0e02b5fd0c71a117c2725715632d02 (diff) |
Add option to do a development build with --devel configure flag. Rename proxy_getserverbyname to proxy_getservbyname.
-rw-r--r-- | Makefile | 2 | ||||
-rwxr-xr-x | configure | 7 | ||||
-rw-r--r-- | src/core.c | 15 | ||||
-rw-r--r-- | src/core.h | 2 |
4 files changed, 16 insertions, 10 deletions
@@ -17,7 +17,7 @@ SRCS = $(sort $(wildcard src/*.c)) OBJS = $(SRCS:.c=.o) LOBJS = src/core.o src/common.o src/libproxychains.o -CCFLAGS = -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror -Wextra -Wunused -Wuninitialized -Wconversion -fno-common +CCFLAGS = -Wall -O2 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror LDFLAGS = -shared -fPIC -ldl -lpthread INC = PIC = -fPIC @@ -1,6 +1,7 @@ #!/bin/sh prefix=/usr/local +develflg=0 usage() { echo "supported arguments" @@ -10,6 +11,7 @@ usage() { echo "--libdir=/path default: $prefix/lib" echo "--includedir=/path default: $prefix/include" echo "--sysconfdir=/path default: $prefix/etc" + echo "--devel default:no (set development mode)" echo "--help : show this text" exit 1 } @@ -29,6 +31,7 @@ parsearg() { --libdir=*) libdir=`spliteq $1`;; --includedir=*) includedir=`spliteq $1`;; --sysconfdir=*) sysconfdir=`spliteq $1`;; + --devel) develflg=1;; --help) usage;; esac } @@ -68,6 +71,10 @@ if [ -z "$CC" ] ; then CC=cc fi +if [ $develflg -eq 1 ]; then + CFLAGS="-Wextra -Wunused -Wuninitialized -Wconversion -fno-common -g -O0" +fi + echo CC?=$CC>config.mak [ -z "$CPPFLAGS" ] || echo CPPFLAGS?=$CPPFLAGS>>config.mak [ -z "$CFLAGS" ] || echo USER_CFLAGS?=$CFLAGS>>config.mak @@ -15,6 +15,7 @@ * * ***************************************************************************/ #include <sys/types.h> +#include <sys/cdefs.h> #include <stdio.h> #include <unistd.h> @@ -400,11 +401,11 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c *cur++ = 1; // version c = ulen & 0xFF; *cur++ = (char)c; - memcpy(cur, user, c); + memcpy(cur, user, (size_t)c); cur += c; c = passlen & 0xFF; *cur++ = (char)c; - memcpy(cur, pass, c); + memcpy(cur, pass, (size_t)c); cur += c; if((size_t)(cur - out) != write_n_bytes(sock, out, (size_t) (cur - out))) @@ -825,8 +826,8 @@ void proxy_freeaddrinfo(struct addrinfo *res) { free(res); } -void proxy_getserverbyname(const char * service, struct servent *se_buf, - __unused char * buf, size_t buf_len, struct servent **se_result) +void proxy_getservbyname(const char * service, struct servent *se_buf, + char * buf, size_t buf_len, struct servent **se_result) { #ifdef __linux__ @@ -836,9 +837,7 @@ void proxy_getserverbyname(const char * service, struct servent *se_buf, #ifdef __APPLE__ struct servent *se; -#ifdef THREAD_SAFE MUTEX_LOCK(&internal_getsrvbyname_lock); -#endif if(service) { se = getservbyname(service, NULL); @@ -849,9 +848,7 @@ void proxy_getserverbyname(const char * service, struct servent *se_buf, *se_result = NULL; } } -#ifdef THREAD_SAFE MUTEX_UNLOCK(&internal_getsrvbyname_lock); -#endif #endif /* __APPLE__ */ } @@ -878,7 +875,7 @@ int proxy_getaddrinfo(const char *node, const char *service, const struct addrin goto err2; } if(service) - proxy_getserverbyname(service, &se_buf, buf, sizeof(buf), &se); + proxy_getservbyname(service, &se_buf, buf, sizeof(buf), &se); port = se ? se->s_port : htons(atoi(service ? service : "0")); ((struct sockaddr_in *) &space->sockaddr_space)->sin_port = (in_port_t)port; @@ -135,6 +135,8 @@ struct gethostbyname_data { }; struct hostent* proxy_gethostbyname(const char *name, struct gethostbyname_data *data); +void proxy_getservbyname(const char * service, struct servent *se_buf, + char * buf, size_t buf_len, struct servent **se_result); int proxy_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res); |