more helper functions added to nxinstall
[public/netxms.git] / src / nxinstall / env.cpp
CommitLineData
3c050e4c
VK
1/*
2** NetXMS - Network Management System
3** NXSL-based installer tool collection
4** Copyright (C) 2005-2011 Victor Kirhenshtein
5**
6** This program is free software; you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation; either version 2 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program; if not, write to the Free Software
18** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19**
20** File: env.cpp
21**
22**/
23
24#include "nxinstall.h"
25
26
27/**
28 * Additional NXSL functions
29 */
30static NXSL_ExtFunction s_nxslInstallerFunctions[] =
31{
32 { _T("access"), F_access, 2 },
c5f180e6
VK
33 { _T("chdir"), F_chdir, 1 },
34 { _T("CopyFile"), F_CopyFile, 2 },
35 { _T("DeleteFile"), F_DeleteFile, 1 },
3c050e4c
VK
36 { _T("fclose"), F_fclose, 1 },
37 { _T("feof"), F_feof, 1 },
38 { _T("fgets"), F_fgets, 1 },
39 { _T("fopen"), F_fopen, -1 },
c5f180e6
VK
40 { _T("fputs"), F_fputs, 2 },
41 { _T("mkdir"), F_mkdir, 1 },
42 { _T("RenameFile"), F_RenameFile, 2 },
43 { _T("rmdir"), F_rmdir, 1 },
44 { _T("system"), F_system, 1 }
3c050e4c
VK
45};
46
47/**
48 * Constructor for installer script environment
49 */
50NXSL_InstallerEnvironment::NXSL_InstallerEnvironment() : NXSL_Environment()
51{
52 setIO(stdin, stdout);
53 registerFunctionSet(sizeof(s_nxslInstallerFunctions) / sizeof(NXSL_ExtFunction), s_nxslInstallerFunctions);
54}
55
56/**
57 * Script trace output
58 */
59void NXSL_InstallerEnvironment::trace(int level, const TCHAR *text)
60{
61 if (level <= g_traceLevel)
62 {
63 _tprintf(_T("%s\n"), text);
64 }
65}