void if_dump_f ( sb_element_t *e ) { printf ( "Type: If\n" ); g_sb_indent += 1; _dump_indent(); printf ( "Condition:\n" ); g_sb_indent += 1; dump_element ( e -> data.ifdata.condition ); g_sb_indent -= 1; _dump_indent(); printf ( "True Path:\n" ); g_sb_indent += 1; dump_element ( e -> data.ifdata.truepath ); g_sb_indent -= 1; _dump_indent(); printf ( "False Path:\n" ); g_sb_indent += 1; dump_element ( e -> data.ifdata.falsepath ); g_sb_indent -= 1; g_sb_indent -= 1; return; }
static void dump_process_info(int to, void *to_arg, Process *p) { Eterm* sp; ErlMessage* mp; int yreg = -1; ERTS_SMP_MSGQ_MV_INQ2PRIVQ(p); if ((p->trace_flags & F_SENSITIVE) == 0 && p->msg.first) { erts_print(to, to_arg, "=proc_messages:%T\n", p->id); for (mp = p->msg.first; mp != NULL; mp = mp->next) { Eterm mesg = ERL_MESSAGE_TERM(mp); if (is_value(mesg)) dump_element(to, to_arg, mesg); else dump_dist_ext(to, to_arg, mp->data.dist_ext); mesg = ERL_MESSAGE_TOKEN(mp); erts_print(to, to_arg, ":"); dump_element(to, to_arg, mesg); erts_print(to, to_arg, "\n"); } } if ((p->trace_flags & F_SENSITIVE) == 0) { if (p->dictionary) { erts_print(to, to_arg, "=proc_dictionary:%T\n", p->id); erts_deep_dictionary_dump(to, to_arg, p->dictionary, dump_element_nl); } } if ((p->trace_flags & F_SENSITIVE) == 0) { erts_print(to, to_arg, "=proc_stack:%T\n", p->id); for (sp = p->stop; sp < STACK_START(p); sp++) { yreg = stack_element_dump(to, to_arg, p, sp, yreg); } erts_print(to, to_arg, "=proc_heap:%T\n", p->id); for (sp = p->stop; sp < STACK_START(p); sp++) { Eterm term = *sp; if (!is_catch(term) && !is_CP(term)) { heap_dump(to, to_arg, term); } } for (mp = p->msg.first; mp != NULL; mp = mp->next) { Eterm mesg = ERL_MESSAGE_TERM(mp); if (is_value(mesg)) heap_dump(to, to_arg, mesg); mesg = ERL_MESSAGE_TOKEN(mp); heap_dump(to, to_arg, mesg); } if (p->dictionary) { erts_deep_dictionary_dump(to, to_arg, p->dictionary, heap_dump); } } }
static void dump_dist_ext(int to, void *to_arg, ErtsDistExternal *edep) { if (!edep) erts_print(to, to_arg, "D0:E0:"); else { byte *e; size_t sz; if (!(edep->flags & ERTS_DIST_EXT_ATOM_TRANS_TAB)) erts_print(to, to_arg, "D0:"); else { int i; erts_print(to, to_arg, "D%X:", edep->attab.size); for (i = 0; i < edep->attab.size; i++) dump_element(to, to_arg, edep->attab.atom[i]); } sz = edep->ext_endp - edep->extp; e = edep->extp; if (edep->flags & ERTS_DIST_EXT_DFLAG_HDR) { ASSERT(*e != VERSION_MAGIC); sz++; } else { ASSERT(*e == VERSION_MAGIC); } erts_print(to, to_arg, "E%X:", sz); if (edep->flags & ERTS_DIST_EXT_DFLAG_HDR) erts_print(to, to_arg, "%02X", VERSION_MAGIC); while (e < edep->ext_endp) erts_print(to, to_arg, "%02X", *e++); } }
void dump_element(int depth, wdl_xml_element *elem) { if (!elem) return; indent(depth); printf("element: %s (line %d col %d)\n",elem->name,elem->line,elem->col); if (elem->attributes.GetSize()) { indent(depth+1); printf("attributes:\n"); int x; for(x=0;x<elem->attributes.GetSize();x++) { const char *key=NULL; const char *value=elem->attributes.Enumerate(x,(char **)&key); indent(depth+2); printf("%s=%s\n",key,value); } } if (elem->value.GetLength()) { indent(depth+1); printf("value: %s\n",elem->value.Get()); } if (elem->elements.GetSize()) { indent(depth+1); printf("elements:\n"); int x; for(x=0;x<elem->elements.GetSize();x++) { dump_element(depth+2,elem->elements.Get(x)); } } }
// Dump lua stack void dump_stack(lua_State* L) { DEBUG("=== STACK DUMP"); int idx; for (idx=1; idx<=lua_gettop(L); ++idx) dump_element(L, idx, 0); DEBUG("=== END DUMP\n"); }
// Dump a lua stack element, with recursion void dump_element_recurse(lua_State* L, int idx, int depth) { dump_element(L, idx, depth); if (lua_istable(L, idx)) { int n = lua_gettop(L); lua_pushvalue(L, idx); // push table on top dump_element_recurse(L, n+1, depth+1); lua_pop(L, 1); // pop table from tack assert( lua_gettop(L) == n ); } }
// Dump a lua variable, without recursion void dump_var(lua_State* L, const char* var) { DEBUG("== VAR DUMP"); int n = lua_gettop(L); lua_getglobal(L, var); assert( lua_gettop(L) > 0 ); dump_element(L, n+1, 0); lua_pop(L, 1); assert( lua_gettop(L) == n ); DEBUG("== END DUMP\n"); }
int main(int argc, const char **argv) { if (argc != 2) { printf("Usage: xmlparse_test filename.xml\n"); return 1; } FILE *fp = fopen(argv[1],"r"); wdl_xml_fileread fr(fp); const char *err = fr.parse(); if (err) { printf("parse error line %d, col %d: %s\n", fr.getLine(),fr.getCol(), err); return 1; } printf("doctype: %s\n",fr.element_doctype_tokens.Get(0)); dump_element(0, fr.element_xml); dump_element(0, fr.element_root); return 0; }
void dump_segment(size_t index, edi_segment_t *s) { size_t c; fprintf(stderr, "Segment %u [%s]:\n", (unsigned int) index, s->tag); for(c = 0; c < s->nelements; c++) { dump_element(c, &(s->elements[c])); } }
void dump_symbol ( sb_symbol_node_t *n ) { while ( n ) { _dump_indent(); printf ( "Symbol name: %s\n", n -> name ); g_sb_indent += 1; dump_element ( n -> value ); g_sb_indent -= 1; n = n -> next; } return; }
static void dump_element_nl(int to, void *to_arg, Eterm x) { dump_element(to, to_arg, x); erts_putc(to, to_arg, '\n'); }
void ExportContext::_dumpElementStack( BString& out) { out << "Element stack:\n"; for_each(m_elementStack.begin(), m_elementStack.end(), dump_element(out)); }
void ClassesWidget::import_ocad_iofxml() { qfLogFuncFrame(); QString fn = qfd::FileDialog::getOpenFileName(this, tr("Open file"), QString(), "XML files (*.xml);; All files (*)"); if(fn.isEmpty()) return; try { QFile f(fn); if(f.open(QFile::ReadOnly)) { QDomDocument xdoc; QString err_str; int err_line; if(!xdoc.setContent(&f, &err_str, &err_line)) QF_EXCEPTION(QString("Error parsing xml file '%1' at line: %2").arg(err_str).arg(err_line)); QDomNodeList xml_courses = xdoc.elementsByTagName(QStringLiteral("Course")); QList<CourseDef> defined_courses_list; for (int i = 0; i < xml_courses.count(); ++i) { QDomElement el_course = xml_courses.at(i).toElement(); if(el_course.isNull()) QF_EXCEPTION(QString("Xml file format error: bad element '%1'").arg("Course")); CourseDef coursedef; QString course_name = element_text(el_course, QStringLiteral("CourseName")); course_name.replace(' ', QString()); course_name.replace(';', '-'); course_name.replace(',', '-'); course_name.replace(':', '-'); course_name.replace('+', '-'); coursedef.setName(course_name); QStringList class_names; QDomNodeList xml_classes = el_course.elementsByTagName(QStringLiteral("ClassShortName")); for (int j = 0; j < xml_classes.count(); ++j) { QString class_name = xml_classes.at(j).toElement().text().trimmed(); class_names << class_name; } coursedef.setClasses(class_names); QDomElement el_course_variantion = el_course.firstChildElement(QStringLiteral("CourseVariation")); if(el_course_variantion.isNull()) QF_EXCEPTION(QString("Xml file format error: missing element '%1'").arg("CourseVariation")); coursedef.setLenght(element_text(el_course_variantion, QStringLiteral("CourseLength")).trimmed().toInt()); coursedef.setClimb(element_text(el_course_variantion, QStringLiteral("CourseClimb")).trimmed().toInt()); QMap<int, QVariant> codes; QDomNodeList xml_controls = el_course.elementsByTagName(QStringLiteral("CourseControl")); for (int j = 0; j < xml_controls.count(); ++j) { QDomElement el_control = xml_controls.at(j).toElement(); int no = element_text(el_control, QStringLiteral("Sequence")).trimmed().toInt(); if(no <= 0) QF_EXCEPTION(QString("Xml file format error: bad sequence number %1 in %2").arg(no).arg(dump_element(el_control))); int code = element_text(el_control, QStringLiteral("ControlCode")).trimmed().toInt(); if(code <= 0) QF_EXCEPTION(QString("Xml file format error: bad control code %1 in %2").arg(code).arg(dump_element(el_control))); codes[no] = code; } coursedef.setCodes(codes.values()); defined_courses_list << coursedef; } importCourses(defined_courses_list); } } catch (const qf::core::Exception &e) { qf::qmlwidgets::framework::MainWindow *fwk = qf::qmlwidgets::framework::MainWindow::frameWork(); qf::qmlwidgets::dialogs::MessageBox::showException(fwk, e); } }