Followup to r29625: fix getopt tests.
[svn.git] / subversion / libsvn_diff / diff.h
blob61858ac174e727e9931bb0e5a8c87876f9136ba1
1 /*
2 * diff.h : private header file
4 * ====================================================================
5 * Copyright (c) 2000-2004 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
19 #if !defined(DIFF_H)
20 #define DIFF_H
22 #include <apr.h>
23 #include <apr_pools.h>
24 #include <apr_general.h>
26 #include "svn_diff.h"
27 #include "svn_types.h"
29 #define SVN_DIFF__UNIFIED_CONTEXT_SIZE 3
31 typedef struct svn_diff__node_t svn_diff__node_t;
32 typedef struct svn_diff__tree_t svn_diff__tree_t;
33 typedef struct svn_diff__position_t svn_diff__position_t;
34 typedef struct svn_diff__lcs_t svn_diff__lcs_t;
36 typedef enum svn_diff__type_e
38 svn_diff__type_common,
39 svn_diff__type_diff_modified,
40 svn_diff__type_diff_latest,
41 svn_diff__type_diff_common,
42 svn_diff__type_conflict
43 } svn_diff__type_e;
45 struct svn_diff_t {
46 svn_diff_t *next;
47 svn_diff__type_e type;
48 apr_off_t original_start;
49 apr_off_t original_length;
50 apr_off_t modified_start;
51 apr_off_t modified_length;
52 apr_off_t latest_start;
53 apr_off_t latest_length;
54 svn_diff_t *resolved_diff;
57 struct svn_diff__position_t
59 svn_diff__position_t *next;
60 svn_diff__node_t *node;
61 apr_off_t offset;
64 struct svn_diff__lcs_t
66 svn_diff__lcs_t *next;
67 svn_diff__position_t *position[2];
68 apr_off_t length;
69 int refcount;
73 /* State used when normalizing whitespace and EOL styles. */
74 typedef enum svn_diff__normalize_state_t
76 /* Initial state; not in a sequence of whitespace. */
77 svn_diff__normalize_state_normal,
78 /* We're in a sequence of whitespace characters. Only entered if
79 we ignore whitespace. */
80 svn_diff__normalize_state_whitespace,
81 /* The previous character was CR. */
82 svn_diff__normalize_state_cr
83 } svn_diff__normalize_state_t;
86 svn_diff__lcs_t *
87 svn_diff__lcs(svn_diff__position_t *position_list1, /* pointer to tail (ring) */
88 svn_diff__position_t *position_list2, /* pointer to tail (ring) */
89 apr_pool_t *pool);
93 * Support functions to build a tree of token positions
95 void
96 svn_diff__tree_create(svn_diff__tree_t **tree, apr_pool_t *pool);
100 * Get all tokens from a datasource. Return the
101 * last item in the (circular) list.
103 svn_error_t *
104 svn_diff__get_tokens(svn_diff__position_t **position_list,
105 svn_diff__tree_t *tree,
106 void *diff_baton,
107 const svn_diff_fns_t *vtable,
108 svn_diff_datasource_e datasource,
109 apr_pool_t *pool);
112 /* Morph a svn_lcs_t into a svn_diff_t. */
113 svn_diff_t *
114 svn_diff__diff(svn_diff__lcs_t *lcs,
115 apr_off_t original_start, apr_off_t modified_start,
116 svn_boolean_t want_common,
117 apr_pool_t *pool);
119 void
120 svn_diff__resolve_conflict(svn_diff_t *hunk,
121 svn_diff__position_t **position_list1,
122 svn_diff__position_t **position_list2,
123 apr_pool_t *pool);
127 * Return an adler32 checksum based on CHECKSUM, updated with
128 * DATA of size LEN.
130 apr_uint32_t
131 svn_diff__adler32(apr_uint32_t checksum, const char *data, apr_size_t len);
134 /* Normalize the characters pointed to by BUF of length *LENGTHP, starting
135 * in state *STATEP according to the OPTIONS.
136 * Adjust *LENGTHP and *STATEP to be the length of the normalized buffer and
137 * the final state, respectively.
138 * Normalized data is written to the memory at *TGT. BUF and TGT may point
139 * to the same memory area. The memory area pointed to by *TGT should be
140 * large enough to hold *LENGTHP bytes.
141 * When on return *TGT is not equal to the value passed in, it points somewhere
142 * into the memory region designated by BUF and *LENGTHP.
144 void
145 svn_diff__normalize_buffer(char **tgt,
146 apr_off_t *lengthp,
147 svn_diff__normalize_state_t *statep,
148 const char *buf,
149 const svn_diff_file_options_t *opts);
152 #endif /* DIFF_H */