core: Add files to blob list on scan
Signed-off-by: Chloe M. <chloe@mirocom.org>
This commit is contained in:
@@ -3,11 +3,25 @@
|
||||
* Provided under the BSD-3 clause
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "blobchain/blob.h"
|
||||
#include "blobchain/memlib.h"
|
||||
|
||||
static void
|
||||
dump_bytes(void *buf, size_t len)
|
||||
{
|
||||
char *p = buf;
|
||||
size_t i = 0;
|
||||
|
||||
while ((i++) < len) {
|
||||
printf("%02X ", p[i] & 0xFF);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int
|
||||
blob_list_init(struct blob_list *lp)
|
||||
{
|
||||
@@ -65,3 +79,27 @@ blob_list_destroy(struct blob_list *lp)
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
blob_list_dump(struct blob_list *lp)
|
||||
{
|
||||
const size_t DUMP_SIZE = 4;
|
||||
struct blob *blob;
|
||||
size_t count = 0;
|
||||
|
||||
if (lp == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
blob = lp->head;
|
||||
while (blob != NULL) {
|
||||
printf("blob %zd/%zd\n", count++, lp->count);
|
||||
printf("... length :: %zd\n", blob->length);
|
||||
printf("... data :: ");
|
||||
dump_bytes(blob->data, blob->length < DUMP_SIZE
|
||||
? blob->length
|
||||
: DUMP_SIZE);
|
||||
|
||||
blob = blob->next;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user