Commit 5c70d631 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

linux work version

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63894 954022d7-b5bf-4e40-9824-e11837661b57
parent d14fd358
......@@ -38,7 +38,7 @@ int CHtmlFile::Convert(const std::wstring& sXml, const std::wstring& sPathIntern
std::wstring sTempFileForParams = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"XML");
NSFile::CFileBinary oFile;
oFile.CreateFile(sTempFileForParams);
oFile.CreateFileW(sTempFileForParams);
oFile.WriteStringUTF8(sXml, true);
oFile.CloseFile();
......@@ -74,17 +74,17 @@ int CHtmlFile::Convert(const std::wstring& sXml, const std::wstring& sPathIntern
#endif
#ifdef LINUX
std::wstring sTempFileForParams = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"XML");
NSFile::CFileBinary oFile;
oFile.CreateFileW(sTempFileForParams);
oFile.WriteStringUTF8(sXml, true);
oFile.CloseFile();
pid_t pid = fork(); // create child process
int status;
std::string sProgramm = U_TO_UTF8(sInternal);
std::string sXmlA = "";
if (!sXml.empty())
sXmlA = U_TO_UTF8(sXml);
FILE* f = fopen("/home/oleg/a.txt", "a+");
fprintf(f, "HtmlCodeAfterFork\n");
fclose(f);
std::string sXmlA = "<html>" + U_TO_UTF8(sTempFileForParams);
switch (pid)
{
......@@ -93,7 +93,22 @@ int CHtmlFile::Convert(const std::wstring& sXml, const std::wstring& sPathIntern
case 0: // child process
{
execl(sProgramm.c_str(), sXmlA.empty() ? NULL : sXmlA.c_str(), 0); // run the command
std::string sLibraryDir = sProgramm;
if (std::string::npos != sProgramm.find_last_of('/'))
sLibraryDir = "LD_LIBRARY_PATH=" + sProgramm.substr(0, sProgramm.find_last_of('/'));
const char* nargs[2];
nargs[0] = sXmlA.c_str();
nargs[1] = NULL;
const char* nenv[3];
nenv[0] = sLibraryDir.c_str();
nenv[1] = "DISPLAY=:0";
nenv[2] = NULL;
execve(sProgramm.c_str(),
(char * const *)nargs,
(char * const *)nenv);
exit(EXIT_SUCCESS);
break;
}
......@@ -107,5 +122,6 @@ int CHtmlFile::Convert(const std::wstring& sXml, const std::wstring& sPathIntern
}
#endif
NSFile::CFileBinary::Remove(sTempFileForParams);
return nReturnCode;
}
......@@ -3,9 +3,8 @@
int main(int argc, char *argv[])
{
std::wstring sPath = NSFile::GetProcessDirectory() + L"/../../Internal/Debug/";
CHtmlFile oFile;
#if 0
std::wstring sPath = NSFile::GetProcessDirectory() + L"/../../Internal/windows/Debug/";
std::wstring sXml = L"\
<html>\
......@@ -14,7 +13,19 @@ int main(int argc, char *argv[])
<destination>D:/test/Document/</destination>\
</html>\
";
#else
std::wstring sPath = NSFile::GetProcessDirectory() + L"/../../Internal/linux/Debug/";
std::wstring sXml = L"\
<html>\
<sdk>file:///home/oleg/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb/Word/sdk-all.js</sdk>\
<file>file:///home/oleg/activex/test.html</file>\
<destination>/home/oleg/activex/1/</destination>\
</html>\
";
#endif
CHtmlFile oFile;
int nResult = oFile.Convert(sXml, sPath);
nResult;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment