blob: 7291585b9a42ae3ea8faf74956d78b36d7256a89 [file] [log] [blame]
vlmfa67ddc2004-06-03 03:38:44 +00001/*-
2 * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
3 * Redistribution and modifications are permitted subject to BSD license.
4 */
5#ifndef _OCTET_STRING_H_
6#define _OCTET_STRING_H_
7
vlmd1579582004-09-24 21:00:50 +00008#include <asn_application.h>
vlmfa67ddc2004-06-03 03:38:44 +00009
10typedef struct OCTET_STRING {
11 uint8_t *buf; /* Buffer with consecutive OCTET_STRING bits */
12 int size; /* Size of the buffer */
13
vlmef6355b2004-09-29 13:26:15 +000014 asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */
vlmfa67ddc2004-06-03 03:38:44 +000015} OCTET_STRING_t;
16
vlmef6355b2004-09-29 13:26:15 +000017extern asn_TYPE_descriptor_t asn_DEF_OCTET_STRING;
vlmfa67ddc2004-06-03 03:38:44 +000018
vlm39ba4c42004-09-22 16:06:28 +000019asn_struct_free_f OCTET_STRING_free;
vlmfa67ddc2004-06-03 03:38:44 +000020asn_struct_print_f OCTET_STRING_print;
21asn_struct_print_f OCTET_STRING_print_ascii;
vlm39ba4c42004-09-22 16:06:28 +000022ber_type_decoder_f OCTET_STRING_decode_ber;
23der_type_encoder_f OCTET_STRING_encode_der;
24xer_type_encoder_f OCTET_STRING_encode_xer;
25xer_type_encoder_f OCTET_STRING_encode_xer_ascii;
vlmfa67ddc2004-06-03 03:38:44 +000026
27/***********************************
28 * Some handy conversion routines. *
29 ***********************************/
30
31/*
32 * This function clears the previous value of the OCTET STRING (if any)
vlm7e66aa82004-09-02 12:11:47 +000033 * and then allocates a new memory and returns a pointer to it.
34 * If size = -1, the size of the original string will be determined
vlmfa67ddc2004-06-03 03:38:44 +000035 * using strlen(str).
36 * If str equals to NULL, the function will silently clear the
37 * current contents of the OCTET STRING.
38 * Returns 0 if it was possible to perform operation, -1 otherwise.
39 */
40int OCTET_STRING_fromBuf(OCTET_STRING_t *s, const char *str, int size);
41
42/*
43 * Allocate and fill the new OCTET STRING and return a pointer to the newly
44 * allocated object. NULL is permitted in str: the function will just allocate
45 * empty OCTET STRING.
46 */
47OCTET_STRING_t *OCTET_STRING_new_fromBuf(const char *str, int size);
48
49/* Handy conversion from the C string into the OCTET STRING. */
50#define OCTET_STRING_fromString(s, str) OCTET_STRING_fromBuf(s, str, -1);
vlmfa67ddc2004-06-03 03:38:44 +000051
52#endif /* _OCTET_STRING_H_ */