| 1 |
// Copyright © 2001-2002 Rob Kaper <[email protected]>, |
| 2 |
// 2001 Erik Bourget <[email protected]> |
| 3 |
// 2010-2015 Sylvain Rochet <[email protected]> |
| 4 |
// |
| 5 |
// This program is free software; you can redistribute it and/or |
| 6 |
// modify it under the terms of the GNU General Public License |
| 7 |
// version 2 as published by the Free Software Foundation. |
| 8 |
// |
| 9 |
// This program is distributed in the hope that it will be useful, |
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
// General Public License for more details. |
| 13 |
// |
| 14 |
// You should have received a copy of the GNU General Public License |
| 15 |
// along with this program; see the file COPYING. If not, see |
| 16 |
// <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
#include "config.h" |
| 19 |
|
| 20 |
//#ifndef _GNU_SOURCE |
| 21 |
//#define _GNU_SOURCE |
| 22 |
//#endif |
| 23 |
//#include <stdarg.h> |
| 24 |
#include <stdio.h> |
| 25 |
|
| 26 |
#include "io.h" |
| 27 |
|
| 28 |
#define BUFSIZE 2048 |
| 29 |
|
| 30 |
std::string escapeXML(std::string data) |
| 31 |
{ |
| 32 |
stringReplace(data, "&", "\n"); |
| 33 |
stringReplace(data, "<", "<"); |
| 34 |
stringReplace(data, ">", ">"); |
| 35 |
stringReplace(data, "\"", """); |
| 36 |
stringReplace(data, "\n", "&"); |
| 37 |
return data; |
| 38 |
} |
| 39 |
|
| 40 |
std::string escapeHTML(std::string data) |
| 41 |
{ |
| 42 |
stringReplace(data, " ", "+"); |
| 43 |
return data; |
| 44 |
} |
| 45 |
|
| 46 |
std::string itoa(int number) |
| 47 |
{ |
| 48 |
char buf[32]; |
| 49 |
snprintf(buf, sizeof(buf)-1, "%d", number); |
| 50 |
buf[sizeof(buf)-1] = 0; |
| 51 |
return std::string(buf); |
| 52 |
} |
| 53 |
|
| 54 |
void stringReplace( std::string & source, const std::string & find, const std::string & replace ) |
| 55 |
{ |
| 56 |
size_t j; |
| 57 |
for ( ; ( j = source.find( find ) ) != std::string::npos ; ) |
| 58 |
source.replace( j, find.length(), replace ); |
| 59 |
} |