1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2009 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
4 // This file must be used under the terms of the CeCILL.
5 // This source file is licensed as described in the file COPYING, which
6 // you should have received as part of this distribution. The terms
7 // are also available at
8 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
12 // Get the configuration of the atoms system
14 function result = atomsGetConfig(field)
15 // Load Atoms Internals lib if it's not already loaded
16 // =========================================================================
17 if ~ exists("atomsinternalslib") then
18 load("SCI/modules/atoms/macros/atoms_internals/lib");
23 // Check number of input arguments
24 // =========================================================================
27 error(msprintf(gettext("%s: Wrong number of input argument: %d to %d expected.\n"),"atomsGetConfig",0,1));
30 // Check input parameters type
31 // =========================================================================
33 if (rhs>0) & (type(field) <> 10) then
34 error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"atomsGetConfig",1));
37 // Check input parameters dimensions
38 // =========================================================================
40 if (rhs>0) & (size(field,"*") <> 1) then
41 error(msprintf(gettext("%s: Wrong size for input argument #%d: Single string expected.\n"),"atomsGetConfig",1));
44 // Define the default value of the result according to the number of input
46 // =========================================================================
54 // Define the path of the file that will record the change
55 // =========================================================================
56 atoms_directory = atomsPath("system","user");
58 // Does the SCIHOME/atoms/config exist, if yes load it
59 // =========================================================================
61 if fileinfo(atoms_directory+"config") <> [] then
62 config_lines = mgetl(atoms_directory+"config");
67 // Loop on each URL specified as input argument
68 // =========================================================================
70 for i=1:size(config_lines,"*")
72 if isempty( stripblanks( config_lines(i) ) ) then
76 if regexp(config_lines(i),"/^[a-zA-Z0-9]*\s=\s/","o") == 1 then
79 current_field_length = regexp(config_lines(i),"/\s=\s/","o")
80 current_field = part(config_lines(i),1:current_field_length-1);
81 current_value = part(config_lines(i),current_field_length+3:length(config_lines(i)));
83 if (rhs==1) & (current_field==field) then
84 result = current_value;
87 result(current_field) = current_value;
91 error(msprintf(gettext("%s: The config file (''%s'') is not well formated at line %d\n"),"atomsGetConfig",atoms_directory+"config",i));