]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/filed/chksum.h
This commit was manufactured by cvs2svn to create tag
[bacula/bacula] / bacula / src / filed / chksum.h
1 /*
2  * General routines for handling the various checksum supported.
3  */
4 /*
5    Copyright (C) 2000-2005 Kern Sibbald
6
7    This program is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License
9    version 2 as amended with additional clauses defined in the
10    file LICENSE in the main source directory.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
15    the file LICENSE for additional details.
16
17  */
18
19 #ifndef _CHKSUM_H_
20 #define _CHKSUM_H_
21
22 #include "bacula.h"
23
24 /*
25  * Link these to findlib options. Doing so allows for simpler handling of
26  * signatures in the callers.
27  * If multiple signatures are specified, the order in chksum_init() matters.
28  * Still, spell out our own names in case we want to change the approach.
29  */
30 #define CHKSUM_NONE     0
31 #define CHKSUM_MD5      FO_MD5
32 #define CHKSUM_SHA1     FO_SHA1
33
34 union chksumContext {
35    MD5Context  md5;
36    SHA1Context sha1;
37 };
38
39 struct CHKSUM {
40    int            type;                /* One of CHKSUM_* above */
41    char           name[5];             /* Big enough for NONE, MD5, SHA1, etc. */
42    bool           updated;             /* True if updated by chksum_update() */
43    chksumContext  context;             /* Context for the algorithm at hand */
44    int            length;              /* Length of signature */
45    unsigned char  signature[30];       /* Large enough for either signature */
46 };
47
48 int chksum_init(CHKSUM *chksum, int flags);
49 int chksum_update(CHKSUM *chksum, void *buf, unsigned len);
50 int chksum_final(CHKSUM *chksum);
51
52 #endif