$darkmode
Elektra 0.11.0
Classes | Typedefs | Enumerations | Functions
io_doc.c File Reference

I/O example binding. More...

#include <stdlib.h>
#include <string.h>
#include <kdbassert.h>
#include <kdbhelper.h>
#include <kdbio.h>
#include <kdblogger.h>
Include dependency graph for io_doc.c:

Classes

struct  SomeIoLibHandle
 Example I/O management library data structure. More...
 
struct  DocOperationData
 [kdbio operation data] More...
 
struct  DocBindingData
 [kdbio operation data] More...
 

Typedefs

typedef struct SomeIoLibHandle SomeIoLibHandle
 Example I/O management library data structure.
 
typedef struct DocOperationData DocOperationData
 [kdbio operation data] More...
 
typedef struct DocBindingData DocBindingData
 [kdbio operation data] More...
 

Enumerations

enum  SomeIoLibFlags { SOME_IOLIB_READABLE = 1 << 0 , SOME_IOLIB_WRITABLE = 1 << 1 }
 Example I/O mangement library bitmask flags. More...
 

Functions

DocOperationDatanewOperationData (void)
 [kdbio binding data] More...
 
int someBitMaskToElektraIoFlags (int bitmask)
 Convert your I/O library bit mask to Elektra's I/O flags. More...
 
void ioDocBindingFdCallback (SomeIoLibHandle *handle, int bitmask)
 Calls the associated operation callback. More...
 
void ioDocBindingTimerCallback (SomeIoLibHandle *handle)
 [kdbio operation callback] More...
 
void ioDocBindingIdleCallback (SomeIoLibHandle *handle)
 Calls the associated operation callback. More...
 
int ioDocBindingUpdateFd (ElektraIoFdOperation *fdOp)
 Update information about a file descriptor watched by I/O binding. More...
 
int ioDocBindingAddFd (ElektraIoInterface *binding, ElektraIoFdOperation *fdOp)
 Add file descriptor to I/O binding. More...
 
int ioDocBindingRemoveFd (ElektraIoFdOperation *fdOp)
 Remove file descriptor from I/O binding. More...
 
int ioDocBindingUpdateTimer (ElektraIoTimerOperation *timerOp)
 Update timer in I/O binding. More...
 
int ioDocBindingAddTimer (ElektraIoInterface *binding, ElektraIoTimerOperation *timerOp)
 Add timer for I/O binding. More...
 
int ioDocBindingRemoveTimer (ElektraIoTimerOperation *timerOp)
 Remove timer from I/O binding. More...
 
int ioDocBindingUpdateIdle (ElektraIoIdleOperation *idleOp)
 Update idle operation in I/O binding. More...
 
int ioDocBindingAddIdle (ElektraIoInterface *binding, ElektraIoIdleOperation *idleOp)
 Add idle operation to I/O binding. More...
 
int ioDocBindingRemoveIdle (ElektraIoIdleOperation *idleOp)
 Remove idle operation from I/O binding. More...
 
int ioDocBindingCleanup (ElektraIoInterface *binding)
 Cleanup. More...
 
ElektraIoInterfaceelektraIoDocNew (char *foo)
 Create and initialize a new doc I/O binding. More...
 

Detailed Description

I/O example binding.

All functions except the I/O binding entry point (elektraIoDocNew()) would normally be static but for documentation purposes they are not.

Typedef Documentation

◆ DocBindingData

[kdbio operation data]

[kdbio binding data] Container for additional information for an I/O binding.

◆ DocOperationData

[kdbio operation data]

Container for additional information for I/O binding operations.

It is helpful to create a data structure for your binding to store additional data

Enumeration Type Documentation

◆ SomeIoLibFlags

Example I/O mangement library bitmask flags.

Enumerator
SOME_IOLIB_READABLE 

indicates that the file descriptor is readable

SOME_IOLIB_WRITABLE 

indicates that the file descriptor is readable

Function Documentation

◆ elektraIoDocNew()

ElektraIoInterface* elektraIoDocNew ( char *  foo)

Create and initialize a new doc I/O binding.

