/* main */ int main(int argc, char* argv[]) { LINKEDLIST *self; PERSONALINFO *personInfo; CreateLinkedList(&self); AddPersonalInfo(&personInfo, "kim", "111", "seoul", FALSE); AppendLinkedList(&self, &personInfo); AddPersonalInfo(&personInfo, "lee", "222", "busan", FALSE); AppendLinkedList(&self, &personInfo); AddPersonalInfo(&personInfo, "park", "333", "inchon", FALSE); InsertLinkedList(&self, 2, &personInfo); DeleteLinkedList(&self, 3); //DeleteLinkedList(&self, 1); //DeleteLinkedList(&self, 1); personInfo = ViewAtLinkedList(&self, 2); printf("name : %s\nphone : %s\naddress : %s\nflag : %d\n", personInfo->name, personInfo->phone, personInfo->address, personInfo->flagOfDelete); DestroyLinkedList(&self); return 0; }
/*! * \brief * Processes an xml map node to populate a map element with its parts. * * \param map_element * The map element to populate. * * \param map_definition * The xml map part definition to process. * * \param host_directory * The relative directory of the maps parts on the file server. * * \returns * Returns true if the map parts were added to the map element successfully, otherwise returns false. * * Processes an xml map element to populate a map element with its parts. */ static bool AddMapParts(c_map_element* map_element, const TiXmlElement* map_definition, const char* host_directory) { // iterate through all of the maps parts const TiXmlElement* current_part = map_definition->FirstChildElement("part"); if(!current_part) { blam::console_printf(false, "No part nodes present for %s", map_element->m_name.c_str()); return false; } do { const char* name = current_part->Attribute("name"); const char* md5 = current_part->Attribute("md5"); const char* encrypted = current_part->Attribute("encrypted"); const char* unencryptedmd5 = current_part->Attribute("unencrypted_md5"); // check the md5 strings are the correct length bool md5_valid = false; if(md5) md5_valid = (strlen(md5) == 32); bool unencrypted_md5_valid = false; if(unencryptedmd5) unencrypted_md5_valid = (strlen(unencryptedmd5) == 32); bool encrypted_value = false; if(encrypted) ValueConversion::FromString(encrypted, encrypted_value); bool encryption_valid = true; if((encrypted_value && !unencryptedmd5) || (!encrypted_value && unencryptedmd5)) encryption_valid = false; else if(encrypted_value && !unencrypted_md5_valid) encryption_valid = false; // if the part is valid, create a new part element if(name && md5 && md5_valid && encryption_valid) { c_part_element* part_element = new c_part_element(); part_element->Ctor(); part_element->m_name.assign(name); // build the parts redirection address c_url_interface url_interface; url_interface.ParseURL(g_map_download_globals.m_host_address); if(host_directory && (strlen(host_directory) > 0)) url_interface.AppendPath(host_directory); url_interface.AppendPath(name); part_element->m_redirect_address = url_interface.GetURL(); // add the part to the maps part list AppendLinkedListNode(map_element->m_parts, part_element); } else { if(!name) blam::console_printf(false, "A part node is missing its name"); if(!md5) blam::console_printf(false, "A part node is missing its md5 checksum"); else if(!md5_valid) blam::console_printf(false, "A part nodes md5 checksum is too long/short"); if(encrypted_value && !unencryptedmd5) blam::console_printf(false, "A part node is encrypted but has no unencrypted_md5 attribute"); else if(!encrypted_value && unencryptedmd5) blam::console_printf(false, "A part node is not encrypted but has an unencrypted_md5 attribute"); else if(encrypted_value && !unencrypted_md5_valid) blam::console_printf(false, "An encrypted part nodes unencrypted md5 checksum is too long/short"); // delete the part list to leave the map element unchanged DeleteLinkedList(map_element->m_parts); return false; } }while(current_part = current_part->NextSiblingElement("part")); return true; }