openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

shell.h (3165B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * File:    sh.h
      8  * Purpose:    Types and structures for command table entires and
      9  *        command return values for cshell commands.
     10  */
     11 
     12 #ifndef _DIAG_SH_H
     13 #define _DIAG_SH_H
     14 
     15 #ifdef __KERNEL__
     16 /* Need jmp_buf to satisfy prototypes */
     17 #define jmp_buf int
     18 #else
     19 #include <setjmp.h>
     20 #endif
     21 #if !defined(SWIG)
     22 #include <sal/appl/io.h>
     23 #endif
     24 #include <appl/diag/parse.h>
     25 
     26 /*
     27  * Define:    RCLOAD_DEPTH_MAX
     28  * Purpose:    Maximum depth of rcload files.
     29  */
     30 #define RCLOAD_DEPTH_MAX    32
     31 
     32 /*
     33  * Define:    LOG_DEFAULT_FILE
     34  * Purpose:    Default file name for "log" command
     35  */
     36 #define LOG_DEFAULT_FILE    "bcm.log"
     37 
     38 /*
     39  * Define:    PUSH_CTRL_C_CNT
     40  * Purpose:    Defines the maximum number of pushed Control-C handlers.
     41  * Notes:    Must be more than RCLOAD_DEPTH_MAX.
     42  */
     43 #define    PUSH_CTRL_C_CNT    (RCLOAD_DEPTH_MAX + 4)
     44 
     45 /*
     46  * Typedef:     cmd_result_t
     47  * Purpose:    Type retured from all commands indicating success, fail, 
     48  *        or print usage.
     49  */
     50 typedef enum cmd_result_e {
     51     CMD_OK   = 0,            /* Command completed successfully */
     52     CMD_FAIL = -1,            /* Command failed */
     53     CMD_USAGE= -2,            /* Command failed, print usage  */
     54     CMD_NFND = -3,            /* Command not found */
     55     CMD_EXIT = -4,            /* Exit current shell level */
     56     CMD_INTR = -5,            /* Command interrupted */
     57     CMD_NOTIMPL = -6            /* Command not implemented */
     58 } cmd_result_t;
     59 
     60 /*
     61  * Typedef:    cmd_func_t
     62  * Purpose:    Defines command function type
     63  */
     64 typedef cmd_result_t (*cmd_func_t)(int, args_t *);
     65 
     66 /*
     67  * Typedef:    cmd_t
     68  * Purpose:    Table command match structure.
     69  */
     70 typedef struct cmd_s {
     71     parse_key_t    c_cmd;            /* Command string */
     72     cmd_func_t    c_f;            /* Function to call */
     73     const char     *c_usage;        /* Usage string */
     74     const char    *c_help;        /* Help string */
     75 } cmd_t;
     76 
     77 /*
     78  * Shell rc file load depth
     79  */
     80 extern int sh_rcload_depth;
     81 
     82 
     83 /*
     84  * Shell 'set' variables
     85  */
     86 
     87 extern int    sh_set_rcload;
     88 extern int    sh_set_rcerror;
     89 extern int    sh_set_lperror;
     90 extern int    sh_set_iferror;
     91 extern int    sh_set_rctest;
     92 extern int    sh_set_more_lines;
     93 extern int    sh_set_report_time;
     94 extern int    sh_set_report_status;
     95 
     96 
     97 /*
     98  * Exported shell.c functions.
     99  */
    100 
    101 cmd_result_t     sh_process(int unit, const char *, int eof);
    102 cmd_result_t    sh_process_command(int unit, char *c);
    103 cmd_result_t    sh_process_command_check(int unit, char *c);
    104 int        sh_check_attached(const char *pfx, const int unit);
    105 cmd_result_t    sh_rcload_file(int u, args_t *, char *f, int add_rc);
    106 void        sh_swap_unit_vars(int new_unit);
    107 
    108 /*
    109  * Functions for pushing/poping where to longjump on control-c.
    110  */
    111 extern void    sh_push_ctrl_c(jmp_buf *);
    112 extern void    sh_pop_ctrl_c(void);
    113 extern void    sh_block_ctrl_c(int);
    114 extern void    sh_ctrl_c_take(void);
    115 extern void    sh_print_version(int verbose);
    116 
    117 extern void    sh_bg_init(void);
    118 
    119 #endif /* _DIAG_SH_H */