libosmovty 1.13.1.1-afb4 Osmocom VTY library

Data Structures | Macros | Functions
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 buffer * | buffer_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_data * | buffer_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

References buffer_data::cp, data, buffer::head, buffer_data::next, buffer::size, buffer_data::sp, and buffer::tail.

Referenced by buffer_put().

## ◆ 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
| ) |  |

References BUFFER_EMPTY, buffer_flush_available(), BUFFER_PENDING, buffer::head, and buffer_data::sp.

Referenced by client_data(), vty_close(), and vty_flush().

## ◆ buffer_flush_available()

buffer_status_t buffer_flush_available | ( | struct buffer * | b,
|  | int | fd
| ) |  |

References BUFFER_DATA_FREE, BUFFER_EMPTY, BUFFER_ERROR, BUFFER_PENDING, buffer_data::cp, buffer_data::data, ERRNO_IO_RETRY, buffer::head, MAX_CHUNKS, MAX_FLUSH, buffer_data::next, buffer_data::sp, and buffer::tail.

Referenced by buffer_flush_all(), and buffer_write().

## ◆ 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
| ) |  |

References buffer_add(), data, buffer::size, and buffer::tail.

Referenced by buffer_putc(), buffer_putstr(), buffer_write(), vty_out_newline(), vty_out_va(), and vty_write().

## ◆ 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 | ) |

References BUFFER_DATA_FREE, data, buffer::head, buffer_data::next, and buffer::tail.

Referenced by buffer_free(), vty_buffer_reset(), vty_read(), and vty_reset().

## ◆ buffer_write()

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

References BUFFER_EMPTY, BUFFER_ERROR, buffer_flush_available(), BUFFER_PENDING, buffer_put(), ERRNO_IO_RETRY, and buffer::head.