2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
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.1-en.txt
15 #include "api_scilab.h"
17 #include "localization.h"
18 #include "createGraphicObject.h"
19 #include "getGraphicObjectProperty.h"
20 #include "graphicObjectProperties.h"
21 #include "HandleManagement.h"
22 #include "FileExist.h"
23 #include "expandPathVariable.h"
26 int sci_loadGui(char *fname, unsigned long fname_len)
31 char* pstFullFile = NULL;
33 int iRhs = nbInputArgument(pvApiCtx);
35 CheckInputArgument(pvApiCtx, 1, 1);
36 CheckOutputArgument(pvApiCtx, 1, 1);
38 sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
41 printError(&sciErr, 0);
45 if (isStringType(pvApiCtx, piAddr) == 0 || isScalar(pvApiCtx, piAddr) == 0)
47 Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 1);
52 if (getAllocatedSingleString(pvApiCtx, piAddr, &pstFile))
56 freeAllocatedSingleString(pstFile);
59 Scierror(202, _("%s: Wrong type for argument #%d: A string expected.\n"), fname, 1);
63 pstFullFile = expandPathVariable(pstFile);
64 if (!FileExist(pstFullFile))
66 Scierror(999, _("%s: This file %s does not exist.\n"), fname, pstFile);
67 freeAllocatedSingleString(pstFile);
68 freeAllocatedSingleString(pstFullFile);
72 int iFig = xmldomload(pstFullFile);
75 Scierror(999, _("%s: can not read file %s.\n"), fname, pstFile);
76 freeAllocatedSingleString(pstFile);
77 freeAllocatedSingleString(pstFullFile);
81 freeAllocatedSingleString(pstFile);
83 long long h = (long long)getHandle(iFig);
84 createScalarHandle(pvApiCtx, iRhs + 1, h);
85 AssignOutputVariable(pvApiCtx, 1) = iRhs + 1;
86 ReturnArguments(pvApiCtx);