00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _CGIUTILS_H_
00023 #define _CGIUTILS_H_ 1
00024
00025 #ifdef __GNUG__
00026 # pragma interface
00027 #endif
00028
00036 #include <new>
00037 #include <string>
00038 #include <fstream>
00039
00040 #include "cgicc/CgiDefs.h"
00041
00042 #if DEBUG
00043
00044 extern std::ofstream gLogFile;
00045 #define LOGLN(s) gLogFile << s << std::endl;
00046 #define LOG(s) gLogFile << s;
00047
00048 #else
00049
00056 #define LOGLN(s)
00057
00064 #define LOG(s)
00065
00066 #endif
00067
00068
00069 namespace cgicc {
00070
00079 CGICC_API bool
00080 stringsAreEqual(const std::string& s1,
00081 const std::string& s2);
00082
00092 CGICC_API bool
00093 stringsAreEqual(const std::string& s1,
00094 const std::string& s2,
00095 size_t n);
00096
00104 CGICC_API std::string
00105 form_urldecode(const std::string& src);
00106
00116 CGICC_API std::string
00117 form_urlencode(const std::string& src);
00118
00119
00133 CGICC_API std::string
00134 charToHex(char c);
00135
00150 CGICC_API char
00151 hexToChar(char first,
00152 char second);
00153
00169 std::string
00170 extractBetween(const std::string& data,
00171 const std::string& separator1,
00172 const std::string& separator2);
00173
00182 inline std::string
00183 extractBetween(const std::string& data,
00184 const std::string& separator)
00185 { return extractBetween(data, separator, separator); }
00186
00194 void
00195 writeString(std::ostream& out,
00196 const std::string& s);
00197
00205 void
00206 writeLong(std::ostream& out,
00207 unsigned long l);
00208
00216 std::string
00217 readString(std::istream& in);
00218
00226 unsigned long
00227 readLong(std::istream& in);
00228
00229 }
00230
00231 #endif