LCOV - code coverage report
Current view: top level - imp - init.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 26 32 81.2 %
Date: 2025-11-11 12:26:46 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #include "../inc/header.h"
       2             : #include "../inc/param_manager.h"
       3             : 
       4             : #include "../inc/global_param.h"
       5             : 
       6             : /**
       7             :  *  \file init.cu
       8             :  *  \author martigan
       9             :  *  \brief Fichier pour la gestion du fichier de configuration en parametre
      10             :  *  \fn int set_with_conf_file(char *conf_file)
      11             :  *  \return 0 on success, other value on error
      12             :  *  
      13             :  *  modify the global variables nb_type, supported_type, supported_length, supported_last_file and supported_type_length
      14             :  *  accordingly to content of conf file.
      15             :  */
      16             : 
      17             : 
      18             : 
      19             : // VR 10-10-16 : est-ce bien utilisé, on dirait, donc les supported_type sont deprecated !
      20           1 : void setdefault(GlobalParam & gp, LocalParam & lp)
      21             : {
      22             :     // size_t NB_TYPE = 4;
      23             : 
      24             :     // VR 10-10-16 : on pourrait quand meme mettre cela dans une fonction
      25           1 :     uint32_t       types[NB_TYPE] = {2, 22, 15, 16};
      26             :     //uint32_t       lengths[NB_TYPE] = {4096, 4104, 9216, 9216};
      27             :     //uint32_t       last_files[NB_TYPE] = {0,0, 0, 0};
      28           1 :     uint32_t       types_lengths[NB_TYPE] = {4096, 4104, 9216, 9216}; // supported number bit
      29             :     
      30           6 :     for (int i = 0; i < NB_TYPE; ++i)
      31             :     {
      32           5 :         AddDTtoCache(gp, lp, types[i], types_lengths[i]);
      33             :     }
      34           1 : }
      35             : 
      36           1 : int set_with_conf_file(std::string conf_file_aux,GlobalParam & gp, LocalParam & lp)
      37             : {
      38           1 :     char    linebuf[256];
      39           1 :     std::vector<std::string> splited_buff;
      40             : 
      41           1 :     printf("file is %s\n", conf_file_aux.c_str());
      42           1 :     FILE *f = fopen(conf_file_aux.c_str(), "r");
      43           1 :     if (f == NULL)
      44             :     {
      45           0 :         printf("conf_file : %s does not exist, getting default type parameters\n", conf_file_aux.c_str());
      46             :         //conf_file = NULL;
      47           0 :         exit(1);
      48             :     } else {
      49           1 :         GlobalParam::Instance().nbtype_ = 0;
      50           2 :         while (fgets(linebuf,  sizeof(linebuf), f)) {
      51           1 :             if (linebuf[0] == '\n')
      52             :                 break;
      53           1 :             if (linebuf[0] == EOF) {
      54           0 :                 if(GlobalParam::Instance().nbtype_ == 0) {
      55           0 :                     puts("empty conf file");
      56           0 :                     return 1;
      57             :                 }
      58             :                 break;
      59             :             }
      60           1 :             if (linebuf[0] == '#')
      61           0 :                 continue;
      62           2 :             std::string buff(&linebuf[0]);
      63           1 :             boost::split(splited_buff, buff, boost::is_any_of(","));
      64           1 :             std::cout<<" buff : "<<buff<<std::endl;
      65           1 :             if (splited_buff.size()) {
      66           1 :                 AddDTtoCache(gp, lp, (uint32_t)atoi(&(splited_buff[0].at(0))), (uint32_t)atoi(&(splited_buff[2].at(0))));
      67             :             }
      68             :         }    
      69           1 :         if (GlobalParam::Instance().nbtype_ == 0) {
      70           1 :             printf("nothing usefull in conf file, exiting\n");
      71             :             return 1;
      72             :         }
      73           1 :         puts("conf file loaded");
      74           1 :         fclose(f);
      75             :     }
      76             :     return 0;   
      77             : }

Generated by: LCOV version 1.14