| 320 | } |
| 321 | |
| 322 | static cell_t smn_ReadPackString(IPluginContext *pContext, const cell_t *params) |
| 323 | { |
| 324 | Handle_t hndl = static_cast<Handle_t>(params[1]); |
| 325 | HandleError herr; |
| 326 | HandleSecurity sec; |
| 327 | CDataPack *pDataPack; |
| 328 | |
| 329 | sec.pOwner = pContext->GetIdentity(); |
| 330 | sec.pIdentity = g_pCoreIdent; |
| 331 | |
| 332 | if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack)) |
| 333 | != HandleError_None) |
| 334 | { |
| 335 | return pContext->ThrowNativeError("Invalid data pack handle %x (error %d).", hndl, herr); |
| 336 | } |
| 337 | |
| 338 | if (!pDataPack->IsReadable()) |
| 339 | { |
| 340 | return pContext->ThrowNativeError("Data pack operation is out of bounds."); |
| 341 | } |
| 342 | |
| 343 | if (pDataPack->GetCurrentType() != CDataPackType::String) |
| 344 | { |
| 345 | return pContext->ThrowNativeError("Invalid data pack type (got %d / expected %d).", pDataPack->GetCurrentType(), CDataPackType::String); |
| 346 | } |
| 347 | |
| 348 | const char *str = pDataPack->ReadString(NULL); |
| 349 | pContext->StringToLocal(params[2], params[3], str); |
| 350 | |
| 351 | return 1; |
| 352 | } |
| 353 | |
| 354 | static cell_t smn_ReadPackFunction(IPluginContext *pContext, const cell_t *params) |
| 355 | { |
nothing calls this directly
no test coverage detected