1 1dfba055 2020-10-07 stsp /* Diff output generators and invocation shims. */
3 1dfba055 2020-10-07 stsp * Copyright (c) 2020 Neels Hofmeyr <neels@hofmeyr.de>
5 1dfba055 2020-10-07 stsp * Permission to use, copy, modify, and distribute this software for any
6 1dfba055 2020-10-07 stsp * purpose with or without fee is hereby granted, provided that the above
7 1dfba055 2020-10-07 stsp * copyright notice and this permission notice appear in all copies.
9 1dfba055 2020-10-07 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 1dfba055 2020-10-07 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 1dfba055 2020-10-07 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 1dfba055 2020-10-07 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 1dfba055 2020-10-07 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 1dfba055 2020-10-07 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 1dfba055 2020-10-07 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 1dfba055 2020-10-07 stsp struct diff_input_info {
19 1dfba055 2020-10-07 stsp const char *left_path;
20 1dfba055 2020-10-07 stsp const char *right_path;
22 e4c510c1 2020-11-21 stsp /* Set by caller of diff_output_* functions. */
24 e4c510c1 2020-11-21 stsp #define DIFF_INPUT_LEFT_NONEXISTENT 0x00000001
25 e4c510c1 2020-11-21 stsp #define DIFF_INPUT_RIGHT_NONEXISTENT 0x00000002
28 1dfba055 2020-10-07 stsp struct diff_output_info {
30 1dfba055 2020-10-07 stsp * Byte offset to each line in the generated output file.
31 1dfba055 2020-10-07 stsp * The total number of lines in the file is line_offsets.len - 1.
32 1dfba055 2020-10-07 stsp * The last offset in this array corresponds to end-of-file.
34 1dfba055 2020-10-07 stsp ARRAYLIST(off_t) line_offsets;
37 1dfba055 2020-10-07 stsp void diff_output_info_free(struct diff_output_info *output_info);
39 1dfba055 2020-10-07 stsp struct diff_chunk_context {
40 1dfba055 2020-10-07 stsp struct diff_range chunk;
41 1dfba055 2020-10-07 stsp struct diff_range left, right;
44 1dfba055 2020-10-07 stsp int diff_output_plain(struct diff_output_info **output_info, FILE *dest,
45 1dfba055 2020-10-07 stsp const struct diff_input_info *info,
46 1dfba055 2020-10-07 stsp const struct diff_result *result);
47 1dfba055 2020-10-07 stsp int diff_output_unidiff(struct diff_output_info **output_info,
48 1dfba055 2020-10-07 stsp FILE *dest, const struct diff_input_info *info,
49 1dfba055 2020-10-07 stsp const struct diff_result *result,
50 1dfba055 2020-10-07 stsp unsigned int context_lines);
51 b7ba71f0 2020-10-07 stsp int diff_output_edscript(struct diff_output_info **output_info,
52 b7ba71f0 2020-10-07 stsp FILE *dest, const struct diff_input_info *info,
53 b7ba71f0 2020-10-07 stsp const struct diff_result *result);
54 1dfba055 2020-10-07 stsp int diff_chunk_get_left_start(const struct diff_chunk *c,
55 1dfba055 2020-10-07 stsp const struct diff_result *r,
56 1dfba055 2020-10-07 stsp int context_lines);
57 1dfba055 2020-10-07 stsp int diff_chunk_get_left_end(const struct diff_chunk *c,
58 1dfba055 2020-10-07 stsp const struct diff_result *r,
59 1dfba055 2020-10-07 stsp int context_lines);
60 1dfba055 2020-10-07 stsp int diff_chunk_get_right_start(const struct diff_chunk *c,
61 1dfba055 2020-10-07 stsp const struct diff_result *r,
62 1dfba055 2020-10-07 stsp int context_lines);
63 1dfba055 2020-10-07 stsp int diff_chunk_get_right_end(const struct diff_chunk *c,
64 1dfba055 2020-10-07 stsp const struct diff_result *r,
65 1dfba055 2020-10-07 stsp int context_lines);
66 e8eedebc 2020-11-06 stsp struct diff_chunk *diff_chunk_get(const struct diff_result *r, int chunk_idx);
67 e8eedebc 2020-11-06 stsp int diff_chunk_get_left_count(struct diff_chunk *c);
68 e8eedebc 2020-11-06 stsp int diff_chunk_get_right_count(struct diff_chunk *c);
69 1dfba055 2020-10-07 stsp void diff_chunk_context_get(struct diff_chunk_context *cc,
70 1dfba055 2020-10-07 stsp const struct diff_result *r,
71 1dfba055 2020-10-07 stsp int chunk_idx, int context_lines);
72 7187fe97 2020-10-17 stsp void diff_chunk_context_load_change(struct diff_chunk_context *cc,
73 7187fe97 2020-10-17 stsp int *nchunks_used,
74 7187fe97 2020-10-17 stsp struct diff_result *result,
75 7187fe97 2020-10-17 stsp int start_chunk_idx,
76 7187fe97 2020-10-17 stsp int context_lines);
78 1dfba055 2020-10-07 stsp struct diff_output_unidiff_state;
79 1dfba055 2020-10-07 stsp struct diff_output_unidiff_state *diff_output_unidiff_state_alloc(void);
80 1dfba055 2020-10-07 stsp void diff_output_unidiff_state_reset(struct diff_output_unidiff_state *state);
81 1dfba055 2020-10-07 stsp void diff_output_unidiff_state_free(struct diff_output_unidiff_state *state);
82 1dfba055 2020-10-07 stsp int diff_output_unidiff_chunk(struct diff_output_info **output_info, FILE *dest,
83 1dfba055 2020-10-07 stsp struct diff_output_unidiff_state *state,
84 1dfba055 2020-10-07 stsp const struct diff_input_info *info,
85 1dfba055 2020-10-07 stsp const struct diff_result *result,
86 1dfba055 2020-10-07 stsp const struct diff_chunk_context *cc);
87 1dfba055 2020-10-07 stsp int diff_output_chunk_left_version(struct diff_output_info **output_info,
89 1dfba055 2020-10-07 stsp const struct diff_input_info *info,
90 1dfba055 2020-10-07 stsp const struct diff_result *result,
91 1dfba055 2020-10-07 stsp const struct diff_chunk_context *cc);
92 1dfba055 2020-10-07 stsp int diff_output_chunk_right_version(struct diff_output_info **output_info,
94 1dfba055 2020-10-07 stsp const struct diff_input_info *info,
95 1dfba055 2020-10-07 stsp const struct diff_result *result,
96 1dfba055 2020-10-07 stsp const struct diff_chunk_context *cc);
98 e4c510c1 2020-11-21 stsp const char *diff_output_get_label_left(const struct diff_input_info *info);
99 e4c510c1 2020-11-21 stsp const char *diff_output_get_label_right(const struct diff_input_info *info);