fix output for local connections
authorGed Murphy <gedmurphy@reactos.org>
Tue, 20 Dec 2005 20:36:38 +0000 (20:36 +0000)
committerGed Murphy <gedmurphy@reactos.org>
Tue, 20 Dec 2005 20:36:38 +0000 (20:36 +0000)
svn path=/trunk/; revision=20279

reactos/apps/utils/net/netstat/netstat.c
reactos/apps/utils/net/netstat/netstat.h

index 82881c0..1007a0a 100644 (file)
@@ -125,6 +125,9 @@ BOOL ParseCmdline(int argc, char* argv[])
                     case 'a' :
                         bDoShowAllCons = TRUE;
                         break;
                     case 'a' :
                         bDoShowAllCons = TRUE;
                         break;
+                    case 'b' :
+                        bDoShowProcName = TRUE;
+                        break;
                     case 'e' :
                         bDoShowEthStats = TRUE;
                         break;
                     case 'e' :
                         bDoShowEthStats = TRUE;
                         break;
@@ -198,9 +201,9 @@ BOOL DisplayOutput()
 
     if (bDoShowRouteTable)
     {
 
     if (bDoShowRouteTable)
     {
+        /* mingw doesn't have lib for _tsystem */
         if (system("route print") == -1)
         {
         if (system("route print") == -1)
         {
-            //mingw doesn't have lib for _tsystem
             _tprintf(_T("cannot find 'route.exe'\n"));
             return EXIT_FAILURE;
         }
             _tprintf(_T("cannot find 'route.exe'\n"));
             return EXIT_FAILURE;
         }
@@ -574,7 +577,7 @@ GetIpHostName(BOOL Local, UINT IpAddr, CHAR Name[], int NameLen)
         return Name;
     }
 
         return Name;
     }
 
-    Name[0] = L'\0';
+    Name[0] = _T('\0');
 
     // Try to translate to a name
     if (!IpAddr) {
 
     // Try to translate to a name
     if (!IpAddr) {
@@ -585,11 +588,12 @@ GetIpHostName(BOOL Local, UINT IpAddr, CHAR Name[], int NameLen)
                 (nIpAddr >> 8) & 0xFF,
                 (nIpAddr) & 0xFF);
         } else {
                 (nIpAddr >> 8) & 0xFF,
                 (nIpAddr) & 0xFF);
         } else {
-            //gethostname(name, namelen);
+            gethostname(Name, NameLen);
         }
     } else if (IpAddr == 0x0100007f) {
         if (Local) {
         }
     } else if (IpAddr == 0x0100007f) {
         if (Local) {
-            //gethostname(name, namelen);
+            if (gethostname(Name, NameLen) != 0)
+                DoFormatMessage(WSAGetLastError());
         } else {
             strcpy(Name, "localhost");
         }
         } else {
             strcpy(Name, "localhost");
         }
@@ -627,7 +631,6 @@ VOID Usage()
 
 
 
 
 
 
-
 /*
  *
  * Parse command line parameters and set any options
 /*
  *
  * Parse command line parameters and set any options
@@ -636,6 +639,14 @@ VOID Usage()
  */
 int main(int argc, char *argv[])
 {
  */
 int main(int argc, char *argv[])
 {
+    WSADATA wsaData;
+
+    if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
+    {
+        _tprintf(_T("WSAStartup() failed : %d\n"), WSAGetLastError());
+        return -1;
+    }
+
     if (ParseCmdline(argc, argv))
         return -1;
 
     if (ParseCmdline(argc, argv))
         return -1;
 
index 0417aeb..43b4824 100644 (file)
@@ -7,6 +7,7 @@
 /* command line options */
 BOOL bNoOptions        = FALSE; // print default
 BOOL bDoShowAllCons    = FALSE; // -a
 /* command line options */
 BOOL bNoOptions        = FALSE; // print default
 BOOL bDoShowAllCons    = FALSE; // -a
+BOOL bDoShowProcName   = FALSE; // -b
 BOOL bDoShowEthStats   = FALSE; // -e
 BOOL bDoShowNumbers    = FALSE; // -n
 BOOL bDoShowProtoCons  = FALSE; // -p
 BOOL bDoShowEthStats   = FALSE; // -e
 BOOL bDoShowNumbers    = FALSE; // -n
 BOOL bDoShowProtoCons  = FALSE; // -p