1 #ifndef PKCS11_DISPLAY_H 2 #define PKCS11_DISPLAY_H 3 4 /* 5 * Copyright (C) 2015 Mathias Brossard <mathias@brossard.org> 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, 20 * USA 21 */ 22 23 #include <stdlib.h> 24 #include <stdio.h> 25 26 #include "pkcs11.h" 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 typedef void (display_func) \ 33 (FILE *, CK_LONG, CK_VOID_PTR, CK_ULONG, CK_VOID_PTR); 34 35 typedef struct { 36 CK_ULONG type; 37 const char *name; 38 } enum_specs; 39 40 typedef struct { 41 CK_ULONG type; 42 enum_specs *specs; 43 CK_ULONG size; 44 const char *name; 45 } enum_spec; 46 47 typedef struct { 48 CK_ULONG type; 49 const char * name; 50 display_func* display; 51 void * arg; 52 } type_spec; 53 54 enum ck_type{ 55 OBJ_T, 56 PROFILE_T, 57 KEY_T, 58 CRT_T, 59 MEC_T, 60 MGF_T, 61 USR_T, 62 STA_T, 63 CKD_T, 64 RV_T 65 }; 66 67 const char *lookup_enum_spec(enum_spec *spec, CK_ULONG value); 68 const char *lookup_enum(CK_ULONG type, CK_ULONG value); 69 void print_enum (FILE *f, CK_LONG type, CK_VOID_PTR value, CK_ULONG size, CK_VOID_PTR arg); 70 void print_boolean (FILE *f, CK_LONG type, CK_VOID_PTR value, CK_ULONG size, CK_VOID_PTR arg); 71 void print_generic (FILE *f, CK_LONG type, CK_VOID_PTR value, CK_ULONG size, CK_VOID_PTR arg); 72 void print_print (FILE *f, CK_LONG type, CK_VOID_PTR value, CK_ULONG size, CK_VOID_PTR arg); 73 void show_error (FILE *f, char *str, CK_RV rc); 74 75 void print_ck_info(FILE *f, CK_INFO *info); 76 void print_slot_list(FILE *f, CK_SLOT_ID_PTR pSlotList, CK_ULONG ulCount); 77 void print_slot_info(FILE *f, CK_SLOT_INFO *info); 78 void print_token_info(FILE *f, CK_TOKEN_INFO *info); 79 void print_mech_list(FILE *f, CK_MECHANISM_TYPE_PTR pMechanismList, 80 CK_ULONG ulMechCount); 81 void print_mech_info(FILE *f, CK_MECHANISM_TYPE type, 82 CK_MECHANISM_INFO_PTR minfo); 83 void print_attribute_list(FILE *f, CK_ATTRIBUTE_PTR pTemplate, 84 CK_ULONG ulCount); 85 void print_attribute_list_req(FILE *f, CK_ATTRIBUTE_PTR pTemplate, 86 CK_ULONG ulCount); 87 void print_session_info(FILE *f, CK_SESSION_INFO *info); 88 void print_interfaces_list(FILE *f, CK_INTERFACE_PTR pInterfacesList, CK_ULONG ulCount); 89 90 extern type_spec ck_attribute_specs[]; 91 extern CK_ULONG ck_attribute_num; 92 extern enum_spec ck_types[]; 93 94 #ifdef __cplusplus 95 }; 96 #endif 97 98 #endif 99