unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: master 094eb04: Fix MS-Windows build with mingw.org's MinGW
       [not found] ` <20191126171404.9DBBC20B21@vcs0.savannah.gnu.org>
@ 2019-11-26 18:25   ` Robert Pluim
  2019-11-26 18:50     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Robert Pluim @ 2019-11-26 18:25 UTC (permalink / raw)
  To: emacs-devel; +Cc: Eli Zaretskii

Thanks for that Eli. Since this is expected to work on pre-Vista
versions of Windows, is the equivalent to the following hack needed in
the new network-interface-list:

	    case MIB_IF_TYPE_ETHERNET:
	      /* Windows before Vista reports wireless adapters as
		 Ethernet.  Work around by looking at the Description
		 string.  */
	      if (strstr (adapter->Description, "Wireless "))
		{
		  ifmt_idx = WLAN;
		  if_num = wlan_count++;
		}
	      else
		{
		  ifmt_idx = ETHERNET;
		  if_num = eth_count++;
		}

GetAdaptersAddresses returns wchar_t* for the description field, which
means (I hope), that thereʼs some api for converting it appropriately.

Robert



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: master 094eb04: Fix MS-Windows build with mingw.org's MinGW
  2019-11-26 18:25   ` master 094eb04: Fix MS-Windows build with mingw.org's MinGW Robert Pluim
@ 2019-11-26 18:50     ` Eli Zaretskii
  2019-11-26 19:33       ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2019-11-26 18:50 UTC (permalink / raw)
  To: Robert Pluim; +Cc: emacs-devel

> From: Robert Pluim <rpluim@gmail.com>
> Cc: Eli Zaretskii <eliz@gnu.org>
> Date: Tue, 26 Nov 2019 19:25:54 +0100
> 
> Thanks for that Eli. Since this is expected to work on pre-Vista
> versions of Windows, is the equivalent to the following hack needed in
> the new network-interface-list:
> 
> 	    case MIB_IF_TYPE_ETHERNET:
> 	      /* Windows before Vista reports wireless adapters as
> 		 Ethernet.  Work around by looking at the Description
> 		 string.  */
> 	      if (strstr (adapter->Description, "Wireless "))
> 		{
> 		  ifmt_idx = WLAN;
> 		  if_num = wlan_count++;
> 		}
> 	      else
> 		{
> 		  ifmt_idx = ETHERNET;
> 		  if_num = eth_count++;
> 		}

I guess so.

> GetAdaptersAddresses returns wchar_t* for the description field, which
> means (I hope), that thereʼs some api for converting it appropriately.

We can use wcsstr instead.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: master 094eb04: Fix MS-Windows build with mingw.org's MinGW
  2019-11-26 18:50     ` Eli Zaretskii
@ 2019-11-26 19:33       ` Eli Zaretskii
  2019-11-27 10:57         ` Robert Pluim
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2019-11-26 19:33 UTC (permalink / raw)
  To: rpluim; +Cc: emacs-devel

> Date: Tue, 26 Nov 2019 20:50:48 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> > GetAdaptersAddresses returns wchar_t* for the description field, which
> > means (I hope), that thereʼs some api for converting it appropriately.
> 
> We can use wcsstr instead.

Alternatively, convert to ASCII with pWideCharToMultiByte (see
filename_to_ansi for an example), and then use strstr.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: master 094eb04: Fix MS-Windows build with mingw.org's MinGW
  2019-11-26 19:33       ` Eli Zaretskii
