plugins/include/handles.inc
author Borja Ferrer <faluco@alliedmods.net>
Sun Jan 07 01:30:28 2007 +0000 (2007-01-07)
changeset 274 959c85596341
parent 251 e5dfa46553f4
child 374 39ab08027d9e
permissions -rw-r--r--
Added a bunch of new file natives.
Fixed possible corruption in snprintf when input buffer was bigger than output buffer and relaying on its retval.
Fixed all cases when the above situation happened.
Fixed _PrintToHL2Log not taking va_list in.
     1 /**
     2  * :TODO: license info
     3  */
     4 
     5 
     6 #if defined _handles_included
     7  #endinput
     8 #endif
     9 #define _handles_included
    10 
    11 enum Handle
    12 {
    13 	INVALID_HANDLE = 0,
    14 };
    15 
    16 /**
    17  * @brief Returns if a handle is valid or not.
    18  * @note It is not a good idea to call this on every Handle.  If you code properly,
    19  *       all of your Handles will either be valid or will expose important bugs to fix.
    20  *       This is provided for situations only where testing for handle validity is needed.
    21  *
    22  * @param hndl		Handle to test for validity.
    23  * @return		True if handle is valid, false otherwise.
    24  */
    25 native bool:IsValidHandle(Handle:hndl);
    26 
    27 /**
    28  * @brief Closes a Handle.  If the handle has multiple copies open, 
    29  * it is not destroyed unless all copies are closed.
    30  * 
    31  * @note Closing a Handle has a different meaning for each Handle type.  Make
    32  *       sure you read the documentation on whatever provided the Handle.
    33  *
    34  * @param hndl		Handle to close.
    35  * @return		True if successful, false if not closeable.
    36  * @error			Invalid handles will cause a run time error.
    37  */
    38 native bool:CloseHandle(Handle:hndl);
    39 
    40 /**
    41  * @brief Clones a Handle.  When passing handles in between plugins, caching handles
    42  * can result in accidental invalidation when one plugin releases the Handle, or is its owner
    43  * is unloaded from memory.  To prevent this, the Handle may be "cloned" with a new owner.
    44  * 
    45  * @note Usually, you will be cloning Handles for other plugins.  This means that if you clone
    46  * the Handle without specifying the new owner, it will assume the identity of your original calling
    47  * plugin, which is not very useful.  You should either specify that the receiving plugin should
    48  * clone the handle on its own, or you should explicitly clone the Handle using the receiving plugin's
    49  * identity Handle.
    50  *
    51  * @param hndl		Handle to clone/duplicate.
    52  * @param plugin	Optional Handle to another plugin to mark as the new owner.
    53  *				If no owner is passed, the owner becomes the calling plugin.
    54  * @return		Handle on success, INVALID_HANDLE if not cloneable.
    55  * @error			Invalid handles will cause a run time error.
    56  */
    57 native Handle:CloneHandle(Handle:hndl, Handle:plugin=INVALID_HANDLE);
    58