aboutsummaryrefslogtreecommitdiffstats
path: root/skeletons/OCTET_STRING.h
diff options
context:
space:
mode:
authorLev Walkin <vlm@lionet.info>2004-06-03 03:38:44 +0000
committerLev Walkin <vlm@lionet.info>2004-06-03 03:38:44 +0000
commitf15320bf6b50a0c02636405561ac8323ae901abd (patch)
tree33461d45122896c6dde35f82f5c7d19b62004a6b /skeletons/OCTET_STRING.h
parent746cb60bbccf47019563665f4aec4b6c462c4163 (diff)
Initial revision
Diffstat (limited to 'skeletons/OCTET_STRING.h')
-rw-r--r--skeletons/OCTET_STRING.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/skeletons/OCTET_STRING.h b/skeletons/OCTET_STRING.h
new file mode 100644
index 00000000..1aed9a35
--- /dev/null
+++ b/skeletons/OCTET_STRING.h
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Redistribution and modifications are permitted subject to BSD license.
+ */
+#ifndef _OCTET_STRING_H_
+#define _OCTET_STRING_H_
+
+#include <constr_TYPE.h>
+
+typedef struct OCTET_STRING {
+ uint8_t *buf; /* Buffer with consecutive OCTET_STRING bits */
+ int size; /* Size of the buffer */
+
+ ber_dec_ctx_t _ber_dec_ctx; /* Parsing across buffer boundaries */
+} OCTET_STRING_t;
+
+extern asn1_TYPE_descriptor_t asn1_DEF_OCTET_STRING;
+
+ber_type_decoder_f OCTET_STRING_decode_ber;
+der_type_encoder_f OCTET_STRING_encode_der;
+asn_struct_print_f OCTET_STRING_print;
+asn_struct_print_f OCTET_STRING_print_ascii;
+asn_struct_free_f OCTET_STRING_free;
+
+/***********************************
+ * Some handy conversion routines. *
+ ***********************************/
+
+/*
+ * This function clears the previous value of the OCTET STRING (if any)
+ * and then allocates a new memory and makes s point to the newly allocated
+ * memory. If size = -1, the size of the original string will be determined
+ * using strlen(str).
+ * If str equals to NULL, the function will silently clear the
+ * current contents of the OCTET STRING.
+ * Returns 0 if it was possible to perform operation, -1 otherwise.
+ */
+int OCTET_STRING_fromBuf(OCTET_STRING_t *s, const char *str, int size);
+
+/*
+ * Allocate and fill the new OCTET STRING and return a pointer to the newly
+ * allocated object. NULL is permitted in str: the function will just allocate
+ * empty OCTET STRING.
+ */
+OCTET_STRING_t *OCTET_STRING_new_fromBuf(const char *str, int size);
+
+/* Handy conversion from the C string into the OCTET STRING. */
+#define OCTET_STRING_fromString(s, str) OCTET_STRING_fromBuf(s, str, -1);
+#define OCTET_STRING_fromString(s, str) OCTET_STRING_fromBuf(s, str, -1);
+
+#endif /* _OCTET_STRING_H_ */