static void dump_msg_metadata(struct istream *input) { struct dbox_metadata_header hdr; const unsigned char *data; size_t size; const char *line; /* verify magic */ if (i_stream_read_bytes(input, &data, &size, sizeof(hdr)) <= 0) { i_fatal("dbox missing metadata at %"PRIuUOFF_T, input->v_offset); } memcpy(&hdr, data, sizeof(hdr)); if (memcmp(hdr.magic_post, DBOX_MAGIC_POST, sizeof(hdr.magic_post)) != 0) i_fatal("dbox wrong post-magic at %"PRIuUOFF_T, input->v_offset); i_stream_skip(input, sizeof(hdr)); /* dump the metadata */ for (;;) { if ((line = i_stream_read_next_line(input)) == NULL) i_fatal("dbox metadata ended unexpectedly at EOF"); if (*line == '\0') break; switch (*line) { case DBOX_METADATA_GUID: printf("msg.guid = %s\n", line + 1); break; case DBOX_METADATA_POP3_UIDL: printf("msg.pop3-uidl = %s\n", line + 1); break; case DBOX_METADATA_POP3_ORDER: printf("msg.pop3-order = %s\n", line + 1); break; case DBOX_METADATA_RECEIVED_TIME: dump_timestamp(input, "msg.received", line + 1); break; case DBOX_METADATA_PHYSICAL_SIZE: (void)dump_size(input, "msg.physical-size", line + 1); break; case DBOX_METADATA_VIRTUAL_SIZE: (void)dump_size(input, "msg.virtual-size", line + 1); break; case DBOX_METADATA_EXT_REF: printf("msg.ext-ref = %s\n", line + 1); break; case DBOX_METADATA_ORIG_MAILBOX: printf("msg.orig-mailbox = %s\n", line + 1); break; case DBOX_METADATA_OLDV1_EXPUNGED: case DBOX_METADATA_OLDV1_FLAGS: case DBOX_METADATA_OLDV1_KEYWORDS: case DBOX_METADATA_OLDV1_SAVE_TIME: case DBOX_METADATA_OLDV1_SPACE: printf("msg.obsolete-%c = %s\n", *line, line + 1); break; } } }
std::ostream& dump(std::ostream& os, const std::string& name, const Stat& stat) { os << std::setw(9) << std::setiosflags(std::ios::left) << name << " raw: " << dump_size(stat.bytes()) << " compressed: " << dump_size(stat.compressed()) << " cache: " << dump_size(stat.cache()); return os; }
//Restore Function int MGTolerance::restore(MGIfstream& buf){ int len = -1; try { double m_mach_zero,m_wc_zero,m_wc_zero_sqr, m_rc_zero,m_rc_zero_sqr,m_angle_zero, m_line_zero,m_max_knot_ratio; buf >> m_mach_zero >> m_wc_zero >> m_wc_zero_sqr >> m_rc_zero >> m_rc_zero_sqr >> m_angle_zero >> m_line_zero >> m_max_knot_ratio; len = dump_size(); set_mach_zero(m_mach_zero); set_wc_zero(m_wc_zero); set_rc_zero(m_rc_zero); set_angle_zero(m_angle_zero); set_line_zero(m_line_zero); set_max_knot_ratio(m_max_knot_ratio); } catch (...) { throw; } return len; }
static bool dump_msg_hdr(struct istream *input, unsigned int hdr_size, uoff_t *msg_size_r) { struct dbox_message_header hdr; const unsigned char *data; size_t size; uoff_t msg_size; if (i_stream_read_bytes(input, &data, &size, hdr_size) <= 0) { if (size == 0) return FALSE; i_fatal("Partial message header read at %"PRIuUOFF_T": " "%"PRIuSIZE_T" bytes", input->v_offset, size); } printf("offset %"PRIuUOFF_T":\n", input->v_offset); if (hdr_size < sizeof(hdr)) i_fatal("file.hdr_size too small: %u", hdr_size); memcpy(&hdr, data, sizeof(hdr)); if (memcmp(hdr.magic_pre, DBOX_MAGIC_PRE, sizeof(hdr.magic_pre)) != 0) i_fatal("dbox wrong pre-magic at %"PRIuUOFF_T, input->v_offset); msg_size = dump_size(input, "msg.size", t_strndup(hdr.message_size_hex, sizeof(hdr.message_size_hex))); i_stream_skip(input, hdr_size); *msg_size_r = msg_size; return TRUE; }
//Restore Function int MGPosition::restore(MGIfstream& buf){ // 0:OK !0:NG -99:file not open int len = -1; try { m_element.restore(buf); len = dump_size(); } catch (...){ throw; } return len; }
int MGPosition::dump(MGOfstream& buf) const{ int len = -1; try{ m_element.dump(buf); len = dump_size(); } catch(...){ throw; } return len; }
// Dump Function int MGEReal::dump(MGOfstream& buf)const{ int len = -1; try{ buf<<m_value; len = dump_size(); } catch(...){ throw; } return len; }
//Restore & Create Object int MGInterval::restore(MGIfstream& buf){ int len = -1; try { m_high.restore(buf); m_low.restore(buf); dump_size(); } catch (...){ throw; } return len; }
//Dump Function int MGOscuCircleData::dump(MGOfstream& buf) const{ int len = -1; try { buf << m_index << m_radius; len = dump_size(); } catch (...) { throw; } return len; }
//Dump Function // length() == size() となるようにサイズを変更してダンプする。 int MGNDDArray::dump(MGOfstream & buf) const{ int len = -1; try { buf << m_length; for(size_t i=0; i<m_length; i++) buf<<m_element[i]; len = dump_size(); } catch (...) { throw; } return len; }
//Restore Function int MGKnot::restore(MGIfstream& buf){ int len = -1; try { buf >> m_value >> m_multiplicity; len = dump_size(); } catch (...) { throw; } return len; }
//Restore Function int MGOscuCircleData::restore(MGIfstream& buf){ int len = 0; try { buf >> m_index >> m_radius; len = dump_size(); } catch (...) { throw; } return len; }
//Dump Function // Dumped Vector Dimension and each element int MGVector::dump(MGOfstream& buf) const{ int len = -1; try{ int dim = sdim(); buf<<dim; for(int i=0; i<dim; i++) buf << m_element[i]; len = dump_size(); } catch(...){ throw; } return len; }
//Dump Function int MGTransf::dump(MGOfstream& buf) const{ int len = -1; try { m_affine.dump(buf); m_translation.dump(buf); len = dump_size(); } catch (...) { throw; } return len; }
//Restore Function int MGKnotVector::restore(MGIfstream& buf){ int len = -1; try { MGNDDArray::restore(buf); buf >> m_order; if(m_order) m_current=m_order-1; len = dump_size(); } catch (...) { throw; } return len; }
//Dump Function int MGKnotVector::dump(MGOfstream& buf) const{ int len = -1; try { MGNDDArray::dump(buf); buf << m_order; len = dump_size(); } catch (...) { throw; } return len; }
//Dump Function int MGKnot::dump(MGOfstream& buf) const{ // 0:OK !0:NG -99: file not open int len = -1; try { buf << m_value << m_multiplicity; len = dump_size(); } catch (...) { throw; } return len; }
// Restore & Create New Object int MGEReal::restore(MGIfstream& buf){ int len = -1; try{ double value; buf>>value; m_value = value; len = dump_size(); } catch (...){ throw; } return len; }
//Restore Function int MGTransf::restore(MGIfstream& buf){ int len = -1; try { m_affine.restore(buf); m_translation.restore(buf); len = dump_size(); } catch (...) { throw; } return len; }
//Restore Function int MGNDDArray::restore(MGIfstream& buf){ int len = -1; try { buf >> len; resize(len); for(int i=0; i<len; i++) buf>>m_element[i]; len = dump_size(); } catch(...){ throw; } return len; }
//Dump Function int MGInterval::dump(MGOfstream& buf)const{ int len = -1; try { m_high.dump(buf); m_low.dump(buf); len = dump_size(); } catch(...) { throw; } return len; }
int MGPPRep::dump(MGOfstream& buf) const{ int len = -1; try{ buf<<m_order<<m_nbreak<<m_sdim; m_break_point.dump(buf); size_t dim = m_order * m_nbreak * m_sdim; for(size_t i=0; i<dim; i++) buf<<m_coef[i]; len = dump_size(); } catch(...){ throw; } return len; }
//Dump Function int MGLBRepEndC::dump(MGOfstream& buf) const{ int len = -1; try { buf << m_cond; m_1deriv.dump(buf); m_2deriv.dump(buf); len = dump_size(); } catch (...) { throw; } return len; }
//Restore Function int MGVector::restore(MGIfstream& buf){ // 0:OK !0:NG -99:file not open int len = -1; try{ int dim; buf>>dim; resize(dim); for(int i=0; i<dim; i++) buf>>m_element[i]; len = dump_size(); } catch (...) { throw; } return len; }
//Dump Function int MGOscuCircle::dump(MGOfstream& buf) const{ int len = -1; try{ std::vector<MGOscuCircleData>::const_iterator i = m_circle.begin(); buf<<m_n; for(size_t iloop = 0; iloop < m_n; iloop++, i++){ (*i).dump(buf); } len = dump_size(); } catch (...) { throw; } return len; }
//Dump Function int MGMatrix::dump(MGOfstream& buf) const{ int len = 0; try{ size_t dim = sdim(); size_t mtx_len = dim*dim; buf << dim; for(size_t i=0; i<mtx_len; i++) buf<<m_matrix[i]; len = dump_size(); } catch (...){ throw; } return len; }
//Restore Function int MGSPointSeq::restore(MGIfstream& buf){ int len = -1; try{ size_t lenu, lenv, dim; buf >> lenu >> lenv >> dim; resize(lenu, lenv, dim); size_t vec_len=lenu*lenv*dim; for (size_t i=0; i<vec_len; i++) buf>>m_spoint[i]; len = dump_size(); } catch (...) { throw; } return len; }
//Restore Function int MGLBRepEndC::restore(MGIfstream& buf){ int len = 0; try { buf >> (int&)m_cond; m_1deriv.restore(buf); m_2deriv.restore(buf); len = dump_size(); } catch (...) { throw; } return len; }
int MGPPRep::restore(MGIfstream& buf){ int len = -1; try{ size_t order, nbreak, sdim; buf>>order>>nbreak>>sdim; resize(order, nbreak, sdim); m_break_point.restore(buf); size_t dim = m_order * m_nbreak * m_sdim; for(size_t i = 0; i < dim ; i++) buf>>m_coef[i]; len = dump_size(); } catch(...){ throw; } return len; }
//Restore Function int MGOscuCircle::restore(MGIfstream& buf){ int len = -1; try{ buf >> m_n; for(size_t i = 0; i < m_n; i++){ MGOscuCircleData Q; Q.restore(buf); m_circle.push_back(Q); } len = dump_size(); } catch (...) { throw; } return len; }