![]() |
|
|||
File indexing completed on 2025-02-21 10:15:32
0001 /* prop.h -- property request/response management routines 0002 * 0003 * Author: Chris Newman 0004 * Removal of implementation-specific details by: Rob Siemborski 0005 * 0006 * This is intended to be used to create a list of properties to request, 0007 * and _then_ request values for all properties. Any change to the request 0008 * list will discard any existing values. This assumption allows a very 0009 * efficient and simple memory model. This was designed for SASL API auxiliary 0010 * property support, but would be fine for other contexts where this property 0011 * model is appropriate. 0012 * 0013 * The "struct propctx" is allocated by prop_new and is a fixed size structure. 0014 * If a prop_init() call were added, it would be reasonable to embed a "struct 0015 * propctx" in another structure. prop_new also allocates a pool of memory 0016 * (in the vbase field) which will be used for an array of "struct propval" 0017 * to list all the requested properties. 0018 * 0019 * Properties may be multi-valued. 0020 */ 0021 0022 #ifndef PROP_H 0023 #define PROP_H 1 0024 0025 /* The following ifdef block is the standard way of creating macros 0026 * which make exporting from a DLL simpler. All files within this DLL 0027 * are compiled with the LIBSASL_EXPORTS symbol defined on the command 0028 * line. this symbol should not be defined on any project that uses 0029 * this DLL. This way any other project whose source files include 0030 * this file see LIBSASL_API functions as being imported from a DLL, 0031 * wheras this DLL sees symbols defined with this macro as being 0032 * exported. */ 0033 /* Under Unix, life is simpler: we just need to mark library functions 0034 * as extern. (Technically, we don't even have to do that.) */ 0035 #ifdef WIN32 0036 # ifdef LIBSASL_EXPORTS 0037 # define LIBSASL_API extern __declspec(dllexport) 0038 # else /* LIBSASL_EXPORTS */ 0039 # define LIBSASL_API extern __declspec(dllimport) 0040 # endif /* LIBSASL_EXPORTS */ 0041 #else /* WIN32 */ 0042 # define LIBSASL_API extern 0043 #endif /* WIN32 */ 0044 0045 /* Same as above, but used during a variable declaration. */ 0046 #ifdef WIN32 0047 # ifdef LIBSASL_EXPORTS 0048 # define LIBSASL_VAR extern __declspec(dllexport) 0049 # else /* LIBSASL_EXPORTS */ 0050 # define LIBSASL_VAR extern __declspec(dllimport) 0051 # endif /* LIBSASL_EXPORTS */ 0052 #else /* WIN32 */ 0053 # define LIBSASL_VAR extern 0054 #endif /* WIN32 */ 0055 0056 /* the resulting structure for property values 0057 */ 0058 struct propval { 0059 const char *name; /* name of property; NULL = end of list */ 0060 /* same pointer used in request will be used here */ 0061 const char **values; /* list of strings, values == NULL if property not 0062 * found, *values == NULL if property found with 0063 * no values */ 0064 unsigned nvalues; /* total number of value strings */ 0065 unsigned valsize; /* total size in characters of all value strings */ 0066 }; 0067 0068 /* 0069 * private internal structure 0070 */ 0071 #define PROP_DEFAULT 4 /* default number of propvals to assume */ 0072 struct propctx; 0073 0074 #ifdef __cplusplus 0075 extern "C" { 0076 #endif 0077 0078 /* create a property context 0079 * estimate -- an estimate of the storage needed for requests & responses 0080 * 0 will use module default 0081 * returns a new property context on success and NULL on any error 0082 */ 0083 LIBSASL_API struct propctx *prop_new(unsigned estimate); 0084 0085 /* create new propctx which duplicates the contents of an existing propctx 0086 * returns SASL_OK on success 0087 * possible other return values include: SASL_NOMEM, SASL_BADPARAM 0088 */ 0089 LIBSASL_API int prop_dup(struct propctx *src_ctx, struct propctx **dst_ctx); 0090 0091 /* Add property names to request 0092 * ctx -- context from prop_new() 0093 * names -- list of property names; must persist until context freed 0094 * or requests cleared (This extends to other contexts that 0095 * are dup'ed from this one, and their children, etc) 0096 * 0097 * NOTE: may clear values from context as side-effect 0098 * returns SASL_OK on success 0099 * possible other return values include: SASL_NOMEM, SASL_BADPARAM 0100 */ 0101 LIBSASL_API int prop_request(struct propctx *ctx, const char **names); 0102 0103 /* return array of struct propval from the context 0104 * return value persists until next call to 0105 * prop_request, prop_clear or prop_dispose on context 0106 * 0107 * returns NULL on error 0108 */ 0109 LIBSASL_API const struct propval *prop_get(struct propctx *ctx); 0110 0111 /* Fill in an array of struct propval based on a list of property names 0112 * return value persists until next call to 0113 * prop_request, prop_clear or prop_dispose on context 0114 * returns number of matching properties which were found (values != NULL) 0115 * if a name requested here was never requested by a prop_request, then 0116 * the name field of the associated vals entry will be set to NULL 0117 * 0118 * The vals array MUST be atleast as long as the names array. 0119 * 0120 * returns # of matching properties on success 0121 * possible other return values include: SASL_BADPARAM 0122 */ 0123 LIBSASL_API int prop_getnames(struct propctx *ctx, const char **names, 0124 struct propval *vals); 0125 0126 /* clear values and optionally requests from property context 0127 * ctx -- property context 0128 * requests -- 0 = don't clear requests, 1 = clear requests 0129 */ 0130 LIBSASL_API void prop_clear(struct propctx *ctx, int requests); 0131 0132 /* erase the value of a property 0133 */ 0134 LIBSASL_API void prop_erase(struct propctx *ctx, const char *name); 0135 0136 /* dispose of property context 0137 * ctx -- is disposed and set to NULL; noop if ctx or *ctx is NULL 0138 */ 0139 LIBSASL_API void prop_dispose(struct propctx **ctx); 0140 0141 0142 /****fetcher interfaces****/ 0143 0144 /* format the requested property names into a string 0145 * ctx -- context from prop_new()/prop_request() 0146 * sep -- separator between property names (unused if none requested) 0147 * seplen -- length of separator, if < 0 then strlen(sep) will be used 0148 * outbuf -- output buffer 0149 * outmax -- maximum length of output buffer including NUL terminator 0150 * outlen -- set to length of output string excluding NUL terminator 0151 * returns SASL_OK on success 0152 * returns SASL_BADPARAM or amount of additional space needed on failure 0153 */ 0154 LIBSASL_API int prop_format(struct propctx *ctx, const char *sep, int seplen, 0155 char *outbuf, unsigned outmax, unsigned *outlen); 0156 0157 /* add a property value to the context 0158 * ctx -- context from prop_new()/prop_request() 0159 * name -- name of property to which value will be added 0160 * if NULL, add to the same name as previous prop_set/setvals call 0161 * value -- a value for the property; will be copied into context 0162 * if NULL, remove existing values 0163 * vallen -- length of value, if <= 0 then strlen(value) will be used 0164 * returns SASL_OK on success 0165 * possible error return values include: SASL_BADPARAM, SASL_NOMEM 0166 */ 0167 LIBSASL_API int prop_set(struct propctx *ctx, const char *name, 0168 const char *value, int vallen); 0169 0170 /* set the values for a property 0171 * ctx -- context from prop_new()/prop_request() 0172 * name -- name of property to which value will be added 0173 * if NULL, add to the same name as previous prop_set/setvals call 0174 * values -- array of values, ending in NULL. Each value is a NUL terminated 0175 * string 0176 * returns SASL_OK on success 0177 * possible error return values include: SASL_BADPARAM, SASL_NOMEM 0178 */ 0179 LIBSASL_API int prop_setvals(struct propctx *ctx, const char *name, 0180 const char **values); 0181 0182 #ifdef __cplusplus 0183 } 0184 #endif 0185 0186 #endif /* PROP_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |