]> cvs.zerfleddert.de Git - rsbs2/blobdiff - rsb-lz.c
add correct handle to sensorpropget requests
[rsbs2] / rsb-lz.c
index 2e50252d2f1786266a114ac3bdd197a7147ff91e..bb735d6cebaf040b318eae11fa88ec4c9f67a2fb 100644 (file)
--- a/rsb-lz.c
+++ b/rsb-lz.c
@@ -271,9 +271,8 @@ unsigned int crc_check(unsigned char *buf, unsigned int len, unsigned int magic)
        return 0;
 }
 
-void extract_lz_file(unsigned char *inbuf, unsigned char *name, unsigned char check_crc)
+unsigned char *extract_lz_file(unsigned char *inbuf, unsigned int *outlen , unsigned char check_crc)
 {
-       unsigned int len;
        unsigned char *outbuf;
        struct data_in_s data_in;
        struct data_out_s data_out;
@@ -281,23 +280,23 @@ void extract_lz_file(unsigned char *inbuf, unsigned char *name, unsigned char ch
        if (*((unsigned int*)inbuf) != LZ_MAGIC)
                err_exit(__func__);
 
-       len = *((unsigned int*)(inbuf + 4));
-       printf(", length: %d", len);
+       *outlen = *((unsigned int*)(inbuf + 4));
+       printf(", length: %d", *outlen);
 
-       if ((outbuf = malloc(len)) == NULL) {
+       if ((outbuf = malloc(*outlen)) == NULL) {
                perror("malloc");
                exit(1);
        }
 
-       bzero(outbuf, len);
+       bzero(outbuf, *outlen);
 
        data_in.start = inbuf + 8;
-       data_in.stop = inbuf + len;
+       data_in.stop = inbuf + *outlen;
        data_in.byte = 0x00;
        data_in.bitpos = 0x80;
 
        data_out.pos = outbuf;
-       data_out.end = outbuf + len;
+       data_out.end = outbuf + *outlen;
 
        lz_expand(&data_in, &data_out);
 
@@ -313,7 +312,5 @@ void extract_lz_file(unsigned char *inbuf, unsigned char *name, unsigned char ch
                }
        }
 
-       write_file((char*)name, outbuf, len);
-       
-       free(outbuf);
+       return outbuf;
 }
Impressum, Datenschutz