]> cvs.zerfleddert.de Git - rsbs2/blobdiff - rsb-lz.c
typo in error message
[rsbs2] / rsb-lz.c
index f5a84fa55832020cead7d92285c8e0502c12d46f..3e6e63820f6ab8c5251b367cac208e6c7d56f6b5 100644 (file)
--- a/rsb-lz.c
+++ b/rsb-lz.c
@@ -2,9 +2,11 @@
 #include <stdlib.h>
 #include <strings.h>
 #include <string.h>
+#include <unistd.h>
 #include <errno.h>
 #include "rsb-crc.h"
 #include "rsb-lz.h"
+#include "extract.h"
 
 /* TODO: IMPLEMET THIS! */
 /* Probably very broken lzw implementation by Agilent:
  * 59b80:      46335053        undefined
  */
 
-static unsigned char *outbuf = NULL;
-
 void fn_59788(const char *fname)
 {
        fprintf(stderr,"%s: error extracting...\n", fname);
-       fprintf(stderr,"outbuf at: %p\n", outbuf);
-       fprintf(stderr,"%s\n", outbuf);
        exit(1);
 }
 
@@ -613,9 +611,11 @@ unsigned int crc_check_59684(unsigned char *arg1, unsigned int arg2, unsigned in
                return 1;
 #endif
 
+       /* ??? */
        r4 = *((unsigned int*)arg1 + 0x20);
        r5 = *((unsigned int*)arg1 + 0x24);
 
+       printf("magic: 0x%08x <-> 0x%08x\n", r5, magic);
        if (r5 != magic)
                return 2;
        
@@ -634,11 +634,6 @@ unsigned int crc_check_59684(unsigned char *arg1, unsigned int arg2, unsigned in
        return 4;
 }
 
-void fn_59508()
-{
-       fprintf(stderr,"%s\n", __func__);
-}
-
 void extract_lz_file(unsigned char *buf, unsigned char *name)
 {
        unsigned char *r3;
@@ -649,23 +644,19 @@ void extract_lz_file(unsigned char *buf, unsigned char *name)
        struct s_59b78 struct1;
        unsigned int arr_59b7c[1024];
 
-       r7 = malloc(4*1024*1024);
-       r10 = r7 + (4*1024*1024);
-
-       if (r7 == NULL) {
-               perror("malloc");
-               exit(1);
-       }
-
-       bzero(r7, 4*1024*1024);
-       outbuf = r7;
-
        if (*((unsigned int*)r11) != LZ_MAGIC)
                fn_59788(__func__);
 
        r3 = r11 + 4;
        r5 = *((unsigned int*)r3);
-       printf(", length: %d\n", r5);
+       printf(", length: %d", r5);
+
+       if ((r7 = malloc(r5)) == NULL) {
+               perror("malloc");
+               exit(1);
+       }
+       r10 = r7 + r5;
+       bzero(r7, r5);
 
        r3 = r7 + r5;
        if (r3 > r10)
@@ -681,40 +672,18 @@ void extract_lz_file(unsigned char *buf, unsigned char *name)
 
        fn_5993c(&struct1, arr_59b7c);
 
+#if 0
+       /* This seems to still be completely broken */
        r3 = r7 + 0x20;
        r5 = *((unsigned int*)r3);
 
-       if (crc_check_59684(r7, r5, 0x46335053) != 0)
+       if ((ret = crc_check_59684(r7, r5, 0x46335053)) != 0) {
+               printf("crc_check return: %d\n", ret);
                fn_59788(__func__);
-       
-       fn_59508();
+       }
+#endif
 
+       write_file((char*)name, r7, r5);
+       
        free(r7);
 }
-
-void search_lz_sections(unsigned char *fw, int len)
-{
-       int i;
-       unsigned char *j;
-
-       for(i = 0; i < len - 4; i++) {
-               if (*((unsigned int*)(fw+i)) == LZ_MAGIC) {
-                       j = fw + i - 1;
-                       if (*j != 0x00)
-                               continue;
-                       printf("0x%02x: ", i);
-                       j--;
-                       while (j > fw) {
-                               if (*j == 0x00) {
-                                       if (strncmp("/web", (char*)(j+1), 4))
-                                               break;
-                                       printf("%s", j+1);
-                                       extract_lz_file(fw + i, j+1);
-                                       break;
-                               }
-                               j--;
-                       }
-                       printf("\n");
-               }
-       }
-}
Impressum, Datenschutz