summaryrefslogtreecommitdiff
path: root/plugins/CryptoPP/src/PGPw/sdk8/include/pgpGroups.h
blob: 73f9eb6db6a661f9d7209b258baa5f4fc4be548f (plain)
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
/*____________________________________________________________________________
	Copyright (C) 2002 PGP Corporation
	All rights reserved.
	
	$Id: pgpGroups.h,v 1.12 2003/08/08 04:40:39 ajivsov Exp $
____________________________________________________________________________*/

#ifndef Included_pgpGroups_h	/* [ */
#define Included_pgpGroups_h

/*____________________________________________________________________________
	Note: All functions in this file have been deprecated and will be
	replaced in the future with equivalent functionality.
____________________________________________________________________________*/

#include "pgpPubTypes.h"
#include "pgpEncode.h"

#if PGP_DEPRECATED	/* [ */

#if PGP_MACINTOSH
#include <Files.h>
#endif

#if PGP_MACINTOSH
#pragma options align=mac68k
#endif

#define kPGPMaxGroupNameLength				63
#define kPGPMaxGroupDescriptionLength		63

typedef PGPChar8	PGPGroupName[ kPGPMaxGroupNameLength + 1 ];
typedef PGPChar8	PGPGroupDescription[ kPGPMaxGroupDescriptionLength + 1 ];


typedef struct PGPGroupSet *		PGPGroupSetRef;
typedef struct PGPGroupIter *		PGPGroupItemIterRef;

#define	kInvalidPGPGroupSetRef			((PGPGroupSetRef) NULL)
#define	kInvalidPGPGroupItemIterRef		((PGPGroupItemIterRef) NULL)

#define PGPGroupSetRefIsValid(ref)		((ref) != kInvalidPGPGroupSetRef)
#define PGPGroupItemIterRefIsValid(ref)	((ref) != kInvalidPGPGroupItemIterRef)

/* any type will do that is distinct */
typedef PGPUInt32				PGPGroupID;
#define kPGPInvalidGroupID		( (PGPGroupID)0 )

enum PGPGroupItemType_
{
	kPGPGroupItem_KeyID = 1,
	kPGPGroupItem_Group,
	
	PGP_ENUM_FORCE( PGPGroupItemType_)
};
PGPENUM_TYPEDEF( PGPGroupItemType_, PGPGroupItemType );

/*____________________________________________________________________________
	A run-time group item, used when iterating through a group.
	For client use; not necessarily the internal storage format.
	
	'userValue' is *not* saved to disk.
____________________________________________________________________________*/

typedef struct PGPGroupItem
{
	PGPGroupItemType	type;
	PGPUserValue		userValue;
	
	union
	{
		PGPGroupID	groupID;
		PGPKeyID	keyID;
	} u;
} PGPGroupItem;


typedef PGPInt32	(*PGPGroupItemCompareProc)( PGPGroupItem *,
							PGPGroupItem *, PGPUserValue userValue );

/*____________________________________________________________________________
	Info obtained via PGPGetGroupInfo.
____________________________________________________________________________*/

typedef struct PGPGroupInfo
{
	PGPGroupID		id;
	PGPGroupName	name;
	PGPGroupName	description;
	PGPUserValue	userValue;
	
} PGPGroupInfo;


typedef PGPFlags	PGPGroupItemIterFlags;
/* flag (1UL << 0 ) is reserved */
#define kPGPGroupIterFlags_Recursive	(PGPFlags)(1UL << 1 )
#define kPGPGroupIterFlags_Keys			(PGPFlags)(1UL << 2 )
#define kPGPGroupIterFlags_Groups		(PGPFlags)(1UL << 3 )

#define kPGPGroupIterFlags_AllKeysRecursive			\
	( kPGPGroupIterFlags_Recursive | kPGPGroupIterFlags_Keys )
	
#define kPGPGroupIterFlags_AllGroupsRecursive			\
	( kPGPGroupIterFlags_Recursive | kPGPGroupIterFlags_Groups )
	
#define kPGPGroupIterFlags_AllItems			\
	( kPGPGroupIterFlags_Keys | kPGPGroupIterFlags_Groups )
	
