mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
Merge pull request #110 from Arkshine/replace-more-snprintf
Replace more snprintf by UTIL_Format.
This commit is contained in:
commit
570c9cfc6b
@ -12,10 +12,6 @@
|
|||||||
#include "CLang.h"
|
#include "CLang.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
|
||||||
#define _snprintf snprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LITIDX_NONE 0
|
#define LITIDX_NONE 0
|
||||||
#define LITIDX_BRACKET 1
|
#define LITIDX_BRACKET 1
|
||||||
#define LITIDX_DEFINITION 2
|
#define LITIDX_DEFINITION 2
|
||||||
|
@ -4092,10 +4092,6 @@ int AMXAPI amx_GetLibraries(AMX *amx)
|
|||||||
return numLibraries;
|
return numLibraries;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
|
||||||
#define _snprintf snprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const char *AMXAPI amx_GetLibrary(AMX *amx, int index, char *buffer, int len)
|
const char *AMXAPI amx_GetLibrary(AMX *amx, int index, char *buffer, int len)
|
||||||
{
|
{
|
||||||
AMX_HEADER *hdr = (AMX_HEADER *)amx->base;
|
AMX_HEADER *hdr = (AMX_HEADER *)amx->base;
|
||||||
|
@ -97,7 +97,7 @@ size_t AddLibrariesFromString(const char *name, LibType type, LibSource src, voi
|
|||||||
char *ptr, *p, s;
|
char *ptr, *p, s;
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
|
||||||
snprintf(buffer, sizeof(buffer)-1, "%s", name);
|
UTIL_Format(buffer, sizeof(buffer)-1, "%s", name);
|
||||||
|
|
||||||
ptr = buffer;
|
ptr = buffer;
|
||||||
p = buffer;
|
p = buffer;
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -12,6 +12,24 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "commctrl.h"
|
#include "commctrl.h"
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
HINSTANCE hPrevInstance,
|
HINSTANCE hPrevInstance,
|
||||||
LPTSTR lpCmdLine,
|
LPTSTR lpCmdLine,
|
||||||
@ -178,7 +196,7 @@ void UpdateListBox(HWND hDlg) {
|
|||||||
//if ((*b).getPosition() < 1) // umm... naaah!
|
//if ((*b).getPosition() < 1) // umm... naaah!
|
||||||
//continue;
|
//continue;
|
||||||
|
|
||||||
_snprintf(tempbuffer, 1023, "%s", (*b).getName());
|
UTIL_Format(tempbuffer, sizeof(tempbuffer)-1, "%s", (*b).getName());
|
||||||
|
|
||||||
SendMessage( // returns LRESULT in lResult
|
SendMessage( // returns LRESULT in lResult
|
||||||
listbox, // handle to destination control
|
listbox, // handle to destination control
|
||||||
@ -325,7 +343,7 @@ void SaveChanges(HWND hDlg) {
|
|||||||
UpdateListBox(hDlg);
|
UpdateListBox(hDlg);
|
||||||
|
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
_snprintf(buffer, 255, "New rank of %s: %d", name, newPosition);
|
UTIL_Format(buffer, sizeof(buffer)-1, "New rank of %s: %d", name, newPosition);
|
||||||
MessageBox(hDlg, buffer, "Update succeeded", MB_OK);
|
MessageBox(hDlg, buffer, "Update succeeded", MB_OK);
|
||||||
|
|
||||||
// In the listbox, we need to reselect the item we just updated. Use the new name.
|
// In the listbox, we need to reselect the item we just updated. Use the new name.
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -21,8 +21,7 @@ int g_CameraCount;
|
|||||||
|
|
||||||
TraceResult g_tr;
|
TraceResult g_tr;
|
||||||
|
|
||||||
#define BUFFERSIZE 1023
|
char g_buffer[1024];
|
||||||
char g_buffer[BUFFERSIZE + 1];
|
|
||||||
|
|
||||||
void UTIL_SetSize(edict_t *pev, const Vector &vecMin, const Vector &vecMax)
|
void UTIL_SetSize(edict_t *pev, const Vector &vecMin, const Vector &vecMax)
|
||||||
{
|
{
|
||||||
@ -870,7 +869,7 @@ static cell AMX_NATIVE_CALL traceresult(AMX *amx, cell *params)
|
|||||||
// (jghg)
|
// (jghg)
|
||||||
static cell AMX_NATIVE_CALL get_string(AMX *amx, cell *params) // (string, returnstring[], length)
|
static cell AMX_NATIVE_CALL get_string(AMX *amx, cell *params) // (string, returnstring[], length)
|
||||||
{
|
{
|
||||||
snprintf(g_buffer, BUFFERSIZE, "%s", STRING(params[1]));
|
UTIL_Format(g_buffer, sizeof(g_buffer)-1, "%s", STRING(params[1]));
|
||||||
return MF_SetAmxString(amx, params[2], g_buffer, params[3]);
|
return MF_SetAmxString(amx, params[2], g_buffer, params[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -299,23 +299,23 @@ static cell AMX_NATIVE_CALL amx_pev(AMX *amx,cell *params)
|
|||||||
return num;
|
return num;
|
||||||
} else if (ValType & Ret_Int) {
|
} else if (ValType & Ret_Int) {
|
||||||
char temp[32];
|
char temp[32];
|
||||||
snprintf(temp, 31, "%d", rets.i);
|
UTIL_Format(temp, sizeof(temp)-1, "%d", rets.i);
|
||||||
return MF_SetAmxString(amx, params[3], temp, size);
|
return MF_SetAmxString(amx, params[3], temp, size);
|
||||||
} else if (ValType == Ret_Float) {
|
} else if (ValType == Ret_Float) {
|
||||||
char temp[32];
|
char temp[32];
|
||||||
snprintf(temp, 31, "%f", rets.f);
|
UTIL_Format(temp, sizeof(temp)-1, "%f", rets.f);
|
||||||
return MF_SetAmxString(amx, params[3], temp, size);
|
return MF_SetAmxString(amx, params[3], temp, size);
|
||||||
} else if (ValType == Ret_Vec) {
|
} else if (ValType == Ret_Vec) {
|
||||||
char temp[32];
|
char temp[32];
|
||||||
snprintf(temp, 31, "%f %f %f", vr.x, vr.y, vr.z);
|
UTIL_Format(temp, sizeof(temp)-1, "%f %f %f", vr.x, vr.y, vr.z);
|
||||||
return MF_SetAmxString(amx, params[3], temp, size);
|
return MF_SetAmxString(amx, params[3], temp, size);
|
||||||
} else if (ValType == Ret_Bytes2) {
|
} else if (ValType == Ret_Bytes2) {
|
||||||
char temp[32];
|
char temp[32];
|
||||||
snprintf(temp, 31, "%d %d", rets.ba[0], rets.ba[1]);
|
UTIL_Format(temp, sizeof(temp)-1, "%d %d", rets.ba[0], rets.ba[1]);
|
||||||
return MF_SetAmxString(amx, params[3], temp, size);
|
return MF_SetAmxString(amx, params[3], temp, size);
|
||||||
} else if (ValType == Ret_Bytes4) {
|
} else if (ValType == Ret_Bytes4) {
|
||||||
char temp[32];
|
char temp[32];
|
||||||
snprintf(temp, 31, "%d %d %d %d", rets.ba[0], rets.ba[1], rets.ba[2], rets.ba[3]);
|
UTIL_Format(temp, sizeof(temp)-1, "%d %d %d %d", rets.ba[0], rets.ba[1], rets.ba[2], rets.ba[3]);
|
||||||
return MF_SetAmxString(amx, params[3], temp, size);
|
return MF_SetAmxString(amx, params[3], temp, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -17,10 +17,6 @@
|
|||||||
#include "GeoIP2/maxminddb.h"
|
#include "GeoIP2/maxminddb.h"
|
||||||
#include "amxxmodule.h"
|
#include "amxxmodule.h"
|
||||||
|
|
||||||
#if defined(WIN32)
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern AMX_NATIVE_INFO geoip_natives[];
|
extern AMX_NATIVE_INFO geoip_natives[];
|
||||||
|
|
||||||
#endif //_INCLUDE_GEOIPAMXX_H
|
#endif //_INCLUDE_GEOIPAMXX_H
|
||||||
|
@ -192,7 +192,7 @@ bool loadDatabase()
|
|||||||
// MF_BuildPathname not used because backslash
|
// MF_BuildPathname not used because backslash
|
||||||
// makes CreateFileMapping failing under windows.
|
// makes CreateFileMapping failing under windows.
|
||||||
|
|
||||||
snprintf(file, sizeof(file)-1, "%s/%s/GeoLite2-%s.mmdb", modName, dataDir, databases[i]);
|
UTIL_Format(file, sizeof(file)-1, "%s/%s/GeoLite2-%s.mmdb", modName, dataDir, databases[i]);
|
||||||
|
|
||||||
status = MMDB_open(file, MMDB_MODE_MMAP, &HandleDB);
|
status = MMDB_open(file, MMDB_MODE_MMAP, &HandleDB);
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ static cell AMX_NATIVE_CALL amx_geoip_region_code(AMX *amx, cell *params)
|
|||||||
if (countryCode)
|
if (countryCode)
|
||||||
{
|
{
|
||||||
finalLength = length + 1; // + 1 for dash.
|
finalLength = length + 1; // + 1 for dash.
|
||||||
snprintf(code, finalLength + 1, "%s-", countryCode); // + EOS.
|
UTIL_Format(code, finalLength + 1, "%s-", countryCode); // + EOS.
|
||||||
|
|
||||||
const char *pathRegion[] = { "subdivisions", "0", "iso_code", NULL }; // First result.
|
const char *pathRegion[] = { "subdivisions", "0", "iso_code", NULL }; // First result.
|
||||||
const char *regionCode = lookupString(ip, pathRegion, &length);
|
const char *regionCode = lookupString(ip, pathRegion, &length);
|
||||||
|
@ -16,10 +16,6 @@
|
|||||||
|
|
||||||
#include "geoip_main.h"
|
#include "geoip_main.h"
|
||||||
|
|
||||||
#if defined(WIN32)
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *stripPort(char *ip);
|
char *stripPort(char *ip);
|
||||||
|
|
||||||
bool lookupByIp(const char *ip, const char **path, MMDB_entry_data_s *result);
|
bool lookupByIp(const char *ip, const char **path, MMDB_entry_data_s *result);
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -108,7 +108,7 @@ static void read_mirror(char *input)
|
|||||||
*data='\0';
|
*data='\0';
|
||||||
|
|
||||||
// mark down the source
|
// mark down the source
|
||||||
snprintf(source, sizeof(source)-1, "%s", input);
|
UTIL_Format(source, sizeof(source)-1, "%s", input);
|
||||||
|
|
||||||
*data=old;
|
*data=old;
|
||||||
|
|
||||||
@ -128,13 +128,13 @@ static void read_mirror(char *input)
|
|||||||
old=*data;
|
old=*data;
|
||||||
*data='\0';
|
*data='\0';
|
||||||
|
|
||||||
snprintf(dest, sizeof(dest)-1, "%s", data2);
|
UTIL_Format(dest, sizeof(dest)-1, "%s", data2);
|
||||||
|
|
||||||
*data=old;
|
*data=old;
|
||||||
|
|
||||||
if (strcmp(dest, CurrentModName)==0)
|
if (strcmp(dest, CurrentModName)==0)
|
||||||
{
|
{
|
||||||
snprintf(CurrentModName, sizeof(CurrentModName)-1, "%s", source);
|
UTIL_Format(CurrentModName, sizeof(CurrentModName)-1, "%s", source);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -313,7 +313,7 @@ int ReadConfig(void)
|
|||||||
FILE *fp=fopen(FileName,"r");
|
FILE *fp=fopen(FileName,"r");
|
||||||
|
|
||||||
|
|
||||||
snprintf(CurrentModName, sizeof(CurrentModName)-1, "%s", MF_GetModname());
|
UTIL_Format(CurrentModName, sizeof(CurrentModName)-1, "%s", MF_GetModname());
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
|
@ -21,12 +21,12 @@
|
|||||||
#define CHECK_FUNCTION(x) \
|
#define CHECK_FUNCTION(x) \
|
||||||
if (x < 0 || x >= HAM_LAST_ENTRY_DONT_USE_ME_LOL) { \
|
if (x < 0 || x >= HAM_LAST_ENTRY_DONT_USE_ME_LOL) { \
|
||||||
char msg[1024]; \
|
char msg[1024]; \
|
||||||
snprintf(msg, sizeof(msg)-1, "Function out of bounds. Got: %d Max: %d",x, HAM_LAST_ENTRY_DONT_USE_ME_LOL - 1); \
|
UTIL_Format(msg, sizeof(msg)-1, "Function out of bounds. Got: %d Max: %d", x, HAM_LAST_ENTRY_DONT_USE_ME_LOL - 1); \
|
||||||
FailPlugin(amx, x, HAM_INVALID_FUNC, msg); \
|
FailPlugin(amx, x, HAM_INVALID_FUNC, msg); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} else if (hooklist[x].isset == 0) { \
|
} else if (hooklist[x].isset == 0) { \
|
||||||
char msg[1024]; \
|
char msg[1024]; \
|
||||||
snprintf(msg, sizeof(msg)-1, "Function %s is not configured in hamdata.ini.",hooklist[x].name); \
|
UTIL_Format(msg, sizeof(msg)-1, "Function %s is not configured in hamdata.ini.", hooklist[x].name); \
|
||||||
FailPlugin(amx, x, HAM_FUNC_NOT_CONFIGURED, msg); \
|
FailPlugin(amx, x, HAM_FUNC_NOT_CONFIGURED, msg); \
|
||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
size_t len=strlen(name);
|
size_t len=strlen(name);
|
||||||
ent=new char[len+1];
|
ent=new char[len+1];
|
||||||
|
|
||||||
snprintf(ent,len+1,"%s",name);
|
UTIL_Format(ent, len + 1, "%s", name);
|
||||||
};
|
};
|
||||||
|
|
||||||
~Hook()
|
~Hook()
|
||||||
|
@ -712,7 +712,7 @@ static cell AMX_NATIVE_CALL RegisterHamFromEntity(AMX *amx, cell *params)
|
|||||||
// It may very well be wrong (such as lots of TS weapons have the same classname)
|
// It may very well be wrong (such as lots of TS weapons have the same classname)
|
||||||
// but it's the best we can do, and better than nothing.
|
// but it's the best we can do, and better than nothing.
|
||||||
// (only used for display)
|
// (only used for display)
|
||||||
snprintf(classname, sizeof(classname) - 1, "%s", STRING(Entity->v.classname));
|
UTIL_Format(classname, sizeof(classname) - 1, "%s", STRING(Entity->v.classname));
|
||||||
|
|
||||||
// If we got here, the function is not hooked
|
// If we got here, the function is not hooked
|
||||||
Hook *hook = new Hook(vtable, hooklist[func].vtid, hooklist[func].targetfunc, hooklist[func].isvoid, hooklist[func].needsretbuf, hooklist[func].paramcount, classname);
|
Hook *hook = new Hook(vtable, hooklist[func].vtid, hooklist[func].targetfunc, hooklist[func].isvoid, hooklist[func].needsretbuf, hooklist[func].paramcount, classname);
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -11,16 +11,10 @@
|
|||||||
// MySQL Module
|
// MySQL Module
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "amxxmodule.h"
|
||||||
#include <string.h>
|
|
||||||
#include "MysqlDriver.h"
|
#include "MysqlDriver.h"
|
||||||
#include "MysqlDatabase.h"
|
#include "MysqlDatabase.h"
|
||||||
|
|
||||||
#if defined WIN32
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#define strncasecmp strnicmp
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
|
|
||||||
bool MysqlDriver::IsCompatDriver(const char *namestring)
|
bool MysqlDriver::IsCompatDriver(const char *namestring)
|
||||||
@ -53,7 +47,7 @@ IDatabase *MysqlDriver::_Connect(DatabaseInfo *info, int *errcode, char *error,
|
|||||||
*errcode = -1;
|
*errcode = -1;
|
||||||
if (error && maxlength)
|
if (error && maxlength)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlength, "Initialization failed");
|
UTIL_Format(error, maxlength, "Initialization failed");
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -78,7 +72,7 @@ IDatabase *MysqlDriver::_Connect(DatabaseInfo *info, int *errcode, char *error,
|
|||||||
}
|
}
|
||||||
if (error && maxlength)
|
if (error && maxlength)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlength, "%s", mysql_error(mysql));
|
UTIL_Format(error, maxlength, "%s", mysql_error(mysql));
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -11,16 +11,11 @@
|
|||||||
// MySQL Module
|
// MySQL Module
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "amxxmodule.h"
|
||||||
#include <string.h>
|
|
||||||
#include "MysqlQuery.h"
|
#include "MysqlQuery.h"
|
||||||
#include "MysqlDatabase.h"
|
#include "MysqlDatabase.h"
|
||||||
#include "MysqlResultSet.h"
|
#include "MysqlResultSet.h"
|
||||||
|
|
||||||
#if defined WIN32
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
|
|
||||||
MysqlQuery::MysqlQuery(const char *querystring, MysqlDatabase *db) :
|
MysqlQuery::MysqlQuery(const char *querystring, MysqlDatabase *db) :
|
||||||
@ -95,7 +90,7 @@ bool MysqlQuery::ExecuteR(QueryInfo *info, char *error, size_t maxlength)
|
|||||||
info->rs = NULL;
|
info->rs = NULL;
|
||||||
if (error && maxlength)
|
if (error && maxlength)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlength, "%s", mysql_error(m_pDatabase->m_pMysql));
|
UTIL_Format(error, maxlength, "%s", mysql_error(m_pDatabase->m_pMysql));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -31,7 +31,7 @@ void ParticleManager::ReadFile(void)
|
|||||||
|
|
||||||
char FileName[256];
|
char FileName[256];
|
||||||
|
|
||||||
snprintf(FileName,sizeof(FileName)-1,"%s/ns.ps",MF_GetModname());
|
UTIL_Format(FileName, sizeof(FileName)-1, "%s/ns.ps", MF_GetModname());
|
||||||
FILE *fp=fopen(FileName,"r");
|
FILE *fp=fopen(FileName,"r");
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
|
@ -28,7 +28,7 @@ void TitleManager::LoadTitles(void)
|
|||||||
|
|
||||||
char FileName[128];
|
char FileName[128];
|
||||||
|
|
||||||
snprintf(FileName,127,"%s/titles.txt",MF_GetModname());
|
UTIL_Format(FileName, sizeof(FileName)-1, "%s/titles.txt", MF_GetModname());
|
||||||
|
|
||||||
FILE *fp=fopen(FileName,"r");
|
FILE *fp=fopen(FileName,"r");
|
||||||
|
|
||||||
|
@ -86,9 +86,9 @@ void MFuncs_Initialize(void)
|
|||||||
char FileName[256];
|
char FileName[256];
|
||||||
DLHANDLE DLLBase;
|
DLHANDLE DLLBase;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
snprintf(FileName,sizeof(FileName)-1,"%s/dlls/ns_i386.so",MF_GetModname());
|
UTIL_Format(FileName,sizeof(FileName)-1,"%s/dlls/ns_i386.so",MF_GetModname());
|
||||||
#else
|
#else
|
||||||
snprintf(FileName,sizeof(FileName)-1,"%s\\dlls\\ns.dll",MF_GetModname());
|
UTIL_Format(FileName, sizeof(FileName)-1, "%s\\dlls\\ns.dll", MF_GetModname());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DLLBase=DLOPEN(FileName);
|
DLLBase=DLOPEN(FileName);
|
||||||
|
@ -49,7 +49,7 @@ cell PSKeyValueI(const char *name, AMX *amx, cell *params)
|
|||||||
|
|
||||||
char StrData[1024];
|
char StrData[1024];
|
||||||
|
|
||||||
snprintf(StrData,sizeof(StrData)-1,"%d",params[2]);
|
UTIL_Format(StrData, sizeof(StrData)-1, "%d", params[2]);
|
||||||
|
|
||||||
kvd.szClassName=const_cast<char *>(STRING(reinterpret_cast<edict_t *>(params[1])->v.classname));
|
kvd.szClassName=const_cast<char *>(STRING(reinterpret_cast<edict_t *>(params[1])->v.classname));
|
||||||
kvd.szKeyName=name;
|
kvd.szKeyName=name;
|
||||||
@ -72,7 +72,7 @@ cell PSKeyValueF(const char *name, AMX *amx, cell *params)
|
|||||||
|
|
||||||
char StrData[1024];
|
char StrData[1024];
|
||||||
|
|
||||||
snprintf(StrData,sizeof(StrData)-1,"%f",amx_ctof2(params[2]));
|
UTIL_Format(StrData, sizeof(StrData)-1, "%f", amx_ctof2(params[2]));
|
||||||
|
|
||||||
kvd.szClassName=const_cast<char *>(STRING(reinterpret_cast<edict_t *>(params[1])->v.classname));
|
kvd.szClassName=const_cast<char *>(STRING(reinterpret_cast<edict_t *>(params[1])->v.classname));
|
||||||
kvd.szKeyName=name;
|
kvd.szKeyName=name;
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -17,10 +17,6 @@
|
|||||||
#include "Binary.h"
|
#include "Binary.h"
|
||||||
#include "CString.h"
|
#include "CString.h"
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
|
||||||
#define _snprintf snprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* :TODO: This beast calls strcpy()/new() way too much by creating new strings on the stack.
|
* :TODO: This beast calls strcpy()/new() way too much by creating new strings on the stack.
|
||||||
* That's easily remedied and it should be fixed?
|
* That's easily remedied and it should be fixed?
|
||||||
@ -366,7 +362,7 @@ bool NVault::GetValue(const char *key, time_t &stamp, char buffer[], size_t len)
|
|||||||
|
|
||||||
sVal = m_Hash.Retrieve(sKey, st);
|
sVal = m_Hash.Retrieve(sKey, st);
|
||||||
stamp = st;
|
stamp = st;
|
||||||
_snprintf(buffer, len, "%s", sVal.c_str());
|
UTIL_Format(buffer, len, "%s", sVal.c_str());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -11,15 +11,12 @@
|
|||||||
// SQLite Module
|
// SQLite Module
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <string.h>
|
#include "amxxmodule.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include "SqliteHeaders.h"
|
#include "SqliteHeaders.h"
|
||||||
#include "SqliteDriver.h"
|
#include "SqliteDriver.h"
|
||||||
#include "SqliteDatabase.h"
|
#include "SqliteDatabase.h"
|
||||||
|
|
||||||
#if defined WIN32
|
#if defined WIN32
|
||||||
#define snprintf _snprintf
|
|
||||||
#define strncasecmp strnicmp
|
|
||||||
#define WINDOWS_LEAN_AND_MEAN
|
#define WINDOWS_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
@ -65,7 +62,7 @@ IDatabase *SqliteDriver::Connect(DatabaseInfo *info, int *errcode, char *error,
|
|||||||
}
|
}
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlength, "%s", sqlite3_errmsg(pSql));
|
UTIL_Format(error, maxlength, "%s", sqlite3_errmsg(pSql));
|
||||||
}
|
}
|
||||||
sqlite3_close(pSql);
|
sqlite3_close(pSql);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -11,16 +11,11 @@
|
|||||||
// SQLite Module
|
// SQLite Module
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "amxxmodule.h"
|
||||||
#include <string.h>
|
|
||||||
#include "SqliteQuery.h"
|
#include "SqliteQuery.h"
|
||||||
#include "SqliteDatabase.h"
|
#include "SqliteDatabase.h"
|
||||||
#include "SqliteResultSet.h"
|
#include "SqliteResultSet.h"
|
||||||
|
|
||||||
#if defined WIN32
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
|
|
||||||
SqliteQuery::SqliteQuery(SqliteDatabase *db, const char *query) :
|
SqliteQuery::SqliteQuery(SqliteDatabase *db, const char *query) :
|
||||||
@ -97,7 +92,7 @@ bool SqliteQuery::ExecuteR(QueryInfo *info, char *error, size_t maxlength)
|
|||||||
{
|
{
|
||||||
if (error && maxlength && errmsg)
|
if (error && maxlength && errmsg)
|
||||||
{
|
{
|
||||||
snprintf(error, maxlength, "%s", errmsg);
|
UTIL_Format(error, maxlength, "%s", errmsg);
|
||||||
}
|
}
|
||||||
info->affected_rows = 0;
|
info->affected_rows = 0;
|
||||||
info->errorcode = err;
|
info->errorcode = err;
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -3124,3 +3124,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
|||||||
return (unsigned short)output;
|
return (unsigned short)output;
|
||||||
}
|
}
|
||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= maxlength)
|
||||||
|
{
|
||||||
|
buffer[maxlength - 1] = '\0';
|
||||||
|
return (maxlength - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
|
|
||||||
#endif //MEMORY_TEST
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -28,8 +28,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MemoryUtils.h"
|
#include "MemoryUtils.h"
|
||||||
#include <string.h>
|
#include "amxxmodule.h"
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -638,7 +637,7 @@ bool MemoryUtils::GetLibraryOfAddress(const void *libPtr, char *buffer, size_t m
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const char *dllpath = info.dli_fname;
|
const char *dllpath = info.dli_fname;
|
||||||
snprintf(buffer, maxlength, "%s", dllpath);
|
UTIL_Format(buffer, maxlength, "%s", dllpath);
|
||||||
if (base)
|
if (base)
|
||||||
{
|
{
|
||||||
*base = (uintptr_t)info.dli_fbase;
|
*base = (uintptr_t)info.dli_fbase;
|
||||||
|
Loading…
Reference in New Issue
Block a user