<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);
  vat_api_hookup (vam);
  clib_warning ("vam %llx", vam);
  rv = vat_plugin_init (vam);
  if (rv)
    clib_warning ("vat_plugin_init returned %d", rv);
  return 0;
}

VLIB_INIT_FUNCTION (api_main_init);

static clib_error_t *
api_command_fn (vlib_main_t * vm,
		unformat_input_t * input, vlib_cli_command_t * cmd)
{<commit_msg>api: remove debug print in api_main_init<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;
  init_error_string_table (vam);
  vat_api_hookup (vam);
  rv = vat_plugin_init (vam);
  if (rv)
    clib_warning ("vat_plugin_init returned %d", rv);
  return 0;
}

VLIB_INIT_FUNCTION (api_main_init);

static clib_error_t *
api_command_fn (vlib_main_t * vm,
		unformat_input_t * input, vlib_cli_command_t * cmd)
{
{'fraction_non_alphanumeric': 0.1314090391188758, 'fraction_numerical': 0.012153437143942271, 'mean_word_length': 4.556962025316456, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '1036047', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1156, 'n_words': 247}