]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/filed/chksum.h
- Copy latest config.sub and config.guess from autoconf.
[bacula/bacula] / bacula / src / filed / chksum.h
1 /*
2  * General routines for handling the various checksum supported.
3  */
4
5 /*
6    Copyright (C) 2004 Kern Sibbald
7
8    This program is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2 of
11    the License, or (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public
19    License along with this program; if not, write to the Free
20    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21    MA 02111-1307, USA.
22
23  */
24
25 #ifndef _CHKSUM_H_
26 #define _CHKSUM_H_
27
28 #include "bacula.h"
29
30 /*
31  * Link these to findlib options. Doing so allows for simpler handling of
32  * signatures in the callers.
33  * If multiple signatures are specified, the order in chksum_init() matters.
34  * Still, spell out our own names in case we want to change the approach.
35  */
36 #define CHKSUM_NONE     0
37 #define CHKSUM_MD5      FO_MD5
38 #define CHKSUM_SHA1     FO_SHA1
39
40 union chksumContext {
41    MD5Context  md5;
42    SHA1Context sha1;
43 };
44
45 struct CHKSUM {
46    int            type;                /* One of CHKSUM_* above */
47    char           name[5];             /* Big enough for NONE, MD5, SHA1, etc. */
48    bool           updated;             /* True if updated by chksum_update() */
49    chksumContext  context;             /* Context for the algorithm at hand */
50    int            length;              /* Length of signature */
51    unsigned char  signature[30];       /* Large enough for either signature */
52 };
53
54 int chksum_init(CHKSUM *chksum, int flags);
55 int chksum_update(CHKSUM *chksum, void *buf, unsigned len);
56 int chksum_final(CHKSUM *chksum);
57
58 #endif