enable building shared library for #128

This commit is contained in:
Max Lv
2014-11-06 10:42:00 +08:00
parent 7adc9037ae
commit 6f64d431b6
25 changed files with 3629 additions and 3116 deletions
+3 -3
View File
@@ -1,3 +1,5 @@
VERSION_INFO = 1:0:0
AM_CFLAGS = -g -O2 -Wall -Werror -Wno-deprecated-declarations -fno-strict-aliasing -std=gnu99 -D_GNU_SOURCE
AM_CFLAGS += -I$(top_srcdir)/libev
AM_CFLAGS += -I$(top_srcdir)/libasyncns
@@ -66,11 +68,9 @@ ss_redir_SOURCES = utils.c \
ss_redir_LDADD = $(SS_COMMON_LIBS)
endif
if BUILD_LIB
lib_LTLIBRARIES = libshadowsocks.la
libshadowsocks_la_SOURCES = $(ss_local_SOURCES)
libshadowsocks_la_CFLAGS = $(ss_local_CFLAGS) -DLIB_ONLY
libshadowsocks_la_LDFLAGS = -version-info $(VERSION_INFO)
libshadowsocks_la_LIBADD = $(ss_local_LDADD)
include_HEADERS = shadowsocks.h
endif
+412 -331
View File
File diff suppressed because it is too large Load Diff
+1 -28
View File
@@ -1166,35 +1166,8 @@ int main (int argc, char **argv)
}
#else
int start_ss_service(profile_t profile, int background)
int start_ss_local_server(profile_t profile)
{
#ifndef __MINGW32__
if (background) {
/* Our process ID and Session ID */
pid_t pid;
/* Fork off the parent process */
pid = fork();
if (pid < 0)
{
return -1;
}
/* If we got a good PID, then
we can exit the parent process. */
if (pid > 0)
{
return pid;
}
/* Close out the standard file descriptors */
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
}
#endif
srand(time(NULL));
char *remote_host = profile.remote_host;
+7 -8
View File
@@ -59,18 +59,17 @@ const profile_t EXAMPLE_PROFILE = {
*/
/*
* Create and start a shadowsocks service.
* Create and start a shadowsocks local server.
*
* If background is set to true, the service will run in a child process and
* return the pid if success. Otherwise, calling this function will block the
* current thread forever.
* Calling this function will block the current thread forever if the server
* starts successfully.
*
* On Win32, background mode is invalid. This function will always block the
* caller and never return.
* Make sure start the server in a seperate process to avoid any potential
* memory and socket leak.
*
* If failed, -1 is returned.
* If failed, -1 is returned. Errors will output to the log file.
*/
int start_ss_service(profile_t profile, int background);
int start_ss_local_server(profile_t profile);
// To stop the service on posix system, just kill the daemon process
// kill(pid, SIGKILL);
+4
View File
@@ -44,6 +44,10 @@
#define INT_DIGITS 19 /* enough for 64 bit integer */
#ifdef LIB_ONLY
FILE* logfile;
#endif
#ifdef HAS_SYSLOG
int use_syslog = 0;
#endif
+2 -2
View File
@@ -44,12 +44,12 @@
#ifdef LIB_ONLY
extern FILE* logfile;
#define TIME_FORMAT "%Y-%m-%d %H:%M:%S"
#define USE_SYSLOG(ident)
FILE *logfile;
#define USE_LOGFILE(ident) do {\
if (ident != NULL) logfile = fopen(ident, "w+");}\
while(0)