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>
28 #define SMINTERFACE_SOURCEMOD_NAME "ISourceMod"
29 #define SMINTERFACE_SOURCEMOD_VERSION 1
34 * @brief Describes various ways of formatting a base path.
38 Path_None = 0, /**< No base path */
39 Path_Game, /**< Base path is absolute mod folder */
40 Path_SM, /**< Base path is absolute to SourceMod */
41 Path_SM_Rel, /**< Base path is relative to SourceMod */
45 * @brief Contains miscellanious helper functions.
47 class ISourceMod : public SMInterface
50 virtual const char *GetInterfaceName()
52 return SMINTERFACE_SOURCEMOD_NAME;
54 virtual unsigned int GetInterfaceVersion()
56 return SMINTERFACE_SOURCEMOD_VERSION;
60 * @brief Returns the full path to the mod directory.
62 * @return A string containing the full mod path.
64 virtual const char *GetModPath() =0;
67 * @brief Returns the full path to the SourceMod directory.
69 * @return A string containing the full SourceMod path.
71 virtual const char *GetSourceModPath() =0;
74 * @brief Builds a platform path for a specific target base path.
76 * @param type Type of path to use as a base.
77 * @param buffer Buffer to write to.
78 * @param maxlength Size of buffer.
79 * @param format Format string.
80 * @param ... Format arguments.
81 * @return Number of bytes written.
83 virtual size_t BuildPath(PathType type, char *buffer, size_t maxlength, char *format, ...) =0;
86 * @brief Logs a message to the SourceMod logs.
88 * @param pExt Extension calling this function.
89 * @param format Message format.
90 * @param ... Message format parameters.
92 virtual void LogMessage(IExtension *pExt, const char *format, ...) =0;
95 * @brief Logs a message to the SourceMod error logs.
97 * @param pExt Extension calling this function.
98 * @param format Message format.
99 * @param ... Message format parameters.
101 virtual void LogError(IExtension *pExt, const char *format, ...) =0;
104 * @brief Formats a string from a native.
106 * @param buffer Buffer to store message.
107 * @param maxlength Maximum length of buffer (inculding null terminator).
108 * @param pContext Pointer to the plugin's context.
109 * @param params Parameter array that was passed to the native.
110 * @param param Parameter index where format string and variable arguments begin.
111 * Note: parameter indexes start at 1.
112 * @return Number of bytes written, not including the null terminator.
114 virtual size_t FormatString(char *buffer,
116 SourcePawn::IPluginContext *pContext,
117 const cell_t *params,
118 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;
151 #endif //_INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_