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