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>
10 * The JER encoder of any type. May be invoked by the application.
13 jer_encode(const asn_TYPE_descriptor_t *td, const void *sptr,
14 asn_app_consume_bytes_f *cb,
16 asn_enc_rval_t er = {0, 0, 0};
21 if(!td || !sptr) goto cb_failed;
26 ASN__CALLBACK3("{\n\"", 3, mname, mlen, "\":", 2);
29 tmper = td->op->jer_encoder(td, sptr, 1, xFlag, cb, app_key);
30 if(tmper.encoded == -1) return tmper;
31 er.encoded += tmper.encoded;
33 ASN__CALLBACK("}", 1);
34 // ASN__CALLBACK3("</", 2, mname, mlen, ">\n", xcan);
42 * This is a helper function for jer_fprint, which directs all incoming data
43 * into the provided file descriptor.
46 jer__print2fp(const void *buffer, size_t size, void *app_key) {
47 FILE *stream = (FILE *)app_key;
49 if(fwrite(buffer, 1, size, stream) != size)
56 jer_fprint(FILE *stream, const asn_TYPE_descriptor_t *td, const void *sptr) {
57 asn_enc_rval_t er = {0,0,0};
59 if(!stream) stream = stdout;
63 er = jer_encode(td, sptr, jer__print2fp, stream);
67 return fflush(stream);