/* ================================== ProfileWindow::ProfileWindow ================================== */ ProfileWindow::ProfileWindow(Profile *prof, TwoDeeOverview *tdo, Gtk::Window *profilewindow, Gtk::Window *overviewwindow, Gtk::EventBox *eventboxprof, const Glib::RefPtr<Gtk::Builder>& builder, AdvancedOptionsWindow *aow) : prof(prof), tdo(tdo), aow(aow), eventboxprof(eventboxprof), profilewindow(profilewindow), overviewwindow(overviewwindow) { profileworker = NULL; classifyworker = new ClassifyWorker(this->prof); classifyworker->sig_done.connect(sigc::mem_fun(*this, &ProfileWindow::points_classified)); classifyworker->start(); load_xml(builder); profilewindow->set_title("LAG Profile"); pointwidthselectprof->set_value(2); movingaveragerangeselect->set_value(5); slantwidthselectprof->set_value(5); classificationselect->set_value(7); connect_signals(); profilewindow->show_all(); set_statusbar_label(""); prof->setshowheightscale(showheightscalecheck->get_active()); prof->setpointwidth(pointwidthselectprof->get_value()); prof->setdrawpoints(pointshowtoggle->get_active()); prof->setdrawmovingaverage(lineshowtoggle->get_active()); prof->setmavrgrange(movingaveragerangeselect->get_value()); prof->setslantwidth(slantwidthselectprof->get_value()); prof->setslantwidth(slantwidthselectprof->get_value()); prof->setslanted(slantedprof->get_active()); }
techtree_t::techtree_t(fs_t& fs,const std::string& name): mgr_t(fs), xml_loadable_t(name), path(fs.canocial(std::string("techs")+"/"+name)) { { const strings_t subdirs = fs.list_dirs(path+"/factions"); for(strings_t::const_iterator i=subdirs.begin(); i!=subdirs.end(); i++) if(fs.exists(path+"/factions/"+*i+"/"+*i+".xml")) { factions.push_back(*i); faction_refs.push_back(ref_t(*this,FACTION,*i)); } if(!factions.size()) data_error("techtree "<<name<<" contains no factions"); }{ const strings_t subdirs = fs.list_dirs(path+"/resources"); for(strings_t::const_iterator i=subdirs.begin(); i!=subdirs.end(); i++) if(fs.exists(path+"/resources/"+*i+"/"+*i+".xml")) { resources.push_back(*i); resource_refs.push_back(ref_t(*this,RESOURCE,*i)); } if(!resources.size()) data_error("techtree "<<name<<" contains no resources"); } fs_file_t::ptr_t f(fs.get(path+"/"+name+".xml")); istream_t::ptr_t in(f->reader()); load_xml(*in); }
int configuration_manager::load_settings() { const char *controller = machine().options().ctrlr(); int loaded = 0; /* loop over all registrants and call their init function */ for (auto type : m_typelist) type.load(config_type::INIT, nullptr); /* now load the controller file */ if (controller[0] != 0) { /* open the config file */ emu_file file(machine().options().ctrlr_path(), OPEN_FLAG_READ); osd_file::error filerr = file.open(controller, ".cfg"); if (filerr != osd_file::error::NONE) throw emu_fatalerror("Could not load controller file %s.cfg", controller); /* load the XML */ if (!load_xml(file, config_type::CONTROLLER)) throw emu_fatalerror("Could not load controller file %s.cfg", controller); } /* next load the defaults file */ emu_file file(machine().options().cfg_directory(), OPEN_FLAG_READ); osd_file::error filerr = file.open("default.cfg"); if (filerr == osd_file::error::NONE) load_xml(file, config_type::DEFAULT); /* finally, load the game-specific file */ filerr = file.open(machine().basename(), ".cfg"); if (filerr == osd_file::error::NONE) loaded = load_xml(file, config_type::GAME); /* loop over all registrants and call their final function */ for (auto type : m_typelist) type.load(config_type::FINAL, nullptr); /* if we didn't find a saved config, return 0 so the main core knows that it */ /* is the first time the game is run and it should diplay the disclaimer. */ return loaded; }
unit_type_t::unit_type_t(faction_t& fraction_,const std::string& name): class_t(fraction_.mgr,UNIT_TYPE,name), xml_loadable_t(name), path(fraction_.fs().canocial(fraction_.path+"/units/"+name)), faction(fraction_) { fs_file_t::ptr_t f(fs().get(path+"/"+name+".xml")); istream_t::ptr_t in(f->reader()); load_xml(*in); }
/* ================================== FileSaver::FileSaver ================================== */ FileSaver::FileSaver(TwoDeeOverview *tdo, Profile *prof, const Glib::RefPtr<Gtk::Builder>& builder) : lidardata (NULL), tdo (tdo), prof (prof), saveworker (NULL) { load_xml(builder); connect_signals(); utmselect->set_active(true); }
/* ================================== AdvancedOptionsWindow::AdvancedOptionsWindow ================================== */ AdvancedOptionsWindow::AdvancedOptionsWindow(TwoDeeOverview *tdo, Profile *prof, const Glib::RefPtr<Gtk::Builder>& builder) : tdo(tdo), prof(prof) { load_xml(builder); connect_signals(); movespeedselect->set_value(10.00); maindetailselect->set_value(1.50); previewdetailselectprof->set_value(2.0); tdo->setmaindetail(maindetailselect->get_value()); prof->setmaindetail(maindetailselectprof->get_value()); prof->setpreviewdetail(previewdetailselectprof->get_value()); }
/* * Craete host tree and all user tree. */ int GatherPolicy::create() { if (strlen(rule_file_) == 0) { strncpy(err_, "rule file name is empty.", sizeof(err_)); return -1; } mutex_.acquire_write(); clientList.reserve(2048); // Reserve 2048 rules. serviceList.reserve(2048); int ret = load_xml(); mutex_.release(); return ret; }
int main (int argc, char *argv[]) { int ret; sqlite3 *handle; char *err_msg = NULL; char **results; int rows; int columns; unsigned char *blob; int blob_len; char *hexBlob; unsigned char *xml; int len; char *sql; void *cache = spatialite_alloc_connection(); if (argc > 1 || argv[0] == NULL) argc = 1; /* silencing stupid compiler warnings */ ret = sqlite3_open_v2 (":memory:", &handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); if (ret != SQLITE_OK) { fprintf(stderr, "cannot open in-memory db: %s\n", sqlite3_errmsg (handle)); sqlite3_close(handle); return -1; } spatialite_init_ex (handle, cache, 0); ret = sqlite3_exec (handle, "SELECT InitSpatialMetadata(1, 'WGS84')", NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf(stderr, "Unexpected InitSpatialMetadata result: %i, (%s)\n", ret, err_msg); sqlite3_free (err_msg); return -2; } #ifdef ENABLE_LIBXML2 /* only if LIBXML2 is supported */ ret = sqlite3_get_table (handle, "SELECT CreateStylingTables(1)", &results, &rows, &columns, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "Error CreateStylingTables: %s\n", err_msg); sqlite3_free (err_msg); return -3; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -4; } if (strcmp(results[1 * columns + 0], "1") != 0) { fprintf (stderr, "Unexpected #0 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -5; } sqlite3_free_table(results); blob = load_blob("empty.png", &blob_len); if (blob == NULL) return -6; hexBlob = build_hex_blob(blob, blob_len); free(blob); if (hexBlob == NULL) return -7; sql = sqlite3_mprintf("SELECT RegisterExternalGraphic('url-A', x%Q)", hexBlob); ret = sqlite3_get_table (handle, sql, &results, &rows, &columns, &err_msg); sqlite3_free(sql); if (ret != SQLITE_OK) { fprintf (stderr, "Error RegisterExternalGraphic #1: %s\n", err_msg); sqlite3_free (err_msg); return -8; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -9; } if (strcmp(results[1 * columns + 0], "1") != 0) { fprintf (stderr, "Unexpected #1 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -10; } sqlite3_free_table(results); sql = sqlite3_mprintf("SELECT RegisterExternalGraphic('url-A', x%Q, 'title', 'abstract', 'file_name')", hexBlob); ret = sqlite3_get_table (handle, sql, &results, &rows, &columns, &err_msg); free(hexBlob); sqlite3_free(sql); if (ret != SQLITE_OK) { fprintf (stderr, "Error RegisterExternalGraphic #2: %s\n", err_msg); sqlite3_free (err_msg); return -11; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -12; } if (strcmp(results[1 * columns + 0], "1") != 0) { fprintf (stderr, "Unexpected #2 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -13; } sqlite3_free_table(results); xml = load_xml("thunderstorm_mild.svg", &len); if (xml == NULL) return -14; gaiaXmlToBlob (cache, xml, len, 1, NULL, &blob, &blob_len, NULL, NULL); free(xml); if (blob == NULL) { fprintf (stderr, "this is not a well-formed XML !!!\n"); return -15; } hexBlob = build_hex_blob(blob, blob_len); free(blob); if (hexBlob == NULL) return -16; sql = sqlite3_mprintf("SELECT RegisterExternalGraphic('url-B', x%Q, 'title', 'abstract', 'file_name')", hexBlob); ret = sqlite3_get_table (handle, sql, &results, &rows, &columns, &err_msg); sqlite3_free(sql); if (ret != SQLITE_OK) { fprintf (stderr, "Error RegisterExternalGraphic #3: %s\n", err_msg); sqlite3_free (err_msg); return -17; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -18; } if (strcmp(results[1 * columns + 0], "1") != 0) { fprintf (stderr, "Unexpected #3 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -19; } sqlite3_free_table(results); sql = sqlite3_mprintf("SELECT RegisterExternalGraphic('url-B', x%Q)", hexBlob); ret = sqlite3_get_table (handle, sql, &results, &rows, &columns, &err_msg); free(hexBlob); sqlite3_free(sql); if (ret != SQLITE_OK) { fprintf (stderr, "Error RegisterExternalGraphic #4: %s\n", err_msg); sqlite3_free (err_msg); return -20; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -21; } if (strcmp(results[1 * columns + 0], "1") != 0) { fprintf (stderr, "Unexpected #4 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -22; } sqlite3_free_table(results); ret = sqlite3_exec (handle, "CREATE TABLE table1 (id INTEGER PRIMARY KEY AUTOINCREMENT)", NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "Error Create Table table1: %s\n", err_msg); sqlite3_free (err_msg); return -23; } ret = sqlite3_get_table (handle, "SELECT AddGeometryColumn('table1', 'geom', 4326, 'POINT', 'XY')", &results, &rows, &columns, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "Error AddGeometryColumn: %s\n", err_msg); sqlite3_free (err_msg); return -24; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -25; } if (strcmp(results[1 * columns + 0], "1") != 0) { fprintf (stderr, "Unexpected #5 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -26; } sqlite3_free_table(results); xml = load_xml("stazioni_se.xml", &len); if (xml == NULL) return -27; gaiaXmlToBlob (cache, xml, len, 1, NULL, &blob, &blob_len, NULL, NULL); free(xml); if (blob == NULL) { fprintf (stderr, "this is not a well-formed XML !!!\n"); return -28; } hexBlob = build_hex_blob(blob, blob_len); free(blob); if (hexBlob == NULL) return -29; sql = sqlite3_mprintf("SELECT RegisterVectorStyledLayer('table1', 'geom', x%Q)", hexBlob); ret = sqlite3_get_table (handle, sql, &results, &rows, &columns, &err_msg); sqlite3_free(sql); if (ret != SQLITE_OK) { fprintf (stderr, "Error RegisterVectorStyledLayer #6: %s\n", err_msg); sqlite3_free (err_msg); return -30; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -31; } if (strcmp(results[1 * columns + 0], "1") != 0) { fprintf (stderr, "Unexpected #6 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -32; } sqlite3_free_table(results); sql = sqlite3_mprintf("SELECT RegisterVectorStyledLayer('table1', 'geom', 0, x%Q)", hexBlob); free(hexBlob); ret = sqlite3_get_table (handle, sql, &results, &rows, &columns, &err_msg); sqlite3_free(sql); if (ret != SQLITE_OK) { fprintf (stderr, "Error RegisterVectorStyledLayer #7: %s\n", err_msg); sqlite3_free (err_msg); return -33; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -34; } if (strcmp(results[1 * columns + 0], "1") != 0) { fprintf (stderr, "Unexpected #7 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -35; } sqlite3_free_table(results); xml = load_xml("raster_se.xml", &len); if (xml == NULL) return -36; gaiaXmlToBlob (cache, xml, len, 1, NULL, &blob, &blob_len, NULL, NULL); free(xml); if (blob == NULL) { fprintf (stderr, "this is not a well-formed XML !!!\n"); return -37; } hexBlob = build_hex_blob(blob, blob_len); free(blob); if (hexBlob == NULL) return -38; sql = sqlite3_mprintf("SELECT RegisterRasterStyledLayer('srtm', x%Q)", hexBlob); ret = sqlite3_get_table (handle, sql, &results, &rows, &columns, &err_msg); sqlite3_free(sql); if (ret != SQLITE_OK) { fprintf (stderr, "Error RegisterRasterStyledLayer #8: %s\n", err_msg); sqlite3_free (err_msg); return -39; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -40; } if (strcmp(results[1 * columns + 0], "1") != 0) { fprintf (stderr, "Unexpected #8 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -41; } sqlite3_free_table(results); sql = sqlite3_mprintf("SELECT RegisterRasterStyledLayer('srtm', 0, x%Q)", hexBlob); free(hexBlob); ret = sqlite3_get_table (handle, sql, &results, &rows, &columns, &err_msg); sqlite3_free(sql); if (ret != SQLITE_OK) { fprintf (stderr, "Error RegisterRasterStyledLayer #9: %s\n", err_msg); sqlite3_free (err_msg); return -42; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -43; } if (strcmp(results[1 * columns + 0], "1") != 0) { fprintf (stderr, "Unexpected #9 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -44; } sqlite3_free_table(results); ret = sqlite3_get_table (handle, "SELECT RegisterStyledGroup('group', 'srtm', 0)", &results, &rows, &columns, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "Error RegisterStyledGroup #10: %s\n", err_msg); sqlite3_free (err_msg); return -45; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -46; } if (strcmp(results[1 * columns + 0], "1") != 0) { fprintf (stderr, "Unexpected #10 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -47; } sqlite3_free_table(results); ret = sqlite3_get_table (handle, "SELECT RegisterStyledGroup('group', 'table1', 'geom', 0)", &results, &rows, &columns, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "Error RegisterStyledGroup #11: %s\n", err_msg); sqlite3_free (err_msg); return -48; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -49; } if (strcmp(results[1 * columns + 0], "1") != 0) { fprintf (stderr, "Unexpected #12 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -50; } sqlite3_free_table(results); ret = sqlite3_get_table (handle, "SELECT RegisterStyledGroup('group', 'srtm', 0, 4)", &results, &rows, &columns, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "Error RegisterStyledGroup #13: %s\n", err_msg); sqlite3_free (err_msg); return -51; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -52; } if (strcmp(results[1 * columns + 0], "0") != 0) { fprintf (stderr, "Unexpected #13 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -53; } sqlite3_free_table(results); ret = sqlite3_get_table (handle, "SELECT RegisterStyledGroup('group', 'table1', 'geom', 0, 1)", &results, &rows, &columns, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "Error RegisterStyledGroup #14: %s\n", err_msg); sqlite3_free (err_msg); return -54; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -55; } if (strcmp(results[1 * columns + 0], "1") != 0) { fprintf (stderr, "Unexpected #14 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -56; } sqlite3_free_table(results); ret = sqlite3_get_table (handle, "SELECT SetStyledGroupInfos('group', 'title', 'abstract')", &results, &rows, &columns, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "Error RegisterStyledGroup #15: %s\n", err_msg); sqlite3_free (err_msg); return -57; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -58; } if (strcmp(results[1 * columns + 0], "1") != 0) { fprintf (stderr, "Unexpected #15 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -59; } sqlite3_free_table(results); ret = sqlite3_get_table (handle, "SELECT SetStyledGroupInfos('group-bis', 'title', 'abstract')", &results, &rows, &columns, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "Error RegisterStyledGroup #16: %s\n", err_msg); sqlite3_free (err_msg); return 60; } if ((rows != 1) || (columns != 1)) { sqlite3_free_table(results); fprintf (stderr, "Unexpected row / column count: %i x %i\n", rows, columns); return -61; } if (strcmp(results[1 * columns + 0], "1") != 0) { fprintf (stderr, "Unexpected #16 result (got %s, expected 1)", results[1 * columns + 0]); sqlite3_free_table(results); return -62; } sqlite3_free_table(results); #endif ret = sqlite3_close (handle); if (ret != SQLITE_OK) { fprintf (stderr, "sqlite3_close() error: %s\n", sqlite3_errmsg (handle)); return -57; } spatialite_cleanup_ex (cache); #ifdef ENABLE_LIBXML2 /* only if LIBXML2 is supported */ xmlCleanupParser(); #endif return 0; }
int main(int argc, /* I - Number of command-line args */ char *argv[]) /* I - Command-line arguments */ { int i; /* Looping var */ const char *reg_file = NULL, /* Registration file/URL to use */ *reg_standard = NULL; /* Which standard to extract */ mxml_node_t *reg_xml, /* Registration XML data */ *reg_2, /* ipp-registrations-2 */ *reg_record, /* <record> */ *reg_collection, /* <collection> */ *reg_name, /* <name> */ *reg_member, /* <member_attribute> */ *reg_sub_member, /* <sub-member_attribute> */ *reg_syntax, /* <syntax> */ *reg_xref; /* <xref> */ cups_array_t *attrs; /* Attribute registrations */ _cups_reg_t *current; /* Current attribute registration */ ipp_tag_t group = IPP_TAG_ZERO, /* Which attributes to test */ reg_group; /* Group for registration */ /* * Parse command-line... */ for (i = 1; i < argc; i ++) { if (!strcmp(argv[i], "--job") && group == IPP_TAG_ZERO) group = IPP_TAG_JOB; else if (!strcmp(argv[i], "--ref")) { i ++; if (i >= argc) return (usage()); reg_standard = argv[i]; } else if (!strcmp(argv[i], "--printer") && group == IPP_TAG_ZERO) group = IPP_TAG_PRINTER; else if (argv[i][0] == '-' || reg_file) return (usage()); else reg_file = argv[i]; } if (group == IPP_TAG_ZERO) return (usage()); /* * Read registrations... */ if (!reg_file) reg_file = "http://www.iana.org/assignments/ipp-registrations/" "ipp-registrations.xml"; if ((reg_xml = load_xml(reg_file)) == NULL) return (1); /* * Scan registrations for attributes... */ if ((reg_2 = mxmlFindElement(reg_xml, reg_xml, "registry", "id", "ipp-registrations-2", MXML_DESCEND)) == NULL) { fprintf(stderr, "xmltotest: No IPP attribute registrations in \"%s\".\n", reg_file); return (1); } attrs = cupsArrayNew((cups_array_func_t)compare_reg, NULL); for (reg_record = mxmlFindElement(reg_2, reg_2, "record", NULL, NULL, MXML_DESCEND); reg_record; reg_record = mxmlFindElement(reg_record, reg_2, "record", NULL, NULL, MXML_NO_DESCEND)) { /* * Get the values from the current record... */ reg_collection = mxmlFindElement(reg_record, reg_record, "collection", NULL, NULL, MXML_DESCEND); reg_name = mxmlFindElement(reg_record, reg_record, "name", NULL, NULL, MXML_DESCEND); reg_member = mxmlFindElement(reg_record, reg_record, "member_attribute", NULL, NULL, MXML_DESCEND); reg_sub_member = mxmlFindElement(reg_record, reg_record, "sub-member_attribute", NULL, NULL, MXML_DESCEND); reg_syntax = mxmlFindElement(reg_record, reg_record, "syntax", NULL, NULL, MXML_DESCEND); reg_xref = mxmlFindElement(reg_record, reg_record, "xref", NULL, NULL, MXML_DESCEND); if (!reg_collection || !reg_name || !reg_syntax || !reg_xref) continue; /* * Filter based on group and standard... */ if (!strcmp(reg_collection->child->value.opaque, "Printer Description")) reg_group = IPP_TAG_PRINTER; else if (!strcmp(reg_collection->child->value.opaque, "Job Description")) reg_group = IPP_TAG_JOB; else if (!strcmp(reg_collection->child->value.opaque, "Job Template")) { if (strstr(reg_name->child->value.opaque, "-default") || strstr(reg_name->child->value.opaque, "-supported")) reg_group = IPP_TAG_PRINTER; else reg_group = IPP_TAG_JOB; } else reg_group = IPP_TAG_ZERO; if (reg_group != group) continue; if (reg_standard && !match_xref(reg_xref, reg_standard)) continue; /* * Add the record to the array... */ if ((current = new_reg(reg_name, reg_member, reg_sub_member, reg_syntax)) != NULL) cupsArrayAdd(attrs, current); } /* * Write out a test for all of the selected attributes... */ puts("{"); if (group == IPP_TAG_PRINTER) { puts("\tOPERATION Get-Printer-Attributes"); puts("\tGROUP operation-attributes-tag"); puts("\tATTR charset attributes-charset utf-8"); puts("\tATTR naturalLanguage attributes-natural-language en"); puts("\tATTR uri printer-uri $uri"); puts("\tATTR name requesting-user-name $user"); puts("\tATTR keyword requested-attributes all,media-col-database"); puts(""); puts("\tSTATUS successful-ok"); puts("\tSTATUS successful-ok-ignored-or-substituted-attributes"); puts(""); } else { puts("\tOPERATION Get-Job-Attributes"); puts("\tGROUP operation-attributes-tag"); puts("\tATTR charset attributes-charset utf-8"); puts("\tATTR naturalLanguage attributes-natural-language en"); puts("\tATTR uri printer-uri $uri"); puts("\tATTR integer job-id $job-id"); puts("\tATTR name requesting-user-name $user"); puts(""); puts("\tSTATUS successful-ok"); puts(""); } for (current = cupsArrayFirst(attrs); current; current = cupsArrayNext(attrs)) write_expect(current, group); puts("}"); return (0); }
void main_window::on_load_mission() { auto filename = QFileDialog::getOpenFileName(this, "Load mission", "missions", "*.zip"); if (!filename.length()) return; std::string filename_str = to_str(filename); auto prov = &nya_resources::get_resources_provider(); nya_resources::file_resources_provider fprov; nya_resources::set_resources_provider(&fprov); nya_resources::zip_resources_provider zprov; bool result = zprov.open_archive(filename_str.c_str()); nya_resources::set_resources_provider(prov); if (!result) { alert("Unable to load location " + filename_str); return; } m_filename.assign(filename_str); pugi::xml_document doc; if (!load_xml(zprov.access("objects.xml"), doc)) return; auto root = doc.first_child(); std::string loc = root.attribute("location").as_string(); if (loc.empty()) return; clear_mission(); m_location = loc; m_scene_view->load_location(loc); auto p = root.child("player"); scene_view::object plr; plr.attributes["align"] = "ally"; plr.yaw = p.attribute("yaw").as_float(); plr.pos = read_vec3(p); plr.y = p.attribute("editor_y").as_float(); plr.pos.y -= plr.y; auto at = p.child("attribute"); for (auto a = at.attributes_begin(); a != at.attributes_end(); ++a) plr.attributes[a->name()] = a->value(); m_scene_view->set_player(plr); for (auto o = root.child("object"); o; o = o.next_sibling("object")) { scene_view::object obj; obj.name = o.attribute("name").as_string(); obj.id = o.attribute("id").as_string(); obj.active = o.attribute("active").as_bool(); obj.yaw = o.attribute("yaw").as_float(); obj.pos = read_vec3(o); obj.y = o.attribute("editor_y").as_float(); obj.pos.y -= obj.y; auto at = o.child("attribute"); for (auto a = at.attributes_begin(); a != at.attributes_end(); ++a) obj.attributes[a->name()] = a->value(); m_scene_view->add_object(obj); } for (auto z = root.child("zone"); z; z = z.next_sibling("zone")) { scene_view::zone zn; zn.name = z.attribute("name").as_string(); zn.active = z.attribute("active").as_bool(); zn.radius = z.attribute("radius").as_float(); zn.pos = read_vec3(z); auto at = z.child("attribute"); for (auto a = at.attributes_begin(); a != at.attributes_end(); ++a) zn.attributes[a->name()] = a->value(); m_scene_view->add_zone(zn); } for (auto p = root.child("path"); p; p = p.next_sibling("path")) { scene_view::path pth; pth.name = p.attribute("name").as_string(); for (auto p0 = p.child("point"); p0; p0 = p0.next_sibling("point")) { nya_math::vec4 p; p.xyz() = read_vec3(p0); p.w = p0.attribute("editor_y").as_float(); p.y -= p.w; pth.points.push_back(p); } m_scene_view->get_paths().push_back(pth); } auto script_res = zprov.access("script.lua"); if (script_res) { std::string script; script.resize(script_res->get_size()); if (!script.empty()) script_res->read_all(&script[0]); m_script_edit->setText(script.c_str()); script_res->release(); } if (load_xml(zprov.access("info.xml"), doc)) { auto root = doc.first_child(); m_mission_title->setText(root.attribute("name").as_string()); m_mission_description->setText(root.child("description").first_child().value()); auto author = root.child("author"); m_mission_author->setText(author.attribute("name").as_string()); m_mission_email->setText(author.attribute("email").as_string()); } update_objects_tree(); m_navigator->setCurrentIndex(mode_info); m_scene_view->set_focus("player spawn", 0); }
static void test_xml_parser(void) { GError *error = NULL; ZCloudStorePlugin *pl; load_xml("<zcloud-module basename=\"disk\">" "<store-plugin prefix=\"disk\"></store-plugin>" "</zcloud-module>", &error); gerror_is_clear(&error, "XML: single plugin in a simple module"); ok(NULL != zcloud_get_store_plugin_by_prefix("disk"), "plugin found"); load_xml("<zcloud-module foo=\"bar\" basename=\"myext\">" "<store-plugin prefix=\"myext\"></store-plugin>" "</zcloud-module>", &error); gerror_is_set(&error, "*'zcloud-module' attribute 'foo' not recognized", G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, "bogus zcloud-module attribute"); load_xml("<zcloud-module basename=\"myext\">" "<store-plugin foo=\"bar\" prefix=\"myext\"></store-plugin>" "</zcloud-module>", &error); gerror_is_set(&error, "*'store-plugin' attribute 'foo' not recognized", G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, "bogus store-plugin attribute"); load_xml("<zcloud-module>" "<store-plugin prefix=\"myext\"></store-plugin>" "</zcloud-module>", &error); gerror_is_set(&error, "*'zcloud-module' attribute 'basename' is required", G_MARKUP_ERROR_INVALID_CONTENT, "missing basename attribute"); load_xml("<zcloud-module basename=\"foo\">" "<store-plugin></store-plugin>" "</zcloud-module>", &error); gerror_is_set(&error, "*'store-plugin' attribute 'prefix' is required", G_MARKUP_ERROR_INVALID_CONTENT, "missing prefix attribute"); load_xml("<zcloud-module basename=\"myext\">" "random text" "</zcloud-module>", &error); gerror_is_set(&error, "*unexpected text", G_MARKUP_ERROR_INVALID_CONTENT, "unexpected text"); load_xml("<zcloud-module basename=\"myext\">" "<blink>hi mom</blink>" "</zcloud-module>", &error); gerror_is_set(&error, "*element 'blink' not recognized", G_MARKUP_ERROR_UNKNOWN_ELEMENT, "bogus element"); load_xml("<store-plugin></store-plugin>", &error); gerror_is_set(&error, "*element 'store-plugin' must appear in a 'zcloud-module' element", G_MARKUP_ERROR_INVALID_CONTENT, "store-plugin with no module"); load_xml("<zcloud-module basename=\"myext\">" "<zcloud-module>", &error); gerror_is_set(&error, "*element 'zcloud-module' cannot be nested", G_MARKUP_ERROR_INVALID_CONTENT, "nested zcloud-module"); load_xml("<zcloud-module basename=\"myext\">" "<store-plugin prefix=\"myext\">" "<store-plugin prefix=\"myext\">", &error); gerror_is_set(&error, "*element 'store-plugin' cannot be nested", G_MARKUP_ERROR_INVALID_CONTENT, "nested store-plugin"); load_xml("<zcloud-module basename=\"myext\">" "<store-plugin prefix=\"myext\">" "<store-plugin prefix=\"myext\">", &error); gerror_is_set(&error, "*element 'store-plugin' cannot be nested", G_MARKUP_ERROR_INVALID_CONTENT, "nested store-plugin"); load_xml("<parameter name=\"foo\" type=\"string\" blurb=\"bar\" />", &error); gerror_is_set(&error, "*element 'parameter' must appear in a 'store-plugin' element", G_MARKUP_ERROR_INVALID_CONTENT, "property with no module"); load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">" "<parameter type=\"string\" blurb=\"bar\" />", &error); gerror_is_set(&error, "*'parameter' attribute 'name' is required", G_MARKUP_ERROR_INVALID_CONTENT, "missing name attribute"); load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">" "<parameter name=\"foo\" blurb=\"bar\" />", &error); gerror_is_set(&error, "*'parameter' attribute 'type' is required", G_MARKUP_ERROR_INVALID_CONTENT, "missing type attribute"); load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">" "<parameter name=\"foo\" type=\"string\" />", &error); gerror_is_set(&error, "*'parameter' attribute 'blurb' is required", G_MARKUP_ERROR_INVALID_CONTENT, "missing blurb attribute"); load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">" "<parameter name=\"foo\" hype=\"string\" />", &error); gerror_is_set(&error, "*'parameter' attribute 'hype' not recognized", G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, "bad property attribute"); load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">" "<parameter name=\"foo\" type=\"rectangle\" blurb=\"bar\"/>", &error); gerror_is_set(&error, "*invalid parameter type 'rectangle'", G_MARKUP_ERROR_INVALID_CONTENT, "bad parameter type"); load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">" "<parameter name=\"1foo\" type=\"string\" blurb=\"bar\"/>", &error); gerror_is_set(&error, "*invalid parameter name '1foo'", G_MARKUP_ERROR_INVALID_CONTENT, "bad parameter name (starts with number)"); load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">" "<parameter name=\"f_o_o\" type=\"string\" blurb=\"bar\"/>", &error); gerror_is_set(&error, "*invalid parameter name 'f_o_o'", G_MARKUP_ERROR_INVALID_CONTENT, "bad parameter name (non-alphanumeric)"); load_xml("<zcloud-module basename=\"mod\">" "<store-plugin prefix=\"withprop\">" " <parameter name=\"ver-bose\" type=\"string\" blurb=\"lots to say\" />" "</store-plugin>" "</zcloud-module>", &error); gerror_is_clear(&error, "no error loading a plugin with a property with dashes in its name"); load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">" "<parameter name=\"foo\" type=\"sTrInG\" blurb=\"bar\">" "<foo>" "</parameter>", &error); gerror_is_set(&error, "*'parameter' element must be empty", G_MARKUP_ERROR_INVALID_CONTENT, "non-empty property"); load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">" "<parameter name=\"foo\" type=\"string\" blurb=\"bar\" />" "<parameter name=\"foo\" type=\"string\" blurb=\"bar\" />", &error); gerror_is_set(&error, "*duplicate parameter name 'foo'", G_MARKUP_ERROR_INVALID_CONTENT, "duplicate property"); load_xml("<zcloud-module basename=\"myext\">" "<store-plugin prefix=\"myext1\"></store-plugin>" "<store-plugin prefix=\"myext2\"></store-plugin>" "</zcloud-module>", &error); gerror_is_clear(&error, "no error loading a module with two store plugins"); ok(NULL != zcloud_get_store_plugin_by_prefix("myext1"), "one of two plugins exists"); ok(NULL != zcloud_get_store_plugin_by_prefix("myext2"), ".. as does the other"); load_xml("<zcloud-module basename=\"myext\">" "<store-plugin prefix=\"dupe\"></store-plugin>" "<store-plugin prefix=\"dupe\"></store-plugin>" "</zcloud-module>", &error); gerror_is_set(&error, "*store plugin prefix 'dupe' is already defined", G_MARKUP_ERROR_INVALID_CONTENT, "duplicate prefixes generate an error"); load_xml("<zcloud-module basename=\"myext1\">" "<store-plugin prefix=\"one\"></store-plugin>" "</zcloud-module><zcloud-module basename=\"myext2\">" "<store-plugin prefix=\"two\"></store-plugin>" "</zcloud-module>", &error); gerror_is_clear(&error, "no error loading two modules"); pl = zcloud_get_store_plugin_by_prefix("one"); ok(pl != NULL, "prefix one exists"); ok(0 == strcmp(pl->module->basename, "myext1"), "..and has the right module name"); pl = zcloud_get_store_plugin_by_prefix("two"); ok(pl != NULL, "prefix two exists"); ok(0 == strcmp(pl->module->basename, "myext2"), "..and has the right module name"); load_xml("<zcloud-module basename=\"mod\">" "<store-plugin prefix=\"withprop\">" " <parameter name=\"verbose\" type=\"string\" blurb=\"talkative; wordy\" />" "</store-plugin>" "</zcloud-module>", &error); gerror_is_clear(&error, "no error loading a plugin with a property without a nick"); pl = zcloud_get_store_plugin_by_prefix("withprop"); is_string(get_paramspec(pl, 0)->name, "verbose", "..name is set correctly"); is_string(g_param_spec_get_blurb(get_paramspec(pl, 0)), "talkative; wordy", "..blurb is set correctly"); is_int(get_paramspec(pl, 0)->value_type, G_TYPE_STRING, "..type is set correctly"); is_string(g_param_spec_get_nick(get_paramspec(pl, 0)), "verbose", "..and the nick defaults correctly"); load_xml("<zcloud-module basename=\"mod\">" "<store-plugin prefix=\"withprop\">" " <parameter name=\"verbose\" type=\"string\" nick=\"loud\" blurb=\"talkative; wordy\" />" "</store-plugin>" "</zcloud-module>", &error); gerror_is_clear(&error, "no error loading a plugin with a property with a nick"); pl = zcloud_get_store_plugin_by_prefix("withprop"); is_string(g_param_spec_get_nick(get_paramspec(pl, 0)), "loud", "..and the nick defaults correctly"); load_xml("<zcloud-module basename=\"foo\">" "<store-plugin prefix=\"one\"></store-plugin>" "</zcloud-module><zcloud-module basename=\"foo\">" "<store-plugin prefix=\"another\"></store-plugin>" "</zcloud-module>", &error); gerror_is_set(&error, "*zcloud-module with basename 'foo' is already defined", G_MARKUP_ERROR_INVALID_CONTENT, "two extensions with the same basename generate an error"); load_xml("<zcloud-module basename=\"myext\">" "<store-plugin prefix=\"one\"></store-plugin>" "<store-plugin prefix=\"two\"></store-plugin>" "</zcloud-module>", &error); gerror_is_clear(&error, "no error loading two plugins"); { GSList *iter, *all; gboolean seen_one = FALSE, seen_two = FALSE; /* evaluate all of the fields in the structs to make sure they're set * correctly */ all = zcloud_get_all_store_plugins(); for (iter = all; iter; iter = iter->next) { pl = (ZCloudStorePlugin *)iter->data; if (0 == strcmp(pl->prefix, "one")) seen_one = TRUE; if (0 == strcmp(pl->prefix, "two")) seen_two = TRUE; is_string(pl->module->basename, "myext", "module basename is correct"); is_string(pl->module->xml_path, "(string)", "module xml_path is correct"); ok(pl->module->module_path != NULL, "module module_path is non-NULL"); } ok(g_slist_length(all) == 2 && seen_one && seen_two, "saw the correct two plugins"); } }