X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=sim%2Fe2-interface.git;a=blobdiff_plain;f=e2sim%2Fprevious%2FASN1c%2Fconstraints.c;fp=e2sim%2Fprevious%2FASN1c%2Fconstraints.c;h=0000000000000000000000000000000000000000;hp=5051c3480e45940ea17d8bf9e25d1383f698e085;hb=f86662b5b6481f27e18313a36355871f3a947193;hpb=a9f02a2b5886990fd81e64f7c218c5d4844f18a3 diff --git a/e2sim/previous/ASN1c/constraints.c b/e2sim/previous/ASN1c/constraints.c deleted file mode 100644 index 5051c34..0000000 --- a/e2sim/previous/ASN1c/constraints.c +++ /dev/null @@ -1,111 +0,0 @@ -/***************************************************************************** -# * -# Copyright 2019 AT&T Intellectual Property * -# * -# Licensed under the Apache License, Version 2.0 (the "License"); * -# you may not use this file except in compliance with the License. * -# You may obtain a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# * -******************************************************************************/ - -#include -#include - -int -asn_generic_no_constraint(const asn_TYPE_descriptor_t *type_descriptor, - const void *struct_ptr, - asn_app_constraint_failed_f *cb, void *key) { - (void)type_descriptor; /* Unused argument */ - (void)struct_ptr; /* Unused argument */ - (void)cb; /* Unused argument */ - (void)key; /* Unused argument */ - - /* Nothing to check */ - return 0; -} - -int -asn_generic_unknown_constraint(const asn_TYPE_descriptor_t *type_descriptor, - const void *struct_ptr, - asn_app_constraint_failed_f *cb, void *key) { - (void)type_descriptor; /* Unused argument */ - (void)struct_ptr; /* Unused argument */ - (void)cb; /* Unused argument */ - (void)key; /* Unused argument */ - - /* Unknown how to check */ - return 0; -} - -struct errbufDesc { - const asn_TYPE_descriptor_t *failed_type; - const void *failed_struct_ptr; - char *errbuf; - size_t errlen; -}; - -static void -_asn_i_ctfailcb(void *key, const asn_TYPE_descriptor_t *td, const void *sptr, - const char *fmt, ...) { - struct errbufDesc *arg = key; - va_list ap; - ssize_t vlen; - ssize_t maxlen; - - arg->failed_type = td; - arg->failed_struct_ptr = sptr; - - maxlen = arg->errlen; - if(maxlen <= 0) - return; - - va_start(ap, fmt); - vlen = vsnprintf(arg->errbuf, maxlen, fmt, ap); - va_end(ap); - if(vlen >= maxlen) { - arg->errbuf[maxlen-1] = '\0'; /* Ensuring libc correctness */ - arg->errlen = maxlen - 1; /* Not counting termination */ - return; - } else if(vlen >= 0) { - arg->errbuf[vlen] = '\0'; /* Ensuring libc correctness */ - arg->errlen = vlen; /* Not counting termination */ - } else { - /* - * The libc on this system is broken. - */ - vlen = sizeof("") - 1; - maxlen--; - arg->errlen = vlen < maxlen ? vlen : maxlen; - memcpy(arg->errbuf, "", arg->errlen); - arg->errbuf[arg->errlen] = 0; - } - - return; -} - -int -asn_check_constraints(const asn_TYPE_descriptor_t *type_descriptor, - const void *struct_ptr, char *errbuf, size_t *errlen) { - struct errbufDesc arg; - int ret; - - arg.failed_type = 0; - arg.failed_struct_ptr = 0; - arg.errbuf = errbuf; - arg.errlen = errlen ? *errlen : 0; - - ret = type_descriptor->encoding_constraints.general_constraints( - type_descriptor, struct_ptr, _asn_i_ctfailcb, &arg); - if(ret == -1 && errlen) *errlen = arg.errlen; - - return ret; -} -