Moving in e2sim originally from it/test/simulators
[sim/e2-interface.git] / e2sim / ASN1c / xer_support.h
1 /*****************************************************************************
2 #                                                                            *
3 # Copyright 2019 AT&T Intellectual Property                                  *
4 #                                                                            *
5 # Licensed under the Apache License, Version 2.0 (the "License");            *
6 # you may not use this file except in compliance with the License.           *
7 # You may obtain a copy of the License at                                    *
8 #                                                                            *
9 #      http://www.apache.org/licenses/LICENSE-2.0                            *
10 #                                                                            *
11 # Unless required by applicable law or agreed to in writing, software        *
12 # distributed under the License is distributed on an "AS IS" BASIS,          *
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
14 # See the License for the specific language governing permissions and        *
15 # limitations under the License.                                             *
16 #                                                                            *
17 ******************************************************************************/
18
19 /*
20  * Copyright (c) 2003, 2004 X/IO Labs, xiolabs.com.
21  * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
22  * Redistribution and modifications are permitted subject to BSD license.
23  */
24 #ifndef _XER_SUPPORT_H_
25 #define _XER_SUPPORT_H_
26
27 #include <asn_system.h>         /* Platform-specific types */
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 /*
34  * Types of data transferred to the application.
35  */
36 typedef enum {
37         PXML_TEXT,      /* Plain text between XML tags. */
38         PXML_TAG,       /* A tag, starting with '<'. */
39         PXML_COMMENT,   /* An XML comment, including "<!--" and "-->". */
40         /* 
41          * The following chunk types are reported if the chunk
42          * terminates the specified XML element.
43          */
44         PXML_TAG_END,           /* Tag ended */
45         PXML_COMMENT_END        /* Comment ended */
46 } pxml_chunk_type_e;
47
48 /*
49  * Callback function that is called by the parser when parsed data is
50  * available. The _opaque is the pointer to a field containing opaque user 
51  * data specified in pxml_create() call. The chunk type is _type and the text 
52  * data is the piece of buffer identified by _bufid (as supplied to
53  * pxml_feed() call) starting at offset _offset and of _size bytes size. 
54  * The chunk is NOT '\0'-terminated.
55  */
56 typedef int (pxml_callback_f)(pxml_chunk_type_e _type,
57         const void *_chunk_data, size_t _chunk_size, void *_key);
58
59 /*
60  * Parse the given buffer as it were a chunk of XML data.
61  * Invoke the specified callback each time the meaninful data is found.
62  * This function returns number of bytes consumed from the bufer.
63  * It will always be lesser than or equal to the specified _size.
64  * The next invocation of this function must account the difference.
65  */
66 ssize_t pxml_parse(int *_stateContext, const void *_buf, size_t _size,
67         pxml_callback_f *cb, void *_key);
68
69 #ifdef __cplusplus
70 }
71 #endif
72
73 #endif  /* _XER_SUPPORT_H_ */