Switch to unified view

a/src/rcldb/pathhash.cpp b/src/rcldb/pathhash.cpp
1
#ifndef lint
1
#ifndef lint
2
static char rcsid[] = "@(#$Id: pathhash.cpp,v 1.5 2007-12-13 06:58:21 dockes Exp $ (C) 2005 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: pathhash.cpp,v 1.6 2008-07-28 12:24:15 dockes Exp $ (C) 2005 J.F.Dockes";
3
#endif
3
#endif
4
/*
4
/*
5
 *   This program is free software; you can redistribute it and/or modify
5
 *   This program is free software; you can redistribute it and/or modify
6
 *   it under the terms of the GNU General Public License as published by
6
 *   it under the terms of the GNU General Public License as published by
7
 *   the Free Software Foundation; either version 2 of the License, or
7
 *   the Free Software Foundation; either version 2 of the License, or
...
...
28
#ifndef NO_NAMESPACES
28
#ifndef NO_NAMESPACES
29
using std::string;
29
using std::string;
30
namespace Rcl {
30
namespace Rcl {
31
#endif /* NO_NAMESPACES */
31
#endif /* NO_NAMESPACES */
32
32
33
    // Debug only
33
#ifdef PATHHASH_HEX
34
#ifdef PATHHASH_HEX
34
static void md5hexprint(const unsigned char hash[16], string &out)
35
static void md5hexprint(const unsigned char hash[16], string &out)
35
{
36
{
36
    out.erase();
37
    out.erase();
37
    out.reserve(33);
38
    out.reserve(33);
...
...
67
    MD5Init(&ctx);
68
    MD5Init(&ctx);
68
    MD5Update(&ctx, (const unsigned char *)(path.c_str()+maxlen-HASHLEN), 
69
    MD5Update(&ctx, (const unsigned char *)(path.c_str()+maxlen-HASHLEN), 
69
          path.length() - (maxlen - HASHLEN));
70
          path.length() - (maxlen - HASHLEN));
70
    MD5Final(chash, &ctx);
71
    MD5Final(chash, &ctx);
71
72
72
#if 0
73
#ifdef PATHHASH_HEX
73
    string hex;
74
    string hex;
74
    md5hexprint(chash, hex);
75
    md5hexprint(chash, hex);
75
    printf("hex  [%s]\n", hex.c_str());
76
    printf("hex  [%s]\n", hex.c_str());
76
#endif
77
#endif
77
78
...
...
80
    string hash;
81
    string hash;
81
    base64_encode(string((char *)chash, 16), hash);
82
    base64_encode(string((char *)chash, 16), hash);
82
    // We happen to know there will be 2 pad chars in there, that we
83
    // We happen to know there will be 2 pad chars in there, that we
83
    // don't need as this won't ever be decoded. Resulting length is 22
84
    // don't need as this won't ever be decoded. Resulting length is 22
84
    hash.resize(hash.length() - 2);
85
    hash.resize(hash.length() - 2);
85
86
86
87
    // Truncate path and append hash
87
    // Truncate path and append hash
88
    phash = path.substr(0, maxlen - HASHLEN) + hash;
88
    phash = path.substr(0, maxlen - HASHLEN) + hash;
89
}
89
}
90
#ifndef NO_NAMESPACES
90
#ifndef NO_NAMESPACES