|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 #ifndef _PK11_TABLE_H_ |
|
5 #define _PK11_TABLE_H_ |
|
6 |
|
7 /* |
|
8 * Supported functions.. |
|
9 */ |
|
10 #include <pkcs11.h> |
|
11 #include "nspr.h" |
|
12 #include "prtypes.h" |
|
13 |
|
14 typedef enum { |
|
15 F_No_Function, |
|
16 #undef CK_NEED_ARG_LIST |
|
17 #define CK_PKCS11_FUNCTION_INFO(func) F_##func, |
|
18 #include "pkcs11f.h" |
|
19 #undef CK_NEED_ARG_LISt |
|
20 #undef CK_PKCS11_FUNCTION_INFO |
|
21 F_SetVar, |
|
22 F_SetStringVar, |
|
23 F_NewArray, |
|
24 F_NewInitializeArgs, |
|
25 F_NewTemplate, |
|
26 F_NewMechanism, |
|
27 F_BuildTemplate, |
|
28 F_SetTemplate, |
|
29 F_Print, |
|
30 F_SaveVar, |
|
31 F_RestoreVar, |
|
32 F_Increment, |
|
33 F_Decrement, |
|
34 F_Delete, |
|
35 F_List, |
|
36 F_Run, |
|
37 F_Load, |
|
38 F_Unload, |
|
39 F_System, |
|
40 F_Loop, |
|
41 F_Time, |
|
42 F_Help, |
|
43 F_Quit, |
|
44 F_QuitIf, |
|
45 F_QuitIfString |
|
46 } FunctionType; |
|
47 |
|
48 /* |
|
49 * Supported Argument Types |
|
50 */ |
|
51 typedef enum { |
|
52 ArgNone, |
|
53 ArgVar, |
|
54 ArgULong, |
|
55 ArgChar, |
|
56 ArgUTF8, |
|
57 ArgInfo, |
|
58 ArgSlotInfo, |
|
59 ArgTokenInfo, |
|
60 ArgSessionInfo, |
|
61 ArgAttribute, |
|
62 ArgMechanism, |
|
63 ArgMechanismInfo, |
|
64 ArgInitializeArgs, |
|
65 ArgFunctionList, |
|
66 /* Modifier Flags */ |
|
67 ArgMask = 0xff, |
|
68 ArgOut = 0x100, |
|
69 ArgArray = 0x200, |
|
70 ArgNew = 0x400, |
|
71 ArgFile = 0x800, |
|
72 ArgStatic = 0x1000, |
|
73 ArgOpt = 0x2000, |
|
74 ArgFull = 0x4000 |
|
75 } ArgType; |
|
76 |
|
77 typedef enum _constType |
|
78 { |
|
79 ConstNone, |
|
80 ConstBool, |
|
81 ConstInfoFlags, |
|
82 ConstSlotFlags, |
|
83 ConstTokenFlags, |
|
84 ConstSessionFlags, |
|
85 ConstMechanismFlags, |
|
86 ConstInitializeFlags, |
|
87 ConstUsers, |
|
88 ConstSessionState, |
|
89 ConstObject, |
|
90 ConstHardware, |
|
91 ConstKeyType, |
|
92 ConstCertType, |
|
93 ConstAttribute, |
|
94 ConstMechanism, |
|
95 ConstResult, |
|
96 ConstTrust, |
|
97 ConstAvailableSizes, |
|
98 ConstCurrentSize |
|
99 } ConstType; |
|
100 |
|
101 typedef struct _constant { |
|
102 const char *name; |
|
103 CK_ULONG value; |
|
104 ConstType type; |
|
105 ConstType attrType; |
|
106 } Constant ; |
|
107 |
|
108 /* |
|
109 * Values structures. |
|
110 */ |
|
111 typedef struct _values { |
|
112 ArgType type; |
|
113 ConstType constType; |
|
114 int size; |
|
115 char *filename; |
|
116 void *data; |
|
117 int reference; |
|
118 int arraySize; |
|
119 } Value; |
|
120 |
|
121 /* |
|
122 * Variables |
|
123 */ |
|
124 typedef struct _variable Variable; |
|
125 struct _variable { |
|
126 Variable *next; |
|
127 char *vname; |
|
128 Value *value; |
|
129 }; |
|
130 |
|
131 /* NOTE: if you change MAX_ARGS, you need to change the commands array |
|
132 * below as well. |
|
133 */ |
|
134 |
|
135 #define MAX_ARGS 10 |
|
136 /* |
|
137 * structure for master command array |
|
138 */ |
|
139 typedef struct _commands { |
|
140 char *fname; |
|
141 FunctionType fType; |
|
142 char *helpString; |
|
143 ArgType args[MAX_ARGS]; |
|
144 } Commands; |
|
145 |
|
146 typedef struct _module { |
|
147 PRLibrary *library; |
|
148 CK_FUNCTION_LIST *functionList; |
|
149 } Module; |
|
150 |
|
151 typedef struct _topics { |
|
152 char *name; |
|
153 char *helpString; |
|
154 } Topics; |
|
155 |
|
156 /* |
|
157 * the command array itself. Make name to function and it's arguments |
|
158 */ |
|
159 |
|
160 extern const char **valueString; |
|
161 extern const int valueCount; |
|
162 extern const char **constTypeString; |
|
163 extern const int constTypeCount; |
|
164 extern const Constant *consts; |
|
165 extern const int constCount; |
|
166 extern const Commands *commands; |
|
167 extern const int commandCount; |
|
168 extern const Topics *topics; |
|
169 extern const int topicCount; |
|
170 |
|
171 extern const char * |
|
172 getName(CK_ULONG value, ConstType type); |
|
173 |
|
174 extern const char * |
|
175 getNameFromAttribute(CK_ATTRIBUTE_TYPE type); |
|
176 |
|
177 extern int totalKnownType(ConstType type); |
|
178 |
|
179 #endif /* _PK11_TABLE_H_ */ |
|
180 |