diffutil.h (1446B)
1 /* see LICENSE file for copyright and license details */ 2 #ifndef ARUU_DIFFUTIL_H 3 #define ARUU_DIFFUTIL_H 4 5 #include <stdio.h> 6 #include <sys/types.h> 7 8 struct diffline { 9 char *data; 10 size_t len; 11 }; 12 13 struct difffile { 14 struct diffline *lines; 15 size_t nlines; 16 }; 17 18 struct diffrange { 19 size_t from; 20 size_t to; 21 }; 22 23 struct diffhunk { 24 struct diffrange old; 25 struct diffrange new; 26 }; 27 28 struct diffhunks { 29 struct diffhunk *v; 30 size_t n; 31 }; 32 33 enum diffformat { 34 DIFF_NORMAL, 35 DIFF_UNIFIED, 36 DIFF_CONTEXT, 37 DIFF_ED, 38 DIFF_RCSED, 39 DIFF_BRIEF, 40 }; 41 42 struct diffopts { 43 enum diffformat format; 44 size_t context; 45 int ignore_case; 46 int ignore_blanks; 47 int strip_cr; 48 int treat_binary; 49 }; 50 51 #define DIFF_SAME 0 52 #define DIFF_DIFFER 1 53 #define DIFF_ERROR 2 54 55 int diff_load(struct difffile *df, const char *path); 56 void diff_free(struct difffile *df); 57 int diff_compute( 58 struct diffhunks *hunks, 59 const struct difffile *old, 60 const struct difffile *new, 61 const struct diffopts *opts 62 ); 63 void diff_hunks_free(struct diffhunks *hunks); 64 int diff_format( 65 FILE *out, 66 const struct diffhunks *hunks, 67 const struct difffile *old, 68 const struct difffile *new, 69 const char *oldlabel, 70 const char *newlabel, 71 const struct diffopts *opts 72 ); 73 int diff_looks_binary(const struct difffile *df); 74 75 #endif