• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __CUTILS_STR_PARMS_H
18 #define __CUTILS_STR_PARMS_H
19 
20 #include <stdint.h>
21 
22 struct str_parms;
23 
24 struct str_parms *str_parms_create(void);
25 struct str_parms *str_parms_create_str(const char *_string);
26 void str_parms_destroy(struct str_parms *str_parms);
27 
28 void str_parms_del(struct str_parms *str_parms, const char *key);
29 
30 int str_parms_add_str(struct str_parms *str_parms, const char *key,
31                       const char *value);
32 int str_parms_add_int(struct str_parms *str_parms, const char *key, int value);
33 
34 int str_parms_add_float(struct str_parms *str_parms, const char *key,
35                         float value);
36 
37 // Returns non-zero if the str_parms contains the specified key.
38 int str_parms_has_key(struct str_parms *str_parms, const char *key);
39 
40 // Gets value associated with the specified key (if present), placing it in the buffer
41 // pointed to by the out_val parameter.  Returns the length of the returned string value.
42 // If 'key' isn't in the parms, then return -ENOENT (-2) and leave 'out_val' untouched.
43 int str_parms_get_str(struct str_parms *str_parms, const char *key,
44                       char *out_val, int len);
45 int str_parms_get_int(struct str_parms *str_parms, const char *key,
46                       int *out_val);
47 int str_parms_get_float(struct str_parms *str_parms, const char *key,
48                         float *out_val);
49 
50 char *str_parms_to_str(struct str_parms *str_parms);
51 
52 /* debug */
53 void str_parms_dump(struct str_parms *str_parms);
54 
55 #endif /* __CUTILS_STR_PARMS_H */
56