Classes | |
class | Directory |
class | File |
Functions | |
ACE_TString | b32h_encode (const ACE_TCHAR *decoded) |
ACE_TString | b32h_decode (const ACE_TCHAR *encoded) |
OpenDDS_Dcps_Export ACE_TString OpenDDS::FileSystemStorage::b32h_encode | ( | const ACE_TCHAR * | decoded | ) |
Definition at line 868 of file FileSystemStorage.cpp.
Referenced by OpenDDS::FileSystemStorage::Directory::make_new_file(), and OpenDDS::FileSystemStorage::Directory::make_new_subdir().
00869 { 00870 static const ACE_TCHAR lookup[] = 00871 ACE_TEXT("0123456789ABCDEFGHIJKLMNOPQRSTUV"); 00872 static const ACE_TCHAR padding[] = ACE_TEXT("======"); 00873 static const size_t enc[] = {0, 2, 4, 5, 7}; // #input -> #non-padded output 00874 ACE_TString encoded; 00875 00876 for (size_t len = ACE_OS::strlen(decoded); *decoded; decoded += 5, len -= 5) { 00877 ACE_UINT64 chunk = 0; 00878 00879 for (size_t i(0); i < 5 && i < len; ++i) { 00880 chunk |= static_cast<ACE_UINT64>(decoded[i] & 0xFF) << ((4 - i) * 8); 00881 } 00882 00883 size_t limit = (len < 5) ? enc[len] : 8; 00884 00885 for (size_t i(0); i < limit; ++i) { 00886 unsigned char val = 00887 static_cast<unsigned char>(chunk >>((7 - i) * 5)) & 0x1F; 00888 encoded += lookup[val]; 00889 } 00890 00891 if (len < 5) { 00892 encoded.append(padding, 8 - enc[len]); 00893 return encoded; 00894 } 00895 } 00896 00897 return encoded; 00898 }
OpenDDS_Dcps_Export ACE_TString OpenDDS::FileSystemStorage::b32h_decode | ( | const ACE_TCHAR * | encoded | ) |
Definition at line 900 of file FileSystemStorage.cpp.
Referenced by OpenDDS::FileSystemStorage::Directory::scan_dir().
00901 { 00902 // #before first '=' -> #output 00903 static const size_t dec[] = {0, 0, 1, 0, 2, 3, 0, 4}; 00904 ACE_TString decoded; 00905 00906 for (; *encoded; encoded += 8) { 00907 ACE_UINT64 chunk = 0; 00908 size_t i = 0; 00909 00910 for (; i < 8 && encoded[i] != ACE_TEXT('='); ++i) { 00911 char idx = (encoded[i] <= ACE_TEXT('9')) 00912 ? (encoded[i] - ACE_TEXT('0')) 00913 : (10 + encoded[i] - ACE_TEXT('A')); 00914 chunk |= static_cast<ACE_UINT64>(idx) << ((7 - i) * 5); 00915 } 00916 00917 size_t limit = (encoded[i] == ACE_TEXT('=')) ? dec[i] : 5; 00918 00919 for (size_t j(0); j < limit; ++j) { 00920 decoded += static_cast<ACE_TCHAR>(chunk >>((4 - j) * 8)) & 0xFF; 00921 } 00922 } 00923 00924 return decoded; 00925 }