changed: now we do not use std::string and char* in the Winix API

everywhere we are using std::wstring and wchar_t*
         (std::string and char* is used only locally in some places
         especially when creating a path to OS file system etc.)
added:   to the special thread when winix closes:
         a write function for curl: FetchPageOnExitCurlCallback()
         without this function the curl library will print
         the page's content to the standart output
changed: TextStream<> class from core can make
         UTF8<->wide strings conversions
removed: from config: utf8 option
         now winix expects UTF8 from the user's input (html forms, url-es)
         and outputs strings in the UTF8 format




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@965 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2014-10-09 20:44:56 +00:00
parent 4abf6642f7
commit 8196fb77d1
74 changed files with 1911 additions and 1612 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -76,7 +76,6 @@ bool Env::Parse(const std::wstring & env_str)
{
space.Clear();
conf_parser.SetSpace(space);
conf_parser.UTF8(config->utf8);
conf_parser.SplitSingle(true);
return (conf_parser.ParseString(env_str) == PT::SpaceParser::ok);

View File

@@ -48,15 +48,9 @@ namespace Winix
FunctionParser::FunctionParser()
{
utf8 = false;
}
void FunctionParser::UTF8(bool use_utf8)
{
utf8 = use_utf8;
}
bool FunctionParser::Parse(Cur * pcur, Db * pdb, Functions * pfunctions, System * psystem)
{
@@ -65,11 +59,7 @@ bool FunctionParser::Parse(Cur * pcur, Db * pdb, Functions * pfunctions, System
system = psystem;
functions = pfunctions;
last_dir = 0;
path = cur->request->env_request_uri;
//!! mozna dodac sprawdzanie dlugosci path
// jesli wieksza niz np 2048 to zglosic incorrect url
// i nie parsowac
path = cur->request->env_request_uri.c_str();
ParseDirsItemFunction();
ParseParams();
@@ -225,7 +215,7 @@ void FunctionParser::ParseParams()
void FunctionParser::ParseOrdinaryParams()
{
if( *path=='?' )
if( *path == '?' )
path += 1;
do
@@ -297,7 +287,7 @@ void FunctionParser::ParseAnchor()
while( *path )
name_ascii += GetChar();
ToWide(name_ascii, cur->request->anchor);
PT::UTF8ToWide(name_ascii, cur->request->anchor);
if( !cur->request->anchor.empty() )
log << log3 << "FP: anchor: " << cur->request->anchor << logend;
@@ -354,17 +344,6 @@ return c;
}
void FunctionParser::ToWide(const std::string & src, std::wstring & dst)
{
dst.clear();
if( utf8 )
PT::UTF8ToWide(src, dst, false);
else
AssignString(src, dst, false);
}
void FunctionParser::ReadName()
{
@@ -374,7 +353,7 @@ void FunctionParser::ReadName()
while( *path && *path!='/' && *path!='?' && *path!='#' )
name_ascii += GetChar();
ToWide(name_ascii, name);
PT::UTF8ToWide(name_ascii, name);
}
@@ -385,7 +364,7 @@ void FunctionParser::ReadOrdinaryParName()
while( *path && *path!='=' && *path!='&' && *path!='#' )
name_ascii += GetChar();
ToWide(name_ascii, name);
PT::UTF8ToWide(name_ascii, name);
}
@@ -399,7 +378,7 @@ void FunctionParser::ReadOrdinaryParValue()
while( *path && *path!='&' && *path!='#' )
value_ascii += GetChar();
ToWide(value_ascii, value);
PT::UTF8ToWide(value_ascii, value);
}
@@ -410,7 +389,7 @@ void FunctionParser::ReadWinixParName()
while( *path && *path!='/' && *path!=':' && *path!='#' )
name_ascii += GetChar();
ToWide(name_ascii, name);
PT::UTF8ToWide(name_ascii, name);
}
@@ -418,13 +397,13 @@ void FunctionParser::ReadWinixParValue()
{
value_ascii.clear();
if( *path==':' )
if( *path == ':' )
path += 1;
while( *path && *path!='/' && *path!='#' )
value_ascii += GetChar();
ToWide(value_ascii, value);
PT::UTF8ToWide(value_ascii, value);
}

View File

@@ -53,7 +53,6 @@ public:
FunctionParser();
bool Parse(Cur * pcur, Db * pdb, Functions * pfunctions, System * psystem);
void UTF8(bool use_utf8);
private:
@@ -62,12 +61,11 @@ private:
System * system;
Functions * functions;
const char * path;
std::string name_ascii, value_ascii;
const wchar_t * path;
std::wstring name, value;
std::string name_ascii, value_ascii;
Item * last_dir;
Param param;
bool utf8;
void SkipSlashes();
@@ -84,8 +82,6 @@ private:
void ParseOrdinaryParams();
void ParseWinixParams();
void ToWide(const std::string & src, std::wstring & dst);
int FromHex(int c);
int GetChar();
void ReadName();

View File

@@ -280,7 +280,6 @@ void Functions::Init()
void Functions::Parse()
{
function_parser.UTF8(config->utf8);
function_parser.Parse(cur, db, this, system);
}

View File

@@ -72,6 +72,9 @@ void IPBanFun::MakePost()
void IPBanFun::MakeGet()
{
char tmp_ip_str[100];
size_t tmp_ip_len = sizeof(tmp_ip_str) / sizeof(char);
if( cur->request->IsParam(L"removeip") )
{
if( cur->request->ParamValue(L"removeip") == L"all" )
@@ -86,12 +89,14 @@ void IPBanFun::MakeGet()
if( cur->session->ip_ban )
cur_ip = cur->session->ip_ban->ip;
AssignString(cur->request->ParamValue(L"removeip"), tmp_ip_str);
int ip = (int)inet_addr(tmp_ip_str.c_str());
session_manager->RemoveIPBan(ip);
if( WideToUTF8(cur->request->ParamValue(L"removeip"), tmp_ip_str, tmp_ip_len) )
{
int ip = (int)inet_addr(tmp_ip_str);
session_manager->RemoveIPBan(ip);
if( cur->session->ip_ban && cur_ip == ip )
cur->session->ip_ban = 0;
if( cur->session->ip_ban && cur_ip == ip )
cur->session->ip_ban = 0;
}
}
system->RedirectToLastFunction();

View File

@@ -57,7 +57,6 @@ public:
private:
std::string tmp_ip_str;
};

View File

@@ -64,7 +64,6 @@ bool Meta::Parse(const std::wstring & meta_str)
{
space.Clear();
conf_parser.SetSpace(space);
conf_parser.UTF8(config->utf8);
conf_parser.SplitSingle(true);
return (conf_parser.ParseString(meta_str) == PT::SpaceParser::ok);

View File

@@ -109,9 +109,7 @@ bool Upload::UploadSaveStaticFile(const Item & item, const std::wstring & tmp_fi
if( RenameFile(tmp_filename, path) )
{
PT::WideToUTF8(path, patha);
if( !SetPriv(patha, config->upload_files_chmod, config->upload_group_int) )
if( !SetPriv(path, config->upload_files_chmod, config->upload_group_int) )
{
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
return false;

View File

@@ -59,7 +59,6 @@ public:
private:
std::wstring path;
std::string patha, path_thumba;
DbItemQuery query;
bool is_jquery_upload;