Open Files 5.3.0
Multi-Platform Event-Driven Application Framework
handle.h File Reference
#include "ofc/core.h"
#include "ofc/types.h"
Include dependency graph for handle.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

#define OFC_INVALID_HANDLE_VALUE   ((OFC_HANDLE)-1)
 
#define OFC_HANDLE16_INVALID   (OFC_HANDLE16)0xFFFF
 
#define OFC_HANDLE16_NULL   ((OFC_HANDLE16) 0)
 
#define OFC_HANDLE_NULL   ((OFC_HANDLE) 0)
 
enum  OFC_HANDLE_TYPE {
  OFC_HANDLE_UNKNOWN , OFC_HANDLE_WAIT_SET , OFC_HANDLE_QUEUE , OFC_HANDLE_FILE ,
  OFC_HANDLE_FSWIN32_FILE , OFC_HANDLE_FSWIN32_OVERLAPPED , OFC_HANDLE_FSWINCE_OVERLAPPED , OFC_HANDLE_FSSMB_OVERLAPPED ,
  OFC_HANDLE_FSDARWIN_OVERLAPPED , OFC_HANDLE_FSLINUX_OVERLAPPED , OFC_HANDLE_FSFILEX_OVERLAPPED , OFC_HANDLE_FSNUFILE_OVERLAPPED ,
  OFC_HANDLE_FSANDROID_OVERLAPPED , OFC_HANDLE_FSRESOLVER_OVERLAPPED , OFC_HANDLE_FSDARWIN_FILE , OFC_HANDLE_FSLINUX_FILE ,
  OFC_HANDLE_FSFILEX_FILE , OFC_HANDLE_FSANDROID_FILE , OFC_HANDLE_FSRESOLVER_FILE , OFC_HANDLE_FSNUFILE_FILE ,
  OFC_HANDLE_FSOTHER_FILE , OFC_HANDLE_FSBROWSER_FILE , OFC_HANDLE_FSBOOKMARK_FILE , OFC_HANDLE_SCHED ,
  OFC_HANDLE_APP , OFC_HANDLE_THREAD , OFC_HANDLE_SOCKET , OFC_HANDLE_SOCKET_IMPL ,
  OFC_HANDLE_EVENT , OFC_HANDLE_TIMER , OFC_HANDLE_PIPE , OFC_HANDLE_WAIT_QUEUE ,
  OFC_HANDLE_TRANSACTION , OFC_HANDLE_SMB_FILE , OFC_HANDLE_MAILSLOT , OFC_HANDLE_PROCESS ,
  OFC_HANDLE_NUM
}
 
typedef OFC_DWORD_PTR OFC_HANDLE
 
typedef OFC_UINT16 OFC_HANDLE16
 
OFC_CORE_LIB OFC_HANDLE ofc_handle_create (OFC_HANDLE_TYPE hType, OFC_VOID *context)
 
OFC_CORE_LIB OFC_VOIDofc_handle_lock (OFC_HANDLE handle)
 
OFC_CORE_LIB OFC_VOIDofc_handle_lock_ex (OFC_HANDLE handle, OFC_HANDLE_TYPE type)
 
OFC_CORE_LIB OFC_VOID ofc_handle_unlock (OFC_HANDLE handle)
 
OFC_CORE_LIB OFC_VOID ofc_handle_destroy (OFC_HANDLE handle)
 
OFC_CORE_LIB OFC_VOID ofc_handle_set_app (OFC_HANDLE hHandle, OFC_HANDLE hApp, OFC_HANDLE hSet)
 
OFC_CORE_LIB OFC_HANDLE ofc_handle_get_app (OFC_HANDLE hHandle)
 
OFC_CORE_LIB OFC_HANDLE ofc_handle_get_wait_set (OFC_HANDLE hHandle)
 
OFC_CORE_LIB OFC_HANDLE_TYPE ofc_handle_get_type (OFC_HANDLE hHandle)
 
OFC_CORE_LIB OFC_VOID ofc_handle16_init (OFC_VOID)
 
OFC_CORE_LIB OFC_VOID ofc_handle16_free (OFC_VOID)
 
OFC_CORE_LIB OFC_HANDLE16 ofc_handle16_create (OFC_VOID *context)
 
OFC_CORE_LIB OFC_VOID ofc_handle16_destroy (OFC_HANDLE16 hHandle)
 
OFC_CORE_LIB OFC_VOIDofc_handle16_lock (OFC_HANDLE16 hHandle)
 
OFC_CORE_LIB OFC_VOID ofc_handle16_unlock (OFC_HANDLE16 hHandle)
 

