00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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;
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