| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#include "config.h" |
| 24 |
#include <stdio.h> |
| 25 |
#include <errno.h> |
| 26 |
#include "trace.h" |
| 27 |
#include "collection.h" |
| 28 |
#include "collection_tools.h" |
| 29 |
#include "ini_config.h" |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
void free_section_list(char **section_list) |
| 34 |
{ |
| 35 |
TRACE_FLOW_STRING("free_section_list","Entry"); |
| 36 |
|
| 37 |
col_free_property_list(section_list); |
| 38 |
|
| 39 |
TRACE_FLOW_STRING("free_section_list","Exit"); |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
void free_attribute_list(char **section_list) |
| 44 |
{ |
| 45 |
TRACE_FLOW_STRING("free_attribute_list","Entry"); |
| 46 |
|
| 47 |
col_free_property_list(section_list); |
| 48 |
|
| 49 |
TRACE_FLOW_STRING("free_attribute_list","Exit"); |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
char **get_section_list(struct collection_item *ini_config, int *size, int *error) |
| 57 |
{ |
| 58 |
char **list; |
| 59 |
|
| 60 |
TRACE_FLOW_STRING("get_section_list","Entry"); |
| 61 |
|
| 62 |
if ((ini_config == NULL) || |
| 63 |
((col_is_of_class(ini_config, COL_CLASS_INI_CONFIG) == 0) && |
| 64 |
(col_is_of_class(ini_config, COL_CLASS_INI_META) == 0))) { |
| 65 |
TRACE_ERROR_NUMBER("Invalid argument.", EINVAL); |
| 66 |
if (error) *error = EINVAL; |
| 67 |
return NULL; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
list = col_collection_to_list(ini_config, size, error); |
| 72 |
|
| 73 |
TRACE_FLOW_STRING("get_section_list returning", ((list == NULL) ? "NULL" : list[0])); |
| 74 |
return list; |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
char **get_attribute_list(struct collection_item *ini_config, const char *section, int *size, int *error) |
| 81 |
{ |
| 82 |
struct collection_item *subcollection = NULL; |
| 83 |
char **list; |
| 84 |
int err; |
| 85 |
|
| 86 |
TRACE_FLOW_STRING("get_attribute_list","Entry"); |
| 87 |
|
| 88 |
if ((ini_config == NULL) || |
| 89 |
((col_is_of_class(ini_config, COL_CLASS_INI_CONFIG) == 0) && |
| 90 |
(col_is_of_class(ini_config, COL_CLASS_INI_META) == 0)) || |
| 91 |
(section == NULL)) { |
| 92 |
TRACE_ERROR_NUMBER("Invalid argument.", EINVAL); |
| 93 |
if (error) *error = EINVAL; |
| 94 |
return NULL; |
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
err = col_get_collection_reference(ini_config, &subcollection, section); |
| 99 |
|
| 100 |
if (err && (subcollection == NULL)) { |
| 101 |
TRACE_ERROR_NUMBER("Failed to get section", err); |
| 102 |
if (error) *error = EINVAL; |
| 103 |
return NULL; |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
list = col_collection_to_list(subcollection, size, error); |
| 108 |
|
| 109 |
col_destroy_collection(subcollection); |
| 110 |
|
| 111 |
TRACE_FLOW_STRING("get_attribute_list returning", ((list == NULL) ? "NULL" : list[0])); |
| 112 |
return list; |
| 113 |
} |