diff --git a/iocalls.c b/iocalls.c index 311da3b..c1fbf7f 100644 --- a/iocalls.c +++ b/iocalls.c @@ -55,7 +55,7 @@ static void * internal_add_input(int source, H3270 *session, void (*fn)(H3270 *s static void * internal_add_output(int source, H3270 *session, void (*fn)(H3270 *session)); static void * internal_add_except(int source, H3270 *session, void (*fn)(H3270 *session)); -static int internal_callthread(int(*callback)(H3270 *, void *), H3270 *session, void *parm); +// static int internal_callthread(int(*callback)(H3270 *, void *), H3270 *session, void *parm); static int internal_wait(H3270 *hSession, int seconds); static int internal_event_dispatcher(H3270 *hSession, int block); @@ -81,8 +81,8 @@ static void internal_ring_bell(H3270 *); static void * (*add_except)(int source, H3270 *session, void (*fn)(H3270 *session)) = internal_add_except; - static int (*callthread)(int(*callback)(H3270 *, void *), H3270 *session, void *parm) - = internal_callthread; +// static int (*callthread)(int(*callback)(H3270 *, void *), H3270 *session, void *parm) +// = internal_callthread; static int (*wait)(H3270 *hSession, int seconds) = internal_wait; @@ -621,10 +621,12 @@ retry: } +/* static int internal_callthread(int(*callback)(H3270 *, void *), H3270 *session, void *parm) { return callback(session,parm); } +*/ static int internal_wait(H3270 *hSession, int seconds) { @@ -755,8 +757,8 @@ LIB3270_EXPORT int lib3270_register_handlers(const struct lib3270_callbacks *cbk if(cbk->AddExcept) add_except = cbk->AddExcept; - if(cbk->callthread) - callthread = cbk->callthread; +// if(cbk->callthread) +// callthread = cbk->callthread; if(cbk->Wait) wait = cbk->Wait; @@ -771,6 +773,7 @@ LIB3270_EXPORT int lib3270_register_handlers(const struct lib3270_callbacks *cbk } +/* LIB3270_EXPORT int lib3270_call_thread(int(*callback)(H3270 *h, void *), H3270 *h, void *parm) { int rc; @@ -786,6 +789,7 @@ LIB3270_EXPORT int lib3270_call_thread(int(*callback)(H3270 *h, void *), H3270 * return rc; } +*/ LIB3270_EXPORT void lib3270_main_iterate(H3270 *hSession, int block) { diff --git a/proxy.c b/proxy.c index c791b04..cf93c58 100644 --- a/proxy.c +++ b/proxy.c @@ -694,15 +694,15 @@ static int proxy_socks4(H3270 *hSession, int fd, char *host, unsigned short port } #endif // HAVE_GETADDRINFO -/* SOCKS version 5 (RFC 1928) proxy. */ +/* SOCKS version 5 (RFC 1928) proxy. */ /* static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port, int force_d) { union { struct sockaddr sa; struct sockaddr_in sin; -#if defined(AF_INET6) /*[*/ +#if defined(AF_INET6) struct sockaddr_in6 sin6; -#endif /*]*/ +#endif } ha; socklen_t ha_len = 0; int use_name = 0; @@ -715,7 +715,7 @@ static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port char nbuf[256]; int done = 0; -#if defined(X3270_TRACE) /*[*/ +#if defined(X3270_TRACE) const char *atype_name[] = { "", @@ -725,7 +725,7 @@ static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port "IPv6" }; unsigned char *portp; -#endif /*]*/ +#endif unsigned short rport; if (force_d) @@ -734,7 +734,7 @@ static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port char errmsg[1024]; int rv; - /* Resolve the hostname. */ + // Resolve the hostname. rv = resolve_host_and_port(hSession,host, CN, &rport, &ha.sa, &ha_len,errmsg, sizeof(errmsg)); if (rv == -2) use_name = 1; @@ -744,22 +744,22 @@ static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port } } - /* Send the authentication request to the server. */ + // Send the authentication request to the server. strcpy((char *)rbuf, "\005\001\000"); -#if defined(X3270_TRACE) /*[*/ +#if defined(X3270_TRACE) trace_dsn(hSession,_("SOCKS5 Proxy: xmit version 5 nmethods 1 (no auth)\n")); trace_netdata(hSession, '>', rbuf, 3); -#endif /*]*/ +#endif if (send(fd, (const char *) rbuf, 3, 0) < 0) { popup_a_sockerr(hSession,_("SOCKS5 Proxy: send error")); return -1; } - /* - * Wait for the server reply. - * Read 2 bytes of response. - */ + // + // Wait for the server reply. + // Read 2 bytes of response. + // nread = 0; for (;;) { fd_set rfds; @@ -772,10 +772,10 @@ static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port if (select(fd + 1, &rfds, NULL, NULL, &tv) < 0) { popup_an_error(hSession,_("SOCKS5 Proxy: server timeout")); -#if defined(X3270_TRACE) /*[*/ +#if defined(X3270_TRACE) if (nread) trace_netdata(hSession, '<', rbuf, nread); -#endif /*]*/ +#endif return -1; } @@ -783,28 +783,28 @@ static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port if (nr < 0) { popup_a_sockerr(hSession,_("SOCKS5 Proxy: receive error")); -#if defined(X3270_TRACE) /*[*/ +#if defined(X3270_TRACE) if (nread) trace_netdata(hSession, '<', rbuf, nread); -#endif /*]*/ +#endif return -1; } if (nr == 0) { popup_a_sockerr(hSession,_("SOCKS5 Proxy: unexpected EOF")); -#if defined(X3270_TRACE) /*[*/ +#if defined(X3270_TRACE) if (nread) trace_netdata(hSession, '<', rbuf, nread); -#endif /*]*/ +#endif return -1; } if (++nread >= 2) break; } -#if defined(X3270_TRACE) /*[*/ +#if defined(X3270_TRACE) trace_netdata(hSession, '<', rbuf, nread); -#endif /*]*/ +#endif if (rbuf[0] != 0x05 || (rbuf[1] != 0 && rbuf[1] != 0xff)) { @@ -812,9 +812,9 @@ static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port return -1; } -#if defined(X3270_TRACE) /*[*/ +#if defined(X3270_TRACE) trace_dsn(hSession,"SOCKS5 Proxy: recv version %d method %d\n", rbuf[0],rbuf[1]); -#endif /*]*/ +#endif if (rbuf[1] == 0xff) { @@ -822,40 +822,40 @@ static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port return -1; } - /* Send the request to the server. */ + // Send the request to the server. buf = lib3270_malloc(32 + strlen(host)); s = buf; - *s++ = 0x05; /* protocol version 5 */ - *s++ = 0x01; /* CONNECT */ - *s++ = 0x00; /* reserved */ + *s++ = 0x05; // protocol version 5 + *s++ = 0x01; // CONNECT + *s++ = 0x00; // reserved if (use_name) { - *s++ = 0x03; /* domain name */ + *s++ = 0x03; // domain name *s++ = strlen(host); strcpy(s, host); s += strlen(host); } else if (ha.sa.sa_family == AF_INET) { - *s++ = 0x01; /* IPv4 */ + *s++ = 0x01; // IPv4 memcpy(s, &ha.sin.sin_addr, 4); s += 4; strcpy(nbuf, inet_ntoa(ha.sin.sin_addr)); -#if defined(AF_INET6) /*[*/ +#if defined(AF_INET6) } else { - *s++ = 0x04; /* IPv6 */ + *s++ = 0x04; // IPv6 memcpy(s, &ha.sin6.sin6_addr, sizeof(struct in6_addr)); s += sizeof(struct in6_addr); (void) inet_ntop(AF_INET6, &ha.sin6.sin6_addr, nbuf, sizeof(nbuf)); -#endif /*]*/ +#endif } SET16(s, port); -#if defined(X3270_TRACE) /*[*/ +#if defined(X3270_TRACE) trace_dsn(hSession,"SOCKS5 Proxy: xmit version 5 connect %s %s port %u\n", use_name? "domainname": ((ha.sa.sa_family == AF_INET)? "IPv4": "IPv6"), use_name? host: nbuf, port); trace_netdata(hSession, '>', (unsigned char *)buf, s - buf); -#endif /*]*/ +#endif if (send(fd, buf, s - buf, 0) < 0) { popup_a_sockerr(hSession,_("SOCKS5 Proxy: send error")); @@ -864,11 +864,11 @@ static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port } lib3270_free(buf); - /* - * Process the reply. - * Only the first two bytes of the response are interesting; - * skip the rest. - */ + // + // Process the reply. + // Only the first two bytes of the response are interesting; + // skip the rest. + // nread = 0; done = 0; buf = NULL; @@ -892,19 +892,19 @@ static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port if (nr < 0) { popup_a_sockerr(hSession,_("SOCKS5 Proxy: receive error")); -#if defined(X3270_TRACE) /*[*/ +#if defined(X3270_TRACE) if (nread) trace_netdata(hSession, '<', (unsigned char *)buf, nread); -#endif /*]*/ +#endif return -1; } if (nr == 0) { popup_an_error(hSession, _("SOCKS5 Proxy: unexpected EOF")); -#if defined(X3270_TRACE) /*[*/ +#if defined(X3270_TRACE) if (nread) trace_netdata(hSession, '<', (unsigned char *)buf, nread); -#endif /*]*/ +#endif return -1; } @@ -916,18 +916,18 @@ static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port if (r != 0x05) { popup_an_error(hSession, _("SOCKS5 Proxy: incorrect reply version 0x%02x"), r); -#if defined(X3270_TRACE) /*[*/ +#if defined(X3270_TRACE) if (nread) trace_netdata(hSession, '<', (unsigned char *)buf, nread); -#endif /*]*/ +#endif return -1; } break; case 1: -#if defined(X3270_TRACE) /*[*/ +#if defined(X3270_TRACE) if (r != 0x00) trace_netdata(hSession, '<', (unsigned char *)buf, nread); -#endif /*]*/ +#endif switch (r) { case 0x00: @@ -973,17 +973,17 @@ static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port case 0x03: n2read = -1; break; -#if defined(AF_INET6) /*[*/ +#if defined(AF_INET6) case 0x04: n2read = sizeof(struct in6_addr) + 2; break; -#endif /*]*/ +#endif default: popup_an_error(hSession, _("SOCKS5 Proxy: unknown server address type 0x%02x"), r); -#if defined(X3270_TRACE) /*[*/ +#if defined(X3270_TRACE) if (nread) trace_netdata(hSession, '<', (unsigned char *)buf, nread); -#endif /*]*/ +#endif return -1; } break; @@ -996,29 +996,29 @@ static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port } } -#if defined(X3270_TRACE) /*[*/ +#if defined(X3270_TRACE) trace_netdata(hSession, '<', (unsigned char *)buf, nread); switch (buf[3]) { - case 0x01: /* IPv4 */ + case 0x01: // IPv4 memcpy(&ha.sin.sin_addr, &buf[4], 4); strcpy(nbuf, inet_ntoa(ha.sin.sin_addr)); portp = (unsigned char *)&buf[4 + 4]; break; - case 0x03: /* domainname */ + case 0x03: // domainname strncpy(nbuf, &buf[5], buf[4]); nbuf[(unsigned char)buf[4]] = '\0'; portp = (unsigned char *)&buf[5 + (unsigned char)buf[4]]; break; -#if defined(AF_INET6) /*[*/ - case 0x04: /* IPv6 */ +#if defined(AF_INET6) + case 0x04: // IPv6 memcpy(&ha.sin6.sin6_addr, &buf[4], sizeof(struct in6_addr)); (void) inet_ntop(AF_INET6, &ha.sin6.sin6_addr, nbuf, sizeof(nbuf)); portp = (unsigned char *)&buf[4 + sizeof(struct in6_addr)]; break; -#endif /*]*/ +#endif default: - /* can't happen */ + // can't happen nbuf[0] = '\0'; portp = (unsigned char *)buf; break; @@ -1029,8 +1029,9 @@ static int proxy_socks5(H3270 *hSession, int fd, char *host, unsigned short port atype_name[(unsigned char)buf[3]], nbuf, rport); -#endif /*]*/ +#endif lib3270_free(buf); return 0; } +*/ diff --git a/resolver.c b/resolver.c index c2d93b4..087bcc9 100644 --- a/resolver.c +++ b/resolver.c @@ -83,7 +83,7 @@ struct parms * Resolve a hostname and port. * Returns 0 for success, -1 for fatal error (name resolution impossible), * -2 for simple error (cannot resolve the name). - */ + */ /* static int cresolve_host_and_port(H3270 *h, struct parms *p) { #if defined( HAVE_GETADDRINFO ) || defined(WIN32) @@ -91,7 +91,7 @@ static int cresolve_host_and_port(H3270 *h, struct parms *p) struct addrinfo hints, *res; int rc; - /* Use getaddrinfo() to resolve the hostname and port together. */ + // Use getaddrinfo() to resolve the hostname and port together. (void) memset(&hints, '\0', sizeof(struct addrinfo)); hints.ai_flags = 0; hints.ai_family = PF_UNSPEC; @@ -138,7 +138,7 @@ static int cresolve_host_and_port(H3270 *h, struct parms *p) char *ptr; struct sockaddr_in *sin = (struct sockaddr_in *) p->sa; - /* Get the port number. */ + // Get the port number. lport = strtoul(p->portname, &ptr, 0); if (ptr == p->portname || *ptr != '\0' || lport == 0L || lport & ~0xffff) { @@ -155,7 +155,7 @@ static int cresolve_host_and_port(H3270 *h, struct parms *p) } *p->pport = ntohs(port); - /* Use gethostbyname() to resolve the hostname. */ + // Use gethostbyname() to resolve the hostname. hp = gethostbyname(p->host); if (hp == (struct hostent *) 0) { @@ -178,8 +178,9 @@ static int cresolve_host_and_port(H3270 *h, struct parms *p) #endif // HAVE_GETADDRINFO return 0; -} +} */ +/* int resolve_host_and_port(H3270 *hSession, const char *host, char *portname, unsigned short *pport,struct sockaddr *sa, socklen_t *sa_len, char *errmsg, int em_len) { int rc; @@ -203,3 +204,4 @@ int resolve_host_and_port(H3270 *hSession, const char *host, char *portname, uns return rc; } +*/ diff --git a/resolverc.h b/resolverc.h index c5c00cd..ac76720 100644 --- a/resolverc.h +++ b/resolverc.h @@ -17,6 +17,6 @@ * Hostname resolution. */ -LIB3270_INTERNAL int resolve_host_and_port(H3270 *session, const char *host, char *portname, unsigned short *pport,struct sockaddr *sa, socklen_t *sa_len, char *errmsg, int em_size); +// LIB3270_INTERNAL int resolve_host_and_port(H3270 *session, const char *host, char *portname, unsigned short *pport,struct sockaddr *sa, socklen_t *sa_len, char *errmsg, int em_size); -- libgit2 0.21.2