CNDP
22.08.0
|
#include <stdlib.h>
#include <string.h>
#include <cne_log.h>
#include <stdint.h>
#include "cne_common.h"
Go to the source code of this file.
Functions | |
CNDP_API struct gapbuf * | gb_create (void) |
CNDP_API void | gb_destroy (struct gapbuf *gb) |
CNDP_API int | gb_init_buf (struct gapbuf *gb, int size) |
CNDP_API int | gb_reset_buf (struct gapbuf *gb) |
CNDP_API uint32_t | gb_copy_to_buf (struct gapbuf *gb, char *dst, uint32_t size) |
CNDP_API void | gb_dump (struct gapbuf *gb, const char *msg) |
static uint32_t | gb_buf_size (struct gapbuf *gb) |
static uint32_t | gb_gap_size (struct gapbuf *gb) |
static uint32_t | gb_data_size (struct gapbuf *gb) |
static char * | gb_start_of_buf (struct gapbuf *gb) |
static char * | gb_start_of_gap (struct gapbuf *gb) |
static char * | gb_end_of_gap (struct gapbuf *gb) |
static char * | gb_end_of_buf (struct gapbuf *gb) |
static char * | gb_point_at (struct gapbuf *gb) |
static int | gb_point_at_start (struct gapbuf *gb) |
static int | gb_point_at_end (struct gapbuf *gb) |
static int | gb_point_at_gap (struct gapbuf *gb) |
static void | gb_set_point (struct gapbuf *gb, int idx) |
static int | gb_point_offset (struct gapbuf *gb) |
static int | gb_eof (struct gapbuf *gb) |
static void | gb_move_gap_to_point (struct gapbuf *gb) |
static void | gb_expand_buf (struct gapbuf *gb, uint32_t more) |
static void | gb_expand_gap (struct gapbuf *gb, uint32_t size) |
static char | gb_get (struct gapbuf *gb) |
static char | gb_get_prev (struct gapbuf *gb) |
static char | gb_get_next (struct gapbuf *gb) |
static void | gb_put (struct gapbuf *gb, char c) |
static char | gb_getc (struct gapbuf *gb) |
static char | gb_getc_prev (struct gapbuf *gb) |
static void | gb_putc (struct gapbuf *gb, char c) |
static void | gb_insert (struct gapbuf *gb, char c) |
static void | gb_del (struct gapbuf *gb, int cnt) |
static uint32_t | gb_str_insert (struct gapbuf *gb, char *str, uint32_t size) |
static uint32_t | gb_left_data_size (struct gapbuf *gb) |
static uint32_t | gb_right_data_size (struct gapbuf *gb) |
static void | gb_move_right (struct gapbuf *gb) |
static void | gb_move_left (struct gapbuf *gb) |
CLI Gap Buffer support
Definition in file cli_gapbuf.h.
CNDP_API struct gapbuf* gb_create | ( | void | ) |
Create the Gap Buffer structure
CNDP_API void gb_destroy | ( | struct gapbuf * | gb | ) |
Destroy
gb | The gapbuf structure pointer. |
CNDP_API int gb_init_buf | ( | struct gapbuf * | gb, |
int | size | ||
) |
Allocate buffer and initialize, if buffer exist free and reallocate.
gb | The gapbuf structure pointer. |
size | Init the gap buffer to the size given |
CNDP_API int gb_reset_buf | ( | struct gapbuf * | gb | ) |
Reset the gap buffer
gb | The gapbuf structure pointer. |
CNDP_API uint32_t gb_copy_to_buf | ( | struct gapbuf * | gb, |
char * | dst, | ||
uint32_t | size | ||
) |
Copy the buffer data into a given buffer
gb | The gapbuf structure pointer. |
dst | Location to copy the data into |
size | Total number of bytes to copy |
CNDP_API void gb_dump | ( | struct gapbuf * | gb, |
const char * | msg | ||
) |
Print out a debug list of the Gap buffer and pointers
gb | The gapbuf structure pointer. |
msg | Message to print out before dump of buffer data |
|
inlinestatic |
Return the number of bytes total in the buffer includes gap size
gb | The gapbuf structure pointer. |
Definition at line 113 of file cli_gapbuf.h.
|
inlinestatic |
Return the gap size in bytes
gb | The gapbuf structure pointer. |
Definition at line 127 of file cli_gapbuf.h.
|
inlinestatic |
Number of data bytes
gb | The gapbuf structure pointer. |
Definition at line 141 of file cli_gapbuf.h.
|
inlinestatic |
Return the start of the buffer address
gb | The gapbuf structure pointer. |
Definition at line 155 of file cli_gapbuf.h.
|
inlinestatic |
Return the pointer to the gap start
gb | The gapbuf structure pointer. |
Definition at line 169 of file cli_gapbuf.h.
|
inlinestatic |
Return the pointer to the end of the gap
gb | The gapbuf structure pointer. |
Definition at line 183 of file cli_gapbuf.h.
|
inlinestatic |
Return the pointer to the end of the buffer
gb | The gapbuf structure pointer. |
Definition at line 197 of file cli_gapbuf.h.
|
inlinestatic |
Return the point location
gb | The gapbuf structure pointer. |
Definition at line 211 of file cli_gapbuf.h.
|
inlinestatic |
Is point at start of buffer
gb | The gapbuf structure pointer. |
Definition at line 225 of file cli_gapbuf.h.
|
inlinestatic |
is point at the end of buffer
gb | The gapbuf structure pointer. |
Definition at line 239 of file cli_gapbuf.h.
|
inlinestatic |
is point at start of gap
gb | The gapbuf structure pointer. |
Definition at line 253 of file cli_gapbuf.h.
|
inlinestatic |
Set point to a givewn index into the buffer
gb | The gapbuf structure pointer. |
idx | Index into the buffer to put point |
Definition at line 269 of file cli_gapbuf.h.
|
inlinestatic |
Get offset of point
gb | The gapbuf structure pointer. |
Definition at line 289 of file cli_gapbuf.h.
|
inlinestatic |
Return true if point is at end of buffer data.
gb | The gapbuf structure pointer. |
Definition at line 306 of file cli_gapbuf.h.
|
inlinestatic |
Move the gap to the location of the point.
gb | The gapbuf structure pointer. |
Definition at line 322 of file cli_gapbuf.h.
|
inlinestatic |
Expand the buffer by the given bytes.
gb | The gapbuf structure pointer. |
more | The number of bytes to increase the buffer |
Definition at line 364 of file cli_gapbuf.h.
|
inlinestatic |
Expand the Gap by the size given.
gb | The gapbuf structure pointer. |
size | Increase the gap by the number of bytes given |
Definition at line 393 of file cli_gapbuf.h.
|
inlinestatic |
Get the byte at the point location.
gb | The gapbuf structure pointer. |
Definition at line 416 of file cli_gapbuf.h.
|
inlinestatic |
Get the byte at the point - 1 location.
gb | The gapbuf structure pointer. |
Definition at line 433 of file cli_gapbuf.h.
|
inlinestatic |
Get the byte at the point + 1 location.
gb | The gapbuf structure pointer. |
Definition at line 457 of file cli_gapbuf.h.
|
inlinestatic |
Put character at point
gb | The gapbuf structure pointer. |
c | The character to put at point |
Definition at line 479 of file cli_gapbuf.h.
|
inlinestatic |
Get the byte at the point location and advance point
gb | The gapbuf structure pointer. |
Definition at line 501 of file cli_gapbuf.h.
|
inlinestatic |
Move point left and return character at point.
fmrgetc() (point == ehole ? *(point = hole - 1) : *(–point))
gb | The gapbuf structure pointer. |
Definition at line 522 of file cli_gapbuf.h.
|
inlinestatic |
Put character at point and advance point
gb | The gapbuf structure pointer. |
c | The character to put at point |
Definition at line 541 of file cli_gapbuf.h.
|
inlinestatic |
Insert the character at point and move point.
gb | The gapbuf structure pointer. |
c | The character to add to buffer |
Definition at line 564 of file cli_gapbuf.h.
|
inlinestatic |
Delete the character(s) at point
gb | The gapbuf structure pointer. |
cnt | Number of characters to delete at point. |
Definition at line 586 of file cli_gapbuf.h.
|
inlinestatic |
Insert a string at point and move point
gb | The gapbuf structure pointer. |
str | String to put at point |
size | Size of the string to insert at point, if zero use strlen() to find length |
Definition at line 607 of file cli_gapbuf.h.
|
inlinestatic |
Left size of the data in the gap buffer
gb | The gapbuf structure pointer. |
Definition at line 640 of file cli_gapbuf.h.
|
inlinestatic |
Right size of the data in the gap buffer
gb | The gapbuf structure pointer. |
Definition at line 654 of file cli_gapbuf.h.
|
inlinestatic |
Move point right one byte
gb | The gapbuf structure pointer. |
Definition at line 670 of file cli_gapbuf.h.
|
inlinestatic |
Move point left one byte
gb | The gapbuf structure pointer. |
Definition at line 686 of file cli_gapbuf.h.