00001 /******************************************************************************* 00002 00003 Copyright (C) 2007 Brendon Costa 00004 00005 This code is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2, or (at your option) 00008 any later version. 00009 00010 This code is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this code; see the file COPYING. If not, write to 00017 the Free Software Foundation, 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 00020 *******************************************************************************/ 00021 #ifndef EDOCBFD_BFD_UTILS_H 00022 #define EDOCBFD_BFD_UTILS_H 00023 00024 #include <list> 00025 #include <string> 00026 #include "EDoc/Persistence.h" 00027 #include "EDoc/ManagedFile.h" 00028 #include <bfd.h> 00029 00030 namespace EDocBFD 00031 { 00032 //=========================================================================== 00033 /** \brief Must be called before using any bfd related functions. 00034 */ 00035 void InitialiseBFD(); 00036 00037 //=========================================================================== 00038 /** \brief Opens the given file using bfd. 00039 */ 00040 struct bfd* OpenBFDFile(std::string filename); 00041 00042 //=========================================================================== 00043 /** \brief Reads the contens of a binary file and extracts all relevant EDoc 00044 * information from them if there is any. 00045 */ 00046 void ProcessReadBFD(std::list<EDoc::ManagedFile>& input_files, 00047 struct bfd* abfd, const EDoc::ManagedFile& filename); 00048 00049 //=========================================================================== 00050 /** \brief Returns a list of temporary files that have been populated with 00051 * the contents of an EDoc section. 00052 */ 00053 std::list<EDoc::ManagedFile> HandleEDocSection(bfd* abfd, asection* asect, 00054 const EDoc::ManagedFile& arch); 00055 00056 //=========================================================================== 00057 /** \brief Embeds the contents of the given file into the given section of a 00058 * binary file. 00059 */ 00060 void EmbedFileInBinary(const std::string& file_to_embed, 00061 const std::string embedded_name, 00062 const std::string& binary_file, 00063 std::string section); 00064 00065 //=========================================================================== 00066 } 00067 00068 #endif // EDOCBFD_BFD_UTILS_H