CNDP  22.08.0
cli_file.h File Reference
#include <stdint.h>
#include "cli.h"
#include "cne_common.h"

Go to the source code of this file.

Enumerations

enum  {
}
 

Functions

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)
 

Detailed Description

CNE Command line interface

Definition in file cli_file.h.

Enumeration Type Documentation

◆ anonymous enum

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.

Function Documentation

◆ 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
optThe option flags read/write/excutable/...
cmpflagsThe 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
optThe option flags
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
optThe option flags
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
optThe option flags
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
optThe option flags
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
optThe option flags
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
flagsThe option flags
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
optThe option flags
cmpflagsThe 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
optThe option flags
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
optThe option flags
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
optThe option flags
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
pathPath string for file
typeType 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
nodePointer to file node
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
nodePointer to file node
buffPointer to place to put the data
lenMax 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
nodePointer to file node
buffPointer to place to get the data
lenMax 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
nodePointer to file node
offsetOffset to move in file
whenceType 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
nodePointer to file node
buffplace to put the line data.
lenMax 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
pathPath string for file
typeType 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
nodePointer to file node
buffplace to put the line data.
lenMax buff size
optFlags 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
pPointer to file node
Returns
Number of bytes read not including the newline