Macro Definition Documentation

◆ OFC_HANDLE16_INVALID

#define OFC_HANDLE16_INVALID   (OFC_HANDLE16)0xFFFF

An invalid 16 bit handle value

◆ OFC_HANDLE16_NULL

#define OFC_HANDLE16_NULL   ((OFC_HANDLE16) 0)

A NULL 16 bit Handle

◆ OFC_HANDLE_NULL

#define OFC_HANDLE_NULL   ((OFC_HANDLE) 0)

◆ OFC_INVALID_HANDLE_VALUE

#define OFC_INVALID_HANDLE_VALUE   ((OFC_HANDLE)-1)

An Invalid 32 bit handle Handle

Examples
smbcp.c, smbls.c, smbrm.c, and test_file.c.

Typedef Documentation

◆ OFC_HANDLE

The definition of the 32 bit handle

Examples
test_dg.c.

◆ OFC_HANDLE16

The definition of the 16 bit handle

Enumeration Type Documentation

◆ OFC_HANDLE_TYPE

Available Handle Types for the 32 bit handles

Enumerator
OFC_HANDLE_UNKNOWN 

The Handle type is Unknown (0x00)

OFC_HANDLE_WAIT_SET 

The Handle is for a Wait Set (a collection of events to wait on)

OFC_HANDLE_QUEUE 

The handle is for a linked list of items

OFC_HANDLE_FILE 

The handle is for an abstracted file f (platform and fs independent)

OFC_HANDLE_FSWIN32_FILE 

The handle is for a Win32 file

OFC_HANDLE_FSWIN32_OVERLAPPED 

The handle is for a Win32 Overlapped Buffer

OFC_HANDLE_FSWINCE_OVERLAPPED 

The handle is for a WinCE Overlapped Buffer

OFC_HANDLE_FSSMB_OVERLAPPED 

An Overlapped Buffer for CIFS)

OFC_HANDLE_FSDARWIN_OVERLAPPED 

An Overlapped Buffer for Darwin

OFC_HANDLE_FSLINUX_OVERLAPPED 

The handle is for a linux overlapped buffer

OFC_HANDLE_FSFILEX_OVERLAPPED 

The handle is for a threadx filex overlapped buffer

OFC_HANDLE_FSNUFILE_OVERLAPPED 

The handle is for a Nucleus filex overlapped buffer

OFC_HANDLE_FSANDROID_OVERLAPPED 

The handle is for a Nucleus filex overlapped buffer

OFC_HANDLE_FSRESOLVER_OVERLAPPED 

Resolver (android) buffer

OFC_HANDLE_FSDARWIN_FILE 

The handle is for a posix file

OFC_HANDLE_FSLINUX_FILE 

The handle for a linux file

OFC_HANDLE_FSFILEX_FILE 

The handle for a threadx filex file

OFC_HANDLE_FSANDROID_FILE 

The handle for a android file

OFC_HANDLE_FSRESOLVER_FILE 

The handle for android content file

OFC_HANDLE_FSNUFILE_FILE 

The handle for a Nucleus NUFile file

OFC_HANDLE_FSOTHER_FILE 

The handle for a port specific file

OFC_HANDLE_FSBROWSER_FILE 

The handle on a browser file

OFC_HANDLE_FSBOOKMARK_FILE 

A bookmark browser handle

OFC_HANDLE_SCHED 

The handle for a scheduler

OFC_HANDLE_APP 

The handle for an application

OFC_HANDLE_THREAD 

Handle for a platform thread

OFC_HANDLE_SOCKET 

handle is for an abstracted socket

OFC_HANDLE_SOCKET_IMPL 

Handle for a platform socket

OFC_HANDLE_EVENT 

Handle for an event

OFC_HANDLE_TIMER 

Handle for a timer

OFC_HANDLE_PIPE 

Handle for a pipe

OFC_HANDLE_WAIT_QUEUE 

Handle for a wait queue

OFC_HANDLE_TRANSACTION 

Handle for an ipc transaction

OFC_HANDLE_SMB_FILE 

Handle for a CIFS File system

OFC_HANDLE_MAILSLOT 

Handle for a mailslot

OFC_HANDLE_PROCESS 

Process

OFC_HANDLE_NUM 

Number of handle types

Function Documentation

◆ ofc_handle16_create()

OFC_CORE_LIB OFC_HANDLE16 ofc_handle16_create ( OFC_VOID context)

Create a 16 bit handle and associate with a context

Parameters
contextThe context to associate with the handle
Returns
The 16 bit handle