#define kPGPGroupIterFlags_AllRecursive	\
	( kPGPGroupIterFlags_Recursive | kPGPGroupIterFlags_AllItems )
	
	

#if PGP_MACINTOSH
#pragma options align=reset
#endif

PGP_BEGIN_C_DECLARATIONS

/*____________________________________________________________________________
	Manipulating pgp group sets (PGPGroupSetRef)
____________________________________________________________________________*/
/* create a new, empty groups collection */
PGPError	PGPNewGroupSet( PGPContextRef context, PGPGroupSetRef *outRef );

/* file is *not* left open; all data is loaded into memory */
PGPError	PGPNewGroupSetFromFile( PGPContextRef context,
				PGPFileSpecRef file,
				PGPGroupSetRef *outRef );

#if PGP_MACINTOSH || PGP_OSX
PGPError	PGPNewGroupSetFromFSSpec( PGPContextRef context,
				const struct FSSpec *spec, PGPGroupSetRef *outRef );
#endif

/* overwrites existing.  Don't bother unless PGPGroupSetNeedsCommit() */
PGPError	PGPSaveGroupSetToFile( PGPGroupSetRef set, PGPFileSpecRef file );

/* free all data structures; be sure to save first if you want */
PGPError	PGPFreeGroupSet( PGPGroupSetRef set );


/* has the group changed? */
PGPBoolean		PGPGroupSetNeedsCommit( PGPGroupSetRef set );

PGPContextRef	PGPGetGroupSetContext( PGPGroupSetRef set );
		
/* export the groupset to a buffer. Use PGPFreeData to free the buffer */
PGPError	PGPExportGroupSetToBuffer( PGPGroupSetRef set, void **buffer,
				PGPSize *bufferSize );

/* import a groupset from a buffer */
PGPError	PGPImportGroupSetFromBuffer(PGPContextRef context, void *buffer,
				PGPSize bufSize, PGPGroupSetRef *outSet );
		
/*____________________________________________________________________________
	Manipulating groups
	
	Groups are always referred to by IDs which remain valid until the set
	is disposed.
____________________________________________________________________________*/

/* initial parent ID is kPGPInvalidGroupID */
PGPError	PGPNewGroup( PGPGroupSetRef set,
				const PGPChar8 * name, const PGPChar8 *description,
				PGPGroupID *id );

PGPError	PGPCountGroupsInSet( PGPGroupSetRef set,
				PGPUInt32 *numGroups);
PGPError	PGPGetIndGroupID( PGPGroupSetRef set,
				PGPUInt32 groupIndex, PGPGroupID *id );

/* delete this group from the set */
/* All references to it are removed in all sets */
PGPError	PGPDeleteGroup( PGPGroupSetRef set, PGPGroupID id );

/* delete the indexed item from the group */
/* the item may be a group or a key */
PGPError	PGPDeleteIndItemFromGroup( PGPGroupSetRef set,
				PGPGroupID	id, PGPUInt32 item );

/* same as PGPDeleteIndItemFromGroup, but accepts an item */
PGPError	PGPDeleteItemFromGroup( PGPGroupSetRef set,
				PGPGroupID id, PGPGroupItem const *item );


PGPError	PGPGetGroupInfo( PGPGroupSetRef set,
				PGPGroupID id, PGPGroupInfo *info );
				
PGPError	PGPSetGroupName( PGPGroupSetRef set,
				PGPGroupID id, const PGPChar8 * name );
PGPError	PGPSetGroupUserValue( PGPGroupSetRef set,
				PGPGroupID id, PGPUserValue userValue );
PGPError	PGPSetGroupDescription( PGPGroupSetRef set,
				PGPGroupID id, const PGPChar8 * name );

/* 'item' specifies a group or a key id */
/* you must fill the item in completely */
PGPError	PGPAddItemToGroup( PGPGroupSetRef set,
				PGPGroupItem const *item, PGPGroupID group );


PGPError	PGPMergeGroupIntoDifferentSet( PGPGroupSetRef fromSet,
				PGPGroupID fromID, PGPGroupSetRef toSet );

