diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-16 19:32:28 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-16 19:32:28 +0000 |
commit | 2baba999a1195f813f6701a3626bfde95258b27c (patch) | |
tree | 8baf70926b5246ae4ce28dcc7f9f43b4352dafbb /ace/ACE.cpp | |
parent | 9124402e03321d7e9cf5320355fdae2164151640 (diff) | |
download | ATCD-2baba999a1195f813f6701a3626bfde95258b27c.tar.gz |
ChangeLogTag:Wed Jun 16 14:27:45 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
Diffstat (limited to 'ace/ACE.cpp')
-rw-r--r-- | ace/ACE.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/ace/ACE.cpp b/ace/ACE.cpp index b5f7d325e98..b1f02e5a883 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -518,15 +518,16 @@ u_long ACE::crc_table_[] = // Compute a POSIX 1003.2 checksum. The routine takes an string and // computes the CRC for it (it stops on the first '\0' character). -u_long -ACE::crc32 (const char *string) -{ // UNICOS UINT32's are 64-bit on the Cray PVP architecture #if !defined(_UNICOS) # define COMPUTE(var, ch) (var) = ((var) << 8) ^ ACE::crc_table_[((var) >> 24) ^ (ch)] #else /* ! _UNICOS */ # define COMPUTE(var, ch) (var) = ( 0x00000000ffffffff & ((var) << 8)) ^ ACE::crc_table_[((var) >> 24) ^ (ch)] #endif /* ! _UNICOS */ + +u_long +ACE::crc32 (const char *string) +{ register ACE_UINT32 crc = 0; u_long len = 0; @@ -547,6 +548,28 @@ ACE::crc32 (const char *string) return ~crc; } +u_long +ACE::crc32 (const char *buffer, ACE_UINT32 len) +{ + register ACE_UINT32 crc = 0; + + for (const char *p = buffer; + p != buffer + len; + ++p) + { + COMPUTE (crc, *p); + } + + // Include the length of the string. + + for (; len != 0; len >>= 8) + COMPUTE (crc, len & 0xff); + + return ~crc; +} + +#undef COMPUTE + size_t ACE::strrepl (char *s, char search, char replace) { |