jer_decoder.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
3  * Redistribution and modifications are permitted subject to BSD license.
4  */
5 #ifndef _JER_DECODER_H_
6 #define _JER_DECODER_H_
7 
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 struct asn_TYPE_descriptor_s; /* Forward declaration */
16 
17 /*
18  * The JER decoder of any ASN.1 type. May be invoked by the application.
19  * Decodes CANONICAL-JER and BASIC-JER.
20  */
22  const struct asn_codec_ctx_s *opt_codec_ctx,
23  const struct asn_TYPE_descriptor_s *type_descriptor,
24  void **struct_ptr, /* Pointer to a target structure's pointer */
25  const void *buffer, /* Data to be decoded */
26  size_t size /* Size of data buffer */
27 );
28 
29 /*
30  * Type of the type-specific JER decoder function.
31  */
33  const asn_codec_ctx_t *opt_codec_ctx,
34  const struct asn_TYPE_descriptor_s *type_descriptor,
35  const asn_jer_constraints_t *constraints,
36  void **struct_ptr,
37  const void *buf_ptr, size_t size);
38 
39 /*******************************
40  * INTERNALLY USEFUL FUNCTIONS *
41  *******************************/
42 
43 /*
44  * Generalized function for decoding the primitive values.
45  * Used by more specialized functions, such as OCTET_STRING_decode_jer_utf8
46  * and others. This function should not be used by applications, as its API
47  * is subject to changes.
48  */
50  const asn_codec_ctx_t *opt_codec_ctx,
51  asn_struct_ctx_t *ctx, /* Type decoder context */
52  void *struct_key, /* Treated as opaque pointer */
53  const void *buf_ptr, size_t size,
54  int (*opt_unexpected_tag_decoder)(void *struct_key, const void *chunk_buf,
55  size_t chunk_size),
56  ssize_t (*body_receiver)(void *struct_key, const void *chunk_buf,
57  size_t chunk_size, int have_more));
58 
59 
60 /*
61  * Fetch the next JER (JSON) token from the stream.
62  * The function returns the number of bytes occupied by the chunk type,
63  * returned in the _ch_type. The _ch_type is only set (and valid) when
64  * the return value is >= 0.
65  */
66 typedef enum pjer_chunk_type {
67  PJER_WMORE, /* Chunk type is not clear, more data expected. */
68  PJER_TEXT, /* General data */
69  PJER_KEY, /* Complete JSON key */
70  PJER_VALUE, /* Complete JSON value */
71  PJER_DLM /* JSON delimiter */
73 ssize_t jer_next_token(int *stateContext,
74  const void *buffer, size_t size, pjer_chunk_type_e *_ch_type);
75 
76 /*
77  * This function checks the buffer for the current token or
78  * against the key name expected to occur.
79  */
80 typedef enum jer_check_sym {
81  JCK_BROKEN, /* Something is broken */
82  JCK_UNKNOWN, /* Key or delimiter is unknown */
83  JCK_KEY, /* Key is OK */
84  JCK_COMMA, /* Delimiter is ',' */
85  JCK_OSTART, /* Delimiter is '{' */
86  JCK_OEND, /* Delimiter is '}' */
87  JCK_ASTART, /* Delimiter is '[' */
88  JCK_AEND /* Delimiter is ']' */
90 jer_check_sym_e jer_check_sym(const void *buf_ptr, int size,
91  const char *need_key);
92 
93 /*
94  * Get the number of bytes consisting entirely of JER whitespace characters.
95  * RETURN VALUES:
96  * >=0: Number of whitespace characters in the string.
97  */
98 size_t jer_whitespace_span(const void *chunk_buf, size_t chunk_size);
99 
100 /*
101  * Skip the series of anticipated extensions.
102  */
104 
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #endif /* _JER_DECODER_H_ */
asn_struct_ctx_s
Definition: constr_TYPE.h:29
jer_support.h
PJER_TEXT
@ PJER_TEXT
Definition: jer_decoder.h:68
JCK_COMMA
@ JCK_COMMA
Definition: jer_decoder.h:84
asn_jer_constraints_s
Definition: jer_support.h:18
JCK_BROKEN
@ JCK_BROKEN
Definition: jer_decoder.h:81
pjer_chunk_type
pjer_chunk_type
Definition: jer_decoder.h:66
jer_decode_general
asn_dec_rval_t jer_decode_general(const asn_codec_ctx_t *opt_codec_ctx, asn_struct_ctx_t *ctx, void *struct_key, const void *buf_ptr, size_t size, int(*opt_unexpected_tag_decoder)(void *struct_key, const void *chunk_buf, size_t chunk_size), ssize_t(*body_receiver)(void *struct_key, const void *chunk_buf, size_t chunk_size, int have_more))
Definition: jer_decoder.c:210
JCK_OEND
@ JCK_OEND
Definition: jer_decoder.h:86
pjer_chunk_type_e
enum pjer_chunk_type pjer_chunk_type_e
asn_dec_rval_t
struct asn_dec_rval_s asn_dec_rval_t
ber_tlv_len_t
ssize_t ber_tlv_len_t
Definition: ber_tlv_length.h:12
JCK_UNKNOWN
@ JCK_UNKNOWN
Definition: jer_decoder.h:82
asn_TYPE_descriptor_s
Definition: constr_TYPE.h:224
JCK_KEY
@ JCK_KEY
Definition: jer_decoder.h:83
jer_type_decoder_f
asn_dec_rval_t() jer_type_decoder_f(const asn_codec_ctx_t *opt_codec_ctx, const struct asn_TYPE_descriptor_s *type_descriptor, const asn_jer_constraints_t *constraints, void **struct_ptr, const void *buf_ptr, size_t size)
Definition: jer_decoder.h:32
jer_whitespace_span
size_t jer_whitespace_span(const void *chunk_buf, size_t chunk_size)
Definition: jer_decoder.c:273
PJER_DLM
@ PJER_DLM
Definition: jer_decoder.h:71
jer_check_sym
jer_check_sym
Definition: jer_decoder.h:80
PJER_VALUE
@ PJER_VALUE
Definition: jer_decoder.h:70
jer_skip_unknown
int jer_skip_unknown(jer_check_sym_e scv, ber_tlv_len_t *depth)
Definition: jer_decoder.c:299
JCK_ASTART
@ JCK_ASTART
Definition: jer_decoder.h:87
asn_codec_ctx_s
Definition: asn_codecs.h:23
asn_dec_rval_s
Definition: asn_codecs.h:86
jer_decode
asn_dec_rval_t jer_decode(const struct asn_codec_ctx_s *opt_codec_ctx, const struct asn_TYPE_descriptor_s *type_descriptor, void **struct_ptr, const void *buffer, size_t size)
PJER_KEY
@ PJER_KEY
Definition: jer_decoder.h:69
jer_next_token
ssize_t jer_next_token(int *stateContext, const void *buffer, size_t size, pjer_chunk_type_e *_ch_type)
Definition: jer_decoder.c:64
asn_application.h
JCK_AEND
@ JCK_AEND
Definition: jer_decoder.h:88
jer_check_sym_e
enum jer_check_sym jer_check_sym_e
PJER_WMORE
@ PJER_WMORE
Definition: jer_decoder.h:67
JCK_OSTART
@ JCK_OSTART
Definition: jer_decoder.h:85


etsi_its_cpm_ts_coding
Author(s): Jean-Pierre Busch , Guido Küppers , Lennart Reiher
autogenerated on Sun May 18 2025 02:22:38