PGPError	PGPMergeGroupSets( PGPGroupSetRef fromSet,
				PGPGroupSetRef intoSet );

PGPError	PGPCopyGroupSet(PGPGroupSetRef sourceSet,
				PGPGroupSetRef *destSet);
	
/*____________________________________________________________________________
	Manipulating group items
____________________________________________________________________________*/

/* count how many items there are in a group */
/* totalItems includes keys and groups */
PGPError	PGPCountGroupItems( PGPGroupSetRef set,
					PGPGroupID id, PGPBoolean recursive,
					PGPUInt32 * numKeys,
					PGPUInt32 * totalItems );

/* non-recursive call; index only applies to group itself */
PGPError	PGPGetIndGroupItem( PGPGroupSetRef set,
				PGPGroupID id, PGPUInt32 groupIndex, PGPGroupItem * item );

/* use PGPGetIndGroupItem() if you want to get the user value */
PGPError	PGPSetIndGroupItemUserValue( PGPGroupSetRef set,
				PGPGroupID id, PGPUInt32 groupIndex, PGPUserValue userValue );

PGPError	PGPSortGroupItems( PGPGroupSetRef set, PGPGroupID id,
				PGPGroupItemCompareProc, PGPUserValue userValue );
				
PGPError	PGPSortGroupSet( PGPGroupSetRef set,
				PGPGroupItemCompareProc, PGPUserValue userValue );

/*____________________________________________________________________________
	PGPGroupItemIterRef--iterator through group items.
	
	Special note: this is not a full-fledged iterator.  You may *not* add
	or delete items while iterating and you may only move forward.  However,
	you may change the values of items.
____________________________________________________________________________*/

PGPError	PGPNewGroupItemIter( PGPGroupSetRef set, PGPGroupID id,
				PGPGroupItemIterFlags flags, PGPGroupItemIterRef *iter );
				
PGPError	PGPFreeGroupItemIter( PGPGroupItemIterRef iter );

/* returns kPGPError_EndOfIteration when done */
PGPError	PGPGroupItemIterNext( PGPGroupItemIterRef iter,
				PGPGroupItem * item );

/*____________________________________________________________________________
	Group utilities
____________________________________________________________________________*/

/*____________________________________________________________________________
	Return the lowest validity of any item in the group
	keyset should contain all keys available
	It is not an error if keys can't be found; you may want to check
	the not found count.
	
	The lowest validity is kPGPValidity_Invalid and kPGPValidity_Unknown
	is never returned.
____________________________________________________________________________*/
PGPError	PGPGetGroupLowestValidity( PGPGroupSetRef set, PGPGroupID id,
				PGPKeyDBRef keyDB, PGPValidity * lowestValidity,
				PGPUInt32 * numKeysNotFound);

/*____________________________________________________________________________
	All all the keys in the group (and its subgroups) to the keyset
____________________________________________________________________________*/
PGPError	PGPNewKeySetFromGroup( PGPGroupSetRef set, PGPGroupID id,
				PGPKeyDBRef keyDB, PGPKeySetRef * resultSet,
				PGPUInt32 * numKeysNotFound);

/*____________________________________________________________________________
	Create a simple, flattened group of unique key IDs from the source group.
	Note that sourceSet and destSet must be different.
____________________________________________________________________________*/
PGPError	PGPNewFlattenedGroupFromGroup(PGPGroupSetRef sourceSet,
				PGPGroupID sourceID, PGPGroupSetRef destSet,
				PGPGroupID *destID);

/*____________________________________________________________________________
	Perform a "standard" sort on a group
____________________________________________________________________________*/
PGPError	PGPSortGroupSetStd( PGPGroupSetRef set, PGPKeyDBRef keydb );
				

PGP_END_C_DECLARATIONS

#endif	/* ] PGP_DEPRECATED */

#endif /* ] Included_pgpGroups_h */


/*__Editor_settings____

	Local Variables:
	tab-width: 4
	End:
	vi: ts=4 sw=4
	vim: si
_____________________*/