Пример #1
0
/* FUNCTION: console_init()
 *
 * Initialize the console module.
 * Create tk_console and tk_nettick tasks.
 *
 * PARAMS: none
 *
 * RETURNS: int               0 if OK, else error code
 */
int
console_init(void)
{
   int err;

   console_wakes = 0;

   /* initialize net tasks */
   if (to_console == TK_NOTASK)
   {
      if ((err = TK_CREATE(&task_console)) != 0)
      {
         console_close(0);
         return (err);
      }
   }

   if (ctx == (CLI_CTX)NULL)
   {
      if (((ctx = cli_get_context()) == (CLI_CTX)NULL) ||
          (GIO_PUSH_CONSOLE(&ctx->gio, GIO_RW) != GIO_DONE))
      {
         cli_free_context(ctx);
         ctx = (CLI_CTX)NULL;
         return (-1);
      }
   }

   return (0);
}
Пример #2
0
int mst_cli_show(struct cli_def *cdef, 
	const char *command,
	char **argv,
	int argc)
{
    mst_clictx_t *cctx = cli_get_context(cdef);

    if ((argc < 2) || !strcmp(argv[0], "?")) {
	    cli_print(cdef, "counters \t Display all counters");
        goto do_exit;
    }

do_exit:
    return CLI_OK;
}
Пример #3
0
/* FUNCTION: call_script()
 * 
 * call_script() - Do type specific preperations for calling do_script().
 *
 * PARAM1: void *             file name or memory object
 * PARAM2: int                type of cmdset; CMDSFROMFILE or CMDSFROMMEM
 * PARAM3: bool_t             TRUE = echo command strings to output stream
 * PARAM4: bool_t             FALSE = suppress command output
 * PARAM5: bool_t             TRUE = halt on first error
 *
 * RETURNS: int               0 or error code
 */
int call_script(void *cmdset, int type,
                bool_t echo_in, bool_t echo_out, bool_t halt)
{
   CLI_CTX ctx;

   /* if there is no script file, just return */
   if ((cmdset == NULL) || (*(char *)cmdset == NUL))
      return (0);

   /* if no type, assume it is a file */
   if (type == 0)
      type = CMDSFROMFILE;

   if ((ctx = cli_get_context()) != (CLI_CTX)NULL)
   {
      int  rtn;

      rtn = call_script_ctx(ctx, cmdset, type, echo_in, echo_out, halt);
      cli_free_context(ctx);
      return (rtn);
   }
   else
      return (-1);            /* couldn't allocate context */
}
Пример #4
0
int cmd_context(struct cli_def *cli, UNUSED(const char *command), UNUSED(char *argv[]), UNUSED(int argc))
{
    struct my_context *myctx = (struct my_context *)cli_get_context(cli);
    cli_print(cli, "User context has a value of %d and message saying %s", myctx->value, myctx->message);
    return CLI_OK;
}