]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Merge branch 'int-new' into bash-completion
authorJan Moskyto Matejka <mq@ucw.cz>
Wed, 12 Jul 2017 11:47:32 +0000 (13:47 +0200)
committerJan Moskyto Matejka <mq@ucw.cz>
Wed, 12 Jul 2017 11:47:32 +0000 (13:47 +0200)
1  2 
client/commands.c
conf/conf.c
conf/conf.h
nest/cli.c
nest/cmds.c
nest/config.Y
proto/ospf/config.Y

index 5ea3f3ff06681a5751d935634703a64b5acc7fef,fdf2652a068d2bbf331d37a05932ca9e2fb42a63..5709cd4440128b757dc61ca4be48af023721921e
@@@ -288,9 -229,9 +290,9 @@@ cmd_complete(const char *cmd, int len, 
  
    /* Find the context */
    n = &cmd_root;
 -  while (cmd < fin && n->son)
 +  while (cmd < fin)
      {
-       if (isspace(*cmd))
+       if (isspace_(*cmd))
        {
          cmd++;
          continue;
diff --cc conf/conf.c
Simple merge
diff --cc conf/conf.h
Simple merge
diff --cc nest/cli.c
Simple merge
diff --cc nest/cmds.c
index a36d838c812376a0c25badff23872e71294598f2,2bc672ea249fa2b5b33fbd5a9d027774ba55e0bf..c4fcebd96025869361a9586c5f10211be677fcfe
@@@ -48,74 -46,26 +48,76 @@@ cmd_show_status(void
  void
  cmd_show_symbols(struct sym_show_data *sd)
  {
-   int pos = 0;
-   struct symbol *sym = sd->sym;
-   if (sym)
-     cli_msg(1010, "%-8s\t%s", sym->name, cf_symbol_class_name(sym));
+   if (sd->sym)
+     cli_msg(1010, "%-8s\t%s", sd->sym->name, cf_symbol_class_name(sd->sym));
    else
+   {
+     HASH_WALK(config->sym_hash, next, sym)
      {
-       while (sym = cf_walk_symbols(config, sym, &pos))
-       {
-         if (sd->type && (sym->class != sd->type))
-           continue;
+       if (!sym->scope->active)
+       continue;
+       if (sd->type && (sym->class != sd->type))
+       continue;
  
-         cli_msg(-1010, "%-8s\t%s", sym->name, cf_symbol_class_name(sym));
-       }
-       cli_msg(0, "");
+       cli_msg(-1010, "%-8s\t%s", sym->name, cf_symbol_class_name(sym));
      }
+     HASH_WALK_END;
+     cli_msg(0, "");
+   }
  }
  
 +static int
 +get_cli_code_for_sym(struct symbol *sym)
 +{
 +  if (cf_symbol_is_constant(sym))
 +    return RC_CONSTANT_NAME;
 +
 +  if (cf_symbol_is_variable(sym))
 +    return RC_VARIABLE_NAME;
 +
 +  switch (sym->class & 0xff)
 +  {
 +  case SYM_PROTO:     return RC_PROTOCOL_NAME;
 +  case SYM_TEMPLATE:  return RC_TEMPLATE_NAME;
 +  case SYM_FUNCTION:  return RC_FUNCTION_NAME;
 +  case SYM_FILTER:    return RC_FILTER_NAME;
 +  case SYM_TABLE:     return RC_TABLE_NAME;
 +  default:
 +    log(L_ERR "Undefined class %d of %s", sym->class, sym->name);
 +  }
 +  return 0;
 +}
 +
 +/**
 + * cmd_send_symbols - send all symbols for auto-completion interactive CLI
 + *
 + * This function sends all known symbols for auto-completion interactive BIRD's
 + * CLI. The first symbol is version of BIRD.
 + */
 +void
 +cmd_send_symbols(void)
 +{
 +  int code, pos = 0;
 +  struct symbol *sym = NULL;
 +
 +  cli_msg(RC_BIRD_VERSION_NUM, "%s", BIRD_VERSION);
 +
 +  while (sym = cf_walk_symbols(config, sym, &pos))
 +  {
 +    code = get_cli_code_for_sym(sym);
 +    cli_msg(code, "%s", sym->name);
 +  }
 +
 +  struct iface *i;
 +  WALK_LIST(i, iface_list)
 +    if (!(i->flags & IF_SHUTDOWN))
 +      cli_msg(RC_INTERFACE_NAME, "\"%s\"", i->name);
 +
 +  cli_msg(RC_DUMP_DONE, "");
 +}
 +
  static void
  print_size(char *dsc, size_t val)
  {
diff --cc nest/config.Y
Simple merge
Simple merge