Nagios
4.4.6
Dev docs for Nagios core and neb-module hackers
|
Go to the documentation of this file. 1 #ifndef LIBNAGIOS_IOCACHE_H_INCLUDED
2 #define LIBNAGIOS_IOCACHE_H_INCLUDED
5 #include <sys/socket.h>
20 typedef struct iocache iocache;
51 extern int iocache_grow(iocache *ioc,
unsigned long increment);
97 extern char *
iocache_use_delim(iocache *ioc,
const char *delim,
size_t delim_len,
unsigned long *size);
133 extern int iocache_add(iocache *ioc,
char *buf,
unsigned int len);
147 extern int iocache_sendto(iocache *ioc,
int fd,
char *buf,
unsigned int len,
int flags,
const struct sockaddr *dest_addr, socklen_t addrlen);
161 static inline int iocache_send(iocache *ioc,
int fd,
char *buf,
unsigned int len,
int flags)
176 static inline int iocache_write(iocache *ioc,
int fd,
char *buf,
unsigned int len)
178 return iocache_send(ioc, fd, buf, len, 0);
int iocache_sendto(iocache *ioc, int fd, char *buf, unsigned int len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen)
Like sendto(), but sends all cached data prior to the requested.
void iocache_destroy(iocache *ioc)
Destroys an iocache object, freeing all memory allocated to it.
iocache * iocache_create(unsigned long size)
Creates the iocache object, initializing it with the given size.
int iocache_add(iocache *ioc, char *buf, unsigned int len)
Add data to the iocache buffer The data is copied, so it can safely be taken from the stack in a func...
void iocache_reset(iocache *ioc)
Resets an iocache struct, discarding all data in it without free()'ing any memory.
int iocache_resize(iocache *ioc, unsigned long new_size)
Resizes the buffer in an io cache.
unsigned long iocache_size(iocache *ioc)
Returns the total size of the io cache.
unsigned long iocache_capacity(iocache *ioc)
Returns remaining read capacity of the io cache.
int iocache_read(iocache *ioc, int fd)
Read data into the iocache buffer.
int iocache_unuse_size(iocache *ioc, unsigned long size)
Forget that a specified number of bytes have been used.
char * iocache_use_size(iocache *ioc, unsigned long size)
Use a chunk of data from iocache based on size.
char * iocache_use_delim(iocache *ioc, const char *delim, size_t delim_len, unsigned long *size)
Use a chunk of data from iocache based on delimiter.
int iocache_grow(iocache *ioc, unsigned long increment)
Grows an iocache object This uses iocache_resize() internally.
unsigned long iocache_available(iocache *ioc)
Return the amount of unread but stored data in the io cache.