@ 2019-11-27 10:57         ` Robert Pluim
  2019-11-27 15:58           ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Robert Pluim @ 2019-11-27 10:57 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

>>>>> On Tue, 26 Nov 2019 21:33:21 +0200, Eli Zaretskii <eliz@gnu.org> said:

    >> Date: Tue, 26 Nov 2019 20:50:48 +0200
    >> From: Eli Zaretskii <eliz@gnu.org>
    >> Cc: emacs-devel@gnu.org
    >> 
    >> > GetAdaptersAddresses returns wchar_t* for the description field, which
    >> > means (I hope), that thereʼs some api for converting it appropriately.
    >> 
    >> We can use wcsstr instead.

    Eli> Alternatively, convert to ASCII with pWideCharToMultiByte (see
    Eli> filename_to_ansi for an example), and then use strstr.

Does the following work for you? I have neither a wireless card
nor a pre-Vista Windows install.

diff --git a/src/w32.c b/src/w32.c
index cb82d51fb9..c5d9a62925 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -9540,8 +9540,23 @@ network_interface_list (bool full, unsigned short match)
       switch (adapter->IfType)
         {
         case IF_TYPE_ETHERNET_CSMACD:
-          ifmt_idx = ETHERNET;
-          if_num = eth_count++;
+          /* Windows before Vista reports wireless adapters as
+             Ethernet.  Work around by looking at the Description
+             string.  */
+          {
+          char description[MAX_UTF8_PATH];
+          if (filename_from_utf16 (adapter->Description, description) == 0
+              && strstr (description, "Wireless "))
+            {
+              ifmt_idx = WLAN;
+              if_num = wlan_count++;
+            }
+          else
+            {
+              ifmt_idx = ETHERNET;
+              if_num = eth_count++;
+            }
+          }
           break;
         case IF_TYPE_ISO88025_TOKENRING:
           ifmt_idx = TOKENRING;



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: master 094eb04: Fix MS-Windows build with mingw.org's MinGW
  2019-11-27 10:57         ` Robert Pluim
@ 2019-11-27 15:58           ` Eli Zaretskii
  2019-11-28  8:43             ` Robert Pluim
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2019-11-27 15:58 UTC (permalink / raw)
  To: Robert Pluim; +Cc: emacs-devel

> From: Robert Pluim <rpluim@gmail.com>
> Cc: emacs-devel@gnu.org
> Date: Wed, 27 Nov 2019 11:57:05 +0100
> 
> Does the following work for you? I have neither a wireless card
> nor a pre-Vista Windows install.

I also have difficulty finding such a machine.  The code looks fine to
me, though, so I suggest you go ahead and push it, and I will try to
test when I have the opportunity.

Thanks.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: master 094eb04: Fix MS-Windows build with mingw.org's MinGW
  2019-11-27 15:58           ` Eli Zaretskii
@ 2019-11-28  8:43             ` Robert Pluim
  0 siblings, 0 replies; 6+ messages in thread
From: Robert Pluim @ 2019-11-28  8:43 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

>>>>> On Wed, 27 Nov 2019 17:58:38 +0200, Eli Zaretskii <eliz@gnu.org> said:

    >> From: Robert Pluim <rpluim@gmail.com>
    >> Cc: emacs-devel@gnu.org
    >> Date: Wed, 27 Nov 2019 11:57:05 +0100
    >> 
    >> Does the following work for you? I have neither a wireless card
    >> nor a pre-Vista Windows install.

    Eli> I also have difficulty finding such a machine.  The code looks fine to
    Eli> me, though, so I suggest you go ahead and push it, and I will try to
    Eli> test when I have the opportunity.

OK, pushed as b05aa8d742

Thanks

Robert



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-11-28  8:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20191126171403.25928.6996@vcs0.savannah.gnu.org>
     [not found] ` <20191126171404.9DBBC20B21@vcs0.savannah.gnu.org>
2019-11-26 18:25   ` master 094eb04: Fix MS-Windows build with mingw.org's MinGW Robert Pluim
2019-11-26 18:50     ` Eli Zaretskii
2019-11-26 19:33       ` Eli Zaretskii
2019-11-27 10:57         ` Robert Pluim
2019-11-27 15:58           ` Eli Zaretskii
2019-11-28  8:43             ` Robert Pluim

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).