Changeset 37

Show
Ignore:
Timestamp:
11/09/07 16:18:49 (1 year ago)
Author:
nlawren2
Message:

xdelta test working, please please please let me commit

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • vowfsc/Makefile

    r34 r37  
    1 db: 
     1current: xdelta 
     2        @echo made $@ 
     3 
     4db: db.c db.h file.db dir.db stream.db 
    25        gcc db.c -o db 
     6 
     7xdelta: xdelta.o xdelta3.o 
     8        gcc xdelta.o xdelta3.o -o xdelta 
     9 
     10xdelta3.o: xdelta3.c xdelta3.h xdelta3-cfgs.h xdelta3-list.h xdelta3-decode.h 
     11        gcc xdelta3.c -c 
     12 
     13xdelta.o: xdelta.c 
     14        gcc xdelta.c -c 
  • vowfsc/db.h

    r35 r37  
    7272char *db_get_file_stream( int file_id, int revision ); // TODO 
    7373 
     74/* Looks first to see if the given stream exists, and 
     75 * returns it's stream id if it does.  If not, it creates 
     76 * a new stream and returns the new stream's id. 
     77 */ 
     78int db_create_stream( char *stream_name, char *stream ); // TODO 
    7479 
    7580/* Sets the delete flag in the file 
  • vowfsc/xdelta.c

    r36 r37  
    1 #include "xdelta.h" 
     1#include "xdelta3.h" 
     2#include <stdio.h> 
     3#include <stdlib.h> 
     4#include <sys/types.h> 
    25 
    3 char *diff( char *old_file, char *new_file, usize_t *diff_size) 
    4 
    5         int size=strlen(old_file); 
    6         usize_t avail_output = (size > XD3_ALLOCSIZE ) ? size : XD3_ALLOCSIZE; 
    7         uint8_t *output_buffer = malloc(avail_output); 
    8         usize_t output_size
     6int main(int argc, char **argv){ 
     7        char *string1=strdup("Most folks are about as happy as they make up their minds to be."); 
     8        char *string2=strdup("The secret of happiness is to make others believe they are the cause of it."); 
     9         
     10        int string1_len=strlen(string1); 
     11        int string2_len=strlen(string2)
    912 
    10         xd3_encode_memory(old_file, 
    11                            strlen(old_file), 
    12                            new_file, 
    13                            strlen(new_file), 
    14                            output_buffer, 
    15                            &output_size, 
    16                            avail_output, 
    17                            0); 
     13        printf("String 1: %s(%i)\n",string1,string1_len); 
     14        printf("String 2: %s(%i)\n",string2,string2_len); 
    1815 
    19         diff_size = output_size; 
     16        char *diff=malloc(XD3_ALLOCSIZE); 
     17        int diff_len; 
    2018 
    21         return output_buffer; 
     19        xd3_encode_memory(string1, string1_len, 
     20                          string2, string2_len, 
     21                          diff, &diff_len, XD3_ALLOCSIZE, 
     22                          0); 
     23         
     24        char *output=malloc(XD3_ALLOCSIZE); 
     25        int output_len; 
     26         
     27        printf("Diff( String1 -> String2 ): %s(%i)\n",diff,diff_len); 
     28         
     29        xd3_decode_memory(diff, diff_len, 
     30                          string2, string2_len, 
     31                          output, &output_len, XD3_ALLOCSIZE, 
     32                          0); 
     33         
     34        printf("Output( Diff -> String2): %s(%i)\n",output,output_len); 
     35 
     36 
     37        free(string1); 
     38        free(string2); 
     39        free(diff); 
     40        free(output); 
     41        return 0; 
    2242} 
    23  
    24 char *patch( char *old_file, char *diff, usize_t *new_size) 
    25 { 
    26         int size=strlen(old_file); 
    27         usize_t avail_output = (size > XD3_ALLOCSIZE ) ? size : XD3_ALLOCSIZE; 
    28         uint8_t *output_buffer = malloc(avail_output); 
    29         usize_t output_size; 
    30  
    31         xd3_decode_memory(old_file, 
    32                            strlen(old_file), 
    33                            diff, 
    34                            strlen(diff), 
    35                            output_buffer, 
    36                            &output_size, 
    37                            avail_output, 
    38                            0); 
    39  
    40         new_size = output_size; 
    41  
    42         return output_buffer; 
    43 } 
    44  
    45 int main(int argc, char *argv[]) 
    46 { 
    47         if (argc < 3) 
    48         { 
    49                 printf("error\n"); 
    50                 return -1; 
    51         } 
    52         else 
    53         { 
    54                 usize_t *diff_size; 
    55                 uint8_t *diff_out = malloc(1000); 
    56                 diff_out = diff(argv[1] , argv[2], &diff_size); 
    57                 printf("%s\n",diff_out); 
    58                 printf("%s\n",patch(argv[2], diff_out, diff_size)); 
    59         } 
    60 }