Changeset 40

Show
Ignore:
Timestamp:
11/10/07 13:28:27 (1 year ago)
Author:
nlawren2
Message:

Removed the C++ files finally, and finished the code. Debugging time.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • vowfsc/db.c

    r39 r40  
    161161                NUM_FILE_FIELDS = sizeof(file_format)/4; 
    162162 
    163                 if( PQnfields(pq_data) != NUM_FILE_FIELDS ){ 
     163                if( PQnfields(res) != NUM_FILE_FIELDS ){ 
    164164                        NUM_FILE_FIELDS = 0; 
    165165                        return NULL; 
     
    167167 
    168168        // Fill file_format with column numbers 
    169 #define db(type, name)  file_format.name = PQfnumber(pq_data, #name ); 
    170 #define db_string(name) file_format.name = PQfnumber(pq_data, #name ); 
     169#define db(type, name)  file_format.name = PQfnumber(res, #name ); 
     170#define db_string(name) file_format.name = PQfnumber(res, #name ); 
    171171#include "file.db" 
    172172        } 
     
    174174        if( PQresultStatus(res) != PGRES_TUPLES_OK ) return NULL; 
    175175         
    176         if( PQnfields(pq_data) != NUM_FILE_FIELDS ) return NULL; 
     176        if( PQnfields(res) != NUM_FILE_FIELDS ) return NULL; 
    177177 
    178178        // Fill stat 
    179 #define db(type, name)  stat.name = *(type*)PQgetvalue(pq_data, 0, file_format.name ); 
    180 #define db_string(name) stat.name = strdup(PQgetvalue(pq_data, 0, file_format.name )); 
     179#define db(type, name)  stat.name = *(type*)PQgetvalue(res, 0, file_format.name ); 
     180#define db_string(name) stat.name = strdup(PQgetvalue(res, 0, file_format.name )); 
    181181#include "file.db" 
    182182         
     
    201201                NUM_FILE_FIELDS = sizeof(file_format)/4; 
    202202 
    203                 if( PQnfields(pq_data) != NUM_FILE_FIELDS ){ 
     203                if( PQnfields(res) != NUM_FILE_FIELDS ){ 
    204204                        NUM_FILE_FIELDS = 0; 
    205205                        return NULL; 
     
    207207 
    208208        // Fill file_format with column numbers 
    209 #define db(type, name)  file_format.name = PQfnumber(pq_data, #name ); 
    210 #define db_string(name) file_format.name = PQfnumber(pq_data, #name ); 
     209#define db(type, name)  file_format.name = PQfnumber(res, #name ); 
     210#define db_string(name) file_format.name = PQfnumber(res, #name ); 
    211211#include "file.db" 
    212212        } 
     
    214214        if( PQresultStatus(res) != PGRES_TUPLES_OK ) return NULL; 
    215215         
    216         if( PQnfields(pq_data) != NUM_FILE_FIELDS ) return NULL; 
     216        if( PQnfields(res) != NUM_FILE_FIELDS ) return NULL; 
    217217 
    218218        // Fill stat 
    219 #define db(type, name)  stat.name = *(type*)PQgetvalue(pq_data, /*row*/, file_format.name ); 
    220 #define db_string(name) stat.name = strdup(PQgetvalue(pq_data, /*row*/, file_format.name )); 
     219#define db(type, name)  stat.name = *(type*)PQgetvalue(res, /*row*/, file_format.name ); 
     220#define db_string(name) stat.name = strdup(PQgetvalue(res, /*row*/, file_format.name )); 
    221221#include "file.db" 
    222222         
     
    354354                NUM_FILE_FIELDS = sizeof(dir_format)/4; 
    355355 
    356                 if( PQnfields(pq_data) != NUM_FILE_FIELDS ){ 
     356                if( PQnfields(res) != NUM_FILE_FIELDS ){ 
    357357                        NUM_FILE_FIELDS = 0; 
    358358                        return NULL; 
     
    360360 
    361361        // Fill dir_format with column numbers 
    362 #define db(type, name)  dir_format.name = PQfnumber(pq_data, #name ); 
    363 #define db_string(name) dir_format.name = PQfnumber(pq_data, #name ); 
     362#define db(type, name)  dir_format.name = PQfnumber(res, #name ); 
     363#define db_string(name) dir_format.name = PQfnumber(res, #name ); 
    364364#include "dir.db" 
    365365        } 
     
    367367        if( PQresultStatus(res) != PGRES_TUPLES_OK ) return NULL; 
    368368         
    369         if( PQnfields(pq_data) != NUM_FILE_FIELDS ) return NULL; 
     369        if( PQnfields(res) != NUM_FILE_FIELDS ) return NULL; 
    370370 
    371371        // Fill stat 
    372 #define db(type, name)  stat.name = *(type*)PQgetvalue(pq_data, /*row*/, dir_format.name ); 
    373 #define db_string(name) stat.name = strdup(PQgetvalue(pq_data, /*row*/, dir_format.name )); 
     372#define db(type, name)  stat.name = *(type*)PQgetvalue(res, /*row*/, dir_format.name ); 
     373#define db_string(name) stat.name = strdup(PQgetvalue(res, /*row*/, dir_format.name )); 
    374374#include "dir.db" 
    375375         
     
    394394                NUM_FILE_FIELDS = sizeof(dir_format)/4; 
    395395 
    396                 if( PQnfields(pq_data) != NUM_FILE_FIELDS ){ 
     396                if( PQnfields(res) != NUM_FILE_FIELDS ){ 
    397397                        NUM_FILE_FIELDS = 0; 
    398398                        return NULL; 
     
    400400 
    401401        // Fill dir_format with column numbers 
    402 #define db(type, name)  dir_format.name = PQfnumber(pq_data, #name ); 
    403 #define db_string(name) dir_format.name = PQfnumber(pq_data, #name ); 
     402#define db(type, name)  dir_format.name = PQfnumber(res, #name ); 
     403#define db_string(name) dir_format.name = PQfnumber(res, #name ); 
    404404#include "dir.db" 
    405405        } 
     
    407407        if( PQresultStatus(res) != PGRES_TUPLES_OK ) return NULL; 
    408408         
    409         if( PQnfields(pq_data) != NUM_FILE_FIELDS ) return NULL; 
     409        if( PQnfields(res) != NUM_FILE_FIELDS ) return NULL; 
    410410 
    411411        // Fill stat 
    412 #define db(type, name)  stat.name = *(type*)PQgetvalue(pq_data, 0, dir_format.name ); 
    413 #define db_string(name) stat.name = strdup(PQgetvalue(pq_data, 0, dir_format.name )); 
     412#define db(type, name)  stat.name = *(type*)PQgetvalue(res, 0, dir_format.name ); 
     413#define db_string(name) stat.name = strdup(PQgetvalue(res, 0, dir_format.name )); 
    414414#include "dir.db" 
    415415         
     
    443443        sprintf(pq_request,"host=%s port=%i dbname=%s user=%s password=%s", host, port, dbname, username, password); 
    444444        pq_conn=PQconnectdb(pq_request); 
     445         
     446        NUM_FILE_FIELDS = 0; 
     447        NUM_DIR_FIELDS = 0; 
     448        NUM_STREAM_FIELDS = 0; 
     449 
    445450        if( PQstatus( pq_conn ) != CONNECTION_OK ) 
    446451                return -1; 
     
    469474                NUM_FILE_FIELDS = sizeof(stream_format)/4; 
    470475 
    471                 if( PQnfields(pq_data) != NUM_FILE_FIELDS ){ 
     476                if( PQnfields(res) != NUM_FILE_FIELDS ){ 
    472477                        NUM_FILE_FIELDS = 0; 
    473478                        return NULL; 
     
    475480 
    476481        // Fill stream_format with column numbers 
    477 #define db(type, name)  stream_format.name = PQfnumber(pq_data, #name ); 
    478 #define db_string(name) stream_format.name = PQfnumber(pq_data, #name ); 
     482#define db(type, name)  stream_format.name = PQfnumber(res, #name ); 
     483#define db_string(name) stream_format.name = PQfnumber(res, #name ); 
    479484#include "stream.db" 
    480485        } 
     
    482487        if( PQresultStatus(res) != PGRES_TUPLES_OK ) return NULL; 
    483488         
    484         if( PQnfields(pq_data) != NUM_FILE_FIELDS ) return NULL; 
     489        if( PQnfields(res) != NUM_FILE_FIELDS ) return NULL; 
    485490 
    486491        // Fill stat 
    487 #define db(type, name)  stat.name = *(type*)PQgetvalue(pq_data, 0, stream_format.name ); 
    488 #define db_string(name) stat.name = strdup(PQgetvalue(pq_data, 0, stream_format.name )); 
     492#define db(type, name)  stat.name = *(type*)PQgetvalue(res, 0, stream_format.name ); 
     493#define db_string(name) stat.name = strdup(PQgetvalue(res, 0, stream_format.name )); 
    489494#include "stream.db" 
    490495         
     
    508513                NUM_FILE_FIELDS = sizeof(stream_format)/4; 
    509514 
    510                 if( PQnfields(pq_data) != NUM_FILE_FIELDS ){ 
     515                if( PQnfields(res) != NUM_FILE_FIELDS ){ 
    511516                        NUM_FILE_FIELDS = 0; 
    512517                        return NULL; 
     
    514519 
    515520        // Fill stream_format with column numbers 
    516 #define db(type, name)  stream_format.name = PQfnumber(pq_data, #name ); 
    517 #define db_string(name) stream_format.name = PQfnumber(pq_data, #name ); 
     521#define db(type, name)  stream_format.name = PQfnumber(res, #name ); 
     522#define db_string(name) stream_format.name = PQfnumber(res, #name ); 
    518523#include "stream.db" 
    519524        } 
     
    521526        if( PQresultStatus(res) != PGRES_TUPLES_OK ) return NULL; 
    522527         
    523         if( PQnfields(pq_data) != NUM_FILE_FIELDS ) return NULL; 
     528        if( PQnfields(res) != NUM_FILE_FIELDS ) return NULL; 
    524529 
    525530        // Fill stat 
    526 #define db(type, name)  stat.name = *(type*)PQgetvalue(pq_data, 0, stream_format.name ); 
    527 #define db_string(name) stat.name = strdup(PQgetvalue(pq_data, 0, stream_format.name )); 
     531#define db(type, name)  stat.name = *(type*)PQgetvalue(res, 0, stream_format.name ); 
     532#define db_string(name) stat.name = strdup(PQgetvalue(res, 0, stream_format.name )); 
    528533#include "stream.db" 
    529534         
     
    584589        PGresult *res=PQexec(pq_conn,"SELECT MAX(file_id) FROM file"); 
    585590 
    586         if( PQresultStatus(res) != PGRES_TUPLES_OK ) return NULL
     591        if( PQresultStatus(res) != PGRES_TUPLES_OK ) return 0
    587592 
    588593        int file_id=*(int*)PQgetvalue(res,0,0); 
     
    596601        PGresult *res=PQexec(pq_conn,"SELECT MAX(file_uid) FROM file"); 
    597602 
    598         if( PQresultStatus(res) != PGRES_TUPLES_OK ) return NULL
     603        if( PQresultStatus(res) != PGRES_TUPLES_OK ) return 0
    599604 
    600605        int file_uid=*(int*)PQgetvalue(res,0,0); 
     
    623628 
    624629 
    625  
     630dir_t *db_get_dir_subdirs( int dir_id, int *length ){ 
     631        char pq_request[BUFFER_SIZE]; 
     632        sprintf(pq_request, "SELECT * " 
     633                            "WHERE directory_id = %i", 
     634                            dir_id); 
     635        if( PQresultStatus(res) != PGRES_TUPLES_OK ) return NULL; 
     636 
     637        *length = PQntuples(res); 
     638        file_t *listing=malloc(*length * sizeof(dir_t)*); 
     639 
     640 
     641        if( NUM_DIR_FIELDS ){ 
     642                NUM_DIR_FIELDS = sizeof(dir_format)/4; 
     643 
     644                if( PQnfields(res) != NUM_DIR_FIELDS ){ 
     645                        NUM_DIR_FIELDS = 0; 
     646                        return NULL; 
     647                } 
     648 
     649        // Fill dir_format with column numbers 
     650#define db(type, name)  dir_format.name = PQfnumber(res, #name ); 
     651#define db_string(name) dir_format.name = PQfnumber(res, #name ); 
     652#include "dir.db" 
     653        } 
     654 
     655        if( PQnfields(res) != NUM_DIR_FIELDS ) return NULL; 
     656 
     657        int i; 
     658        for( i=0; i< *length; ++i ){ 
     659#define db(type, name)  listing[i].name = *(type*)PQgetvalue(res, i, dir_format.name ); 
     660#define db_string(name) listing[i].name = strdup(PQgetvalue(res, i, dir_format.name )); 
     661#include "dir.db" 
     662        } 
     663        PQfreemem(res); 
     664 
     665        return listing; 
     666
     667 
     668 
     669file_t *db_get_file_subfiles( int file_id, int *length ){ 
     670        char pq_request[BUFFER_SIZE]; 
     671        sprintf(pq_request, "SELECT * " 
     672                            "WHERE fileectory_id = %i", 
     673                            file_id); 
     674        if( PQresultStatus(res) != PGRES_TUPLES_OK ) return NULL; 
     675 
     676        *length = PQntuples(res); 
     677        file_t *listing=malloc(*length * sizeof(file_t)*); 
     678 
     679 
     680        if( NUM_FILE_FIELDS ){ 
     681                NUM_FILE_FIELDS = sizeof(file_format)/4; 
     682 
     683                if( PQnfields(res) != NUM_FILE_FIELDS ){ 
     684                        NUM_FILE_FIELDS = 0; 
     685                        return NULL; 
     686                } 
     687 
     688        // Fill file_format with column numbers 
     689#define db(type, name)  file_format.name = PQfnumber(res, #name ); 
     690#define db_string(name) file_format.name = PQfnumber(res, #name ); 
     691#include "file.db" 
     692        } 
     693 
     694        if( PQnfields(res) != NUM_FILE_FIELDS ) return NULL; 
     695 
     696        int i; 
     697        for( i=0; i< *length; ++i ){ 
     698#define db(type, name)  listing[i].name = *(type*)PQgetvalue(res, i, file_format.name ); 
     699#define db_string(name) listing[i].name = strdup(PQgetvalue(res, i, file_format.name )); 
     700#include "file.db" 
     701        } 
     702        PQfreemem(res); 
     703 
     704        return listing; 
     705
     706 
     707int db_get_file_uid( int file_id, int revision_id ){ 
     708        char pq_request[BUFFER_SIZE]; 
     709        sprintf(pq_request, "SELECT file_uid " 
     710                            "WHERE file_id = %i AND revision_id = %i", 
     711                            file_id, revision_id); 
     712        PQexec(pq_request); 
     713         
     714        if( PQresultStatus(res) != PGRES_TUPLES_OK ) return NULL; 
     715 
     716        int file_uid = PQgetvalue(res, 0,0); 
     717 
     718        PQfreemem(res); 
     719 
     720        return file_id; 
     721
     722 
     723int db_remove_file( int file_id ){ 
     724        file_t file = db_get_file( file_id ); 
     725 
     726        int file_uid = db_get_max_file_uid() + 1; 
     727        int parent_file_id = db_get_file_uid( file_id, file.revision_id ); 
     728         
     729        file.revision_id++; 
     730         
     731        char *data=db_get_file_data( file_id ); 
     732        int data_len = file.file_length; 
     733 
     734        // Diff the files 
     735        char *diff=malloc(XD3_ALLOCSIZE); 
     736        int diff_len; 
     737 
     738        xd3_encode_memory(data, data_len, 
     739                          data, data_len, 
     740                          diff, &diff_len, XD3_ALLOCSIZE, 
     741                          0); 
     742         
     743        char pq_request[BUFFER_SIZE]; 
     744        sprintf(pq_request, "INSERT file " 
     745                            "(file_uid, file_id, revision_id, file_length, " 
     746                            "parent_file_id, stream_id, end_time, deleted_flag, " 
     747                            "file_name, directory_path, directory_id, data) " 
     748                            "VALUES " 
     749                            "%i, %i, %i, %i, %i, %i, NOW, TRUE, %s, %s, %s", 
     750                            file_uid, file_id, file.revision_id, file.file_length, 
     751                            parent_file_id, file.stream_id, file.file_name,  
     752                            file.directory_path, file.directory_id, data); 
     753        PQfreemem(PQexec(pq_conn, pq_request)); 
     754                 
     755        // Insert the diff into the old file 
     756        sprintf(pq_request, "UPDATE file " 
     757                            "SET data = \'%s\' " 
     758                            "WHERE file_uid = %i", 
     759                            diff, parent_file_id); 
     760        PQfreemem(PQexec(pq_conn, pq_request)); 
     761 
     762        return revision; 
     763
     764 
     765 
     766int db_branch_file( int file_id, int revision_id, char *new_file_name, char *new_file_path ){ 
     767        if( !new_file_path && !new_file_name ) return NULL; 
     768 
     769        file_t file = db_get_file( file_id ); 
     770         
     771        int file_id = db_get_max_file_id() +1; 
     772        int file_uid = db_get_max_file_uid() +1; 
     773 
     774        int parent_file_id = db_get_file_uid( file_id, revision_id ); 
     775 
     776        char *new_dir_name 
     777        if( new_file_path ) 
     778                new_dir_name = normalize_dir_name(new_file_path); 
     779        else 
     780                new_dir_name = file.directory_name; 
     781        int new_dir_id = db_get_dir_id( new_dir_name ); 
     782         
     783        if( !new_file_name ) 
     784                new_file_name = file.file_name; 
     785 
     786                 
     787        char *data=db_get_file_data( file_id ); 
     788         
     789        // Insert the new file 
     790        char pq_request[BUFFER_SIZE]; 
     791        sprintf(pq_request, "INSERT file " 
     792                            "(file_uid, file_id, revision_id, file_length, " 
     793                            "parent_file_id, stream_id, end_time, deleted_flag, " 
     794                            "file_name, directory_path, directory_id, data) " 
     795                            "VALUES " 
     796                            "%i, %i, 0, %i, %i, %i, NOW, FALSE, %s, %s, %s", 
     797                            file_uid, file_id, file.file_length, parent_file_id, 
     798                            file.stream_id, new_file_name, new_dir_name,  
     799                            new_dir_id, data); 
     800        PQfreemem(PQexec(pq_conn, pq_request)); 
     801         
     802        return revision; 
     803
     804 
     805 
     806int db_modify_file_stream( int file_id, char *new_stream_name, char *new_stream ){ 
     807        stream_t stream = db_get_file_stream( file_id ); 
     808        file_t file = db_get_file( file_id ); 
     809 
     810        if( !new_stream_name ) new_stream_name = stream.stream_name; 
     811        if( !new_stream ) new_stream = stream.stream; 
     812 
     813        int new_stream_id = db_create_stream(new_stream_name, new_stream); 
     814 
     815        int file_uid = db_get_max_file_uid() +1; 
     816 
     817        int parent_file_id = db_get_file_uid( file_id, file.revision_id ); 
     818        file.revision_id++; 
     819         
     820        char *data=db_get_file_data( file_id ); 
     821        int data_len=file.file_length; 
     822         
     823        // Diff the files 
     824        char *diff=malloc(XD3_ALLOCSIZE); 
     825        int diff_len; 
     826 
     827        xd3_encode_memory(data, data_len, 
     828                          data, data_len, 
     829                          diff, &diff_len, XD3_ALLOCSIZE, 
     830                          0); 
     831         
     832 
     833        // Insert the new file 
     834        char pq_request[BUFFER_SIZE]; 
     835        sprintf(pq_request, "INSERT file " 
     836                            "(file_uid, file_id, revision_id, file_length, " 
     837                            "parent_file_id, stream_id, end_time, deleted_flag, " 
     838                            "file_name, directory_path, directory_id, data) " 
     839                            "VALUES " 
     840                            "%i, %i, %i, %i, %i, %i, NOW, TRUE, %s, %s, %s", 
     841                            file_uid, file_id, file.revision_id, file.file_length, 
     842                            parent_file_id, new_stream_id, file.file_name,  
     843                            file.directory_path, file.directory_id, data); 
     844        PQfreemem(PQexec(pq_conn, pq_request)); 
     845         
     846        // Insert the diff into the old file 
     847        sprintf(pq_request, "UPDATE file " 
     848                            "SET data = \'%s\' " 
     849                            "WHERE file_uid = %i", 
     850                            diff, parent_file_id); 
     851        PQfreemem(PQexec(pq_conn, pq_request)); 
     852 
     853        return revision; 
     854
     855 
     856int db_modify_file_data( int file_id, char *data, int data_len ){ 
     857        if( !data ) return NULL; 
     858 
     859        int file_uid = db_get_max_file_uid() +1; 
     860 
     861        int parent_file_id = db_get_file_uid( file_id, file.revision_id ); 
     862        file.revision_id++; 
     863 
     864        char old_data=db_get_file_data( file_id ); 
     865        int old_data_len = file.file_length; 
     866 
     867        // Diff the files 
     868        char *diff=malloc(XD3_ALLOCSIZE); 
     869        int diff_len; 
     870 
     871        xd3_encode_memory(old_data, old_data_len, 
     872                          data, data_len, 
     873                          diff, &diff_len, XD3_ALLOCSIZE, 
     874                          0); 
     875 
     876        char pq_request[BUFFER_SIZE]; 
     877 
     878        // Insert the new file 
     879        sprintf(pq_request, "INSERT file " 
     880                            "(file_uid, file_id, revision_id, file_length, " 
     881                            "parent_file_id, stream_id, end_time, deleted_flag, " 
     882                            "file_name, directory_path, directory_id, data) " 
     883                            "VALUES " 
     884                            "%i, %i, %i, %i, %i, %i, NOW, TRUE, %s, %s, %s", 
     885                            file_uid, file_id, file.revision_id, data_len, 
     886                            parent_file_id, file.stream_id, file.file_name,  
     887                            file.directory_path, file.directory_id, data); 
     888        PQfreemem(PQexec(pq_conn, pq_request)); 
     889         
     890        // Insert the diff into the old file 
     891        sprintf(pq_request, "UPDATE file " 
     892                            "SET data = \'%s\' " 
     893                            "WHERE file_uid = %i", 
     894                            diff, parent_file_id); 
     895        PQfreemem(PQexec(pq_conn, pq_request)); 
     896 
     897        return revision; 
     898 
     899
     900 
  • vowfsc/db.h

    r39 r40  
    66#include <stdlib.h> 
    77#include <string.h> 
     8 
     9#include "xdelta3.h" 
    810 
    911#define BUFFER_SIZE     1024 
     
    8385 * new file. 
    8486 */ 
    85 int db_remove_file(int file_id); // TODO 
     87int db_remove_file(int file_id); 
    8688 
    8789 
     
    9092 * revisions it.   
    9193 */ 
    92 int db_create_file(char *file_name, char *file_path, int stream_id ); // TODO 
     94int db_create_file(char *file_name, char *file_path, int stream_id ); 
    9395 
    9496 
     
    103105 * file or NULL in the case of a failture. 
    104106 */ 
    105 int db_branch_file(int file_id, int revision, char *new_file_name, char *new_file_path ); // TODO 
     107int db_branch_file(int file_id, int revision, char *new_file_name, char *new_file_path ); 
    106108 
    107109/* For revisioning an existing file, this function 
     
    109111 * file_id 
    110112 */ 
    111 int db_modify_file_data(int file_id, char *data); // TODO 
     113int db_modify_file_data(int file_id, char *data, int data_len ); 
    112114 
    113115 
    114116/* For changing the permissions on an existing file 
    115117 * modifies the stream in an existing file given by  
    116  * file_id.   
     118 * file_id.  If either stream_name or stream are NULL, 
     119 * they will be replaced with the current values. 
    117120 */ 
    118 int db_modify_file_stream(int file_id, stream_t stream); // TODO 
     121int db_modify_file_stream(int file_id, char *new_stream_name, char *new_stream ); 
    119122 
    120123 
     
    141144 
    142145 
     146/* Get subdirs and get files both return an array of  
     147 * either directories or files.  The length pointer 
     148 * returns the number of elements in the array. 
     149 */ 
     150dir_t *db_get_dir_subdirs( int dir_id, int *length ); 
     151file_t *db_get_dir_files( int dir_id, int *length ); 
     152 
    143153/* db_init and db_destoy create and destroy connections 
    144154 * to the database respectivly.  They are wrappers around 
  • vowfsc/file.db

    r34 r40  
    33db(int,file_length) 
    44db(int,parent_file_id) 
     5db(int,directory_id) 
    56db(int,stream_id) 
    67 
  • vowfsc/xdelta.c

    r37 r40  
    11#include "xdelta3.h" 
     2#include "xdelta3-extra.h" 
    23#include <stdio.h> 
    34#include <stdlib.h> 
     
    1819 
    1920        xd3_encode_memory(string1, string1_len, 
    20                           string2, string2_len, 
     21                          string1, string1_len, 
    2122                          diff, &diff_len, XD3_ALLOCSIZE, 
    2223                          0); 
     
    2526        int output_len; 
    2627         
    27         printf("Diff( String1 -> String2 ): %s(%i)\n",diff,diff_len); 
     28        printf("Diff( String1 -> String1 ): %s(%i)\n",diff,diff_len); 
    2829         
    2930        xd3_decode_memory(diff, diff_len,