From 3d8ed01d2653c45e52821ba00ac72099a12600e1 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Fri, 27 Apr 2007 03:19:46 +0000 Subject: --- ckcapi-util.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 ckcapi-util.h (limited to 'ckcapi-util.h') diff --git a/ckcapi-util.h b/ckcapi-util.h new file mode 100644 index 0000000..b37ea39 --- /dev/null +++ b/ckcapi-util.h @@ -0,0 +1,46 @@ + +#ifndef __CKCAPI_UTIL_H__ +#define __CKCAPI_UTIL_H__ + +#include + +/* -------------------------------------------------------------------------------- + * WINDOWS + */ + +CK_RV ckcapi_util_win_to_cryptoki_err (DWORD werr); + + +/* -------------------------------------------------------------------------------- + * ARRAYS + */ + +typedef struct _Array +{ + void* data; + size_t len; +} +Array; + +#define ckcapi_util_array_append(a,v) \ + ckcapi_util_array_append_vals(a, &(v), 1) +#define ckcapi_util_array_index(a,t,i) \ + (((t*) (a)->data) [(i)]) + +Array* ckcapi_util_array_new (int zero_terminated, int zero, + size_t element_size); + +Array* ckcapi_util_array_sized_new (int zero_terminated, int zero, + size_t element_size, size_t reserved_size); + +void* ckcapi_util_array_free (Array* array, int free_segment); + +int ckcapi_util_array_append_vals (Array* array, const void* data, + size_t num); + +void ckcapi_util_array_remove_index (Array* array, unsigned int index); + +void ckcapi_util_array_remove_range (Array* array, unsigned int index, + size_t count); + +#endif /* __CKCAPI_UTIL_H__ */ \ No newline at end of file -- cgit v1.2.3