summaryrefslogtreecommitdiff
path: root/v4l2-apps/util/xc3028-firmware/firmware-tool.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2008-02-20 05:37:56 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-02-20 05:37:56 -0300
commitb8fc485e6b70590178b108ef66e954d175c322fe (patch)
treec16b203c87a9b8a012bccf8fdb8d4def788b1ce7 /v4l2-apps/util/xc3028-firmware/firmware-tool.c
parent979f7d3a3f3ca4d1a95209513038a785d6c85d7c (diff)
downloadmediapointer-dvb-s2-b8fc485e6b70590178b108ef66e954d175c322fe.tar.gz
mediapointer-dvb-s2-b8fc485e6b70590178b108ef66e954d175c322fe.tar.bz2
firmware-tool: add --write option to --list
From: Mauro Carvalho Chehab <mchehab@infradead.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'v4l2-apps/util/xc3028-firmware/firmware-tool.c')
-rw-r--r--v4l2-apps/util/xc3028-firmware/firmware-tool.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/v4l2-apps/util/xc3028-firmware/firmware-tool.c b/v4l2-apps/util/xc3028-firmware/firmware-tool.c
index 768f03db4..de1262ceb 100644
--- a/v4l2-apps/util/xc3028-firmware/firmware-tool.c
+++ b/v4l2-apps/util/xc3028-firmware/firmware-tool.c
@@ -512,7 +512,7 @@ void list_firmware_desc(FILE *fp, struct firmware_description *desc)
fprintf(fp, "size: %u\n", desc->size);
}
-void list_firmware(struct firmware *f, unsigned int dump)
+void list_firmware(struct firmware *f, unsigned int dump, char *binfile)
{
unsigned int i = 0;
@@ -538,6 +538,28 @@ void list_firmware(struct firmware *f, unsigned int dump)
}
printf("\n");
}
+ if (binfile) {
+ char name[strlen(binfile)+4], *p;
+ p = strrchr(binfile,'.');
+ if (p) {
+ int n = p - binfile;
+ strncpy(name, binfile, n);
+ sprintf(name + n, "%03i", i);
+ strcat(name, p);
+ } else {
+ strcpy(name, binfile);
+ sprintf(name + strlen(name), "%03i", i);
+ }
+ FILE *fp;
+
+ fp = fopen(name,"w");
+ if (!fp) {
+ perror("Opening file to write");
+ return;
+ }
+ fwrite(f->desc[i].data, f->desc[i].size, 1, fp);
+ fclose(fp);
+ }
}
}
@@ -903,11 +925,11 @@ void seek_firmware(struct firmware *f, char *seek_file, char *write_file) {
f->desc[i].size);
while (hunk) {
if (hunk->data) {
- int j;
+ int k;
fprintf(fp, "\tsyswrite(OUTFILE, ");
- for (j = 0; j < hunk->size; j++) {
- fprintf(fp, "chr(%d)", hunk->data[j]);
- if (j < hunk->size-1)
+ for (k = 0; k < hunk->size; k++) {
+ fprintf(fp, "chr(%d)", hunk->data[k]);
+ if (k < hunk->size-1)
fprintf(fp,".");
}
fprintf(fp,");\n");
@@ -933,7 +955,7 @@ void seek_firmware(struct firmware *f, char *seek_file, char *write_file) {
void print_usage(void)
{
printf("firmware-tool usage:\n");
- printf("\t firmware-tool --list [--dump] <firmware-file>\n");
+ printf("\t firmware-tool --list [--dump] [--write <bin-file>] <firmware-file>\n");
printf("\t firmware-tool --add <firmware-dump> <firmware-file>\n");
printf("\t firmware-tool --delete <index> <firmware-file>\n");
printf("\t firmware-tool --type <type> --index <i> <firmware-file>\n");
@@ -1057,7 +1079,7 @@ int main(int argc, char* argv[])
switch(action) {
case LIST_ACTION:
- list_firmware(f, dump);
+ list_firmware(f, dump, write_file);
break;
case ADD_ACTION: