3 * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
4 * Redistribution and modifications are permitted subject to BSD license.
6 #include <asn_internal.h>
7 #include <constr_TYPE.h>
11 * Version of the ASN.1 infrastructure shipped with compiler.
13 int get_asn1c_environment_version() { return ASN1C_ENVIRONMENT_VERSION; }
15 static asn_app_consume_bytes_f _print2fp;
18 * Return the outmost tag of the type.
21 asn_TYPE_outmost_tag(const asn_TYPE_descriptor_t *type_descriptor,
22 const void *struct_ptr, int tag_mode, ber_tlv_tag_t tag) {
27 if(type_descriptor->tags_count)
28 return type_descriptor->tags[0];
30 return type_descriptor->op->outmost_tag(type_descriptor, struct_ptr, 0, 0);
34 * Print the target language's structure in human readable form.
37 asn_fprint(FILE *stream, const asn_TYPE_descriptor_t *td,
38 const void *struct_ptr) {
39 if(!stream) stream = stdout;
40 if(!td || !struct_ptr) {
45 /* Invoke type-specific printer */
46 if(td->op->print_struct(td, struct_ptr, 1, _print2fp, stream)) {
50 /* Terminate the output */
51 if(_print2fp("\n", 1, stream)) {
55 return fflush(stream);
58 /* Dump the data into the specified stdio stream */
60 _print2fp(const void *buffer, size_t size, void *app_key) {
61 FILE *stream = (FILE *)app_key;
63 if(fwrite(buffer, 1, size, stream) != size)
71 * Some compilers do not support variable args macros.
72 * This function is a replacement of ASN_DEBUG() macro.
74 void ASN_DEBUG_f(const char *fmt, ...);
75 void ASN_DEBUG_f(const char *fmt, ...) {
78 vfprintf(stderr, fmt, ap);
79 fprintf(stderr, "\n");