1 // ===================================================================== 2 // 3 // base128.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 typedef unsigned char t_byte; 31 32 class base128 { 33 #define LINELEN 64 34 35 private: 36 bool ateof; 37 int linelength; 38 size_t iocp; 39 size_t iolen; 40 std::string output; 41 42 void addlf(std::string &); 43 void escape(std::string &, bool encode = true); 44 void init(); 45 void remlf(std::string &); 46 47 public: base128()48 base128() { init(); }; ~base128()49 ~base128() {}; 50 std::string encode(std::string &in); 51 std::string decode(std::string &in, bool &decode_error); 52 }; 53 54