PebbleOS
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
shell.h File Reference
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <pbl/kernel/compiler.h>
#include <pbl/kernel/section.h>

Data Structures

struct  pbl_shell_cmd
 Command. More...
 

Macros

#define PBL_SHELL_OPT_ARG_MAX   UINT8_MAX
 Any number of optional arguments.
 
#define PBL_SHELL_CMD_ARG(_syntax, _subcmd, _help, _handler, _mand, _opt)
 Initializer of a command with an argument count check.
 
#define PBL_SHELL_CMD(_syntax, _subcmd, _help, _handler)    PBL_SHELL_CMD_ARG(_syntax, _subcmd, _help, _handler, 0, 0)
 Initializer of a command without an argument count check.
 
#define PBL_SHELL_SUBCMD_SET_END   {0}
 Terminates a file-local subcommand array of PBL_SHELL_CMD() entries.
 
#define PBL_SHELL_SUBCMD_SET_CREATE(_name)
 Define a subcommand set that any file can extend with PBL_SHELL_SUBCMD_ADD().
 
#define PBL_SHELL_SUBCMD_ADD(_set, _syntax, _subcmd, _help, _handler, _mand, _opt)    PBL_SHELL_SUBCMD_ADD_ID(__COUNTER__, _set, _syntax, _subcmd, _help, _handler, _mand, _opt)
 Add a subcommand to a set, from any file.
 
#define PBL_SHELL_CMD_ARG_REGISTER(_syntax, _subcmd, _help, _handler, _mand, _opt)
 Register a root command with an argument count check.
 
#define PBL_SHELL_CMD_REGISTER(_syntax, _subcmd, _help, _handler)    PBL_SHELL_CMD_ARG_REGISTER(_syntax, _subcmd, _help, _handler, 0, 0)
 Register a root command without an argument count check.
 

Typedefs

typedef int(* pbl_shell_cmd_handler_t) (const struct pbl_shell *sh, size_t argc, char **argv)
 Command handler.
 

Functions

void pbl_shell_print (const struct pbl_shell *sh, const char *fmt,...)
 Print a formatted line.
 
void pbl_shell_fprintf (const struct pbl_shell *sh, const char *fmt,...)
 Print formatted text without a line break.
 
void pbl_shell_vfprintf (const struct pbl_shell *sh, const char *fmt, va_list args)
 Print formatted text without a line break, with a va_list.
 
void pbl_shell_error (const struct pbl_shell *sh, const char *fmt,...)
 Print a formatted line prefixed with "error: ".
 
void pbl_shell_hexdump (const struct pbl_shell *sh, const void *data, size_t len)
 Print a hex dump, 16 bytes a line with offsets and ASCII.
 
void pbl_shell_help (const struct pbl_shell *sh, const struct pbl_shell_cmd *cmd)
 Print the help of a command and the list of its subcommands.
 
void pbl_shell_cmd_done (const struct pbl_shell *sh, int ret)
 Finish a command whose handler returned -EINPROGRESS.
 
int pbl_shell_strtol (const char *str, long *out)
 Parse an argument as a signed integer.
 
int pbl_shell_strtoul (const char *str, unsigned long *out)
 Parse an argument as an unsigned integer.