| @@ -276,6 +276,7 @@ OBJECTS := \ | |||
| $(OBJDIR)/juce_NamedPipe_b3a205e0.o \ | |||
| $(OBJDIR)/juce_TemporaryFile_935f3fc6.o \ | |||
| $(OBJDIR)/juce_ZipFile_16fbb396.o \ | |||
| $(OBJDIR)/juce_MACAddress_b81987ed.o \ | |||
| $(OBJDIR)/juce_Socket_cf39c63b.o \ | |||
| $(OBJDIR)/juce_URL_d6b7cff1.o \ | |||
| $(OBJDIR)/juce_BufferedInputStream_c71b2b68.o \ | |||
| @@ -1548,6 +1549,11 @@ $(OBJDIR)/juce_ZipFile_16fbb396.o: ../../src/io/files/juce_ZipFile.cpp | |||
| @echo "Compiling juce_ZipFile.cpp" | |||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | |||
| $(OBJDIR)/juce_MACAddress_b81987ed.o: ../../src/io/network/juce_MACAddress.cpp | |||
| -@mkdir -p $(OBJDIR) | |||
| @echo "Compiling juce_MACAddress.cpp" | |||
| @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" | |||
| $(OBJDIR)/juce_Socket_cf39c63b.o: ../../src/io/network/juce_Socket.cpp | |||
| -@mkdir -p $(OBJDIR) | |||
| @echo "Compiling juce_Socket.cpp" | |||
| @@ -245,6 +245,7 @@ | |||
| BBCA4C01CEF1EDA75625D6DC = { isa = PBXBuildFile; fileRef = D9B3C04F8EB4228DD59002E7; }; | |||
| 136FB9588C834E6F4A1EEBFB = { isa = PBXBuildFile; fileRef = 17C3AF03FF7AE88AE0C73311; }; | |||
| 274415D1C0AE9BF56FAAE791 = { isa = PBXBuildFile; fileRef = 4035C867821E9B5887AA25FB; }; | |||
| CBAD975785BD26A0DA9417B6 = { isa = PBXBuildFile; fileRef = EFA58F646B69B227AEF14140; }; | |||
| 2A8F78D412AC7EC0C2998A1A = { isa = PBXBuildFile; fileRef = 06B06C420341B005DFF951D2; }; | |||
| 2DD969525DEF4AD408E9BB59 = { isa = PBXBuildFile; fileRef = AD7A1C2C82EE714EBDD52EFC; }; | |||
| 059B694C912BE81023D5240D = { isa = PBXBuildFile; fileRef = D4211E697F43821CDBCE4F24; }; | |||
| @@ -888,6 +889,8 @@ | |||
| 75D6F1C676E178DEA8B86849 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_TemporaryFile.h; path = ../../src/io/files/juce_TemporaryFile.h; sourceTree = SOURCE_ROOT; }; | |||
| 4035C867821E9B5887AA25FB = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ZipFile.cpp; path = ../../src/io/files/juce_ZipFile.cpp; sourceTree = SOURCE_ROOT; }; | |||
| 4D005659935C7DE99C2C01E2 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ZipFile.h; path = ../../src/io/files/juce_ZipFile.h; sourceTree = SOURCE_ROOT; }; | |||
| EFA58F646B69B227AEF14140 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_MACAddress.cpp; path = ../../src/io/network/juce_MACAddress.cpp; sourceTree = SOURCE_ROOT; }; | |||
| 7241B187AA9B0217838B6052 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_MACAddress.h; path = ../../src/io/network/juce_MACAddress.h; sourceTree = SOURCE_ROOT; }; | |||
| 06B06C420341B005DFF951D2 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_Socket.cpp; path = ../../src/io/network/juce_Socket.cpp; sourceTree = SOURCE_ROOT; }; | |||
| 286206E754AC14DEAF88FD43 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_Socket.h; path = ../../src/io/network/juce_Socket.h; sourceTree = SOURCE_ROOT; }; | |||
| AD7A1C2C82EE714EBDD52EFC = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_URL.cpp; path = ../../src/io/network/juce_URL.cpp; sourceTree = SOURCE_ROOT; }; | |||
| @@ -1663,6 +1666,8 @@ | |||
| 4035C867821E9B5887AA25FB, | |||
| 4D005659935C7DE99C2C01E2 ); name = files; sourceTree = "<group>"; }; | |||
| 13FBF71BD76A08C8971C6351 = { isa = PBXGroup; children = ( | |||
| EFA58F646B69B227AEF14140, | |||
| 7241B187AA9B0217838B6052, | |||
| 06B06C420341B005DFF951D2, | |||
| 286206E754AC14DEAF88FD43, | |||
| AD7A1C2C82EE714EBDD52EFC, | |||
| @@ -2165,6 +2170,7 @@ | |||
| BBCA4C01CEF1EDA75625D6DC, | |||
| 136FB9588C834E6F4A1EEBFB, | |||
| 274415D1C0AE9BF56FAAE791, | |||
| CBAD975785BD26A0DA9417B6, | |||
| 2A8F78D412AC7EC0C2998A1A, | |||
| 2DD969525DEF4AD408E9BB59, | |||
| 059B694C912BE81023D5240D, | |||
| @@ -807,6 +807,8 @@ | |||
| <File RelativePath="..\..\src\io\files\juce_ZipFile.h"/> | |||
| </Filter> | |||
| <Filter Name="network"> | |||
| <File RelativePath="..\..\src\io\network\juce_MACAddress.cpp"/> | |||
| <File RelativePath="..\..\src\io\network\juce_MACAddress.h"/> | |||
| <File RelativePath="..\..\src\io\network\juce_Socket.cpp"/> | |||
| <File RelativePath="..\..\src\io\network\juce_Socket.h"/> | |||
| <File RelativePath="..\..\src\io\network\juce_URL.cpp"/> | |||
| @@ -807,6 +807,8 @@ | |||
| <File RelativePath="..\..\src\io\files\juce_ZipFile.h"/> | |||
| </Filter> | |||
| <Filter Name="network"> | |||
| <File RelativePath="..\..\src\io\network\juce_MACAddress.cpp"/> | |||
| <File RelativePath="..\..\src\io\network\juce_MACAddress.h"/> | |||
| <File RelativePath="..\..\src\io\network\juce_Socket.cpp"/> | |||
| <File RelativePath="..\..\src\io\network\juce_Socket.h"/> | |||
| <File RelativePath="..\..\src\io\network\juce_URL.cpp"/> | |||
| @@ -809,6 +809,8 @@ | |||
| <File RelativePath="..\..\src\io\files\juce_ZipFile.h"/> | |||
| </Filter> | |||
| <Filter Name="network"> | |||
| <File RelativePath="..\..\src\io\network\juce_MACAddress.cpp"/> | |||
| <File RelativePath="..\..\src\io\network\juce_MACAddress.h"/> | |||
| <File RelativePath="..\..\src\io\network\juce_Socket.cpp"/> | |||
| <File RelativePath="..\..\src\io\network\juce_Socket.h"/> | |||
| <File RelativePath="..\..\src\io\network\juce_URL.cpp"/> | |||
| @@ -359,6 +359,7 @@ | |||
| <ClCompile Include="..\..\src\io\files\juce_NamedPipe.cpp"/> | |||
| <ClCompile Include="..\..\src\io\files\juce_TemporaryFile.cpp"/> | |||
| <ClCompile Include="..\..\src\io\files\juce_ZipFile.cpp"/> | |||
| <ClCompile Include="..\..\src\io\network\juce_MACAddress.cpp"/> | |||
| <ClCompile Include="..\..\src\io\network\juce_Socket.cpp"/> | |||
| <ClCompile Include="..\..\src\io\network\juce_URL.cpp"/> | |||
| <ClCompile Include="..\..\src\io\streams\juce_BufferedInputStream.cpp"/> | |||
| @@ -727,6 +728,7 @@ | |||
| <ClInclude Include="..\..\src\io\files\juce_NamedPipe.h"/> | |||
| <ClInclude Include="..\..\src\io\files\juce_TemporaryFile.h"/> | |||
| <ClInclude Include="..\..\src\io\files\juce_ZipFile.h"/> | |||
| <ClInclude Include="..\..\src\io\network\juce_MACAddress.h"/> | |||
| <ClInclude Include="..\..\src\io\network\juce_Socket.h"/> | |||
| <ClInclude Include="..\..\src\io\network\juce_URL.h"/> | |||
| <ClInclude Include="..\..\src\io\streams\juce_BufferedInputStream.h"/> | |||
| @@ -925,6 +925,9 @@ | |||
| <ClCompile Include="..\..\src\io\files\juce_ZipFile.cpp"> | |||
| <Filter>Juce\Source\io\files</Filter> | |||
| </ClCompile> | |||
| <ClCompile Include="..\..\src\io\network\juce_MACAddress.cpp"> | |||
| <Filter>Juce\Source\io\network</Filter> | |||
| </ClCompile> | |||
| <ClCompile Include="..\..\src\io\network\juce_Socket.cpp"> | |||
| <Filter>Juce\Source\io\network</Filter> | |||
| </ClCompile> | |||
| @@ -2103,6 +2106,9 @@ | |||
| <ClInclude Include="..\..\src\io\files\juce_ZipFile.h"> | |||
| <Filter>Juce\Source\io\files</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="..\..\src\io\network\juce_MACAddress.h"> | |||
| <Filter>Juce\Source\io\network</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="..\..\src\io\network\juce_Socket.h"> | |||
| <Filter>Juce\Source\io\network</Filter> | |||
| </ClInclude> | |||
| @@ -245,6 +245,7 @@ | |||
| BBCA4C01CEF1EDA75625D6DC = { isa = PBXBuildFile; fileRef = D9B3C04F8EB4228DD59002E7; }; | |||
| 136FB9588C834E6F4A1EEBFB = { isa = PBXBuildFile; fileRef = 17C3AF03FF7AE88AE0C73311; }; | |||
| 274415D1C0AE9BF56FAAE791 = { isa = PBXBuildFile; fileRef = 4035C867821E9B5887AA25FB; }; | |||
| CBAD975785BD26A0DA9417B6 = { isa = PBXBuildFile; fileRef = EFA58F646B69B227AEF14140; }; | |||
| 2A8F78D412AC7EC0C2998A1A = { isa = PBXBuildFile; fileRef = 06B06C420341B005DFF951D2; }; | |||
| 2DD969525DEF4AD408E9BB59 = { isa = PBXBuildFile; fileRef = AD7A1C2C82EE714EBDD52EFC; }; | |||
| 059B694C912BE81023D5240D = { isa = PBXBuildFile; fileRef = D4211E697F43821CDBCE4F24; }; | |||
| @@ -888,6 +889,8 @@ | |||
| 75D6F1C676E178DEA8B86849 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_TemporaryFile.h; path = ../../src/io/files/juce_TemporaryFile.h; sourceTree = SOURCE_ROOT; }; | |||
| 4035C867821E9B5887AA25FB = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ZipFile.cpp; path = ../../src/io/files/juce_ZipFile.cpp; sourceTree = SOURCE_ROOT; }; | |||
| 4D005659935C7DE99C2C01E2 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ZipFile.h; path = ../../src/io/files/juce_ZipFile.h; sourceTree = SOURCE_ROOT; }; | |||
| EFA58F646B69B227AEF14140 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_MACAddress.cpp; path = ../../src/io/network/juce_MACAddress.cpp; sourceTree = SOURCE_ROOT; }; | |||
| 7241B187AA9B0217838B6052 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_MACAddress.h; path = ../../src/io/network/juce_MACAddress.h; sourceTree = SOURCE_ROOT; }; | |||
| 06B06C420341B005DFF951D2 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_Socket.cpp; path = ../../src/io/network/juce_Socket.cpp; sourceTree = SOURCE_ROOT; }; | |||
| 286206E754AC14DEAF88FD43 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_Socket.h; path = ../../src/io/network/juce_Socket.h; sourceTree = SOURCE_ROOT; }; | |||
| AD7A1C2C82EE714EBDD52EFC = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_URL.cpp; path = ../../src/io/network/juce_URL.cpp; sourceTree = SOURCE_ROOT; }; | |||
| @@ -1663,6 +1666,8 @@ | |||
| 4035C867821E9B5887AA25FB, | |||
| 4D005659935C7DE99C2C01E2 ); name = files; sourceTree = "<group>"; }; | |||
| 13FBF71BD76A08C8971C6351 = { isa = PBXGroup; children = ( | |||
| EFA58F646B69B227AEF14140, | |||
| 7241B187AA9B0217838B6052, | |||
| 06B06C420341B005DFF951D2, | |||
| 286206E754AC14DEAF88FD43, | |||
| AD7A1C2C82EE714EBDD52EFC, | |||
| @@ -2165,6 +2170,7 @@ | |||
| BBCA4C01CEF1EDA75625D6DC, | |||
| 136FB9588C834E6F4A1EEBFB, | |||
| 274415D1C0AE9BF56FAAE791, | |||
| CBAD975785BD26A0DA9417B6, | |||
| 2A8F78D412AC7EC0C2998A1A, | |||
| 2DD969525DEF4AD408E9BB59, | |||
| 059B694C912BE81023D5240D, | |||
| @@ -1201,6 +1201,10 @@ | |||
| file="src/io/files/juce_ZipFile.h"/> | |||
| </GROUP> | |||
| <GROUP id="bOzVjzYUR" name="network"> | |||
| <FILE id="vyRckg9" name="juce_MACAddress.cpp" compile="1" resource="0" | |||
| file="src/io/network/juce_MACAddress.cpp"/> | |||
| <FILE id="WzxXWpV" name="juce_MACAddress.h" compile="0" resource="0" | |||
| file="src/io/network/juce_MACAddress.h"/> | |||
| <FILE id="HAyAhTsrK" name="juce_Socket.cpp" compile="1" resource="0" | |||
| file="src/io/network/juce_Socket.cpp"/> | |||
| <FILE id="HBCQxvfwV" name="juce_Socket.h" compile="0" resource="0" | |||
| @@ -127,6 +127,7 @@ | |||
| #include "../src/io/files/juce_TemporaryFile.cpp" | |||
| #include "../src/io/network/juce_Socket.cpp" | |||
| #include "../src/io/network/juce_URL.cpp" | |||
| #include "../src/io/network/juce_MACAddress.cpp" | |||
| #include "../src/io/streams/juce_BufferedInputStream.cpp" | |||
| #include "../src/io/streams/juce_FileInputSource.cpp" | |||
| #include "../src/io/streams/juce_MemoryInputStream.cpp" | |||
| @@ -120,7 +120,7 @@ private: | |||
| << "\nCPU has SSE2: " << (SystemStats::hasSSE2() ? "yes" : "no") | |||
| << "\nCPU has 3DNOW: " << (SystemStats::has3DNow() ? "yes" : "no") | |||
| << "\nMemory size: " << SystemStats::getMemorySizeInMegabytes() << "MB" | |||
| << "\nFound network card MAC addresses: " << SystemStats::getMACAddressStrings().joinIntoString (", ") | |||
| << "\nFound network card MAC addresses: " << getMacAddressList() | |||
| << "\nCurrent executable file: " << File::getSpecialLocation (File::currentExecutableFile).getFullPathName() | |||
| << "\nCurrent application file: " << File::getSpecialLocation (File::currentApplicationFile).getFullPathName() | |||
| << "\nCurrent working directory: " << File::getCurrentWorkingDirectory().getFullPathName() | |||
| @@ -133,6 +133,18 @@ private: | |||
| return systemInfo; | |||
| } | |||
| static const String getMacAddressList() | |||
| { | |||
| Array <MACAddress> macAddresses; | |||
| MACAddress::findAllAddresses (macAddresses); | |||
| StringArray addressStrings; | |||
| for (int i = 0; i < macAddresses.size(); ++i) | |||
| addressStrings.add (macAddresses[i].toString()); | |||
| return addressStrings.joinIntoString (", "); | |||
| } | |||
| }; | |||
| @@ -1682,26 +1682,6 @@ const String SystemStats::getJUCEVersion() | |||
| + "." + String (JUCE_BUILDNUMBER); | |||
| } | |||
| const StringArray SystemStats::getMACAddressStrings() | |||
| { | |||
| int64 macAddresses [16]; | |||
| const int numAddresses = getMACAddresses (macAddresses, numElementsInArray (macAddresses), false); | |||
| StringArray s; | |||
| for (int i = 0; i < numAddresses; ++i) | |||
| { | |||
| s.add (String::toHexString (0xff & (int) (macAddresses [i] >> 40)).paddedLeft ('0', 2) | |||
| + "-" + String::toHexString (0xff & (int) (macAddresses [i] >> 32)).paddedLeft ('0', 2) | |||
| + "-" + String::toHexString (0xff & (int) (macAddresses [i] >> 24)).paddedLeft ('0', 2) | |||
| + "-" + String::toHexString (0xff & (int) (macAddresses [i] >> 16)).paddedLeft ('0', 2) | |||
| + "-" + String::toHexString (0xff & (int) (macAddresses [i] >> 8)).paddedLeft ('0', 2) | |||
| + "-" + String::toHexString (0xff & (int) (macAddresses [i] >> 0)).paddedLeft ('0', 2)); | |||
| } | |||
| return s; | |||
| } | |||
| #ifdef JUCE_DLL | |||
| void* juce_Malloc (const int size) | |||
| @@ -9738,6 +9718,66 @@ END_JUCE_NAMESPACE | |||
| /*** End of inlined file: juce_URL.cpp ***/ | |||
| /*** Start of inlined file: juce_MACAddress.cpp ***/ | |||
| BEGIN_JUCE_NAMESPACE | |||
| MACAddress::MACAddress() | |||
| : asInt64 (0) | |||
| { | |||
| } | |||
| MACAddress::MACAddress (const MACAddress& other) | |||
| : asInt64 (other.asInt64) | |||
| { | |||
| } | |||
| MACAddress& MACAddress::operator= (const MACAddress& other) | |||
| { | |||
| asInt64 = other.asInt64; | |||
| return *this; | |||
| } | |||
| MACAddress::MACAddress (const uint8 bytes[6]) | |||
| : asInt64 (0) | |||
| { | |||
| memcpy (asBytes, bytes, sizeof (asBytes)); | |||
| } | |||
| const String MACAddress::toString() const | |||
| { | |||
| String s; | |||
| s.preallocateStorage (18); | |||
| for (int i = 0; i < numElementsInArray (asBytes); ++i) | |||
| { | |||
| s << String::toHexString ((int) asBytes[i]).paddedLeft ('0', 2); | |||
| if (i < numElementsInArray (asBytes) - 1) | |||
| s << '-'; | |||
| } | |||
| return s; | |||
| } | |||
| int64 MACAddress::toInt64() const throw() | |||
| { | |||
| int64 n = 0; | |||
| for (int i = numElementsInArray (asBytes); --i >= 0;) | |||
| n = (n << 8) | asBytes[i]; | |||
| return n; | |||
| } | |||
| bool MACAddress::isNull() const throw() { return asInt64 == 0; } | |||
| bool MACAddress::operator== (const MACAddress& other) const throw() { return asInt64 == other.asInt64; } | |||
| bool MACAddress::operator!= (const MACAddress& other) const throw() { return asInt64 != other.asInt64; } | |||
| END_JUCE_NAMESPACE | |||
| /*** End of inlined file: juce_MACAddress.cpp ***/ | |||
| /*** Start of inlined file: juce_BufferedInputStream.cpp ***/ | |||
| BEGIN_JUCE_NAMESPACE | |||
| @@ -10335,7 +10375,12 @@ Uuid::Uuid() | |||
| if (! hasCheckedMacAddresses) | |||
| { | |||
| hasCheckedMacAddresses = true; | |||
| SystemStats::getMACAddresses (macAddresses, 2); | |||
| Array<MACAddress> result; | |||
| MACAddress::findAllAddresses (result); | |||
| for (int i = 0; i < numElementsInArray (macAddresses); ++i) | |||
| macAddresses[i] = result[i].toInt64(); | |||
| } | |||
| value.asInt64[0] = macAddresses[0]; | |||
| @@ -239855,121 +239900,91 @@ void juce_closeInternetFile (void* handle) | |||
| } | |||
| } | |||
| static int getMACAddressViaGetAdaptersInfo (int64* addresses, int maxNum, const bool littleEndian) throw() | |||
| namespace MACAddressHelpers | |||
| { | |||
| int numFound = 0; | |||
| DynamicLibraryLoader dll ("iphlpapi.dll"); | |||
| DynamicLibraryImport (GetAdaptersInfo, getAdaptersInfo, DWORD, dll, (PIP_ADAPTER_INFO, PULONG)) | |||
| if (getAdaptersInfo != 0) | |||
| void getViaGetAdaptersInfo (Array<MACAddress>& result) | |||
| { | |||
| ULONG len = sizeof (IP_ADAPTER_INFO); | |||
| MemoryBlock mb; | |||
| PIP_ADAPTER_INFO adapterInfo = (PIP_ADAPTER_INFO) mb.getData(); | |||
| if (getAdaptersInfo (adapterInfo, &len) == ERROR_BUFFER_OVERFLOW) | |||
| { | |||
| mb.setSize (len); | |||
| adapterInfo = (PIP_ADAPTER_INFO) mb.getData(); | |||
| } | |||
| DynamicLibraryLoader dll ("iphlpapi.dll"); | |||
| DynamicLibraryImport (GetAdaptersInfo, getAdaptersInfo, DWORD, dll, (PIP_ADAPTER_INFO, PULONG)) | |||
| if (getAdaptersInfo (adapterInfo, &len) == NO_ERROR) | |||
| if (getAdaptersInfo != 0) | |||
| { | |||
| PIP_ADAPTER_INFO adapter = adapterInfo; | |||
| ULONG len = sizeof (IP_ADAPTER_INFO); | |||
| MemoryBlock mb; | |||
| PIP_ADAPTER_INFO adapterInfo = (PIP_ADAPTER_INFO) mb.getData(); | |||
| while (adapter != 0) | |||
| if (getAdaptersInfo (adapterInfo, &len) == ERROR_BUFFER_OVERFLOW) | |||
| { | |||
| int64 mac = 0; | |||
| for (unsigned int i = 0; i < adapter->AddressLength; ++i) | |||
| mac = (mac << 8) | adapter->Address[i]; | |||
| if (littleEndian) | |||
| mac = (int64) ByteOrder::swap ((uint64) mac); | |||
| if (numFound < maxNum && mac != 0) | |||
| addresses [numFound++] = mac; | |||
| mb.setSize (len); | |||
| adapterInfo = (PIP_ADAPTER_INFO) mb.getData(); | |||
| } | |||
| adapter = adapter->Next; | |||
| if (getAdaptersInfo (adapterInfo, &len) == NO_ERROR) | |||
| { | |||
| for (PIP_ADAPTER_INFO adapter = adapterInfo; adapter != 0; adapter = adapter->Next) | |||
| { | |||
| if (adapter->AddressLength >= 6) | |||
| result.addIfNotAlreadyThere (MACAddress (adapter->Address)); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return numFound; | |||
| } | |||
| static int getMACAddressesViaNetBios (int64* addresses, int maxNum, const bool littleEndian) throw() | |||
| { | |||
| int numFound = 0; | |||
| DynamicLibraryLoader dll ("netapi32.dll"); | |||
| DynamicLibraryImport (Netbios, NetbiosCall, UCHAR, dll, (PNCB)) | |||
| if (NetbiosCall != 0) | |||
| void getViaNetBios (Array<MACAddress>& result) | |||
| { | |||
| NCB ncb; | |||
| zerostruct (ncb); | |||
| DynamicLibraryLoader dll ("netapi32.dll"); | |||
| DynamicLibraryImport (Netbios, NetbiosCall, UCHAR, dll, (PNCB)) | |||
| struct ASTAT | |||
| if (NetbiosCall != 0) | |||
| { | |||
| ADAPTER_STATUS adapt; | |||
| NAME_BUFFER NameBuff [30]; | |||
| }; | |||
| NCB ncb; | |||
| zerostruct (ncb); | |||
| ASTAT astat; | |||
| zeromem (&astat, sizeof (astat)); // (can't use zerostruct here in VC6) | |||
| struct ASTAT | |||
| { | |||
| ADAPTER_STATUS adapt; | |||
| NAME_BUFFER NameBuff [30]; | |||
| }; | |||
| LANA_ENUM enums; | |||
| zerostruct (enums); | |||
| ASTAT astat; | |||
| zeromem (&astat, sizeof (astat)); // (can't use zerostruct here in VC6) | |||
| ncb.ncb_command = NCBENUM; | |||
| ncb.ncb_buffer = (unsigned char*) &enums; | |||
| ncb.ncb_length = sizeof (LANA_ENUM); | |||
| NetbiosCall (&ncb); | |||
| LANA_ENUM enums; | |||
| zerostruct (enums); | |||
| for (int i = 0; i < enums.length; ++i) | |||
| { | |||
| zerostruct (ncb); | |||
| ncb.ncb_command = NCBRESET; | |||
| ncb.ncb_lana_num = enums.lana[i]; | |||
| ncb.ncb_command = NCBENUM; | |||
| ncb.ncb_buffer = (unsigned char*) &enums; | |||
| ncb.ncb_length = sizeof (LANA_ENUM); | |||
| NetbiosCall (&ncb); | |||
| if (NetbiosCall (&ncb) == 0) | |||
| for (int i = 0; i < enums.length; ++i) | |||
| { | |||
| zerostruct (ncb); | |||
| memcpy (ncb.ncb_callname, "* ", NCBNAMSZ); | |||
| ncb.ncb_command = NCBASTAT; | |||
| ncb.ncb_command = NCBRESET; | |||
| ncb.ncb_lana_num = enums.lana[i]; | |||
| ncb.ncb_buffer = (unsigned char*) &astat; | |||
| ncb.ncb_length = sizeof (ASTAT); | |||
| if (NetbiosCall (&ncb) == 0) | |||
| { | |||
| if (astat.adapt.adapter_type == 0xfe) | |||
| { | |||
| uint64 mac = 0; | |||
| for (int i = 6; --i >= 0;) | |||
| mac = (mac << 8) | astat.adapt.adapter_address [littleEndian ? i : (5 - i)]; | |||
| zerostruct (ncb); | |||
| memcpy (ncb.ncb_callname, "* ", NCBNAMSZ); | |||
| ncb.ncb_command = NCBASTAT; | |||
| ncb.ncb_lana_num = enums.lana[i]; | |||
| if (numFound < maxNum && mac != 0) | |||
| addresses [numFound++] = mac; | |||
| } | |||
| ncb.ncb_buffer = (unsigned char*) &astat; | |||
| ncb.ncb_length = sizeof (ASTAT); | |||
| if (NetbiosCall (&ncb) == 0 && astat.adapt.adapter_type == 0xfe) | |||
| result.addIfNotAlreadyThere (MACAddress (astat.adapt.adapter_address)); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return numFound; | |||
| } | |||
| int SystemStats::getMACAddresses (int64* addresses, int maxNum, const bool littleEndian) | |||
| void MACAddress::findAllAddresses (Array<MACAddress>& result) | |||
| { | |||
| int numFound = getMACAddressViaGetAdaptersInfo (addresses, maxNum, littleEndian); | |||
| if (numFound == 0) | |||
| numFound = getMACAddressesViaNetBios (addresses, maxNum, littleEndian); | |||
| return numFound; | |||
| MACAddressHelpers::getViaGetAdaptersInfo (result); | |||
| MACAddressHelpers::getViaNetBios (result); | |||
| } | |||
| bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAddress, | |||
| @@ -256110,10 +256125,8 @@ int NamedPipe::write (const void* sourceBuffer, int numBytesToWrite, int timeOut | |||
| // compiled on its own). | |||
| #if JUCE_INCLUDED_FILE | |||
| int SystemStats::getMACAddresses (int64* addresses, int maxNum, const bool littleEndian) | |||
| void MACAddress::findAllAddresses (Array<MACAddress>& result) | |||
| { | |||
| int numResults = 0; | |||
| const int s = socket (AF_INET, SOCK_DGRAM, 0); | |||
| if (s != -1) | |||
| { | |||
| @@ -256130,22 +256143,14 @@ int SystemStats::getMACAddresses (int64* addresses, int maxNum, const bool littl | |||
| if (ioctl (s, SIOCGIFFLAGS, &ifr) == 0 | |||
| && (ifr.ifr_flags & IFF_LOOPBACK) == 0 | |||
| && ioctl (s, SIOCGIFHWADDR, &ifr) == 0 | |||
| && numResults < maxNum) | |||
| && ioctl (s, SIOCGIFHWADDR, &ifr) == 0) | |||
| { | |||
| int64 a = 0; | |||
| for (int j = 6; --j >= 0;) | |||
| a = (a << 8) | (uint8) ifr.ifr_hwaddr.sa_data [littleEndian ? j : (5 - j)]; | |||
| *addresses++ = a; | |||
| ++numResults; | |||
| result.addIfNotAlreadyThere (MACAddress ((const uint8*) ifr.ifr_hwaddr.sa_data)); | |||
| } | |||
| } | |||
| close (s); | |||
| } | |||
| return numResults; | |||
| } | |||
| bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAddress, | |||
| @@ -256251,11 +256256,8 @@ public: | |||
| return false; | |||
| } | |||
| const MemoryBlock requestHeader (createRequestHeader (hostName, hostPort, | |||
| proxyName, proxyPort, | |||
| hostPath, url, | |||
| headers, postData, | |||
| isPost)); | |||
| const MemoryBlock requestHeader (createRequestHeader (hostName, hostPort, proxyName, proxyPort, | |||
| hostPath, url, headers, postData, isPost)); | |||
| size_t totalHeaderSent = 0; | |||
| while (totalHeaderSent < requestHeader.getSize()) | |||
| @@ -256268,10 +256270,8 @@ public: | |||
| const int numToSend = jmin (1024, (int) (requestHeader.getSize() - totalHeaderSent)); | |||
| if (send (socketHandle, | |||
| ((const char*) requestHeader.getData()) + totalHeaderSent, | |||
| numToSend, 0) | |||
| != numToSend) | |||
| if (send (socketHandle, ((const char*) requestHeader.getData()) + totalHeaderSent, numToSend, 0) | |||
| != numToSend) | |||
| { | |||
| closeSocket(); | |||
| return false; | |||
| @@ -256290,8 +256290,6 @@ public: | |||
| if (responseHeader.isNotEmpty()) | |||
| { | |||
| //DBG (responseHeader); | |||
| headerLines.clear(); | |||
| headerLines.addLines (responseHeader); | |||
| @@ -264109,46 +264107,30 @@ void PlatformUtilities::fpuReset() | |||
| // compiled on its own). | |||
| #if JUCE_INCLUDED_FILE | |||
| int SystemStats::getMACAddresses (int64* addresses, int maxNum, const bool littleEndian) | |||
| void MACAddress::findAllAddresses (Array<MACAddress>& result) | |||
| { | |||
| #ifndef IFT_ETHER | |||
| #define IFT_ETHER 6 | |||
| #endif | |||
| ifaddrs* addrs = 0; | |||
| int numResults = 0; | |||
| if (getifaddrs (&addrs) == 0) | |||
| { | |||
| const ifaddrs* cursor = addrs; | |||
| while (cursor != 0 && numResults < maxNum) | |||
| for (const ifaddrs* cursor = addrs; cursor != 0; cursor = cursor->ifa_next) | |||
| { | |||
| sockaddr_storage* sto = (sockaddr_storage*) cursor->ifa_addr; | |||
| if (sto->ss_family == AF_LINK) | |||
| { | |||
| const sockaddr_dl* const sadd = (const sockaddr_dl*) cursor->ifa_addr; | |||
| if (sadd->sdl_type == IFT_ETHER) | |||
| { | |||
| const uint8* const addr = ((const uint8*) sadd->sdl_data) + sadd->sdl_nlen; | |||
| #ifndef IFT_ETHER | |||
| #define IFT_ETHER 6 | |||
| #endif | |||
| uint64 a = 0; | |||
| for (int i = 6; --i >= 0;) | |||
| a = (a << 8) | addr [littleEndian ? i : (5 - i)]; | |||
| *addresses++ = (int64) a; | |||
| ++numResults; | |||
| } | |||
| if (sadd->sdl_type == IFT_ETHER) | |||
| result.addIfNotAlreadyThere (MACAddress (((const uint8*) sadd->sdl_data) + sadd->sdl_nlen)); | |||
| } | |||
| cursor = cursor->ifa_next; | |||
| } | |||
| freeifaddrs (addrs); | |||
| } | |||
| return numResults; | |||
| } | |||
| bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAddress, | |||
| @@ -15112,20 +15112,19 @@ public: | |||
| static const String getCpuVendor(); | |||
| /** Checks whether Intel MMX instructions are available. */ | |||
| static bool hasMMX() throw() { return cpuFlags.hasMMX; } | |||
| static bool hasMMX() throw() { return cpuFlags.hasMMX; } | |||
| /** Checks whether Intel SSE instructions are available. */ | |||
| static bool hasSSE() throw() { return cpuFlags.hasSSE; } | |||
| static bool hasSSE() throw() { return cpuFlags.hasSSE; } | |||
| /** Checks whether Intel SSE2 instructions are available. */ | |||
| static bool hasSSE2() throw() { return cpuFlags.hasSSE2; } | |||
| static bool hasSSE2() throw() { return cpuFlags.hasSSE2; } | |||
| /** Checks whether AMD 3DNOW instructions are available. */ | |||
| static bool has3DNow() throw() { return cpuFlags.has3DNow; } | |||
| static bool has3DNow() throw() { return cpuFlags.has3DNow; } | |||
| /** Returns the number of CPUs. | |||
| */ | |||
| static int getNumCpus() throw() { return cpuFlags.numCpus; } | |||
| /** Returns the number of CPUs. */ | |||
| static int getNumCpus() throw() { return cpuFlags.numCpus; } | |||
| /** Finds out how much RAM is in the machine. | |||
| @@ -15140,34 +15139,6 @@ public: | |||
| */ | |||
| static int getPageSize(); | |||
| /** Returns a list of MAC addresses found on this machine. | |||
| @param addresses an array into which the MAC addresses should be copied | |||
| @param maxNum the number of elements in this array | |||
| @param littleEndian the endianness of the numbers to return. If this is true, | |||
| the least-significant byte of each number is the first byte | |||
| of the mac address. If false, the least significant byte is | |||
| the last number. Note that the default values of this parameter | |||
| are different on Mac/PC to avoid breaking old software that was | |||
| written before this parameter was added (when the two systems | |||
| defaulted to using different endiannesses). In newer | |||
| software you probably want to specify an explicit value | |||
| for this. | |||
| @returns the number of MAC addresses that were found | |||
| */ | |||
| static int getMACAddresses (int64* addresses, int maxNum, | |||
| #if JUCE_MAC | |||
| bool littleEndian = true); | |||
| #else | |||
| bool littleEndian = false); | |||
| #endif | |||
| /** Returns a list of MAC addresses found on this machine. | |||
| @returns an array of strings containing the MAC addresses that were found | |||
| */ | |||
| static const StringArray getMACAddressStrings(); | |||
| // not-for-public-use platform-specific method gets called at startup to initialise things. | |||
| static void initialiseStats(); | |||
| @@ -16418,6 +16389,71 @@ private: | |||
| /*** End of inlined file: juce_ZipFile.h ***/ | |||
| #endif | |||
| #ifndef __JUCE_MACADDRESS_JUCEHEADER__ | |||
| /*** Start of inlined file: juce_MACAddress.h ***/ | |||
| #ifndef __JUCE_MACADDRESS_JUCEHEADER__ | |||
| #define __JUCE_MACADDRESS_JUCEHEADER__ | |||
| /** | |||
| A wrapper for a streaming (TCP) socket. | |||
| This allows low-level use of sockets; for an easier-to-use messaging layer on top of | |||
| sockets, you could also try the InterprocessConnection class. | |||
| @see DatagramSocket, InterprocessConnection, InterprocessConnectionServer | |||
| */ | |||
| class JUCE_API MACAddress | |||
| { | |||
| public: | |||
| /** Populates a list of the MAC addresses of all the available network cards. */ | |||
| static void findAllAddresses (Array<MACAddress>& results); | |||
| /** Creates a null address (00-00-00-00-00-00). */ | |||
| MACAddress(); | |||
| /** Creates a copy of another address. */ | |||
| MACAddress (const MACAddress& other); | |||
| /** Creates a copy of another address. */ | |||
| MACAddress& operator= (const MACAddress& other); | |||
| /** Creates an address from 6 bytes. */ | |||
| explicit MACAddress (const uint8 bytes[6]); | |||
| /** Returns a pointer to the 6 bytes that make up this address. */ | |||
| const uint8* getBytes() const throw() { return asBytes; } | |||
| /** Returns a dash-separated string in the form "11-22-33-44-55-66" */ | |||
| const String toString() const; | |||
| /** Returns the address in the lower 6 bytes of an int64. | |||
| This uses a little-endian arrangement, with the first byte of the address being | |||
| stored in the least-significant byte of the result value. | |||
| */ | |||
| int64 toInt64() const throw(); | |||
| /** Returns true if this address is null (00-00-00-00-00-00). */ | |||
| bool isNull() const throw(); | |||
| bool operator== (const MACAddress& other) const throw(); | |||
| bool operator!= (const MACAddress& other) const throw(); | |||
| private: | |||
| union | |||
| { | |||
| uint64 asInt64; | |||
| uint8 asBytes[6]; | |||
| }; | |||
| }; | |||
| #endif // __JUCE_MACADDRESS_JUCEHEADER__ | |||
| /*** End of inlined file: juce_MACAddress.h ***/ | |||
| #endif | |||
| #ifndef __JUCE_SOCKET_JUCEHEADER__ | |||
| @@ -43,26 +43,6 @@ const String SystemStats::getJUCEVersion() | |||
| + "." + String (JUCE_BUILDNUMBER); | |||
| } | |||
| const StringArray SystemStats::getMACAddressStrings() | |||
| { | |||
| int64 macAddresses [16]; | |||
| const int numAddresses = getMACAddresses (macAddresses, numElementsInArray (macAddresses), false); | |||
| StringArray s; | |||
| for (int i = 0; i < numAddresses; ++i) | |||
| { | |||
| s.add (String::toHexString (0xff & (int) (macAddresses [i] >> 40)).paddedLeft ('0', 2) | |||
| + "-" + String::toHexString (0xff & (int) (macAddresses [i] >> 32)).paddedLeft ('0', 2) | |||
| + "-" + String::toHexString (0xff & (int) (macAddresses [i] >> 24)).paddedLeft ('0', 2) | |||
| + "-" + String::toHexString (0xff & (int) (macAddresses [i] >> 16)).paddedLeft ('0', 2) | |||
| + "-" + String::toHexString (0xff & (int) (macAddresses [i] >> 8)).paddedLeft ('0', 2) | |||
| + "-" + String::toHexString (0xff & (int) (macAddresses [i] >> 0)).paddedLeft ('0', 2)); | |||
| } | |||
| return s; | |||
| } | |||
| //============================================================================== | |||
| #ifdef JUCE_DLL | |||
| @@ -117,20 +117,19 @@ public: | |||
| static const String getCpuVendor(); | |||
| /** Checks whether Intel MMX instructions are available. */ | |||
| static bool hasMMX() throw() { return cpuFlags.hasMMX; } | |||
| static bool hasMMX() throw() { return cpuFlags.hasMMX; } | |||
| /** Checks whether Intel SSE instructions are available. */ | |||
| static bool hasSSE() throw() { return cpuFlags.hasSSE; } | |||
| static bool hasSSE() throw() { return cpuFlags.hasSSE; } | |||
| /** Checks whether Intel SSE2 instructions are available. */ | |||
| static bool hasSSE2() throw() { return cpuFlags.hasSSE2; } | |||
| static bool hasSSE2() throw() { return cpuFlags.hasSSE2; } | |||
| /** Checks whether AMD 3DNOW instructions are available. */ | |||
| static bool has3DNow() throw() { return cpuFlags.has3DNow; } | |||
| static bool has3DNow() throw() { return cpuFlags.has3DNow; } | |||
| /** Returns the number of CPUs. | |||
| */ | |||
| static int getNumCpus() throw() { return cpuFlags.numCpus; } | |||
| /** Returns the number of CPUs. */ | |||
| static int getNumCpus() throw() { return cpuFlags.numCpus; } | |||
| //============================================================================== | |||
| /** Finds out how much RAM is in the machine. | |||
| @@ -146,36 +145,6 @@ public: | |||
| */ | |||
| static int getPageSize(); | |||
| //============================================================================== | |||
| /** Returns a list of MAC addresses found on this machine. | |||
| @param addresses an array into which the MAC addresses should be copied | |||
| @param maxNum the number of elements in this array | |||
| @param littleEndian the endianness of the numbers to return. If this is true, | |||
| the least-significant byte of each number is the first byte | |||
| of the mac address. If false, the least significant byte is | |||
| the last number. Note that the default values of this parameter | |||
| are different on Mac/PC to avoid breaking old software that was | |||
| written before this parameter was added (when the two systems | |||
| defaulted to using different endiannesses). In newer | |||
| software you probably want to specify an explicit value | |||
| for this. | |||
| @returns the number of MAC addresses that were found | |||
| */ | |||
| static int getMACAddresses (int64* addresses, int maxNum, | |||
| #if JUCE_MAC | |||
| bool littleEndian = true); | |||
| #else | |||
| bool littleEndian = false); | |||
| #endif | |||
| /** Returns a list of MAC addresses found on this machine. | |||
| @returns an array of strings containing the MAC addresses that were found | |||
| */ | |||
| static const StringArray getMACAddressStrings(); | |||
| //============================================================================== | |||
| // not-for-public-use platform-specific method gets called at startup to initialise things. | |||
| static void initialiseStats(); | |||
| @@ -30,7 +30,7 @@ BEGIN_JUCE_NAMESPACE | |||
| #include "juce_Uuid.h" | |||
| #include "juce_Random.h" | |||
| #include "juce_Time.h" | |||
| #include "juce_SystemStats.h" | |||
| #include "../io/network/juce_MACAddress.h" | |||
| #include "../containers/juce_MemoryBlock.h" | |||
| @@ -46,7 +46,12 @@ Uuid::Uuid() | |||
| if (! hasCheckedMacAddresses) | |||
| { | |||
| hasCheckedMacAddresses = true; | |||
| SystemStats::getMACAddresses (macAddresses, 2); | |||
| Array<MACAddress> result; | |||
| MACAddress::findAllAddresses (result); | |||
| for (int i = 0; i < numElementsInArray (macAddresses); ++i) | |||
| macAddresses[i] = result[i].toInt64(); | |||
| } | |||
| value.asInt64[0] = macAddresses[0]; | |||
| @@ -0,0 +1,88 @@ | |||
| /* | |||
| ============================================================================== | |||
| This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||
| Copyright 2004-10 by Raw Material Software Ltd. | |||
| ------------------------------------------------------------------------------ | |||
| JUCE can be redistributed and/or modified under the terms of the GNU General | |||
| Public License (Version 2), as published by the Free Software Foundation. | |||
| A copy of the license is included in the JUCE distribution, or can be found | |||
| online at www.gnu.org/licenses. | |||
| JUCE is distributed in the hope that it will be useful, but WITHOUT ANY | |||
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | |||
| A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |||
| ------------------------------------------------------------------------------ | |||
| To release a closed-source product which uses JUCE, commercial licenses are | |||
| available: visit www.rawmaterialsoftware.com/juce for more information. | |||
| ============================================================================== | |||
| */ | |||
| #include "../../core/juce_StandardHeader.h" | |||
| BEGIN_JUCE_NAMESPACE | |||
| #include "juce_MACAddress.h" | |||
| //============================================================================== | |||
| MACAddress::MACAddress() | |||
| : asInt64 (0) | |||
| { | |||
| } | |||
| MACAddress::MACAddress (const MACAddress& other) | |||
| : asInt64 (other.asInt64) | |||
| { | |||
| } | |||
| MACAddress& MACAddress::operator= (const MACAddress& other) | |||
| { | |||
| asInt64 = other.asInt64; | |||
| return *this; | |||
| } | |||
| MACAddress::MACAddress (const uint8 bytes[6]) | |||
| : asInt64 (0) | |||
| { | |||
| memcpy (asBytes, bytes, sizeof (asBytes)); | |||
| } | |||
| const String MACAddress::toString() const | |||
| { | |||
| String s; | |||
| s.preallocateStorage (18); | |||
| for (int i = 0; i < numElementsInArray (asBytes); ++i) | |||
| { | |||
| s << String::toHexString ((int) asBytes[i]).paddedLeft ('0', 2); | |||
| if (i < numElementsInArray (asBytes) - 1) | |||
| s << '-'; | |||
| } | |||
| return s; | |||
| } | |||
| int64 MACAddress::toInt64() const throw() | |||
| { | |||
| int64 n = 0; | |||
| for (int i = numElementsInArray (asBytes); --i >= 0;) | |||
| n = (n << 8) | asBytes[i]; | |||
| return n; | |||
| } | |||
| bool MACAddress::isNull() const throw() { return asInt64 == 0; } | |||
| bool MACAddress::operator== (const MACAddress& other) const throw() { return asInt64 == other.asInt64; } | |||
| bool MACAddress::operator!= (const MACAddress& other) const throw() { return asInt64 != other.asInt64; } | |||
| END_JUCE_NAMESPACE | |||
| @@ -0,0 +1,90 @@ | |||
| /* | |||
| ============================================================================== | |||
| This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||
| Copyright 2004-10 by Raw Material Software Ltd. | |||
| ------------------------------------------------------------------------------ | |||
| JUCE can be redistributed and/or modified under the terms of the GNU General | |||
| Public License (Version 2), as published by the Free Software Foundation. | |||
| A copy of the license is included in the JUCE distribution, or can be found | |||
| online at www.gnu.org/licenses. | |||
| JUCE is distributed in the hope that it will be useful, but WITHOUT ANY | |||
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | |||
| A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |||
| ------------------------------------------------------------------------------ | |||
| To release a closed-source product which uses JUCE, commercial licenses are | |||
| available: visit www.rawmaterialsoftware.com/juce for more information. | |||
| ============================================================================== | |||
| */ | |||
| #ifndef __JUCE_MACADDRESS_JUCEHEADER__ | |||
| #define __JUCE_MACADDRESS_JUCEHEADER__ | |||
| #include "../../containers/juce_Array.h" | |||
| //============================================================================== | |||
| /** | |||
| A wrapper for a streaming (TCP) socket. | |||
| This allows low-level use of sockets; for an easier-to-use messaging layer on top of | |||
| sockets, you could also try the InterprocessConnection class. | |||
| @see DatagramSocket, InterprocessConnection, InterprocessConnectionServer | |||
| */ | |||
| class JUCE_API MACAddress | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| /** Populates a list of the MAC addresses of all the available network cards. */ | |||
| static void findAllAddresses (Array<MACAddress>& results); | |||
| //============================================================================== | |||
| /** Creates a null address (00-00-00-00-00-00). */ | |||
| MACAddress(); | |||
| /** Creates a copy of another address. */ | |||
| MACAddress (const MACAddress& other); | |||
| /** Creates a copy of another address. */ | |||
| MACAddress& operator= (const MACAddress& other); | |||
| /** Creates an address from 6 bytes. */ | |||
| explicit MACAddress (const uint8 bytes[6]); | |||
| /** Returns a pointer to the 6 bytes that make up this address. */ | |||
| const uint8* getBytes() const throw() { return asBytes; } | |||
| /** Returns a dash-separated string in the form "11-22-33-44-55-66" */ | |||
| const String toString() const; | |||
| /** Returns the address in the lower 6 bytes of an int64. | |||
| This uses a little-endian arrangement, with the first byte of the address being | |||
| stored in the least-significant byte of the result value. | |||
| */ | |||
| int64 toInt64() const throw(); | |||
| /** Returns true if this address is null (00-00-00-00-00-00). */ | |||
| bool isNull() const throw(); | |||
| bool operator== (const MACAddress& other) const throw(); | |||
| bool operator!= (const MACAddress& other) const throw(); | |||
| //============================================================================== | |||
| private: | |||
| union | |||
| { | |||
| uint64 asInt64; | |||
| uint8 asBytes[6]; | |||
| }; | |||
| }; | |||
| #endif // __JUCE_MACADDRESS_JUCEHEADER__ | |||
| @@ -182,6 +182,9 @@ | |||
| #ifndef __JUCE_ZIPFILE_JUCEHEADER__ | |||
| #include "io/files/juce_ZipFile.h" | |||
| #endif | |||
| #ifndef __JUCE_MACADDRESS_JUCEHEADER__ | |||
| #include "io/network/juce_MACAddress.h" | |||
| #endif | |||
| #ifndef __JUCE_SOCKET_JUCEHEADER__ | |||
| #include "io/network/juce_Socket.h" | |||
| #endif | |||
| @@ -61,6 +61,7 @@ BEGIN_JUCE_NAMESPACE | |||
| #include "../io/files/juce_FileOutputStream.h" | |||
| #include "../io/files/juce_DirectoryIterator.h" | |||
| #include "../io/network/juce_URL.h" | |||
| #include "../io/network/juce_MACAddress.h" | |||
| #include "../io/streams/juce_MemoryInputStream.h" | |||
| #include "../io/streams/juce_MemoryOutputStream.h" | |||
| #include "../events/juce_MessageManager.h" | |||
| @@ -50,6 +50,7 @@ BEGIN_JUCE_NAMESPACE | |||
| #include "../io/files/juce_NamedPipe.h" | |||
| #include "../io/files/juce_DirectoryIterator.h" | |||
| #include "../io/network/juce_URL.h" | |||
| #include "../io/network/juce_MACAddress.h" | |||
| #include "../io/streams/juce_MemoryInputStream.h" | |||
| #include "../io/streams/juce_BufferedInputStream.h" | |||
| #include "../core/juce_PlatformUtilities.h" | |||
| @@ -51,6 +51,7 @@ BEGIN_JUCE_NAMESPACE | |||
| #include "../io/files/juce_NamedPipe.h" | |||
| #include "../io/files/juce_DirectoryIterator.h" | |||
| #include "../io/network/juce_URL.h" | |||
| #include "../io/network/juce_MACAddress.h" | |||
| #include "../core/juce_PlatformUtilities.h" | |||
| #include "../text/juce_LocalisedStrings.h" | |||
| #include "../utilities/juce_DeletedAtShutdown.h" | |||
| @@ -29,10 +29,8 @@ | |||
| //============================================================================== | |||
| int SystemStats::getMACAddresses (int64* addresses, int maxNum, const bool littleEndian) | |||
| void MACAddress::findAllAddresses (Array<MACAddress>& result) | |||
| { | |||
| int numResults = 0; | |||
| const int s = socket (AF_INET, SOCK_DGRAM, 0); | |||
| if (s != -1) | |||
| { | |||
| @@ -49,22 +47,14 @@ int SystemStats::getMACAddresses (int64* addresses, int maxNum, const bool littl | |||
| if (ioctl (s, SIOCGIFFLAGS, &ifr) == 0 | |||
| && (ifr.ifr_flags & IFF_LOOPBACK) == 0 | |||
| && ioctl (s, SIOCGIFHWADDR, &ifr) == 0 | |||
| && numResults < maxNum) | |||
| && ioctl (s, SIOCGIFHWADDR, &ifr) == 0) | |||
| { | |||
| int64 a = 0; | |||
| for (int j = 6; --j >= 0;) | |||
| a = (a << 8) | (uint8) ifr.ifr_hwaddr.sa_data [littleEndian ? j : (5 - j)]; | |||
| *addresses++ = a; | |||
| ++numResults; | |||
| result.addIfNotAlreadyThere (MACAddress ((const uint8*) ifr.ifr_hwaddr.sa_data)); | |||
| } | |||
| } | |||
| close (s); | |||
| } | |||
| return numResults; | |||
| } | |||
| @@ -173,11 +163,8 @@ public: | |||
| return false; | |||
| } | |||
| const MemoryBlock requestHeader (createRequestHeader (hostName, hostPort, | |||
| proxyName, proxyPort, | |||
| hostPath, url, | |||
| headers, postData, | |||
| isPost)); | |||
| const MemoryBlock requestHeader (createRequestHeader (hostName, hostPort, proxyName, proxyPort, | |||
| hostPath, url, headers, postData, isPost)); | |||
| size_t totalHeaderSent = 0; | |||
| while (totalHeaderSent < requestHeader.getSize()) | |||
| @@ -190,10 +177,8 @@ public: | |||
| const int numToSend = jmin (1024, (int) (requestHeader.getSize() - totalHeaderSent)); | |||
| if (send (socketHandle, | |||
| ((const char*) requestHeader.getData()) + totalHeaderSent, | |||
| numToSend, 0) | |||
| != numToSend) | |||
| if (send (socketHandle, ((const char*) requestHeader.getData()) + totalHeaderSent, numToSend, 0) | |||
| != numToSend) | |||
| { | |||
| closeSocket(); | |||
| return false; | |||
| @@ -212,8 +197,6 @@ public: | |||
| if (responseHeader.isNotEmpty()) | |||
| { | |||
| //DBG (responseHeader); | |||
| headerLines.clear(); | |||
| headerLines.addLines (responseHeader); | |||
| @@ -28,46 +28,30 @@ | |||
| #if JUCE_INCLUDED_FILE | |||
| //============================================================================== | |||
| int SystemStats::getMACAddresses (int64* addresses, int maxNum, const bool littleEndian) | |||
| void MACAddress::findAllAddresses (Array<MACAddress>& result) | |||
| { | |||
| #ifndef IFT_ETHER | |||
| #define IFT_ETHER 6 | |||
| #endif | |||
| ifaddrs* addrs = 0; | |||
| int numResults = 0; | |||
| if (getifaddrs (&addrs) == 0) | |||
| { | |||
| const ifaddrs* cursor = addrs; | |||
| while (cursor != 0 && numResults < maxNum) | |||
| for (const ifaddrs* cursor = addrs; cursor != 0; cursor = cursor->ifa_next) | |||
| { | |||
| sockaddr_storage* sto = (sockaddr_storage*) cursor->ifa_addr; | |||
| if (sto->ss_family == AF_LINK) | |||
| { | |||
| const sockaddr_dl* const sadd = (const sockaddr_dl*) cursor->ifa_addr; | |||
| if (sadd->sdl_type == IFT_ETHER) | |||
| { | |||
| const uint8* const addr = ((const uint8*) sadd->sdl_data) + sadd->sdl_nlen; | |||
| uint64 a = 0; | |||
| for (int i = 6; --i >= 0;) | |||
| a = (a << 8) | addr [littleEndian ? i : (5 - i)]; | |||
| #ifndef IFT_ETHER | |||
| #define IFT_ETHER 6 | |||
| #endif | |||
| *addresses++ = (int64) a; | |||
| ++numResults; | |||
| } | |||
| if (sadd->sdl_type == IFT_ETHER) | |||
| result.addIfNotAlreadyThere (MACAddress (((const uint8*) sadd->sdl_data) + sadd->sdl_nlen)); | |||
| } | |||
| cursor = cursor->ifa_next; | |||
| } | |||
| freeifaddrs (addrs); | |||
| } | |||
| return numResults; | |||
| } | |||
| //============================================================================== | |||
| @@ -325,121 +325,91 @@ void juce_closeInternetFile (void* handle) | |||
| } | |||
| //============================================================================== | |||
| static int getMACAddressViaGetAdaptersInfo (int64* addresses, int maxNum, const bool littleEndian) throw() | |||
| namespace MACAddressHelpers | |||
| { | |||
| int numFound = 0; | |||
| DynamicLibraryLoader dll ("iphlpapi.dll"); | |||
| DynamicLibraryImport (GetAdaptersInfo, getAdaptersInfo, DWORD, dll, (PIP_ADAPTER_INFO, PULONG)) | |||
| if (getAdaptersInfo != 0) | |||
| void getViaGetAdaptersInfo (Array<MACAddress>& result) | |||
| { | |||
| ULONG len = sizeof (IP_ADAPTER_INFO); | |||
| MemoryBlock mb; | |||
| PIP_ADAPTER_INFO adapterInfo = (PIP_ADAPTER_INFO) mb.getData(); | |||
| DynamicLibraryLoader dll ("iphlpapi.dll"); | |||
| DynamicLibraryImport (GetAdaptersInfo, getAdaptersInfo, DWORD, dll, (PIP_ADAPTER_INFO, PULONG)) | |||
| if (getAdaptersInfo (adapterInfo, &len) == ERROR_BUFFER_OVERFLOW) | |||
| if (getAdaptersInfo != 0) | |||
| { | |||
| mb.setSize (len); | |||
| adapterInfo = (PIP_ADAPTER_INFO) mb.getData(); | |||
| } | |||
| ULONG len = sizeof (IP_ADAPTER_INFO); | |||
| MemoryBlock mb; | |||
| PIP_ADAPTER_INFO adapterInfo = (PIP_ADAPTER_INFO) mb.getData(); | |||
| if (getAdaptersInfo (adapterInfo, &len) == NO_ERROR) | |||
| { | |||
| PIP_ADAPTER_INFO adapter = adapterInfo; | |||
| while (adapter != 0) | |||
| if (getAdaptersInfo (adapterInfo, &len) == ERROR_BUFFER_OVERFLOW) | |||
| { | |||
| int64 mac = 0; | |||
| for (unsigned int i = 0; i < adapter->AddressLength; ++i) | |||
| mac = (mac << 8) | adapter->Address[i]; | |||
| if (littleEndian) | |||
| mac = (int64) ByteOrder::swap ((uint64) mac); | |||
| if (numFound < maxNum && mac != 0) | |||
| addresses [numFound++] = mac; | |||
| mb.setSize (len); | |||
| adapterInfo = (PIP_ADAPTER_INFO) mb.getData(); | |||
| } | |||
| adapter = adapter->Next; | |||
| if (getAdaptersInfo (adapterInfo, &len) == NO_ERROR) | |||
| { | |||
| for (PIP_ADAPTER_INFO adapter = adapterInfo; adapter != 0; adapter = adapter->Next) | |||
| { | |||
| if (adapter->AddressLength >= 6) | |||
| result.addIfNotAlreadyThere (MACAddress (adapter->Address)); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return numFound; | |||
| } | |||
| static int getMACAddressesViaNetBios (int64* addresses, int maxNum, const bool littleEndian) throw() | |||
| { | |||
| int numFound = 0; | |||
| DynamicLibraryLoader dll ("netapi32.dll"); | |||
| DynamicLibraryImport (Netbios, NetbiosCall, UCHAR, dll, (PNCB)) | |||
| if (NetbiosCall != 0) | |||
| void getViaNetBios (Array<MACAddress>& result) | |||
| { | |||
| NCB ncb; | |||
| zerostruct (ncb); | |||
| DynamicLibraryLoader dll ("netapi32.dll"); | |||
| DynamicLibraryImport (Netbios, NetbiosCall, UCHAR, dll, (PNCB)) | |||
| struct ASTAT | |||
| if (NetbiosCall != 0) | |||
| { | |||
| ADAPTER_STATUS adapt; | |||
| NAME_BUFFER NameBuff [30]; | |||
| }; | |||
| NCB ncb; | |||
| zerostruct (ncb); | |||
| ASTAT astat; | |||
| zeromem (&astat, sizeof (astat)); // (can't use zerostruct here in VC6) | |||
| struct ASTAT | |||
| { | |||
| ADAPTER_STATUS adapt; | |||
| NAME_BUFFER NameBuff [30]; | |||
| }; | |||
| LANA_ENUM enums; | |||
| zerostruct (enums); | |||
| ASTAT astat; | |||
| zeromem (&astat, sizeof (astat)); // (can't use zerostruct here in VC6) | |||
| ncb.ncb_command = NCBENUM; | |||
| ncb.ncb_buffer = (unsigned char*) &enums; | |||
| ncb.ncb_length = sizeof (LANA_ENUM); | |||
| NetbiosCall (&ncb); | |||
| LANA_ENUM enums; | |||
| zerostruct (enums); | |||
| for (int i = 0; i < enums.length; ++i) | |||
| { | |||
| zerostruct (ncb); | |||
| ncb.ncb_command = NCBRESET; | |||
| ncb.ncb_lana_num = enums.lana[i]; | |||
| ncb.ncb_command = NCBENUM; | |||
| ncb.ncb_buffer = (unsigned char*) &enums; | |||
| ncb.ncb_length = sizeof (LANA_ENUM); | |||
| NetbiosCall (&ncb); | |||
| if (NetbiosCall (&ncb) == 0) | |||
| for (int i = 0; i < enums.length; ++i) | |||
| { | |||
| zerostruct (ncb); | |||
| memcpy (ncb.ncb_callname, "* ", NCBNAMSZ); | |||
| ncb.ncb_command = NCBASTAT; | |||
| ncb.ncb_command = NCBRESET; | |||
| ncb.ncb_lana_num = enums.lana[i]; | |||
| ncb.ncb_buffer = (unsigned char*) &astat; | |||
| ncb.ncb_length = sizeof (ASTAT); | |||
| if (NetbiosCall (&ncb) == 0) | |||
| { | |||
| if (astat.adapt.adapter_type == 0xfe) | |||
| { | |||
| uint64 mac = 0; | |||
| for (int i = 6; --i >= 0;) | |||
| mac = (mac << 8) | astat.adapt.adapter_address [littleEndian ? i : (5 - i)]; | |||
| zerostruct (ncb); | |||
| memcpy (ncb.ncb_callname, "* ", NCBNAMSZ); | |||
| ncb.ncb_command = NCBASTAT; | |||
| ncb.ncb_lana_num = enums.lana[i]; | |||
| if (numFound < maxNum && mac != 0) | |||
| addresses [numFound++] = mac; | |||
| } | |||
| ncb.ncb_buffer = (unsigned char*) &astat; | |||
| ncb.ncb_length = sizeof (ASTAT); | |||
| if (NetbiosCall (&ncb) == 0 && astat.adapt.adapter_type == 0xfe) | |||
| result.addIfNotAlreadyThere (MACAddress (astat.adapt.adapter_address)); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return numFound; | |||
| } | |||
| int SystemStats::getMACAddresses (int64* addresses, int maxNum, const bool littleEndian) | |||
| void MACAddress::findAllAddresses (Array<MACAddress>& result) | |||
| { | |||
| int numFound = getMACAddressViaGetAdaptersInfo (addresses, maxNum, littleEndian); | |||
| if (numFound == 0) | |||
| numFound = getMACAddressesViaNetBios (addresses, maxNum, littleEndian); | |||
| return numFound; | |||
| MACAddressHelpers::getViaGetAdaptersInfo (result); | |||
| MACAddressHelpers::getViaNetBios (result); | |||
| } | |||
| //============================================================================== | |||