Mercurial > hg > nnchat
changeset 623:118276b60667
More work towards using th-libs th_network module.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 21 Jun 2014 02:40:51 +0300 |
parents | bb6b07b44800 |
children | 24d97c710497 |
files | Makefile.gen main.c ui.h |
diffstat | 3 files changed, 20 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile.gen Tue May 27 07:31:20 2014 +0300 +++ b/Makefile.gen Sat Jun 21 02:40:51 2014 +0300 @@ -17,7 +17,7 @@ THLIBS_A=$(OBJPATH)thlibs.a THLIBS_OBJ=th_util.o th_string.o th_args.o th_ioctx.o th_config.o th_network.o -NNCHAT_OBJ=main.o util.o network.o ui.o +NNCHAT_OBJ=main.o util.o ui.o NNCHAT_BIN=$(BINPATH)nnchat$(EXEEXT) TARGETS+=$(THLIBS_A) $(NNCHAT_BIN)
--- a/main.c Tue May 27 07:31:20 2014 +0300 +++ b/main.c Sat Jun 21 02:40:51 2014 +0300 @@ -58,8 +58,8 @@ */ int optPort = 8005, optProxyPort = 1080, - optProxyType = NN_PROXY_NONE, - optProxyAuthType = NN_PROXY_AUTH_NONE; + optProxyType = TH_PROXY_NONE, + optProxyAuthType = TH_PROXY_AUTH_NONE; int optUserColor = 0x000000; char *optServer = "chat.newbienudes.com", *optProxyServer = NULL, @@ -194,10 +194,10 @@ // Validate proxy type if (strcasecmp(proto, "socks4") == 0) - optProxyType = NN_PROXY_SOCKS4; + optProxyType = TH_PROXY_SOCKS4; else if (strcasecmp(proto, "socks4a") == 0) - optProxyType = NN_PROXY_SOCKS4A; + optProxyType = TH_PROXY_SOCKS4A; else { THERR("Invalid proxy type specified: '%s'\n", proto); @@ -240,12 +240,12 @@ // Check what authentication type to use /* - if (optProxyType == NN_PROXY_SOCKS5 && + if (optProxyType == TH_PROXY_SOCKS5 && optProxyUserID != NULL && optProxyPassword != NULL) - optProxyAuthType = NN_PROXY_AUTH_USER; + optProxyAuthType = TH_PROXY_AUTH_USER; else */ - optProxyAuthType = NN_PROXY_AUTH_NONE; + optProxyAuthType = TH_PROXY_AUTH_NONE; ret = TRUE; @@ -361,7 +361,7 @@ if (msg != NULL) { - BOOL ret = nn_conn_send_buf(conn, msg, strlen(msg) + 1); + BOOL ret = th_conn_send_buf(conn, msg, strlen(msg) + 1); th_free(msg); return ret; } @@ -566,16 +566,18 @@ } -void nn_network_errfunc(struct _th_conn_t *conn, const char *msg) +void nn_network_errfunc(struct _th_conn_t *conn, int err, const char *msg) { (void) conn; + (void) err; errorMsg("%s", msg); } -void nn_network_msgfunc(struct _th_conn_t *conn, const char *msg) +void nn_network_msgfunc(struct _th_conn_t *conn, int loglevel, const char *msg) { (void) conn; + (void) loglevel; printMsgConst(NULL, LOG_STAMP | LOG_WINDOW | LOG_FILE, msg); } @@ -1970,7 +1972,7 @@ int main(int argc, char *argv[]) { char *tmpStr; - int index, updateCount = 0; + int index, updateCount = 0, ret; BOOL argsOK, colorSet = FALSE; th_conn_t *conn = NULL; nn_editbuf_t *editBuf = nn_editbuf_new(NN_TMPBUF_SIZE); @@ -2160,9 +2162,9 @@ } // Initialize network - if (!nn_network_init()) + if ((ret = th_network_init()) != THERR_OK) { - THERR("Could not initialize network subsystem.\n"); + THERR("Could not initialize network subsystem: %s\n", th_error_str(ret)); goto err_exit; } @@ -2216,7 +2218,7 @@ editState.conn = conn; // Are we using a proxy? - if (optProxyType != NN_PROXY_NONE && optProxyServer != NULL) + if (optProxyType != TH_PROXY_NONE && optProxyServer != NULL) { if (optProxyUserID == NULL) optProxyUserID = "James Bond"; @@ -2231,7 +2233,7 @@ // Okay, try to resolve the hostname conn->host = th_strdup(optServer); - conn->hst = nn_resolve_host(conn, optServer); + conn->hst = th_resolve_host(conn, optServer); if (conn->hst == NULL) goto err_exit; @@ -2390,7 +2392,7 @@ th_free(optUserNameEnc); th_conn_free(conn); - nn_network_close(); + th_network_close(); THMSG(1, "Connection terminated.\n");