| RSA BSAFE Cert-C Micro Edition |
The power of PKI for the smallest of devices |
00001 /* $Id: r_lib.h,v 1.40 2002/10/16 06:22:09 jmckee Exp $ */
00002 /*
00003 * Copyright (C) 1998-2002 RSA Security Inc. All rights reserved.
00004 *
00005 * This work contains proprietary information of RSA Security.
00006 * Distribution is limited to authorized licensees of RSA
00007 * Security. Any unauthorized reproduction, distribution or
00008 * modification of this work is strictly prohibited.
00009 *
00010 */
00011 /**
00012 * @file
00013 * This file provides information on the structures, function prototypes and
00014 * defines used in the manipulation of library context objects.
00015 */
00016 #ifndef HEADER_COMMON_R_LIB_H
00017 #define HEADER_COMMON_R_LIB_H
00018
00019 #ifdef __cplusplus
00020 extern "C" {
00021 #endif
00022
00023 #include "r_com.h"
00024 #include "r_flg.h"
00025 #include "r_strtbl.h"
00026
00027 #ifndef NO_BIO
00028 #include "bio.h"
00029 #endif
00030
00031 /**
00032 * @defgroup RES_LIST_GROUP Resource List Module
00033 * This section provides information on the resource list, which is used to
00034 * perform link and runtime implementation selection of modules.
00035 * @{
00036 */
00037 /**
00038 * @}
00039 */
00040 /**
00041 * @defgroup RES_LIST_TYPE Types
00042 * This section outlines the types used when dealing with the library and
00043 * the resources within.
00044 * @ingroup RES_LIST_GROUP
00045 *
00046 * @{
00047 */
00048 /**
00049 * The common library context. This opaque structure is created via
00050 * R_LIB_CTX_new() and is required by all other #R_LIB_CTX
00051 * functions. It maintains the state required by the library
00052 * during execution. It can be freed via R_LIB_CTX_free() when it is no
00053 * longer required. Under normal circumstances only one context is
00054 * needed at a time.
00055 */
00056 #ifndef HEADER_COMMON_R_LIB_CTX_TYPEDEF_DEF
00057 #define HEADER_COMMON_R_LIB_CTX_TYPEDEF_DEF
00058 typedef struct r_lib_ctx_st R_LIB_CTX;
00059 #endif
00060 /* end defgroup RES_LIST_TYPE */
00061 /**
00062 * @}
00063 */
00064
00065 #ifndef HEADER_COMMON_R_RES_ITEM_TYPEDEF_DEF
00066 #define HEADER_COMMON_R_RES_ITEM_TYPEDEF_DEF
00067
00068 /**
00069 * The resource item. A structure that is used to store the
00070 * individual members of a resource list.
00071 */
00072 typedef struct r_res_item_st R_RES_ITEM;
00073 #endif
00074
00075 #ifndef HEADER_COMMON_R_RES_LIST_TYPEDEF_DEF
00076 #define HEADER_COMMON_R_RES_LIST_TYPEDEF_DEF
00077 /**
00078 * The resource list. A structure that is used to store the
00079 * resource list.
00080 *
00081 * See @ref R_RES_ITEM.
00082 */
00083 typedef R_RES_ITEM R_RES_LIST;
00084 #endif
00085
00086 #ifndef HEADER_COMMON_R_RES_FLAG_TYPEDEF_DEF
00087 #define HEADER_COMMON_R_RES_FLAG_TYPEDEF_DEF
00088 /**
00089 * Indicates the type of the resource flag.
00090 */
00091 typedef int R_RES_FLAG;
00092 #endif
00093
00094 /**
00095 * The library method table. An opaque structure that contains
00096 * the methods for the #R_LIB_CTX functions.
00097 */
00098 typedef struct r_lib_method_st R_LIB_METHOD;
00099
00100 /**
00101 * The library context debug structure which is used to define the type of
00102 * debugging required and the location where the debug information is
00103 * sent.
00104 */
00105
00106 typedef struct r_lib_debug_st
00107 {
00108 R_FLG dbg_flg;
00109 #ifndef NO_BIO
00110 BIO *bio;
00111 #else
00112 void *bio;
00113 #endif
00114 } R_LIB_DEBUG;
00115
00116 /**
00117 * The library context feature structure which is used to store the state of
00118 * the library features.
00119 */
00120 typedef struct r_lib_feat_st
00121 {
00122 unsigned long feature;
00123 } R_LIB_FEAT;
00124
00125 /* Feature hash defines */
00126 #define R_LIB_FEATURE_LOCKING 0x00000001L
00127 /**
00128 * @defgroup RES_LIST_FN Operation Functions
00129 * This section outlines the functions used for initialization and
00130 * manipulation of the #R_LIB_CTX and resources used within.
00131 * @ingroup RES_LIST_GROUP
00132 *
00133 * @{
00134 */
00135 /* Get string defines */
00136 #define R_LIB_CTX_get_error_string(lib_ctx,mod_id,code) \
00137 R_LIB_CTX_get_string(lib_ctx,mod_id,R_RES_SUB_ID_ERROR_STRINGS,code)
00138 #define R_LIB_CTX_get_reason_string(lib_ctx,mod_id,code) \
00139 R_LIB_CTX_get_string(lib_ctx,mod_id,R_RES_SUB_ID_REASON_STRINGS,code)
00140 #define R_LIB_CTX_get_detail_string(lib_ctx,mod_id,code) \
00141 R_LIB_CTX_get_string(lib_ctx,mod_id,R_RES_SUB_ID_DETAIL_STRINGS,code)
00142 #define R_LIB_CTX_get_function_string(lib_ctx,mod_id,code) \
00143 R_LIB_CTX_get_string(lib_ctx,mod_id,R_RES_SUB_ID_FUNCTION_STRINGS,code)
00144
00145
00146 int R_LIB_CTX_new(R_RES_LIST *r_list, R_RES_FLAG flag, R_LIB_CTX **lib_ctx);
00147 int R_LIB_CTX_free(R_LIB_CTX *lib_ctx);
00148 int R_LIB_CTX_dup(R_LIB_CTX *lib_ctx, R_RES_FLAG flag, R_LIB_CTX **res_ctx);
00149
00150 int R_LIB_CTX_get_resource(R_LIB_CTX *res_ctx, int mod_id, int impl_id,
00151 int sub_id, R_RES_FLAG flag, int res_type, void **data);
00152 int R_LIB_CTX_get_module(R_LIB_CTX *res_ctx, int mod_id, int impl_id,
00153 int sub_id, R_RES_FLAG flag, void **mod);
00154 int R_LIB_CTX_get_module_data(R_LIB_CTX *lib_ctx, int mod_id,
00155 void **impl_data);
00156
00157 int R_LIB_CTX_set_features(R_LIB_CTX *lib_ctx, int impl_id,
00158 unsigned long features);
00159 int R_LIB_CTX_reset_features(R_LIB_CTX *lib_ctx, int impl_id);
00160 int R_LIB_CTX_retrieve_features(R_LIB_CTX *lib_ctx, int impl_id,
00161 unsigned long *features);
00162 unsigned long R_LIB_CTX_get_features(R_LIB_CTX *lib_ctx, int impl_id);
00163 int R_LIB_CTX_feature_disable(R_LIB_CTX *lib_ctx, int impl_id,
00164 unsigned long feature);
00165 int R_LIB_CTX_feature_enable(R_LIB_CTX *lib_ctx, int impl_id,
00166 unsigned long feature);
00167 int R_LIB_CTX_is_feature_enabled(R_LIB_CTX *lib_ctx, int impl_id,
00168 unsigned long feature);
00169
00170 int R_LIB_CTX_get_lib_debug_data(R_LIB_CTX *lib_ctx, R_LIB_DEBUG **data);
00171 int R_LIB_CTX_set_lib_debug_data(R_LIB_CTX *lib_ctx, R_LIB_DEBUG *data);
00172
00173 R_RES_LIST *R_LIB_CTX_get_resource_list(R_LIB_CTX *lib_ctx);
00174
00175 R_LIB_METHOD *R_LIB_CTX_get_default_method(void *imp_data);
00176 R_LIB_METHOD *R_LIB_CTX_get_small_method(void *imp_data);
00177
00178 R_STRTBL *R_LIB_CTX_com_err_str_table(void *imp_data);
00179
00180 int R_LIB_CTX_lib_debug_data_start(R_RES_LIST *res_list, R_RES_ITEM *item,
00181 void **imp_data);
00182 int R_LIB_CTX_lib_feature_start(R_RES_LIST *res_list, R_RES_ITEM *item,
00183 void **imp_data);
00184
00185 char *R_LIB_CTX_get_string(R_LIB_CTX *lib_ctx, int mod_id, int table_id,
00186 int err_code);
00187
00188 /* end defgroup RES_LIST_FN */
00189 /**
00190 * @}
00191 */
00192
00193 /**
00194 * @defgroup R_LIB_RES Library Definitions
00195 * This section details the definitions used in the resource list and
00196 * initialization of the library.
00197 * @ingroup RES_LIST_GROUP
00198 *
00199 * @{
00200 */
00201
00202 /**
00203 * A cut-down library interface that only supports the <tt>get_resource</tt>,
00204 * <tt>get_module</tt> and <tt>get_module_data</tt> methods of the #R_LIB_CTX
00205 * interface.
00206 *
00207 * @see R_LIB_CTX_get_small_method().
00208 */
00209 #define R_LIB_RES_SMALL \
00210 { R_RES_MOD_ID_LIBRARY, R_RES_IMPL_ID_DEF, R_RES_SUB_ID_DEF, \
00211 R_RES_FLAG_DEF, NULL, NULL, \
00212 (void *(*)(void *))R_LIB_CTX_get_small_method, NULL }
00213
00214 /**
00215 * Indicates the full #R_LIB_CTX interface.
00216 * @see R_LIB_CTX_get_default_method().
00217 */
00218 #define R_LIB_RES_DEFAULT \
00219 { R_RES_MOD_ID_LIBRARY, R_RES_IMPL_ID_DEF, R_RES_SUB_ID_DEF, \
00220 R_RES_FLAG_DEF, NULL, NULL, \
00221 (void *(*)(void *))R_LIB_CTX_get_default_method, NULL }
00222
00223 /**
00224 * Textual descriptions of common error codes. This is only required if using
00225 * R_LIB_CTX_get_string() string functions.
00226 *
00227 * @see R_LIB_CTX_com_err_str_table().
00228 */
00229 #define R_LIB_RES_ERROR_STRINGS \
00230 { R_RES_MOD_ID_LIBRARY, R_RES_IMPL_ID_DEF, R_RES_SUB_ID_ERROR_STRINGS, \
00231 R_RES_FLAG_DEF, NULL, NULL, NULL, \
00232 (void *(*)(void *))R_LIB_CTX_com_err_str_table }
00233
00234 /**
00235 * @}
00236 */
00237
00238 #ifdef __cplusplus
00239 }
00240 #endif
00241
00242 #endif /* HEADER_COMMON_R_LIB_H */
00243