CNDP  22.08.0
cli_search.h File Reference
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#include <inttypes.h>
#include "cne_common.h"

Go to the source code of this file.

Data Structures

struct  args_t
 

Functions

CNDP_API int cli_scan_directory (struct cli_node *dir, cli_scan_t func, uint32_t flags, args_t *args)
 
CNDP_API int cli_find_node (const char *path, struct cli_node **ret)
 
CNDP_API struct cli_node * cli_find_cmd (const char *path)
 
CNDP_API uint32_t cli_dir_item_count (struct cli_node *node, uint32_t types)
 
CNDP_API uint32_t cli_path_cmd_count (void)
 
CNDP_API uint32_t cli_node_list_with_type (struct cli_node *node, uint32_t flags, void **ret)
 
CNDP_API void cli_node_list_free (void *node)
 
CNDP_API uint32_t cli_path_item_count (uint32_t types)
 
CNDP_API struct cli_node * cli_last_dir_in_path (const char *path)
 
CNDP_API struct cli_node * cli_search_dir (struct cli_node *dir, const char *name, uint32_t type)
 
CNDP_API int cli_scan_path (const char *path, cli_scan_t func, uint32_t flags, args_t *args)
 

Detailed Description

CNE Command line interface

Definition in file cli_search.h.

Function Documentation

◆ cli_scan_directory()

CNDP_API int cli_scan_directory ( struct cli_node *  dir,
cli_scan_t  func,
uint32_t  flags,
args_t args 
)

typedef of function passed in cli_scan_directory() Scan a directory and call the func with the node found.

Note
Uses a thread variable called this_cli.
Parameters
dirNode pointer to directory to scan
funccli_scan_t function pointer
flagsTODO
argsvoid * used by the function being called.
Returns
0 on success or -1 on error

◆ cli_find_node()

CNDP_API int cli_find_node ( const char *  path,
struct cli_node **  ret 
)

Find a node by path

Note
Uses a thread variable called this_cli.
Parameters
pathPath to node
retPointer to pointer of a cli_node if found
Returns
1 if found else 0

◆ cli_find_cmd()

CNDP_API struct cli_node* cli_find_cmd ( const char *  path)

Search the local and bin directories for a command

Note
Uses a thread variable called this_cli.
Parameters
pathString for the command to use
Returns
Pointer to the command node or NULL

◆ cli_dir_item_count()

CNDP_API uint32_t cli_dir_item_count ( struct cli_node *  node,
uint32_t  types 
)

Count the number of type(s) of nodes available in a given node

Note
Uses a thread variable called this_cli.
Parameters
nodenode or NULL for current working directory
typesTODO
Returns
Number of nodes found of this type in the directory

◆ cli_path_cmd_count()

CNDP_API uint32_t cli_path_cmd_count ( void  )

Count the number of commands in the execute path

Note
Uses a thread variable called this_cli.
Returns
Number of nodes found of this type in the directory

◆ cli_node_list_with_type()

CNDP_API uint32_t cli_node_list_with_type ( struct cli_node *  node,
uint32_t  flags,
void **  ret 
)

Return a list of nodes matching given information

Note
Uses a thread variable called this_cli.
Parameters
nodeNode to start search or use the path list.
flagsType of nodes to return
retPointer to an array of pointer for return value
Returns
Number of nodes found of this type in the directory

◆ cli_node_list_free()

CNDP_API void cli_node_list_free ( void *  node)

Free a node back to the free list

Note
Uses a thread variable called this_cli.
Parameters
nodePointer to the node to free
Returns
N/A

◆ cli_path_item_count()

CNDP_API uint32_t cli_path_item_count ( uint32_t  types)

Count the number of commands in the execute path

Note
Uses a thread variable called this_cli.
Parameters
typesThe number of nodes to count
Returns
Number of nodes found of this type in the directory

◆ cli_last_dir_in_path()

CNDP_API struct cli_node* cli_last_dir_in_path ( const char *  path)

Find and return the last node in a give path string

Note
Uses a thread variable called this_cli.
Parameters
pathPath string to scan
Returns
Pointer to last directory node in path

◆ cli_search_dir()

CNDP_API struct cli_node* cli_search_dir ( struct cli_node *  dir,
const char *  name,
uint32_t  type 
)

Scan a directory for a given string matching name

Note
Uses a thread variable called this_cli.
Parameters
dirPointer to directory node to start with in scanning
nameString to match the nodes with
typeType of nodes to include in scan.
Returns
Number of nodes found of this type in the directory

◆ cli_scan_path()

CNDP_API int cli_scan_path ( const char *  path,
cli_scan_t  func,
uint32_t  flags,
args_t args 
)

Scan the directory given by the path

Note
Uses a thread variable called this_cli.
Parameters
pathThe path string to use
funcThe function to call when a match is found.
flagsType of files to include in match
argsArguments to include with function call.
Returns
Number of nodes found of this type in the directory