minor changes
authorVictor Kirhenshtein <victor@netxms.org>
Sun, 15 Feb 2009 13:56:28 +0000 (13:56 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Sun, 15 Feb 2009 13:56:28 +0000 (13:56 +0000)
src/server/tools/nxdbmgr/Makefile.am
src/server/tools/nxdbmgr/clear.cpp [new file with mode: 0644]
src/server/tools/nxdbmgr/import.cpp [new file with mode: 0644]
src/server/tools/nxdbmgr/nxdbmgr.cpp
src/server/tools/nxdbmgr/nxdbmgr.h
src/server/tools/nxdbmgr/nxdbmgr.vcproj

index bce7b25..dbd5bef 100644 (file)
@@ -1,8 +1,10 @@
 INCLUDES=-I@top_srcdir@/include -I@top_srcdir@/src/server/include
 
 bin_PROGRAMS = nxdbmgr
-nxdbmgr_SOURCES = nxdbmgr.cpp check.cpp export.cpp init.cpp reindex.cpp unlock.cpp upgrade.cpp
-nxdbmgr_LDADD = ../../../libnetxms/libnetxms.la ../../libnxsrv/libnxsrv.la ../../../libnxsnmp/libnxsnmp.la
+nxdbmgr_SOURCES = nxdbmgr.cpp check.cpp clear.cpp export.cpp import.cpp \
+                  init.cpp reindex.cpp unlock.cpp upgrade.cpp
+nxdbmgr_LDADD = ../../../libnetxms/libnetxms.la ../../libnxsrv/libnxsrv.la \
+                ../../../libnxsnmp/libnxsnmp.la
 
 EXTRA_DIST = \
        nxdbmgr.vcproj nxdbmgr.h
diff --git a/src/server/tools/nxdbmgr/clear.cpp b/src/server/tools/nxdbmgr/clear.cpp
new file mode 100644 (file)
index 0000000..5137ab5
--- /dev/null
@@ -0,0 +1,37 @@
+/* 
+** nxdbmgr - NetXMS database manager
+** Copyright (C) 2004-2009 Victor Kirhenshtein
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: clear.cpp
+**
+**/
+
+#include "nxdbmgr.h"
+
+
+//
+// Clear database
+//
+
+BOOL ClearDatabase()
+{
+       printf("WARNING!!!\nThis operation will clear all configuration and collected data from database.\nAre you sure (y/N)?");
+       if (!GetYesNo())
+               return FALSE;
+
+       return TRUE;
+}
diff --git a/src/server/tools/nxdbmgr/import.cpp b/src/server/tools/nxdbmgr/import.cpp
new file mode 100644 (file)
index 0000000..7c62c5f
--- /dev/null
@@ -0,0 +1,35 @@
+/* 
+** nxdbmgr - NetXMS database manager
+** Copyright (C) 2004-2009 Victor Kirhenshtein
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: import.cpp
+**
+**/
+
+#include "nxdbmgr.h"
+#include "sqlite3.h"
+
+
+//
+// Import database
+//
+
+void ImportDatabase(const char *file)
+{
+       if (!ClearDatabase())
+               return;
+}
index b9bb22b..3ce7bbf 100644 (file)
@@ -632,6 +632,8 @@ int main(int argc, char *argv[])
          ReindexDatabase();
       else if (!strcmp(argv[optind], "export"))
          ExportDatabase(argv[optind + 1]);
+      else if (!strcmp(argv[optind], "import"))
+         ImportDatabase(argv[optind + 1]);
    }
 
    // Shutdown
index cf601c0..7c940c8 100644 (file)
@@ -56,7 +56,9 @@
 void CheckDatabase();
 void InitDatabase(const TCHAR *pszInitFile);
 void ReindexDatabase();
+BOOL ClearDatabase();
 void ExportDatabase(const char *file);
+void ImportDatabase(const char *file);
 void UpgradeDatabase();
 void UnlockDatabase();
 DB_RESULT SQLSelect(const TCHAR *pszQuery);
index 55f1c3b..0b0c079 100644 (file)
                                RelativePath=".\check.cpp"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\clear.cpp"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath=".\export.cpp"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\import.cpp"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath=".\init.cpp"\r
                                >\r