///\file sourcery.cpp /// Utility program used for c-string dumping files. #undef DEBUG #define DEBUG -1 #include "../lib/encode.cpp" #include "../lib/encode.h" #include "../lib/url.cpp" #include "../lib/url.h" #include #include #include #include #include #include #include #include #include std::string getContents(const char *fileName){ std::ifstream inFile(fileName); std::string fullText; if (inFile){ std::stringstream contents; contents << inFile.rdbuf(); inFile.close(); return contents.str(); } return ""; } int main(int argc, char *argv[]){ if (argc < 4){ std::cerr << "Usage: " << argv[0] << " []" << std::endl; return 42; } const char *splitText = 0; if (argc >= 5){splitText = argv[4];} char workDir[512]; getcwd(workDir, 512); HTTP::URL inUri(std::string("file://") + workDir + "/"); inUri = inUri.link(argv[1]); // Read the entire first argument into a string buffer std::string fullText = getContents(inUri.getFilePath().c_str()); // replace every with the contents of the file '*' while (fullText.find("", locStart); // Assume we should abort if the strlen of the filename is > 230 chars if (locEnd - locStart >= 230){break;} HTTP::URL fileName = inUri.link(fullText.substr(locStart + 13, locEnd - locStart - 13)); std::string subText = getContents(fileName.getFilePath().c_str()); fullText = fullText.substr(0, locStart) + "