<commit_before>/*
 *  Copyright (c) 2010 <NAME>
 *  Copyright (c) 2010 <NAME>
 *
 *  This is free software; see gpl-3.0.txt
 */
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>

#include <chunk.h>
#include <chunkiser.h>

#include "output.h"
#include "measures.h"
#include "dbg.h"

static int next_chunk = -1;
static int buff_size;
extern bool chunk_log;

struct outbuf {
  struct chunk c;
};
static struct outbuf *buff;
static struct output_stream *out;

void output_init(int bufsize, const char *config)
{
  char cfg[256];

  if (config && (strlen(config) > 4) && (memcmp(config, "udp:", 4) == 0)) {
    config += 4;
    sprintf(cfg, "dechunkiser=udp");
    sprintf(cfg + strlen(cfg), ",%s", config);
  } else {
    sprintf(cfg, "dechunkiser=avf,media=av");
  }
  out = out_stream_init(config, cfg);
  if (out == NULL) {
     fprintf(stderr, "Error: can't initialize output module\n");
     exit(1);
  }
  if (!buff) {
    int i;

    buff_size = bufsize;
    buff = malloc(sizeof(struct outbuf) * buff_size);
    if (!buff) {
     fprintf(stderr, "Error: can't allocate output buffer\n");
     exit(1);
    }
    for (i = 0; i < buff_size; i++) {
      buff[i].c.data = NULL;
    }
  } else {
   fprintf(stderr, "Error: output buffer re-init not allowed!\n");
   exit(1);
  }
}

static void buffer_print(void)
{<commit_msg>output=grapes: add dummy config with "dummy:"<commit_after>/*
 *  Copyright (c) 2010 <NAME>
 *  Copyright (c) 2010 <NAME>
 *
 *  This is free software; see gpl-3.0.txt
 */
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>

#include <chunk.h>
#include <chunkiser.h>

#include "output.h"
#include "measures.h"
#include "dbg.h"

static int next_chunk = -1;
static int buff_size;
extern bool chunk_log;

struct outbuf {
  struct chunk c;
};
static struct outbuf *buff;
static struct output_stream *out;

void output_init(int bufsize, const char *config)
{
  char cfg[256];

  if (config && (strlen(config) > 4) && (memcmp(config, "udp:", 4) == 0)) {
    config += 4;
    sprintf(cfg, "dechunkiser=udp");
    sprintf(cfg + strlen(cfg), ",%s", config);
  } else if (config && (strlen(config) >= 6) && (memcmp(config, "dummy:", 6) == 0)) {
    config += 6;
    sprintf(cfg, "dechunkiser=dummy");
    sprintf(cfg + strlen(cfg), ",%s", config);
  } else {
    sprintf(cfg, "dechunkiser=avf,media=av");
  }
  out = out_stream_init(config, cfg);
  if (out == NULL) {
     fprintf(stderr, "Error: can't initialize output module\n");
     exit(1);
  }
  if (!buff) {
    int i;

    buff_size = bufsize;
    buff = malloc(sizeof(struct outbuf) * buff_size);
    if (!buff) {
     fprintf(stderr, "Error: can't allocate output buffer\n");
     exit(1);
    }
    for (i = 0; i < buff_size; i++) {
      buff[i].c.data = NULL;
    }
  } else {
   fprintf(stderr, "Error: output buffer re-init not allowed!\n");
   exit(1);
  }
}

static void buffer_print(void)
{
{'fraction_non_alphanumeric': 0.1730057219791316, 'fraction_numerical': 0.016156176371592057, 'mean_word_length': 3.4557721139430284, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 24, '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': '4390961', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1118, 'n_words': 296}