find native by name
authorBorja Ferrer <faluco@alliedmods.net>
Tue Aug 01 01:14:54 2006 +0000 (2006-08-01)
changeset 420b5bc1d7dd71
parent 41 4ba0f76067f0
child 43 a6fd3d47dd92
find native by name
sourcepawn/vm/sp_vm.c
     1.1 --- a/sourcepawn/vm/sp_vm.c	Tue Aug 01 00:21:00 2006 +0000
     1.2 +++ b/sourcepawn/vm/sp_vm.c	Tue Aug 01 01:14:54 2006 +0000
     1.3 @@ -1,4 +1,5 @@
     1.4  #include <limits.h>
     1.5 +#include <string.h>
     1.6  #include <assert.h>
     1.7  #include "sp_vm.h"
     1.8  
     1.9 @@ -105,3 +106,19 @@
    1.10  
    1.11  	return SP_ERR_NONE;
    1.12  }
    1.13 +
    1.14 +int SP_FindNativeByName(sp_context_t *ctx, const char *name, uint32_t *index)
    1.15 +{
    1.16 +	uint32_t i;
    1.17 +
    1.18 +	for (i = 0; i < ctx->plugin->info->natives_num; i++)
    1.19 +	{
    1.20 +		if (!strcmp(name, ctx->natives[i].name))
    1.21 +		{
    1.22 +			if (index)
    1.23 +				*index = i;
    1.24 +			return SP_ERR_NONE;
    1.25 +		}
    1.26 +	}
    1.27 +	return SP_ERR_NOT_FOUND;
    1.28 +}
    1.29 \ No newline at end of file