<commit_before>/*!  \file 

$Id: client_stdout.c,v 1.8 2004-09-27 13:47:01 tractobob Exp $

-----------------------------------------------------------------------

TSP Library - core components for a generic Transport Sampling Protocol.

Copyright (c) 2002 <NAME>, <NAME>, <NAME> and <NAME> 

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

-----------------------------------------------------------------------

Project   : TSP
Maintainer: <EMAIL>
Component : Consumer

-----------------------------------------------------------------------

Purpose   : Simple consummer test that print samples received to stdout

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

#include "tsp_sys_headers.h"
#include "tsp_prjcfg.h"
#include "tsp_consumer.h"

/*#include "fortify.h"*/


/* Number of samples  that will be counted before the data check test pass */
#define TSP_TEST_COUNT_SAMPLES 100  
#define TSP_NANOSLEEP_PERIOD_US (100*1000) /* 10Hz */

int main(int argc, char *argv[]){

  const TSP_consumer_information_t*  information;
  TSP_consumer_symbol_requested_list_t symbols;

  int i, j;
  int period=0;
  char* name;
  int count_samples = 0;
  int nb_samples = -1;
  char symbol_buf[50];
  int test_ok = TRUE;
  int test_mode = 0;
  int all_data_ok = TRUE;
  TSP_provider_t provider;


  /*Fortify_EnterScope();*/
  printf ("#=========================================================#\n");
  printf ("# Launching <stdout_client> for printing symbols received #\n");
  printf ("#=========================================================#\n");
 
  if(!TSP_consumer_init(&argc, &argv))
    {
      STRACE_ERROR(("TSP init failed"));
      return -1;
    }

  switch (argc-1) { /* No Breaks please */
  case 5: 
    nb_samples = atoi(argv[5]);  /* nb-sample */
  case 4:
    test_mode = atoi(argv[4]);  /* 0 = no, 1=infinite loop */
  case 3:       /* Anything after name and perdio --> test mode */
  case 2:
    period = atoi (argv[2]);
  case 1:      
    name = argv[1];
    break;
  default : 
      STRACE_ERROR(("USAGE %s : serverURL period <test mode nb_sample> \n", argv[0]));
      return -1;
  }

 once_again:
  
  /*-------------------------------------------------------------------------------------------------------*/ 
  /* TEST : STAGE 001 | STEP 001 */
  /*-------------------------------------------------------------------------------------------------------*/ 
  provider = TSP_consumer_connect_url(name);
  if(provider)
    {
      const char* info = TSP_consumer_get_connected_name(provider) ;
      STRACE_INFO(("Server %s, info = '%s'", name, info));
	  
      /* Check name */
      if(strcmp(info, "StubbedServer"))
	{
	  STRACE_ERROR(("Serveur name corrupted"));
	  STRACE_TEST(("STAGE 001 | STEP 001 : FAILED"));
	  return -1;
	}
	  
    }
  else
    {
      STRACE_ERROR(("Unable to find any provider for host"));
      return -1;
    }

  STRACE_TEST(("STAGE 001 | STEP 001 : PASSED"));


  /*-------------------------------------------------------------------------------------------------------*/ 
  /* TEST : STAGE 001 | STEP 002 */
  /*-------------------------------------------------------------------------------------------------------*/ 
  /* Le 1er provider existe puisqu'il y en a au moins 1 */

  if(!TSP_consumer_request_open(provider, 0, 0))
    {
      STRACE_ERROR(("TSP_request_provider_open failed"));
      STRACE_TEST(("STAGE 001 | STEP 002 : FAILED"));
      return -1;
    }
  <commit_msg>Check for StubbedServer name in URL format ...<commit_after>/*!  \file 

$Id: client_stdout.c,v 1.9 2004-10-05 12:19:28 tractobob Exp $

-----------------------------------------------------------------------

TSP Library - core components for a generic Transport Sampling Protocol.

Copyright (c) 2002 <NAME>, <NAME>, <NAME> and <NAME> 

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

-----------------------------------------------------------------------

Project   : TSP
Maintainer: <EMAIL>
Component : Consumer

-----------------------------------------------------------------------

Purpose   : Simple consummer test that print samples received to stdout

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

#include "tsp_sys_headers.h"
#include "tsp_prjcfg.h"
#include "tsp_consumer.h"

/*#include "fortify.h"*/


/* Number of samples  that will be counted before the data check test pass */
#define TSP_TEST_COUNT_SAMPLES 100  
#define TSP_NANOSLEEP_PERIOD_US (100*1000) /* 10Hz */

int main(int argc, char *argv[]){

  const TSP_consumer_information_t*  information;
  TSP_consumer_symbol_requested_list_t symbols;

  int i, j;
  int period=0;
  char* name;
  int count_samples = 0;
  int nb_samples = -1;
  char symbol_buf[50];
  int test_ok = TRUE;
  int test_mode = 0;
  int all_data_ok = TRUE;
  TSP_provider_t provider;


  /*Fortify_EnterScope();*/
  printf ("#=========================================================#\n");
  printf ("# Launching <stdout_client> for printing symbols received #\n");
  printf ("#=========================================================#\n");
 
  if(!TSP_consumer_init(&argc, &argv))
    {
      STRACE_ERROR(("TSP init failed"));
      return -1;
    }

  switch (argc-1) { /* No Breaks please */
  case 5: 
    nb_samples = atoi(argv[5]);  /* nb-sample */
  case 4:
    test_mode = atoi(argv[4]);  /* 0 = no, 1=infinite loop */
  case 3:       /* Anything after name and perdio --> test mode */
  case 2:
    period = atoi (argv[2]);
  case 1:      
    name = argv[1];
    break;
  default : 
      STRACE_ERROR(("USAGE %s : serverURL period <test mode nb_sample> \n", argv[0]));
      printf(TSP_URL_FORMAT_USAGE);
      return -1;
  }

 once_again:
  
  /*-------------------------------------------------------------------------------------------------------*/ 
  /* TEST : STAGE 001 | STEP 001 */
  /*-------------------------------------------------------------------------------------------------------*/ 
  provider = TSP_consumer_connect_url(name);
  if(provider)
    {
      const char* info = TSP_consumer_get_connected_name(provider) ;
      STRACE_INFO(("Server %s, info = '%s'", name, info));
	  
      /* Check name */
      if(!strstr(info, "StubbedServer"))
	{
	  STRACE_ERROR(("Serveur name corrupted"));
	  STRACE_TEST(("STAGE 001 | STEP 001 : FAILED"));
	  return -1;
	}
	  
    }
  else
    {
      STRACE_ERROR(("Unable to find any provider for host"));
      return -1;
    }

  STRACE_TEST(("STAGE 001 | STEP 001 : PASSED"));


  /*-------------------------------------------------------------------------------------------------------*/ 
  /* TEST : STAGE 001 | STEP 002 */
  /*-------------------------------------------------------------------------------------------------------*/ 
  /* Le 1er provider existe puisqu'il y en a au moins 1 */

  if(!TSP_consumer_request_open(provider, 0, 0))
    {
      STRACE_ERROR(("TSP_request_provider_open failed"));
      STRACE_TEST(("STAGE 001 | STEP 002 : FAILED"));
      return -1;
    }
  
{'fraction_non_alphanumeric': 0.2895813282001925, 'fraction_numerical': 0.02550529355149182, 'mean_word_length': 1.761794019933555, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '5814581', 'n_tokens_mistral': 2514, 'n_tokens_neox': 2294, 'n_words': 744}