#include <stdint.h>
#include "cli.h"
#include "cne_common.h"
Go to the source code of this file.
|
static int | is_file_set (uint32_t opt, uint32_t cmpflags) |
|
static int | is_file_rd (uint32_t opt) |
|
static int | is_file_wr (uint32_t opt) |
|
static int | is_file_append (uint32_t opt) |
|
static int | is_file_open (uint32_t opt) |
|
static int | is_file_close (uint32_t opt) |
|
static int | is_data_rdonly (uint32_t flags) |
|
static int | is_file_eq (uint32_t opt, uint32_t cmpflags) |
|
static int | is_seek_set (uint32_t opt) |
|
static int | is_seek_cur (uint32_t opt) |
|
static int | is_seek_end (uint32_t opt) |
|
CNDP_API struct cli_node * | cli_file_open (const char *path, const char *type) |
|
CNDP_API int | cli_file_close (struct cli_node *node) |
|
CNDP_API int | cli_file_read (struct cli_node *node, char *buff, int len) |
|
CNDP_API int | cli_file_write (struct cli_node *node, char *buff, int len) |
|
CNDP_API int | cli_file_seek (struct cli_node *node, int offset, uint32_t whence) |
|
CNDP_API int | cli_readline (struct cli_node *node, char *buff, int len) |
|
CNDP_API struct cli_node * | cli_file_create (const char *path, const char *type) |
|
CNDP_API int | cli_file_handler (struct cli_node *node, char *buff, int len, uint32_t opt) |
|
CNDP_API int | cli_system (char *p) |
|
CNE Command line interface
Definition in file cli_file.h.
◆ anonymous enum
Enumerator |
---|
CLI_FILE_WR | Do a read on a file
|
CLI_FILE_APPEND | Do a write on a file
|
CLI_FILE_OPEN | Append to a file
|
CLI_FILE_CLOSE | Open a file
|
CLI_FILE_CREATE | Close a file
|
CLI_SEEK_SET | Create a file
|
CLI_SEEK_CUR | Set file pointer to a given offset
|
CLI_SEEK_END | Seek from current file pointer
|
CLI_DATA_RDONLY | Seek from end of file
|
CLI_FREE_DATA | file is read only
|
CLI_DATA_EXPAND | File data needs to be freed
|
Definition at line 28 of file cli_file.h.
◆ is_file_set()
static int is_file_set |
( |
uint32_t |
opt, |
|
|
uint32_t |
cmpflags |
|
) |
| |
|
inlinestatic |
Test to see if a CLI node is a file type
- Parameters
-
opt | The option flags read/write/excutable/... |
cmpflags | The option flags to compare with |
- Returns
- 0 if not set or 1 if any of the bits are set
Definition at line 68 of file cli_file.h.
◆ is_file_rd()
static int is_file_rd |
( |
uint32_t |
opt | ) |
|
|
inlinestatic |
Test to see if a CLI node is a file readable
- Parameters
-
- Returns
- 0 if not set or 1 if any of the bits are set
Definition at line 82 of file cli_file.h.
◆ is_file_wr()
static int is_file_wr |
( |
uint32_t |
opt | ) |
|
|
inlinestatic |
Test to see if a CLI node is a file writeable
- Parameters
-
- Returns
- 0 if not set or 1 if any of the bits are set
Definition at line 96 of file cli_file.h.
◆ is_file_append()
static int is_file_append |
( |
uint32_t |
opt | ) |
|
|
inlinestatic |
Test to see if a CLI node is a file appendable
- Parameters
-
- Returns
- 0 if not set or 1 if any of the bits are set
Definition at line 110 of file cli_file.h.
◆ is_file_open()
static int is_file_open |
( |
uint32_t |
opt | ) |
|
|
inlinestatic |
Test to see if a CLI node is a file open
- Parameters
-
- Returns
- 0 if not set or 1 if any of the bits are set
Definition at line 124 of file cli_file.h.
◆ is_file_close()
static int is_file_close |
( |
uint32_t |
opt | ) |
|
|
inlinestatic |
Test to see if a CLI node is a file closed
- Parameters
-
- Returns
- 0 if not set or 1 if any of the bits are set
Definition at line 138 of file cli_file.h.
◆ is_data_rdonly()
static int is_data_rdonly |
( |
uint32_t |
flags | ) |
|
|
inlinestatic |
Test to see if a CLI node is a file read only
- Parameters
-
- Returns
- 0 if not set or 1 if any of the bits are set
Definition at line 158 of file cli_file.h.
◆ is_file_eq()
static int is_file_eq |
( |
uint32_t |
opt, |
|
|
uint32_t |
cmpflags |
|
) |
| |
|
inlinestatic |
Test to see if a CLI node is a file and matches the options
- Parameters
-
opt | The option flags |
cmpflags | The compare option flags, which must match exactly |
- Returns
- 0 if not set or 1 if any of the bits are set
Definition at line 174 of file cli_file.h.
◆ is_seek_set()
static int is_seek_set |
( |
uint32_t |
opt | ) |
|
|
inlinestatic |
Test to see if a CLI node is a file Seek flag is set
- Parameters
-
- Returns
- 0 if not set or 1 if any of the bits are set
Definition at line 188 of file cli_file.h.
◆ is_seek_cur()
static int is_seek_cur |
( |
uint32_t |
opt | ) |
|
|
inlinestatic |
Test to see if a CLI node is a file is seek current
- Parameters
-
- Returns
- 0 if not set or 1 if any of the bits are set
Definition at line 202 of file cli_file.h.
◆ is_seek_end()
static int is_seek_end |
( |
uint32_t |
opt | ) |
|
|
inlinestatic |
Test to see if a CLI node is a file seek at end
- Parameters
-
- Returns
- 0 if not set or 1 if any of the bits are set
Definition at line 216 of file cli_file.h.
◆ cli_file_open()
CNDP_API struct cli_node* cli_file_open |
( |
const char * |
path, |
|
|
const char * |
type |
|
) |
| |
Open a file.
- Parameters
-
path | Path string for file |
type | Type of open string r, w, and/or + characters |
- Returns
- Node pointer or NULL on error
◆ cli_file_close()
CNDP_API int cli_file_close |
( |
struct cli_node * |
node | ) |
|
Close a file
- Parameters
-
- Returns
- 0 on OK and -1 on error
◆ cli_file_read()
CNDP_API int cli_file_read |
( |
struct cli_node * |
node, |
|
|
char * |
buff, |
|
|
int |
len |
|
) |
| |
read data from a file
- Parameters
-
node | Pointer to file node |
buff | Pointer to place to put the data |
len | Max Number of bytes to read |
- Returns
- Number of bytes read and -1 on error
◆ cli_file_write()
CNDP_API int cli_file_write |
( |
struct cli_node * |
node, |
|
|
char * |
buff, |
|
|
int |
len |
|
) |
| |
write data to a file
- Parameters
-
node | Pointer to file node |
buff | Pointer to place to get the data |
len | Max Number of bytes to write |
- Returns
- Number of bytes written and -1 on error
◆ cli_file_seek()
CNDP_API int cli_file_seek |
( |
struct cli_node * |
node, |
|
|
int |
offset, |
|
|
uint32_t |
whence |
|
) |
| |
write data to a file
- Parameters
-
node | Pointer to file node |
offset | Offset to move in file |
whence | Type of seek operation CLI_SEEK_SET, CLI_SEEK_CUR and CLI_SEEK_END |
- Returns
- Offset in file after seek and -1 on error
◆ cli_readline()
CNDP_API int cli_readline |
( |
struct cli_node * |
node, |
|
|
char * |
buff, |
|
|
int |
len |
|
) |
| |
write data to a file
- Parameters
-
node | Pointer to file node |
buff | place to put the line data. |
len | Max buff size |
- Returns
- Number of bytes read not including the newline
◆ cli_file_create()
CNDP_API struct cli_node* cli_file_create |
( |
const char * |
path, |
|
|
const char * |
type |
|
) |
| |
create a data file in memory will be lost at reset.
- Parameters
-
path | Path string for file |
type | Type of open string r, w, and/or + characters |
- Returns
- Node pointer or NULL on error
◆ cli_file_handler()
CNDP_API int cli_file_handler |
( |
struct cli_node * |
node, |
|
|
char * |
buff, |
|
|
int |
len, |
|
|
uint32_t |
opt |
|
) |
| |
Generic file function for basic file handling
- Parameters
-
node | Pointer to file node |
buff | place to put the line data. |
len | Max buff size |
opt | Flags for file handling |
- Returns
- Number of bytes read not including the newline
◆ cli_system()
CNDP_API int cli_system |
( |
char * |
p | ) |
|
Generic file function for basic file handling
- Parameters
-
- Returns
- Number of bytes read not including the newline