1/*
2 * delta.h:  private delta library things
3 *
4 * ====================================================================
5 *    Licensed to the Apache Software Foundation (ASF) under one
6 *    or more contributor license agreements.  See the NOTICE file
7 *    distributed with this work for additional information
8 *    regarding copyright ownership.  The ASF licenses this file
9 *    to you under the Apache License, Version 2.0 (the
10 *    "License"); you may not use this file except in compliance
11 *    with the License.  You may obtain a copy of the License at
12 *
13 *      http://www.apache.org/licenses/LICENSE-2.0
14 *
15 *    Unless required by applicable law or agreed to in writing,
16 *    software distributed under the License is distributed on an
17 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 *    KIND, either express or implied.  See the License for the
19 *    specific language governing permissions and limitations
20 *    under the License.
21 * ====================================================================
22 */
23
24/* ==================================================================== */
25
26
27#include <apr_pools.h>
28#include <apr_hash.h>
29
30#include "svn_delta.h"
31
32#ifndef SVN_LIBSVN_DELTA_H
33#define SVN_LIBSVN_DELTA_H
34
35
36#ifdef __cplusplus
37extern "C" {
38#endif /* __cplusplus */
39
40
41/* Private interface for text deltas. */
42
43/* The standard size of one svndiff window. */
44
45#define SVN_DELTA_WINDOW_SIZE 102400
46
47
48/* Context/baton for building an operation sequence. */
49
50typedef struct svn_txdelta__ops_baton_t {
51  int num_ops;                  /* current number of ops */
52  int src_ops;                  /* current number of source copy ops */
53  int ops_size;                 /* number of ops allocated */
54  svn_txdelta_op_t *ops;        /* the operations */
55
56  svn_stringbuf_t *new_data;    /* any new data used by the operations */
57} svn_txdelta__ops_baton_t;
58
59
60/* Insert a delta op into the delta window being built via BUILD_BATON. If
61   OPCODE is svn_delta_new, bytes from NEW_DATA are copied into the window
62   data and OFFSET is ignored.  Otherwise NEW_DATA is ignored. All
63   allocations are performed in POOL. */
64void svn_txdelta__insert_op(svn_txdelta__ops_baton_t *build_baton,
65                            enum svn_delta_action opcode,
66                            apr_size_t offset,
67                            apr_size_t length,
68                            const char *new_data,
69                            apr_pool_t *pool);
70
71/* Remove / truncate the last delta ops spanning the last MAX_LEN bytes
72   from the delta window being built via BUILD_BATON starting.  Return the
73   number of bytes that were actually removed. */
74apr_size_t
75svn_txdelta__remove_copy(svn_txdelta__ops_baton_t *build_baton,
76                         apr_size_t max_len);
77
78/* Allocate a delta window from POOL. */
79svn_txdelta_window_t *
80svn_txdelta__make_window(const svn_txdelta__ops_baton_t *build_baton,
81                         apr_pool_t *pool);
82
83
84/* Create xdelta window data. Allocate temporary data from POOL. */
85void svn_txdelta__xdelta(svn_txdelta__ops_baton_t *build_baton,
86                         const char *start,
87                         apr_size_t source_len,
88                         apr_size_t target_len,
89                         apr_pool_t *pool);
90
91
92#ifdef __cplusplus
93}
94#endif /* __cplusplus */
95
96#endif  /* SVN_LIBSVN_DELTA_H */
97