2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2011 - DIGITEO - Calixte DENIZET
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
7 * This file is hereby licensed under the terms of the GNU GPL v2.0,
8 * pursuant to article 5.3.4 of the CeCILL v.2.1.
9 * This file was originally licensed under the terms of the CeCILL v2.1,
10 * and continues to be available under such terms.
11 * For more information, see the COPYING file which you should have received
12 * along with this program.
16 #include "ScilabPreferences.hxx"
17 #include "GiwsException.hxx"
18 #include "preferences_gw.hxx"
23 #include "api_scilab.h"
24 #include "localization.h"
25 #include "getScilabJavaVM.h"
26 #include "expandPathVariable.h"
27 #include "sci_malloc.h"
30 using namespace org_scilab_modules_preferences;
32 /*--------------------------------------------------------------------------*/
33 int sci_addModulePreferences(char * fname, void *pvApiCtx)
39 char * expTbxPath = 0;
40 char * tbxPrefFile = 0;
41 char * expTbxPrefFile = 0;
42 char ** array[] = {&tbxName, &tbxPath, &tbxPrefFile};
48 for (int i = 0; i < Rhs; i++)
50 err = getVarAddressFromPosition(pvApiCtx, i + 1, &addr);
57 if (!isStringType(pvApiCtx, addr))
59 Scierror(999, gettext("%s: Wrong type for input argument #%i: string expected.\n"), fname, i + 1);
60 for (int j = 0; j < i; j++)
64 freeAllocatedSingleString(*(array[j]));
70 if (getAllocatedSingleString(pvApiCtx, addr, array[i]))
76 expTbxPath = expandPathVariable(const_cast<char *>(tbxPath));
77 expTbxPrefFile = expandPathVariable(const_cast<char *>(tbxPrefFile));
81 ScilabPreferences::addToolboxInfos(getScilabJavaVM(), tbxName, expTbxPath, expTbxPrefFile);
83 catch (const GiwsException::JniException & e)
85 Scierror(999, "%s: %s", fname, e.getJavaDescription().c_str());
86 for (int i = 0; i < Rhs; i++)
90 freeAllocatedSingleString(*(array[i]));
99 for (int i = 0; i < Rhs; i++)
103 freeAllocatedSingleString(*(array[i]));
107 FREE(expTbxPrefFile);
114 /*--------------------------------------------------------------------------*/