From c83b9320aefc9fe23d3b64512d314ccfb9ef487a Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Thu, 15 Jan 2026 00:11:47 +0100 Subject: [PATCH] Patch level : 12.00 1402 Files correlati : ve01.exe Commento : Corretta abilitazione CIG CUP --- src/xvaga01/xvaga.cpp | 691 +++++++++++++++++++++++++++++++++++------- src/xvaga01/xvt.h | 6 +- 2 files changed, 582 insertions(+), 115 deletions(-) diff --git a/src/xvaga01/xvaga.cpp b/src/xvaga01/xvaga.cpp index 75a7554ee..5d5044521 100644 --- a/src/xvaga01/xvaga.cpp +++ b/src/xvaga01/xvaga.cpp @@ -1491,6 +1491,241 @@ void xvt_font_unmap(XVT_FNTID font_id) font.SetWin(NULL_WIN); } +/////////////////////////////////////////////////////////// +// HTTP +/////////////////////////////////////////////////////////// + +static char * protocols[] = { "ftp", "http", "https", nullptr }; + +BOOLEAN xvt_is_network_protocol(const char *protocol) +{ + if (protocol != nullptr) + for (int i = 0; protocols[i] != nullptr; i++) + if (strcmp(protocol, protocols[i]) == 0) + return true; + return false; +} + +static int xvt_sys_timeout(const char* server) +{ + wxString var = _T("Timeout["); + + var += server; + var += "]"; + + int timeout = xvt_sys_get_profile_int(xvt_fsys_get_campo_ini(), var, "Timeout", -1); + + if (timeout < 0) + timeout = xvt_sys_get_profile_int(xvt_fsys_get_campo_ini(), "Server", "Timeout", 120); + + return timeout; +} + +static void xvt_sys_proxy(wxString & proxy) +{ + xvt_sys_get_profile_string(xvt_fsys_get_campo_ini(), "Server", "Proxy", "", + proxy.GetWriteBuf(MAX_PATH), MAX_PATH); + proxy.UngetWriteBuf(); +} + +static int decode_result(wxString & resfile, char * &result) +{ + wxString strResult; + wxFileInputStream res(resfile); + + while (!res.Eof()) + strResult += res.GetC(); + strResult = strResult.AfterFirst(_T(' ')); + + int rescode = atoi(strResult.Left(3)); + int pos = strResult.Find(""); + + strResult = strResult.Mid(pos + 7); + pos = strResult.Find(""); + if (pos >= 0) + strResult = strResult.Left(pos); + result = _strdup(strResult); + return rescode; +} + +static BOOLEAN is_ftp(const char* file) // @parm ritorna se file è un direttorio di cui controllare l'esistenza +{ + return file && *file && strncmp(file, "ftp:", 4) == 0; +} + +static BOOLEAN is_http(const char* file) // @parm ritorna se file è un direttorio di cui controllare l'esistenza +{ + return file && *file && (strncmp(file, "http:", 5) == 0 || strncmp(file, "https:", 6) == 0); +} + +static BOOLEAN is_https(const char* file) // @parm ritorna se file è un direttorio di cui controllare l'esistenza +{ + return file && *file && strncmp(file, "https:", 6) == 0; +} + +static BOOLEAN is_remote(const char* file) +{ + return is_ftp(file) || is_http(file); +} + +static BOOLEAN is_local(const char* file) +{ + return !is_remote(file); +} + +int xvt_http_get(const char *remote, const char * local, const char * user, const char * password) +{ + wxString tempresult = wxFileName::CreateTempFileName("res"); + wxString command = _T("./curl -i "); + wxString proxy; + + if (user != nullptr) + { + command += _T("-u "); + command += user; + command += _T(":"); + if (password != nullptr) + command += password; + command += _T(" "); + } + xvt_sys_proxy(proxy); + if (!proxy.IsEmpty()) + { + command += _T("-x "); + command += proxy; + command += _T(" "); + } + command += _T("-o "); + command += tempresult; + command += _T(" "); + command += remote; + + wxArrayString r; + long retcode = wxExecute(command, r, wxEXEC_SYNC); + int rescode = -1; + + if (retcode == 0) + { + char *result; + + rescode = decode_result(tempresult, result); + + wxFileOutputStream out(local); + + out.Write(result, strlen(result)); + delete result; + } + wxRemoveFile(tempresult); + return rescode; +} + +int xvt_http_post(const char *remote, const char * result, const char * content_type, + const char * request, const char * user, const char * password) +{ + wxString command = _T("./curl -i "); + wxString tempresult = wxFileName::CreateTempFileName("res"); + wxArrayString res; + wxString proxy; + + command += _T("-X POST "); + command += remote; + command += _T(" "); + if (user != nullptr) + { + command += _T("-u "); + command += user; + command += _T(":"); + if (password != nullptr) + command += password; + command += _T(" "); + } + xvt_sys_proxy(proxy); + if (!proxy.IsEmpty()) + { + command += _T("-x "); + command += proxy; + command += _T(" "); + } + command += _T("-H \"Content-Type: "); + command += content_type != nullptr ? content_type : "text/html "; + command += _T("\" "); + if (request != nullptr) + { + command += _T("--data \""); + command += request; + command += _T("\" "); + } + command += _T(" -o "); + command += tempresult; + + wxArrayString r; + long retcode = wxExecute(command, r, wxEXEC_SYNC); + int rescode = -1; + + if (retcode == 0) + { + char * strResult; + + rescode = decode_result(tempresult, strResult); + + wxFileOutputStream out(result); + + out.Write(strResult, strlen(strResult)); + delete strResult; + } + wxRemoveFile(tempresult); + return rescode; +} + +int xvt_http_put(const char * local, const char *remote, const char * user, const char * password) +{ + wxString command = _T("./curl -i "); + wxString tempresult = wxFileName::CreateTempFileName("res"); + wxArrayString res; + int rescode = 0; + wxString proxy; + + if (user != nullptr) + { + command += _T("-u "); + command += user; + command += _T(":"); + if (password != nullptr) + command += password; + command += _T(" "); + } + xvt_sys_proxy(proxy); + if (!proxy.IsEmpty()) + { + command += _T("-x "); + command += proxy; + command += _T(" "); + } + command += _T("-T "); + command += local; + command += _T(" "); + command += remote; + command += _T(" -o "); + command += tempresult; + + long retcode = wxExecute(command, res); + + if (retcode == 0) + { + wxFileInputStream res(tempresult); + long long size = wxFileName::GetSize(tempresult).GetValue(); + wxString buffer; + + res.Read(buffer.GetWriteBuf(size), size); + buffer.UngetWriteBuf(); + buffer = buffer.SubString(0, size); + buffer = buffer.Mid(9); + rescode = atoi(buffer.Left(3)); + } + wxRemoveFile(tempresult); + return rescode; +} + /////////////////////////////////////////////////////////// // File system /////////////////////////////////////////////////////////// @@ -1498,7 +1733,21 @@ void xvt_font_unmap(XVT_FNTID font_id) BOOLEAN xvt_fsys_build_pathname(char* mbs, const char* volname, const char* dirname, const char* leafroot, const char* leafext, const char* /* leafvers */) { #ifdef __WXMSW__ - _makepath(mbs, volname, dirname, leafroot, leafext); + if (xvt_is_network_protocol(volname)) + { + char path[MAX_PATH]; + + _makepath(path, nullptr, dirname, leafroot, leafext); + sprintf(mbs, "%s:%s", volname, path); + + const int len = strlen(mbs); + + for (int i = 0; i < len; i++) + if (mbs[i] == '\\') + mbs[i] = '/'; + } + else + _makepath(mbs, volname, dirname, leafroot, leafext); #else *mbs = '\0'; if (dirname && *dirname) @@ -1886,20 +2135,20 @@ void xvt_fsys_set_file_time(const char * file, struct tm * ctime, struct tm * at static bool xvt_sys_ftp_passive_mode(const char* server) { - static char pasv = ' '; - if (pasv <= ' ') - { - char str[16] = ""; - xvt_sys_get_profile_string(xvt_fsys_get_campo_ini(), "Server", "ftp", "Passive", str, sizeof(str)); - pasv = toupper(str[0]); - } - return pasv != 'A'; + static char pasv = ' '; + if (pasv <= ' ') + { + char str[16] = ""; + xvt_sys_get_profile_string(xvt_fsys_get_campo_ini(), "Server", "ftp", "Passive", str, sizeof(str)); + pasv = toupper(str[0]); + } + return pasv != 'A'; } SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs) { wxBusyCursor hourglass; - + wxString ext; SLIST list = xvt_slist_create(); int flags = wxFILE | wxDIR; @@ -1910,9 +2159,12 @@ SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs) } else flags = wxFILE; - + if (flags == wxFILE) + wxSplitPath(pat, NULL, NULL, &ext); + const wxURL url(pat); - if (url.GetScheme() == "ftp") + + if (is_ftp(pat)) { const wxString strHost = url.GetServer(); const wxString strUser = url.GetUser(); @@ -1929,7 +2181,10 @@ SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs) ftp.SetPassword(strPwd); } ftp.SetPassive(xvt_sys_ftp_passive_mode(strHost)); + + int timeout = xvt_sys_timeout(strHost); + ftp.SetTimeout(timeout); const bool bConnected = ftp.Connect(strHost); if (bConnected && ftp.ChDir(fnDir)) { @@ -1937,8 +2192,8 @@ SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs) RemotePath = RemotePath.BeforeLast('/'); wxArrayString files; + ftp.GetList(files, fnName, true); - for (size_t i = 0; i < files.GetCount(); i++) { const int type = files[i][0] == 'd' ? wxDIR : wxFILE; @@ -1946,32 +2201,99 @@ SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs) { wxString f = RemotePath; f << '/' << files[i].AfterLast(' '); wxString size = files[i].Mid(30); - xvt_slist_add_at_elt(list, NULL, f, type == wxFILE ? wxAtol(size) : -1L); + bool bGood = true; + + if (flags == wxFILE && ext.Len() >= 3) + bGood = wxStricmp(ext, size.AfterLast('.')) == 0; + if (bGood) + xvt_slist_add_at_elt(list, NULL, f, type == wxFILE ? wxAtol(size) : -1L); } } } } - else //normale list_files - { - wxString ext; - if (flags == wxFILE) - wxSplitPath(pat, NULL, NULL, &ext); + else + if (is_http(pat)) + { + const wxString strHost = url.GetServer(); + const wxString strUser = url.GetUser(); + const wxString strPwd = url.GetPassword(); + const wxFileName fnPath = url.GetPath(); + const wxString fnDir = fnPath.GetPath(wxPATH_GET_VOLUME, wxPATH_UNIX); + const wxString fnName = fnPath.GetFullName(); + wxHTTP http; - wxString f = ::wxFindFirstFile(pat, flags); - while (!f.IsEmpty()) - { - if (f.StartsWith(".\\") || f.StartsWith("./")) - f = f.Mid(2); + if (!strUser.IsEmpty()) + { + http.SetUser(strUser); + http.SetPassword(strPwd); + } - bool bGood = true; - if (flags == wxFILE && ext.Len() >= 3) - bGood = wxStricmp(ext, f.AfterLast('.')) == 0; - if (bGood) - xvt_slist_add_at_elt(list, NULL, f, 0L); - f = ::wxFindNextFile(); - } - } + int timeout = xvt_sys_timeout(strHost); + http.SetTimeout(timeout); + if (http.Connect(strHost)) + { + wxString RemotePath = pat; + RemotePath = RemotePath.BeforeLast('/'); + RemotePath += _T("/"); + + wxArrayString files; + wxString dir = wxFileName::CreateTempFileName("dir"); + char * result = nullptr; + + int rescode = xvt_http_get(RemotePath, dir, strUser.IsEmpty() ? nullptr : strUser.c_str(), + strPwd.IsEmpty() ? nullptr : strPwd.c_str()); + + wxTextFile fdir(dir); + wxString line; + + fdir.Open(); + for (line = fdir.GetFirstLine(); !fdir.Eof(); line = fdir.GetNextLine()) + { + const int type = line[line.Len() - 1] == '/' ? wxDIR : wxFILE; + + if (type & flags) // Entry type matches desired mask? + { + if (line.Find("
  • = 3) + bGood = wxStricmp(ext, line.AfterLast('.')) == 0; + if (bGood) + { + wxString file = RemotePath; + + file += line; + xvt_slist_add_at_elt(list, nullptr, file, type == wxFILE ? wxAtol(file) : -1L); + } + } + } + } + fdir.Close(); + } + } + else //normale list_files + { + wxString f = ::wxFindFirstFile(pat, flags); + + while (!f.IsEmpty()) + { + if (f.StartsWith(".\\") || f.StartsWith("./")) + f = f.Mid(2); + + bool bGood = true; + + if (flags == wxFILE && ext.Len() >= 3) + bGood = wxStricmp(ext, f.AfterLast('.')) == 0; + if (bGood) + xvt_slist_add_at_elt(list, NULL, f, 0L); + f = ::wxFindNextFile(); + } + } return list; } @@ -1996,140 +2318,272 @@ BOOLEAN xvt_fsys_set_dir(const DIRECTORY *dirp) } BOOLEAN xvt_fsys_fcopy(const char* orig, const char* dest) -{ +{ wxURL orig_url(orig); - - wxInputStream* input = nullptr; const wxString ischeme = orig_url.GetScheme(); + wxFTP iftp; + wxInputStream* input = nullptr; + wxURL dest_url(dest); + const wxString oscheme = dest_url.GetScheme(); + wxFTP oftp; + wxOutputStream* output = nullptr; + wxHTTP ihttp; - if (ischeme == "ftp") + if (is_ftp(orig)) { - wxFTP& ftp = *wxStaticCast(&orig_url.GetProtocol(), wxFTP); const wxString strHost = orig_url.GetServer(); const wxString strUser = orig_url.GetUser(); const wxString strPwd = orig_url.GetPassword(); const wxFileName fnPath = orig_url.GetPath(); const wxString fnDir = fnPath.GetPath(wxPATH_GET_VOLUME, wxPATH_UNIX); const wxString fnName = fnPath.GetFullName(); + int timeout = xvt_sys_timeout(strHost); if (!strUser.IsEmpty()) { - ftp.SetUser(strUser); - ftp.SetPassword(strPwd); + iftp.SetUser(strUser); + iftp.SetPassword(strPwd); } - ftp.SetPassive(xvt_sys_ftp_passive_mode(strHost)); - - if (ftp.Connect(strHost) && ftp.SetBinary() && ftp.ChDir(fnDir)) - input = ftp.GetInputStream(fnName); + iftp.SetPassive(xvt_sys_ftp_passive_mode(strHost)); + iftp.SetTimeout(timeout); + if (iftp.Connect(strHost) && iftp.SetBinary() && iftp.ChDir(fnDir)) + input = iftp.GetInputStream(fnName); } else - if (ischeme == "http") - return false; - /*{ - + if (is_http(orig)) + { const wxString strHost = orig_url.GetServer(); + const short intPort = atoi(dest_url.GetPort()); const wxString strUser = orig_url.GetUser(); const wxString strPwd = orig_url.GetPassword(); const wxFileName fnPath = orig_url.GetPath(); - - wxHTTP http; + int timeout = xvt_sys_timeout(strHost); if (!strUser.IsEmpty()) { - http.SetUser(strUser); - http.SetPassword(strPwd); + ihttp.SetUser(strUser); + ihttp.SetPassword(strPwd); } - http.SetHeader(_T("Content-type"), _T("application/x-www-form-urlencoded")); //remember to define “Content-type: application/x-www-form-urlencoded”, or remote server can’t get your posted data. - wxString PostData("postdata="); - PostData << fnPath.GetFullPath(); - http.SetPostBuffer(PostData); //it’s the data to be posted - if (http.Connect(strHost)) - { - input = http.GetInputStream(_T("/getfile.php")); - if (input != nullptr && http.GetError() != wxPROTO_NOERR) - { - delete input; - input = nullptr; - } - } - }*/ + wxString ContentType = _T("application"); + wxString oext; + + wxSplitPath(dest, nullptr, nullptr, &oext); + if (oext == "xml") + ContentType += _T("xml"); + else + ContentType += _T("octet - stream"); + ihttp.SetHeader(_T("Content-type"), ContentType); //remember to define “Content-type: application/x-www-form-urlencoded”, or remote server can’t get your posted data. + ihttp.SetTimeout(timeout); + wxApp::IsMainLoopRunning(); + if (ihttp.Connect(strHost, intPort)) + input = ihttp.GetInputStream(fnPath.GetFullPath(wxPATH_UNIX)); + } else - input = new wxFileInputStream(orig); - if (input == nullptr) - return false; - - wxURL dest_url(dest); - wxOutputStream* output = NULL; - const wxString scheme = dest_url.GetScheme(); - - if (scheme == "ftp") + input = new wxFileInputStream(orig); + if (input == nullptr) + return false; + if (is_ftp(dest)) { - wxFTP ftp; const wxString strHost = dest_url.GetServer(); const wxString strUser = dest_url.GetUser(); const wxString strPwd = dest_url.GetPassword(); const wxFileName fnPath = dest_url.GetPath(); const wxString fnDir = fnPath.GetPath(wxPATH_GET_VOLUME, wxPATH_UNIX); const wxString fnName = fnPath.GetFullName(); + int timeout = xvt_sys_timeout(strHost); if (!strUser.IsEmpty()) { - ftp.SetUser(strUser); - ftp.SetPassword(strPwd); + oftp.SetUser(strUser); + oftp.SetPassword(strPwd); + } + oftp.SetPassive(xvt_sys_ftp_passive_mode(strHost)); + oftp.SetTimeout(timeout); + if (oftp.Connect(strHost) && oftp.SetBinary() && oftp.ChDir(fnDir)) + { + xvt_fsys_remove_file(dest); + output = oftp.GetOutputStream(fnName); } - ftp.SetPassive(xvt_sys_ftp_passive_mode(strHost)); - - if (ftp.Connect(strHost) && ftp.SetBinary() && ftp.ChDir(fnDir)) - output = ftp.GetOutputStream(fnName); } else - if (scheme == "http") - return false; - /*{ + if (is_http(dest)) + { const wxString strHost = dest_url.GetServer(); + const short intPort = atoi(dest_url.GetPort()); const wxString strUser = dest_url.GetUser(); const wxString strPwd = dest_url.GetPassword(); const wxFileName fnPath = dest_url.GetPath(); - wxHTTP http; + bool ok = false; + wxArrayString res; + wxString tempname = wxFileName::CreateTempFileName("htt"); + wxString tempresult = wxFileName::CreateTempFileName("res"); + wxFileOutputStream temp(tempname); + int size = input->GetSize(); + + input->Read(temp); + temp.Close(); + + int rescode = xvt_http_put(tempname, dest, strUser.IsEmpty() ? nullptr: strUser.c_str(), + strPwd.IsEmpty() ? nullptr : strPwd.c_str()); + + ok = (rescode > 199) && (rescode < 300); + if (is_local(orig) && input != nullptr) + delete input; + return ok; +/* provare sulla 3.3 + int timeout = xvt_sys_timeout(strHost); + int size = input->GetSize(); + wxSocketClient * socket = new wxSocketClient(); + wxString header; + wxString buffer; + wxString data; + wxString oext; + + wxSplitPath(dest, nullptr, nullptr, &oext); + input->Read(buffer, size); + buffer[size] = '\0'; + data << buffer; + delete[]buffer; + +//Set up header +//PUT + header += "PUT "; + header += dest; + header += " HTTP/1.1\n"; +//Write user agent + header += "User-Agent: wxWidget 2.x\n"; +//Write host website name + header += "Host: "; + header += strHost; + header += ":"; + header += wxString::Format("%d", intPort); + header += "\n"; +//Write content type + header += "Content-Type: application"; + if (oext == "xml") + header += "/xml"; + else + header += "/octet - stream"; + header += "\n"; +//Write POST content length + header += "Content-Length: "; + int dlen = data.Len(); + int hlen = header.Len(); + header += wxString::Format("%d", dlen); + header += "\n\n"; +//Print on screen to make sure it looks right + wxMessageBox(header); + header += data; + wxMessageBox(header); + int alllen = header.Len(); +//Connect to host + + wxIPV4address * address = new wxIPV4address(); + + address->Hostname(strHost); + address->Service(intPort); + if (socket->Connect(*address)) + { + //Write header + socket->Write(header.c_str(), header.Len()); + wxMessageBox(wxString::Format("Wrote %d out of %d bytes", socket->LastCount(), header.Len())); + if (socket->Error()) + wxMessageBox(wxString::Format("Errore %d", socket->LastError())); + //Write data +// socket->Write(data.c_str(), data.Len()); +// wxMessageBox(wxString::Format("Wrote %d out of %d bytes", socket->LastCount(), data.Len())); + + //Get Response + wxString buf; + + socket->Read(buf.GetWriteBuf(1000), 1000); + buf.UngetWriteBuf(); + //Trim response to what was read from stream + buf = buf.SubString(0, socket->LastCount() - 1); + buf = buf.Mid(9); + int rescode = atoi(buf.Left(3)); + wxMessageBox(wxString::Format("Read %d bytes: %s", socket->LastCount(), buf)); + ok = (rescode > 199) && (rescode < 300); + } + delete socket; + delete address; + */ +/* provare nella 3.3 + wxHTTP ohttp; if (!strUser.IsEmpty()) { - http.SetUser(strUser); - http.SetPassword(strPwd); + ohttp.SetUser(strUser); + ohttp.SetPassword(strPwd); } - http.SetHeader(_T("Content-type"), _T("application/x-www-form-urlencoded")); //remember to define “Content-type: application/x-www-form-urlencoded”, or remote server can’t get your posted data. - - wxString PostData("postdata="); - - PostData << fnPath.GetFullPath(); - http.SetPostBuffer(PostData); //it’s the data to be posted - if (http.Connect(strHost)) + if (ohttp.Connect(strHost, intPort)) { - output = http.GetResponse(); - if (output != nullptr) && http.GetError() == wxPROTO_NOERR; + wxString PostData; // ("postdata="); + int size = input->GetSize(); + char * buffer = new char[size + 1]; + wxString ofile = fnPath.GetFullPath(wxPATH_UNIX); + + ohttp.SetHeader(_T("POST "), ofile + _T(" HTTP/1.0")); + ohttp.SetHeader(_T("Host:"), strHost); + ohttp.SetHeader(_T("User - Agent:"), _T("HTTPTool / 1.0")); + ohttp.SetHeader(_T("Content-Length:"), wxString::Format("%d", size)); + ohttp.SetHeader(_T("Content-type:"), _T("application/octet-stream")); + input->Read(buffer, size); + buffer[size] = '\0'; + PostData << buffer; + delete[]buffer; +#if wxCHECK_VERSION(3,3,0) + ohttp.SetPostText("text/html;", PostData); //it’s the data to be posted +#else + ohttp.SetPostBuffer(PostData); //it’s the data to be posted +#endif + input = ohttp.GetInputStream(ofile); + + wxProtocolError err = ohttp.GetError(); + + if (input != nullptr) { - wxDELETE(output); - output = nullptr; + wxDELETE(input); + input = nullptr; } - } - } */ - else + if (ohttp.IsConnected()) + ohttp.Close();*/ + if (is_local(orig) && input != nullptr) + delete input; + return ok; +// return err == wxPROTO_NOERR; +// } + } + else output = new wxFileOutputStream(dest); - // } BOOLEAN ok = false; if (input != nullptr && output != nullptr) { - input->Read(*output); + if (is_ftp(dest)) + { + int size = input->GetSize(); + char * buffer = new char[size]; + + input->Read(buffer, size); + output->Write(buffer, size); + delete[]buffer; + } + else + input->Read(*output); wxStreamError err = output->GetLastError(); - ok = (err == wxSTREAM_NO_ERROR); - output->Close(); + ok = output->IsOk(); + output->Close(); + if (iftp.IsConnected()) + iftp.Close(); + if (oftp.IsConnected()) + oftp.Close(); } - if (input != nullptr) - delete input; - if (output != nullptr && scheme != "ftp") + if (is_local(orig) && input != nullptr) + delete input; + if (is_local(dest) && output != nullptr) delete output; return ok; } @@ -3245,15 +3699,16 @@ void xvt_scr_set_focus_vobj(WINDOW win) BOOLEAN xvt_slist_add_at_elt(SLIST list, SLIST_ELT e, const char *sx, long data) { - const BOOLEAN ok = list != NULL; + const BOOLEAN ok = list != nullptr; + if (ok) { SLIST_ELT item = new SLIST_ITEM; item->str = xvt_str_duplicate(sx); item->data = data; - item->next = NULL; + item->next = nullptr; - SLIST_ELT last = NULL; + SLIST_ELT last = nullptr; // if (e != NULL) // Add at head by default (else at tail) // { for (SLIST_ELT i = list->head; i; i = (SLIST_ELT)i->next) @@ -3263,7 +3718,7 @@ BOOLEAN xvt_slist_add_at_elt(SLIST list, SLIST_ELT e, const char *sx, long data) break; } // } - if (last == NULL) + if (last == nullptr) { item->next = list->head; list->head = item; @@ -4087,7 +4542,11 @@ int xvt_fsys_access(const char *pathname, int mode) ftp.SetPassword(strPwd); } ftp.SetPassive(xvt_sys_ftp_passive_mode(strHost)); - return ftp.Connect(strHost) && ftp.ChDir(fnDir) ? 0 : EACCES; + + int timeout = xvt_sys_timeout(strHost); + + ftp.SetTimeout(timeout); + return ftp.Connect(strHost) && ftp.ChDir(fnDir) ? 0 : EACCES; } } SLIST files = xvt_fsys_list_files("", pathname, true); @@ -4146,8 +4605,12 @@ BOOLEAN xvt_fsys_remove_file(const char *pathname) } ftp.SetPassive(xvt_sys_ftp_passive_mode(strHost)); + int timeout = xvt_sys_timeout(strHost); + + ftp.SetTimeout(timeout); if (ftp.Connect(strHost)) if (ftp.ChDir(fnDir)) + if (ftp.FileExists(fnName)) return ftp.RmFile(fnName); return false; } @@ -5038,4 +5501,4 @@ int xvt_dongle_crypt(unsigned short* data) data[2] ^= 0xDEAD; data[3] ^= 0xBEEF; return 0; -} \ No newline at end of file +} diff --git a/src/xvaga01/xvt.h b/src/xvaga01/xvt.h index b8ef95c8e..f4e330e72 100644 --- a/src/xvaga01/xvt.h +++ b/src/xvaga01/xvt.h @@ -47,7 +47,6 @@ extern "C" { #define XVT_INSTALL_DIR 3 #define XVT_TEMP_DIR 4 - #define MAX_TASKS 1024 XVTDLL void xvt_app_allow_quit(void); @@ -192,6 +191,11 @@ XVTDLL void xvt_font_set_style(XVT_FNTID font_id, XVT_FONT_STYLE XVTDLL long xvt_font_serialize(XVT_FNTID font_id, char *buf, long max_buf); XVTDLL void xvt_font_unmap(XVT_FNTID font_id); +XVTDLL BOOLEAN xvt_is_network_protocol(const char *protocol); +XVTDLL int xvt_http_get(const char *remote, const char * local, const char * user, const char * password); +XVTDLL int xvt_http_post(const char *remote, const char * result, const char * content_type, const char * request, const char * user, const char * password); +XVTDLL int xvt_http_put(const char * local, const char *remote, const char * user, const char * password); + XVTDLL BOOLEAN xvt_fsys_build_pathname(char *mbs, const char *volname, const char *dirname, const char *leafroot, const char *leafext, const char *leafvers); XVTDLL BOOLEAN xvt_fsys_convert_dir_to_str(DIRECTORY *dirp, char *path, int sz_path); XVTDLL BOOLEAN xvt_fsys_convert_str_to_dir(const char *path, DIRECTORY *dirp);