mirroed sdk fixes
authorDavid Anderson <dvander@alliedmods.net>
Sun Oct 28 08:25:56 2007 +0000 (2007-10-28)
changeset 1650766564f4c929
parent 1649 37373aea4dfe
child 1651 077571ea8942
mirroed sdk fixes
extensions/bintools/sdk/smsdk_ext.h
extensions/cstrike/sdk/smsdk_ext.h
extensions/geoip/sdk/smsdk_ext.h
extensions/mysql/sdk/smsdk_ext.h
extensions/sdktools/sdk/smsdk_ext.h
extensions/sqlite/sdk/smsdk_ext.h
extensions/topmenus/sdk/smsdk_ext.h
     1.1 --- a/extensions/bintools/sdk/smsdk_ext.h	Sun Oct 28 08:24:47 2007 +0000
     1.2 +++ b/extensions/bintools/sdk/smsdk_ext.h	Sun Oct 28 08:25:56 2007 +0000
     1.3 @@ -269,11 +269,15 @@
     1.4  #define SM_GET_IFACE(prefix, addr) \
     1.5  	if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
     1.6  	{ \
     1.7 -		if (error) \
     1.8 +		if (error != NULL && maxlength) \
     1.9  		{ \
    1.10 -			snprintf(error, maxlength, "Could not find interface: %s (version: %d)", SMINTERFACE_##prefix##_NAME, SMINTERFACE_##prefix##_VERSION); \
    1.11 -			return false; \
    1.12 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    1.13 +			if (len >= maxlength) \
    1.14 +			{ \
    1.15 +				error[maxlength - 1] = '\0'; \
    1.16 +			} \
    1.17  		} \
    1.18 +		return false; \
    1.19  	}
    1.20  /** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
    1.21  #define SM_GET_LATE_IFACE(prefix, addr) \
    1.22 @@ -282,11 +286,15 @@
    1.23  #define SM_CHECK_IFACE(prefix, addr) \
    1.24  	if (!addr) \
    1.25  	{ \
    1.26 -		if (error) \
    1.27 +		if (error != NULL && maxlength) \
    1.28  		{ \
    1.29 -			snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    1.30 -			return false; \
    1.31 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    1.32 +			if (len >= maxlength) \
    1.33 +			{ \
    1.34 +				error[maxlength - 1] = '\0'; \
    1.35 +			} \
    1.36  		} \
    1.37 +		return false; \
    1.38  	}
    1.39  
    1.40  #endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
     2.1 --- a/extensions/cstrike/sdk/smsdk_ext.h	Sun Oct 28 08:24:47 2007 +0000
     2.2 +++ b/extensions/cstrike/sdk/smsdk_ext.h	Sun Oct 28 08:25:56 2007 +0000
     2.3 @@ -273,11 +273,15 @@
     2.4  #define SM_GET_IFACE(prefix, addr) \
     2.5  	if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
     2.6  	{ \
     2.7 -		if (error) \
     2.8 +		if (error != NULL && maxlength) \
     2.9  		{ \
    2.10 -			snprintf(error, maxlength, "Could not find interface: %s (version: %d)", SMINTERFACE_##prefix##_NAME, SMINTERFACE_##prefix##_VERSION); \
    2.11 -			return false; \
    2.12 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    2.13 +			if (len >= maxlength) \
    2.14 +			{ \
    2.15 +				error[maxlength - 1] = '\0'; \
    2.16 +			} \
    2.17  		} \
    2.18 +		return false; \
    2.19  	}
    2.20  /** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
    2.21  #define SM_GET_LATE_IFACE(prefix, addr) \
    2.22 @@ -286,11 +290,15 @@
    2.23  #define SM_CHECK_IFACE(prefix, addr) \
    2.24  	if (!addr) \
    2.25  	{ \
    2.26 -		if (error) \
    2.27 +		if (error != NULL && maxlength) \
    2.28  		{ \
    2.29 -			snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    2.30 -			return false; \
    2.31 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    2.32 +			if (len >= maxlength) \
    2.33 +			{ \
    2.34 +				error[maxlength - 1] = '\0'; \
    2.35 +			} \
    2.36  		} \
    2.37 +		return false; \
    2.38  	}
    2.39  
    2.40  #endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
     3.1 --- a/extensions/geoip/sdk/smsdk_ext.h	Sun Oct 28 08:24:47 2007 +0000
     3.2 +++ b/extensions/geoip/sdk/smsdk_ext.h	Sun Oct 28 08:25:56 2007 +0000
     3.3 @@ -269,11 +269,15 @@
     3.4  #define SM_GET_IFACE(prefix, addr) \
     3.5  	if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
     3.6  	{ \
     3.7 -		if (error) \
     3.8 +		if (error != NULL && maxlength) \
     3.9  		{ \
    3.10 -			snprintf(error, maxlength, "Could not find interface: %s (version: %d)", SMINTERFACE_##prefix##_NAME, SMINTERFACE_##prefix##_VERSION); \
    3.11 -			return false; \
    3.12 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    3.13 +			if (len >= maxlength) \
    3.14 +			{ \
    3.15 +				error[maxlength - 1] = '\0'; \
    3.16 +			} \
    3.17  		} \
    3.18 +		return false; \
    3.19  	}
    3.20  /** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
    3.21  #define SM_GET_LATE_IFACE(prefix, addr) \
    3.22 @@ -282,11 +286,15 @@
    3.23  #define SM_CHECK_IFACE(prefix, addr) \
    3.24  	if (!addr) \
    3.25  	{ \
    3.26 -		if (error) \
    3.27 +		if (error != NULL && maxlength) \
    3.28  		{ \
    3.29 -			snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    3.30 -			return false; \
    3.31 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    3.32 +			if (len >= maxlength) \
    3.33 +			{ \
    3.34 +				error[maxlength - 1] = '\0'; \
    3.35 +			} \
    3.36  		} \
    3.37 +		return false; \
    3.38  	}
    3.39  
    3.40  #endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
     4.1 --- a/extensions/mysql/sdk/smsdk_ext.h	Sun Oct 28 08:24:47 2007 +0000
     4.2 +++ b/extensions/mysql/sdk/smsdk_ext.h	Sun Oct 28 08:25:56 2007 +0000
     4.3 @@ -269,11 +269,15 @@
     4.4  #define SM_GET_IFACE(prefix, addr) \
     4.5  	if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
     4.6  	{ \
     4.7 -		if (error) \
     4.8 +		if (error != NULL && maxlength) \
     4.9  		{ \
    4.10 -			snprintf(error, maxlength, "Could not find interface: %s (version: %d)", SMINTERFACE_##prefix##_NAME, SMINTERFACE_##prefix##_VERSION); \
    4.11 -			return false; \
    4.12 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    4.13 +			if (len >= maxlength) \
    4.14 +			{ \
    4.15 +				error[maxlength - 1] = '\0'; \
    4.16 +			} \
    4.17  		} \
    4.18 +		return false; \
    4.19  	}
    4.20  /** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
    4.21  #define SM_GET_LATE_IFACE(prefix, addr) \
    4.22 @@ -282,11 +286,15 @@
    4.23  #define SM_CHECK_IFACE(prefix, addr) \
    4.24  	if (!addr) \
    4.25  	{ \
    4.26 -		if (error) \
    4.27 +		if (error != NULL && maxlength) \
    4.28  		{ \
    4.29 -			snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    4.30 -			return false; \
    4.31 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    4.32 +			if (len >= maxlength) \
    4.33 +			{ \
    4.34 +				error[maxlength - 1] = '\0'; \
    4.35 +			} \
    4.36  		} \
    4.37 +		return false; \
    4.38  	}
    4.39  
    4.40  #endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
     5.1 --- a/extensions/sdktools/sdk/smsdk_ext.h	Sun Oct 28 08:24:47 2007 +0000
     5.2 +++ b/extensions/sdktools/sdk/smsdk_ext.h	Sun Oct 28 08:25:56 2007 +0000
     5.3 @@ -279,11 +279,15 @@
     5.4  #define SM_GET_IFACE(prefix, addr) \
     5.5  	if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
     5.6  	{ \
     5.7 -		if (error) \
     5.8 +		if (error != NULL && maxlength) \
     5.9  		{ \
    5.10 -			snprintf(error, maxlength, "Could not find interface: %s (version: %d)", SMINTERFACE_##prefix##_NAME, SMINTERFACE_##prefix##_VERSION); \
    5.11 -			return false; \
    5.12 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    5.13 +			if (len >= maxlength) \
    5.14 +			{ \
    5.15 +				error[maxlength - 1] = '\0'; \
    5.16 +			} \
    5.17  		} \
    5.18 +		return false; \
    5.19  	}
    5.20  /** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
    5.21  #define SM_GET_LATE_IFACE(prefix, addr) \
    5.22 @@ -292,11 +296,15 @@
    5.23  #define SM_CHECK_IFACE(prefix, addr) \
    5.24  	if (!addr) \
    5.25  	{ \
    5.26 -		if (error) \
    5.27 +		if (error != NULL && maxlength) \
    5.28  		{ \
    5.29 -			snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    5.30 -			return false; \
    5.31 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    5.32 +			if (len >= maxlength) \
    5.33 +			{ \
    5.34 +				error[maxlength - 1] = '\0'; \
    5.35 +			} \
    5.36  		} \
    5.37 +		return false; \
    5.38  	}
    5.39  
    5.40  #endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
     6.1 --- a/extensions/sqlite/sdk/smsdk_ext.h	Sun Oct 28 08:24:47 2007 +0000
     6.2 +++ b/extensions/sqlite/sdk/smsdk_ext.h	Sun Oct 28 08:25:56 2007 +0000
     6.3 @@ -269,11 +269,15 @@
     6.4  #define SM_GET_IFACE(prefix, addr) \
     6.5  	if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
     6.6  	{ \
     6.7 -		if (error) \
     6.8 +		if (error != NULL && maxlength) \
     6.9  		{ \
    6.10 -			snprintf(error, maxlength, "Could not find interface: %s (version: %d)", SMINTERFACE_##prefix##_NAME, SMINTERFACE_##prefix##_VERSION); \
    6.11 -			return false; \
    6.12 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    6.13 +			if (len >= maxlength) \
    6.14 +			{ \
    6.15 +				error[maxlength - 1] = '\0'; \
    6.16 +			} \
    6.17  		} \
    6.18 +		return false; \
    6.19  	}
    6.20  /** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
    6.21  #define SM_GET_LATE_IFACE(prefix, addr) \
    6.22 @@ -282,11 +286,15 @@
    6.23  #define SM_CHECK_IFACE(prefix, addr) \
    6.24  	if (!addr) \
    6.25  	{ \
    6.26 -		if (error) \
    6.27 +		if (error != NULL && maxlength) \
    6.28  		{ \
    6.29 -			snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    6.30 -			return false; \
    6.31 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    6.32 +			if (len >= maxlength) \
    6.33 +			{ \
    6.34 +				error[maxlength - 1] = '\0'; \
    6.35 +			} \
    6.36  		} \
    6.37 +		return false; \
    6.38  	}
    6.39  
    6.40  #endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
     7.1 --- a/extensions/topmenus/sdk/smsdk_ext.h	Sun Oct 28 08:24:47 2007 +0000
     7.2 +++ b/extensions/topmenus/sdk/smsdk_ext.h	Sun Oct 28 08:25:56 2007 +0000
     7.3 @@ -290,11 +290,15 @@
     7.4  #define SM_GET_IFACE(prefix, addr) \
     7.5  	if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
     7.6  	{ \
     7.7 -		if (error) \
     7.8 +		if (error != NULL && maxlength) \
     7.9  		{ \
    7.10 -			snprintf(error, maxlength, "Could not find interface: %s (version: %d)", SMINTERFACE_##prefix##_NAME, SMINTERFACE_##prefix##_VERSION); \
    7.11 -			return false; \
    7.12 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    7.13 +			if (len >= maxlength) \
    7.14 +			{ \
    7.15 +				error[maxlength - 1] = '\0'; \
    7.16 +			} \
    7.17  		} \
    7.18 +		return false; \
    7.19  	}
    7.20  /** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
    7.21  #define SM_GET_LATE_IFACE(prefix, addr) \
    7.22 @@ -303,11 +307,15 @@
    7.23  #define SM_CHECK_IFACE(prefix, addr) \
    7.24  	if (!addr) \
    7.25  	{ \
    7.26 -		if (error) \
    7.27 +		if (error != NULL && maxlength) \
    7.28  		{ \
    7.29 -			snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    7.30 -			return false; \
    7.31 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
    7.32 +			if (len >= maxlength) \
    7.33 +			{ \
    7.34 +				error[maxlength - 1] = '\0'; \
    7.35 +			} \
    7.36  		} \
    7.37 +		return false; \
    7.38  	}
    7.39  
    7.40  #endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_