# HG changeset patch # User Matti Hamalainen # Date 1403307651 -10800 # Node ID 118276b606671bdac4793abc50daa285d7d78802 # Parent bb6b07b448001cefee3273e1ea353aaaa49aa67a More work towards using th-libs th_network module. diff -r bb6b07b44800 -r 118276b60667 Makefile.gen --- 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) diff -r bb6b07b44800 -r 118276b60667 main.c --- 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"); diff -r bb6b07b44800 -r 118276b60667 ui.h --- a/ui.h Tue May 27 07:31:20 2014 +0300 +++ b/ui.h Sat Jun 21 02:40:51 2014 +0300 @@ -22,7 +22,7 @@ #include #include "th_types.h" #include "th_string.h" -#include "network.h" +#include "th_network.h" #define SET_MAX_WINDOWS (32) #define NN_BACKBUF_LEN (512) // Backbuffer size (in lines)