/////////////////////////////////////////////////////////////////////// // HexRep.h - converts from binary files to hex files // // ver 1.0 // // // // Language: Visual C++, ver 6.0 // // Platform: Del XPS1000, Windows 2000 Professional // // Application: ImageTrek Project, Fall 2000 // // Author: Jim Fawcett, CST 2-187, Syracuse Univ. // // (315) 443-3948, jfawcett@twcny.rr.com // /////////////////////////////////////////////////////////////////////// /* Module Operations: ================== This module provides a set of global functions to build hex files or XML elements with hex contents That entails: - convert binary files to hexadecimal ASCII representation - embed the hex rep between file tags If you specify one or more file names on the command line this module's test stub builds one file, hex.$$$ with a set of XML elements, one for each file cited. If the first argument on the command line is a switch of the form /5, then the test stub will extract each file payload, converting the hex representation back to binary, naming the resulting files temp0.tmp, temp1.tmp, temp2.tmp, ... ,temp9.tmp */ /////////////////////////////////////////////////////////////////////// // build process // /////////////////////////////////////////////////////////////////////// // required files: // // - HexRep.h, HexRep.cpp, timer.h, timer.cpp // // // // command line build: // // msdev HexRep.dsw /MAKE /REBUILD // // or // // cl /GX /DTEST_HEXREP HexRep.cpp timer.cpp // /////////////////////////////////////////////////////////////////////// /* Maintenance History =================== ver 1.0 : 3 Nov 2000 - first release ver 2.0 : 22 Jan 2001 - turned prototype into a more accessible module Planned Modifications ===================== - get rid of hex.$$$ file, let client specify file */ // #include #include //----< convert short int to 4 hex chars in string >------------------- std::string toHex(unsigned short value); //----< convert 4 hex chars to unsigned short >------------------------ unsigned short fromHex(const char buffer[4]); //----< create hex.$$$ temp file from file named fileName >------------ void fileToHex(const std::string &fileName); //----< create file named fileName converted from hex.$$$ >------------ void hexToFile(const std::string &fileName); //----< add XML element with hex contents to hex.$$$ >----------------- HANDLE makeFileElement(const std::string &fileName, HANDLE tempHandle); //----< extract next file from XML element in hex.$$$ >---------------- HANDLE extractFileElement(const std::string &fileName, HANDLE tempHandle);