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