dvander@370: /**
ds@653: * vim: set ts=4 :
ds@1330: * =============================================================================
dvander@1231: * SourceMod
ds@1947: * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
ds@1330: * =============================================================================
dvander@370: *
ds@1330: * This program is free software; you can redistribute it and/or modify it under
ds@1330: * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330: * Free Software Foundation.
dvander@1231: *
ds@1330: * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
ds@1330: * details.
dvander@1231: *
ds@1330: * You should have received a copy of the GNU General Public License along with
ds@1330: * this program. If not, see .
dvander@1231: *
ds@1330: * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330: * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330: * by the Valve Corporation. You must obey the GNU General Public License in
ds@1330: * all respects for all other code used. Additionally, AlliedModders LLC grants
ds@1330: * this exception to all derivative works. AlliedModders LLC defines further
ds@1330: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330: * or .
dvander@370: *
dvander@370: * Version: $Id$
dvander@370: */
dvander@370:
dvander@203: #ifndef _INCLUDE_SOURCEMOD_CORE_SYSTEM_PLUGININFODATABASE_H_
dvander@203: #define _INCLUDE_SOURCEMOD_CORE_SYSTEM_PLUGININFODATABASE_H_
dvander@203:
dvander@203: /**
dvander@203: * This file parses plugin_settings.cfg and stores the information in cached memory.
dvander@203: * It provides simplistic abstraction to retrieving the info.
dvander@203: * :TODO: currently untested
dvander@203: */
dvander@203:
dvander@203: #include "sm_memtable.h"
dvander@203: #include "ITextParsers.h"
dvander@203: #include "IPluginSys.h"
dvander@203: #include "sm_globals.h"
dvander@203:
dvander@203: struct PluginOpts
dvander@203: {
dvander@203: int key;
dvander@203: int val;
dvander@203: };
dvander@203:
dvander@203: struct PluginSettings
dvander@203: {
dvander@203: void Init();
dvander@203: int name;
dvander@203: bool pause_val;
dvander@203: PluginType type_val;
dvander@203: int optarray;
dvander@203: size_t opts_num;
dvander@203: size_t opts_size;
dvander@1436: bool blockload_val;
dvander@203: };
dvander@203:
dvander@203: class CPluginInfoDatabase : public ITextListener_SMC
dvander@203: {
dvander@203: public:
dvander@203: CPluginInfoDatabase();
dvander@203: ~CPluginInfoDatabase();
dvander@203: public: //ITextListener_SMC
dvander@203: void ReadSMC_ParseStart();
dvander@1656: SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name);
dvander@1656: SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value);
dvander@1656: SMCResult ReadSMC_LeavingSection(const SMCStates *states);
dvander@203: public:
dvander@203: /**
dvander@203: * Returns the number of plugin settings available.
dvander@203: */
dvander@203: unsigned int GetSettingsNum();
dvander@203:
dvander@203: /**
dvander@203: * Given an index, returns the plugin settings block if the filename matches.
dvander@203: * Otherwise, returns NULL.
dvander@203: */
dvander@203: PluginSettings *GetSettingsIfMatch(unsigned int index, const char *filename);
dvander@203:
dvander@203: /**
dvander@203: * Given a plugin settings struct and an index,
dvander@203: * returns the given JIT key/value option pair at that index.
dvander@203: * If the input is invalid, key and val will be set to NULL.
dvander@203: */
dvander@203: void GetOptionsForPlugin(PluginSettings *settings, unsigned int opt_num, const char **key, const char **val);
dvander@203: private:
dvander@1656: SMCResult MakeError(const char *fmt, ...);
dvander@203: private:
dvander@203: BaseStringTable *m_strtab;
dvander@203: int m_errmsg;
dvander@203: bool in_plugins;
dvander@203: bool in_options;
dvander@351: int m_infodb;
dvander@203: size_t m_infodb_count;
dvander@203: size_t m_infodb_size;
dvander@203: int cur_plugin;
dvander@203: };
dvander@203:
dvander@203:
dvander@203: #endif //_INCLUDE_SOURCEMOD_CORE_SYSTEM_PLUGININFODATABASE_H_