| 314 | } |
| 315 | |
| 316 | int db_ctl::load_idx_hosts(void) |
| 317 | { |
| 318 | const char* sql = "select id, addr, count from tbl_host_idx"; |
| 319 | if (ctl_conn_->sql_select(sql) == false) |
| 320 | { |
| 321 | logger_error("sql(%s) error", sql); |
| 322 | return -1; |
| 323 | } |
| 324 | |
| 325 | const std::vector<acl::db_row*>* rows = ctl_conn_->get_rows(); |
| 326 | if (rows == NULL) |
| 327 | { |
| 328 | logger_warn("tbl_host_idx empty"); |
| 329 | return 0; |
| 330 | } |
| 331 | |
| 332 | unsigned int id; |
| 333 | const char* addr; |
| 334 | acl_int64 count; |
| 335 | size_t i; |
| 336 | for (i = 0; i < rows->size(); i++) |
| 337 | { |
| 338 | const acl::db_row* row = (*rows)[i]; |
| 339 | if ((id = row->field_int("id", -1)) == (unsigned int) -1) |
| 340 | { |
| 341 | logger_error("id(-1) invalid"); |
| 342 | continue; |
| 343 | } |
| 344 | else if ((addr = row->field_string("addr")) == NULL) |
| 345 | { |
| 346 | logger_error("name null"); |
| 347 | continue; |
| 348 | } |
| 349 | else if ((count = row->field_int64("count", -1)) == -1) |
| 350 | { |
| 351 | logger_error("count invalid"); |
| 352 | continue; |
| 353 | } |
| 354 | idx_host* host = new idx_host(id, addr, count); |
| 355 | idx_hosts_.push_back(host); |
| 356 | } |
| 357 | ctl_conn_->free_result(); |
| 358 | return (int) i; |
| 359 | } |
| 360 | |
| 361 | int db_ctl::load_dat_hosts(void) |
| 362 | { |
nothing calls this directly
no test coverage detected