bool get_game_data(const char *input_fname, const char *output_fname, bool from_update) { FILE *outfile = NULL; if((outfile = (output_fname ? fopen(output_fname, "w") : stdout)) == NULL){ ltr_int_log_message("Can't open the output file '%s'!\n", output_fname); return false; } if(!game_data_init(input_fname, from_update)){ ltr_int_log_message("Can't process the data file '%s'!\n", input_fname); return false; } mxml_node_t *game; const char *name; const char *id; for(game = mxmlFindElement(tree, tree, "Game", NULL, NULL, MXML_DESCEND); game != NULL; game = mxmlFindElement(game, tree, "Game", NULL, NULL, MXML_DESCEND)){ name = mxmlElementGetAttr(game, "Name"); id = mxmlElementGetAttr(game, "Id"); mxml_node_t *appid = mxmlFindElement(game, game, "ApplicationID", NULL, NULL, MXML_DESCEND); if(appid == NULL){ fprintf(outfile, "%s \"%s\"\n", id, name); }else{ fprintf(outfile, "%s \"%s\" (%s)\n", id, name, appid->child->value.text.string); } } fclose(outfile); game_data_close(); return true; }
/** * Loads an area from an XML node. * @param node The <area> node. * @param area The Area. */ void FileProcessor::loadArea_Area(mxml_node_t* area_node, Area* area) { loadArea_Tag(area_node, area); const char* sWidth = mxmlElementGetAttr(area_node, "width"); const char* sHeight = mxmlElementGetAttr(area_node, "height"); area->setSize(atoi(sWidth), atoi(sHeight)); mxml_node_t* node; for(node = area_node->child; node; node = node->next) { if(node->type == MXML_ELEMENT) { Object* object = NULL; if(strcasecmp(node->value.element.name, "object") == 0) { object = new Object(); loadArea_Object(node, object); } else if(strcasecmp(node->value.element.name, "rigidbody") == 0) { RigidBody* rigidbody = new RigidBody(); loadArea_RigidBody(node, rigidbody); object = rigidbody; } else if(strcasecmp(node->value.element.name, "creature") == 0) { Creature* creature = new Creature(); loadArea_RigidBody(node, creature); object = creature; } else if(strcasecmp(node->value.element.name, "tiles") == 0) { loadArea_Tiles(node, area); } if(object) { area->addObject(object); //GameManager* gm = area->getGameManager(); //gm->registerObject(object); } } } }
void FileProcessor::loadArea_Tiles(mxml_node_t* tiles_node, Area* area) { mxml_node_t* node; for(node = tiles_node->child; node; node = node->next) { if(node->type == MXML_ELEMENT) { if(strcasecmp(node->value.element.name, "tile") == 0) { const char* sX = mxmlElementGetAttr(node, "x"); const char* sY = mxmlElementGetAttr(node, "y"); const char* sSolid = mxmlElementGetAttr(node, "solid"); const char* sFilename = mxmlElementGetAttr(node, "filename"); const char* sRotation = mxmlElementGetAttr(node, "rotation"); int x = atoi(sX); int y = atoi(sY); float rotation = atof(sRotation); Tile* tile = new Tile(sFilename); tile->setRotation(rotation); area->setTile(x, y, tile); if(!strcasecmp(sSolid, "true")) { area->setSolid(x, y, true); } else { area->setSolid(x, y, false); } } } } }
void FSDriver::readEvents(mxml_node_t *const xml) { mxml_node_t *node = xml; while (true) { node = mxmlFindElement(node, xml, "event", NULL, NULL, MXML_DESCEND); if (node == NULL) { break; } const char *counter = mxmlElementGetAttr(node, "counter"); if (counter == NULL) { continue; } if (counter[0] == '/') { logg->logError(__FILE__, __LINE__, "Old style filesystem counter (%s) detected, please create a new unique counter value and move the filename into the path attribute, see events-Filesystem.xml for examples", counter); handleException(); } if (strncmp(counter, "filesystem_", 11) != 0) { continue; } const char *path = mxmlElementGetAttr(node, "path"); if (path == NULL) { logg->logError(__FILE__, __LINE__, "The filesystem counter %s is missing the required path attribute", counter); handleException(); } const char *regex = mxmlElementGetAttr(node, "regex"); setCounters(new FSCounter(getCounters(), strdup(counter), strdup(path), regex)); } }
/** * Checks if the Device is already in the XML file * * @param device the device that we want to check * * @return returns HPD_YES if the device is in the XML file and HPD_NO if it is not */ int device_is_in_xml_file(Device *device) { mxml_node_t *xml_device; for (xml_device = mxmlFindElement(service_xml_file->xml_tree, service_xml_file->xml_tree, "device", NULL, NULL, MXML_DESCEND); xml_device != NULL; xml_device = mxmlFindElement( xml_device, service_xml_file->xml_tree, "device", NULL, NULL, MXML_DESCEND)) { if(strcmp(mxmlElementGetAttr(xml_device,"type") , device->type) == 0 && strcmp(mxmlElementGetAttr(xml_device,"id") , device->ID) == 0) { return HPD_YES; } } return HPD_NO; }
BOOL main_parse_motd(CHAR *motd) { mxml_node_t *tree, *node; INT day, month, year; CHAR *text = NULL; if (motd == NULL) return RES_FAIL; tree = mxmlLoadString(NULL, motd, MXML_OPAQUE_CALLBACK); if (tree == NULL) { dialog_set_status("main_parse_motd: mxmlLoadString() выполнена с ошибкой"); return RES_FAIL; } for (node = mxmlFindElement(tree, tree, "entry", NULL, NULL, MXML_DESCEND); node != NULL; node = mxmlFindElement(node, tree, "entry", NULL, NULL, MXML_DESCEND)) { day = atoi((CHAR *)mxmlElementGetAttr(node, "day")); month = atoi((CHAR *)mxmlElementGetAttr(node, "month")); year = atoi((CHAR *)mxmlElementGetAttr(node, "year")); text = node->child->value.opaque; } if (text != NULL) dialog_set_motd(text, day, month, year); return RES_OK; }
/** * Reads a float array, such as verticies, normals, text cords, etc... * @param tempory The ModelTempory struct to hold the array. * @param mesh The mesh using the floats * @param xnode The XML node containing the data. * @return */ FloatArray* RCBC_MiniXML_ProcessGeometries_Mesh_FloatArray(ModelTempory *tempory, Mesh *mesh, mxml_node_t *xnode) { DEBUG_M("Entering function..."); const char* id = mxmlElementGetAttr(xnode, "id"); const char* count_s = mxmlElementGetAttr(xnode, "count"); int count = atoi(count_s); FloatArray* newarray = NEW(FloatArray, count); if(!newarray) { return NULL; } GLfloat f = 0.0f; int i = 0; char* pch = strtok(xnode->child->value.opaque, " "); while(pch && i < count) { sscanf(pch, "%f", &f); newarray->values[i] = f; pch = strtok(NULL, " "); i++; } ListAdd(tempory->deleteme, newarray); DEBUG_M("exiting function"); return newarray; }
static int /* O - Result of comparison */ index_compare(mxml_index_t* ind, /* I - Index */ mxml_node_t* first, /* I - First node */ mxml_node_t* second) { /* I - Second node */ int diff; /* Difference */ /* * Check the element name... */ if ((diff = strcmp(first->value.element.name, second->value.element.name)) != 0) { return (diff); } /* * Check the attribute value... */ if (ind->attr) { if ((diff = strcmp(mxmlElementGetAttr(first, ind->attr), mxmlElementGetAttr(second, ind->attr))) != 0) { return (diff); } } /* * No difference, return 0... */ return (0); }
int XMLwrapper::loadXMLfile(const char *filename){ if (tree!=NULL) mxmlDelete(tree); tree=NULL; ZERO(&parentstack,(int)sizeof(parentstack)); ZERO(&values,(int)sizeof(values)); stackpos=0; char *xmldata=doloadfile(filename); if (xmldata==NULL) return(-1);//the file could not be loaded or uncompressed printf("%s\n",xmldata); root=tree=mxmlLoadString(NULL,xmldata,MXML_OPAQUE_CALLBACK); delete []xmldata; if (tree==NULL) return(-2);//this is not XML node=root=mxmlFindElement(tree,tree,"paulstretch-data",NULL,NULL,MXML_DESCEND); if (root==NULL) return(-3);//the XML doesnt embbed required data push(root); values.xml_version.major=str2int(mxmlElementGetAttr(root,"version-major")); values.xml_version.minor=str2int(mxmlElementGetAttr(root,"version-minor")); return(0); };
void GetPublisherFromGameid(char *idtxt, char *dest, int destsize) { /* guess publisher from company list using last two characters from game id */ nodeindextmp = mxmlIndexNew(nodedata,"company", NULL); nodeidtmp = mxmlIndexReset(nodeindextmp); *element_text=0; char publishercode[3]; sprintf(publishercode,"%c%c", idtxt[4],idtxt[5]); while (strcmp(element_text,publishercode) != 0) { nodeidtmp = mxmlIndexFind(nodeindextmp,"company", NULL); if (nodeidtmp != NULL) { strlcpy(element_text,mxmlElementGetAttr(nodeidtmp, "code"),sizeof(element_text)); } else { break; } } if (!strcmp(element_text,publishercode)) { strlcpy(dest,mxmlElementGetAttr(nodeidtmp, "name"),destsize); } else { strcpy(dest,""); } // free memory mxmlIndexDelete(nodeindextmp); }
/** * Checks if the Service is already in the XML file * * @param service the service that we want to check * * @return returns HPD_NO if the device is not in the XML file and HPD_YES if it is */ int service_is_in_xml_file(Service *service) { if( device_is_in_xml_file(service->device) == HPD_NO ) return HPD_NO; mxml_node_t *device = get_xml_node_of_device(service->device); if(device == NULL) { printf("Error while retrieving device node\n"); return HPD_E_IMPOSSIBLE_TO_RETRIEVE_DEVICE_XML_NODE; } mxml_node_t *xml_service; for (device = mxmlFindElement(service_xml_file->xml_tree, service_xml_file->xml_tree, "device", NULL, NULL, MXML_DESCEND); device != NULL; device = mxmlFindElement( device, service_xml_file->xml_tree, "device", NULL, NULL, MXML_DESCEND)) { if(strcmp(mxmlElementGetAttr(device,"type") , service->device->type) == 0 && strcmp(mxmlElementGetAttr(device,"id") , service->device->ID) == 0) { for (xml_service = mxmlFindElement( device, device, "service", NULL, NULL, MXML_DESCEND); xml_service != NULL; xml_service = mxmlFindElement( xml_service, device, "service", NULL, NULL, MXML_DESCEND)) { if(strcmp(mxmlElementGetAttr(xml_service,"type") , service->type) == 0 && strcmp(mxmlElementGetAttr(xml_service,"id") , service->ID) == 0) { return HPD_YES; } } } } return HPD_NO; }
/** * Loads scripts into an Object. * @param node The <script> node. * @param object The Object. */ void FileProcessor::loadArea_Script(mxml_node_t* node, Object* object) { const char* stype = mxmlElementGetAttr(node, "type"); const char* filename = mxmlElementGetAttr(node, "filename"); int script_type = SCRIPT_ONUPDATE; if(strcasecmp(stype, "onupdate") == 0) { object->setScript(script_type, filename); } }
/** * 为重新进行索引内部数据的整理, 解析配置文件, 初始化 index_lib 内部的builder * * @param config xml的配置节点。 内部的子节点包括了 索引的各个配置项 * 样例: * <indexLib> * <index path="/dir" /> * </indexLib> * * @return 0: success ; -1: 程序处理失败 */ int init_rebuild( mxml_node_t * config ) { mxml_node_t * modulesNode = NULL; mxml_node_t * indexLibNode = NULL; // index_lib的根节点 mxml_node_t * profileNode = NULL; // profile配置节点 mxml_node_t * indexNode = NULL; // index配置节点 mxml_node_t * idDictNode = NULL; // nid->docId 字典及deletemap节点 modulesNode = mxmlFindElement(config, config, "modules", NULL, NULL, MXML_DESCEND); if ( modulesNode == NULL || modulesNode->parent != config ) { TERR("can't find modules's node"); return -1; } indexLibNode = mxmlFindElement(modulesNode, modulesNode, "indexLib", NULL, NULL, MXML_DESCEND); // 检查节点有效性 if ( indexLibNode == NULL || indexLibNode->parent != modulesNode ) { TERR("can't find indexLib's node"); return -1; } // 获取配置节点 profileNode = mxmlFindElement(indexLibNode, indexLibNode, "profile", NULL, NULL, MXML_DESCEND); indexNode = mxmlFindElement(indexLibNode, indexLibNode, "index", NULL, NULL, MXML_DESCEND); idDictNode = mxmlFindElement(indexLibNode, indexLibNode, "idDict", NULL, NULL, MXML_DESCEND); // 检查节点有效性 if ( profileNode == NULL || profileNode->parent != indexLibNode ) { TERR("can't find indexLib's child node profile"); return -1; } if ( indexNode == NULL || indexNode->parent != indexLibNode ) { TERR("can't find indexLib's child node index"); return -1; } if ( idDictNode == NULL || idDictNode->parent != indexLibNode ) { TERR("can't find indexLib's child node idDict"); return -1; } // 开始 初始化 各个模块 if ( initProfile( mxmlElementGetAttr(profileNode, "path" ), false, true ) ) return -1; if ( initIdDict ( mxmlElementGetAttr(idDictNode, "path" ), false) ) return -1; if ( initFullIndex( mxmlElementGetAttr(indexNode, "path" ) ) ) return -1; if ( initIdxBuilder( mxmlElementGetAttr(indexNode, "path" ) ) ) return -1; return 0; }
/** * Loads the rotation on an Object from XML node. * @param node The <rotation> node. * @param object The Object. */ void FileProcessor::loadArea_Rotation(mxml_node_t* node, Object* object) { const char* sRX = mxmlElementGetAttr(node, "rx"); const char* sRY = mxmlElementGetAttr(node, "ry"); const char* sRZ = mxmlElementGetAttr(node, "rz"); const char* sAngle = mxmlElementGetAttr(node, "angle"); object->setRotX(atof(sRX)); object->setRotY(atof(sRY)); object->setRotZ(atof(sRZ)); object->setRotAngle(atof(sAngle)); }
/** * Loads model information into a Model. * @param model_node The <mode> node. * @param model The VModel */ void FileProcessor::loadArea_Model(mxml_node_t* model_node, VModel* model) { const char* filename = mxmlElementGetAttr(model_node, "filename"); model->setFilename(filename); const char* vstr = mxmlElementGetAttr(model_node, "visible"); if(strcasecmp(vstr, "false") == 0) { model->setVisible(false); } else { model->setVisible(true); } }
int update_service_xml( Service *service ) { mxml_node_t *xml_service; mxml_node_t *xml_device; for (xml_device = mxmlFindElement(service_xml_file->xml_tree, service_xml_file->xml_tree, "device", NULL, NULL, MXML_DESCEND); xml_device != NULL; xml_device = mxmlFindElement( xml_device, service_xml_file->xml_tree, "device", NULL, NULL, MXML_DESCEND)) { if(strcmp(mxmlElementGetAttr(xml_device,"type") , service->device->type) == 0 && strcmp(mxmlElementGetAttr(xml_device,"id") , service->device->ID) == 0) { for (xml_service = mxmlFindElement(xml_device, xml_device, "service", NULL, NULL, MXML_DESCEND); xml_service != NULL; xml_service = mxmlFindElement(xml_service, xml_device, "service", NULL, NULL, MXML_DESCEND)) { if(strcmp(mxmlElementGetAttr(xml_service,"type") , service->type) == 0 && strcmp(mxmlElementGetAttr(xml_service,"id") , service->ID) == 0) { if(service->description != NULL) mxmlElementSetAttr(xml_service, "desc", service->description); if(service->unit != NULL) mxmlElementSetAttr(xml_service, "unit", service->unit); save_xml_tree(); return HPD_YES; } } } } return HPD_NO; }
/** * @brief retrieve a Short attribute from an XML Node * @param[in] parent XML Node structure to get from * @param[in] name Name of the attribute * @param[in] defaultval Default value to return if no such attribute defined */ short XML_GetShort (xmlNode_t* parent, const char* name, const short defaultval) { const char* txt = mxmlElementGetAttr(parent, name); if (!txt) return defaultval; return atoi(txt); }
static int /* O - Result of comparison */ index_find(mxml_index_t* ind, /* I - Index */ const char* element, /* I - Element name or NULL */ const char* value, /* I - Attribute value or NULL */ mxml_node_t* node) { /* I - Node */ int diff; /* Difference */ /* * Check the element name... */ if (element) { if ((diff = strcmp(element, node->value.element.name)) != 0) { return (diff); } } /* * Check the attribute value... */ if (value) { if ((diff = strcmp(value, mxmlElementGetAttr(node, ind->attr))) != 0) { return (diff); } } /* * No difference, return 0... */ return (0); }
/** * @brief retrieve a Long attribute from an XML Node * @param[in] parent XML Node structure to get from * @param[in] name Name of the attribute * @param[in] defaultval Default value to return if no such attribute defined */ long XML_GetLong (xmlNode_t* parent, const char* name, const long defaultval) { const char* txt = mxmlElementGetAttr(parent, name); if (!txt) return defaultval; return atol(txt); }
/** * @brief retrieve a String attribute from an XML Node * @param[in] parent XML Node structure to get from * @param[in] name Name of the attribute * @return empty string if no such attribute defined */ const char* XML_GetString (xmlNode_t* parent, const char* name) { const char* str = mxmlElementGetAttr(parent, name); if (!str) return ""; return str; }
int PLCvalidation_precompileST(mxml_node_t *pou, mxml_node_t *ST) { ST = mxmlWalkNext (ST, NULL, MXML_DESCEND); if (ST->type != MXML_ELEMENT) { RTL_TRDBG (TRACE_ST, "precompile ST code : not an MXML_ELEMENT (%d)\n", ST->type); return 0; } char *STcode = ST->value.element.name; if (!memcmp(STcode, "![CDATA[", 8)) STcode += 8; while (STcode[strlen(STcode)-1] == ']') STcode[strlen(STcode)-1] = 0; RTL_TRDBG (TRACE_ST, "precompile ST code : (%s)\n", STcode); if (compileST (STcode) != 0) { char *name = (char *)mxmlElementGetAttr(pou, "name"); sprintf (_lastError, "pou '%s' compilation failed '%20.20s'", name, STcode); return -1; } mxmlElementSetAttrf (ST, "tree", "%ld", programBlock); RTL_TRDBG (TRACE_ST, "ST code precompiled at %p\n", programBlock); return 0; }
/** * @brief retrieve a Float attribute from an XML Node * @param[in] parent XML Node structure to get from * @param[in] name Name of the attribute * @param[in] defaultval Default value to return if no such attribute defined */ float XML_GetFloat (xmlNode_t* parent, const char* name, const float defaultval) { const char* txt = mxmlElementGetAttr(parent, name); if (!txt) return defaultval; return atof(txt); }
void XmlNode::ReadArray( std::vector<std::vector<std::string> >& result, std::vector<std::string>& keys, const char * name ) { result.clear(); if(_data == NULL || keys.size() == 0) return; mxml_node_t * node = (mxml_node_t *)_data; if(node == NULL) return; mxml_node_t * child = mxmlFindElement(node, node, name, NULL, NULL, MXML_DESCEND_FIRST); size_t c = keys.size(); while(child != NULL) { std::vector<std::string> item; item.resize(c); for(size_t i = 0; i < c; ++ i) { const char * str = mxmlElementGetAttr(child, keys[i].c_str()); if(str == NULL) continue; item[i] = str; } result.push_back(item); child = mxmlFindElement(child, node, name, NULL, NULL, MXML_NO_DESCEND); } }
/** * @brief retrieve a Double attribute from an XML Node * @param[in] parent XML Node structure to get from * @param[in] name Name of the attribute * @param[in] defaultval Default value to return if no such attribute defined */ double XML_GetDouble (xmlNode_t* parent, const char* name, const double defaultval) { const char* txt = mxmlElementGetAttr(parent, name); if (!txt) return defaultval; return atof(txt); }
void sax_cb(mxml_node_t *node, mxml_sax_event_t event, void *data) { const char *node_name = mxmlGetElement(node); if (event == MXML_SAX_DATA) { if (! strcmp(current_tag[tag_ptr], "DistanceMeters")) { if (! strcmp(current_tag[tag_ptr-1], "Lap")) { const char *x = mxmlGetText(node, NULL); lap_distances[lap_count] = atof(x); lap_count++; } } } if (event == MXML_SAX_ELEMENT_OPEN) { tag_ptr++; strcpy(current_tag[tag_ptr], node_name); if(! strcmp(node_name, "Activity")) { const char *t = mxmlElementGetAttr(node, "Sport"); strcpy(sport, t); } } if (event == MXML_SAX_ELEMENT_CLOSE) { tag_ptr--; } }
/* Process the <library_effects> section of COLLADA */ void RCBC_MiniXML_ProcessTextureEffects(ModelTempory *tempory, mxml_node_t *node) { DEBUG_M("Entering function..."); const char* id; mxml_node_t* child; assert(tempory); if(!node) { return; } /* Loop through all the effect nodes */ for(node = node->child; node != NULL; node = node->next) { if(node->type == MXML_ELEMENT && strcasecmp(node->value.element.name, "effect") == 0) { id = mxmlElementGetAttr(node, "id"); for(child = node->child; child != NULL; child = child->next) { if(child->type == MXML_ELEMENT && strcasecmp(child->value.element.name, "profile_COMMON") == 0) { Hookup* fx_hookup = NEW(Hookup, (char*)id, NULL); ListAdd(tempory->sources, fx_hookup); RCBC_MiniXML_ProcessTextureEffects_Profile(tempory, child, fx_hookup); } } } } }
void StreamlineSetup::handleRequest(char* xml) { mxml_node_t *tree, *node; const char * attr = NULL; tree = mxmlLoadString(NULL, xml, MXML_NO_CALLBACK); node = mxmlFindElement(tree, tree, TAG_REQUEST, ATTR_TYPE, NULL, MXML_DESCEND_FIRST); if (node) { attr = mxmlElementGetAttr(node, ATTR_TYPE); } if (attr && strcmp(attr, VALUE_EVENTS) == 0) { sendEvents(); logg.logMessage("Sent events xml response"); } else if (attr && strcmp(attr, VALUE_CONFIGURATION) == 0) { sendConfiguration(); logg.logMessage("Sent configuration xml response"); } else if (attr && strcmp(attr, VALUE_COUNTERS) == 0) { sendCounters(); logg.logMessage("Sent counters xml response"); } else if (attr && strcmp(attr, VALUE_CAPTURED) == 0) { CapturedXML capturedXML; char* capturedText = capturedXML.getXML(false); sendData(capturedText, strlen(capturedText), RESPONSE_XML); free(capturedText); logg.logMessage("Sent captured xml response"); } else if (attr && strcmp(attr, VALUE_DEFAULTS) == 0) { sendDefaults(); logg.logMessage("Sent default configuration xml response"); } else { char error[] = "Unknown request"; sendData(error, strlen(error), RESPONSE_NAK); logg.logMessage("Received unknown request:\n%s", xml); } mxmlDelete(tree); }
/** * Loads the Object from XML file. * @param obj_node The <object> node. * @param object The Object. */ void FileProcessor::loadArea_Object(mxml_node_t* obj_node, Object* object) { loadArea_Tag(obj_node, object); const char* visibility_s = mxmlElementGetAttr(obj_node, "visible"); if(visibility_s != NULL && strncasecmp(visibility_s, "false", strlen(visibility_s)) == 0) { object->setVisible(false); } else { object->setVisible(true); } mxml_node_t* node; for(node = obj_node->child; node; node = node->next) { if(node->type == MXML_ELEMENT) { if(strcasecmp(node->value.element.name, "position") == 0) { loadArea_Position(node, object); } else if(strcasecmp(node->value.element.name, "rotation") == 0) { loadArea_Rotation(node, object); } else if(strcasecmp(node->value.element.name, "script") == 0) { loadArea_Script(node, object); } else if(strcasecmp(node->value.element.name, "model") == 0) { VModel* model = new VModel(); model->setVisible(object->isVisible()); loadArea_Model(node, model); object->setVisual(model); } } } }
int verify_findMD5Sum(const char * md5orig, int disc_type) { print_gecko("Looking for MD5 [%s]\r\n", md5orig); char *xmlPointer = (disc_type == IS_NGC_DISC) ? ngcDAT : wiiDAT; if(xmlPointer) { mxml_node_t *pointer = (disc_type == IS_NGC_DISC) ? ngcXML : wiiXML; pointer = mxmlLoadString(NULL, xmlPointer, MXML_TEXT_CALLBACK); print_gecko("Looking in the %s XML\r\n", pointer == ngcXML ? "GameCube" : "Wii"); if (pointer) { // open the <datafile> mxml_node_t *item = mxmlFindElement(pointer, pointer, "datafile", NULL, NULL, MXML_DESCEND); print_gecko("DataFile Pointer OK\r\n"); if (item) { mxml_index_t *iterator = mxmlIndexNew(item, "game", NULL); mxml_node_t *gameElem = NULL; //print_gecko("Item Pointer OK\r\n"); // iterate over all the <game> entries while ((gameElem = mxmlIndexEnum(iterator)) != NULL) { // get the md5 and compare it mxml_node_t *md5Elem = mxmlFindElement(gameElem, gameElem, NULL, "md5", NULL, MXML_DESCEND); // get the name too mxml_node_t *nameElem = mxmlFindElement(gameElem, gameElem, NULL, "name", NULL, MXML_DESCEND); char md5[64]; memset(&md5[0], 0, 64); strncpy(&md5[0], mxmlElementGetAttr(md5Elem, "md5"), 32); //print_gecko("Comparing game [%s] and md5 [%s]\r\n",mxmlElementGetAttr(nameElem, "name"),mxmlElementGetAttr(md5Elem, "md5")); if (!strnicmp(&md5[0], md5orig, 32)) { snprintf(&gameName[0], 128, "%s", mxmlElementGetAttr( nameElem, "name")); print_gecko("Found a match!\r\n"); return 1; } } } } } return 0; }
/** * Gets the internal node for a given Device * * @param _device The device concerned * * @return returns the mxml_node_t corresponding to the Device of NULL if not in the XML file */ mxml_node_t * get_xml_node_of_device(Device *_device) { mxml_node_t *device; for (device = mxmlFindElement(service_xml_file->xml_tree, service_xml_file->xml_tree,"device", NULL, NULL, MXML_DESCEND); device != NULL; device = mxmlFindElement(device, service_xml_file->xml_tree, "device", NULL, NULL, MXML_DESCEND)) { if(strcmp(mxmlElementGetAttr(device,"type") , _device->type) == 0 && strcmp(mxmlElementGetAttr(device,"id") , _device->ID) == 0) { return device; } } return NULL; }