2 * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
3 * Redistribution and modifications are permitted subject to BSD license.
5 #include <asn_internal.h>
6 #include <constr_TYPE.h>
10 * Version of the ASN.1 infrastructure shipped with compiler.
12 int get_asn1c_environment_version() { return ASN1C_ENVIRONMENT_VERSION; }
14 static asn_app_consume_bytes_f _print2fp;
17 * Return the outmost tag of the type.
20 asn_TYPE_outmost_tag(const asn_TYPE_descriptor_t *type_descriptor,
21 const void *struct_ptr, int tag_mode, ber_tlv_tag_t tag) {
26 if(type_descriptor->tags_count)
27 return type_descriptor->tags[0];
29 return type_descriptor->op->outmost_tag(type_descriptor, struct_ptr, 0, 0);
33 * Print the target language's structure in human readable form.
36 asn_fprint(FILE *stream, const asn_TYPE_descriptor_t *td,
37 const void *struct_ptr) {
38 if(!stream) stream = stdout;
39 if(!td || !struct_ptr) {
44 /* Invoke type-specific printer */
45 if(td->op->print_struct(td, struct_ptr, 1, _print2fp, stream)) {
49 /* Terminate the output */
50 if(_print2fp("\n", 1, stream)) {
54 return fflush(stream);
57 /* Dump the data into the specified stdio stream */
59 _print2fp(const void *buffer, size_t size, void *app_key) {
60 FILE *stream = (FILE *)app_key;
62 if(fwrite(buffer, 1, size, stream) != size)
70 * Some compilers do not support variable args macros.
71 * This function is a replacement of ASN_DEBUG() macro.
73 void ASN_DEBUG_f(const char *fmt, ...);
74 void ASN_DEBUG_f(const char *fmt, ...) {
77 vfprintf(stderr, fmt, ap);
78 fprintf(stderr, "\n");