void co_debug_download_and_parse(void) { co_manager_handle_t handle; xml_start(); handle = co_os_manager_open(); if (handle) { char *buffer = co_os_malloc(BUFFER_SIZE); if (buffer) { co_manager_ioctl_debug_reader_t debug_reader; debug_reader.user_buffer = buffer; debug_reader.user_buffer_size = BUFFER_SIZE; while (1) { debug_reader.filled = 0; co_rc_t rc = co_manager_debug_reader(handle, &debug_reader); if (!CO_OK(rc)) { fprintf(stderr, "log ended: %x\n", (int)rc); return; } parse_tlv_buffer(buffer, debug_reader.filled); /* Flush, if stdout not redirected */ if (output_file != stdout) fflush (output_file); } co_os_free(buffer); } co_os_manager_close(handle); } xml_end(); }
static void xml_start_cb(void *userdata, const XML_Char *name, const XML_Char **attr) { struct xml_data *xdata = (struct xml_data*)userdata; if (!strcmp(name, ELEMENT_SENSORS)) { xdata->xml_stag = ELE_SENSORS; xdata->depth += 1; } else if (!strcmp(name, ELEMENT_COUNT)) { xdata->xml_stag = ELE_COUNT; } else if (!strcmp(name, ELEMENT_SENSOR)) { xdata->xml_stag = ELE_SENSOR; xdata->curr_sens += 1; xdata->curr_inflx =-1; } else if (!strcmp(name, ELEMENT_CHARACTERISTICS)) { xdata->xml_stag = ELE_CHARACTERISTICS; xdata->depth += 1; } else if (!strcmp(name, ELEMENT_INFLEXIONPOINT)) { xdata->xml_stag = ELE_INFLEXIONPOINT; xdata->curr_inflx += 1; xdata->depth += 1; } else { ALOGD("Thermalutils: Unknown xml tag found"); } xml_start(xdata, attr); }
static void co_debug_parse(int fd) { xml_start(); for (;;) { co_debug_tlv_t tlv; int nread; nread = read(fd, &tlv, sizeof(tlv)); if (nread != sizeof(tlv) || tlv.length == 0) break; char block[tlv.length]; nread = read_helper(fd, (void*)&block, tlv.length); if (nread != tlv.length) break; parse_tlv(&tlv, block); /* Flush every block, if stdout not redirected */ if (output_file != stdout) fflush (output_file); } xml_end(); }