]> Creatis software - gdcm.git/commitdiff
ENH: update test for tesing MAC adrress
authormalaterre <malaterre>
Thu, 6 Jan 2005 19:10:07 +0000 (19:10 +0000)
committermalaterre <malaterre>
Thu, 6 Jan 2005 19:10:07 +0000 (19:10 +0000)
Testing/TestUtil.cxx
src/gdcmUtil.cxx
src/gdcmUtil.h

index b61aa4cd1ffe911d894455de16c7c66f341e8c27..24c285d540078f46cfa6bd7ce1e88ddb5569440b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestUtil.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/12/07 13:39:32 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2005/01/06 19:10:07 $
+  Version:   $Revision: 1.6 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -43,5 +43,8 @@ int TestUtil(int , char * [])
    if(  gdcm::Util::DicomStringEqual(d,ref) ) 
       return 1;
 
+   // MAC Adress
+   std::cout << "Mac Address:" << gdcm::Util::GetMACAddress() << std::endl;
+
    return 0;
 }
index 589609b0a1850d174de5f56d8ca8e4a1bd762aa4..8c980a3159f2a1b8ef1b445ca2b73d79da358c47 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/06 18:53:02 $
-  Version:   $Revision: 1.73 $
+  Date:      $Date: 2005/01/06 19:10:07 $
+  Version:   $Revision: 1.74 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -639,28 +639,32 @@ long GetMacAddrSys ( u_char *addr)
   return -1;
 }
 
-//std::string Util::GetMACAddress()
-//{
-//   // This is a rip from: http://cplus.kompf.de/macaddr.html for Linux, HPUX and AIX 
-//   // and http://tangentsoft.net/wskfaq/examples/src/snmpmac.cpp for windows version
-//   long stat;
-//   int i;
-//   u_char addr[6];
-// 
-//   stat = mac_addr_sys( addr);
-//   if (0 == stat)
-//   {
-//      printf( "MAC address = ");
-//      for (i=0; i<6; ++i) {
-//           printf("%2.2x", addr[i]);
-//         }
-//         printf( "\n");
-//     }
-//     else {
-//         fprintf( stderr, "can't get MAC address\n");
-//         exit( 1);
-//     }
-//}
+std::string Util::GetMACAddress()
+{
+   // This is a rip from: http://cplus.kompf.de/macaddr.html for Linux, HPUX and AIX 
+   // and http://tangentsoft.net/wskfaq/examples/src/snmpmac.cpp for windows version
+   long stat;
+   u_char addr[6];
+   std::string macaddr;
+   stat = GetMacAddrSys( addr);
+   if (0 == stat)
+   {
+      //printf( "MAC address = ");
+        for (int i=0; i<6; ++i) 
+        {
+            //printf("%2.2x", addr[i]);
+            macaddr += Format("%2.2x", addr[i]);
+        }
+       // printf( "\n");
+      return macaddr;
+   }
+   else
+   {
+      //printf( "No MAC address !\n" );
+      return "";
+   }
+}
 
 /**
  * \ingroup Util
index 85013ce43f7f0cc68831e5923d56b668594d280d..4d44df6023d42bd5ba3b0b1c6cfa114778c44a19 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/05 15:19:42 $
-  Version:   $Revision: 1.46 $
+  Date:      $Date: 2005/01/06 19:10:07 $
+  Version:   $Revision: 1.47 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -57,6 +57,8 @@ public:
    static std::string CreateUniqueUID(const std::string& root = "");
    static bool        IsCurrentProcessorBigEndian();
 
+   static std::string GetMACAddress();
+
 private:
    static std::string GetIPAddress(); //Do not expose this method
 };