"Fossies" - the Fresh Open Source Software Archive 
Member "qdiff-0.9.1/tdiffoutput.h" (21 Oct 2008, 3162 Bytes) of package /linux/privat/old/qdiff-0.9.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "tdiffoutput.h" see the
Fossies "Dox" file reference documentation.
1 /*GPL*START*
2 *
3 * Copyright (C) 1998 by Johannes Overmann <overmann@iname.com>
4 * Copyright (C) 2008 by Tong Sun <suntong001@users.sourceforge.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 * *GPL*END*/
20
21 #ifndef _tdiffoutput_h_
22 #define _tdiffoutput_h_
23
24 #include <sys/stat.h>
25 #include <sys/mman.h>
26 #include <sys/ioctl.h>
27 #include <fcntl.h>
28 #include <unistd.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31
32 #include "terror.h"
33 #include "trotfile.h"
34 #include "tappconfig.h"
35
36 class TDiffOutput {
37 public:
38 // ctor & dtor
39 TDiffOutput(TROTFile& f1, TROTFile& f2, const TAppConfig& ac);
40 ~TDiffOutput();
41
42 // interface
43 void ins(int i); // insertion
44 void del(int i); // deletion
45 void sub(int i, int ins=0, int del=0); // substitution
46 void mat(int i); // match
47
48 void flush(); // flush buffers: assume no more output
49
50 private: // private data
51 TROTFile& f1; // file data
52 TROTFile& f2;
53 int o1; // current offset in file
54 int o2;
55 const TAppConfig& ac; // for command line options
56 enum MODE_T {VERTICAL, F_ASCII, U_ASCII, HEX} mode;
57 enum DIFF_T {NIL, MAT, SUB, DEL, INS};
58 bool verbose;
59
60 // output options:
61 bool hide_mat;
62 bool hide_ins;
63 bool hide_del;
64 bool hide_sub;
65 bool range_mat;
66 bool range_ins;
67 bool range_del;
68 bool range_sub;
69 bool no_color;
70 int width;
71 int bytes_per_line;
72 int max_bytes_per_line;
73 int half_line_len;
74 char *linebuf1;
75 char *linebuf2;
76 char *linebuf1p;
77 char *linebuf2p;
78 int bytesin1;
79 int bytesin2;
80 DIFF_T lastcolor1;
81 DIFF_T lastcolor2;
82 bool needadr1;
83 bool needadr2;
84 int line1;
85 int line2;
86 int tab_size;
87 bool alignment_marks;
88 bool show_lf_and_tab;
89 bool show_space;
90 bool line_numbers;
91 bool no_line_break;
92 char unprint;
93 bool control_hex;
94
95 // private methods
96 MODE_T autoMode();
97 void setStrLen(char *str, int len) const;
98 void printSplitLine(char *abuf1, char *abuf2) const;
99 void putHexElem(int o1, uchar b1, int o2, uchar b2, DIFF_T diff);
100 void putAscElem(int o1, uchar b1, int o2, uchar b2, DIFF_T diff, bool formatted);
101 const char *colorStr(DIFF_T diff) const;
102 int charLen(uchar c, int pos) const;
103 void putSpace(char **p, int num) const;
104 void putChar(char **p, uchar c, int pos) const;
105 const char *printChar(uchar c, char *buf) const;
106
107 // forbid copy
108 TDiffOutput(const TDiffOutput&);
109 const TDiffOutput& operator= (const TDiffOutput&);
110 };
111
112 #endif
113
114