-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompitem.h
180 lines (148 loc) · 6.19 KB
/
compitem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
* PARTICULAR PURPOSE.
*
* Copyright (c) Microsoft Corporation. All Rights Reserved.
*/
#ifndef __COMPITEM_H__
#define __COMPITEM_H__
/*
* CompItem
*
* a CompItem is a comparison between two files. It keeps track
* of the two files. It knows how to compare two files, and knows the
* results of the comparison: the end result is a list of SECTIONs
* in each of the files, and a composite list of sections.
*
* One or other of the files may not exist.
*
* a compitem has a state - this indicates whether the two
* files are the same, or different, or if only one file of that
* name exists. This state is set on creation of the CompItem
* and may be queried later.
*
*/
#ifndef INC_VIEW_COMPLIST
#define INC_VIEW_COMPLIST
typedef struct compitem FAR* COMPITEM; /* handle to a compitem */
typedef struct view FAR * VIEW; /* handle to a VIEW */
typedef struct complist FAR * COMPLIST; /* handle to a complist */
#endif // INC_VIEW_COMPLIST
/* build a new compitem from two files. Either (but not both) of the files
* may be NULL.
*
* This operation may cause the files to be read in and compared.
* In any case, this will be done by the time a call to one of
* the query*sections functions completes.
*
* If the LIST parameter is not NULL, the item will be
* appended to the list during initialisation - that is, the
* compitem will do a List_NewLast operation and then initialise the
* resulting object. If LIST is NULL, the compitem will allocate the
* structure using some other memory allocation scheme. in either
* case, the compitem handle will be returned. This also affects
* behaviour of compitem_delete- we only free the compitem itself if
* we allocated it ourself and not through List_NewLast.
*/
COMPITEM compitem_new(DIRITEM left, DIRITEM right, LIST list, BOOL fExact);
/* delete a compitem and free all associated data - INCLUDING deleting
* the two FILEDATAs and all associated list of lines and sections.
*
* If the compitem was allocated on a list, it will not be freed, only
* the memory hanging off it.
*/
void compitem_delete(COMPITEM item);
/* return a handle to a LIST of SECTIONs representing the compared file.
* this call will cause the list to be created if it hasn't already been.
*
* returned handle will be NULL if either of the files is NULL.
*
* the list of sections can be traversed using the standard list functions.
* the list you have a handle to is still owned by the compitem. to delete
* it, call compitem_delete to delete the whole thing, or
* compitem_discardsections to throw away all of the results of the compare
*/
LIST compitem_getcomposite(COMPITEM item);
/*
* discard all compare data - throw away the composite section list and
* any associated data (including the left and right section lists).
* retains the two files. This is used either to free up memory when a
* compitem is no longer being viewed, or to cause a new compare when
* the global compare options flags (such as ignore_blanks) have changed.
*/
void compitem_discardsections(COMPITEM item);
/* return the handle to the list of sections in the left, right file.
* These calls will cause the lists to be created if they are not already.
*
* the compitem still owns the list. traverse it with the standard list
* functions, but don't change it or delete it.
*/
LIST compitem_getleftsections(COMPITEM item);
LIST compitem_getrightsections(COMPITEM item);
/* return the handle of the left or right file */
FILEDATA compitem_getleftfile(COMPITEM item);
FILEDATA compitem_getrightfile(COMPITEM item);
/* query the compare state of this compitem */
int compitem_getstate(COMPITEM item);
/* get a pointer to a text string describing the item (normally the
* file name or filenames if different. The text pointed to should not
* be changed or freed.
*/
LPSTR compitem_gettext_tag(COMPITEM item);
/* return a pointer to a text string describing the compare result - this
* will be a text form of the item's state.
* The text pointed to should not be changed or freed.
*/
LPSTR compitem_gettext_result(COMPITEM item);
/*
* options for compitem_getfilename, indicating which name is desired
*/
#define CI_LEFT 1 /* name of left file */
#define CI_RIGHT 2 /* name of right file */
#define CI_COMP 3 /* name of composite file */
/*
* return the name of the file associated with this compitem. The option
* argument (one of CI_LEFT, CI_RIGHT, CI_COMP) indicates which file
* is required.
*
* The file may be a temporary file, if the file option specifies a remote
* file, or the composite file.
*
* call compitem_freefilename once the file is finished with.
*/
LPSTR compitem_getfilename(VIEW view, COMPITEM item, int option);
/*
* free memory created by a call to compitem_getfilename. if a temporary
* file was created, this may cause it to be deleted. The option argument must
* be the same as passed to the original compitem_getfilename call.
*/
void compitem_freefilename(COMPITEM item, int option, LPSTR filename);
/* save the composite file
*
* if savename is not null, write the item out to savename using compopts.
* otherwise, prompt by dialog for filename and options.
*/
LPSTR compitem_savecomp(VIEW view, COMPITEM ci, LPSTR savename, int listopts);
/*
* worker function to write the actual composite file
*
* if savename is not null, write the list out to savename using compopts.
* otherwise, prompt by dialog for filename and options.
*/
LPSTR compitem_writefile(VIEW view, COMPITEM ci, LPSTR savename, int compopts);
/*
* set the mark state of a file. The only use for this is to retrieve it
* later using compitem_getmark. The state is a bool.
*/
void compitem_setmark(COMPITEM item, BOOL bMark);
/*
* return the mark state set by compitem_setmark
*/
BOOL compitem_getmark(COMPITEM item);
/* Tell compitem the paths to be used for autocopy. Copies left to right */
void compitem_SetCopyPaths(LPSTR LeftPath, LPSTR RightPath);
/* Rescan the file, get new checksums etc */
void compitem_rescan(COMPITEM ci);
#endif