| 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>`

## 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]
typedef struct DocBindingData | DocBindingData
| [kdbio operation data]

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

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

## Detailed Description

I/O example binding.

Copyright
  BSD License (see LICENSE.md or https://www.libelektra.org)

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

## Typedef Documentation

## ◆ DocBindingData

typedef struct DocBindingData DocBindingData

[kdbio operation data]

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

## ◆ DocOperationData

typedef struct DocOperationData 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

enum 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

  foo | Some 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

  binding | I/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

  handle | some I/O management handle
  flags | flags 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

  handle | some 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

  handle | some 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

  bitmask | bit mask from I/O management library

Returns
  bit mask with Elektra's I/O flags (ElektraIoFdFlags)