Blame nss/cmd/lib/pk11table.h

Packit 40b132
/* This Source Code Form is subject to the terms of the Mozilla Public
Packit 40b132
 * License, v. 2.0. If a copy of the MPL was not distributed with this
Packit 40b132
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Packit 40b132
#ifndef _PK11_TABLE_H_
Packit 40b132
#define _PK11_TABLE_H_
Packit 40b132
Packit 40b132
/*
Packit 40b132
 * Supported functions..
Packit 40b132
 */
Packit 40b132
#include <pkcs11.h>
Packit 40b132
#include "nspr.h"
Packit 40b132
#include "prtypes.h"
Packit 40b132
Packit 40b132
typedef enum {
Packit 40b132
    F_No_Function,
Packit 40b132
#undef CK_NEED_ARG_LIST
Packit 40b132
#define CK_PKCS11_FUNCTION_INFO(func) F_##func,
Packit 40b132
#include "pkcs11f.h"
Packit 40b132
#undef CK_NEED_ARG_LISt
Packit 40b132
#undef CK_PKCS11_FUNCTION_INFO
Packit 40b132
    F_SetVar,
Packit 40b132
    F_SetStringVar,
Packit 40b132
    F_NewArray,
Packit 40b132
    F_NewInitializeArgs,
Packit 40b132
    F_NewTemplate,
Packit 40b132
    F_NewMechanism,
Packit 40b132
    F_BuildTemplate,
Packit 40b132
    F_SetTemplate,
Packit 40b132
    F_Print,
Packit 40b132
    F_SaveVar,
Packit 40b132
    F_RestoreVar,
Packit 40b132
    F_Increment,
Packit 40b132
    F_Decrement,
Packit 40b132
    F_Delete,
Packit 40b132
    F_List,
Packit 40b132
    F_Run,
Packit 40b132
    F_Load,
Packit 40b132
    F_Unload,
Packit 40b132
    F_System,
Packit 40b132
    F_Loop,
Packit 40b132
    F_Time,
Packit 40b132
    F_Help,
Packit 40b132
    F_Quit,
Packit 40b132
    F_QuitIf,
Packit 40b132
    F_QuitIfString
Packit 40b132
} FunctionType;
Packit 40b132
Packit 40b132
/*
Packit 40b132
 * Supported Argument Types
Packit 40b132
 */
Packit 40b132
typedef enum {
Packit 40b132
    ArgNone,
Packit 40b132
    ArgVar,
Packit 40b132
    ArgULong,
Packit 40b132
    ArgChar,
Packit 40b132
    ArgUTF8,
Packit 40b132
    ArgInfo,
Packit 40b132
    ArgSlotInfo,
Packit 40b132
    ArgTokenInfo,
Packit 40b132
    ArgSessionInfo,
Packit 40b132
    ArgAttribute,
Packit 40b132
    ArgMechanism,
Packit 40b132
    ArgMechanismInfo,
Packit 40b132
    ArgInitializeArgs,
Packit 40b132
    ArgFunctionList,
Packit 40b132
/* Modifier Flags */
Packit 40b132
    ArgMask = 0xff,
Packit 40b132
    ArgOut = 0x100,
Packit 40b132
    ArgArray = 0x200,
Packit 40b132
    ArgNew = 0x400,
Packit 40b132
    ArgFile = 0x800,
Packit 40b132
    ArgStatic = 0x1000,
Packit 40b132
    ArgOpt = 0x2000,
Packit 40b132
    ArgFull = 0x4000
Packit 40b132
} ArgType;
Packit 40b132
Packit 40b132
typedef enum _constType
Packit 40b132
{
Packit 40b132
    ConstNone,
Packit 40b132
    ConstBool,
Packit 40b132
    ConstInfoFlags,
Packit 40b132
    ConstSlotFlags,
Packit 40b132
    ConstTokenFlags,
Packit 40b132
    ConstSessionFlags,
Packit 40b132
    ConstMechanismFlags,
Packit 40b132
    ConstInitializeFlags,
Packit 40b132
    ConstUsers,
Packit 40b132
    ConstSessionState,
Packit 40b132
    ConstObject,
Packit 40b132
    ConstHardware,
Packit 40b132
    ConstKeyType,
Packit 40b132
    ConstCertType,
Packit 40b132
    ConstAttribute,
Packit 40b132
    ConstMechanism,
Packit 40b132
    ConstResult,
Packit 40b132
    ConstTrust,
Packit 40b132
    ConstAvailableSizes,
Packit 40b132
    ConstCurrentSize
Packit 40b132
} ConstType;
Packit 40b132
Packit 40b132
typedef struct _constant {
Packit 40b132
    const char *name;
Packit 40b132
    CK_ULONG value;
Packit 40b132
    ConstType type;
Packit 40b132
    ConstType attrType;
Packit 40b132
} Constant ;
Packit 40b132
Packit 40b132
/*
Packit 40b132
 * Values structures.
Packit 40b132
 */
