# Find is necessary because of subdirs...
-@echo "-- Cleaning macros (*.bin) --"; \
find $(top_builddir) -name "*.bin" | xargs --no-run-if-empty rm 2> /dev/null; \
- echo "-- Cleaning names files (names) --"; \
- find $(top_builddir)/modules/*/macros -name "names" | xargs --no-run-if-empty rm 2> /dev/null; \
echo "-- Cleaning lib files (lib) --"; \
find $(top_builddir)/modules/*/macros -name "lib" | xargs --no-run-if-empty rm 2> /dev/null
# Find is necessary because of subdirs...
-@echo "-- Cleaning macros (*.bin) --"; \
find $(top_builddir) -name "*.bin" | xargs --no-run-if-empty rm 2> /dev/null; \
- echo "-- Cleaning names files (names) --"; \
- find $(top_builddir)/modules/*/macros -name "names" | xargs --no-run-if-empty rm 2> /dev/null; \
echo "-- Cleaning lib files (lib) --"; \
find $(top_builddir)/modules/*/macros -name "lib" | xargs --no-run-if-empty rm 2> /dev/null
{
#endif
- /* Initialize the algorithm. */
- void md5_init(md5_state_t *pms);
+/* Initialize the algorithm. */
+void md5_init(md5_state_t *pms);
- /* Append a string to the message. */
- void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
+/* Append a string to the message. */
+void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
- /* Finish the message and return the digest. */
- void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
+/* Finish the message and return the digest. */
+void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
- char *md5_file(FILE *fp);
+char *md5_file(FILE *fp);
- char *md5_str(char *p);
+char *md5_str(char *p);
#ifdef __cplusplus
} /* end extern "C" */
<ClInclude Include="..\..\includes\islittleendian.h" />
<ClInclude Include="..\..\includes\loadversion.h" />
<ClInclude Include="..\..\includes\machine.h" />
+ <ClInclude Include="..\..\includes\md5.h" />
<ClInclude Include="..\..\includes\sci_malloc.h" />
<ClInclude Include="..\..\includes\PARAMS.h" />
<ClInclude Include="..\..\includes\PATH_MAX.h" />
<ClInclude Include="getstaticdebuginfo.h" />
<ClInclude Include="getstaticDebugInfo_Windows.h" />
<ClInclude Include="gw_dynamic_generic.h" />
- <ClInclude Include="md5.h" />
<ClInclude Include="saveCWDInPreferences.h" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="gw_dynamic_generic.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="md5.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="..\cpp\partition.hxx">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\includes\InitializePreferences.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\includes\md5.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\core.iss" />
@rem Allan CORNET INRIA 2006
@cd ..\..\..\
@del lib /s 2>NUL
- @del *.moc /s 2>NUL
+ @del *.bin /s 2>NUL
chdir ("SCI/modules");
if getos() == "Windows" then
+ dos("del *.bin /s 2>NUL","-echo");
dos("del lib /s 2>NUL","-echo");
+ dos("del names /s 2>NUL","-echo");
dos("del *.moc /s 2>NUL","-echo");
else
+ unix("rm -Rf *.bin");
unix("rm -Rf lib");
+ unix("rm -Rf names");
+ unix("rm -Rf *.moc");
end
chdir (CurrentDirectory);
#include "dynlib_io.h"
#include "library.hxx"
-IO_IMPEXP types::Library* loadlib(const std::wstring& _wstXML, int* ierr, bool _isFile = true, bool _bAddInContext = true);
+struct MacroInfo
+{
+ MacroInfo() {} //needed by unordered_map
+ MacroInfo(const std::wstring& _name, const std::wstring& _file, const std::wstring& _md5) :
+ name(_name),
+ file(_file),
+ md5(_md5) {}
+ std::wstring name;
+ std::wstring file;
+ std::wstring md5;
+};
+typedef std::unordered_map<std::wstring, MacroInfo> MacroInfoList;
+IO_IMPEXP types::Library* loadlib(const std::wstring& _wstXML, int* ierr, bool _isFile = true, bool _bAddInContext = true);
+IO_IMPEXP int parseLibFile(const std::wstring& _wstXML, MacroInfoList& info, std::wstring& libname);
#endif /* !__LOADLIB_H__ */
\ No newline at end of file
#include "library.hxx"
#include "macrofile.hxx"
#include "serializervisitor.hxx"
+#include "loadlib.hxx"
extern "C"
{
#include "freeArrayOfString.h"
#include "Scierror.h"
#include "scicurdir.h"
-
+#include "md5.h"
}
xmlTextWriterPtr openXMLFile(const wchar_t *_pstFilename, const wchar_t* _pstLibName);
void closeXMLFile(xmlTextWriterPtr _pWriter);
-bool AddMacroToXML(xmlTextWriterPtr _pWriter, pair<wstring, wstring> _pair);
+bool AddMacroToXML(xmlTextWriterPtr _pWriter, const wstring& name, const wstring& file, const wstring& md5);
using namespace types;
ConfigVariable::setPromptMode(oldVal);
}
+ MacroInfoList lstOld;
if (FileExistW(pstParseFile))
{
+ //read it to get previous information like md5
+ std::wstring libname;
+ parseLibFile(pstParseFile, lstOld, libname);
deleteafileW(pstParseFile);
}
wstring pstPathBin(pstPath[k]);
pstPathBin.replace(pstPathBin.end() - 3, pstPathBin.end(), L"bin");
+ //compute file md5
+ FILE* fmdf5 = os_wfopen(stFullPath.data(), L"rb");
+ char* md5 = md5_file(fmdf5);
+ fclose(fmdf5);
+
+ wchar_t* wmd5 = to_wide_string(md5);
+ FREE(md5);
+ std::wstring wide_md5(wmd5);
+ FREE(wmd5);
+
+ //check if is exist in old file
+
+ MacroInfoList::iterator it = lstOld.find(pstPathBin);
+ if (it != lstOld.end())
+ {
+ if (wide_md5 == (*it).second.md5)
+ {
+ //file not change, we can skip it
+ AddMacroToXML(pWriter, (*it).second.name, pstPathBin, wide_md5);
+ pLib->add((*it).second.name, new types::MacroFile((*it).second.name, stFullPathBin, pstLibName));
+ continue;
+ }
+ }
+
if (bVerbose)
{
sciprint(_("%ls: Processing file: %ls\n"), L"genlib", pstPath[k]);
const wstring& name = pFD->getSymbol().getName();
if (name + L".sci" == pstPath[k])
{
- if (AddMacroToXML(pWriter, pair<wstring, wstring>(name, pstPathBin)) == false)
+ if (AddMacroToXML(pWriter, name, pstPathBin, wide_md5) == false)
{
os_swprintf(pstVerbose, 65535, _W("%ls: Warning: %ls information cannot be added to file %ls. File ignored\n").c_str(), L"genlib", pFD->getSymbol().getName().c_str(), pstPath[k]);
scilabWriteW(pstVerbose);
return pWriter;
}
-bool AddMacroToXML(xmlTextWriterPtr _pWriter, pair<wstring, wstring> _pair)
+bool AddMacroToXML(xmlTextWriterPtr _pWriter, const wstring& name, const wstring& file, const wstring& md5)
{
int iLen;
}
//Add attribute "name"
- char* pstFirst = wide_string_to_UTF8(_pair.first.c_str());
- iLen = xmlTextWriterWriteAttribute(_pWriter, (xmlChar*)"name", (xmlChar*)pstFirst);
+ char* pst1 = wide_string_to_UTF8(name.data());
+ iLen = xmlTextWriterWriteAttribute(_pWriter, (xmlChar*)"name", (xmlChar*)pst1);
if (iLen < 0)
{
return false;
}
- FREE(pstFirst);
+ FREE(pst1);
//Add attribute "file"
- char* pstSecond = wide_string_to_UTF8(_pair.second.c_str());
- iLen = xmlTextWriterWriteAttribute(_pWriter, (xmlChar*)"file", (xmlChar*)pstSecond);
+ char* pst2 = wide_string_to_UTF8(file.data());
+ iLen = xmlTextWriterWriteAttribute(_pWriter, (xmlChar*)"file", (xmlChar*)pst2);
if (iLen < 0)
{
return false;
}
- FREE(pstSecond);
+ FREE(pst2);
+
+ //Add attribute "md5"
+ char* pst3 = wide_string_to_UTF8(md5.data());
+ iLen = xmlTextWriterWriteAttribute(_pWriter, (xmlChar*)"md5", (xmlChar*)pst3);
+ if (iLen < 0)
+ {
+ return false;
+ }
+ FREE(pst3);
//close "macro" node
iLen = xmlTextWriterEndElement(_pWriter);
{
return false;
}
+
return true;
}
if (_isFile)
{
+ //remove / or \ at the end
size_t pos = wstPath.find_last_of(L"/\\");
wstPath = wstPath.substr(0, pos);
pos = wstOriginalPath.find_last_of(L"/\\");
wstFile += L"lib";
}
- char* pstFile = wide_string_to_UTF8(wstFile.c_str());
+
+ std::wstring libname;
+ MacroInfoList lst;
+ *err = parseLibFile(wstFile, lst, libname);
+ if (*err)
+ {
+ return lib;
+ }
+
+ lib = new types::Library(wstOriginalPath);
+
+ std::wstring stFilename(wstPath);
+ if (stFilename.empty() == false && *stFilename.rbegin() != DIR_SEPARATORW[0])
+ {
+ stFilename += DIR_SEPARATORW;
+ }
+
+
+ for (const auto& macro : lst)
+ {
+ lib->add(macro.second.name, new types::MacroFile(macro.second.name, stFilename + macro.second.file, libname));
+ }
+
+
+ if (_bAddInContext)
+ {
+ symbol::Context* ctx = symbol::Context::getInstance();
+ symbol::Symbol sym = symbol::Symbol(libname);
+ if (ctx->isprotected(sym) == false)
+ {
+ ctx->put(sym, lib);
+ }
+ else
+ {
+ *err = 2;
+ delete lib;
+ lib = NULL;
+ }
+ }
+
+ return lib;
+}
+
+int parseLibFile(const std::wstring& _wstXML, MacroInfoList& info, std::wstring& libname)
+{
+ info.clear();
+
+ char* pstFile = wide_string_to_UTF8(_wstXML.data());
if (FileExist(pstFile) == FALSE)
{
- *err = 1;
FREE(pstFile);
- return NULL;
+ return 1;
}
char *encoding = GetXmlFileEncoding(pstFile);
/* check if the XML file has been encoded with utf8 (unicode) or not */
if (stricmp("utf-8", encoding))
{
- *err = 1;
FREE(pstFile);
free(encoding);
return NULL;
}
xmlDocPtr doc;
- xmlXPathContextPtr xpathCtxt = NULL;
- xmlXPathObjectPtr xpathObj = NULL;
- wchar_t* pstName = NULL;
- wchar_t* pstLibName = NULL;
- wchar_t* pstFileName = NULL;
+ xmlXPathContextPtr xpathCtxt = NULL;
+ xmlXPathObjectPtr xpathObj = NULL;
+ wchar_t* pstName = NULL;
+ wchar_t* pstLibName = NULL;
+ wchar_t* pstFileName = NULL;
+ wchar_t* pstMd5 = NULL;
free(encoding);
if (doc == NULL)
{
- *err = 1;
- //std::cout << "Error: Could not parse file " << pstFile << std::endl;
FREE(pstFile);
- return NULL;
+ return 1;
}
FREE(pstFile);
- lib = new types::Library(wstOriginalPath);
-
xpathCtxt = xmlXPathNewContext(doc);
xpathObj = xmlXPathEval((const xmlChar*)"//scilablib", xpathCtxt);
if (xpathObj && xpathObj->nodesetval->nodeMax)
{
xmlAttrPtr attrib = xpathObj->nodesetval->nodeTab[0]->properties;
- if (xmlStrEqual (attrib->name, (const xmlChar*)"name"))
+ if (xmlStrEqual(attrib->name, (const xmlChar*)"name"))
{
/* we found the tag name */
const char *str = (const char*)attrib->children->content;
pstLibName = to_wide_string(str);
+ libname = pstLibName;
+ FREE(pstLibName);
xmlXPathFreeObject(xpathObj);
}
else
xmlXPathFreeContext(xpathCtxt);
}
xmlXPathFreeObject(xpathObj);
- delete lib;
- return NULL;
+ return 1;
}
}
if (xpathObj && xpathObj->nodesetval->nodeMax)
{
/* the Xpath has been understood and there are node */
- for (int i = 0 ; i < xpathObj->nodesetval->nodeNr ; i++)
+ for (int i = 0; i < xpathObj->nodesetval->nodeNr; i++)
{
xmlAttrPtr attrib = xpathObj->nodesetval->nodeTab[i]->properties;
/* Get the properties of <module> */
while (attrib != NULL)
{
/* loop until when have read all the attributes */
- if (xmlStrEqual (attrib->name, (const xmlChar*)"name"))
+ if (xmlStrEqual(attrib->name, (const xmlChar*)"name"))
{
/* we found the tag name */
const char *str = (const char*)attrib->children->content;
const char *str = (const char*)attrib->children->content;
pstFileName = to_wide_string(str);
}
+ else if (xmlStrEqual(attrib->name, (const xmlChar*)"md5"))
+ {
+ /* we found the tag activate */
+ const char *str = (const char*)attrib->children->content;
+ pstMd5 = to_wide_string(str);
+ }
attrib = attrib->next;
}
- if (pstName && pstFileName)
+ if (pstName && pstFileName && pstMd5)
{
- std::wstring stFilename(wstPath);
- if (stFilename.empty() == false && *stFilename.rbegin() != DIR_SEPARATORW[0])
- {
- stFilename += DIR_SEPARATORW;
- }
-
- stFilename += pstFileName;
- lib->add(pstName, new types::MacroFile(pstName, stFilename, pstLibName));
+ info[pstFileName] = MacroInfo(pstName, pstFileName, pstMd5);
}
if (pstName)
FREE(pstFileName);
pstFileName = NULL;
}
+
+ if (pstMd5)
+ {
+ FREE(pstMd5);
+ pstMd5 = NULL;
+ }
}
}
xmlXPathFreeContext(xpathCtxt);
}
- if (_bAddInContext)
- {
- symbol::Context* ctx = symbol::Context::getInstance();
- symbol::Symbol sym = symbol::Symbol(pstLibName);
- if (ctx->isprotected(sym) == false)
- {
- ctx->put(symbol::Symbol(pstLibName), lib);
- }
- else
- {
- *err = 2;
- delete lib;
- lib = NULL;
- }
- }
-
xmlFreeDoc(doc);
- FREE(pstLibName);
- return lib;
+ return 0;
}
static char *GetXmlFileEncoding(std::string _filename)
+++ /dev/null
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) INRIA
-//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution. The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
-function N=%r_i_hm(varargin)
- //author Serge Steer INRIA
- M=varargin($);
- N=varargin($-1);//inserted matrix
- // M(i,...)=N
- Den=ones(M);
- M(varargin(1:$-2))=N.num
- Den(varargin(1:$-2))=N.den
- N.num=M
- N.den=Den
-
-endfunction
+++ /dev/null
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) INRIA, Serge Steer
-//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution. The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
-
-function r=%p_o_st(a,b)
- // implements r=a==b
- // for a a matrix of polynomials and b a struct
- r=%f
-endfunction
+++ /dev/null
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) INRIA
-//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution. The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
-function N=%r_i_hm(varargin)
- //author Serge Steer INRIA
- M=varargin($);
- N=varargin($-1);//inserted matrix
- // M(i,...)=N, M hypermatrix; N rational matrix
- Num=M;
- Den=ones(M);
- Num(varargin(1:$-2))=N.num
- Den(varargin(1:$-2))=N.den
-
- N.num=Num;
- N.den=Den;
-endfunction
+++ /dev/null
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) INRIA, Serge Steer
-//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution. The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
-
-function r=%st_o_l(a,b)
- // implements r=a==b
- // for a a struct and b a list
- r=%f
-endfunction
function [ok,a_domaine,b_domaine,discr,signe,choix,type_meth,degre,Nbr_maillage,..
CI,CI1,CLa_type,CLa_exp,CLb_type,CLb_exp,oper,a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,..
- a6,b6,a7,b7,k,mesures,params_pde]=setvalue_IHM_EDP(params_pde)
+ a6,b6,a7,b7,k,mesures,params_pde]=setvalue_IHM_PDE(params_pde)
// Cette fonction permet d'evaluer les parametres de l'IHM suite au l'evaluation du context //
// Entree : //
// - params_pde (tlist) : rajouter a la list exprs du bloc EDP afin de sauvegarder les //