vlm | c4436cf | 2004-10-21 11:20:50 +0000 | [diff] [blame] | 1 | /*- |
| 2 | * Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved. |
| 3 | * Redistribution and modifications are permitted subject to BSD license. |
| 4 | */ |
| 5 | #ifndef ASN_CODECS_PRIM_H |
| 6 | #define ASN_CODECS_PRIM_H |
| 7 | |
| 8 | #include <asn_application.h> |
| 9 | |
| 10 | typedef struct ASN__PRIMITIVE_TYPE_s { |
| 11 | uint8_t *buf; /* Buffer with consecutive primitive encoding bytes */ |
| 12 | int size; /* Size of the buffer */ |
| 13 | } ASN__PRIMITIVE_TYPE_t; /* Do not use this type directly! */ |
| 14 | |
| 15 | asn_struct_free_f ASN__PRIMITIVE_TYPE_free; |
| 16 | ber_type_decoder_f ber_decode_primitive; |
| 17 | der_type_encoder_f der_encode_primitive; |
| 18 | |
| 19 | /* |
vlm | 4df9cc1 | 2005-03-09 22:19:25 +0000 | [diff] [blame] | 20 | * A callback specification for the xer_decode_primitive() function below. |
| 21 | */ |
| 22 | enum xer_pbd_rval { |
| 23 | XPBD_SYSTEM_FAILURE, /* System failure (memory shortage, etc) */ |
| 24 | XPBD_DECODER_LIMIT, /* Hit some decoder limitation or deficiency */ |
| 25 | XPBD_BROKEN_ENCODING, /* Encoding of a primitive body is broken */ |
| 26 | XPBD_NOT_BODY_IGNORE, /* Not a body format, but safe to ignore */ |
vlm | 8a0261a | 2005-07-21 09:16:27 +0000 | [diff] [blame] | 27 | XPBD_BODY_CONSUMED /* Body is recognized and consumed */ |
vlm | 4df9cc1 | 2005-03-09 22:19:25 +0000 | [diff] [blame] | 28 | }; |
| 29 | typedef enum xer_pbd_rval (xer_primitive_body_decoder_f) |
| 30 | (asn_TYPE_descriptor_t *td, void *struct_ptr, |
| 31 | const void *chunk_buf, size_t chunk_size); |
| 32 | |
| 33 | /* |
vlm | b848b2a | 2004-10-21 14:02:19 +0000 | [diff] [blame] | 34 | * Specific function to decode simple primitive types. |
vlm | c4436cf | 2004-10-21 11:20:50 +0000 | [diff] [blame] | 35 | * Also see xer_decode_general() in xer_decoder.h |
| 36 | */ |
| 37 | asn_dec_rval_t xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx, |
| 38 | asn_TYPE_descriptor_t *type_descriptor, |
vlm | b848b2a | 2004-10-21 14:02:19 +0000 | [diff] [blame] | 39 | void **struct_ptr, size_t struct_size, |
vlm | c4436cf | 2004-10-21 11:20:50 +0000 | [diff] [blame] | 40 | const char *opt_mname, |
vlm | b02dcc6 | 2005-03-10 18:52:02 +0000 | [diff] [blame] | 41 | const void *buf_ptr, size_t size, |
vlm | 4df9cc1 | 2005-03-09 22:19:25 +0000 | [diff] [blame] | 42 | xer_primitive_body_decoder_f *prim_body_decoder |
| 43 | ); |
vlm | c4436cf | 2004-10-21 11:20:50 +0000 | [diff] [blame] | 44 | |
| 45 | #endif /* ASN_CODECS_PRIM_H */ |