1 // SSTypes.h:structure definitions for SourceSafe files
3 //////////////////////////////////////////////////////////////////////
5 #if !defined(AFX_SSTYPES_H__6602C07F_65ED_4FD7_A730_6D416805378A__INCLUDED_)
6 #define AFX_SSTYPES_H__6602C07F_65ED_4FD7_A730_6D416805378A__INCLUDED_
10 #endif // _MSC_VER > 1000
14 #include <boost/preprocessor/seq.hpp>
15 #include <boost/preprocessor/control.hpp>
16 #include <boost/preprocessor/comparison/greater.hpp>
18 typedef unsigned char byte
;
19 typedef unsigned long ulong
;
20 typedef unsigned short ushort
;
22 inline std::string
toString (const char* ch
, int len
)
24 return std::string (ch
, len
);
27 inline std::string
timeToString (const time_t& t
, int len
)
31 const char* format2
= "Date: %-8s Time: %s";
32 const tm
* ttm
= gmtime (&t
);//localtime (&versionDate);
33 strftime (date
, countof (date
), "%x", ttm
);
34 strftime (time
, countof (time
), "%X", ttm
);
35 char line2
[60]; _snprintf (line2
, 60, format2
, date
, time
);
39 //---------------------------------------------------------------------------
40 // OLE API documentation
41 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvss/html/vssauto.asp
43 //---------------------------------------------------------------------------
44 //struct RECORD_HEADER {
50 #define SS_TYPE_I(T) BOOST_PP_SEQ_ELEM(0, T)
51 #define SS_VARIABLE_I(T) BOOST_PP_SEQ_ELEM(1, T)
52 #define SS_ARRAYSIZE_I(T) BOOST_PP_SEQ_ELEM(2, T)
53 #define SS_RETURNTYPE_I(T) BOOST_PP_SEQ_ELEM(3, T)
54 #define SS_CONVFUNC_I(T) BOOST_PP_SEQ_ELEM(4, T)
56 #define SS_IS_ARRAY_I(T) BOOST_PP_IF (BOOST_PP_GREATER(BOOST_PP_SEQ_SIZE(T),2), BOOST_PP_GREATER(SS_ARRAYSIZE_I(T),1), 0)
57 #define SS_ARRAY_DECL(T) BOOST_PP_CAT([, BOOST_PP_CAT(SS_ARRAYSIZE_I(T), ]))
59 #define SS_IS_RETURNTYPE_I(T) BOOST_PP_GREATER(BOOST_PP_SEQ_SIZE(T),3)
60 #define SS_IS_CONVFUNC_I(T) BOOST_PP_GREATER(BOOST_PP_SEQ_SIZE(T),4)
62 #define SS_TYPE(T) SS_TYPE_I(T)
63 #define SS_NAME(T) SS_VARIABLE_I(T)
64 #define SS_VARIABLE_DECL(T) BOOST_PP_IF(SS_IS_ARRAY_I(T), BOOST_PP_CAT(SS_VARIABLE_I(T), SS_ARRAY_DECL(T)), SS_VARIABLE_I(T))
65 #define SS_RETURNTYPE(T) BOOST_PP_IF(SS_IS_RETURNTYPE_I(T), SS_RETURNTYPE_I(T), SS_TYPE_I(T))
67 #define SS_ACCESSOR(DATA, T) return (DATA->SS_NAME(T));
68 #define SS_CONVERTER(DATA, T, FUNC) return FUNC (DATA->SS_NAME(T), SS_ARRAYSIZE_I(T));
71 #define DEFINE_ELEMENTS(r, data, T) \
72 SS_TYPE(T) SS_VARIABLE_DECL(T);
74 #define SS_STRUCT(name, fields) \
77 BOOST_PP_SEQ_FOR_EACH(DEFINE_ELEMENTS, ~, fields) \
80 #define DEFINE_ACCESSORS(R, DATA, T) \
81 SS_RETURNTYPE(T) BOOST_PP_CAT (Get, SS_NAME(T)) () const\
83 BOOST_PP_IF(SS_IS_CONVFUNC_I(T), SS_CONVERTER(DATA, T, SS_CONVFUNC_I(T)), SS_ACCESSOR(DATA, T)); \
87 #define RECORD_HEADER_SEQ \
89 ((char) (type) (2) (std::string) (toString)) \
92 SS_STRUCT(RECORD_HEADER
, RECORD_HEADER_SEQ
);
96 // short flags; // 00 = item, 01 == project
97 // char name[34]; // short name
98 // ulong nsmap; // offset into the names.dat
103 ((short) (flags)) /* 00 = item, 01 == project */ \
104 ((char) (name) (34) (std::string) (toString)) /* short name */ \
105 ((ulong) (nsmap)) /* offset into the names.dat */
107 SS_STRUCT(SSNAME
, SSNAME_SEQ
);
109 // TODO: in the OLE API: VSSITEM_PROJECT = 0; VSSITEM_FILE = 1
110 #define SSITEM_PROJECT 1
111 #define SSITEM_FILE 2
121 // short type; // 1 Project, 2 File
123 // short numberOfRecords;
125 // // This is the last name that was given to the item
128 // char fileExt[2]; // .A or .B
130 // // offsets for records
131 // ulong i1; // first EL Header
132 // ulong i2; // last EL oder FD HEader
133 // ulong i3; // size of the file
137 ((short) (Type)) /* 1 Project, 2 File */ \
138 ((short) (NumberOfActions)) \
140 /* This is the last name that was given to the item */ \
141 ((SSNAME) (SSName)) \
142 ((char) (Dummy) (2) (std::string) (toString)) \
143 ((char) (LatestExt) (2) (std::string) (toString)) /* .A or .B */ \
145 /* offsets for records */ \
146 ((ulong) (HistoryOffsetBegin)) /* first EL Header */ \
147 ((ulong) (HistoryOffsetLast)) /* last EL oder FD HEader */ \
148 ((ulong) (HistoryOffsetEnd)) /* size of the file */
150 SS_STRUCT (DH
, DH_SEQ
);
154 struct DH_FILE
: public DH
{
159 // 0x04 == store only latest revision
160 // 0x41 == checked out
163 char ShareSrcSpec
[10];
165 ulong OffsetBFRecord
; // offset to the last BR record in the file
166 ulong OffsetPFRecord
; // offset to the last PF record in the file
167 short NumberOfBranches
; // number of the BF records
168 short NumberOfReferences
; // Reference count for the item
170 ulong OffsetCFRecord1
; // file checked out, ptr to CF record
171 ulong OffsetCFRecord2
; // file not checked out, ptr to CF record
172 int unknown
; // changes after checkin
176 // diese scheinen immer Paare zu bilden, nach einem Checkin ändert sich
188 // dito wie dxx, jedoch zum ersten mal nach einem Checkin
198 short NumberOfItems
; // including projects
199 short NumberOfProjects
; // number of subprojects
202 struct DH_PROJECT
: public DH
{
205 char ParentSpec
[258]; // of last checkout
211 short NumberOfItems
; // including projects
212 short NumberOfProjects
;
220 Destroyed_Project
= 4,
224 Recovered_Project
= 8,
226 Renamed_Project
= 10,
228 // missing action 12,
230 Shared_File
= 14, // Share, Pin, Unpin
231 Branch_File
= 15, // reported as Rollback im Parent Project
236 // missing known actions: archives, restores
239 inline eAction
ushortToAction (const ushort
& v
, int)
241 return static_cast <eAction
> (v
);
244 #define VERSION_RECORD_SEQ \
245 ((ulong) (Previous)) /* previous VERSION_RECORD */ \
246 ((ushort) (ActionID) (1) (eAction) (ushortToAction)) /* eAction action */ \
247 ((short) (VersionNumber)) \
248 ((time_t) (Date) (1) (std::string) (timeToString)) \
249 ((char) (Username) (32) (std::string) (toString)) \
251 ((char) (Label) (32) (std::string) (toString)) \
253 /* This seems to be always be a pointer to the next record \
254 If (lengthComment != 0) this next record is the comment record */ \
255 ((ulong) (OffsetToNextRecordOrComment)) \
257 /* This offset seems to be NULL in most cases \
258 In case of a LabelAction this is the offset to the so called LabelComment Record \
259 In addition the lengthLabelComment is > 0 */ \
260 ((ulong) (OffsetToLabelComment)) \
262 /* Length of the comment strings */ \
263 ((short) (LengthComment)) \
264 ((short) (LengthLabelComment))
266 SS_STRUCT (VERSION_RECORD
, VERSION_RECORD_SEQ
);
268 //struct VERSION_RECORD {
269 // ulong previous; // previous VERSION_RECORD
270 // ushort action; // eAction action;
277 // // This seems to be always be a pointer to the next record
278 // // If (lengthComment != 0) this next record is the comment record
279 // ulong offsetToNextRecordOrComment;
281 // // This offset seems to be NULL in most cases
282 // // In case of a LabelAction this is the offset to the so called LabelComment Record
283 // // In addition the lengthLabelComment is > 0
284 // ulong offsetToLabelComment;
286 // // Length of the comment strings
287 // short lengthComment;
288 // short lengthLabelComment;
296 //struct CREATED_PROJECT_ACTION {
298 // char physical[10];
301 //struct ADDED_PROJECT_ACTION {
303 // char physical[10];
306 //struct ADDED_FILE_ACTION {
308 // char physical[10];
311 struct DESTROYED_ACTION
{
317 //struct DESTROYED_PROJECT_ACTION {
320 // char physical[10];
323 //struct DESTROYED_FILE_ACTION {
326 // char physical[10];
329 //struct DELETED_PROJECT_ACTION {
331 // char physical[10];
334 //struct DELETED_FILE_ACTION {
336 // char physical[10];
339 //struct RECOVERED_PROJECT_ACTION {
341 // char physical[10];
344 //struct RECOVERED_FILE_ACTION {
346 // char physical[10];
349 struct RENAMED_ACTION
{
351 SSNAME name
; // old name
355 struct SHARED_FILE_ACTION
{
356 char srcPathSpec
[260];
358 short pinnedToVersion
; // -1: shared, 0: pinned; >0 unpinned und letzte Version?
359 short version
; // >0: version, ==0 unpinned
360 short padding2
; // reference ins project file? Nr des shares?
364 //struct CREATED_FILE_ACTION {
366 // char physical[10];
369 struct CHECKED_IN_ACTION
{
370 ulong offsetFileDelta
;
372 char checkInSpec
[260];
375 struct ROLLBACK_ACTION
{
386 char CheckOutFolder
[256];
390 // char parentSpec[80];
391 // char fileSpec2[60];
392 // char padding3[120];
393 char ParentSpec
[260];
399 // Check Out: flag1=01, flag2=40, flag3=00
400 // Check In : flag1=00, flag2=00, flag3=10
406 int NumberOfVersions
;
410 short command
; // 01 copy, 00 replace, 02
417 ulong PreviousOffset
;
423 ulong PreviousOffset
;
424 char BranchToPhys
[10];
428 //---------------------------------------------------------------------------
429 struct PROJECT_ENTRY
{
432 // 0x02 store binary diffs
433 // 0x04 store only latest revision
437 short pinnedToVersion
;
441 //---------------------------------------------------------------------------
467 //---------------------------------------------------------------------------
471 static const char* ActionToString (eAction e
);
476 #endif // !defined(AFX_SSTYPES_H__6602C07F_65ED_4FD7_A730_6D416805378A__INCLUDED_)