| 172 | } |
| 173 | |
| 174 | bool http_servlet::xmlToJson(acl::xml& xml, acl::json& json) |
| 175 | { |
| 176 | /** |
| 177 | * ���ݸ�ʽ |
| 178 | * <servers> |
| 179 | * <server conns='xxx' used='xxx' qlen='xxx' max_threads='xxx' |
| 180 | * curr_threads='xxx' busy_threads='xxx' addr='xxx' load='xxx'> |
| 181 | * <proc> |
| 182 | * <conns>xxx</conns> |
| 183 | * <used>xxx</used> |
| 184 | * <pid>xxx</pid> |
| 185 | * <max_threads>xxx</max_threads> |
| 186 | * <curr_threads>xxx</curr_threads> |
| 187 | * <busy_threads>xxx</busy_threads> |
| 188 | * <qlen>xxx</qlen> |
| 189 | * <type>xxx</type> |
| 190 | * </proc> |
| 191 | * </server> |
| 192 | * </servers> |
| 193 | */ |
| 194 | |
| 195 | acl::xml_node& root = xml.get_root(); |
| 196 | acl::xml_node* servers = NULL; |
| 197 | for (acl::xml_node* child = root.first_child(); |
| 198 | child != NULL; child = root.next_child()) |
| 199 | { |
| 200 | const char* tag = child->tag_name(); |
| 201 | if (tag != NULL && strcasecmp(tag, "servers") == 0) |
| 202 | { |
| 203 | servers = child; |
| 204 | break; |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | if (servers == NULL) |
| 209 | { |
| 210 | logger_error("no servers found in: %s", xml.to_string()); |
| 211 | return false; |
| 212 | } |
| 213 | |
| 214 | acl::json_node& a = json.create_array(); |
| 215 | json.get_root().add_child("servers", a); |
| 216 | |
| 217 | for (acl::xml_node* child = servers->first_child(); |
| 218 | child != NULL; child = servers->next_child()) |
| 219 | { |
| 220 | const char* tag = child->tag_name(); |
| 221 | if (tag == NULL || strcasecmp(tag, "server") != 0) |
| 222 | continue; |
| 223 | |
| 224 | const char* ptr = (*child)["conns"]; |
| 225 | if (ptr == NULL || *ptr == 0) |
| 226 | continue; |
| 227 | int conns = atoi(ptr); |
| 228 | |
| 229 | if ((ptr = (*child)["used"]) == NULL || *ptr == 0) |
| 230 | continue; |
| 231 | int used = atoi(ptr); |
nothing calls this directly
no test coverage detected