blob: 3b41be2f3932080899a3d643d57ef5e6d70b6359 [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001/*-
2 * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
3 * Redistribution and modifications are permitted subject to BSD license.
4 */
Lev Walkina9cc46e2004-09-22 16:06:28 +00005#include <asn_internal.h>
Lev Walkinf15320b2004-06-03 03:38:44 +00006#include <NULL.h>
7#include <BOOLEAN.h> /* Implemented in terms of BOOLEAN type */
8
9/*
10 * NULL basic type description.
11 */
Lev Walkin5e033762004-09-29 13:26:15 +000012static ber_tlv_tag_t asn_DEF_NULL_tags[] = {
Lev Walkinf15320b2004-06-03 03:38:44 +000013 (ASN_TAG_CLASS_UNIVERSAL | (5 << 2))
14};
Lev Walkin5e033762004-09-29 13:26:15 +000015asn_TYPE_descriptor_t asn_DEF_NULL = {
Lev Walkinf15320b2004-06-03 03:38:44 +000016 "NULL",
Lev Walkindc06f6b2004-10-20 15:50:55 +000017 "NULL",
Lev Walkina9cc46e2004-09-22 16:06:28 +000018 BOOLEAN_free,
19 NULL_print,
Lev Walkinf15320b2004-06-03 03:38:44 +000020 asn_generic_no_constraint,
21 BOOLEAN_decode_ber, /* Implemented in terms of BOOLEAN */
22 NULL_encode_der, /* Special handling of DER encoding */
Lev Walkina9cc46e2004-09-22 16:06:28 +000023 0, /* Not implemented yet */
24 NULL_encode_xer, /* Special handling of DER encoding */
Lev Walkinf15320b2004-06-03 03:38:44 +000025 0, /* Use generic outmost tag fetcher */
Lev Walkin5e033762004-09-29 13:26:15 +000026 asn_DEF_NULL_tags,
27 sizeof(asn_DEF_NULL_tags) / sizeof(asn_DEF_NULL_tags[0]),
28 asn_DEF_NULL_tags, /* Same as above */
29 sizeof(asn_DEF_NULL_tags) / sizeof(asn_DEF_NULL_tags[0]),
Lev Walkin449f8322004-08-20 13:23:42 +000030 0, 0, /* No members */
Lev Walkind9bd7752004-06-05 08:17:50 +000031 0 /* No specifics */
Lev Walkinf15320b2004-06-03 03:38:44 +000032};
33
Lev Walkina9cc46e2004-09-22 16:06:28 +000034asn_enc_rval_t
Lev Walkin5e033762004-09-29 13:26:15 +000035NULL_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
Lev Walkinf15320b2004-06-03 03:38:44 +000036 int tag_mode, ber_tlv_tag_t tag,
37 asn_app_consume_bytes_f *cb, void *app_key) {
Lev Walkina9cc46e2004-09-22 16:06:28 +000038 asn_enc_rval_t erval;
Lev Walkinf15320b2004-06-03 03:38:44 +000039
Lev Walkin8e8078a2004-09-26 13:10:40 +000040 erval.encoded = der_write_tags(td, 0, tag_mode, 0, tag, cb, app_key);
Lev Walkinf15320b2004-06-03 03:38:44 +000041 if(erval.encoded == -1) {
Lev Walkina9cc46e2004-09-22 16:06:28 +000042 erval.failed_type = td;
Lev Walkinf15320b2004-06-03 03:38:44 +000043 erval.structure_ptr = ptr;
44 }
45
46 return erval;
47}
48
Lev Walkina9cc46e2004-09-22 16:06:28 +000049asn_enc_rval_t
Lev Walkin5e033762004-09-29 13:26:15 +000050NULL_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
Lev Walkina9cc46e2004-09-22 16:06:28 +000051 int ilevel, enum xer_encoder_flags_e flags,
52 asn_app_consume_bytes_f *cb, void *app_key) {
53 asn_enc_rval_t er;
54
55 (void)td;
56 (void)sptr;
57 (void)ilevel;
58 (void)flags;
59 (void)cb;
60 (void)app_key;
61
62 /* XMLNullValue is empty */
63 er.encoded = 0;
64
65 return er;
66}
67
Lev Walkinf15320b2004-06-03 03:38:44 +000068int
Lev Walkin5e033762004-09-29 13:26:15 +000069NULL_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
Lev Walkinf15320b2004-06-03 03:38:44 +000070 asn_app_consume_bytes_f *cb, void *app_key) {
Lev Walkind9bd7752004-06-05 08:17:50 +000071
72 (void)td; /* Unused argument */
73 (void)ilevel; /* Unused argument */
74
Lev Walkinf15320b2004-06-03 03:38:44 +000075 if(sptr) {
Lev Walkin8e8078a2004-09-26 13:10:40 +000076 return (cb("<present>", 9, app_key) < 0) ? -1 : 0;
Lev Walkinf15320b2004-06-03 03:38:44 +000077 } else {
Lev Walkin8e8078a2004-09-26 13:10:40 +000078 return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
Lev Walkinf15320b2004-06-03 03:38:44 +000079 }
80}