fiasco: Added function fiasco_print_info, fixed fiasco_free
This commit is contained in:
1 parent
4de49acb49
commit
366680af1b
2 files changed
+28
-14
No files matched your search
+26
-14
@@ -85,6 +85,8 @@ struct fiasco * fiasco_alloc_from_file(const char * file) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fiasco->orig_filename = strdup(file);
|
||||||
|
|
||||||
READ_OR_FAIL(fiasco, &byte, 1);
|
READ_OR_FAIL(fiasco, &byte, 1);
|
||||||
if ( byte != 0xb4 )
|
if ( byte != 0xb4 )
|
||||||
FIASCO_READ_ERROR(fiasco, "Invalid fiasco signature");
|
FIASCO_READ_ERROR(fiasco, "Invalid fiasco signature");
|
||||||
@@ -254,6 +256,11 @@ void fiasco_free(struct fiasco * fiasco) {
|
|||||||
list = next;
|
list = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( fiasco->fd >= 0 )
|
||||||
|
close(fiasco->fd);
|
||||||
|
|
||||||
|
free(fiasco->orig_filename);
|
||||||
|
|
||||||
free(fiasco);
|
free(fiasco);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -520,18 +527,7 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) {
|
|||||||
name = image_name_alloc_from_values(image);
|
name = image_name_alloc_from_values(image);
|
||||||
|
|
||||||
printf("Unpacking image...\n");
|
printf("Unpacking image...\n");
|
||||||
printf(" hash: %#04x\n", image->hash);
|
image_print_info(image);
|
||||||
printf(" size: %d bytes\n", image->size);
|
|
||||||
|
|
||||||
if ( image->type )
|
|
||||||
printf(" type: %s\n", image_type_to_string(image->type));
|
|
||||||
|
|
||||||
if ( image->device )
|
|
||||||
printf(" device: %s\n", device_to_string(image->device));
|
|
||||||
if ( image->hwrevs )
|
|
||||||
printf(" hwrevs: %s\n", image->hwrevs);
|
|
||||||
if ( image->version )
|
|
||||||
printf(" version: %s\n", image->version);
|
|
||||||
|
|
||||||
if ( image->layout ) {
|
if ( image->layout ) {
|
||||||
|
|
||||||
@@ -543,11 +539,11 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) {
|
|||||||
|
|
||||||
sprintf(layout_name, "%s.layout", name);
|
sprintf(layout_name, "%s.layout", name);
|
||||||
|
|
||||||
printf(" layout file: %s\n", layout_name);
|
printf(" Layout file: %s\n", layout_name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" output file: %s\n", name);
|
printf(" Output file: %s\n", name);
|
||||||
|
|
||||||
fd = open(name, O_RDWR|O_CREAT|O_TRUNC, 0644);
|
fd = open(name, O_RDWR|O_CREAT|O_TRUNC, 0644);
|
||||||
if ( fd < 0 ) {
|
if ( fd < 0 ) {
|
||||||
@@ -585,6 +581,9 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) {
|
|||||||
|
|
||||||
image_list = image_list->next;
|
image_list = image_list->next;
|
||||||
|
|
||||||
|
if ( image_list )
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( dir ) {
|
if ( dir ) {
|
||||||
@@ -599,3 +598,16 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fiasco_print_info(struct fiasco * fiasco) {
|
||||||
|
|
||||||
|
if ( fiasco->orig_filename )
|
||||||
|
printf("File: %s\n", fiasco->orig_filename);
|
||||||
|
|
||||||
|
if ( fiasco->name[0] )
|
||||||
|
printf(" Fiasco Name: %s\n", fiasco->name);
|
||||||
|
|
||||||
|
if ( fiasco->swver[0] )
|
||||||
|
printf(" Fiasco Software release version: %s\n", fiasco->swver);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ struct fiasco {
|
|||||||
char name[257];
|
char name[257];
|
||||||
char swver[257];
|
char swver[257];
|
||||||
int fd;
|
int fd;
|
||||||
|
char * orig_filename;
|
||||||
struct image_list * first;
|
struct image_list * first;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -36,5 +37,6 @@ void fiasco_free(struct fiasco * fiasco);
|
|||||||
void fiasco_add_image(struct fiasco * fiasco, struct image * image);
|
void fiasco_add_image(struct fiasco * fiasco, struct image * image);
|
||||||
int fiasco_write_to_file(struct fiasco * fiasco, const char * file);
|
int fiasco_write_to_file(struct fiasco * fiasco, const char * file);
|
||||||
int fiasco_unpack(struct fiasco * fiasco, const char * dir);
|
int fiasco_unpack(struct fiasco * fiasco, const char * dir);
|
||||||
|
void fiasco_print_info(struct fiasco * fiasco);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in new issue
Block a user