2 * ===============================================================
3 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
4 * ===============================================================
6 * This file is part of the SourceMod/SourcePawn SDK. This file may only be
7 * used or modified under the Terms and Conditions of its License Agreement,
8 * which is found in public/licenses/LICENSE.txt. As of this notice, derivative
9 * works must be licensed under the GNU General Public License (version 2 or
10 * greater). A copy of the GPL is included under public/licenses/GPL.txt.
12 * To view the latest information, see: http://www.sourcemod.net/license.php
17 #ifndef _INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
18 #define _INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
22 * @brief Defines miscellanious helper functions useful to extensions.
25 #include <IShareSys.h>
26 #include <sp_vm_api.h>
27 #include <IDataPack.h>
29 #define SMINTERFACE_SOURCEMOD_NAME "ISourceMod"
30 #define SMINTERFACE_SOURCEMOD_VERSION 1
35 * @brief Describes various ways of formatting a base path.
39 Path_None = 0, /**< No base path */
40 Path_Game, /**< Base path is absolute mod folder */
41 Path_SM, /**< Base path is absolute to SourceMod */
42 Path_SM_Rel, /**< Base path is relative to SourceMod */
46 * @brief Contains miscellaneous helper functions.
48 class ISourceMod : public SMInterface
51 virtual const char *GetInterfaceName()
53 return SMINTERFACE_SOURCEMOD_NAME;
55 virtual unsigned int GetInterfaceVersion()
57 return SMINTERFACE_SOURCEMOD_VERSION;
61 * @brief Returns the full path to the mod directory.
63 * @return A string containing the full mod path.
65 virtual const char *GetModPath() const =0;
68 * @brief Returns the full path to the SourceMod directory.
70 * @return A string containing the full SourceMod path.
72 virtual const char *GetSourceModPath() const =0;
75 * @brief Builds a platform path for a specific target base path.
77 * @param type Type of path to use as a base.
78 * @param buffer Buffer to write to.
79 * @param maxlength Size of buffer.
80 * @param format Format string.
81 * @param ... Format arguments.
82 * @return Number of bytes written.
84 virtual size_t BuildPath(PathType type, char *buffer, size_t maxlength, char *format, ...) =0;
87 * @brief Logs a message to the SourceMod logs.
89 * @param pExt Extension calling this function.
90 * @param format Message format.
91 * @param ... Message format parameters.
93 virtual void LogMessage(IExtension *pExt, const char *format, ...) =0;
96 * @brief Logs a message to the SourceMod error logs.
98 * @param pExt Extension calling this function.
99 * @param format Message format.
100 * @param ... Message format parameters.
102 virtual void LogError(IExtension *pExt, const char *format, ...) =0;
105 * @brief Formats a string from a native.
107 * @param buffer Buffer to store message.
108 * @param maxlength Maximum length of buffer (inculding null terminator).
109 * @param pContext Pointer to the plugin's context.
110 * @param params Parameter array that was passed to the native.
111 * @param param Parameter index where format string and variable arguments begin.
112 * Note: parameter indexes start at 1.
113 * @return Number of bytes written, not including the null terminator.
115 virtual size_t FormatString(char *buffer,
117 SourcePawn::IPluginContext *pContext,
118 const cell_t *params,
119 unsigned int param) =0;
122 * @brief Creates a data pack object.
124 * @return A new IDataPack object.
126 virtual IDataPack *CreateDataPack() =0;
129 * @brief Releases a data pack's resources so it can be re-used.
131 * @param pack An IDataPack object to release.
133 virtual void FreeDataPack(IDataPack *pack) =0;
136 * @brief Returns the automated data pack handle type.
138 * The readonly data type is the parent of the writable type.
139 * Note that calling CloseHandle() on either type will release the data pack.
140 * The readonly type is inheritable, but due to limitations of the Handle System,
141 * the writable type is not.
143 * @param readonly If true, the readonly type will be returned.
144 * @return The Handle type for storing generic data packs.
146 virtual HandleType_t GetDataPackHandleType(bool readonly=false) =0;
150 #endif //_INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_