| 266 | } |
| 267 | |
| 268 | int db_ctl::load_names(void) |
| 269 | { |
| 270 | const char* sql = "select id, name, type from tbl_name"; |
| 271 | if (ctl_conn_->sql_select(sql) == false) |
| 272 | { |
| 273 | logger_error("sql(%s) error", sql); |
| 274 | return -1; |
| 275 | } |
| 276 | |
| 277 | const std::vector<acl::db_row*>* rows = ctl_conn_->get_rows(); |
| 278 | if (rows == NULL) |
| 279 | { |
| 280 | logger_error("tbl_name empty"); |
| 281 | return 0; |
| 282 | } |
| 283 | |
| 284 | unsigned int id; |
| 285 | int type; |
| 286 | const char* name; |
| 287 | size_t i; |
| 288 | for (i = 0; i < rows->size(); i++) |
| 289 | { |
| 290 | const acl::db_row* row = (*rows)[i]; |
| 291 | id = row->field_int("id", -1); |
| 292 | if (id == (unsigned int) -1) |
| 293 | { |
| 294 | logger_error("invalid id"); |
| 295 | continue; |
| 296 | } |
| 297 | name = row->field_string("name"); |
| 298 | if (name == NULL) |
| 299 | { |
| 300 | logger_error("invalid name"); |
| 301 | continue; |
| 302 | } |
| 303 | type = row->field_int("type", -1); |
| 304 | if (type < NAME_TYPE_DB || type > NAME_TYPE_IDX) |
| 305 | { |
| 306 | logger_error("invalid type"); |
| 307 | continue; |
| 308 | } |
| 309 | add_name(name, id, (name_type_t) type); |
| 310 | } |
| 311 | |
| 312 | ctl_conn_->free_result(); |
| 313 | return (int) i; |
| 314 | } |
| 315 | |
| 316 | int db_ctl::load_idx_hosts(void) |
| 317 | { |
nothing calls this directly
no test coverage detected