summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2012-08-09 16:05:44 +0200
committerPali Rohár <pali.rohar@gmail.com>2012-08-09 16:05:44 +0200
commit366680af1b1476ac26dcbbe888d89f7012fd0c01 (patch)
treeefc4e0fea9a309bf7372059590d291954d82de70 /src
parent4de49acb4949a9a35fee3b97ee706fed4e3b6e1a (diff)
download0xFFFF-366680af1b1476ac26dcbbe888d89f7012fd0c01.tar.bz2
fiasco: Added function fiasco_print_info, fixed fiasco_free
Diffstat (limited to 'src')
-rw-r--r--src/fiasco2.c40
-rw-r--r--src/fiasco2.h2
2 files changed, 28 insertions, 14 deletions
diff --git a/src/fiasco2.c b/src/fiasco2.c
index 1b7fe4b..bd27764 100644
--- a/src/fiasco2.c
+++ b/src/fiasco2.c
@@ -85,6 +85,8 @@ struct fiasco * fiasco_alloc_from_file(const char * file) {
return NULL;
}
+ fiasco->orig_filename = strdup(file);
+
READ_OR_FAIL(fiasco, &byte, 1);
if ( byte != 0xb4 )
FIASCO_READ_ERROR(fiasco, "Invalid fiasco signature");
@@ -254,6 +256,11 @@ void fiasco_free(struct fiasco * fiasco) {
list = next;
}
+ if ( fiasco->fd >= 0 )
+ close(fiasco->fd);
+
+ free(fiasco->orig_filename);
+
free(fiasco);
}
@@ -520,18 +527,7 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) {
name = image_name_alloc_from_values(image);
printf("Unpacking image...\n");
- printf(" hash: %#04x\n", image->hash);
- 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);
+ image_print_info(image);
if ( image->layout ) {
@@ -543,11 +539,11 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) {
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);
if ( fd < 0 ) {
@@ -585,6 +581,9 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) {
image_list = image_list->next;
+ if ( image_list )
+ printf("\n");
+
}
if ( dir ) {
@@ -599,3 +598,16 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) {
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);
+
+}
diff --git a/src/fiasco2.h b/src/fiasco2.h
index 36c000d..43c7954 100644
--- a/src/fiasco2.h
+++ b/src/fiasco2.h
@@ -27,6 +27,7 @@ struct fiasco {
char name[257];
char swver[257];
int fd;
+ char * orig_filename;
struct image_list * first;
};
@@ -36,5 +37,6 @@ void fiasco_free(struct fiasco * fiasco);
void fiasco_add_image(struct fiasco * fiasco, struct image * image);
int fiasco_write_to_file(struct fiasco * fiasco, const char * file);
int fiasco_unpack(struct fiasco * fiasco, const char * dir);
+void fiasco_print_info(struct fiasco * fiasco);
#endif