1 /* svndiff-test.c -- test driver for text deltas
3 * ====================================================================
4 * Copyright (c) 2000-2004 CollabNet. All rights reserved.
6 * This software is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at http://subversion.tigris.org/license-1.html.
9 * If newer versions of this license are posted there, you may use a
10 * newer version instead, at your option.
12 * This software consists of voluntary contributions made by many
13 * individuals. For exact contribution history, see the revision
14 * history and logs, available at http://subversion.tigris.org/.
15 * ====================================================================
21 #include <apr_general.h>
22 #include "svn_base64.h"
23 #include "svn_quoprint.h"
24 #include "svn_pools.h"
25 #include "svn_delta.h"
26 #include "svn_error.h"
30 main(int argc
, char **argv
)
34 apr_file_t
*source_file
;
35 apr_file_t
*target_file
;
36 svn_stream_t
*stdout_stream
;
37 svn_txdelta_stream_t
*txdelta_stream
;
38 svn_txdelta_window_handler_t svndiff_handler
;
39 svn_stream_t
*encoder
;
46 printf("usage: %s source target [version]\n", argv
[0]);
51 pool
= svn_pool_create(NULL
);
52 apr_err
= apr_file_open(&source_file
, argv
[1], (APR_READ
| APR_BINARY
),
53 APR_OS_DEFAULT
, pool
);
56 fprintf(stderr
, "unable to open \"%s\" for reading\n", argv
[1]);
60 apr_err
= apr_file_open(&target_file
, argv
[2], (APR_READ
| APR_BINARY
),
61 APR_OS_DEFAULT
, pool
);
64 fprintf(stderr
, "unable to open \"%s\" for reading\n", argv
[2]);
68 version
= atoi(argv
[3]);
70 svn_txdelta(&txdelta_stream
,
71 svn_stream_from_aprfile(source_file
, pool
),
72 svn_stream_from_aprfile(target_file
, pool
),
75 err
= svn_stream_for_stdout(&stdout_stream
, pool
);
77 svn_handle_error2(err
, stdout
, TRUE
, "svndiff-test: ");
79 #ifdef QUOPRINT_SVNDIFFS
80 encoder
= svn_quoprint_encode(stdout_stream
, pool
);
82 encoder
= svn_base64_encode(stdout_stream
, pool
);
84 svn_txdelta_to_svndiff2(&svndiff_handler
, &svndiff_baton
,
85 encoder
, version
, pool
);
86 err
= svn_txdelta_send_txstream(txdelta_stream
,
91 svn_handle_error2(err
, stdout
, TRUE
, "svndiff-test: ");
93 apr_file_close(source_file
);
94 apr_file_close(target_file
);
95 svn_pool_destroy(pool
);