aboutsummaryrefslogtreecommitdiff
path: root/src/exit
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2013-01-31 09:11:41 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2013-01-31 09:11:41 +0000
commit1ad609fa9008ffde67c0fb2689f71298dbaa0626 (patch)
tree9298e207d03d6df299b42ae78ea58a9e0440b2f8 /src/exit
parent729c3ac4bf294e9f358269197f5d7ff60ea18854 (diff)
downloadgnunet-1ad609fa9008ffde67c0fb2689f71298dbaa0626.tar.gz
gnunet-1ad609fa9008ffde67c0fb2689f71298dbaa0626.zip
some final code-beautification (coding style 4tw!)
removed a few obsolete variables
Diffstat (limited to 'src/exit')
-rw-r--r--src/exit/gnunet-helper-exit-windows.c64
1 files changed, 30 insertions, 34 deletions
diff --git a/src/exit/gnunet-helper-exit-windows.c b/src/exit/gnunet-helper-exit-windows.c
index 4918df15a..38ef66cac 100644
--- a/src/exit/gnunet-helper-exit-windows.c
+++ b/src/exit/gnunet-helper-exit-windows.c
@@ -444,7 +444,7 @@ setup_interface ()
444 /** 444 /**
445 * Bootstrap our device info using the drivers inf-file 445 * Bootstrap our device info using the drivers inf-file
446 */ 446 */
447 if (!SetupDiGetINFClassA (inf_file_path, 447 if ( ! SetupDiGetINFClassA (inf_file_path,
448 &class_guid, 448 &class_guid,
449 class_name, sizeof (class_name) / sizeof (char), 449 class_name, sizeof (class_name) / sizeof (char),
450 NULL)) 450 NULL))
@@ -459,7 +459,7 @@ setup_interface ()
459 return FALSE; 459 return FALSE;
460 460
461 DeviceNode.cbSize = sizeof (SP_DEVINFO_DATA); 461 DeviceNode.cbSize = sizeof (SP_DEVINFO_DATA);
462 if (!SetupDiCreateDeviceInfoA (DeviceInfo, 462 if ( ! SetupDiCreateDeviceInfoA (DeviceInfo,
463 class_name, 463 class_name,
464 &class_guid, 464 &class_guid,
465 NULL, 465 NULL,
@@ -469,7 +469,7 @@ setup_interface ()
469 return FALSE; 469 return FALSE;
470 470
471 /* Deploy all the information collected into the registry */ 471 /* Deploy all the information collected into the registry */
472 if (!SetupDiSetDeviceRegistryPropertyA (DeviceInfo, 472 if ( ! SetupDiSetDeviceRegistryPropertyA (DeviceInfo,
473 &DeviceNode, 473 &DeviceNode,
474 SPDRP_HARDWAREID, 474 SPDRP_HARDWAREID,
475 (LPBYTE) hwidlist, 475 (LPBYTE) hwidlist,
@@ -477,14 +477,14 @@ setup_interface ()
477 return FALSE; 477 return FALSE;
478 478
479 /* Install our new class(=device) into the system */ 479 /* Install our new class(=device) into the system */
480 if (!SetupDiCallClassInstaller (DIF_REGISTERDEVICE, 480 if ( ! SetupDiCallClassInstaller (DIF_REGISTERDEVICE,
481 DeviceInfo, 481 DeviceInfo,
482 &DeviceNode)) 482 &DeviceNode))
483 return FALSE; 483 return FALSE;
484 484
485 /* This system call tends to take a while (several seconds!) on 485 /* This system call tends to take a while (several seconds!) on
486 "modern" Windoze systems */ 486 "modern" Windoze systems */
487 if (!UpdateDriverForPlugAndPlayDevicesA (NULL, 487 if ( ! UpdateDriverForPlugAndPlayDevicesA (NULL,
488 secondary_hwid, 488 secondary_hwid,
489 inf_file_path, 489 inf_file_path,
490 INSTALLFLAG_FORCE | INSTALLFLAG_NONINTERACTIVE, 490 INSTALLFLAG_FORCE | INSTALLFLAG_NONINTERACTIVE,
@@ -518,7 +518,7 @@ remove_interface ()
518 * 1. Prepare our existing device information set, and place the 518 * 1. Prepare our existing device information set, and place the
519 * uninstall related information into the structure 519 * uninstall related information into the structure
520 */ 520 */
521 if (!SetupDiSetClassInstallParamsA (DeviceInfo, 521 if ( ! SetupDiSetClassInstallParamsA (DeviceInfo,
522 (PSP_DEVINFO_DATA) & DeviceNode, 522 (PSP_DEVINFO_DATA) & DeviceNode,
523 &remove.ClassInstallHeader, 523 &remove.ClassInstallHeader,
524 sizeof (remove))) 524 sizeof (remove)))
@@ -526,7 +526,7 @@ remove_interface ()
526 /* 526 /*
527 * 2. Uninstall the virtual interface using the class installer 527 * 2. Uninstall the virtual interface using the class installer
528 */ 528 */
529 if (!SetupDiCallClassInstaller (DIF_REMOVE, 529 if ( ! SetupDiCallClassInstaller (DIF_REMOVE,
530 DeviceInfo, 530 DeviceInfo,
531 (PSP_DEVINFO_DATA) & DeviceNode)) 531 (PSP_DEVINFO_DATA) & DeviceNode))
532 return FALSE; 532 return FALSE;
@@ -623,14 +623,12 @@ resolve_interface_name ()
623 instance_key); 623 instance_key);
624 624
625 /* look inside instance_key\\Connection */ 625 /* look inside instance_key\\Connection */
626 status = RegOpenKeyExA ( 626 if (ERROR_SUCCESS != RegOpenKeyExA (
627 HKEY_LOCAL_MACHINE, 627 HKEY_LOCAL_MACHINE,
628 query_key, 628 query_key,
629 0, 629 0,
630 KEY_READ, 630 KEY_READ,
631 &instance_key_handle); 631 &instance_key_handle))
632
633 if (status != ERROR_SUCCESS)
634 goto cleanup; 632 goto cleanup;
635 633
636 /* now, read our PnpInstanceID */ 634 /* now, read our PnpInstanceID */
@@ -696,7 +694,6 @@ check_tapw32_version (HANDLE handle)
696 DWORD len; 694 DWORD len;
697 memset (&(version), 0, sizeof (version)); 695 memset (&(version), 0, sizeof (version));
698 696
699
700 if (DeviceIoControl (handle, TAP_WIN_IOCTL_GET_VERSION, 697 if (DeviceIoControl (handle, TAP_WIN_IOCTL_GET_VERSION,
701 &version, sizeof (version), 698 &version, sizeof (version),
702 &version, sizeof (version), &len, NULL)) 699 &version, sizeof (version), &len, NULL))
@@ -705,7 +702,8 @@ check_tapw32_version (HANDLE handle)
705 (int) version[1], 702 (int) version[1],
706 (version[2] ? "(DEBUG)" : "")); 703 (version[2] ? "(DEBUG)" : ""));
707 704
708 if (version[0] != TAP_WIN_MIN_MAJOR || version[1] < TAP_WIN_MIN_MINOR){ 705 if ((version[0] != TAP_WIN_MIN_MAJOR) ||
706 (version[1] < TAP_WIN_MIN_MINOR )){
709 fprintf (stderr, "FATAL: This version of gnunet requires a TAP-Windows driver that is at least version %d.%d\n", 707 fprintf (stderr, "FATAL: This version of gnunet requires a TAP-Windows driver that is at least version %d.%d\n",
710 TAP_WIN_MIN_MAJOR, 708 TAP_WIN_MIN_MAJOR,
711 TAP_WIN_MIN_MINOR); 709 TAP_WIN_MIN_MINOR);
@@ -755,7 +753,7 @@ init_tun ()
755 0 753 0
756 ); 754 );
757 755
758 if (handle == INVALID_HANDLE_VALUE) 756 if (INVALID_HANDLE_VALUE == handle)
759 { 757 {
760 fprintf (stderr, "FATAL: CreateFile failed on TAP device: %s\n", device_path); 758 fprintf (stderr, "FATAL: CreateFile failed on TAP device: %s\n", device_path);
761 return handle; 759 return handle;
@@ -799,7 +797,6 @@ tun_up (HANDLE handle)
799 fprintf (stderr, "DEBUG: successfully set TAP device to UP\n"); 797 fprintf (stderr, "DEBUG: successfully set TAP device to UP\n");
800 798
801 return TRUE; 799 return TRUE;
802
803} 800}
804 801
805 802
@@ -834,7 +831,6 @@ attempt_read_tap (struct io_facility * input_facility,
834{ 831{
835 struct GNUNET_MessageHeader * hdr; 832 struct GNUNET_MessageHeader * hdr;
836 unsigned short size; 833 unsigned short size;
837 BOOL status;
838 834
839 switch (input_facility->facility_state) 835 switch (input_facility->facility_state)
840 { 836 {
@@ -844,16 +840,15 @@ attempt_read_tap (struct io_facility * input_facility,
844 { 840 {
845 return FALSE; 841 return FALSE;
846 } 842 }
847 843
848 input_facility->buffer_size = 0; 844 input_facility->buffer_size = 0;
849 status = ReadFile (input_facility->handle,
850 input_facility->buffer,
851 sizeof (input_facility->buffer) - sizeof (struct GNUNET_MessageHeader),
852 &input_facility->buffer_size,
853 &input_facility->overlapped);
854 845
855 /* Check how the task is handled */ 846 /* Check how the task is handled */
856 if (status) 847 if (ReadFile (input_facility->handle,
848 input_facility->buffer,
849 sizeof (input_facility->buffer) - sizeof (struct GNUNET_MessageHeader),
850 &input_facility->buffer_size,
851 &input_facility->overlapped))
857 {/* async event processed immediately*/ 852 {/* async event processed immediately*/
858 853
859 /* reset event manually*/ 854 /* reset event manually*/
@@ -866,7 +861,7 @@ attempt_read_tap (struct io_facility * input_facility,
866 * send it our via STDOUT. Is that possible at the moment? */ 861 * send it our via STDOUT. Is that possible at the moment? */
867 if ((IOSTATE_READY == output_facility->facility_state || 862 if ((IOSTATE_READY == output_facility->facility_state ||
868 IOSTATE_WAITING == output_facility->facility_state) 863 IOSTATE_WAITING == output_facility->facility_state)
869 && 0 < input_facility->buffer_size) 864 && (0 < input_facility->buffer_size))
870 { /* hand over this buffers content and apply message header for gnunet */ 865 { /* hand over this buffers content and apply message header for gnunet */
871 hdr = (struct GNUNET_MessageHeader *) output_facility->buffer; 866 hdr = (struct GNUNET_MessageHeader *) output_facility->buffer;
872 size = input_facility->buffer_size + sizeof (struct GNUNET_MessageHeader); 867 size = input_facility->buffer_size + sizeof (struct GNUNET_MessageHeader);
@@ -909,11 +904,11 @@ attempt_read_tap (struct io_facility * input_facility,
909 case IOSTATE_QUEUED: 904 case IOSTATE_QUEUED:
910 { 905 {
911 // there was an operation going on already, check if that has completed now. 906 // there was an operation going on already, check if that has completed now.
912 status = GetOverlappedResult (input_facility->handle, 907
913 &input_facility->overlapped, 908 if (GetOverlappedResult (input_facility->handle,
914 &input_facility->buffer_size, 909 &input_facility->overlapped,
915 FALSE); 910 &input_facility->buffer_size,
916 if (status) 911 FALSE))
917 {/* successful return for a queued operation */ 912 {/* successful return for a queued operation */
918 if (! ResetEvent (input_facility->overlapped.hEvent)) 913 if (! ResetEvent (input_facility->overlapped.hEvent))
919 return FALSE; 914 return FALSE;
@@ -978,6 +973,7 @@ attempt_read_tap (struct io_facility * input_facility,
978 } 973 }
979} 974}
980 975
976
981/** 977/**
982 * Attempts to read off an input facility (tap or named pipe) in overlapped mode. 978 * Attempts to read off an input facility (tap or named pipe) in overlapped mode.
983 * 979 *
@@ -1095,11 +1091,10 @@ attempt_read_stdin (struct io_facility * input_facility,
1095 case IOSTATE_QUEUED: 1091 case IOSTATE_QUEUED:
1096 { 1092 {
1097 // there was an operation going on already, check if that has completed now. 1093 // there was an operation going on already, check if that has completed now.
1098 status = GetOverlappedResult (input_facility->handle, 1094 if (GetOverlappedResult (input_facility->handle,
1099 &input_facility->overlapped, 1095 &input_facility->overlapped,
1100 &input_facility->buffer_size, 1096 &input_facility->buffer_size,
1101 FALSE); 1097 FALSE))
1102 if (status)
1103 {/* successful return for a queued operation */ 1098 {/* successful return for a queued operation */
1104 hdr = (struct GNUNET_MessageHeader *) input_facility->buffer; 1099 hdr = (struct GNUNET_MessageHeader *) input_facility->buffer;
1105 1100
@@ -1166,6 +1161,7 @@ attempt_read_stdin (struct io_facility * input_facility,
1166 } 1161 }
1167} 1162}
1168 1163
1164
1169/** 1165/**
1170 * Attempts to write to an output facility (tap or named pipe) in overlapped mode. 1166 * Attempts to write to an output facility (tap or named pipe) in overlapped mode.
1171 * 1167 *