void FileOpenOptions::SetFromNode(DataNode *parentNode) { if(parentNode == 0) return; DataNode *searchNode = parentNode->GetNode("FileOpenOptions"); if(searchNode == 0) return; DataNode *node; DataNode **children; if((node = searchNode->GetNode("typeNames")) != 0) SetTypeNames(node->AsStringVector()); if((node = searchNode->GetNode("typeIDs")) != 0) SetTypeIDs(node->AsStringVector()); // Clear all the DBOptionsAttributess if we got any. bool clearedOpenOptions = false; // Go through all of the children and construct a new // DBOptionsAttributes for each one of them. children = searchNode->GetChildren(); if(children != 0) { for(int i = 0; i < searchNode->GetNumChildren(); ++i) { if(children[i]->GetKey() == std::string("DBOptionsAttributes")) { if (!clearedOpenOptions) { ClearOpenOptions(); clearedOpenOptions = true; } DBOptionsAttributes temp; temp.SetFromNode(children[i]); AddOpenOptions(temp); } } } if((node = searchNode->GetNode("Enabled")) != 0) SetEnabled(node->AsIntVector()); if((node = searchNode->GetNode("preferredIDs")) != 0) SetPreferredIDs(node->AsStringVector()); }
int main(int argc, char *argv[]) { AppLib::Logging::setApplicationName("appinspect"); AppLib::Logging::verbose = true; // Check arguments. if (argc != 2) { AppLib::Logging::showErrorW("Invalid arguments provided."); AppLib::Logging::showErrorO("Usage: appinspect <filename>"); return 1; } // Set up the array of command names and their functions. Program::AvailableCommands["help"] = &DoHelp; Program::AvailableCommands["children"] = &GetChildren; Program::AvailableCommands["segments"] = &DoSegments; Program::AvailableCommands["clean"] = &DoClean; Program::AvailableCommands["show"] = &DoShow; // Set the type names up. SetTypeNames(); // Open the data stream. Program::FSStream = new AppLib::LowLevel::BlockStream(argv[1]); if (!Program::FSStream->is_open()) { AppLib::Logging::showErrorW("Unable to open specified file as a block stream. Make"); AppLib::Logging::showErrorO("sure the file is not currently in use."); return 1; } // Open the package. Program::FS = new AppLib::LowLevel::FS(Program::FSStream); // Package is now open. Show the initial filesystem information and // start the main application loop. AppLib::LowLevel::INode node = Program::FS->getINodeByPosition(OFFSET_FSINFO); AppLib::Logging::showInfoW("INode ID: %i", node.inodeid); AppLib::Logging::showInfoO("INode Type: %i", node.type); AppLib::Logging::showInfoO("Filesystem Name: %s", node.fs_name); AppLib::Logging::showInfoO("Filesystem Version: %i.%i.%i", node.ver_major, node.ver_minor, node.ver_revision); AppLib::Logging::showInfoO("Application Name: %s", node.app_name); AppLib::Logging::showInfoO("Application Version: %s", node.app_ver); AppLib::Logging::showInfoO("Application Description: %s", node.app_desc); AppLib::Logging::showInfoO("Application Author: %s", node.app_author); AppLib::Logging::showInfoO("Position of root directory INode: %p", node.pos_root); AppLib::Logging::showInfoO("Position of freelist INode: %p", node.pos_freelist); while (true) { std::cout << ">> "; std::string cmdstr = ReadLine(); std::vector<std::string> command = ParseCommand(cmdstr); while (command.size() != 0 && command[0] == "__continue") { std::cout << ".. "; cmdstr += ReadLine(); command = ParseCommand(cmdstr); } if (command.size() == 0) { std::cout << "# Bad input." << std::endl; continue; } if (command[0] == "exit") return 0; for (std::map<std::string, Program::CommandFunc>::iterator iter = Program::AvailableCommands.begin(); iter != Program::AvailableCommands.end(); iter++) { if (command[0] == iter->first) { iter->second(command); goto aftercmd_standard; } } std::cout << "# Bad command." << std::endl; aftercmd_standard: continue; } }