Changeset 1202 in Sophya for trunk/SophyaLib


Ignore:
Timestamp:
Sep 27, 2000, 5:56:51 PM (25 years ago)
Author:
ansari
Message:

bug swap md5

Location:
trunk/SophyaLib/BaseTools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/BaseTools/ppersist.cc

    r1101 r1202  
    174174  string typ_name = typeid(o).name() ;
    175175  return (getDataObjClassId(typ_name) );
     176}
     177
     178
     179static inline void bswap8(void* p)
     180{
     181  uint_8 tmp = *(uint_8*)p;
     182  *(uint_8*)p = ((tmp >> (7*8)) & 0x000000FF) |
     183                ((tmp >> (5*8)) & 0x0000FF00) |
     184                ((tmp >> (3*8)) & 0x00FF0000) |
     185                ((tmp >> (1*8)) & 0xFF000000) |
     186                ((tmp & 0xFF000000) << (1*8))  |
     187                ((tmp & 0x00FF0000) << (3*8))  |
     188                ((tmp & 0x0000FF00) << (5*8))  |
     189                ((tmp & 0x000000FF) << (7*8));
     190}
     191
     192static inline void bswap4(void* p)
     193{
     194  uint_4 tmp = *(uint_4*)p;
     195  *(uint_4*)p = ((tmp >> 24) & 0x000000FF) |
     196                ((tmp >> 8)  & 0x0000FF00) |
     197                ((tmp & 0x0000FF00) << 8)  |
     198                ((tmp & 0x000000FF) << 24);
     199}
     200
     201static inline void bswap2(void* p)
     202{
     203  uint_2 tmp = *(uint_2*)p;
     204  *(uint_2*)p = ((tmp >> 8) & 0x00FF) |
     205                ((tmp & 0x00FF) << 8);
     206}
     207
     208
     209uint_8 PIOPersist::Hash(string const& typname) {
     210        md5_init(&ctx);
     211        md5_write(&ctx, (unsigned char*) typname.c_str(), typname.size());
     212        md5_final(&ctx);
     213        uint_8 hash1 =   *((uint_8*) ctx.buf);
     214        uint_8 hash2 =   *((uint_8*) (ctx.buf+8));
     215#if IS_BIG_ENDIAN
     216        bswap8(&hash1);
     217        bswap8(&hash2);
     218#endif
     219       
     220        return (hash1+hash2);
    176221}
    177222
     
    564609//--
    565610
    566 
    567 static inline void bswap8(void* p)
    568 {
    569   uint_8 tmp = *(uint_8*)p;
    570   *(uint_8*)p = ((tmp >> (7*8)) & 0x000000FF) |
    571                 ((tmp >> (5*8)) & 0x0000FF00) |
    572                 ((tmp >> (3*8)) & 0x00FF0000) |
    573                 ((tmp >> (1*8)) & 0xFF000000) |
    574                 ((tmp & 0xFF000000) << (1*8))  |
    575                 ((tmp & 0x00FF0000) << (3*8))  |
    576                 ((tmp & 0x0000FF00) << (5*8))  |
    577                 ((tmp & 0x000000FF) << (7*8));
    578 }
    579 
    580 static inline void bswap4(void* p)
    581 {
    582   uint_4 tmp = *(uint_4*)p;
    583   *(uint_4*)p = ((tmp >> 24) & 0x000000FF) |
    584                 ((tmp >> 8)  & 0x0000FF00) |
    585                 ((tmp & 0x0000FF00) << 8)  |
    586                 ((tmp & 0x000000FF) << 24);
    587 }
    588 
    589 static inline void bswap2(void* p)
    590 {
    591   uint_2 tmp = *(uint_2*)p;
    592   *(uint_2*)p = ((tmp >> 8) & 0x00FF) |
    593                 ((tmp & 0x00FF) << 8);
    594 }
    595611
    596612void
  • trunk/SophyaLib/BaseTools/ppersist.h

    r895 r1202  
    8888    static uint_8                getDataObjClassId(AnyDataObj const & o);
    8989
    90     static uint_8 Hash(string const& typname) {
    91         md5_init(&ctx);
    92         md5_write(&ctx, (unsigned char*) typname.c_str(), typname.size());
    93         md5_final(&ctx);
    94         return ( *((uint_8*) ctx.buf) + *((uint_8*) (ctx.buf+8)));
    95     }
     90    static uint_8 Hash(string const& typname);
    9691    static MD5_CONTEXT ctx;
    9792 
Note: See TracChangeset for help on using the changeset viewer.