root/vowfsc/xdelta.c

Revision 54, 1.2 kB (checked in by nlawren2, 10 months ago)

Fixed more stuff

Line 
1 #include "xdelta3.h"
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <sys/types.h>
5
6 int 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);
12
13         printf("String 1: %s(%i)\n",string1,string1_len);
14         printf("String 2: %s(%i)\n",string2,string2_len);
15
16         char *diff=malloc(XD3_ALLOCSIZE);
17         int diff_len;
18
19         xd3_encode_memory(string2, string2_len,
20                           string1, string1_len,
21                           diff, &diff_len, XD3_ALLOCSIZE,
22                           0);
23        
24         char *output=malloc(XD3_ALLOCSIZE);
25         int output_len;
26        
27         printf("Diff( String2 -> String1 ): %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         xd3_decode_memory(diff, diff_len,
37                           string1, string1_len,
38                           output, &output_len, XD3_ALLOCSIZE,
39                           0);
40        
41         printf("Output( Diff -> String1 ): %s(%i)\n",output,output_len);
42
43
44
45         free(string1);
46         free(string2);
47         free(diff);
48         free(output);
49         return 0;
50 }
Note: See TracBrowser for help on using the browser.