libosmovty 1.9.0.196-9975
Osmocom VTY library
buffer.c File Reference

Buffering of output and input. More...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stddef.h>
#include <sys/uio.h>
#include <osmocom/core/talloc.h>
#include <osmocom/vty/buffer.h>
#include <osmocom/vty/vty.h>

Data Structures

struct  buffer
 
struct  buffer_data
 

Macros

#define BUFFER_SIZE_DEFAULT   4096
 
#define BUFFER_DATA_FREE(D)   talloc_free((D))
 
#define MAX_CHUNKS   16
 
#define MAX_FLUSH   131072
 

Functions

struct bufferbuffer_new (void *ctx, size_t size)
 
void buffer_free (struct buffer *b)
 
char * buffer_getstr (struct buffer *b)
 
int buffer_empty (struct buffer *b)
 
void buffer_reset (struct buffer *b)
 
static struct buffer_databuffer_add (struct buffer *b)
 
void buffer_put (struct buffer *b, const void *p, size_t size)
 
void buffer_putc (struct buffer *b, unsigned char c)
 
void buffer_putstr (struct buffer *b, const char *c)
 
buffer_status_t buffer_flush_all (struct buffer *b, int fd)
 
buffer_status_t buffer_flush_available (struct buffer *b, int fd)
 
buffer_status_t buffer_write (struct buffer *b, int fd, const void *p, size_t size)
 

Detailed Description

Buffering of output and input.

Macro Definition Documentation

◆ BUFFER_DATA_FREE

#define BUFFER_DATA_FREE (   D)    talloc_free((D))

◆ BUFFER_SIZE_DEFAULT

#define BUFFER_SIZE_DEFAULT   4096

◆ MAX_CHUNKS

#define MAX_CHUNKS   16

◆ MAX_FLUSH

#define MAX_FLUSH   131072

Function Documentation

◆ buffer_add()

static struct buffer_data * buffer_add ( struct buffer b)
static

◆ buffer_empty()

int buffer_empty ( struct buffer b)

References buffer::head.

◆ buffer_flush_all()

buffer_status_t buffer_flush_all ( struct buffer b,
int  fd 
)

◆ buffer_flush_available()

◆ buffer_free()

void buffer_free ( struct buffer b)

References buffer_reset().

Referenced by vty_close(), and vty_new().

◆ buffer_getstr()

char * buffer_getstr ( struct buffer b)

References data, buffer::head, and tall_vty_ctx.

◆ buffer_new()

struct buffer * buffer_new ( void *  ctx,
size_t  size 
)

References BUFFER_SIZE_DEFAULT, and buffer::size.

Referenced by vty_new().

◆ buffer_put()

void buffer_put ( struct buffer b,
const void *  p,
size_t  size 
)

◆ buffer_putc()

void buffer_putc ( struct buffer b,
unsigned char  c 
)

References buffer_put(), and c.

◆ buffer_putstr()

void buffer_putstr ( struct buffer b,
const char *  c 
)

References buffer_put(), and c.

◆ buffer_reset()

void buffer_reset ( struct buffer b)

◆ buffer_write()

buffer_status_t buffer_write ( struct buffer b,
int  fd,
const void *  p,
size_t  size 
)