Commit 2018072f12417b1570da19351865eaa74ea70bb1
1 parent
05595ed8
Exists in
master
and in
3 other branches
Loading default values for uint props from windows registry.
Showing
5 changed files
with
66 additions
and
7 deletions
Show diff stats
src/core/host.c
... | ... | @@ -326,7 +326,6 @@ LIB3270_EXPORT const char * lib3270_get_default_host(const H3270 GNUC_UNUSED(*hS |
326 | 326 | |
327 | 327 | RegCloseKey(hKey); |
328 | 328 | |
329 | - trace("***************** %d",dwRet); | |
330 | 329 | if(dwRet == ERROR_SUCCESS) |
331 | 330 | { |
332 | 331 | default_host = (char *) realloc(default_host,cbData+1); | ... | ... |
src/core/properties/unsigned.c
... | ... | @@ -147,6 +147,7 @@ static unsigned int lib3270_get_host_type_number(const H3270 *hSession) |
147 | 147 | |
148 | 148 | { |
149 | 149 | .name = "unlock_delay", // Property name. |
150 | + .group = LIB3270_ACTION_GROUP_OFFLINE, // Property group. | |
150 | 151 | #ifdef UNLOCK_MS |
151 | 152 | .default_value = UNLOCK_MS, |
152 | 153 | #else | ... | ... |
src/core/session.c
... | ... | @@ -24,8 +24,6 @@ |
24 | 24 | * |
25 | 25 | * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) |
26 | 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) |
27 | - * licinio@bb.com.br (Licínio Luis Branco) | |
28 | - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
29 | 27 | * |
30 | 28 | */ |
31 | 29 | |
... | ... | @@ -47,7 +45,7 @@ |
47 | 45 | #include "../ssl/crl.h" |
48 | 46 | #include <lib3270/trace.h> |
49 | 47 | #include <lib3270/log.h> |
50 | - | |
48 | +#include <lib3270/properties.h> | |
51 | 49 | |
52 | 50 | /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ |
53 | 51 | |
... | ... | @@ -364,15 +362,62 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char |
364 | 362 | hSession->pointer = (unsigned short) LIB3270_POINTER_LOCKED; |
365 | 363 | |
366 | 364 | #ifdef UNLOCK_MS |
367 | - hSession->unlock_delay_ms = UNLOCK_MS; | |
365 | + lib3270_set_unlock_delay(hSession,UNLOCK_MS); | |
368 | 366 | #else |
369 | - hSession->unlock_delay_ms = 350; | |
367 | + lib3270_set_unlock_delay(hSession,350); | |
370 | 368 | #endif // UNLOCK_MS |
371 | 369 | |
372 | 370 | // CSD |
373 | 371 | for(f=0;f<4;f++) |
374 | 372 | hSession->csd[f] = hSession->saved_csd[f] = LIB3270_ANSI_CSD_US; |
375 | 373 | |
374 | +#ifdef _WIN32 | |
375 | + // Get defaults from registry. | |
376 | + { | |
377 | + HKEY hKey; | |
378 | + DWORD disp = 0; | |
379 | + LSTATUS rc = RegCreateKeyEx( | |
380 | + HKEY_LOCAL_MACHINE, | |
381 | + "Software\\" LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME) "\\protocol", | |
382 | + 0, | |
383 | + NULL, | |
384 | + REG_OPTION_NON_VOLATILE, | |
385 | + KEY_QUERY_VALUE|KEY_READ, | |
386 | + NULL, | |
387 | + &hKey, | |
388 | + &disp); | |
389 | + | |
390 | + if(rc == ERROR_SUCCESS) | |
391 | + { | |
392 | + size_t property; | |
393 | + const LIB3270_UINT_PROPERTY * uiProps = lib3270_get_unsigned_properties_list(); | |
394 | + | |
395 | + for(property = 0; uiProps[property].name;property++) | |
396 | + { | |
397 | + if(!(uiProps[property].set && uiProps[property].group == LIB3270_ACTION_GROUP_OFFLINE)) | |
398 | + continue; | |
399 | + | |
400 | + DWORD val = (DWORD) uiProps[property].default_value; | |
401 | + DWORD cbData = sizeof(DWORD); | |
402 | + DWORD dwRet = RegQueryValueEx(hKey, uiProps[property].name, NULL, NULL, (LPBYTE) &val, &cbData); | |
403 | + | |
404 | + if(dwRet == ERROR_SUCCESS) | |
405 | + { | |
406 | + debug("%s=%u",uiProps[property].name,(unsigned int) val); | |
407 | + uiProps[property].set(hSession,(unsigned int) val); | |
408 | + } | |
409 | + else | |
410 | + { | |
411 | + uiProps[property].set(hSession,uiProps[property].default_value); | |
412 | + } | |
413 | + | |
414 | + } | |
415 | + | |
416 | + RegCloseKey(hKey); | |
417 | + } | |
418 | + } | |
419 | +#endif // _WIN32 | |
420 | + | |
376 | 421 | // Initialize toggles |
377 | 422 | initialize_toggles(hSession); |
378 | 423 | ... | ... |
src/core/windows/registry.c
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 | #include <windows.h> |
37 | 37 | #include <lib3270.h> |
38 | 38 | |
39 | -LSTATUS lib3270_win32_create_regkey(LPCSTR lpSubKey, REGSAM samDesired, PHKEY phkResult) { | |
39 | +LIB3270_EXPORT LSTATUS lib3270_win32_create_regkey(LPCSTR lpSubKey, REGSAM samDesired, PHKEY phkResult) { | |
40 | 40 | |
41 | 41 | LSTATUS rc; |
42 | 42 | DWORD disp; |
... | ... | @@ -55,3 +55,16 @@ LSTATUS lib3270_win32_create_regkey(LPCSTR lpSubKey, REGSAM samDesired, PHKEY ph |
55 | 55 | |
56 | 56 | return rc; |
57 | 57 | } |
58 | + | |
59 | +LIB3270_EXPORT DWORD lib3270_win32_get_dword(HKEY hKey, const char *name, DWORD def) | |
60 | +{ | |
61 | + DWORD val = def; | |
62 | + DWORD cbData = sizeof(DWORD); | |
63 | + | |
64 | + DWORD dwRet = RegQueryValueEx(hKey, name, NULL, NULL, (LPBYTE) &val, &cbData); | |
65 | + | |
66 | + if(dwRet != ERROR_SUCCESS) | |
67 | + return def; | |
68 | + | |
69 | + return val; | |
70 | +} | ... | ... |
src/include/lib3270.h
... | ... | @@ -1561,6 +1561,7 @@ |
1561 | 1561 | LIB3270_EXPORT const char * lib3270_win32_strerror(int e); |
1562 | 1562 | LIB3270_EXPORT const char * lib3270_win32_local_charset(void); |
1563 | 1563 | LIB3270_EXPORT LSTATUS lib3270_win32_create_regkey(LPCSTR lpSubKey, REGSAM samDesired, PHKEY phkResult); |
1564 | + LIB3270_EXPORT DWORD lib3270_win32_get_dword(HKEY hKey, const char *name, DWORD def); | |
1564 | 1565 | |
1565 | 1566 | /** |
1566 | 1567 | * @brief Translate windows error code. | ... | ... |