void ui_message_handlert::print( unsigned level, const std::string &message, int sequence_number, const source_locationt &location) { if(verbosity>=level) { switch(get_ui()) { case PLAIN: message_handlert::print( level, message, sequence_number, location); break; case XML_UI: case JSON_UI: { std::string tmp_message(message); if(!tmp_message.empty() && *tmp_message.rbegin()=='\n') tmp_message.resize(tmp_message.size()-1); const char *type=level_string(level); std::string sequence_number_str= sequence_number>=0?i2string(sequence_number):""; ui_msg(type, tmp_message, sequence_number_str, location); } break; } } }
static void parse_content(int level, int64_t end_pos) { while (static_cast<int64_t>(g_in->getFilePointer()) < end_pos) { int64_t element_start_pos = g_in->getFilePointer(); try { vint_c id = read_id(end_pos); vint_c size = read_size(end_pos); std::string element_name = g_element_names[id.value]; if (element_name.empty()) element_name = Y("unknown"); mxinfo(boost::format(Y("%1%pos %2% id 0x%|3$x| size %4% header size %5% (%6%)\n")) % level_string(level) % element_start_pos % id.value % size.value % (id.coded_size + size.coded_size) % element_name); if (size.is_unknown()) { mxinfo(boost::format(Y("%1% Warning: size is coded as 'unknown' (all bits are set)\n")) % level_string(level)); // In Matroska segments often have an unknown size – so don't // warn about it. if (element_name != "Segment") g_warnings_found = true; } int64_t content_end_pos = size.is_unknown() ? end_pos : g_in->getFilePointer() + size.value; if (content_end_pos > end_pos) { mxinfo(boost::format(Y("%1% Error: Element ends after scope\n")) % level_string(level)); g_errors_found = true; if (!g_in->setFilePointer2(end_pos)) mxerror(boost::format(Y("Error: Seek to %1%\n")) % end_pos); return; } if (g_is_master[id.value]) parse_content(level + 1, content_end_pos); if (!g_in->setFilePointer2(content_end_pos)) mxerror(boost::format(Y("Error: Seek to %1%\n")) % content_end_pos); } catch (id_error_c &error) { std::string message = id_error_c::end_of_file == error.code ? Y("End of file") : id_error_c::end_of_scope == error.code ? Y("End of scope") : id_error_c::first_byte_is_zero == error.code ? Y("First byte is zero") : id_error_c::longer_than_four_bytes == error.code ? Y("ID is longer than four bytes") : Y("reason is unknown"); mxinfo(boost::format(Y("%1%Error at %2%: error reading the element ID (%3%)\n")) % level_string(level) % element_start_pos % message); g_errors_found = true; if (!g_in->setFilePointer2(end_pos)) mxerror(boost::format(Y("Error: Seek to %1%\n")) % end_pos); return; } catch (size_error_c &error) { std::string message = size_error_c::end_of_file == error.code ? Y("End of file") : size_error_c::end_of_scope == error.code ? Y("End of scope") : Y("reason is unknown"); mxinfo(boost::format(Y("%1%Error at %2%: error reading the element size (%3%)\n")) % level_string(level) % element_start_pos % message); g_errors_found = true; if (!g_in->setFilePointer2(end_pos)) mxerror(boost::format(Y("Error: Seek to %1%\n")) % end_pos); return; } catch (...) { mxerror(Y("Unknown error occured\n")); } } }