Added KvGetSectionSymbol

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401715
This commit is contained in:
Matt Woodrow 2007-11-21 20:58:00 +00:00
parent bce7cf5bdd
commit 19c184aefc
2 changed files with 41 additions and 0 deletions

View File

@ -948,6 +948,36 @@ static cell_t smn_FindKeyById(IPluginContext *pContext, const cell_t *params)
return 1;
}
static cell_t smn_KvGetSectionSymbol(IPluginContext *pCtx, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError herr;
HandleSecurity sec;
KeyValueStack *pStk;
cell_t *val;
sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None)
{
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
}
KeyValues *pSection = pStk->pCurRoot.front();
pContext->LocalToPhysAddr(params[2], &val);
*val = pSection->GetNameSymbol();
if (!*val)
{
return 0;
}
return 1;
}
static KeyValueNatives s_KeyValueNatives;
REGISTER_NATIVES(keyvaluenatives)
@ -984,5 +1014,6 @@ REGISTER_NATIVES(keyvaluenatives)
{"KvCopySubkeys", smn_CopySubkeys},
{"KvFindKeyById", smn_FindKeyById},
{"KvGetNameSymbol", smn_GetNameSymbol},
{"KvGetSectionSymbol", smn_KvGetSectionSymbol},
{NULL, NULL}
};

View File

@ -394,3 +394,13 @@ native bool:KvFindKeyById(Handle:kv, id, String:name[], maxlength);
* @error Invalid Handle.
*/
native bool:KvGetNameSymbol(Handle:kv, const String:key[], &id);
/**
* Retrieves the current section id.
*
* @param kv KeyValues Handle.
* @param id Id of the current section.
* @return True on success, false on failure.
* @error Invalid Handle.
*/
native bool:KvGetSectionSymbol(Handle:kv, &id);