/*
** SellaNMS
** $Id: check.cxx,v 1.10 2005/11/25 02:57:47 sella Exp $
** Copyright (c) 2001-2005 Digital Genesis Software, LLC. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

static const char rcsid[] = "$Id: check.cxx,v 1.10 2005/11/25 02:57:47 sella Exp $";

#include "check.h"
#include <stdio.h>

void getLibrary(int &library) {
	library = LIBRARY_STORAGE;
}

void check(RESULT &result, ConfigNode *config) {
	const int table_count = 24;

	Storage storage;
	StorageData data;

	char buf[132];
	char tables[table_count][64] = {
		"connection",
		"connection_data",
		"connection_point",
		"output",
		"gui_event",
		"gui_history",
		"gui_event_message",
		"discovery_icmp",
		"discovery_snmp_oid",
		"gui_view",
		"gui_channel_assoc",
		"gui_channel",
		"gui_user",
		"gui_user_prefs",
		"element",
		"element_data",
		"element_attr",
		"interface",
		"interface_data",
		"interface_attr",
		"ip",
		"ip_data",
		"ip_attr"
	};

	if ((result = storage.setConfig(*config)) == SUCCESS) {
		for (int x = 0; x < table_count; x++) {
			snprintf(buf, 132, "SELECT COUNT(*) FROM %s", tables[x]);
			if ((result = storage.query(data, buf)) != SUCCESS) {
				LMSG("ERROR: Table %s is missing from the database.", tables[x]);
				return;
			}
		}
	}
}

/*
** Local Variables:
** c-basic-offset: 3
** tab-width: 3
** End:
** vim600: fdm=marker
** vim: noet ts=3 sw=3
*/
