1 #include "asn_internal.h"
2 #include "constraints.h"
5 asn_generic_no_constraint(asn_TYPE_descriptor_t
*type_descriptor
,
6 const void *struct_ptr
, asn_app_constraint_failed_f
*cb
, void *key
) {
8 (void)type_descriptor
; /* Unused argument */
9 (void)struct_ptr
; /* Unused argument */
10 (void)cb
; /* Unused argument */
11 (void)key
; /* Unused argument */
13 /* Nothing to check */
18 asn_generic_unknown_constraint(asn_TYPE_descriptor_t
*type_descriptor
,
19 const void *struct_ptr
, asn_app_constraint_failed_f
*cb
, void *key
) {
21 (void)type_descriptor
; /* Unused argument */
22 (void)struct_ptr
; /* Unused argument */
23 (void)cb
; /* Unused argument */
24 (void)key
; /* Unused argument */
26 /* Unknown how to check */
31 asn_TYPE_descriptor_t
*failed_type
;
32 const void *failed_struct_ptr
;
38 _asn_i_ctfailcb(void *key
, asn_TYPE_descriptor_t
*td
, const void *sptr
, const char *fmt
, ...) {
39 struct errbufDesc
*arg
= key
;
44 arg
->failed_type
= td
;
45 arg
->failed_struct_ptr
= sptr
;
52 vlen
= vsnprintf(arg
->errbuf
, maxlen
, fmt
, ap
);
55 arg
->errbuf
[maxlen
-1] = '\0'; /* Ensuring libc correctness */
56 arg
->errlen
= maxlen
- 1; /* Not counting termination */
58 } else if(vlen
>= 0) {
59 arg
->errbuf
[vlen
] = '\0'; /* Ensuring libc correctness */
60 arg
->errlen
= vlen
; /* Not counting termination */
63 * The libc on this system is broken.
65 vlen
= sizeof("<broken vsnprintf>") - 1;
67 arg
->errlen
= vlen
< maxlen
? vlen
: maxlen
;
68 memcpy(arg
->errbuf
, "<broken vsnprintf>", arg
->errlen
);
69 arg
->errbuf
[arg
->errlen
] = 0;
76 asn_check_constraints(asn_TYPE_descriptor_t
*type_descriptor
,
77 const void *struct_ptr
, char *errbuf
, size_t *errlen
) {
78 struct errbufDesc arg
;
82 arg
.failed_struct_ptr
= 0;
84 arg
.errlen
= errlen
? *errlen
: 0;
86 ret
= type_descriptor
->check_constraints(type_descriptor
,
87 struct_ptr
, _asn_i_ctfailcb
, &arg
);
88 if(ret
== -1 && errlen
)