Migrated integrity_checker_t to INIT/METHOD macros
This commit is contained in:
@@ -57,11 +57,8 @@ struct private_integrity_checker_t {
|
||||
int checksum_count;
|
||||
};
|
||||
|
||||
/**
|
||||
* Implementation of integrity_checker_t.build_file
|
||||
*/
|
||||
static u_int32_t build_file(private_integrity_checker_t *this, char *file,
|
||||
size_t *len)
|
||||
METHOD(integrity_checker_t, build_file, u_int32_t,
|
||||
private_integrity_checker_t *this, char *file, size_t *len)
|
||||
{
|
||||
u_int32_t checksum;
|
||||
chunk_t contents;
|
||||
@@ -136,11 +133,8 @@ static int callback(struct dl_phdr_info *dlpi, size_t size, Dl_info *dli)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of integrity_checker_t.build_segment
|
||||
*/
|
||||
static u_int32_t build_segment(private_integrity_checker_t *this, void *sym,
|
||||
size_t *len)
|
||||
METHOD(integrity_checker_t, build_segment, u_int32_t,
|
||||
private_integrity_checker_t *this, void *sym, size_t *len)
|
||||
{
|
||||
chunk_t segment;
|
||||
Dl_info dli;
|
||||
@@ -180,11 +174,8 @@ static integrity_checksum_t *find_checksum(private_integrity_checker_t *this,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of integrity_checker_t.check_file
|
||||
*/
|
||||
static bool check_file(private_integrity_checker_t *this,
|
||||
char *name, char *file)
|
||||
METHOD(integrity_checker_t, check_file, bool,
|
||||
private_integrity_checker_t *this, char *name, char *file)
|
||||
{
|
||||
integrity_checksum_t *cs;
|
||||
u_int32_t sum;
|
||||
@@ -217,11 +208,8 @@ static bool check_file(private_integrity_checker_t *this,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of integrity_checker_t.check_segment
|
||||
*/
|
||||
static bool check_segment(private_integrity_checker_t *this,
|
||||
char *name, void *sym)
|
||||
METHOD(integrity_checker_t, check_segment, bool,
|
||||
private_integrity_checker_t *this, char *name, void *sym)
|
||||
{
|
||||
integrity_checksum_t *cs;
|
||||
u_int32_t sum;
|
||||
@@ -254,10 +242,8 @@ static bool check_segment(private_integrity_checker_t *this,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of integrity_checker_t.check
|
||||
*/
|
||||
static bool check(private_integrity_checker_t *this, char *name, void *sym)
|
||||
METHOD(integrity_checker_t, check, bool,
|
||||
private_integrity_checker_t *this, char *name, void *sym)
|
||||
{
|
||||
Dl_info dli;
|
||||
|
||||
@@ -277,10 +263,8 @@ static bool check(private_integrity_checker_t *this, char *name, void *sym)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of integrity_checker_t.destroy.
|
||||
*/
|
||||
static void destroy(private_integrity_checker_t *this)
|
||||
METHOD(integrity_checker_t, destroy, void,
|
||||
private_integrity_checker_t *this)
|
||||
{
|
||||
if (this->handle)
|
||||
{
|
||||
@@ -294,17 +278,19 @@ static void destroy(private_integrity_checker_t *this)
|
||||
*/
|
||||
integrity_checker_t *integrity_checker_create(char *checksum_library)
|
||||
{
|
||||
private_integrity_checker_t *this = malloc_thing(private_integrity_checker_t);
|
||||
private_integrity_checker_t *this;
|
||||
|
||||
this->public.check_file = (bool(*)(integrity_checker_t*, char *name, char *file))check_file;
|
||||
this->public.build_file = (u_int32_t(*)(integrity_checker_t*, char *file, size_t *len))build_file;
|
||||
this->public.check_segment = (bool(*)(integrity_checker_t*, char *name, void *sym))check_segment;
|
||||
this->public.build_segment = (u_int32_t(*)(integrity_checker_t*, void *sym, size_t *len))build_segment;
|
||||
this->public.check = (bool(*)(integrity_checker_t*, char *name, void *sym))check;
|
||||
this->public.destroy = (void(*)(integrity_checker_t*))destroy;
|
||||
INIT(this,
|
||||
.public = {
|
||||
.check_file = _check_file,
|
||||
.build_file = _build_file,
|
||||
.check_segment = _check_segment,
|
||||
.build_segment = _build_segment,
|
||||
.check = _check,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
);
|
||||
|
||||
this->checksum_count = 0;
|
||||
this->handle = NULL;
|
||||
if (checksum_library)
|
||||
{
|
||||
this->handle = dlopen(checksum_library, RTLD_LAZY);
|
||||
|
||||
Reference in New Issue
Block a user