Aegis  4.25.D505
common/fp.h
Go to the documentation of this file.
00001 //
00002 //      cook - file construction tool
00003 //      Copyright (C) 1994, 2003-2006, 2008 Peter Miller.
00004 //
00005 //      This program is free software; you can redistribute it and/or modify
00006 //      it under the terms of the GNU General Public License as published by
00007 //      the Free Software Foundation; either version 3 of the License, or
00008 //      (at your option) any later version.
00009 //
00010 //      This program is distributed in the hope that it will be useful,
00011 //      but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 //      GNU General Public License for more details.
00014 //
00015 //      You should have received a copy of the GNU General Public License
00016 //      along with this program. If not, see
00017 //      <http://www.gnu.org/licenses/>.
00018 //
00019 
00020 #ifndef COMMON_FP_H
00021 #define COMMON_FP_H
00022 
00023 #include <common/ac/stddef.h>
00024 
00030 struct fingerprint_methods_ty; // forward
00031 
00032 #define FINGERPRINT_BASE_CLASS \
00033         struct fingerprint_methods_ty *method;
00034 
00035 struct fingerprint_ty
00036 {
00037         FINGERPRINT_BASE_CLASS
00038 };
00039 
00040 struct fingerprint_methods_ty
00041 {
00042     long            size;
00043     const char      *name;
00044     void            (*constructor)(fingerprint_ty *);
00045     void            (*destructor)(fingerprint_ty *);
00046     void            (*addn)(fingerprint_ty *, unsigned char *, size_t);
00047     int             (*hash)(fingerprint_ty *, unsigned char *);
00048     void            (*sum)(fingerprint_ty *, char *, size_t);
00049 };
00050 
00051 fingerprint_ty *fingerprint_new(fingerprint_methods_ty *);
00052 void fingerprint_delete(fingerprint_ty *);
00053 void fingerprint_add(fingerprint_ty *, int);
00054 int fingerprint_file_hash(fingerprint_ty *, const char *, unsigned char *);
00055 int fingerprint_file_sum(fingerprint_ty *, const char *, char *, size_t);
00056 
00057 #define fingerprint_addn(p, s, n) \
00058         (p)->method->addn((p), (s), (n))
00059 #define fingerprint_hash(p, s) \
00060         (p)->method->hash((p), (s))
00061 #define fingerprint_sum(p, s, len) \
00062         (p)->method->sum((p), (s), (len))
00063 
00065 #endif // COMMON_FP_H