<commit_before>/***********************************************************************
*             This software is part of the atrshmlog package           *
*                   Copyright (c) 2016  ATRSoft GmbH                   *
*                      and is licensed under the                       *
*                     Apache License, Version 2.0                      *
*                         by ATRSoft GmbH                              *
*                                                                      *
*                A copy of the License is available at                 *
*             http://www.apache.org/licenses/LICENSE-2.0               *
*                                                                      *
*               <NAME> <<EMAIL>>                  *
*                                                                      *
***********************************************************************/

/** \file atrshmlogreset.c
 * \brief We are the check and reset tool for the shared memory
 */
#include "atrshmlog.h"

#include "atrshmlog_internal.h"

/*
 * ------------------------------------------------------------------
 */

/**
 * attach and verify the struct parameters
 *
 * this is a testing program
 * it is used with tee, reader and the others to make checking for error
 * possible.
 * you can of course always dump and then check the content with something like
 * od or a smart hex fileeditor ...
 * but for a quick check this is ok.
 * see for overrites and hanging buffers with corrupted
 * states ...
 * of wrong versiones ...
 * or whatever you can imageine what went wrong ...
 * after using this its then time to fire up your debugger ... in case
 * something is wrong.
 *
 */
int main (int argc, char*argv[])
{
  const char *shmid_ptr = ATRSHMLOG_GET_ENV_SHMID();

  long lanz;
  
  if (shmid_ptr == (void*)0)
    {
      printf("usage: %s count_of_buffers\n", argv[0]);
      printf("ENVIRONMENT VARIABLE NOT SET !!!\n");
      printf("%s_ID\n", ATRSHMLOG_GET_ENV_PREFIX());
      printf("logsystem version is %d.\n", ATRSHMLOGVERSION);
      exit(1);
    }

  if (argc != 2)
    {
      printf("usage: %s count_of_buffers\n", argv[0]);
      printf("parameter count wrong.\n");
      printf("logsystem version is %d.\n", ATRSHMLOGVERSION);
      exit(1);
    }

  lanz = strtol(argv[1], 0, 10);
  
  printf("shm log attach and verify.\n");
  printf("logsystem version is %d.\n", ATRSHMLOGVERSION);
  
  ATRSHMLOG_ATTACH();

  if (!ATRSHMLOG_LOGGING)
    {
      printf ("attach not successful.\ncheck ENVIRONMENT VARIABLE %s_ID\n"
          "Value seems not to fit : '%s'\n", ATRSHMLOG_GET_ENV_PREFIX(),shmid_ptr);

      exit(1);
    }

  fflush(stdout);
  
  {<commit_msg>We do no longer need the count, can use COUNT too<commit_after>/***********************************************************************
*             This software is part of the atrshmlog package           *
*                   Copyright (c) 2016  ATRSoft GmbH                   *
*                      and is licensed under the                       *
*                     Apache License, Version 2.0                      *
*                         by ATRSoft GmbH                              *
*                                                                      *
*                A copy of the License is available at                 *
*             http://www.apache.org/licenses/LICENSE-2.0               *
*                                                                      *
*               <NAME> <<EMAIL>>                  *
*                                                                      *
***********************************************************************/

/** \file atrshmlogreset.c
 * \brief We are the check and reset tool for the shared memory
 */
#include "atrshmlog.h"

#include "atrshmlog_internal.h"

/*
 * ------------------------------------------------------------------
 */

/**
 * attach and verify the struct parameters
 *
 * this is a testing program
 * it is used with tee, reader and the others to make checking for error
 * possible.
 * you can of course always dump and then check the content with something like
 * od or a smart hex fileeditor ...
 * but for a quick check this is ok.
 * see for overrites and hanging buffers with corrupted
 * states ...
 * of wrong versiones ...
 * or whatever you can imageine what went wrong ...
 * after using this its then time to fire up your debugger ... in case
 * something is wrong.
 *
 */
int main (int argc, char*argv[])
{
  const char *shmid_ptr = ATRSHMLOG_GET_ENV_SHMID();

  long lanz;
  
  if (shmid_ptr == (void*)0)
    {
      printf("usage: %s count_of_buffers\n", argv[0]);
      printf("ENVIRONMENT VARIABLE NOT SET !!!\n");
      printf("%s_ID\n", ATRSHMLOG_GET_ENV_PREFIX());
      printf("logsystem version is %d.\n", ATRSHMLOGVERSION);
      exit(1);
    }


  const char *s_anz;
  
  if (argc != 2)
    {
      if (ATRSHMLOG_GET_ENV("_COUNT"))
	{
	  s_anz = ATRSHMLOG_GET_ENV("_COUNT");
	}
      else
	{
	  printf("usage: %s countbuffer\n", argv[0]);
	  printf("parameter count wrong.\n");
	  printf("logsystem version is %d.\n", ATRSHMLOGVERSION);
	  exit(1);
	}
    }
  else
    {
      s_anz = argv[1];
    }
  
  lanz = strtol(s_anz, 0, 10);
  
  printf("shm log attach and verify.\n");
  printf("logsystem version is %d.\n", ATRSHMLOGVERSION);
  
  ATRSHMLOG_ATTACH();

  if (!ATRSHMLOG_LOGGING)
    {
      printf ("attach not successful.\ncheck ENVIRONMENT VARIABLE %s_ID\n"
          "Value seems not to fit : '%s'\n", ATRSHMLOG_GET_ENV_PREFIX(),shmid_ptr);

      exit(1);
    }

  fflush(stdout);
  
  {
{'fraction_non_alphanumeric': 0.17125220458553791, 'fraction_numerical': 0.006701940035273368, 'mean_word_length': 1.5812471552116523, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5176485', 'n_tokens_mistral': 1597, 'n_tokens_neox': 1534, 'n_words': 471}