diff --git a/connect.c b/connect.c index c822806..31e8466 100644 --- a/connect.c +++ b/connect.c @@ -245,7 +245,10 @@ static void net_connected(H3270 *hSession) sockstart(hSession); #endif +#if defined(HAVE_LIBSSL) set_ssl_state(hSession,LIB3270_SSL_UNSECURE); +#endif // HAVE_LIBSSL + snprintf(hSession->full_model_name,LIB3270_FULL_MODEL_NAME_LENGTH,"IBM-327%c-%d",hSession->m3279 ? '9' : '8', hSession->model_num); @@ -331,7 +334,7 @@ static void net_connected(H3270 *hSession) _( "SSL error" ), _( "Unable to connect to secure hosts" ), _( "This version of %s was built without support for secure sockets layer (SSL)." ), - PACKAGE_NAME)); + PACKAGE_NAME); return EINVAL; #endif // HAVE_LIBSSL diff --git a/host.c b/host.c index 0d4d3f7..c868b25 100644 --- a/host.c +++ b/host.c @@ -61,300 +61,6 @@ static void try_reconnect(H3270 *session); /* - * Strip qualifiers from a hostname. - * Returns the hostname part in a newly-malloc'd string. - * 'needed' is returned True if anything was actually stripped. - * Returns NULL if there is a syntax error. - */ /* -static char * -split_host(H3270 *hSession, char *s, char *ansi, char *std_ds, char *passthru, - char *non_e, char *secure, char *no_login, char *xluname, - char **port, char *needed) -{ - char *lbracket = CN; - char *at = CN; - char *r = NULL; - char colon = False; - - *ansi = False; - *std_ds = False; - *passthru = False; - *non_e = False; - *secure = False; - *xluname = '\0'; - *port = CN; - - *needed = False; - - // - // Hostname syntax is: - // Zero or more optional prefixes (A:, S:, P:, N:, L:, C:). - // An optional LU name separated by '@'. - // A hostname optionally in square brackets (which quote any colons - // in the name). - // An optional port name or number separated from the hostname by a - // space or colon. - // No additional white space or colons are allowed. - // - - // Strip leading whitespace. - while (*s && isspace(*s)) - s++; - - if (!*s) - { - popup_an_error(hSession,_( "Empty hostname" )); - goto split_fail; - } - - // Strip trailing whitespace. - while (isspace(*(s + strlen(s) - 1))) - *(s + strlen(s) - 1) = '\0'; - - // Start with the prefixes. - while (*s && *(s + 1) && isalpha(*s) && *(s + 1) == ':') { - switch (*s) { - case 'a': - case 'A': - *ansi = True; - break; - case 's': - case 'S': - *std_ds = True; - break; - case 'p': - case 'P': - *passthru = True; - break; - case 'n': - case 'N': - *non_e = True; - break; -#if defined(HAVE_LIBSSL) - case 'l': - case 'L': - *secure = True; - break; -#else - case 'l': - case 'L': - popup_system_error(hSession, _( "SSL error" ), - _( "Unable to connect to secure hosts" ), - _( "This version of %s was built without support for secure sockets layer (SSL)." ), - PACKAGE_NAME - ); - - goto split_fail; -#endif // HAVE_LIBSSL - case 'c': - case 'C': - *no_login = True; - break; - default: - popup_system_error(hSession, _( "Hostname syntax error" ), - _( "Can't connect to host" ), - _( "Option '%c:' is not supported" ), - *s ); - - goto split_fail; - } - *needed = True; - s += 2; - - // Allow whitespace around the prefixes. - while (*s && isspace(*s)) - s++; - } - - // Process the LU name. - lbracket = strchr(s, '['); - at = strchr(s, '@'); - if (at != CN && lbracket != CN && at > lbracket) - at = CN; - if (at != CN) { - char *t; - char *lu_last = at - 1; - - if (at == s) { - popup_system_error(hSession,NULL,_("Hostname syntax error"),"%s",_("Empty LU name")); - goto split_fail; - } - while (lu_last < s && isspace(*lu_last)) - lu_last--; - for (t = s; t <= lu_last; t++) { - if (isspace(*t)) { - char *u = t + 1; - - while (isspace(*u)) - u++; - if (*u != '@') { - popup_system_error(hSession,NULL,_("Hostname syntax error"),"%s",_("Space in LU name")); - goto split_fail; - } - break; - } - if (t - s < LIB3270_LUNAME_LENGTH) { - xluname[t - s] = *t; - } - } - xluname[t - s] = '\0'; - s = at + 1; - while (*s && isspace(*s)) - s++; - *needed = True; - } - - // - // Isolate the hostname. - // At this point, we've found its start, so we can malloc the buffer - // that will hold the copy. - /// - if (lbracket != CN) { - char *rbracket; - - // Check for junk before the '['. - if (lbracket != s) { - popup_system_error(hSession,NULL,_("Hostname syntax error"),"%s",_("Text before '['")); - goto split_fail; - } - - s = r = NewString(lbracket + 1); - - // - // Take whatever is inside square brackets, including - // whitespace, unmodified -- except for empty strings. - // - rbracket = strchr(s, ']'); - if (rbracket == CN) { - popup_system_error(hSession,NULL,_("Hostname syntax error"),"%s",_("Missing ']'")); - goto split_fail; - } - if (rbracket == s) { - popup_system_error(hSession,NULL,_("Hostname syntax error"),"%s",_("Empty hostname")); - goto split_fail; - } - *rbracket = '\0'; - - // Skip over any whitespace after the bracketed name. - s = rbracket + 1; - while (*s && isspace(*s)) - s++; - if (!*s) - goto split_success; - colon = (*s == ':'); - } else { - char *name_end; - - // Check for an empty string. - if (!*s || *s == ':') { - popup_an_error(hSession,"Empty hostname"); - goto split_fail; - } - - s = r = NewString(s); - - // Find the end of the hostname. - while (*s && !isspace(*s) && *s != ':') - s++; - name_end = s; - - // If the terminator is whitespace, skip the rest of it. - while (*s && isspace(*s)) - s++; - - // - // If there's nothing but whitespace (or nothing) after the - // name, we're done. - // - if (*s == '\0') { - *name_end = '\0'; - goto split_success; - } - colon = (*s == ':'); - *name_end = '\0'; - } - - // - // If 'colon' is set, 's' points at it (or where it was). Skip - // it and any whitespace that follows. - // - if (colon) { - s++; - while (*s && isspace(*s)) - s++; - if (!*s) { - popup_system_error(hSession,NULL,_("Hostname syntax error"),"%s",_("Empty port name")); - goto split_fail; - } - } - - // - // Set the portname and find its end. - // Note that trailing spaces were already stripped, so the end of the - // portname must be a NULL. - // - *port = s; - *needed = True; - while (*s && !isspace(*s) && *s != ':') - s++; - if (*s != '\0') { - popup_system_error(hSession,NULL,_("Hostname syntax error"),"%s",_("Multiple port names")); - goto split_fail; - } - goto split_success; - -split_fail: - lib3270_free(r); - r = CN; - -split_success: - return r; -} -*/ - -/* -int lib3270_connect(H3270 *hSession, int wait) -{ - int rc; - - CHECK_SESSION_HANDLE(hSession); - - lib3270_main_iterate(hSession,0); - - if (CONNECTED || HALF_CONNECTED) - return EBUSY; - - if(!hSession->host.full) - return EINVAL; - - if (hSession->auto_reconnect_inprogress) - return EBUSY; - - if(PCONNECTED) - return EBUSY; - - rc = do_connect(hSession); - if(rc) - return rc; - - if(wait) - { - while(!IN_ANSI && !IN_3270) - { - lib3270_main_iterate(hSession,1); - - if(!PCONNECTED) - { - return ENOTCONN; - } - } - } - - return rc; -} -*/ - -/* * Called from timer to attempt an automatic reconnection. */ static void try_reconnect(H3270 *session) diff --git a/ssl.c b/ssl.c index 9c1f616..7409ab2 100644 --- a/ssl.c +++ b/ssl.c @@ -48,7 +48,9 @@ #include #include "trace_dsc.h" +#if defined(HAVE_LIBSSL) static int ssl_3270_ex_index = -1; /**< Index of h3270 handle in SSL session */ +#endif // HAVE_LIBSSL /*--[ Implement ]------------------------------------------------------------------------------------*/ diff --git a/telnet.c b/telnet.c index 299fd4d..bc3a247 100644 --- a/telnet.c +++ b/telnet.c @@ -141,7 +141,10 @@ static void check_in3270(H3270 *session); static void store3270in(H3270 *hSession, unsigned char c); static void check_linemode(H3270 *hSession, Boolean init); static int net_connected(H3270 *session); + +#if defined(HAVE_LIBSSL) static void continue_tls(H3270 *hSession, unsigned char *sbbuf, int len); +#endif // HAVE_LIBSSL #if defined(X3270_TN3270E) /*[*/ static int tn3270e_negotiate(H3270 *hSession); @@ -924,7 +927,9 @@ LIB3270_INTERNAL void lib3270_sock_disconnect(H3270 *hSession) */ void net_disconnect(H3270 *session) { +#if defined(HAVE_LIBSSL) set_ssl_state(session,LIB3270_SSL_UNSECURE); +#endif // HAVE_LIBSSL session->disconnect(session); @@ -1498,6 +1503,7 @@ static int telnet_fsm(H3270 *hSession, unsigned char c) return 0; } +#if defined(HAVE_LIBSSL) /** * Process a STARTTLS subnegotiation. */ @@ -1520,6 +1526,7 @@ static void continue_tls(H3270 *hSession, unsigned char *sbbuf, int len) trace_dsn(hSession,"%s FOLLOWS %s\n", opt(TELOPT_STARTTLS), cmd(SE)); ssl_negotiate(hSession); } +#endif // HAVE_LIBSSL #if defined(X3270_TN3270E) /*[*/ /* Send a TN3270E terminal type request. */ -- libgit2 0.21.2