From 7a04996251ed2f13b8c5d1b5d1c0ec46142150d6 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Thu, 2 Dec 2021 22:03:59 -0300 Subject: [PATCH] Fixing MAC build (#25) --- locale/pt_BR.po | 228 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------ src/core/macos/connect.c | 320 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------- src/core/macos/curl.c | 38 +++++++++++++++++--------------------- src/core/macos/download.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/core/macos/event_dispatcher.c | 6 ++++-- src/core/macos/ldap.c | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/core/macos/log.c | 13 +++++-------- src/core/macos/private.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/core/macos/util.c | 24 ++---------------------- src/core/util.c | 2 ++ src/mkfb/mkfb.c | 1 + 11 files changed, 651 insertions(+), 268 deletions(-) create mode 100644 src/core/macos/download.c create mode 100644 src/core/macos/ldap.c create mode 100644 src/core/macos/private.h diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 3a8e642..c296346 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: pw3270 5.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-09-01 23:49-0300\n" +"POT-Creation-Date: 2021-12-02 21:59-0300\n" "PO-Revision-Date: 2021-09-01 23:53-0300\n" "Last-Translator: Perry Werneck \n" "Language-Team: Português \n" @@ -179,10 +179,6 @@ msgstr "Back space" msgid "Backspaces the cursor until it hits the front of a word" msgstr "Volta o cursor até que atinga o início de uma palavra" -#: src/core/windows/connect.c:123 -msgid "Bad winsock version" -msgstr "Versão winsock inválida" - #: src/core/toggles/table.c:257 msgid "Beep on errors" msgstr "Emitir som nos erros" @@ -227,37 +223,25 @@ msgstr "Arquivo CMS não encontrado, transferência cancelada" msgid "CRL signature failure" msgstr "Erro na assinatura CRL" -#: src/core/toggles/init.c:83 src/core/windows/connect.c:372 +#: src/core/toggles/init.c:83 src/core/macos/connect.c:334 #, c-format msgid "Can't %s network keep-alive" msgstr "Não foi possível %s opção \"keep-alive\"" -#: src/core/windows/ldap.c:149 -msgid "Can't bind to LDAP server" -msgstr "Não foi possível conectar ao servidor LDAP" - -#: src/core/windows/connect.c:232 src/core/windows/connect.c:276 +#: src/core/macos/connect.c:215 src/core/macos/connect.c:269 #, c-format msgid "Can't connect to %s:%s" msgstr "Não foi possível conectar a %s:%s" -#: src/core/windows/http.c:110 -msgid "Can't connect to HTTP server." -msgstr "Não foi possível conectar ao servidor HTTP" - -#: src/core/windows/connect.c:197 +#: src/core/macos/connect.c:165 msgid "Can't connect to host" msgstr "Não foi possível conectar no host" -#: src/core/windows/http.c:121 -msgid "Can't create HTTP request." -msgstr "Não foi possível criar requisição HTTP" - #: src/network_modules/openssl/start.c:71 msgid "Can't decode CRL data" msgstr "Não foi possível decodificar dados do CRL" -#: src/core/windows/ldap.c:204 +#: src/core/macos/ldap.c:167 msgid "Can't decode certificate revocation list" msgstr "Não foi possível decodificar a lista de certificados revogados" @@ -269,42 +253,26 @@ msgstr "Não foi possível determinar o estado TLS/SSL" msgid "Can't get file size" msgstr "Não foi possível obter o tamanho do arquivo" -#: src/core/windows/ldap.c:133 -msgid "Can't initialize LDAP" -msgstr "Erro ao inicializar LDAP" +#: src/core/macos/curl.c:171 +msgid "Can't initialize curl operation" +msgstr "Erro ao inicializar operação CURL" #: src/network_modules/openssl/context.c:164 msgid "Can't initialize the TLS/SSL context." msgstr "Erro ao inicializar contexto TLS/SSL" -#: src/core/session.c:198 +#: src/core/session.c:205 msgid "Can't load" msgstr "Não foi possível carregar" -#: src/core/windows/http.c:99 -msgid "Can't open HTTP session" -msgstr "Não foi possível abrir sessão HTTP" - -#: src/core/session.c:186 +#: src/core/session.c:193 msgid "Can't print" msgstr "Não é possível imprimir" -#: src/core/windows/http.c:173 -msgid "Can't read HTTP response size." -msgstr "Não posso obter tamanho da resposta HTTP" - -#: src/core/session.c:192 +#: src/core/session.c:199 msgid "Can't save" msgstr "Não é possível salvar" -#: src/core/windows/http.c:134 -msgid "Can't send HTTP request." -msgstr "Não posso enviar requisição HTTP" - -#: src/core/windows/ldap.c:141 -msgid "Can't set LDAP protocol version" -msgstr "Não é possível setar a versão do protocolo LDAP" - #: src/network_modules/tools.c:190 msgid "Can't set socket to blocking mode." msgstr "Não foi possível mudar o socket para o modo blocante." @@ -317,10 +285,6 @@ msgstr "Não foi possível setar o socket para o modo não blocante." msgid "Can't start file transfer." msgstr "Não foi possível iniciar transferência de arquivo." -#: src/core/windows/connect.c:124 -msgid "Can't use this system winsock" -msgstr "Não posso usar a winsock do sistema" - #: src/core/ft/ft.c:151 msgid "Cancelled by user" msgstr "Cancelado pelo usuário" @@ -407,8 +371,8 @@ msgstr "Connected initial" msgid "Connecting" msgstr "Conectando" -#: src/core/windows/connect.c:358 src/core/windows/connect.c:376 -#: src/network_modules/tools.c:160 +#: src/core/macos/connect.c:230 src/core/macos/connect.c:321 +#: src/core/macos/connect.c:338 src/network_modules/tools.c:160 msgid "Connection error" msgstr "Erro de conexão" @@ -512,8 +476,8 @@ msgstr "Tipo de dispositivo rejeitado" msgid "Disconnect from host" msgstr "Desconecta do servidor" -#: src/core/ft/ft.c:244 src/network_modules/openssl/main.c:99 -#: src/network_modules/openssl/main.c:147 +#: src/core/ft/ft.c:244 src/network_modules/openssl/main.c:100 +#: src/network_modules/openssl/main.c:148 msgid "Disconnected from host." msgstr "Desconectado do servidor." @@ -537,10 +501,6 @@ msgstr "Dup" msgid "EOR received when not in 3270 mode, ignored." msgstr "EOR recebido fora do modo 3270, ignorado." -#: src/core/windows/http.c:157 -msgid "Empty response from HTTP server." -msgstr "Recebi resposta vazia do servidor HTTP" - #: src/core/toggles/table.c:298 msgid "Enable network in/out trace" msgstr "Habilitar trace de entrada/saída de rede" @@ -593,12 +553,12 @@ msgstr "Apagar campos" msgid "Erro sending data to host" msgstr "Erro ao enviar dados para o servidor" -#: src/core/ft/ft_dft.c:413 src/core/ft/ft_cut.c:408 +#: src/core/ft/ft_cut.c:408 src/core/ft/ft_dft.c:413 #, c-format msgid "Error \"%s\" reading from local file (rc=%d)" msgstr "Erro \"%s\" lendo arquivo local (rc=%d)" -#: src/core/ft/ft_dft.c:306 src/core/ft/ft_cut.c:504 +#: src/core/ft/ft_cut.c:504 src/core/ft/ft_dft.c:306 #, c-format msgid "Error \"%s\" writing to local file (rc=%d)" msgstr "Erro \"%s\" gravando arquivo local (rc=%d)" @@ -611,14 +571,10 @@ msgstr "Erro na transferência do arquivo, transferência cancelada" msgid "Error reading file from host: file transfer canceled" msgstr "Erro ao ler arquivo do host: Transferência cancelada" -#: src/network_modules/openssl/main.c:169 +#: src/network_modules/openssl/main.c:170 msgid "Error reading from host" msgstr "Erro lendo do servidor" -#: src/core/windows/http.c:145 -msgid "Error receiving HTTP response." -msgstr "Erro recebendo resposta HTTP." - #: src/network_modules/tools.c:66 src/network_modules/tools.c:82 msgid "Error receiving data from host" msgstr "Erro recebendo dados do servidor" @@ -631,7 +587,7 @@ msgstr "Erro ao ler ou gravar no host: Transferência cancelada" msgid "Error writing file to host: file transfer canceled" msgstr "Erro ao gravar arquivo no host, transferência cancelada" -#: src/network_modules/openssl/main.c:122 +#: src/network_modules/openssl/main.c:123 msgid "Error writing to host." msgstr "Erro enviando para o servidor" @@ -896,12 +852,14 @@ msgstr "Teclado está bloqueado" msgid "Keyboard lock status" msgstr "Estado de bloqueio do teclado" -#: src/core/windows/ldap.c:179 -msgid "LDAP Search did not produce any attributes." +#: src/core/macos/ldap.c:147 +#, fuzzy +msgid "LDAP search did not produce any attributes." msgstr "Pesquisa LDAP não produziu atributos." -#: src/core/windows/ldap.c:186 -msgid "LDAPSearch did not produce any values." +#: src/core/macos/ldap.c:157 +#, fuzzy +msgid "LDAP search did not produce any values." msgstr "Pesquisa LDAP não produziu valores." #: src/core/properties/signed.c:70 @@ -989,8 +947,8 @@ msgstr "Move para o próximo campo desprotegido" msgid "Move to the previous unprotected field on screen" msgstr "Move para o campo desprotegido anterior" -#: src/core/telnet.c:304 src/core/windows/event_dispatcher.c:135 -#: src/core/windows/connect.c:223 +#: src/core/telnet.c:304 src/core/macos/connect.c:200 +#: src/core/macos/event_dispatcher.c:130 msgid "Network error" msgstr "Erro de rede" @@ -1018,7 +976,7 @@ msgstr "Sem suporte LDAP" msgid "No TLS/SSL support on this session" msgstr "Sem suporte TLS/SSL nessa sessão" -#: src/core/windows/download.c:62 +#: src/core/macos/download.c:55 msgid "No handler for URL scheme." msgstr "Nenhum manipulador para o esquema de URL" @@ -1046,10 +1004,6 @@ msgstr "Diferente de zero se o host é AS400" msgid "Non zero if the host is TSO." msgstr "Diferente de zero se o host é TSO" -#: src/core/windows/connect.c:307 -msgid "Not connected to host" -msgstr "Sem conexão com servidor" - #: src/core/ft/ft.c:626 msgid "Not in 3270 mode, transfer cancelled" msgstr "Não está no modo 3270, transferência cancelada" @@ -1313,7 +1267,7 @@ msgstr "Seleciona a direita" msgid "Select word" msgstr "Seleciona palavra" -#: src/core/windows/event_dispatcher.c:136 +#: src/core/macos/event_dispatcher.c:131 msgid "Select() failed when processing for events." msgstr "Select() falhou ao processar eventos." @@ -1500,13 +1454,18 @@ msgstr "" "A lista de revogação de certificados (CRL) de um certificado não pôde ser " "encontrada." -#: src/network_modules/openssl/main.c:123 -#: src/network_modules/openssl/main.c:170 +#: src/network_modules/openssl/main.c:124 +#: src/network_modules/openssl/main.c:171 #, c-format msgid "The SSL error message was %s" msgstr "A mensagem de erro SSL foi \"%s\"" -#: src/core/windows/ldap.c:101 src/core/windows/ldap.c:110 +#: src/core/macos/connect.c:191 +#, fuzzy, c-format +msgid "The System error was '%s' (rc=%d)" +msgstr "O erro do sistema foi \"%s\" (rc=%d)" + +#: src/core/macos/ldap.c:82 src/core/macos/ldap.c:91 msgid "The URL argument should be in the format ldap://[HOST]/[DN]?attribute" msgstr "A URL deve ser no formato ldap://[HOST]/[DN]?attribute" @@ -1723,8 +1682,8 @@ msgstr "" "O Certificado raiz não está marcado como confiável para os fins " "especificados." -#: src/network_modules/openssl/main.c:101 -#: src/network_modules/openssl/main.c:149 +#: src/network_modules/openssl/main.c:102 +#: src/network_modules/openssl/main.c:150 msgid "The secure connection has been closed cleanly." msgstr "A conexão segura foi fechada corretamente" @@ -1757,24 +1716,12 @@ msgstr "O erro do sistema operacional foi %d" msgid "The system error code was %d (%s)" msgstr "O erro do sistema operacional foi \"%d\" (%s)" -#: src/core/windows/connect.c:239 -#, c-format -msgid "The system error was \"%s\"" -msgstr "O erro do sistema operacional foi \"%s\"" - -#: src/core/windows/connect.c:298 src/core/windows/connect.c:306 -#: src/core/windows/connect.c:314 src/core/windows/connect.c:324 +#: src/core/macos/connect.c:222 src/core/macos/connect.c:282 #, c-format msgid "The system error was \"%s\" (rc=%d)" msgstr "O erro do sistema operacional foi \"%s\" (rc=%d)" -#: src/core/windows/connect.c:225 src/core/windows/connect.c:360 -#: src/core/windows/connect.c:378 -#, c-format -msgid "The system error was %s" -msgstr "O erro do sistema operacional foi \"%s\"" - -#: src/core/util.c:260 +#: src/core/util.c:266 #, c-format msgid "The system error was '%s' (rc=%d)" msgstr "O erro do sistema foi \"%s\" (rc=%d)" @@ -1805,10 +1752,6 @@ msgstr "Este é um erro no programa do host." msgid "Time for auto-reconnect" msgstr "Tempo para reconexão automática" -#: src/core/windows/connect.c:299 -msgid "Timeout conneting to host" -msgstr "Timeout ao conectar com o host" - #: src/core/toggles/table.c:93 src/core/toggles/table.c:94 msgid "Trace Data Stream" msgstr "Trace Data Stream" @@ -1857,8 +1800,8 @@ msgstr "Mostrar posição do cursor" msgid "Transfer cancelled by host" msgstr "Transferência cancelada pelo host" -#: src/core/ft/ft_dft.c:213 src/core/ft/ft_dft.c:344 src/core/ft/ft_cut.c:387 -#: src/core/ft/ft_cut.c:475 +#: src/core/ft/ft_cut.c:387 src/core/ft/ft_cut.c:475 src/core/ft/ft_dft.c:213 +#: src/core/ft/ft_dft.c:344 msgid "Transfer cancelled by user" msgstr "Transferência cancelada pelo usuário" @@ -1874,7 +1817,7 @@ msgstr "Transferência falhou" msgid "Transmission error" msgstr "Erro de transmissão" -#: src/core/windows/connect.c:198 +#: src/core/macos/connect.c:166 msgid "Try again" msgstr "Tentar novamente" @@ -1903,7 +1846,7 @@ msgstr "Incapaz de decifrar a assinatura do certificado" msgid "Unable to get certificate CRL." msgstr "Incapaz de obter o CRL de um certificado." -#: src/core/windows/connect.c:224 +#: src/core/macos/connect.c:201 msgid "Unable to get connection state." msgstr "Não foi possível obter o estado da conexão." @@ -1915,7 +1858,7 @@ msgstr "Não foi possível obter emissor do certificado" msgid "Unable to get local issuer certificate" msgstr "Unable to get local issuer certificate" -#: src/core/session.c:198 +#: src/core/session.c:205 msgid "Unable to load from file" msgstr "Não foi possível ler do arquivo" @@ -1927,11 +1870,11 @@ msgstr "Incapaz de negociar uma conexão segura com o host" msgid "Unable to paste text" msgstr "Incapaz de colar texto" -#: src/core/session.c:186 +#: src/core/session.c:193 msgid "Unable to print" msgstr "Incapaz de imprimir" -#: src/core/session.c:192 +#: src/core/session.c:199 msgid "Unable to save" msgstr "Incapaz de salvar" @@ -2023,10 +1966,6 @@ msgstr "Usar teclas +/- para navegar por campos" msgid "Use the keys +/- from keypad to select editable fields" msgstr "Use the keys +/- from keypad to select editable fields" -#: src/core/windows/connect.c:111 -msgid "WSAStartup failed" -msgstr "WSAStartup falhou" - #: src/core/ft/ft.c:487 msgid "Waiting for GET response" msgstr "Aguardando resposta do pedido de download" @@ -2039,11 +1978,6 @@ msgstr "Aguardando resposta do pedido de upload" msgid "Warning" msgstr "Alerta" -#: src/core/windows/util.c:126 src/core/windows/util.c:169 -#, c-format -msgid "Windows error %d" -msgstr "Erro windows foi %d" - #: src/core/toggles/table.c:103 src/core/toggles/table.c:104 msgid "Wrap around" msgstr "Wrap around" @@ -2131,15 +2065,15 @@ msgstr "_Desconectar" msgid "_Reconnect" msgstr "_Reconectar" -#: src/core/windows/connect.c:340 +#: src/core/macos/connect.c:233 src/core/macos/connect.c:302 msgid "_Retry" msgstr "_Repetir" -#: src/core/toggles/init.c:83 src/core/windows/connect.c:372 +#: src/core/toggles/init.c:83 src/core/macos/connect.c:334 msgid "disable" msgstr "desabilitar" -#: src/core/toggles/init.c:83 src/core/windows/connect.c:372 +#: src/core/toggles/init.c:83 src/core/macos/connect.c:334 msgid "enable" msgstr "habilitar" @@ -2163,7 +2097,7 @@ msgstr "Versão da lib3270" msgid "numeric lock" msgstr "numeric lock" -#: src/core/windows/connect.c:359 +#: src/core/macos/connect.c:322 msgid "setsockopt(SO_OOBINLINE) has failed" msgstr "setsockopt(SO_OOBINLINE) has failed" @@ -2386,6 +2320,9 @@ msgstr "setsockopt(SO_OOBINLINE) has failed" #~ msgid "Background" #~ msgstr "Fundo" +#~ msgid "Bad winsock version" +#~ msgstr "Versão winsock inválida" + #~ msgid "Black" #~ msgstr "Preto" @@ -2428,9 +2365,18 @@ msgstr "setsockopt(SO_OOBINLINE) has failed" #~ msgid "Can't add activity" #~ msgstr "Não é possível adicionar atividade" +#~ msgid "Can't bind to LDAP server" +#~ msgstr "Não foi possível conectar ao servidor LDAP" + +#~ msgid "Can't connect to HTTP server." +#~ msgstr "Não foi possível conectar ao servidor HTTP" + #~ msgid "Can't convert line %lu from %s to %s" #~ msgstr "Não foi possível converter a linha %lu de %s para %s" +#~ msgid "Can't create HTTP request." +#~ msgstr "Não foi possível criar requisição HTTP" + #~ msgid "Can't cut rectangular regions" #~ msgstr "Recortar não permitido em seleção retangular" @@ -2456,8 +2402,8 @@ msgstr "setsockopt(SO_OOBINLINE) has failed" #~ msgid "Can't get screen contents" #~ msgstr "Não foi possível obter o conteúdo da tela" -#~ msgid "Can't initialize curl operation" -#~ msgstr "Erro ao inicializar operação CURL" +#~ msgid "Can't initialize LDAP" +#~ msgstr "Erro ao inicializar LDAP" #~ msgid "Can't load \"%s\": %s" #~ msgstr "Não foi possível carregar \"%s\": %s" @@ -2483,6 +2429,9 @@ msgstr "setsockopt(SO_OOBINLINE) has failed" #~ msgid "Can't open CRL File" #~ msgstr "Não foi possível abrir arquivo CRL" +#~ msgid "Can't open HTTP session" +#~ msgstr "Não foi possível abrir sessão HTTP" + #~ msgid "Can't open file" #~ msgstr "Não foi possível abrir arquivo" @@ -2513,6 +2462,9 @@ msgstr "setsockopt(SO_OOBINLINE) has failed" #~ msgid "Can't read \"%s\": %s" #~ msgstr "Não foi possível ler \"%s\": %s" +#~ msgid "Can't read HTTP response size." +#~ msgstr "Não posso obter tamanho da resposta HTTP" + #~ msgid "Can't recognize \"%s\" as a valid host type" #~ msgstr "Não reconheço \"%s\" como um tipo de host válido" @@ -2549,6 +2501,12 @@ msgstr "setsockopt(SO_OOBINLINE) has failed" #~ msgid "Can't search LDAP server" #~ msgstr "Não foi possível conectar ao servidor LDAP" +#~ msgid "Can't send HTTP request." +#~ msgstr "Não posso enviar requisição HTTP" + +#~ msgid "Can't set LDAP protocol version" +#~ msgstr "Não é possível setar a versão do protocolo LDAP" + #~ msgid "Can't set callback table" #~ msgstr "Não foi possível setar a tabela de retornos" @@ -2567,6 +2525,9 @@ msgstr "setsockopt(SO_OOBINLINE) has failed" #~ msgid "Can't start upload." #~ msgstr "Não foi possível iniciar upload." +#~ msgid "Can't use this system winsock" +#~ msgstr "Não posso usar a winsock do sistema" + #~ msgid "Can't use winsock version %d.%d" #~ msgstr "Não posso usar versão winsock %d.%d" @@ -2763,6 +2724,9 @@ msgstr "setsockopt(SO_OOBINLINE) has failed" #~ msgid "Empty port name" #~ msgstr "Porta em branco" +#~ msgid "Empty response from HTTP server." +#~ msgstr "Recebi resposta vazia do servidor HTTP" + #~ msgid "" #~ "Erase\n" #~ "Input" @@ -2794,6 +2758,9 @@ msgstr "setsockopt(SO_OOBINLINE) has failed" #~ msgid "Error loading CRL" #~ msgstr "Erro lendo CRL" +#~ msgid "Error receiving HTTP response." +#~ msgstr "Erro recebendo resposta HTTP." + #~ msgid "Error resolving %s: %s" #~ msgstr "Erro ao resolver %s: %s" @@ -3121,6 +3088,9 @@ msgstr "setsockopt(SO_OOBINLINE) has failed" #~ msgid "Not available" #~ msgstr "Não disponível" +#~ msgid "Not connected to host" +#~ msgstr "Sem conexão com servidor" + #~ msgid "Not the same terminal type" #~ msgstr "O tipo de terminal é diferente" @@ -3886,6 +3856,14 @@ msgstr "setsockopt(SO_OOBINLINE) has failed" #~ "O certificado de segurança apresentado pelo servidor não foi assinado por " #~ "uma autoridade certificadora confiável." +#, c-format +#~ msgid "The system error was \"%s\"" +#~ msgstr "O erro do sistema operacional foi \"%s\"" + +#, c-format +#~ msgid "The system error was %s" +#~ msgstr "O erro do sistema operacional foi \"%s\"" + #~ msgid "The system error was %s (%d)" #~ msgstr "O erro do sistema operacional foi \"%s\" (%d)" @@ -3932,6 +3910,9 @@ msgstr "setsockopt(SO_OOBINLINE) has failed" #~ msgstr "" #~ "Esta versão do %s foi gerada sem suporte para conexões seguras (SSL)." +#~ msgid "Timeout conneting to host" +#~ msgstr "Timeout ao conectar com o host" + #~ msgid "To" #~ msgstr "Para" @@ -4088,6 +4069,9 @@ msgstr "setsockopt(SO_OOBINLINE) has failed" #~ msgid "WSAEventSelect failed" #~ msgstr "WSAEventSelect falhou" +#~ msgid "WSAStartup failed" +#~ msgstr "WSAStartup falhou" + #~ msgid "WaitForMultipleObjects() failed when processing for events." #~ msgstr "WaitForMultipleObjects() falhou ao processar eventos" @@ -4106,6 +4090,10 @@ msgstr "setsockopt(SO_OOBINLINE) has failed" #~ msgid "Windows Western languages (CP1252)" #~ msgstr "Windows ocidental (CP1252)" +#, c-format +#~ msgid "Windows error %d" +#~ msgstr "Erro windows foi %d" + #~ msgid "Windows error was \"%s\" (%u)" #~ msgstr "Erro windows foi \"%s\" (%u)" diff --git a/src/core/macos/connect.c b/src/core/macos/connect.c index 6f98c8d..df5cc7b 100644 --- a/src/core/macos/connect.c +++ b/src/core/macos/connect.c @@ -39,86 +39,80 @@ #include #include #include -#include #include -#define SOCK_CLOSE(s) close(s->connection.sock); s->connection.sock = -1; - #include #include "hostc.h" #include "trace_dsc.h" #include "telnetc.h" #include "screen.h" +#include "utilc.h" #include #include #include +#include +#include +//#include +#include /*---[ Implement ]-------------------------------------------------------------------------------*/ +static int sock_connect(H3270 *hSession, int sock, const struct sockaddr *address, socklen_t address_len) { -static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG GNUC_UNUSED(flag), void GNUC_UNUSED(*dunno)) { - int err; - socklen_t len = sizeof(err); + lib3270_socket_set_non_blocking(hSession, sock, 1); - if(hSession->xio.write) { - trace("%s write=%p",__FUNCTION__,hSession->xio.write); - lib3270_remove_poll(hSession, hSession->xio.write); - hSession->xio.write = NULL; - } + if(!connect(sock,address,address_len)) + return 0; - if(getsockopt(hSession->connection.sock, SOL_SOCKET, SO_ERROR, (char *) &err, &len) < 0) { - lib3270_disconnect(hSession); - lib3270_popup_dialog( - hSession, - LIB3270_NOTIFY_ERROR, - _( "Network error" ), - _( "Unable to get connection state." ), - _( "%s" ), strerror(errno) - ); - return; - } else if(err) { - char buffer[4096]; + if(errno != EINPROGRESS) + return errno; - snprintf(buffer,4095,_( "Can't connect to %s" ), lib3270_get_url(hSession) ); + unsigned int timer; + for(timer = 0; timer < hSession->connection.timeout; timer += 10) { - lib3270_disconnect(hSession); - lib3270_popup_dialog( - hSession, - LIB3270_NOTIFY_ERROR, - _( "Connection failed" ), - buffer, - _( "%s" ), strerror(err) - ); - return; - } + if(lib3270_get_connection_state(hSession) != LIB3270_CONNECTING) + return errno = ECANCELED; - hSession->xio.except = lib3270_add_poll_fd(hSession,hSession->connection.sock,LIB3270_IO_FLAG_EXCEPTION,net_exception,0); - hSession->xio.read = lib3270_add_poll_fd(hSession,hSession->connection.sock,LIB3270_IO_FLAG_READ,net_input,0); + struct pollfd pfd = { + .fd = sock, + .events = POLLOUT + }; + + switch(poll(&pfd,1,10)) { + case -1: // Poll error + return errno; + + case 0: + break; + + case 1: + // Got response. + if(pfd.revents & POLLOUT) { + debug("%s: Connection complete",__FUNCTION__); + return 0; + } + break; + } -#if defined(HAVE_LIBSSL) - if(hSession->ssl.con && hSession->ssl.state == LIB3270_SSL_UNDEFINED) { - if(ssl_negotiate(hSession)) - return; } -#endif - lib3270_setup_session(hSession); - lib3270_set_connected_initial(hSession); + return errno = ETIMEDOUT; } -struct resolver { - const char * message; -}; -static int background_connect(H3270 *hSession, void *host) { +int lib3270_network_connect(H3270 *hSession, LIB3270_NETWORK_STATE *state) { + + // Reset state + set_ssl_state(hSession,LIB3270_SSL_UNDEFINED); + // + // Resolve hostname + // struct addrinfo hints; struct addrinfo * result = NULL; - struct addrinfo * rp = NULL; - memset(&hints,0,sizeof(hints)); hints.ai_family = AF_UNSPEC; // Allow IPv4 or IPv6 hints.ai_socktype = SOCK_STREAM; // Stream socket @@ -128,74 +122,199 @@ static int background_connect(H3270 *hSession, void *host) { status_resolving(hSession); int rc = getaddrinfo(hSession->host.current, hSession->host.srvc, &hints, &result); - if(rc != 0) { - ((struct resolver *) host)->message = gai_strerror(rc); + if(rc) { + state->error_message = gai_strerror(rc); return -1; } + // + // Try connecting to hosts. + // + int sock = -1; + struct addrinfo * rp = NULL; + status_connecting(hSession); - for(rp = result; hSession->connection.sock < 0 && rp != NULL; rp = rp->ai_next) { - hSession->connection.sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); - if(hSession->connection.sock < 0) { - ((struct resolver *) host)->message = strerror(errno); + for(rp = result; sock < 0 && rp != NULL && state->syserror != ECANCELED; rp = rp->ai_next) { + // Got socket from host definition. + sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); + if(sock < 0) { + // Can't get socket. + state->syserror = errno; continue; } - // Connected! - if(connect(hSession->connection.sock, rp->ai_addr, rp->ai_addrlen)) { - SOCK_CLOSE(hSession); - ((struct resolver *) host)->message = strerror(errno); + // Try connect. + if(sock_connect(hSession, sock, rp->ai_addr, rp->ai_addrlen)) { + // Can't connect to host + state->syserror = errno; + close(sock); + sock = -1; continue; } + lib3270_socket_set_non_blocking(hSession,sock,0); } freeaddrinfo(result); - return 0; + if(sock < 0) { + static const LIB3270_POPUP popup = { + .name = "CantConnect", + .type = LIB3270_NOTIFY_ERROR, + .summary = N_("Can't connect to host"), + .label = N_("Try again") + }; + + state->popup = &popup; + return sock; + } + + // don't share the socket with our children + (void) fcntl(sock, F_SETFD, 1); + return sock; } -int net_reconnect(H3270 *hSession, int seconds) { - struct resolver host; - memset(&host,0,sizeof(host)); +static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG GNUC_UNUSED(flag), void GNUC_UNUSED(*dunno)) { + int err = 0; + socklen_t len = sizeof(err); - // Connect to host - if(lib3270_run_task(hSession, background_connect, &host) || hSession->connection.sock < 0) { - char buffer[4096]; - snprintf(buffer,4095,_( "Can't connect to %s:%s"), hSession->host.current, hSession->host.srvc); + if(hSession->xio.write) { + trace("%s write=%p",__FUNCTION__,hSession->xio.write); + lib3270_remove_poll(hSession, hSession->xio.write); + hSession->xio.write = NULL; + } - lib3270_popup_dialog( hSession, - LIB3270_NOTIFY_ERROR, - _( "Connection error" ), - buffer, - "%s", - host.message); + if(hSession->network.module->getsockopt(hSession, SOL_SOCKET, SO_ERROR, (char *) &err, &len) < 0) { + lib3270_autoptr(char) body = lib3270_strdup_printf( + _("The System error was '%s' (rc=%d)"), + strerror(errno), + errno + ); - lib3270_set_disconnected(hSession); - return errno = ENOTCONN; + lib3270_disconnect(hSession); + + LIB3270_POPUP popup = { + .type = LIB3270_NOTIFY_ERROR, + .title = _( "Network error" ), + .summary = _( "Unable to get connection state." ), + .body = body + }; + + lib3270_popup(hSession,&popup,0); + + return; + + } else if(err) { + + lib3270_disconnect(hSession); + + lib3270_autoptr(char) summary = + lib3270_strdup_printf( + _( "Can't connect to %s:%s"), + hSession->host.current, + hSession->host.srvc + ); + + lib3270_autoptr(char) body = + lib3270_strdup_printf( + _("The system error was \"%s\" (rc=%d)"), + strerror(err), + err + ); + + + LIB3270_POPUP popup = { + .type = LIB3270_NOTIFY_ERROR, + .title = _( "Connection error" ), + .summary = summary, + .body = body, + .label = _("_Retry") + }; + + if(lib3270_popup(hSession,&popup,!hSession->auto_reconnect_inprogress) == 0) + lib3270_activate_auto_reconnect(hSession,1000); + + return; } - /* don't share the socket with our children */ - (void) fcntl(hSession->connection.sock, F_SETFD, 1); + if(lib3270_start_tls(hSession)) { + lib3270_disconnect(hSession); + return; + } - hSession->ever_3270 = False; + hSession->xio.except = hSession->network.module->add_poll(hSession,LIB3270_IO_FLAG_EXCEPTION,net_exception,0); + hSession->xio.read = hSession->network.module->add_poll(hSession,LIB3270_IO_FLAG_READ,net_input,0); + + lib3270_setup_session(hSession); + lib3270_set_connected_initial(hSession); -#if defined(HAVE_LIBSSL) - debug("%s: TLS/SSL is %s",__FUNCTION__,hSession->ssl.enabled ? "ENABLED" : "DISABLED") - trace_dsn(hSession,"TLS/SSL is %s\n", hSession->ssl.enabled ? "enabled" : "disabled" ); - if(hSession->ssl.enabled) { - hSession->ssl.host = 1; - if(ssl_init(hSession)) - return errno = ENOTCONN; + lib3270_notify_tls(hSession); +} + +int net_reconnect(H3270 *hSession, int seconds) { + LIB3270_NETWORK_STATE state; + memset(&state,0,sizeof(state)); + + // Initialize and connect to host + set_ssl_state(hSession,LIB3270_SSL_UNDEFINED); + lib3270_set_cstate(hSession,LIB3270_CONNECTING); + + if(lib3270_run_task(hSession, (int(*)(H3270 *, void *)) hSession->network.module->connect, &state)) { + lib3270_autoptr(LIB3270_POPUP) popup = + lib3270_popup_clone_printf( + NULL, + _( "Can't connect to %s:%s"), + hSession->host.current, + hSession->host.srvc + ); + + if(!popup->summary) { + popup->summary = popup->body; + popup->body = NULL; + } + + lib3270_autoptr(char) syserror = NULL; + if(state.syserror) { + syserror = lib3270_strdup_printf( + _("The system error was \"%s\" (rc=%d)"), + strerror(state.syserror), + state.syserror + ); + } +#ifdef _WIN32 + else if(state.winerror) { +#error TODO + } +#endif // _WIN32 + + if(!popup->body) { + if(state.error_message) + popup->body = state.error_message; + else + popup->body = syserror; + } + + lib3270_disconnect(hSession); // To cleanup states. + + popup->label = _("_Retry"); + if(lib3270_popup(hSession,popup,!hSession->auto_reconnect_inprogress) == 0) + lib3270_activate_auto_reconnect(hSession,1000); + + return errno = ENOTCONN; } -#endif // HAVE_LIBSSL + + + // + // Connected + // + hSession->ever_3270 = False; // set options for inline out-of-band data and keepalives int optval = 1; - if (setsockopt(hSession->connection.sock, SOL_SOCKET, SO_OOBINLINE, (char *)&optval,sizeof(optval)) < 0) { + if(hSession->network.module->setsockopt(hSession, SOL_SOCKET, SO_OOBINLINE, &optval, sizeof(optval)) < 0) { int rc = errno; lib3270_popup_dialog( hSession, LIB3270_NOTIFY_ERROR, @@ -203,12 +322,12 @@ int net_reconnect(H3270 *hSession, int seconds) { _( "setsockopt(SO_OOBINLINE) has failed" ), "%s", strerror(rc)); - SOCK_CLOSE(hSession); + hSession->network.module->disconnect(hSession); return rc; } optval = lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_ALIVE) ? 1 : 0; - if (setsockopt(hSession->connection.sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0) { + if (hSession->network.module->setsockopt(hSession, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) < 0) { int rc = errno; char buffer[4096]; @@ -220,7 +339,8 @@ int net_reconnect(H3270 *hSession, int seconds) { buffer, "%s", strerror(rc)); - SOCK_CLOSE(hSession); + + hSession->network.module->disconnect(hSession); return rc; } else { trace_dsn(hSession,"Network keep-alive is %s\n",optval ? "enabled" : "disabled" ); @@ -242,18 +362,27 @@ int net_reconnect(H3270 *hSession, int seconds) { lib3270_set_cstate(hSession, LIB3270_PENDING); lib3270_st_changed(hSession, LIB3270_STATE_HALF_CONNECT, True); - hSession->xio.write = lib3270_add_poll_fd(hSession,hSession->connection.sock,LIB3270_IO_FLAG_WRITE,net_connected,0); - // hSession->ns_write_id = AddOutput(hSession->sock, hSession, net_connected); + hSession->xio.write = hSession->network.module->add_poll(hSession,LIB3270_IO_FLAG_WRITE,net_connected,0); trace("%s: Connection in progress",__FUNCTION__); if(seconds) { + int rc = lib3270_wait_for_cstate(hSession,LIB3270_CONNECTED_TN3270E,seconds); + if(rc) { + lib3270_disconnect(hSession); + lib3270_write_log(hSession,"connect", "%s: %s",__FUNCTION__,strerror(ETIMEDOUT)); + return errno = rc; + } + + /* time_t end = time(0)+seconds; - while(time(0) < end) { + while(time(0) < end) + { lib3270_main_iterate(hSession,1); - switch(hSession->connection.state) { + switch(hSession->connection.state) + { case LIB3270_PENDING: case LIB3270_CONNECTED_INITIAL: case LIB3270_CONNECTED_ANSI: @@ -261,7 +390,7 @@ int net_reconnect(H3270 *hSession, int seconds) { case LIB3270_CONNECTED_INITIAL_E: case LIB3270_CONNECTED_NVT: case LIB3270_CONNECTED_SSCP: - case LIB3270_RESOLVING: + case LIB3270_CONNECTING: break; case LIB3270_NOT_CONNECTED: @@ -283,6 +412,7 @@ int net_reconnect(H3270 *hSession, int seconds) { lib3270_write_log(hSession,"connect", "%s: %s",__FUNCTION__,strerror(ETIMEDOUT)); return errno = ETIMEDOUT; + */ } return 0; diff --git a/src/core/macos/curl.c b/src/core/macos/curl.c index c3c3074..b644169 100644 --- a/src/core/macos/curl.c +++ b/src/core/macos/curl.c @@ -155,21 +155,20 @@ static int internal_curl_trace_callback(CURL GNUC_UNUSED(*handle), curl_infotype return 0; } -char * lib3270_get_from_url(H3270 *hSession, const char *url, size_t *length, const char **error_message) { +char * lib3270_url_get_using_curl(H3270 *hSession, const char *url, const char **error) { lib3270_write_event_trace(hSession,"Getting data from %s",url); // Use CURL to download the CRL - lib3270_autoptr(CURLDATA) crl_data = lib3270_malloc(sizeof(CURLDATA)); + lib3270_autoptr(CURLDATA) curl_data = lib3270_malloc(sizeof(CURLDATA)); lib3270_autoptr(CURL) hCurl = curl_easy_init(); - memset(crl_data,0,sizeof(CURLDATA)); - crl_data->hSession = hSession; - crl_data->data.length = CRL_DATA_LENGTH; - crl_data->data.contents = lib3270_malloc(crl_data->data.length); + memset(curl_data,0,sizeof(CURLDATA)); + curl_data->hSession = hSession; + curl_data->data.length = CRL_DATA_LENGTH; + curl_data->data.contents = lib3270_malloc(curl_data->data.length); if(!hCurl) { - *error_message= _( "Can't initialize curl operation" ); - errno = EINVAL; + *error = _( "Can't initialize curl operation" ); return NULL; } @@ -178,39 +177,36 @@ char * lib3270_get_from_url(H3270 *hSession, const char *url, size_t *length, co curl_easy_setopt(hCurl, CURLOPT_URL, url); curl_easy_setopt(hCurl, CURLOPT_FOLLOWLOCATION, 1L); - curl_easy_setopt(hCurl, CURLOPT_ERRORBUFFER, crl_data->errbuf); + curl_easy_setopt(hCurl, CURLOPT_ERRORBUFFER, curl_data->errbuf); curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, internal_curl_write_callback); - curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void *) crl_data); + curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void *) curl_data); curl_easy_setopt(hCurl, CURLOPT_USERNAME, ""); if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_SSL_TRACE)) { curl_easy_setopt(hCurl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(hCurl, CURLOPT_DEBUGFUNCTION, internal_curl_trace_callback); - curl_easy_setopt(hCurl, CURLOPT_DEBUGDATA, (void *) crl_data); + curl_easy_setopt(hCurl, CURLOPT_DEBUGDATA, (void *) curl_data); } res = curl_easy_perform(hCurl); if(res != CURLE_OK) { - if(crl_data->errbuf[0]) - lib3270_write_log(hSession,"curl","%s: %s",url, crl_data->errbuf); + if(curl_data->errbuf[0]) + lib3270_write_log(hSession,"curl","%s: %s",url, curl_data->errbuf); - *error_message = curl_easy_strerror(res); + *error = curl_easy_strerror(res); - lib3270_write_log(hSession,"curl","%s: %s",url, *error_message); + lib3270_write_log(hSession,"curl","%s: %s",url, *error); errno = EINVAL; return NULL; } - if(length) - *length = (size_t) crl_data->length; - - char * httpText = lib3270_malloc(crl_data->length+1); - memset(httpText,0,crl_data->length+1); - memcpy(httpText,crl_data->data.contents,crl_data->length); + char * httpText = lib3270_malloc(curl_data->length+1); + memset(httpText,0,curl_data->length+1); + memcpy(httpText,curl_data->data.contents,curl_data->length); return httpText; diff --git a/src/core/macos/download.c b/src/core/macos/download.c new file mode 100644 index 0000000..b431439 --- /dev/null +++ b/src/core/macos/download.c @@ -0,0 +1,63 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como - e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + +#include "private.h" +#include + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + +char * lib3270_url_get(H3270 *hSession, const char *u, const char **error) { + + lib3270_autoptr(char) url = lib3270_unescape(u); + + if(strncasecmp(url,"file://",7) == 0) { + + // Load local file contents. + char *rc = lib3270_file_get_contents(hSession,url+7); + if(!rc) + *error = strerror(errno); + return rc; + } + +#if defined(HAVE_LIBCURL) + + return lib3270_url_get_using_curl(hSession,url,error); + +#else + + // Can't get contents + *error = _("No handler for URL scheme."); + errno = EINVAL; + return NULL; + + +#endif // HAVE_LIBCURL + + +} diff --git a/src/core/macos/event_dispatcher.c b/src/core/macos/event_dispatcher.c index 7622dbc..bd5f3f1 100644 --- a/src/core/macos/event_dispatcher.c +++ b/src/core/macos/event_dispatcher.c @@ -166,11 +166,13 @@ retry: if (t->tv.tv_sec < now.tv_sec ||(t->tv.tv_sec == now.tv_sec && t->tv.tv_usec < now.tv_usec)) { t->in_play = True; - (*t->proc)(hSession); - processed_any = True; + (*t->proc)(hSession,t->userdata); lib3270_linked_list_delete_node(&hSession->timeouts,t); + processed_any = True; + + } else { break; } diff --git a/src/core/macos/ldap.c b/src/core/macos/ldap.c new file mode 100644 index 0000000..74f9d6e --- /dev/null +++ b/src/core/macos/ldap.c @@ -0,0 +1,176 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como - e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + +#include + +#if defined(HAVE_LDAP) && defined(HAVE_LIBSSL) + +#include +#include +#include +#include +#include +#include + +#define LDAP_DEPRECATED 1 +#include + +typedef char LDAPPTR; + +//--[ Implement ]------------------------------------------------------------------------------------ + +static inline void lib3270_autoptr_cleanup_LDAPMessage(LDAPMessage **message) { + debug("%s(%p)",__FUNCTION__,*message); + if(message) + ldap_msgfree(*message); + *message = NULL; +} + +static inline void lib3270_autoptr_cleanup_LDAP(LDAP **ld) { + debug("%s(%p)",__FUNCTION__,*ld); + if(*ld) + ldap_unbind_ext(*ld, NULL, NULL); + *ld = NULL; +} + +static inline void lib3270_autoptr_cleanup_BerElement(BerElement **ber) { + debug("%s(%p)",__FUNCTION__,*ber); + if(*ber) + ber_free(*ber, 0); + *ber = NULL; +} + +static inline void lib3270_autoptr_cleanup_LDAPPTR(char **ptr) { + debug("%s(%p)",__FUNCTION__,*ptr); + if(*ptr) + ldap_memfree(*ptr); + *ptr = NULL; +} + +X509_CRL * lib3270_crl_get_using_ldap(H3270 *hSession, const char *url, const char **error) { + + // Get attributes + char * attrs[] = { NULL, NULL }; + char * base = strchr(url+7,'/'); + if(!base) { + *error = _( "The URL argument should be in the format ldap://[HOST]/[DN]?attribute" ); + errno = EINVAL; + return NULL; + } + + *(base++) = 0; + attrs[0] = strchr(base,'?'); + + if(!base) { + *error = _( "The URL argument should be in the format ldap://[HOST]/[DN]?attribute" ); + errno = EINVAL; + return NULL; + } + + *(attrs[0]++) = 0; + + debug("host: \"%s\"",url); + debug("Base: \"%s\"",base); + debug("Attr: \"%s\"",attrs[0]); + + // Do LDAP Query + lib3270_autoptr(LDAP) ld = NULL; + lib3270_autoptr(BerElement) ber = NULL; + + int rc = ldap_initialize(&ld, url); + if(rc != LDAP_SUCCESS) { + *error = ldap_err2string(rc); + return NULL; + } + + unsigned long version = LDAP_VERSION3; + rc = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION,(void *) &version); + if(rc != LDAP_SUCCESS) { + *error = ldap_err2string(rc); + return NULL; + } + + rc = ldap_simple_bind_s(ld, "", ""); + if(rc != LDAP_SUCCESS) { + *error = ldap_err2string(rc); + return NULL; + } + + lib3270_autoptr(LDAPMessage) results = NULL; + rc = ldap_search_ext_s( + ld, // Specifies the LDAP pointer returned by a previous call to ldap_init(), ldap_ssl_init(), or ldap_open(). + base, // Specifies the DN of the entry at which to start the search. + LDAP_SCOPE_BASE, // Specifies the scope of the search. + NULL, // Specifies a string representation of the filter to apply in the search. + (char **) &attrs, // Specifies a null-terminated array of character string attribute types to return from entries that match filter. + 0, // Should be set to 1 to request attribute types only. Set to 0 to request both attributes types and attribute values. + NULL, + NULL, + NULL, + 0, + &results + ); + + if(rc != LDAP_SUCCESS) { + *error = ldap_err2string(rc); + return NULL; + } + + lib3270_autoptr(LDAPPTR) attr = ldap_first_attribute(ld, results, &ber); + if(!attr) { + *error = _("LDAP search did not produce any attributes."); + errno = ENOENT; + return NULL; + } + + // + // Load CRL + // + struct berval ** value = ldap_get_values_len(ld, results, attr); + if(!value) { + *error =_("LDAP search did not produce any values."); + errno = ENOENT; + return NULL; + } + + X509_CRL * crl = NULL; + + const unsigned char *crl_data = (const unsigned char *) value[0]->bv_val; + + if(!d2i_X509_CRL(&crl, &crl_data, value[0]->bv_len)) { + *error = _( "Can't decode certificate revocation list" ); + } + + ldap_value_free_len(value); + + return crl; + +} + +#endif // HAVE_LDAP diff --git a/src/core/macos/log.c b/src/core/macos/log.c index d83c6d4..636d972 100644 --- a/src/core/macos/log.c +++ b/src/core/macos/log.c @@ -42,22 +42,19 @@ int use_syslog = 0; -void default_log_writer(H3270 GNUC_UNUSED(*session), const char *module, int GNUC_UNUSED(rc), const char *fmt, va_list arg_ptr) { +int default_loghandler(const H3270 GNUC_UNUSED(*session), void GNUC_UNUSED(*userdata), const char *module, int GNUC_UNUSED(rc), const char *message) { #ifdef HAVE_SYSLOG if(use_syslog) { - vsyslog(LOG_INFO, fmt, arg_ptr); + syslog(LOG_INFO, "%s: %s", module, message); } else { - printf("%s:\t",module); - vprintf(fmt,arg_ptr); - printf("\n"); + printf("%s %s\n", module, message); fflush(stdout); } #else - printf("%s:\t",module); - vprintf(fmt,arg_ptr); - printf("\n"); + printf("%s %s\n", module, message); fflush(stdout); #endif + return 0; } LIB3270_EXPORT int lib3270_set_syslog(int flag) { diff --git a/src/core/macos/private.h b/src/core/macos/private.h new file mode 100644 index 0000000..eb7b198 --- /dev/null +++ b/src/core/macos/private.h @@ -0,0 +1,48 @@ +/* + * "Software G3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral ', conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como private.h e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) + * + */ + +#ifndef PRIVATE_H_INCLUDED + +#define PRIVATE_H_INCLUDED + +#include +#include + +#include +#include + +#if defined(HAVE_LIBCURL) +LIB3270_INTERNAL char * lib3270_url_get_using_curl(H3270 *hSession, const char *u, const char **error); +#endif // HAVE_LIBCURL + +#if defined(HAVE_LDAP) +LIB3270_INTERNAL char * lib3270_url_get_using_ldap(H3270 *hSession, const char *u, const char **error); +#endif // HAVE_LDAP + +#endif // !PRIVATE_H_INCLUDED diff --git a/src/core/macos/util.c b/src/core/macos/util.c index 1fd86be..f5fb275 100644 --- a/src/core/macos/util.c +++ b/src/core/macos/util.c @@ -36,10 +36,7 @@ #include #include #include -#include -#include -#include -#include +#include static char * concat(char *path, const char *name, size_t *length) { size_t szCurrent = strlen(path); @@ -77,24 +74,7 @@ char * lib3270_build_data_filename(const char *str, ...) { va_list args; va_start (args, str); - char *filename; - CFBundleRef mainBundle = CFBundleGetMainBundle(); - if (mainBundle) { - CFURLRef url = CFBundleCopyBundleURL(mainBundle); - if (url) { - size_t szPath = PATH_MAX; - char *path = (char *) lib3270_malloc(szPath); - CFURLGetFileSystemRepresentation(url, true, path, szPath); - CFRelease(url); - path = concat(path, "Contents/Resources", &szPath); - filename = build_filename(path, str, args); - lib3270_free(path); - } else { - filename = build_filename(LIB3270_STRINGIZE_VALUE_OF(DATADIR), str, args); - } - } else { - filename = build_filename(LIB3270_STRINGIZE_VALUE_OF(DATADIR), str, args); - } + char *filename = build_filename(LIB3270_STRINGIZE_VALUE_OF(DATADIR), str, args); va_end (args); diff --git a/src/core/util.c b/src/core/util.c index 8ec4b9e..fe393ff 100644 --- a/src/core/util.c +++ b/src/core/util.c @@ -50,6 +50,8 @@ #include #endif // defined +#include + #define my_isspace(c) isspace((unsigned char)c) /// @brief Cheesy internal version of sprintf that allocates its own memory. diff --git a/src/mkfb/mkfb.c b/src/mkfb/mkfb.c index 1c86b5e..5679be2 100644 --- a/src/mkfb/mkfb.c +++ b/src/mkfb/mkfb.c @@ -41,6 +41,7 @@ #define tmpfile w32_tmpfile #elif defined( __APPLE__ ) #define tmpfile osx_tmpfile +#include #endif // OS #include -- libgit2 0.21.2