1 /*****************************************************************************
3 # Copyright 2019 AT&T Intellectual Property *
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 *
9 # http://www.apache.org/licenses/LICENSE-2.0 *
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. *
17 ******************************************************************************/
20 * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
21 * Redistribution and modifications are permitted subject to BSD license.
23 #include <asn_internal.h>
24 #include <constr_TYPE.h>
28 * Version of the ASN.1 infrastructure shipped with compiler.
30 int get_asn1c_environment_version() { return ASN1C_ENVIRONMENT_VERSION; }
32 static asn_app_consume_bytes_f _print2fp;
35 * Return the outmost tag of the type.
38 asn_TYPE_outmost_tag(const asn_TYPE_descriptor_t *type_descriptor,
39 const void *struct_ptr, int tag_mode, ber_tlv_tag_t tag) {
44 if(type_descriptor->tags_count)
45 return type_descriptor->tags[0];
47 return type_descriptor->op->outmost_tag(type_descriptor, struct_ptr, 0, 0);
51 * Print the target language's structure in human readable form.
54 asn_fprint(FILE *stream, const asn_TYPE_descriptor_t *td,
55 const void *struct_ptr) {
56 if(!stream) stream = stdout;
57 if(!td || !struct_ptr) {
62 /* Invoke type-specific printer */
63 if(td->op->print_struct(td, struct_ptr, 1, _print2fp, stream)) {
67 /* Terminate the output */
68 if(_print2fp("\n", 1, stream)) {
72 return fflush(stream);
75 /* Dump the data into the specified stdio stream */
77 _print2fp(const void *buffer, size_t size, void *app_key) {
78 FILE *stream = (FILE *)app_key;
80 if(fwrite(buffer, 1, size, stream) != size)
88 * Some compilers do not support variable args macros.
89 * This function is a replacement of ASN_DEBUG() macro.
91 void ASN_DEBUG_f(const char *fmt, ...);
92 void ASN_DEBUG_f(const char *fmt, ...) {
95 vfprintf(stderr, fmt, ap);
96 fprintf(stderr, "\n");