<commit_before>#include "vat.h"

vat_main_t vat_main;

void
vat_suspend (vlib_main_t * vm, f64 interval)
{
  vlib_process_suspend (vm, interval);
}

static u8 *
format_api_error (u8 * s, va_list * args)
{
  vat_main_t *vam = va_arg (*args, vat_main_t *);
  i32 error = va_arg (*args, u32);
  uword *p;

  p = hash_get (vam->error_string_by_error_number, -error);

  if (p)
    s = format (s, "%s", p[0]);
  else
    s = format (s, "%d", error);
  return s;
}


static void
init_error_string_table (vat_main_t * vam)
{

  vam->error_string_by_error_number = hash_create (0, sizeof (uword));

#define _(n,v,s) hash_set (vam->error_string_by_error_number, -v, s);
  foreach_vnet_api_error;
#undef _

  hash_set (vam->error_string_by_error_number, 99, "Misc");
}

static clib_error_t *
api_main_init (vlib_main_t * vm)
{
  vat_main_t *vam = &vat_main;
  int rv;
  int vat_plugin_init (vat_main_t * vam);

  vam->vlib_main = vm;
  vam->my_client_index = (u32) ~ 0;
  init_error_string_table (vam);
  rv = vat_plugin_init (vam);
  if (rv)
    clib_warning ("vat_plugin_init returned %d", rv);
  return 0;
}

VLIB_INIT_FUNCTION (api_main_init);

void
vat_plugin_hash_create (void)
{
  vat_main_t *vam = &vat_main;

  vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
  vam->function_by_name = hash_create_string (0, sizeof (uword));
  vam->help_by_name = hash_create_string (0, sizeof (uword));
}

static clib_error_t *
api_command_fn (vlib_main_t * vm,
		unformat_input_t * input, vlib_cli_command_t * cmd)
{
  vat_main_t *vam = &vat_main;
  unformat_input_t _input;
  uword c;
  u8 *cmdp, *argsp, *this_cmd;
  uword *p;
  u32 arg_len;
  int rv;
  int (*fp) (vat_main_t *);
  api_main_t *am = &api_main;

  vam->vl_input_queue = am->shmem_hdr->vl_input_queue;

  vec_reset_length (vam->inbuf);
  vam->input = &_input;

  while (((c = unformat_get_input (input)) != '\n') &&
	 (c != UNFORMAT_END_OF_INPUT))
    vec_add1 (vam->inbuf, c);

  /* Add 1 octet's worth of extra space in case there are no args... */
  vec_add1 (vam->inbuf, 0);

  /*$$$$ reinstall macro evaluator */

  /* Split input into cmd + args */
  this_cmd = cmdp = vam->inbuf;

  /* Skip leading whitespace */
  while (cmdp < (this_cmd + vec_len (this_cmd)))
    {
      if (*cmdp == ' ' || *cmdp == '\t' || *cmdp == '\n')
	{
	  cmdp++;
	}
      else
	break;
    }
<commit_msg>VPP-608: warnings be gone<commit_after>#include "vat.h"

vat_main_t vat_main;

void
vat_suspend (vlib_main_t * vm, f64 interval)
{
  vlib_process_suspend (vm, interval);
}

static u8 *
format_api_error (u8 * s, va_list * args)
{
  vat_main_t *vam = va_arg (*args, vat_main_t *);
  i32 error = va_arg (*args, u32);
  uword *p;

  p = hash_get (vam->error_string_by_error_number, -error);

  if (p)
    s = format (s, "%s", p[0]);
  else
    s = format (s, "%d", error);
  return s;
}


static void
init_error_string_table (vat_main_t * vam)
{

  vam->error_string_by_error_number = hash_create (0, sizeof (uword));

#define _(n,v,s) hash_set (vam->error_string_by_error_number, -v, s);
  foreach_vnet_api_error;
#undef _

  hash_set (vam->error_string_by_error_number, 99, "Misc");
}

static clib_error_t *
api_main_init (vlib_main_t * vm)
{
  vat_main_t *vam = &vat_main;
  int rv;
  int vat_plugin_init (vat_main_t * vam);

  vam->vlib_main = vm;
  vam->my_client_index = (u32) ~ 0;
  /* Ensure that vam->inbuf is never NULL */
  vec_validate (vam->inbuf, 0);
  init_error_string_table (vam);
  rv = vat_plugin_init (vam);
  if (rv)
    clib_warning ("vat_plugin_init returned %d", rv);
  return 0;
}

VLIB_INIT_FUNCTION (api_main_init);

void
vat_plugin_hash_create (void)
{
  vat_main_t *vam = &vat_main;

  vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
  vam->function_by_name = hash_create_string (0, sizeof (uword));
  vam->help_by_name = hash_create_string (0, sizeof (uword));
}

static clib_error_t *
api_command_fn (vlib_main_t * vm,
		unformat_input_t * input, vlib_cli_command_t * cmd)
{
  vat_main_t *vam = &vat_main;
  unformat_input_t _input;
  uword c;
  u8 *cmdp, *argsp, *this_cmd;
  uword *p;
  u32 arg_len;
  int rv;
  int (*fp) (vat_main_t *);
  api_main_t *am = &api_main;

  vam->vl_input_queue = am->shmem_hdr->vl_input_queue;

#ifdef __COVERITY
  /*
   * Convince Coverity that it's not a NULL pointer...
   * Done once for real below, since we never vec_free(vam->inbuf);
   */
  vec_validate (vam->inbuf, 0);
#endif

  vec_reset_length (vam->inbuf);
  vam->input = &_input;

  while (((c = unformat_get_input (input)) != '\n') &&
	 (c != UNFORMAT_END_OF_INPUT))
    vec_add1 (vam->inbuf, c);

  /* Add 1 octet's worth of extra space in case there are no args... */
  vec_add1 (vam->inbuf, 0);

  /*$$$$ reinstall macro evaluator */

  /* Split input into cmd + args */
  this_cmd = cmdp = vam->inbuf;

  /* Skip leading whitespace */
  while (cmdp < (this_cmd + vec_len (this_cmd)))
    {
      if (*cmdp == ' ' || *cmdp == '\t' || *cmdp == '\n')
	{
	  cmdp++;
	}
      else
	break;
    }

{'fraction_non_alphanumeric': 0.14602034709754638, 'fraction_numerical': 0.011370436864153202, 'mean_word_length': 3.8119001919385798, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5653652', 'n_tokens_mistral': 2219, 'n_tokens_neox': 2122, 'n_words': 477}