Add option to do a development build with --devel configure flag. Rename proxy_getserverbyname to proxy_getservbyname.

This commit is contained in:
Adam Hamsik 2012-08-05 15:07:37 +02:00
parent 025840930b
commit 361889a2d2
4 changed files with 16 additions and 10 deletions

View File

@ -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

7
configure vendored
View File

@ -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

View File

@ -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;

View File

@ -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);