Packit 40b132
typedef struct _values {
Packit 40b132
    ArgType	type;
Packit 40b132
    ConstType	constType;
Packit 40b132
    int		size;
Packit 40b132
    char	*filename;
Packit 40b132
    void	*data;
Packit 40b132
    int 	reference;
Packit 40b132
    int		arraySize;
Packit 40b132
} Value;
Packit 40b132
Packit 40b132
/*
Packit 40b132
 * Variables
Packit 40b132
 */
Packit 40b132
typedef struct _variable Variable;
Packit 40b132
struct _variable {
Packit 40b132
    Variable *next;
Packit 40b132
    char *vname;
Packit 40b132
    Value *value;
Packit 40b132
};
Packit 40b132
Packit 40b132
/* NOTE: if you change MAX_ARGS, you need to change the commands array
Packit 40b132
 * below as well.
Packit 40b132
 */
Packit 40b132
Packit 40b132
#define MAX_ARGS 10
Packit 40b132
/*
Packit 40b132
 * structure for master command array
Packit 40b132
 */
Packit 40b132
typedef struct _commands {
Packit 40b132
    char	*fname;
Packit 40b132
    FunctionType	fType;
Packit 40b132
    char	*helpString;
Packit 40b132
    ArgType	args[MAX_ARGS];
Packit 40b132
} Commands;
Packit 40b132
Packit 40b132
typedef struct _module {
Packit 40b132
    PRLibrary *library;
Packit 40b132
    CK_FUNCTION_LIST *functionList;
Packit 40b132
} Module;
Packit 40b132
Packit 40b132
typedef struct _topics {
Packit 40b132
    char	*name;
Packit 40b132
    char	*helpString;
Packit 40b132
} Topics;
Packit 40b132
Packit 40b132
/*
Packit 40b132
 * the command array itself. Make name to function and it's arguments
Packit 40b132
 */
Packit 40b132
Packit 40b132
extern const char **valueString;
Packit 40b132
extern const int valueCount;
Packit 40b132
extern const char **constTypeString;
Packit 40b132
extern const int constTypeCount;
Packit 40b132
extern const Constant *consts;
Packit 40b132
extern const int constCount;
Packit 40b132
extern const Commands *commands;
Packit 40b132
extern const int commandCount;
Packit 40b132
extern const Topics *topics;
Packit 40b132
extern const int topicCount;
Packit 40b132
Packit 40b132
extern const char *
Packit 40b132
getName(CK_ULONG value, ConstType type);
Packit 40b132
Packit 40b132
extern const char *
Packit 40b132
getNameFromAttribute(CK_ATTRIBUTE_TYPE type);
Packit 40b132
Packit 40b132
extern int totalKnownType(ConstType type);
Packit 40b132
Packit 40b132
#endif /* _PK11_TABLE_H_ */
Packit 40b132