1
/* Copyright (C) 2004-2005 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
#include <ndb_types.h>
18
#include "mgmapi_configuration.hpp"
19
#include "../mgmsrv/ConfigInfo.hpp"
21
ndb_mgm_configuration_iterator::ndb_mgm_configuration_iterator
22
(const ndb_mgm_configuration & conf, unsigned type_of_section)
23
: m_config(conf.m_config)
26
m_typeOfSection = type_of_section;
30
ndb_mgm_configuration_iterator::~ndb_mgm_configuration_iterator(){
35
ndb_mgm_configuration_iterator::reset(){
36
if(m_sectionNo != (Uint32)~0){
37
m_config.closeSection();
43
ndb_mgm_configuration_iterator::enter(){
44
bool ok = m_config.openSection(m_typeOfSection, m_sectionNo);
55
ndb_mgm_configuration_iterator::first(){
62
ndb_mgm_configuration_iterator::next(){
69
ndb_mgm_configuration_iterator::valid() const {
70
return m_sectionNo != (Uint32)~0;
74
ndb_mgm_configuration_iterator::find(int param, unsigned search){
75
unsigned val = search + 1;
77
while(get(param, &val) == 0 && val != search){
89
ndb_mgm_configuration_iterator::get(int param, unsigned * value) const {
90
return m_config.get(param, value) != true;
95
ndb_mgm_configuration_iterator::get(int param,
96
unsigned long long * value) const{
97
return m_config.get(param, value) != true;
101
ndb_mgm_configuration_iterator::get(int param, const char ** value) const {
102
return m_config.get(param, value) != true;
106
* Published C interface
109
ndb_mgm_configuration_iterator*
110
ndb_mgm_create_configuration_iterator(ndb_mgm_configuration * conf,
111
unsigned type_of_section){
112
ndb_mgm_configuration_iterator* iter = (ndb_mgm_configuration_iterator*)
113
malloc(sizeof(ndb_mgm_configuration_iterator));
117
return new(iter) ndb_mgm_configuration_iterator(* conf, type_of_section);
122
void ndb_mgm_destroy_iterator(ndb_mgm_configuration_iterator* iter){
124
iter->~ndb_mgm_configuration_iterator();
131
ndb_mgm_first(ndb_mgm_configuration_iterator* iter){
132
return iter->first();
137
ndb_mgm_next(ndb_mgm_configuration_iterator* iter){
143
ndb_mgm_valid(const ndb_mgm_configuration_iterator* iter){
144
return iter->valid();
149
ndb_mgm_get_int_parameter(const ndb_mgm_configuration_iterator* iter,
150
int param, unsigned * value){
151
return iter->get(param, value);
156
ndb_mgm_get_int64_parameter(const ndb_mgm_configuration_iterator* iter,
157
int param, Uint64 * value){
158
return iter->get(param, value);
163
ndb_mgm_get_string_parameter(const ndb_mgm_configuration_iterator* iter,
164
int param, const char ** value){
165
return iter->get(param, value);
170
ndb_mgm_find(ndb_mgm_configuration_iterator* iter,
171
int param, unsigned search){
172
return iter->find(param, search);
176
* Retrieve information about parameter
177
* @param info : in - pointer to structure allocated by caller
178
* @param size : in/out : pointer to int initialized to sizeof(ndb_mgm_param_info)...will be set to bytes set by function on return
182
ndb_mgm_get_db_parameter_info(Uint32 paramId, struct ndb_mgm_param_info * info, size_t * size) {
183
if ( paramId == 0 ) {
188
for (int i = 0; i < data.m_NoOfParams; i++) {
189
if (paramId == data.m_ParamInfo[i]._paramId && strcmp("DB", data.m_ParamInfo[i]._section) == 0) {
191
if (tmp + sizeof(info->m_id) <= *size)
193
info->m_id = data.m_ParamInfo[i]._paramId;
194
tmp += sizeof(info->m_id);
197
if (tmp + sizeof(info->m_name) <= *size)
199
info->m_name = data.m_ParamInfo[i]._fname;
200
tmp += sizeof(info->m_name);