|
dvander@247
|
1 |
/** |
|
ds@475
|
2 |
* vim: set ts=4 : |
|
ds@1330
|
3 |
* ============================================================================= |
|
dvander@374
|
4 |
* SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. |
|
ds@1330
|
5 |
* ============================================================================= |
|
ds@1330
|
6 |
* |
|
ds@1330
|
7 |
* This file is part of the SourceMod/SourcePawn SDK. |
|
dvander@374
|
8 |
* |
|
ds@1330
|
9 |
* This program is free software; you can redistribute it and/or modify it under |
|
ds@1330
|
10 |
* the terms of the GNU General Public License, version 3.0, as published by the |
|
ds@1330
|
11 |
* Free Software Foundation. |
|
ds@1330
|
12 |
* |
|
ds@1330
|
13 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
ds@1330
|
14 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
ds@1330
|
15 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
ds@1330
|
16 |
* details. |
|
ds@1330
|
17 |
* |
|
ds@1330
|
18 |
* You should have received a copy of the GNU General Public License along with |
|
ds@1330
|
19 |
* this program. If not, see <http://www.gnu.org/licenses/>. |
|
ds@1330
|
20 |
* |
|
ds@1330
|
21 |
* As a special exception, AlliedModders LLC gives you permission to link the |
|
ds@1330
|
22 |
* code of this program (as well as its derivative works) to "Half-Life 2," the |
|
ds@1330
|
23 |
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software |
|
ds@1330
|
24 |
* by the Valve Corporation. You must obey the GNU General Public License in |
|
ds@1330
|
25 |
* all respects for all other code used. Additionally, AlliedModders LLC grants |
|
ds@1330
|
26 |
* this exception to all derivative works. AlliedModders LLC defines further |
|
ds@1330
|
27 |
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), |
|
ds@1330
|
28 |
* or <http://www.sourcemod.net/license.php>. |
|
dvander@374
|
29 |
* |
|
dvander@374
|
30 |
* Version: $Id$ |
|
dvander@247
|
31 |
*/ |
|
dvander@247
|
32 |
|
|
dvander@247
|
33 |
#if defined _handles_included |
|
dvander@247
|
34 |
#endinput |
|
dvander@247
|
35 |
#endif |
|
dvander@247
|
36 |
#define _handles_included |
|
dvander@247
|
37 |
|
|
dvander@619
|
38 |
/** |
|
dvander@619
|
39 |
* Handle helper macros. |
|
dvander@619
|
40 |
*/ |
|
dvander@247
|
41 |
enum Handle |
|
dvander@247
|
42 |
{ |
|
dvander@247
|
43 |
INVALID_HANDLE = 0, |
|
dvander@247
|
44 |
}; |
|
dvander@247
|
45 |
|
|
dvander@247
|
46 |
|
|
dvander@247
|
47 |
/** |
|
dvander@812
|
48 |
* Closes a Handle. If the handle has multiple copies open, |
|
dvander@247
|
49 |
* it is not destroyed unless all copies are closed. |
|
dvander@247
|
50 |
* |
|
dvander@247
|
51 |
* @note Closing a Handle has a different meaning for each Handle type. Make |
|
dvander@247
|
52 |
* sure you read the documentation on whatever provided the Handle. |
|
dvander@247
|
53 |
* |
|
dvander@247
|
54 |
* @param hndl Handle to close. |
|
ds@475
|
55 |
* @return True if successful, false if not closeable. |
|
dvander@247
|
56 |
* @error Invalid handles will cause a run time error. |
|
dvander@247
|
57 |
*/ |
|
dvander@247
|
58 |
native bool:CloseHandle(Handle:hndl); |
|
dvander@247
|
59 |
|
|
dvander@247
|
60 |
/** |
|
dvander@812
|
61 |
* Clones a Handle. When passing handles in between plugins, caching handles |
|
dvander@247
|
62 |
* can result in accidental invalidation when one plugin releases the Handle, or is its owner |
|
dvander@247
|
63 |
* is unloaded from memory. To prevent this, the Handle may be "cloned" with a new owner. |
|
dvander@247
|
64 |
* |
|
dvander@247
|
65 |
* @note Usually, you will be cloning Handles for other plugins. This means that if you clone |
|
dvander@247
|
66 |
* the Handle without specifying the new owner, it will assume the identity of your original calling |
|
dvander@247
|
67 |
* plugin, which is not very useful. You should either specify that the receiving plugin should |
|
dvander@247
|
68 |
* clone the handle on its own, or you should explicitly clone the Handle using the receiving plugin's |
|
dvander@247
|
69 |
* identity Handle. |
|
dvander@247
|
70 |
* |
|
dvander@247
|
71 |
* @param hndl Handle to clone/duplicate. |
|
dvander@247
|
72 |
* @param plugin Optional Handle to another plugin to mark as the new owner. |
|
ds@475
|
73 |
* If no owner is passed, the owner becomes the calling plugin. |
|
ds@475
|
74 |
* @return Handle on success, INVALID_HANDLE if not cloneable. |
|
dvander@247
|
75 |
* @error Invalid handles will cause a run time error. |
|
dvander@247
|
76 |
*/ |
|
dvander@247
|
77 |
native Handle:CloneHandle(Handle:hndl, Handle:plugin=INVALID_HANDLE); |
|
dvander@1398
|
78 |
|
|
dvander@1398
|
79 |
/** |
|
dvander@1398
|
80 |
* Do not use this function. Returns if a Handle and its contents |
|
dvander@1398
|
81 |
* are readable, whereas INVALID_HANDLE only checks for the absence |
|
dvander@1398
|
82 |
* of a Handle. |
|
dvander@1398
|
83 |
* |
|
dvander@1398
|
84 |
* This function is intended only for tests where the validity of a |
|
dvander@1398
|
85 |
* Handle can absolutely not be known. |
|
dvander@1398
|
86 |
* |
|
dvander@1398
|
87 |
* Do not use this to check the return values of functions, or to |
|
dvander@1398
|
88 |
* check if timers should be closed (except in very rare cases). |
|
dvander@1398
|
89 |
* This function is for very specific usage and using it for general |
|
dvander@1398
|
90 |
* purpose routines can and will hide very subtle bugs. |
|
dvander@1398
|
91 |
* |
|
dvander@1398
|
92 |
* @param hndl Handle to test for validity. |
|
dvander@1398
|
93 |
* @return True if handle is valid, false otherwise. |
|
dvander@1398
|
94 |
*/ |
|
dvander@1765
|
95 |
#pragma deprecated Do not use this function. |
|
dvander@1398
|
96 |
native bool:IsValidHandle(Handle:hndl); |