Mark many merge tests as skip-against-old-server.
[svn.git] / subversion / tests / libsvn_delta / svndiff-test.c
blobeea1405e6f1957ef9f37313d8ccaca551f80b6f4
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 * ====================================================================
18 #include <ctype.h>
19 #include <stdio.h>
20 #include <string.h>
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"
29 int
30 main(int argc, char **argv)
32 svn_error_t *err;
33 apr_status_t apr_err;
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;
40 void *svndiff_baton;
41 apr_pool_t *pool;
42 int version = 0;
44 if (argc < 3)
46 printf("usage: %s source target [version]\n", argv[0]);
47 exit(0);
50 apr_initialize();
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);
54 if (apr_err)
56 fprintf(stderr, "unable to open \"%s\" for reading\n", argv[1]);
57 exit(1);
60 apr_err = apr_file_open(&target_file, argv[2], (APR_READ | APR_BINARY),
61 APR_OS_DEFAULT, pool);
62 if (apr_err)
64 fprintf(stderr, "unable to open \"%s\" for reading\n", argv[2]);
65 exit(1);
67 if (argc == 4)
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),
73 pool);
75 err = svn_stream_for_stdout(&stdout_stream, pool);
76 if (err)
77 svn_handle_error2(err, stdout, TRUE, "svndiff-test: ");
79 #ifdef QUOPRINT_SVNDIFFS
80 encoder = svn_quoprint_encode(stdout_stream, pool);
81 #else
82 encoder = svn_base64_encode(stdout_stream, pool);
83 #endif
84 svn_txdelta_to_svndiff2(&svndiff_handler, &svndiff_baton,
85 encoder, version, pool);
86 err = svn_txdelta_send_txstream(txdelta_stream,
87 svndiff_handler,
88 svndiff_baton,
89 pool);
90 if (err)
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);
96 apr_terminate();
97 exit(0);