~ubuntu-branches/ubuntu/quantal/apt-cacher-ng/quantal-backports

« back to all changes in this revision

Viewing changes to include/csmapping.h

  • Committer: Package Import Robot
  • Author(s): Eduard Bloch
  • Date: 2011-11-26 13:09:45 UTC
  • mfrom: (1.1.30) (29.1.18 sid)
  • Revision ID: package-import@ubuntu.com-20111126130945-acifclz6ksfl8607
Tags: 0.6.10-1
New upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
                memcpy(csum, a.csum, 20);
39
39
        };
40
40
        
41
 
        bool Set(const mstring & in, CSTYPES eCstype, off_t newsize)
 
41
        bool Set(const mstring & hexString, CSTYPES eCstype, off_t newsize)
42
42
        {
43
 
                if(newsize<0 || in.empty()
 
43
                if(newsize<0 || hexString.empty()
44
44
                                || (eCstype!=CSTYPE_MD5 && eCstype!=CSTYPE_SHA1)
45
 
                                || (eCstype==CSTYPE_MD5 && 32 != in.length())
46
 
                                || (eCstype==CSTYPE_SHA1 && 40 != in.length()))
 
45
                                || (eCstype==CSTYPE_MD5 && 32 != hexString.length())
 
46
                                || (eCstype==CSTYPE_SHA1 && 40 != hexString.length()))
47
47
                        return false;
48
48
 
49
49
                size=newsize;
50
50
                csType=eCstype;
51
 
                return CsAsciiToBin(in.c_str(), csum, CSTYPE_MD5==csType?16:20);
 
51
                return CsAsciiToBin(hexString.c_str(), csum, CSTYPE_MD5==csType?16:20);
52
52
        }
53
53
        void Set(uint8_t *pData, CSTYPES eCstype, off_t newsize)
54
54
        {
77
77
        {
78
78
                return GetCsAsString()+"_"+offttos(size);
79
79
        }
80
 
        bool operator==(const tFingerprint & other) const
 
80
        inline bool operator==(const tFingerprint & other) const
81
81
        {
82
82
                if(other.csType!=csType || size!=other.size)
83
83
                        return false;
140
140
};
141
141
struct ltCacheKeyComp
142
142
{
143
 
  bool operator()(const tImpFileInfo &a, const tImpFileInfo &b) const
 
143
  inline bool operator()(const tImpFileInfo &a, const tImpFileInfo &b) const
144
144
  {
 
145
          return (a.mtime!=b.mtime) ? (a.mtime<b.mtime) :
145
146
#if defined(WINDOWS) || defined(WIN32)
146
 
#warning FIXME, make this use nocasestringmap
 
147
                          (strcasecmp(a.sPath.c_str(), b.sPath.c_str()) < 0);
 
148
#else
 
149
                          (a.sPath<b.sPath);
147
150
#endif
148
 
          if(a.mtime!=b.mtime)
149
 
                  return a.mtime<b.mtime;
150
 
      return (a.sPath<b.sPath);
151
151
  }
152
152
};
153
153
 
154
 
typedef MYSTD::map<tFingerprint, tImpFileInfo> tImportMap;
 
154
typedef MYMAP<tFingerprint, tImpFileInfo> tImportMap;
155
155
typedef MYSTD::deque<MYSTD::pair<tFingerprint, tImpFileInfo> > tImportList;
156
 
typedef MYSTD::map<tImpFileInfo, tFingerprint, ltCacheKeyComp> tFprCacheMap;
 
156
typedef MYMAP<tImpFileInfo, tFingerprint, ltCacheKeyComp> tFprCacheMap;
157
157
 
158
158
 
159
159
#endif /*CSMAPPING_H_*/