Program: gdcm
Module: $RCSfile: gdcmUtil.cxx,v $
Language: C++
- Date: $Date: 2004/12/03 20:43:37 $
- Version: $Revision: 1.68 $
+ Date: $Date: 2005/01/05 15:19:42 $
+ Version: $Revision: 1.71 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include <stdarg.h> //only included in implementation file
#include <stdio.h> //only included in implementation file
-#if defined _MSC_VER
+#if defined(_MSC_VER)
#include <winsock.h> // for gethostname & gethostbyname
#undef GetCurrentTime
#else
const std::string& subStr)
{
int count = 0; // counts how many times it appears
- unsigned int x = 0; // The index position in the string
+ std::string::size_type x = 0; // The index position in the string
do
{
return s1_even == s2_even;
}
+
+
+/**
+ * \ingroup Util
+ * \brief tells us if the processor we are working with is BigEndian or not
+ */
+bool Util::IsCurrentProcessorBigEndian()
+{
+ uint16_t intVal = 1;
+ uint8_t bigEndianRepr[4] = { 0x00, 0x00, 0x00, 0x01 };
+ int res = memcmp(reinterpret_cast<const void*>(&intVal),
+ reinterpret_cast<const void*>(bigEndianRepr), 4);
+ if (res == 0)
+ return true;
+ else
+ return false;
+}
+
+
/**
* \ingroup Util
* \brief Return the IP adress of the machine writting the DICOM image
# define HOST_NAME_MAX 255
// In this case we should maybe check the string was not truncated.
// But I don't known how to check that...
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+ // with WinSock DLL we need to initialise the WinSock before using gethostname
+ WORD wVersionRequested = MAKEWORD(1,0);
+ WSADATA WSAData;
+ int err = WSAStartup(wVersionRequested,&WSAData);
+ if (err != 0) {
+ /* Tell the user that we could not find a usable */
+ /* WinSock DLL. */
+ WSACleanup();
+ return "127.0.0.1";
+ }
+#endif
+
#endif //HOST_NAME_MAX
std::string str;
(unsigned int)((unsigned char*)pHost->h_addr_list[i])[j]);
}
// str now contains one local IP address
+
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+ WSACleanup();
+#endif
+
}
}
// If an error occur r == -1