Back to index

lightning-sunbird  0.9+nobinonly
pk11util.h
Go to the documentation of this file.
00001 
00002 /*
00003  * Supported functions..
00004  */
00005 #include <pkcs11.h>
00006 #include "nspr.h"
00007 #include "prtypes.h"
00008 
00009 typedef enum {
00010     F_No_Function,
00011 #undef CK_NEED_ARG_LIST
00012 #define CK_PKCS11_FUNCTION_INFO(func) F_##func,
00013 #include "pkcs11f.h"
00014 #undef CK_NEED_ARG_LISt
00015 #undef CK_PKCS11_FUNCTION_INFO
00016     F_SetVar,
00017     F_SetStringVar,
00018     F_NewArray,
00019     F_NewInitializeArgs,
00020     F_NewTemplate,
00021     F_NewMechanism,
00022     F_BuildTemplate,
00023     F_SetTemplate,
00024     F_Print,
00025     F_SaveVar,
00026     F_RestoreVar,
00027     F_Increment,
00028     F_Decrement,
00029     F_Delete,
00030     F_List,
00031     F_Run,
00032     F_Load,
00033     F_Unload,
00034     F_System,
00035     F_Loop,
00036     F_Time,
00037     F_Help,
00038     F_Quit,
00039     F_QuitIf,
00040     F_QuitIfString,
00041 } FunctionType;
00042 
00043 /*
00044  * Supported Argument Types
00045  */
00046 typedef enum {
00047     ArgNone,
00048     ArgVar,
00049     ArgULong,
00050     ArgChar,
00051     ArgUTF8,
00052     ArgInfo,
00053     ArgSlotInfo,
00054     ArgTokenInfo,
00055     ArgSessionInfo,
00056     ArgAttribute,
00057     ArgMechanism,
00058     ArgMechanismInfo,
00059     ArgInitializeArgs,
00060     ArgFunctionList,
00061 /* Modifier Flags */
00062     ArgMask = 0xff,
00063     ArgOut = 0x100,
00064     ArgArray = 0x200,
00065     ArgNew = 0x400,
00066     ArgFile = 0x800,
00067     ArgStatic = 0x1000,
00068     ArgOpt = 0x2000,
00069     ArgFull = 0x4000,
00070 } ArgType;
00071 
00072 typedef enum _constType
00073 {
00074     ConstNone,
00075     ConstBool,
00076     ConstInfoFlags,
00077     ConstSlotFlags,
00078     ConstTokenFlags,
00079     ConstSessionFlags,
00080     ConstMechanismFlags,
00081     ConstInitializeFlags,
00082     ConstUsers,
00083     ConstSessionState,
00084     ConstObject,
00085     ConstHardware,
00086     ConstKeyType,
00087     ConstCertType,
00088     ConstAttribute,
00089     ConstMechanism,
00090     ConstResult,
00091     ConstTrust,
00092     ConstAvailableSizes,
00093     ConstCurrentSize
00094 } ConstType;
00095 
00096 typedef struct _constant {
00097     const char *name;
00098     CK_ULONG value;
00099     ConstType type;
00100     ConstType attrType;
00101 } Constant ;
00102 
00103 /*
00104  * Values structures.
00105  */
00106 typedef struct _values {
00107     ArgType   type;
00108     ConstType constType;
00109     int              size;
00110     char      *filename;
00111     void      *data;
00112     int       reference;
00113     int              arraySize;
00114 } Value;
00115 
00116 /*
00117  * Variables
00118  */
00119 typedef struct _variable Variable;
00120 struct _variable {
00121     Variable *next;
00122     char *vname;
00123     Value *value;
00124 };
00125 
00126 /* NOTE: if you change MAX_ARGS, you need to change the commands array
00127  * below as well.
00128  */
00129 
00130 #define MAX_ARGS 10
00131 /*
00132  * structure for master command array
00133  */
00134 typedef struct _commands {
00135     char      *fname;
00136     FunctionType     fType;
00137     char      *helpString;
00138     ArgType   args[MAX_ARGS];
00139 } Commands;
00140 
00141 typedef struct _module {
00142     PRLibrary *library;
00143     CK_FUNCTION_LIST *functionList;
00144 } Module;
00145 
00146 typedef struct _topics {
00147     char      *name;
00148     char      *helpString;
00149 } Topics;
00150 
00151 /*
00152  * the command array itself. Make name to function and it's arguments
00153  */
00154 
00155 extern const char **valueString;
00156 extern const int valueCount;
00157 extern const char **constTypeString;
00158 extern const int constTypeCount;
00159 extern const Constant *consts;
00160 extern const int constCount;
00161 extern const Commands *commands;
00162 extern const int commandCount;
00163 extern const Topics *topics;
00164 extern const int topicCount;
00165