Hex Artifact Content
Not logged in

Artifact 91eb7965062f4312de0c32613b15f5a8ef33a9d7:


0000: 2f 2a 0a 20 2a 20 54 68 69 73 20 66 69 6c 65 20  /*. * This file 
0010: 69 73 20 61 20 70 61 72 74 20 6f 66 20 4a 61 76  is a part of Jav
0020: 61 20 42 69 6e 64 69 6e 67 73 20 66 6f 72 20 4c  a Bindings for L
0030: 69 62 72 68 61 73 68 0a 20 2a 20 43 6f 70 79 72  ibrhash. * Copyr
0040: 69 67 68 74 20 28 63 29 20 32 30 31 31 2d 32 30  ight (c) 2011-20
0050: 31 32 2c 20 53 65 72 67 65 79 20 42 61 73 61 6c  12, Sergey Basal
0060: 61 65 76 20 3c 73 62 61 73 61 6c 61 65 76 40 67  aev <sbasalaev@g
0070: 6d 61 69 6c 2e 63 6f 6d 3e 0a 20 2a 20 4c 69 62  mail.com>. * Lib
0080: 72 68 61 73 68 20 69 73 20 28 63 29 20 32 30 31  rhash is (c) 201
0090: 31 2d 32 30 31 32 2c 20 41 6c 65 6b 73 65 79 20  1-2012, Aleksey 
00a0: 4b 72 61 76 63 68 65 6e 6b 6f 20 3c 72 68 61 73  Kravchenko <rhas
00b0: 68 2e 61 64 6d 69 6e 40 67 6d 61 69 6c 2e 63 6f  h.admin@gmail.co
00c0: 6d 3e 0a 20 2a 20 0a 20 2a 20 50 65 72 6d 69 73  m>. * . * Permis
00d0: 73 69 6f 6e 20 69 73 20 68 65 72 65 62 79 20 67  sion is hereby g
00e0: 72 61 6e 74 65 64 2c 20 66 72 65 65 20 6f 66 20  ranted, free of 
00f0: 63 68 61 72 67 65 2c 20 20 74 6f 20 61 6e 79 20  charge,  to any 
0100: 70 65 72 73 6f 6e 20 6f 62 74 61 69 6e 69 6e 67  person obtaining
0110: 20 61 20 63 6f 70 79 0a 20 2a 20 6f 66 20 74 68   a copy. * of th
0120: 69 73 20 73 6f 66 74 77 61 72 65 20 61 6e 64 20  is software and 
0130: 61 73 73 6f 63 69 61 74 65 64 20 64 6f 63 75 6d  associated docum
0140: 65 6e 74 61 74 69 6f 6e 20 66 69 6c 65 73 20 28  entation files (
0150: 74 68 65 20 22 53 6f 66 74 77 61 72 65 22 29 2c  the "Software"),
0160: 20 74 6f 20 64 65 61 6c 0a 20 2a 20 69 6e 20 74   to deal. * in t
0170: 68 65 20 53 6f 66 74 77 61 72 65 20 77 69 74 68  he Software with
0180: 6f 75 74 20 72 65 73 74 72 69 63 74 69 6f 6e 2c  out restriction,
0190: 20 20 69 6e 63 6c 75 64 69 6e 67 20 77 69 74 68    including with
01a0: 6f 75 74 20 6c 69 6d 69 74 61 74 69 6f 6e 20 74  out limitation t
01b0: 68 65 20 72 69 67 68 74 73 0a 20 2a 20 74 6f 20  he rights. * to 
01c0: 20 75 73 65 2c 20 20 63 6f 70 79 2c 20 20 6d 6f   use,  copy,  mo
01d0: 64 69 66 79 2c 20 20 6d 65 72 67 65 2c 20 70 75  dify,  merge, pu
01e0: 62 6c 69 73 68 2c 20 64 69 73 74 72 69 62 75 74  blish, distribut
01f0: 65 2c 20 73 75 62 6c 69 63 65 6e 73 65 2c 20 61  e, sublicense, a
0200: 6e 64 2f 6f 72 20 73 65 6c 6c 0a 20 2a 20 63 6f  nd/or sell. * co
0210: 70 69 65 73 20 20 6f 66 20 20 74 68 65 20 53 6f  pies  of  the So
0220: 66 74 77 61 72 65 2c 20 20 61 6e 64 20 20 74 6f  ftware,  and  to
0230: 20 70 65 72 6d 69 74 20 20 70 65 72 73 6f 6e 73   permit  persons
0240: 20 20 74 6f 20 77 68 6f 6d 20 20 74 68 65 20 53    to whom  the S
0250: 6f 66 74 77 61 72 65 20 20 69 73 0a 20 2a 20 66  oftware  is. * f
0260: 75 72 6e 69 73 68 65 64 20 74 6f 20 64 6f 20 73  urnished to do s
0270: 6f 2e 0a 20 2a 20 0a 20 2a 20 54 68 69 73 20 6c  o.. * . * This l
0280: 69 62 72 61 72 79 20 20 69 73 20 64 69 73 74 72  ibrary  is distr
0290: 69 62 75 74 65 64 20 20 69 6e 20 74 68 65 20 68  ibuted  in the h
02a0: 6f 70 65 20 74 68 61 74 20 69 74 20 77 69 6c 6c  ope that it will
02b0: 20 62 65 20 75 73 65 66 75 6c 2c 20 62 75 74 20   be useful, but 
02c0: 57 49 54 48 4f 55 54 0a 20 2a 20 41 4e 59 20 57  WITHOUT. * ANY W
02d0: 41 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74  ARRANTY; without
02e0: 20 65 76 65 6e 20 74 68 65 20 69 6d 70 6c 69 65   even the implie
02f0: 64 20 77 61 72 72 61 6e 74 79 20 6f 66 20 4d 45  d warranty of ME
0300: 52 43 48 41 4e 54 41 42 49 4c 49 54 59 20 6f 72  RCHANTABILITY or
0310: 20 46 49 54 4e 45 53 53 0a 20 2a 20 46 4f 52 20   FITNESS. * FOR 
0320: 41 20 50 41 52 54 49 43 55 4c 41 52 20 50 55 52  A PARTICULAR PUR
0330: 50 4f 53 45 2e 20 55 73 65 20 69 74 20 61 74 20  POSE. Use it at 
0340: 79 6f 75 72 20 6f 77 6e 20 72 69 73 6b 21 0a 20  your own risk!. 
0350: 2a 2f 0a 0a 2f 2a 20 54 68 69 73 20 69 73 20 63  */../* This is c
0360: 6f 6e 76 65 6e 69 65 6e 74 20 73 74 72 75 63 74  onvenient struct
0370: 75 72 65 20 74 6f 20 68 6f 6c 64 20 6d 65 73 73  ure to hold mess
0380: 61 67 65 20 64 69 67 65 73 74 2e 20 2a 2f 0a 0a  age digest. */..
0390: 23 69 66 6e 64 65 66 20 44 49 47 45 53 54 5f 48  #ifndef DIGEST_H
03a0: 0a 23 64 65 66 69 6e 65 20 44 49 47 45 53 54 5f  .#define DIGEST_
03b0: 48 0a 0a 74 79 70 65 64 65 66 20 73 74 72 75 63  H..typedef struc
03c0: 74 20 7b 0a 09 69 6e 74 20 68 61 73 68 5f 69 64  t {..int hash_id
03d0: 3b 0a 09 73 69 7a 65 5f 74 20 68 61 73 68 5f 6c  ;..size_t hash_l
03e0: 65 6e 3b 0a 09 75 6e 73 69 67 6e 65 64 20 63 68  en;..unsigned ch
03f0: 61 72 20 2a 68 61 73 68 5f 64 61 74 61 3b 0a 7d  ar *hash_data;.}
0400: 20 44 69 67 65 73 74 53 74 72 75 63 74 3b 0a 0a   DigestStruct;..
0410: 74 79 70 65 64 65 66 20 44 69 67 65 73 74 53 74  typedef DigestSt
0420: 72 75 63 74 2a 20 44 69 67 65 73 74 3b 0a 0a 2f  ruct* Digest;../
0430: 2a 2a 0a 20 2a 20 46 72 65 65 73 20 6d 65 6d 6f  **. * Frees memo
0440: 72 79 20 6f 63 63 75 70 61 74 65 64 20 62 79 20  ry occupated by 
0450: 44 69 67 65 73 74 2e 0a 20 2a 20 40 70 61 72 61  Digest.. * @para
0460: 6d 20 20 6f 62 6a 20 20 6f 62 6a 65 63 74 20 74  m  obj  object t
0470: 6f 20 66 72 65 65 0a 20 2a 2f 0a 76 6f 69 64 20  o free. */.void 
0480: 66 72 65 65 44 69 67 65 73 74 28 44 69 67 65 73  freeDigest(Diges
0490: 74 20 6f 62 6a 29 3b 0a 0a 2f 2a 2a 0a 20 2a 20  t obj);../**. * 
04a0: 43 6f 6d 70 61 72 65 73 20 74 77 6f 20 44 69 67  Compares two Dig
04b0: 65 73 74 20 69 6e 73 74 61 6e 63 65 73 2e 0a 20  est instances.. 
04c0: 2a 20 40 70 61 72 61 6d 20 20 6f 62 6a 31 20 20  * @param  obj1  
04d0: 66 69 72 73 74 20 6f 62 6a 65 63 74 20 74 6f 20  first object to 
04e0: 63 6f 6d 70 61 72 65 0a 20 2a 20 40 70 61 72 61  compare. * @para
04f0: 6d 20 20 6f 62 6a 32 20 20 73 65 63 6f 6e 64 20  m  obj2  second 
0500: 6f 62 6a 65 63 74 20 74 6f 20 63 6f 6d 70 61 72  object to compar
0510: 65 0a 20 2a 20 40 72 65 74 75 72 6e 20 20 31 20  e. * @return  1 
0520: 69 66 20 6f 62 6a 65 63 74 73 20 61 72 65 20 65  if objects are e
0530: 71 75 61 6c 2c 20 30 20 6f 74 68 65 72 77 69 73  qual, 0 otherwis
0540: 65 0a 20 2a 2f 0a 69 6e 74 20 63 6f 6d 70 61 72  e. */.int compar
0550: 65 44 69 67 65 73 74 73 28 44 69 67 65 73 74 20  eDigests(Digest 
0560: 6f 62 6a 31 2c 20 44 69 67 65 73 74 20 6f 62 6a  obj1, Digest obj
0570: 32 29 3b 0a 0a 2f 2a 2a 0a 20 2a 20 43 61 6c 63  2);../**. * Calc
0580: 75 6c 61 74 65 73 20 68 61 73 68 63 6f 64 65 20  ulates hashcode 
0590: 66 6f 72 20 44 69 67 65 73 74 2e 0a 20 2a 20 40  for Digest.. * @
05a0: 70 61 72 61 6d 20 20 6f 62 6a 20 20 6f 62 6a 65  param  obj  obje
05b0: 63 74 20 74 6f 20 63 61 6c 63 75 6c 61 74 65 20  ct to calculate 
05c0: 68 61 73 68 20 63 6f 64 65 0a 20 2a 2f 0a 69 6e  hash code. */.in
05d0: 74 20 68 61 73 68 63 6f 64 65 46 6f 72 44 69 67  t hashcodeForDig
05e0: 65 73 74 28 44 69 67 65 73 74 20 6f 62 6a 29 3b  est(Digest obj);
05f0: 0a 0a 23 65 6e 64 69 66 20 2f 2a 20 44 49 47 45  ..#endif /* DIGE
0600: 53 54 5f 48 20 2a 2f 0a                          ST_H */.