1 // ===================================================================== 2 // 3 // base256.h 4 // 5 // Author: Dave Freese, W1HKJ 6 // Copyright: 2012 7 // 8 // This file is part of FLAMP. 9 // 10 // This is free software; you can redistribute it and/or modify 11 // it under the terms of the GNU General Public License as published by 12 // the Free Software Foundation; either version 3 of the License, or 13 // (at your option) any later version. 14 // 15 // This software is distributed in the hope that it will be useful, 16 // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 // GNU General Public License for more details. 19 // 20 // You should have received a copy of the GNU General Public License 21 // along with this program. If not, see <http://www.gnu.org/licenses/>. 22 // ===================================================================== 23 24 #include <stdio.h> 25 #include <stdlib.h> 26 #include <ctype.h> 27 28 #include <string> 29 30 class base256 { 31 #define LINELEN 64 32 private: 33 bool ateof; 34 int linelength; 35 size_t iocp; 36 size_t iolen; 37 std::string output; 38 39 void addlf(std::string &); 40 void escape(std::string &, bool encode = true); 41 void init(); 42 void remlf(std::string &); 43 public: base256()44 base256() { init(); }; ~base256()45 ~base256() {}; 46 std::string encode(std::string &in); 47 std::string decode(std::string &in, bool &decode_error); 48 }; 49