Parameters
fooSome data from I/O management library (e.g. a handle)
Returns
Populated I/O interface

[kdbio binding create]

[kdbio binding create] [kdbio binding setdata]

[kdbio binding setdata]

◆ ioDocBindingAddFd()

int ioDocBindingAddFd ( ElektraIoInterface binding,
ElektraIoFdOperation fdOp 
)

Add file descriptor to I/O binding.

See also
kdbio.h ElektraIoBindingAddFd

[kdbio binding addfd]

[kdbio binding addfd]

◆ ioDocBindingAddIdle()

int ioDocBindingAddIdle ( ElektraIoInterface binding,
ElektraIoIdleOperation idleOp 
)

Add idle operation to I/O binding.

See also
kdbio.h ElektraIoBindingAddIdle

◆ ioDocBindingAddTimer()

int ioDocBindingAddTimer ( ElektraIoInterface binding,
ElektraIoTimerOperation timerOp 
)

Add timer for I/O binding.

See also
kdbio.h ElektraIoBindingAddTimer

◆ ioDocBindingCleanup()

int ioDocBindingCleanup ( ElektraIoInterface binding)

Cleanup.

Parameters
bindingI/O binding
See also
kdbio.h ElektraIoBindingCleanup

◆ ioDocBindingFdCallback()

void ioDocBindingFdCallback ( SomeIoLibHandle handle,
int  bitmask 
)

Calls the associated operation callback.

Called by your I/O management library whenever a file descriptor status has changed.

Parameters
handlesome I/O management handle
flagsflags bit mask [kdbio operation callback]

◆ ioDocBindingIdleCallback()

void ioDocBindingIdleCallback ( SomeIoLibHandle handle)

Calls the associated operation callback.

Called by your I/O management library whenever an idle operation can run without interfering with other operations.

Parameters
handlesome I/O management handle

◆ ioDocBindingRemoveFd()

int ioDocBindingRemoveFd ( ElektraIoFdOperation fdOp)

Remove file descriptor from I/O binding.

See also
kdbio.h ElektraIoBindingRemoveFd

[kdbio operation getdata]

[kdbio operation getdata]

◆ ioDocBindingRemoveIdle()

int ioDocBindingRemoveIdle ( ElektraIoIdleOperation idleOp)

Remove idle operation from I/O binding.

See also
kdbio.h ElektraIoBindingRemoveIdle

◆ ioDocBindingRemoveTimer()

int ioDocBindingRemoveTimer ( ElektraIoTimerOperation timerOp)

Remove timer from I/O binding.

See also
kdbio.h ElektraIoBindingRemoveTimer

◆ ioDocBindingTimerCallback()

void ioDocBindingTimerCallback ( SomeIoLibHandle handle)

[kdbio operation callback]

Calls the associated operation callback. Called by your I/O management library whenever a timer interval has passed.

Parameters
handlesome I/O management handle

◆ ioDocBindingUpdateFd()

int ioDocBindingUpdateFd ( ElektraIoFdOperation fdOp)

Update information about a file descriptor watched by I/O binding.

See also
kdbio.h ElektraIoBindingUpdateFd

◆ ioDocBindingUpdateIdle()

int ioDocBindingUpdateIdle ( ElektraIoIdleOperation idleOp)

Update idle operation in I/O binding.

See also
kdbio.h ElektraIoBindingUpdateIdle

◆ ioDocBindingUpdateTimer()

int ioDocBindingUpdateTimer ( ElektraIoTimerOperation timerOp)

Update timer in I/O binding.

See also
kdbio.h ElektraIoBindingUpdateTimer

◆ newOperationData()

DocOperationData* newOperationData ( void  )

[kdbio binding data]

A little helper function for allocating our custom operation data structure

Returns
New data structure, remember to call elektraFree()

◆ someBitMaskToElektraIoFlags()

int someBitMaskToElektraIoFlags ( int  bitmask)

Convert your I/O library bit mask to Elektra's I/O flags.

Parameters
bitmaskbit mask from I/O management library
Returns
bit mask with Elektra's I/O flags (ElektraIoFdFlags)