$darkmode
Elektra 0.10.0
|
Implementation of I/O functions as defined in kdbio.h. More...
#include <kdbhelper.h>
#include <kdbinvoke.h>
#include <kdbio.h>
#include <kdbioplugin.h>
#include <kdbioprivate.h>
#include <kdblogger.h>
#include <kdbprivate.h>
#include <fcntl.h>
#include <stdio.h>
Functions | |
int | elektraIoContract (KeySet *contract, ElektraIoInterface *ioBinding) |
Creates a contract for use with kdbOpen() that sets up an I/O binding. More... | |
ElektraIoInterface * | elektraIoGetBinding (KDB *kdb) |
Get I/O binding for asynchronous I/O operations for KDB instance. More... | |
ElektraIoInterface * | elektraIoNewBinding (ElektraIoBindingAddFd *addFd, ElektraIoBindingUpdateFd *updateFd, ElektraIoBindingRemoveFd *removeFd, ElektraIoBindingAddTimer *addTimer, ElektraIoBindingUpdateTimer *updateTimer, ElektraIoBindingRemoveTimer *removeTimer, ElektraIoBindingAddIdle *addIdle, ElektraIoBindingUpdateIdle *updateIdle, ElektraIoBindingRemoveIdle *removeIdle, ElektraIoBindingCleanup *cleanup) |
Create a new I/O binding. More... | |
int | elektraIoBindingAddFd (ElektraIoInterface *binding, ElektraIoFdOperation *fdOp) |
Add file descriptor to be watched by I/O binding. More... | |
int | elektraIoBindingUpdateFd (ElektraIoFdOperation *fdOp) |
Notify I/O binding about changes to file descriptor watch operation. More... | |
int | elektraIoBindingRemoveFd (ElektraIoFdOperation *fdOp) |
Remove file descriptor from I/O binding. More... | |
int | elektraIoBindingAddTimer (ElektraIoInterface *binding, ElektraIoTimerOperation *timerOp) |
Add timer to I/O binding. More... | |
int | elektraIoBindingUpdateTimer (ElektraIoTimerOperation *timerOp) |
Notifiy I/O binding about changes to timer structure. More... | |
int | elektraIoBindingRemoveTimer (ElektraIoTimerOperation *timerOp) |
Remove timer from I/O binding. More... | |
int | elektraIoBindingAddIdle (ElektraIoInterface *binding, ElektraIoIdleOperation *idleOp) |
Add idle to I/O binding. More... | |
int | elektraIoBindingUpdateIdle (ElektraIoIdleOperation *idleOp) |
Notifiy I/O binding about changes to idle structure. More... | |
int | elektraIoBindingRemoveIdle (ElektraIoIdleOperation *idleOp) |
Remove idle from I/O binding. More... | |
int | elektraIoBindingCleanup (ElektraIoInterface *binding) |
Free memory used by I/O binding. More... | |
void * | elektraIoBindingGetData (ElektraIoInterface *binding) |
Get private data from I/O Binding. More... | |
int | elektraIoBindingSetData (ElektraIoInterface *binding, void *data) |
Set private data from I/O Binding. More... | |
ElektraIoFdOperation * | elektraIoNewFdOperation (int fd, int flags, int enabled, ElektraIoFdCallback callback, void *privateData) |
Create a new file descriptor watch operation. More... | |
ElektraIoTimerOperation * | elektraIoNewTimerOperation (unsigned int interval, int enabled, ElektraIoTimerCallback callback, void *privateData) |
Create a new timer operation. More... | |
ElektraIoIdleOperation * | elektraIoNewIdleOperation (int enabled, ElektraIoIdleCallback callback, void *privateData) |
Create a new idle operation. More... | |
int | elektraIoFdSetEnabled (ElektraIoFdOperation *fdOp, int enabled) |
Enable or disable file descriptor watch operation. More... | |
int | elektraIoFdSetFlags (ElektraIoFdOperation *fdOp, int flags) |
Update flag bitmask of file descriptor watch operation. More... | |
int | elektraIoTimerSetEnabled (ElektraIoTimerOperation *timerOp, int enabled) |
Enable or disable timer operation. More... | |
int | elektraIoTimerSetInterval (ElektraIoTimerOperation *timerOp, unsigned int interval) |
Update interval of timer operation. More... | |
int | elektraIoIdleSetEnabled (ElektraIoIdleOperation *idleOp, int enabled) |
Enable or disable idle operation. More... | |
int | elektraIoFdGetFd (ElektraIoFdOperation *fdOp) |
Get file descriptor number from operation. More... | |
void * | elektraIoFdGetData (ElektraIoFdOperation *fdOp) |
Get private data from operation. More... | |
int | elektraIoFdSetBindingData (ElektraIoFdOperation *fdOp, void *data) |
Set private binding data for operation. More... | |
void * | elektraIoFdGetBindingData (ElektraIoFdOperation *fdOp) |
Get private binding data from operation. More... | |
ElektraIoInterface * | elektraIoFdGetBinding (ElektraIoFdOperation *fdOp) |
Get binding from operation. More... | |
int | elektraIoFdIsEnabled (ElektraIoFdOperation *fdOp) |
Check if file descriptor watch operation is enabled or disabled. More... | |
int | elektraIoFdGetFlags (ElektraIoFdOperation *fdOp) |
Get flag bitmask of file descriptor watch operation. More... | |
ElektraIoFdCallback | elektraIoFdGetCallback (ElektraIoFdOperation *fdOp) |
Get callback of file descriptor watch operation. More... | |
int | elektraIoTimerSetBindingData (ElektraIoTimerOperation *timerOp, void *data) |
Set private binding data for operation. More... | |
void * | elektraIoTimerGetBindingData (ElektraIoTimerOperation *timerOp) |
Get private binding data from operation. More... | |
ElektraIoInterface * | elektraIoTimerGetBinding (ElektraIoTimerOperation *timerOp) |
Get binding from operation. More... | |
void * | elektraIoTimerGetData (ElektraIoTimerOperation *timerOp) |
Get private data from operation. More... | |
int | elektraIoTimerIsEnabled (ElektraIoTimerOperation *timerOp) |
Check if timer operation is enabled or disabled. More... | |
unsigned int | elektraIoTimerGetInterval (ElektraIoTimerOperation *timerOp) |
Get interval of timer operation. More... | |
ElektraIoTimerCallback | elektraIoTimerGetCallback (ElektraIoTimerOperation *timerOp) |
Get callback of timer operation. More... | |
int | elektraIoIdleSetBindingData (ElektraIoIdleOperation *idleOp, void *data) |
Set private binding data for operation. More... | |
void * | elektraIoIdleGetBindingData (ElektraIoIdleOperation *idleOp) |
Get private binding data from operation. More... | |
ElektraIoInterface * | elektraIoIdleGetBinding (ElektraIoIdleOperation *idleOp) |
Get binding from operation. More... | |
void * | elektraIoIdleGetData (ElektraIoIdleOperation *idleOp) |
Get private data from operation. More... | |
int | elektraIoIdleIsEnabled (ElektraIoIdleOperation *idleOp) |
Check if idle operation is enabled or disabled. More... | |
ElektraIoIdleCallback | elektraIoIdleGetCallback (ElektraIoIdleOperation *idleOp) |
Get callback of idle operation. More... | |
Implementation of I/O functions as defined in kdbio.h.
int elektraIoBindingAddFd | ( | ElektraIoInterface * | binding, |
ElektraIoFdOperation * | fdOp | ||
) |
Add file descriptor to be watched by I/O binding.
An operation may only be added to one binding.
binding | I/O binding handle |
fdOp | file descriptor operation handle |
1 | on success |
0 | on error |
int elektraIoBindingAddIdle | ( | ElektraIoInterface * | binding, |
ElektraIoIdleOperation * | idleOp | ||
) |
Add idle to I/O binding.
Idle callbacks are executed without negative effects on other IO sources or the application (e.g. next event loop iteration) An operation may only be added to one binding.
binding | I/O binding handle |
idleOp | idle operation handle |
1 | on success |
0 | on error |
int elektraIoBindingAddTimer | ( | ElektraIoInterface * | binding, |
ElektraIoTimerOperation * | timerOp | ||
) |
Add timer to I/O binding.
Timeouts callbacks are executed after the initial interval has elapsed and then repeatedly after the interval has elapsed. An operation may only be added to one binding.
binding | I/O binding handle |
timerOp | timer operation handle |
1 | on success |
0 | on error |
int elektraIoBindingCleanup | ( | ElektraIoInterface * | binding | ) |
Free memory used by I/O binding.
All added operations have to be removed before calling this function.
binding | I/O binding handle |
1 | on success |
0 | on error |
void* elektraIoBindingGetData | ( | ElektraIoInterface * | binding | ) |
Get private data from I/O Binding.
To be used by I/O binding implementations only.
binding | I/O-Binding handle |
int elektraIoBindingRemoveFd | ( | ElektraIoFdOperation * | fdOp | ) |
Remove file descriptor from I/O binding.
fdOp | file descriptor operation handle |
1 | on success |
0 | on error |
int elektraIoBindingRemoveIdle | ( | ElektraIoIdleOperation * | idleOp | ) |
Remove idle from I/O binding.
idleOp | idle operation handle |
1 | on success |
0 | on error |
int elektraIoBindingRemoveTimer | ( | ElektraIoTimerOperation * | timerOp | ) |
Remove timer from I/O binding.
timerOp | timer operation handle |
1 | on success |
0 | on error |
int elektraIoBindingSetData | ( | ElektraIoInterface * | binding, |
void * | data | ||
) |
Set private data from I/O Binding.
To be used by I/O binding implementations only.
binding | I/O binding handle |
data | private data |
1 | on success |
0 | on error |
int elektraIoBindingUpdateFd | ( | ElektraIoFdOperation * | fdOp | ) |
Notify I/O binding about changes to file descriptor watch operation.
fdOp | file descriptor operation handle |
1 | on success |
0 | on error |
int elektraIoBindingUpdateIdle | ( | ElektraIoIdleOperation * | idleOp | ) |
Notifiy I/O binding about changes to idle structure.
idleOp | idle operation handle |
1 | on success |
0 | on error |
int elektraIoBindingUpdateTimer | ( | ElektraIoTimerOperation * | timerOp | ) |
Notifiy I/O binding about changes to timer structure.
timerOp | timer operation handle |
1 | on success |
0 | on error |
int elektraIoContract | ( | KeySet * | contract, |
ElektraIoInterface * | ioBinding | ||
) |
Creates a contract for use with kdbOpen() that sets up an I/O binding.
When you call kdbOpen() with this contract, the KDB instance will use ioBinding
as its I/O binding.
contract | The keyset into which the contract is written. |
ioBinding | The ioBinding to use. |
-1 | if contract or ioBinding are NULL |
0 | on success |
ElektraIoInterface* elektraIoFdGetBinding | ( | ElektraIoFdOperation * | fdOp | ) |
Get binding from operation.
fdOp | fd operation handle |
void* elektraIoFdGetBindingData | ( | ElektraIoFdOperation * | fdOp | ) |
Get private binding data from operation.
fdOp | file descriptor operation handle |
ElektraIoFdCallback elektraIoFdGetCallback | ( | ElektraIoFdOperation * | fdOp | ) |
Get callback of file descriptor watch operation.
fdOp | file descriptor operation handle |
void* elektraIoFdGetData | ( | ElektraIoFdOperation * | fdOp | ) |
Get private data from operation.
fdOp | file descriptor operation handle |
int elektraIoFdGetFd | ( | ElektraIoFdOperation * | fdOp | ) |
Get file descriptor number from operation.
fdOp | file descriptor operation handle |
int elektraIoFdGetFlags | ( | ElektraIoFdOperation * | fdOp | ) |
Get flag bitmask of file descriptor watch operation.
fdOp | file descriptor operation handle |
int elektraIoFdIsEnabled | ( | ElektraIoFdOperation * | fdOp | ) |
Check if file descriptor watch operation is enabled or disabled.
fdOp | file descriptor operation handle |
0 | if disabled |
1 | if enabled |
int elektraIoFdSetBindingData | ( | ElektraIoFdOperation * | fdOp, |
void * | data | ||
) |
Set private binding data for operation.
fdOp | file descriptor operation handle |
data | pointer to data |
1 | on success |
0 | on error |
int elektraIoFdSetEnabled | ( | ElektraIoFdOperation * | fdOp, |
int | enabled | ||
) |
Enable or disable file descriptor watch operation.
fdOp | file descriptor operation handle |
enabled | 0 to disabled, any other value for enabled |
1 | on success |
0 | on error |
int elektraIoFdSetFlags | ( | ElektraIoFdOperation * | fdOp, |
int | flags | ||
) |
Update flag bitmask of file descriptor watch operation.
fdOp | file descriptor operation handle |
flags | watch flag bitmask (see ElektraIoFdFlags). |
1 | on success |
0 | on error |
ElektraIoInterface* elektraIoGetBinding | ( | KDB * | kdb | ) |
Get I/O binding for asynchronous I/O operations for KDB instance.
Returns NULL if no I/O binding was set.
kdb | KDB instance |
ElektraIoInterface* elektraIoIdleGetBinding | ( | ElektraIoIdleOperation * | idleOp | ) |
Get binding from operation.
idleOp | idle operation handle |
void* elektraIoIdleGetBindingData | ( | ElektraIoIdleOperation * | idleOp | ) |
Get private binding data from operation.
idleOp | idle operation handle |
ElektraIoIdleCallback elektraIoIdleGetCallback | ( | ElektraIoIdleOperation * | idleOp | ) |
Get callback of idle operation.
idleOp | idle operation handle |
void* elektraIoIdleGetData | ( | ElektraIoIdleOperation * | idleOp | ) |
Get private data from operation.
idleOp | idle operation handle |
int elektraIoIdleIsEnabled | ( | ElektraIoIdleOperation * | idleOp | ) |
Check if idle operation is enabled or disabled.
idleOp | idle operation handle |
0 | if disabled |
1 | if enabled |
int elektraIoIdleSetBindingData | ( | ElektraIoIdleOperation * | idleOp, |
void * | data | ||
) |
Set private binding data for operation.
idleOp | idle operation handle |
data | pointer to data |
1 | on success |
0 | on error |
int elektraIoIdleSetEnabled | ( | ElektraIoIdleOperation * | idleOp, |
int | enabled | ||
) |
Enable or disable idle operation.
idleOp | idle operation handle |
enabled | 0 to disabled, any other value for enabled |
1 | on success |
0 | on error |
ElektraIoInterface* elektraIoNewBinding | ( | ElektraIoBindingAddFd * | addFd, |
ElektraIoBindingUpdateFd * | updateFd, | ||
ElektraIoBindingRemoveFd * | removeFd, | ||
ElektraIoBindingAddTimer * | addTimer, | ||
ElektraIoBindingUpdateTimer * | updateTimer, | ||
ElektraIoBindingRemoveTimer * | removeTimer, | ||
ElektraIoBindingAddIdle * | addIdle, | ||
ElektraIoBindingUpdateIdle * | updateIdle, | ||
ElektraIoBindingRemoveIdle * | removeIdle, | ||
ElektraIoBindingCleanup * | cleanup | ||
) |
Create a new I/O binding.
Make sure to free returned data in ElektraIoBindingCleanup.
addFd | function for adding a file descriptor watch operation |
updateFd | function for updating a file descriptor operation |
removeFd | function for removing a file descriptor operation |
addTimer | function for adding a timer operation |
updateTimer | function for updateing a timer operation |
removeTimer | function for removing a timer operation |
addIdle | function for adding an idle operation |
updateIdle | function for updating an idle operation |
removeIdle | function for removing an idle operation |
cleanup | function for cleaning up binding data |
ElektraIoFdOperation* elektraIoNewFdOperation | ( | int | fd, |
int | flags, | ||
int | enabled, | ||
ElektraIoFdCallback | callback, | ||
void * | data | ||
) |
Create a new file descriptor watch operation.
Free returned data after use.
fd | file descriptor number |
flags | watch flag bitmask (see ElektraIoFdFlags). Select on which file descriptor state changes the callback should be invoked |
enabled | 0 to disabled, any other value for enabled |
callback | Called when file descriptor state has changes |
data | Custom private data |
ElektraIoIdleOperation* elektraIoNewIdleOperation | ( | int | enabled, |
ElektraIoIdleCallback | callback, | ||
void * | data | ||
) |
Create a new idle operation.
Free returned data after use.
enabled | 0 to disable, any other value for enabled |
callback | Called when file descriptor state has changes |
data | Custom private data |
ElektraIoTimerOperation* elektraIoNewTimerOperation | ( | unsigned int | interval, |
int | enabled, | ||
ElektraIoTimerCallback | callback, | ||
void * | data | ||
) |
Create a new timer operation.
Free returned data after use.
interval | timer interval in milliseconds |
enabled | 0 to disable, any other value for enabled |
callback | Called when file descriptor state has changes |
data | Custom private data |
ElektraIoInterface* elektraIoTimerGetBinding | ( | ElektraIoTimerOperation * | timerOp | ) |
Get binding from operation.
timerOp | timer operation handle |
void* elektraIoTimerGetBindingData | ( | ElektraIoTimerOperation * | timerOp | ) |
Get private binding data from operation.
timerOp | timer operation handle |
ElektraIoTimerCallback elektraIoTimerGetCallback | ( | ElektraIoTimerOperation * | timerOp | ) |
Get callback of timer operation.
timerOp | timer operation handle |
void* elektraIoTimerGetData | ( | ElektraIoTimerOperation * | timerOp | ) |
Get private data from operation.
timerOp | timer operation handle |
unsigned int elektraIoTimerGetInterval | ( | ElektraIoTimerOperation * | timerOp | ) |
Get interval of timer operation.
timerOp | timer operation handle |
int elektraIoTimerIsEnabled | ( | ElektraIoTimerOperation * | timerOp | ) |
Check if timer operation is enabled or disabled.
timerOp | timer operation handle |
0 | if disabled |
1 | if enabled |
int elektraIoTimerSetBindingData | ( | ElektraIoTimerOperation * | timerOp, |
void * | data | ||
) |
Set private binding data for operation.
timerOp | timer operation handle |
data | pointer to data |
1 | on success |
0 | on error |
int elektraIoTimerSetEnabled | ( | ElektraIoTimerOperation * | timerOp, |
int | enabled | ||
) |
Enable or disable timer operation.
timerOp | timer operation handle |
enabled | 0 to disabled, any other value for enabled |
1 | on success |
0 | on error |
int elektraIoTimerSetInterval | ( | ElektraIoTimerOperation * | timerOp, |
unsigned int | interval | ||
) |
Update interval of timer operation.
timerOp | timer operation handle |
interval | timer interval in milliseconds |
1 | on success |
0 | on error |