Skip to content

Commit 9ac8b28

Browse files
committed
Pass success flag to plugins, include changes
1 parent 6f14a3a commit 9ac8b28

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

package/scripting/include/env_variables.inc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@
4040
* @param szName The environment variable name.
4141
* @param szBuffer Buffer where value should be written.
4242
* @param iBufferLength Maximum size of the buffer.
43+
* @param bExists The ref to variable where will be written
44+
* information about presence environment variable.
4345
* @return The written bytes count.
4446
*/
45-
native int GetEnvironmentVariable(const char[] szName, char[] szBuffer, int iBufferLength);
47+
native int GetEnvironmentVariable(const char[] szName, char[] szBuffer, int iBufferLength, bool &bExists = false);
4648

4749
/**
4850
* Do not edit below this line!
@@ -62,3 +64,10 @@ public Extension __ext_env_variables =
6264
required = 0,
6365
#endif
6466
};
67+
68+
#if !defined REQUIRE_EXTENSIONS
69+
public void __ext_env_variables_SetNTVOptional()
70+
{
71+
MarkNativeAsOptional("GetEnvironmentVariable");
72+
}
73+
#endif

src/natives.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ static cell_t sm_getenv(SourcePawn::IPluginContext *pContext, const cell_t *para
4040
char *value = getenv(name);
4141

4242
cell_t is_success = (value != NULL) ? 1 : 0;
43+
if (params[0] > 3)
44+
{
45+
cell_t *addr;
46+
pContext->LocalToPhysAddr(params[4], &addr);
47+
*addr = is_success;
48+
}
49+
4350
if (value != NULL)
4451
{
4552
size_t numBytes;

src/smsdk_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
/* Basic information exposed publicly */
4141
#define SMEXT_CONF_NAME "Environment Variables"
4242
#define SMEXT_CONF_DESCRIPTION "Extension what implements getenv() for SourcePawn plugins"
43-
#define SMEXT_CONF_VERSION "1.0.0.0"
43+
#define SMEXT_CONF_VERSION "1.0.0.1"
4444
#define SMEXT_CONF_AUTHOR "CrazyHackGUT aka Kruzya"
4545
#define SMEXT_CONF_URL "https://kruzya.me/"
4646
#define SMEXT_CONF_LOGTAG "ENV"

0 commit comments

Comments
 (0)