diff options
author | Luo Jinghua <sunmoon1997@gmail.com> | 2009-09-02 11:30:23 +0800 |
---|---|---|
committer | Luo Jinghua <sunmoon1997@gmail.com> | 2009-09-02 11:30:23 +0800 |
commit | 3b5a85363fec4bb8dfa2e95f8e5ce9b999fa1011 (patch) | |
tree | 156deaebbe579ce87ba28607ca6c2e1bce4ae28b | |
parent | 539825afa715e2a7644c3b338407397ff2652b6a (diff) |
wrapper: if PPSW_PORT is set, connect to server via that port
-rw-r--r-- | wrapper/ppswrapper.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/wrapper/ppswrapper.c b/wrapper/ppswrapper.c index ab250ba..23a05a9 100644 --- a/wrapper/ppswrapper.c +++ b/wrapper/ppswrapper.c @@ -41,12 +41,20 @@ static struct { static ppsw_t* ppsw_client_get(void) { + const char *ppsw_port = getenv ("PPSW_PORT"); + int port = -1; + if (ppsw_state.client) { ppsw_state.refcnt++; return ppsw_state.client; } - ppsw_state.client = ppsw_client_create (PPSW_PORT); + if (ppsw_port) + port = atoi (ppsw_port); + if (port >= 0 && port < 1024) + port = -1; + + ppsw_state.client = ppsw_client_create (port); if (!ppsw_state.client) return NULL; |