1 /*
2  * %CopyrightBegin%
3  *
4  * Copyright Ericsson AB 1998-2016. All Rights Reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * %CopyrightEnd%
19  *
20 
21  */
22 #include "reg.h"
23 
ei_reg_getfval(ei_reg * reg,const char * key)24 double ei_reg_getfval(ei_reg *reg, const char *key)
25 {
26   ei_hash *tab;
27   ei_reg_obj *obj=NULL;
28 
29   if (!key || !reg) return -1; /* return (double)EI_BADARG; */
30   tab = reg->tab;
31   if (!(obj=ei_hash_lookup(tab,key))) return -1; /* return EI_NOTFOUND; */
32   if (obj->attr & EI_DELET) return -1; /* return EI_NOTFOUND; */
33   if (ei_reg_typeof(obj) != EI_FLT) return -1; /* return (double)EI_TYPE; */
34 
35   return obj->val.f;
36 }
37