Commit edb3d54527dabd7f2e1d51698f73d5d357201768

Authored by Perry Werneck
1 parent 5e674a1f
Exists in master and in 1 other branch develop

Fixing warnings

@@ -44,6 +44,7 @@ @@ -44,6 +44,7 @@
44 <Unit filename="src/core/tools.cc" /> 44 <Unit filename="src/core/tools.cc" />
45 <Unit filename="src/core/windows/init.cc" /> 45 <Unit filename="src/core/windows/init.cc" />
46 <Unit filename="src/core/windows/resources.rc" /> 46 <Unit filename="src/core/windows/resources.rc" />
  47 + <Unit filename="src/core/windows/tools.cc" />
47 <Unit filename="src/include/config.h" /> 48 <Unit filename="src/include/config.h" />
48 <Unit filename="src/include/lib3270/hllapi.h" /> 49 <Unit filename="src/include/lib3270/hllapi.h" />
49 <Unit filename="src/testprogram/testprogram.cc" /> 50 <Unit filename="src/testprogram/testprogram.cc" />
src/core/hllapi.cc
@@ -114,7 +114,7 @@ HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc @@ -114,7 +114,7 @@ HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc
114 114
115 } 115 }
116 116
117 -static int invalid_request(char *buffer, unsigned short *length, unsigned short *rc) { 117 +static int invalid_request(char GNUC_UNUSED(*buffer), unsigned short GNUC_UNUSED(*length), unsigned short *rc) {
118 *rc = HLLAPI_STATUS_BAD_PARAMETER; 118 *rc = HLLAPI_STATUS_BAD_PARAMETER;
119 return *rc; 119 return *rc;
120 } 120 }
@@ -149,17 +149,17 @@ static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc) @@ -149,17 +149,17 @@ static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc)
149 149
150 } 150 }
151 151
152 -static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc) { 152 +static int disconnect_ps(char GNUC_UNUSED(*buffer), unsigned short GNUC_UNUSED(*length), unsigned short *rc) {
153 *rc = hllapi_deinit(); 153 *rc = hllapi_deinit();
154 return HLLAPI_STATUS_SUCCESS; 154 return HLLAPI_STATUS_SUCCESS;
155 } 155 }
156 156
157 -static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc) { 157 +static int get_library_revision(char GNUC_UNUSED(*buffer), unsigned short GNUC_UNUSED(*length), unsigned short *rc) {
158 *rc = hllapi_get_revision(); 158 *rc = hllapi_get_revision();
159 return HLLAPI_STATUS_SUCCESS; 159 return HLLAPI_STATUS_SUCCESS;
160 } 160 }
161 161
162 -static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) { 162 +static int get_cursor_position(char GNUC_UNUSED(*buffer), unsigned short GNUC_UNUSED(*length), unsigned short *rc) {
163 163
164 try { 164 try {
165 165
@@ -181,7 +181,7 @@ static int get_cursor_position(char *buffer, unsigned short *length, unsigned sh @@ -181,7 +181,7 @@ static int get_cursor_position(char *buffer, unsigned short *length, unsigned sh
181 181
182 } 182 }
183 183
184 -static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc) { 184 +static int set_cursor_position(char GNUC_UNUSED(*buffer), unsigned short GNUC_UNUSED(*length), unsigned short *rc) {
185 185
186 try { 186 try {
187 187
@@ -247,7 +247,7 @@ static int search_ps(char *buffer, unsigned short *length, unsigned short *ps) { @@ -247,7 +247,7 @@ static int search_ps(char *buffer, unsigned short *length, unsigned short *ps) {
247 247
248 size_t pos = string::npos; 248 size_t pos = string::npos;
249 249
250 - if(length > 0) { 250 + if(length) {
251 251
252 pos = getSession().find(string((const char *) buffer,(size_t) length).c_str()); 252 pos = getSession().find(string((const char *) buffer,(size_t) length).c_str());
253 253
@@ -280,7 +280,7 @@ static int search_ps(char *buffer, unsigned short *length, unsigned short *ps) { @@ -280,7 +280,7 @@ static int search_ps(char *buffer, unsigned short *length, unsigned short *ps) {
280 280
281 } 281 }
282 282
283 -static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc) { 283 +static int copy_ps(char *buffer, unsigned short *length, unsigned short GNUC_UNUSED(*rc)) {
284 284
285 // 285 //
286 // Data String Preallocated target string the size of your host presentation space. This can vary depending on how your host presentation space 286 // Data String Preallocated target string the size of your host presentation space. This can vary depending on how your host presentation space
@@ -351,7 +351,7 @@ static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc) { @@ -351,7 +351,7 @@ static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc) {
351 351
352 } 352 }
353 353
354 -static int wait_system(char *buffer, unsigned short *length, unsigned short *rc) { 354 +static int wait_system(char GNUC_UNUSED(*buffer), unsigned short GNUC_UNUSED(*length), unsigned short *rc) {
355 355
356 // 356 //
357 // Checks the status of the host-connected presentation space. If the session is 357 // Checks the status of the host-connected presentation space. If the session is
@@ -372,6 +372,7 @@ static int wait_system(char *buffer, unsigned short *length, unsigned short *rc) @@ -372,6 +372,7 @@ static int wait_system(char *buffer, unsigned short *length, unsigned short *rc)
372 // 372 //
373 373
374 int state = hllapi_wait_for_ready(60); 374 int state = hllapi_wait_for_ready(60);
  375 + *rc = (unsigned short) state;
375 return (state == HLLAPI_STATUS_WAITING ? HLLAPI_STATUS_TIMEOUT : state); 376 return (state == HLLAPI_STATUS_WAITING ? HLLAPI_STATUS_TIMEOUT : state);
376 377
377 } 378 }
@@ -399,12 +400,14 @@ static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps @@ -399,12 +400,14 @@ static int copy_str_to_ps(char *text, unsigned short *length, unsigned short *ps
399 return hllapi_emulate_input(text,*length,0); 400 return hllapi_emulate_input(text,*length,0);
400 } 401 }
401 402
402 -static int reset_system(char *buffer, unsigned short *length, unsigned short *rc) {  
403 - return hllapi_kybdreset(); 403 +static int reset_system(char GNUC_UNUSED(*buffer), unsigned short GNUC_UNUSED(*length), unsigned short *rc) {
  404 + int state = hllapi_kybdreset();
  405 + *rc = (unsigned short) state;
  406 + return state;
404 } 407 }
405 408
406 409
407 -static int pause_system(char *buffer, unsigned short *length, unsigned short *rc) { 410 +static int pause_system(char GNUC_UNUSED(*buffer), unsigned short *length, unsigned short *rc) {
408 411
409 if(!*length) 412 if(!*length)
410 { 413 {
@@ -427,7 +430,10 @@ static int pause_system(char *buffer, unsigned short *length, unsigned short *rc @@ -427,7 +430,10 @@ static int pause_system(char *buffer, unsigned short *length, unsigned short *rc
427 } 430 }
428 431
429 // Pause "flexivel", aguarda mudança no conteúdo da tela!!! 432 // Pause "flexivel", aguarda mudança no conteúdo da tela!!!
430 - return hllapi_wait_for_change((*length) / 2); 433 + int state = hllapi_wait_for_change((*length) / 2);
  434 +
  435 + *rc = (unsigned short) state;
  436 + return state;
431 437
432 } 438 }
433 439
src/core/private.h
@@ -42,6 +42,23 @@ @@ -42,6 +42,23 @@
42 #include <lib3270/log.h> 42 #include <lib3270/log.h>
43 #include <lib3270/hllapi.h> 43 #include <lib3270/hllapi.h>
44 44
  45 + //
  46 + // Compiler-specific #defines.
  47 + //
  48 + // Reference: GLIBC gmacros.h
  49 + //
  50 + #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
  51 +
  52 + #define GNUC_UNUSED \
  53 + __attribute__((__unused__))
  54 +
  55 + #else
  56 +
  57 + #define GNUC_UNUSED
  58 +
  59 + #endif
  60 +
  61 +
45 using std::runtime_error; 62 using std::runtime_error;
46 using std::string; 63 using std::string;
47 using TN3270::Host; 64 using TN3270::Host;
src/core/set.cc
@@ -118,7 +118,7 @@ @@ -118,7 +118,7 @@
118 118
119 } 119 }
120 120
121 - HLLAPI_API_CALL hllapi_emulate_input(const LPSTR text, WORD length, WORD pasting) 121 + HLLAPI_API_CALL hllapi_emulate_input(const LPSTR text, WORD length, WORD GNUC_UNUSED(pasting))
122 { 122 {
123 if(!(text && *text)) 123 if(!(text && *text))
124 return HLLAPI_STATUS_BAD_PARAMETER; 124 return HLLAPI_STATUS_BAD_PARAMETER;
src/core/tools.cc
@@ -32,75 +32,6 @@ @@ -32,75 +32,6 @@
32 32
33 /*--[ Implement ]------------------------------------------------------------------------------------*/ 33 /*--[ Implement ]------------------------------------------------------------------------------------*/
34 34
35 - HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir) {  
36 -  
37 - LSTATUS rc;  
38 - HKEY hKey = 0;  
39 - unsigned long szDatadir = strlen(datadir);  
40 -  
41 - static const char * keys[] = {  
42 -  
43 - "Software\\" LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),  
44 - "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),  
45 -  
46 -#ifdef LIB3270_NAME  
47 - "Software\\" LIB3270_STRINGIZE_VALUE_OF(LIB3270_NAME),  
48 - "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" LIB3270_STRINGIZE_VALUE_OF(LIB3270_NAME),  
49 -#endif  
50 -  
51 - "Software\\pw3270",  
52 - "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\pw3270"  
53 - };  
54 -  
55 - size_t ix;  
56 -  
57 - string installLocation;  
58 -  
59 - *datadir = 0;  
60 -  
61 - for(ix = 0; !*datadir && ix < (sizeof(keys)/sizeof(keys[0])); ix++) {  
62 -  
63 - rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE,keys[ix],0,KEY_QUERY_VALUE,&hKey);  
64 - if(rc == ERROR_SUCCESS) {  
65 -  
66 - unsigned long datatype; // #defined in winnt.h (predefined types 0-11)  
67 - unsigned long datalen = (unsigned long) szDatadir;  
68 -  
69 - memset(datadir,0,datalen);  
70 -  
71 - rc = RegQueryValueExA(hKey,"InstallLocation",NULL,&datatype,(LPBYTE) datadir,&datalen);  
72 - if(rc != ERROR_SUCCESS) {  
73 - *datadir = 0; // Just in case  
74 - }  
75 -  
76 - RegCloseKey(hKey);  
77 -  
78 - }  
79 -  
80 - }  
81 -  
82 -  
83 -  
84 - /*  
85 - #ifdef _WIN32  
86 - HKEY hKey = 0;  
87 - unsigned long datalen = strlen(datadir);  
88 -  
89 - *datadir = 0;  
90 -  
91 - if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\pw3270",0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS)  
92 - {  
93 - unsigned long datatype; // #defined in winnt.h (predefined types 0-11)  
94 - if(RegQueryValueExA(hKey,"datadir",NULL,&datatype,(LPBYTE) datadir,&datalen) != ERROR_SUCCESS)  
95 - *datadir = 0;  
96 - RegCloseKey(hKey);  
97 - }  
98 -#endif // _WIN32  
99 -*/  
100 -  
101 - return *datadir;  
102 - }  
103 -  
104 DWORD hllapi_translate_error(LIB3270_KEYBOARD_LOCK_STATE state) { 35 DWORD hllapi_translate_error(LIB3270_KEYBOARD_LOCK_STATE state) {
105 36
106 // Is unlocked. 37 // Is unlocked.
src/core/windows/init.cc
@@ -70,7 +70,7 @@ @@ -70,7 +70,7 @@
70 static HANDLE hModule = 0; 70 static HANDLE hModule = 0;
71 static HANDLE hEventLog = 0; 71 static HANDLE hEventLog = 0;
72 72
73 - BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwcallpurpose, LPVOID lpvResvd) { 73 + BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwcallpurpose, LPVOID GNUC_UNUSED(lpvResvd)) {
74 switch(dwcallpurpose) { 74 switch(dwcallpurpose) {
75 case DLL_PROCESS_ATTACH: 75 case DLL_PROCESS_ATTACH:
76 hModule = hInstance; 76 hModule = hInstance;
src/core/windows/tools.cc 0 → 100644
@@ -0,0 +1,103 @@ @@ -0,0 +1,103 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
  19 + * Place, Suite 330, Boston, MA, 02111-1307, USA
  20 + *
  21 + * Este programa está nomeado como - e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include "../private.h"
  31 + #include <errno.h>
  32 +
  33 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  34 +
  35 + HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir) {
  36 +
  37 + LSTATUS rc;
  38 + HKEY hKey = 0;
  39 + unsigned long szDatadir = strlen(datadir);
  40 +
  41 + static const char * keys[] = {
  42 +
  43 + "Software\\" LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),
  44 + "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),
  45 +
  46 +#ifdef LIB3270_NAME
  47 + "Software\\" LIB3270_STRINGIZE_VALUE_OF(LIB3270_NAME),
  48 + "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" LIB3270_STRINGIZE_VALUE_OF(LIB3270_NAME),
  49 +#endif
  50 +
  51 + "Software\\pw3270",
  52 + "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\pw3270"
  53 + };
  54 +
  55 + size_t ix;
  56 +
  57 + string installLocation;
  58 +
  59 + *datadir = 0;
  60 +
  61 + for(ix = 0; !*datadir && ix < (sizeof(keys)/sizeof(keys[0])); ix++) {
  62 +
  63 + rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE,keys[ix],0,KEY_QUERY_VALUE,&hKey);
  64 + if(rc == ERROR_SUCCESS) {
  65 +
  66 + unsigned long datatype; // #defined in winnt.h (predefined types 0-11)
  67 + unsigned long datalen = (unsigned long) szDatadir;
  68 +
  69 + memset(datadir,0,datalen);
  70 +
  71 + rc = RegQueryValueExA(hKey,"InstallLocation",NULL,&datatype,(LPBYTE) datadir,&datalen);
  72 + if(rc != ERROR_SUCCESS) {
  73 + *datadir = 0; // Just in case
  74 + }
  75 +
  76 + RegCloseKey(hKey);
  77 +
  78 + }
  79 +
  80 + }
  81 +
  82 +
  83 +
  84 + /*
  85 + #ifdef _WIN32
  86 + HKEY hKey = 0;
  87 + unsigned long datalen = strlen(datadir);
  88 +
  89 + *datadir = 0;
  90 +
  91 + if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\pw3270",0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS)
  92 + {
  93 + unsigned long datatype; // #defined in winnt.h (predefined types 0-11)
  94 + if(RegQueryValueExA(hKey,"datadir",NULL,&datatype,(LPBYTE) datadir,&datalen) != ERROR_SUCCESS)
  95 + *datadir = 0;
  96 + RegCloseKey(hKey);
  97 + }
  98 +#endif // _WIN32
  99 +*/
  100 +
  101 + return *datadir;
  102 + }
  103 +
win/hllapi.nsi
@@ -4,11 +4,11 @@ @@ -4,11 +4,11 @@
4 4
5 Name "hllapi" 5 Name "hllapi"
6 Caption "hllapi - PW3270 HLLAPI Module" 6 Caption "hllapi - PW3270 HLLAPI Module"
7 -outfile "hllapi-5.2.19.9-x86_64.exe" 7 +outfile "hllapi-5.2.19.9-i686.exe"
8 8
9 XPStyle on 9 XPStyle on
10 10
11 -installDir "$PROGRAMFILES64\hllapi" 11 +installDir "$PROGRAMFILES\hllapi"
12 12
13 # Get installation folder from registry if available 13 # Get installation folder from registry if available
14 InstallDirRegKey HKLM "Software\hllapi" "InstallLocation" 14 InstallDirRegKey HKLM "Software\hllapi" "InstallLocation"
@@ -17,10 +17,10 @@ RequestExecutionLevel admin @@ -17,10 +17,10 @@ RequestExecutionLevel admin
17 17
18 # Properties 18 # Properties
19 VIProductVersion "5.2.19.9" 19 VIProductVersion "5.2.19.9"
20 -VIFileVersion "19.9.23.14" 20 +VIFileVersion "19.9.23.15"
21 21
22 VIAddVersionKey "ProductVersion" "5.2.19.9" 22 VIAddVersionKey "ProductVersion" "5.2.19.9"
23 -VIAddVersionKey "FileVersion" "19.9.23.14" 23 +VIAddVersionKey "FileVersion" "19.9.23.15"
24 24
25 VIAddVersionKey "ProductName" "hllapi" 25 VIAddVersionKey "ProductName" "hllapi"
26 VIAddVersionKey "FileDescription" "PW3270 HLLAPI Module" 26 VIAddVersionKey "FileDescription" "PW3270 HLLAPI Module"
@@ -51,7 +51,7 @@ SubSection &quot;hllapi&quot; SecMain @@ -51,7 +51,7 @@ SubSection &quot;hllapi&quot; SecMain
51 51
52 Section "Core" SecCore 52 Section "Core" SecCore
53 53
54 - SetRegView 64 54 + SetRegView 32
55 ${DisableX64FSRedirection} 55 ${DisableX64FSRedirection}
56 56
57 # define the output path for this file 57 # define the output path for this file
@@ -107,7 +107,7 @@ Section &quot;Uninstall&quot; @@ -107,7 +107,7 @@ Section &quot;Uninstall&quot;
107 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\hllapi" 107 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\hllapi"
108 DeleteRegKey HKLM "Software\hllapi" 108 DeleteRegKey HKLM "Software\hllapi"
109 109
110 - SetRegView 64 110 + SetRegView 32
111 DeleteRegKey HKLM "Software\hllapi" 111 DeleteRegKey HKLM "Software\hllapi"
112 112
113 SectionEnd 113 SectionEnd