2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2011 - DIGITEO - Calixte DENIZET
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13 #include "ScilabPreferences.hxx"
14 #include "GiwsException.hxx"
18 #include "gw_preferences.h"
21 #include "api_scilab.h"
22 #include "localization.h"
23 #include "getScilabJavaVM.h"
24 #include "expandPathVariable.h"
28 using namespace org_scilab_modules_preferences;
30 /*--------------------------------------------------------------------------*/
31 int sci_addModulePreferences(char * fname, unsigned long fname_len)
37 char * expTbxPath = 0;
38 char * tbxPrefFile = 0;
39 char * expTbxPrefFile = 0;
40 char ** array[] = {&tbxName, &tbxPath, &tbxPrefFile};
46 for (int i = 0; i < Rhs; i++)
48 err = getVarAddressFromPosition(pvApiCtx, i + 1, &addr);
55 if (!isStringType(pvApiCtx, addr))
57 Scierror(999, gettext("%s: Wrong type for input argument #%i: A string expected.\n"), fname, i + 1);
58 for (int j = 0; j < i; j++)
62 freeAllocatedSingleString(*(array[j]));
68 getAllocatedSingleString(pvApiCtx, addr, array[i]);
71 expTbxPath = expandPathVariable(const_cast<char *>(tbxPath));
72 expTbxPrefFile = expandPathVariable(const_cast<char *>(tbxPrefFile));
76 ScilabPreferences::addToolboxInfos(getScilabJavaVM(), tbxName, expTbxPath, expTbxPrefFile);
78 catch (const GiwsException::JniException & e)
80 Scierror(999, _("%s: A Java exception arised:\n%s"), fname, e.what());
84 for (int i = 0; i < Rhs; i++)
88 freeAllocatedSingleString(*(array[i]));
102 /*--------------------------------------------------------------------------*/