libextractor  1.11
About: GNU libextractor is a library used to extract meta-data from files of arbitrary type.
  Fossies Dox: libextractor-1.11.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

extractor_ipc_gnu.c File Reference

IPC with plugin for GNU/POSIX systems. More...

#include "platform.h"
#include "extractor.h"
#include "extractor_datasource.h"
#include "extractor_logging.h"
#include "extractor_plugin_main.h"
#include "extractor_plugins.h"
#include "extractor_ipc.h"
#include <dirent.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/shm.h>
#include <signal.h>
Include dependency graph for extractor_ipc_gnu.c:

Go to the source code of this file.

Data Structures

struct  EXTRACTOR_SharedMemory
 
struct  EXTRACTOR_Channel
 

Functions

struct EXTRACTOR_SharedMemoryEXTRACTOR_IPC_shared_memory_create_ (size_t size)
 
unsigned int EXTRACTOR_IPC_shared_memory_change_rc_ (struct EXTRACTOR_SharedMemory *shm, int delta)
 
void EXTRACTOR_IPC_shared_memory_destroy_ (struct EXTRACTOR_SharedMemory *shm)
 
ssize_t EXTRACTOR_IPC_shared_memory_set_ (struct EXTRACTOR_SharedMemory *shm, struct EXTRACTOR_Datasource *ds, uint64_t off, size_t size)
 
uint64_t EXTRACTOR_datasource_get_pos_ (struct EXTRACTOR_Datasource *ds)
 
struct EXTRACTOR_ChannelEXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin, struct EXTRACTOR_SharedMemory *shm)
 
void EXTRACTOR_IPC_channel_destroy_ (struct EXTRACTOR_Channel *channel)
 
ssize_t EXTRACTOR_IPC_channel_send_ (struct EXTRACTOR_Channel *channel, const void *data, size_t size)
 
int EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel **channels, unsigned int num_channels, EXTRACTOR_ChannelMessageProcessor proc, void *proc_cls)
 

Detailed Description

IPC with plugin for GNU/POSIX systems.

Author
Christian Grothoff

Definition in file extractor_ipc_gnu.c.

Function Documentation

◆ EXTRACTOR_datasource_get_pos_()

uint64_t EXTRACTOR_datasource_get_pos_ ( struct EXTRACTOR_Datasource ds)

Query datasource for current position

Parameters
dsdata source to query
Returns
current position in the datasource or UINT_MAX on error

Definition at line 259 of file extractor_ipc_gnu.c.

◆ EXTRACTOR_IPC_channel_create_()

struct EXTRACTOR_Channel* EXTRACTOR_IPC_channel_create_ ( struct EXTRACTOR_PluginList plugin,
struct EXTRACTOR_SharedMemory shm 
)

Create a channel to communicate with a process wrapping the plugin of the given name. Starts the process as well.

Parameters
pluginthe plugin
shmmemory to share with the process
Returns
NULL on error, otherwise IPC channel

Definition at line 280 of file extractor_ipc_gnu.c.

◆ EXTRACTOR_IPC_channel_destroy_()

void EXTRACTOR_IPC_channel_destroy_ ( struct EXTRACTOR_Channel channel)

Destroy communication channel with a plugin/process. Also destroys the process.

Parameters
channelchannel to communicate with the plugin

Definition at line 399 of file extractor_ipc_gnu.c.

Referenced by EXTRACTOR_IPC_channel_create_(), and EXTRACTOR_IPC_channel_recv_().

◆ EXTRACTOR_IPC_channel_recv_()

int EXTRACTOR_IPC_channel_recv_ ( struct EXTRACTOR_Channel **  channels,
unsigned int  num_channels,
EXTRACTOR_ChannelMessageProcessor  proc,
void *  proc_cls 
)

Receive data from any of the given IPC channels (blocking). Wait for one of the plugins to reply. Selects on plugin output pipes, runs 'receive_reply' on each activated pipe until it gets a seek request or a done message. Called repeatedly by the user until all pipes are dry or broken.

Parameters
channelsarray of channels, channels that break may be set to NULL
num_channelslength of the channels array
procfunction to call to process messages (may be called more than once)
proc_clsclosure for proc
Returns
-1 on error, 1 on success

Definition at line 467 of file extractor_ipc_gnu.c.

◆ EXTRACTOR_IPC_channel_send_()

ssize_t EXTRACTOR_IPC_channel_send_ ( struct EXTRACTOR_Channel channel,
const void *  data,
size_t  size 
)

Send data via the given IPC channel (blocking).

Parameters
channelchannel to communicate with the plugin
bufdata to send
sizenumber of bytes in buf to send
Returns
-1 on error, number of bytes sent on success (never does partial writes)

Definition at line 428 of file extractor_ipc_gnu.c.

Referenced by EXTRACTOR_IPC_channel_create_().

◆ EXTRACTOR_IPC_shared_memory_change_rc_()

unsigned int EXTRACTOR_IPC_shared_memory_change_rc_ ( struct EXTRACTOR_SharedMemory shm,
int  delta 
)

Change the reference counter for this shm instance.

Parameters
shminstance to update
deltavalue to change RC by
Returns
new RC

Definition at line 196 of file extractor_ipc_gnu.c.

◆ EXTRACTOR_IPC_shared_memory_create_()

struct EXTRACTOR_SharedMemory* EXTRACTOR_IPC_shared_memory_create_ ( size_t  size)

Create a shared memory area.

Parameters
sizesize of the shared area
Returns
NULL on error

Definition at line 134 of file extractor_ipc_gnu.c.

◆ EXTRACTOR_IPC_shared_memory_destroy_()

void EXTRACTOR_IPC_shared_memory_destroy_ ( struct EXTRACTOR_SharedMemory shm)

Destroy shared memory area.

Parameters
shmmemory area to destroy
Returns
NULL on error

Definition at line 211 of file extractor_ipc_gnu.c.

◆ EXTRACTOR_IPC_shared_memory_set_()

ssize_t EXTRACTOR_IPC_shared_memory_set_ ( struct EXTRACTOR_SharedMemory shm,
struct EXTRACTOR_Datasource ds,
uint64_t  off,
size_t  size 
)

Initialize shared memory area from data source.

Parameters
shmmemory area to initialize
dsdata source to use for initialization
offoffset to use in data source
sizenumber of bytes to copy
Returns
-1 on error, otherwise number of bytes copied

Definition at line 231 of file extractor_ipc_gnu.c.