| 1 |
// Base64Encoder.h |
| 2 |
// |
| 3 |
// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood |
| 4 |
// See file AUTHORS for contact information |
| 5 |
// |
| 6 |
// This file is part of RudeConfig. |
| 7 |
// |
| 8 |
// RudeConfig is free software; you can redistribute it and/or modify |
| 9 |
// it under the terms of the GNU General Public License as published by |
| 10 |
// the Free Software Foundation; either version 2, or (at your option) |
| 11 |
// any later version. |
| 12 |
// |
| 13 |
// RudeConfig is distributed in the hope that it will be useful, |
| 14 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
// GNU General Public License for more details. |
| 17 |
// |
| 18 |
// You should have received a copy of the GNU General Public License |
| 19 |
// along with RudeConfig; (see COPYING) if not, write to the Free Software |
| 20 |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 21 |
// 02111-1307, USA. |
| 22 |
//------------------------------------------------------------------------ |
| 23 |
|
| 24 |
#ifndef INCLUDED_BASE64ENCODER_H |
| 25 |
#define INCLUDED_BASE64ENCODER_H |
| 26 |
|
| 27 |
|
| 28 |
namespace rude{ |
| 29 |
namespace config{ |
| 30 |
|
| 31 |
class Base64Encoder{ |
| 32 |
|
| 33 |
private: |
| 34 |
static char c_encode(char uc); |
| 35 |
static unsigned char c_decode(char c); |
| 36 |
static bool IsBase64(char c); |
| 37 |
|
| 38 |
public: |
| 39 |
|
| 40 |
// datalength does not need to include the NULL terminator for strings |
| 41 |
// |
| 42 |
// a NULL terminator is appended to result to make it string friendly |
| 43 |
// but outlength does not include the |
| 44 |
// appended NULL terminator in length calculation |
| 45 |
// |
| 46 |
// CALLER RESPONSIBLE FOR DELETING RETURNED char * if it is not NULL. |
| 47 |
// |
| 48 |
static char * encode(const char *data, int datalength, int &outlength); |
| 49 |
|
| 50 |
|
| 51 |
// datalength does not need to include the NULL terminator for strings |
| 52 |
// NULL Terminator is appended to result, but outlength does not include the |
| 53 |
// appended NULL terminator in length calculation |
| 54 |
// |
| 55 |
// CALLER RESPONSIBLE FOR DELETING RETURNED char * if it is not NULL. |
| 56 |
// |
| 57 |
static char * decode(const char *data, int datalength, int &outlength); |
| 58 |
|
| 59 |
}; |
| 60 |
}} |
| 61 |
|
| 62 |
#endif |
| 63 |
|
| 64 |
|