◆ ofc_handle16_destroy()

OFC_CORE_LIB OFC_VOID ofc_handle16_destroy ( OFC_HANDLE16  hHandle)

Destroy a 16 bit handle

Parameters
hHandleThe 16 bit handle to destroy

◆ ofc_handle16_free()

OFC_CORE_LIB OFC_VOID ofc_handle16_free ( OFC_VOID  )

Destroy the 16 bit handle structures

◆ ofc_handle16_init()

OFC_CORE_LIB OFC_VOID ofc_handle16_init ( OFC_VOID  )

Initialize the 16 bit handle support.

This should be called at system initialization/startup time to create the handle database and initialize the check digits.

◆ ofc_handle16_lock()

OFC_CORE_LIB OFC_VOID* ofc_handle16_lock ( OFC_HANDLE16  hHandle)

Reference a 16 bit handle

This will take a 16 bit handle, increment it's reference count and return the context to the handle.

Parameters
hHandleThe 16 bit handle
Returns
A pointer to the context associated with the handle. If the handle is invalid, OFC_NULL is returned.

◆ ofc_handle16_unlock()

OFC_CORE_LIB OFC_VOID ofc_handle16_unlock ( OFC_HANDLE16  hHandle)

Dereference a 16 bit handle

Parameters
hHandleThe 16 bit handle to dereference
Remarks
If the reference count reaches zero and the handle is marked for destruction the handle will be released.

◆ ofc_handle_create()

OFC_CORE_LIB OFC_HANDLE ofc_handle_create ( OFC_HANDLE_TYPE  hType,
OFC_VOID context 
)

Create a handle from some context

Parameters
hTypeThe handle Type
contextThe context to associate with the handle
Returns
The Handle

◆ ofc_handle_destroy()

OFC_CORE_LIB OFC_VOID ofc_handle_destroy ( OFC_HANDLE  handle)

Mark a handle to be destroyed

Parameters
handleThe handle to destroy
Remarks
If outstanding references are still held on the handle, the handle will be marked for destruction. If no references are outstanding, the handle will be destroyed immediately.

◆ ofc_handle_get_app()

OFC_CORE_LIB OFC_HANDLE ofc_handle_get_app ( OFC_HANDLE  hHandle)

Return the application associated with a handle

Parameters
hHandleThe handle to find the associated application for.
Returns
The handle of the application
See also
ofc_handle_set_app
Examples
smbcp.c, and test_file.c.

◆ ofc_handle_get_type()

OFC_CORE_LIB OFC_HANDLE_TYPE ofc_handle_get_type ( OFC_HANDLE  hHandle)

Get the handle type

Parameters
hHandleThe handle to find the type of
Returns
The type of the handle

◆ ofc_handle_get_wait_set()

OFC_CORE_LIB OFC_HANDLE ofc_handle_get_wait_set ( OFC_HANDLE  hHandle)

Return the Wait Set that this handle is part of

Parameters
hHandleThe handle to find the wait set for.
Returns
The handle of the wait set
See also
ofc_handle_set_app

◆ ofc_handle_lock()

OFC_CORE_LIB OFC_VOID* ofc_handle_lock ( OFC_HANDLE  handle)

Increase the reference count of a handle and return the context

Parameters
handleThe handle to reference
Returns
The context for the handle

◆ ofc_handle_lock_ex()

OFC_CORE_LIB OFC_VOID* ofc_handle_lock_ex ( OFC_HANDLE  handle,
OFC_HANDLE_TYPE  type 
)

Increase the reference count of a handle and return the context. Provide a handle type for validation.

Parameters
handleThe handle to reference
typeThe handle type to validate
Returns
The context for the handle

◆ ofc_handle_set_app()

OFC_CORE_LIB OFC_VOID ofc_handle_set_app ( OFC_HANDLE  hHandle,
OFC_HANDLE  hApp,
OFC_HANDLE  hSet 
)

Associate a handle with an application

Parameters
hHandleHandle to associate
hAppApplication to associate
hSetThe Wait Set that this handle is part of
Remarks
This is used when adding a handle to a wait set which the scheduler uses to wait for an event. By associating the handle with an application, the scheduler knows which application to service when an event occurs on a specific handle

◆ ofc_handle_unlock()

OFC_CORE_LIB OFC_VOID ofc_handle_unlock ( OFC_HANDLE  handle)

Decrement the reference count of a handle

Parameters
handleThe handle to unreference
Remarks
If the handle is marked to be destroyed and the decrement results in the reference count reaching 0, the handle will be freed