Main Page   Class Hierarchy   Compound List   File List   Compound Members  

C_GeneratorConfig.cpp

00001 /*
00002  *  This program is free software; you can redistribute it and/or modify
00003  *  it under the terms of the GNU General Public License as published by
00004  *  the Free Software Foundation; either version 2 of the License, or
00005  *  (at your option) any later version.
00006  *
00007  *  This program is distributed in the hope that it will be useful,
00008  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00009  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010  *  GNU General Public License for more details.
00011  *
00012  *  You should have received a copy of the GNU General Public License
00013  *  along with this program; if not, write to the Free Software
00014  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00015  *
00016  * (c)Copyright 2006 Hewlett-Packard Development Company, LP.
00017  *
00018  */
00019 
00020 #include "C_GeneratorConfig.hpp"
00021 #include "C_CommandLine.cpp"
00022 #include "GeneratorTrace.hpp"
00023 #include "GeneratorDefaults.h"
00024 #include "integer_t.hpp" // For strtoul_f
00025 
00026 #include <unistd.h>
00027 #include <cstring>
00028 
00029 #define XML_CONFIG_SECTION      (char*)"configuration"
00030 #define XML_CONFIG_SUBSECTION   (char*)"define"
00031 #define XML_CONFIG_ENTITY       (char*)"entity"
00032 #define XML_CONFIG_ENTITY_VALUE (char*)"traffic-param"
00033 #define XML_CONFIG_NAME         (char*)"name"
00034 #define XML_CONFIG_VALUE        (char*)"value"
00035 #define XML_CONFIG_PARAM_ENTITY_VALUE (char*)"config-param"
00036 
00037 
00038 const char* config_opt_table[] = {
00039   "call-rate",
00040   "burst-limit",
00041   "max-send",
00042   "max-receive",
00043   "select-timeout-ms",
00044   "max-simultaneous-calls",
00045   "call-timeout-ms",
00046   "msg-buffer-size",
00047   "display-period",
00048   "log-stat-period",
00049   "log-file",
00050   "log-stat-file",
00051   "response-time-repartition",
00052   "number-calls",
00053   "msg-check-level",
00054   "msg-check-behaviour",
00055   "data-log-file",
00056   "data-log-period",
00057   "data-log-number",
00058   "call-rate-scale",
00059   "external-data-file",
00060   "external-data-select",
00061   "data-log-rtdistrib",
00062   "log-protocol-stat-period",
00063   "log-protocol-stat-name",
00064   "log-protocol-stat-file",
00065   "display-protocol-stat",
00066   "display-scenario-stat",
00067   "files-no-timestamp",
00068   "call-timeout-behaviour-abort",
00069   "call-open-timeout-ms",
00070   "execute-check-action",
00071   "max-retrans",
00072   "retrans-enabled",
00073   "model-traffic-select"
00074 
00075 };
00076 
00077 static const char _check_level_char [] = {
00078   'P',
00079   'A'
00080 } ;
00081 
00082 static const char _check_behaviour_char [] = {
00083   'W',
00084   'E'
00085 } ;
00086 
00087 const unsigned int _check_level_mask [] = {
00088   0x00000002,
00089   0x00000004
00090 } ;
00091 
00092 const unsigned int _check_behaviour_mask [] = {
00093   LOG_LEVEL_WAR,
00094   LOG_LEVEL_ERR
00095 } ;
00096 
00097 const char* _check_external_select[] = {
00098   "sequential",
00099   "random"
00100 } ;
00101 
00102 
00103 const char* _model_traffic_select[] = {
00104   "uniform",
00105   "best-effort",
00106   "poisson"
00107 } ;
00108 
00109 bool C_GeneratorConfig::set_data 
00110 (T_GeneratorCmdLineOption   P_opt, 
00111  char                     **P_argtab) {
00112 
00113   char * L_currentValue = P_argtab [0] ;
00114 
00115     switch (P_opt) {
00116 
00117     case E_CMDLINE_conf_file:
00118       m_option_conf_file = L_currentValue ;
00119       return (true) ;
00120 
00121     case E_CMDLINE_scen_file:
00122       m_option_scen_file = L_currentValue ;
00123       return (true) ;
00124 
00125     case E_CMDLINE_dico_file:
00126       m_option_dico_file_list->push_back(L_currentValue) ;
00127       return (true) ;
00128 
00129     case E_CMDLINE_log_file:
00130       m_option_log_file = L_currentValue ;
00131       return (true) ;
00132 
00133     case E_CMDLINE_log_level: {
00134       for (unsigned int L_i=0; L_i < strlen(L_currentValue) ; L_i++) {
00135         switch (L_currentValue[L_i]) {
00136         case 'E':
00137         case 'e':
00138           m_option_log_level |= gen_mask_table[LOG_LEVEL_ERR] ;
00139           break ;
00140         case 'W':
00141         case 'w':
00142           m_option_log_level |= gen_mask_table[LOG_LEVEL_WAR] ;
00143           break ;
00144         case 'M':
00145         case 'm':
00146           m_option_log_level |= gen_mask_table[LOG_LEVEL_MSG] ;
00147           break ;
00148         case 'T':
00149         case 't':
00150           m_option_log_level |= gen_mask_table[LOG_LEVEL_TRAFFIC_ERR] ;
00151           break ;
00152         case 'B':
00153         case 'b':
00154           m_option_log_level |= gen_mask_table[LOG_LEVEL_BUF] ;
00155           break ;
00156         case 'A':
00157         case 'a':
00158           m_option_log_level |= gen_mask_table[LOG_LEVEL_ALL] ;
00159           break ;
00160         case 'N':
00161         case 'n':
00162           if (m_option_log_level & gen_mask_table[LOG_LEVEL_ERR]) {
00163             m_option_log_level -= gen_mask_table[LOG_LEVEL_ERR] ;
00164           }
00165           break ;
00166         default:
00167           return (false);
00168         }
00169       }
00170     }
00171       return (true) ;
00172 
00173     case E_CMDLINE_help:
00174       return (true) ;
00175 
00176     case E_CMDLINE_bg_mode:
00177       m_option_bg_mode = true ;
00178       return (true) ;
00179 
00180     case E_CMDLINE_timestamp_log:
00181       m_option_timestamp_log = false ;
00182       return (true) ;
00183 
00184     case E_CMDLINE_check_msg:
00185       m_option_check_msg = true ;
00186       return (true) ;
00187 
00188     case E_CMDLINE_remote_cmd:
00189       m_option_remote_cmd = L_currentValue ;
00190       return (true) ;
00191 
00192     case E_CMDLINE_remote_dico_path:
00193       m_option_remote_dico_path = L_currentValue ;
00194       return (true) ;
00195 
00196 
00197     case E_CMDLINE_nbOptions:
00198       return (false) ;          // ???
00199       
00200     } // switch (P_opt)
00201     
00202     return false;               // ???
00203 
00204 } // C_GeneratorConfig::set_data
00205 
00206 
00207 C_GeneratorConfig::C_GeneratorConfig (int P_argc, char** P_argv) {
00208 
00209   int L_result ;
00210   int L_i ;
00211 
00212   NEW_VAR (m_option_dico_file_list, T_charPlist);
00213  
00214   NEW_VAR (m_configValueList, T_ConfigValueList);
00215 
00216   C_GeneratorConfig::T_value_type one_value_string [] = {
00217     C_GeneratorConfig::E_VT_STRING
00218   } ;
00219 
00220 
00221   C_GeneratorConfig::T_command_option L_command_opt [] = {
00222 
00223      { E_CMDLINE_conf_file, (char*)"conf", 
00224        C_GeneratorConfig::E_OT_MANDATORY, 1 , one_value_string, 
00225        (char*)"<configuration file name>", (char*)""},
00226 
00227      { E_CMDLINE_scen_file, (char*)"scen", 
00228        C_GeneratorConfig::E_OT_MANDATORY, 1 , one_value_string, 
00229        (char*)"<scenario file name>", (char*)""},
00230 
00231      { E_CMDLINE_dico_file, (char*)"dico", 
00232        C_GeneratorConfig::E_OT_MANDATORY, 1 , one_value_string, 
00233        (char*)"<protocol dictionary file name>", (char*)"can be used more than once"},
00234 
00235      { E_CMDLINE_log_file, (char*)"log", 
00236        C_GeneratorConfig::E_OT_OPTIONAL, 1 , one_value_string, 
00237        (char*)"<logging file name>", (char*)""},
00238 
00239      { E_CMDLINE_log_level, (char*)"llevel", 
00240        C_GeneratorConfig::E_OT_OPTIONAL, 1 , one_value_string, 
00241        (char*)"<logging level mask>", 
00242        (char*)"levels: \n          M: msg,     B: buffer,   E: error,\n          W: warning, N: no error, T: traffic error,\n          A: all.     Default E"},
00243 
00244      { E_CMDLINE_help, (char*)"help",
00245        C_GeneratorConfig::E_OT_OPTIONAL, 0, NULL,
00246        (char*)"", (char*)"display syntax command line"},
00247 
00248      { E_CMDLINE_bg_mode, (char*)"bg",
00249        C_GeneratorConfig::E_OT_OPTIONAL, 0, NULL,
00250        (char*)"", (char*)"background mode"},
00251 
00252      { E_CMDLINE_timestamp_log, (char*)"notimelog",
00253        C_GeneratorConfig::E_OT_OPTIONAL, 0, NULL,
00254        (char*)"", (char*)"no time stamp on the log (default time stamp)"},
00255 
00256      { E_CMDLINE_check_msg, (char*)"msgcheck",
00257        C_GeneratorConfig::E_OT_OPTIONAL, 0, NULL,
00258        (char*)"", 
00259        (char*)"check the field of the messages received (default no check)"},
00260 
00261      { E_CMDLINE_remote_cmd, (char*)"ctrl",
00262        C_GeneratorConfig::E_OT_OPTIONAL, 1,  one_value_string,
00263        (char*)"", 
00264        (char*)"remote control active on @IP:port (default no remote)"},
00265 
00266      { E_CMDLINE_remote_dico_path, (char*)"ctrldicopath",
00267        C_GeneratorConfig::E_OT_OPTIONAL, 1,  one_value_string,
00268        (char*)"", 
00269        (char*)"remote dictionary path (default remote-ctrl.xml in\n                   /usr/local/share/seagull/config)"}
00270 
00271   } ;
00272 
00273 
00274   // general command line description
00275   C_GeneratorConfig::T_command_line L_command_descr = {
00276     E_CMDLINE_nbOptions, // options number
00277     E_CMDLINE_help, // option index for help: -1 => no help option
00278     L_command_opt // command options table
00279   } ;
00280 
00281 
00282   // Init to default values
00283   m_option_log_file  = DEF_OPTION_LOG_FILE  ;
00284   m_option_conf_file = DEF_OPTION_CONF_FILE ;
00285 
00286   m_option_scen_file = DEF_OPTION_SCEN_FILE ;
00287   m_option_log_level = gen_mask_table[DEF_OPTION_LOG_LEVEL] ;
00288   m_option_bg_mode   = DEF_OPTION_BG_MODE   ;
00289   m_call_rate = DEF_CALL_RATE ;
00290   m_burst_limit = DEF_BURST_LIMIT ;
00291   m_max_send = DEF_MAX_SEND ;
00292   m_max_receive = DEF_MAX_RECEIVE ;
00293   m_select_timeout = DEF_SELECT_TIMEOUT_MS ;
00294   m_max_simultaneous_calls = DEF_MAX_SIMULTANEOUS_CALLS ;
00295   m_call_timeout = DEF_CALL_TIMEOUT ;
00296   m_msg_buffer_size = DEF_MSG_BUFFER_SIZE ;
00297   m_display_period = DEF_DISPLAY_PERIOD ;
00298   m_log_stat_period = DEF_LOG_STAT_PERIOD ;
00299   m_log_stat_file = DEF_LOG_STAT_FILE ;
00300 
00301   m_external_data_file = DEF_EXTERNAL_DATA_FILE ; 
00302   m_external_data_select = DEF_EXTERNAL_DATA_SELECT ; // by default sequential
00303 
00304   m_resp_time_repart = DEF_RESP_TIME_REPART ;
00305   m_number_calls = DEF_NUMBER_CALLS ;
00306   m_option_timestamp_log = DEF_TIMESTAMP_LOG ;
00307   m_option_check_msg = DEF_CHECK_MSG ;
00308   m_check_level_mask = _check_level_mask[DEF_CHECK_LEVEL] ;
00309   m_check_behaviour = DEF_CHECK_BEHAVIOUR ;
00310 
00311   m_data_log_file = DEF_DATA_LOG_FILE ;
00312   m_data_log_period = DEF_DATA_LOG_PERIOD ;
00313   m_data_log_number = DEF_DATA_LOG_NUMBER ;
00314 
00315   m_data_log_rtdistrib = DEF_DATA_LOG_RTDISTRIB ;
00316   m_log_protocol_stat_period = DEF_LOG_PROTOCOL_STAT_PERIOD ;
00317   m_log_protocol_stat_name  = DEF_LOG_PROTOCOL_STAT  ;
00318   m_log_protocol_stat_file = DEF_LOG_PROTOCOL_STAT_FILE ;
00319   m_display_protocol_stat  = DEF_DISPLAY_PROTOCOL_STAT   ;
00320   m_display_scenario_stat  = DEF_DISPLAY_SCENARIO_STAT   ;
00321   m_files_no_timestamp     = DEF_FILES_NO_TIMESTAMP ;
00322   m_call_timeout_beh_abr   = DEF_CALL_TIMEOUT_BEH_ABRT ;
00323 
00324   m_execute_check_action   = DEF_EXECUTE_CHECK_ACTION ;
00325   m_open_timeout           = DEF_OPEN_TIMEOUT     ;
00326 
00327   m_max_retrans        = DEF_MAX_RETRANS       ;
00328   m_retrans_enabled    = DEF_RETRANS_ENABLED   ;
00329 
00330   m_model_traffic_select = DEF_MODEL_TRAFFIC_SELECT ; // by default to be define
00331 
00332   m_call_rate_scale = DEF_CALL_RATE_SCALE ;
00333 
00334   m_option_remote_cmd = DEF_OPTION_REMOTE_CMD ;
00335   m_option_remote_dico_path = DEF_REMOTE_DICO_PATH ;
00336 
00337   ALLOC_TABLE(m_conf_opt_set, bool*, sizeof(bool), E_CFG_OPT_Number);
00338   for(L_i=0; L_i < E_CFG_OPT_Number; L_i++) {
00339     m_conf_opt_set[L_i] = false ;
00340   }
00341   
00342   L_result = 
00343     startAnalyzeCommandLine (P_argc, (char**) P_argv, &L_command_descr) ;
00344 
00345   if (L_result == -1) {
00346      GEN_ERROR(E_GEN_FATAL_ERROR, "Analyze command line error");
00347   }
00348 
00349 }
00350 
00351 C_GeneratorConfig::~C_GeneratorConfig() {
00352 
00353   m_option_log_file = NULL ;
00354   m_option_conf_file = NULL ;
00355   m_option_bg_mode = false ;
00356   m_option_remote_cmd  = NULL ;
00357 
00358   m_option_remote_dico_path = NULL ;
00359 
00360   if (!m_option_dico_file_list->empty()) {
00361     m_option_dico_file_list->erase(m_option_dico_file_list->begin(),
00362                                   m_option_dico_file_list->end());
00363 
00364   }
00365   DELETE_VAR(m_option_dico_file_list);
00366 
00367 
00368   if (!m_configValueList->empty()) {
00369     m_configValueList->erase(m_configValueList->begin(),
00370                              m_configValueList->end());
00371 
00372   }
00373   DELETE_VAR(m_configValueList);
00374 
00375 
00376   FREE_TABLE(m_conf_opt_set);
00377 
00378 } // destructor
00379 
00380 
00381 
00382 
00383 bool          C_GeneratorConfig::checkConfig(){
00384 
00385   bool L_return = true ;
00386 
00387   return (L_return) ;
00388 }
00389 
00390 char* C_GeneratorConfig::get_conf_file() {
00391   return(m_option_conf_file) ;
00392 }
00393 
00394 
00395 char* C_GeneratorConfig::get_remote_cmd() {
00396   return(m_option_remote_cmd) ;
00397 }
00398 
00399 char* C_GeneratorConfig::get_remote_dico_path() {
00400   return(m_option_remote_dico_path) ;
00401 }
00402 
00403 char* C_GeneratorConfig::get_log_file() {
00404   return(m_option_log_file) ;
00405 }
00406 
00407 char* C_GeneratorConfig::get_scen_file() {
00408   return(m_option_scen_file) ;
00409 }
00410 
00411 T_pcharPlist  C_GeneratorConfig::get_dico_file_list() {
00412 return(m_option_dico_file_list) ;
00413 }
00414 
00415 
00416 T_pConfigValueList C_GeneratorConfig::get_config_param_list() {
00417 return(m_configValueList) ;
00418 }
00419 
00420 
00421 unsigned int C_GeneratorConfig::get_log_level() {
00422   return(m_option_log_level) ;
00423 }
00424 
00425 bool  C_GeneratorConfig::get_bg_mode () {
00426   return(m_option_bg_mode) ;
00427 }
00428 
00429 bool  C_GeneratorConfig::get_check_msg () {
00430   return(m_option_check_msg) ;
00431 }
00432 
00433 bool  C_GeneratorConfig::get_timestamp_log () {
00434   return(m_option_timestamp_log) ;
00435 }
00436 
00437 
00438 bool  C_GeneratorConfig::get_display_protocol_stat () {
00439   return(m_display_protocol_stat) ;
00440 }
00441 
00442 bool  C_GeneratorConfig::get_display_scenario_stat () {
00443   return(m_display_scenario_stat) ;
00444 }
00445 
00446 bool  C_GeneratorConfig::get_files_no_timestamp () {
00447   return(m_files_no_timestamp) ;
00448 }
00449 
00450 bool  C_GeneratorConfig::get_call_timeout_beh_abr () {
00451   return(m_call_timeout_beh_abr) ;
00452 }
00453 
00454 bool  C_GeneratorConfig::get_execute_check_action () {
00455   return (m_execute_check_action) ;
00456 }
00457 
00458 bool  C_GeneratorConfig::get_retrans_enabled () {
00459   return (m_retrans_enabled) ;
00460 }
00461 
00462 
00463 bool C_GeneratorConfig::set_value (T_GeneratorConfigOption P_opt, 
00464                                    char *P_value) {
00465   bool         L_ret     = true ;
00466   char        *L_end_str = NULL ;
00467   unsigned int L_i              ;
00468   int          L_j              ;
00469 
00470   switch (P_opt) {
00471   case E_CFG_OPT_CALL_RATE :
00472     m_call_rate = strtoul_f(P_value, &L_end_str, 10) ;
00473     if (L_end_str[0] != '\0') { // not a number
00474       L_ret = false ;
00475     }
00476     break ;
00477 
00478   case E_CFG_OPT_BURST_LIMIT :
00479     m_burst_limit = strtoul_f(P_value, &L_end_str, 10) ;
00480     if (L_end_str[0] != '\0') { // not a number
00481       L_ret = false ;
00482     }
00483     break ;
00484 
00485   case E_CFG_OPT_MAX_SEND :
00486     m_max_send = strtoul_f(P_value, &L_end_str, 10) ;
00487     if (L_end_str[0] != '\0') { // not a number
00488       L_ret = false ;
00489     }
00490     break ;
00491 
00492   case E_CFG_OPT_MAX_RECEIVE :
00493     m_max_receive = strtoul_f(P_value, &L_end_str, 10) ;
00494     if (L_end_str[0] != '\0') { // not a number
00495       L_ret = false ;
00496     }
00497     break ;
00498 
00499   case E_CFG_OPT_SELECT_TIMEOUT_MS :
00500     m_select_timeout = strtoul_f(P_value, &L_end_str, 10) ;
00501     if (L_end_str[0] != '\0') { // not a number
00502       L_ret = false ;
00503     }
00504     break ;
00505 
00506   case E_CFG_OPT_MAX_SIMULTANEOUS_CALLS :
00507     m_max_simultaneous_calls = strtoul_f(P_value, &L_end_str, 10) ;
00508     if (L_end_str[0] != '\0') { // not a number
00509       L_ret = false ;
00510     }
00511     break ;
00512 
00513   case E_CFG_OPT_CALL_TIMEOUT :
00514     m_call_timeout = strtoul_f(P_value, &L_end_str, 10) ;
00515     if (L_end_str[0] != '\0') { // not a number
00516       L_ret = false ;
00517     }
00518     break ;
00519 
00520   case E_CFG_OPT_MSG_BUFFER_SIZE :
00521     m_msg_buffer_size = strtoul_f(P_value, &L_end_str, 10) ;
00522     if (L_end_str[0] != '\0') { // not a number
00523       L_ret = false ;
00524     }
00525     break ;
00526 
00527   case E_CFG_OPT_DISPLAY_PERIOD :
00528     m_display_period = strtoul_f(P_value, &L_end_str, 10) ;
00529     if (L_end_str[0] != '\0') { // not a number
00530       L_ret = false ;
00531     }
00532     break ;
00533 
00534   case E_CFG_OPT_LOG_STAT_PERIOD :
00535     m_log_stat_period = strtoul_f(P_value, &L_end_str, 10) ;
00536     if (L_end_str[0] != '\0') { // not a number
00537       L_ret = false ;
00538     }
00539     break ;
00540 
00541   case E_CFG_OPT_LOG_FILE :
00542     m_option_log_file = P_value ; 
00543     break ;
00544 
00545   case E_CFG_OPT_LOG_STAT_FILE :
00546     m_log_stat_file = P_value ;
00547     break ;
00548 
00549   case E_CFG_OPT_RESP_TIME_REPART:
00550     m_resp_time_repart = P_value ;
00551     break ;
00552 
00553   case E_CFG_OPT_NUMBER_CALLS:
00554     m_number_calls = strtoul_f(P_value, &L_end_str, 10) ;
00555     if (L_end_str[0] != '\0') { // not a number
00556       L_ret = false ;
00557     }
00558     break ;
00559 
00560   case E_CFG_OPT_CHECK_LEVEL:
00561     m_check_level_mask = 0 ;
00562     for (L_i=0; L_i < strlen(P_value); L_i++) {
00563       for (L_j = 0 ; L_j < E_NB_CHECK_LEVEL; L_j++) {
00564         if (P_value[L_i] == _check_level_char[L_j]) {
00565           m_check_level_mask |= _check_level_mask[L_j] ;
00566           break ;
00567         }
00568       }
00569     }
00570     break ;
00571 
00572   case E_CFG_OPT_CHECK_BEHAVIOUR:
00573     L_ret = false ;
00574     if (strlen(P_value) == 1) {
00575       for (L_j = 0 ; L_j < E_NB_CHECK_BEHAVIOUR; L_j++) {
00576         if (P_value[0] == _check_behaviour_char[L_j]) {
00577           m_check_behaviour = L_j ;
00578           L_ret = true ;
00579           break ;
00580         }
00581       }
00582     }
00583     break ;
00584 
00585   case E_CFG_OPT_DATA_LOG_FILE:
00586     m_data_log_file = P_value ;
00587     break ;
00588 
00589   case E_CFG_OPT_DATA_LOG_PERIOD:
00590     m_data_log_period = strtoul_f(P_value, &L_end_str, 10) ;
00591     if (L_end_str[0] != '\0') { // not a number
00592       L_ret = false ;
00593     }
00594     break ;
00595 
00596   case E_CFG_OPT_DATA_LOG_NUMBER:
00597     m_data_log_number = strtoul_f(P_value, &L_end_str, 10) ;
00598     if (L_end_str[0] != '\0') { // not a number
00599       L_ret = false ;
00600     }
00601     break ;
00602 
00603   case E_CFG_OPT_CALL_RATE_SCALE :
00604     m_call_rate_scale = strtoul_f(P_value, &L_end_str, 10) ;
00605     if (L_end_str[0] != '\0') { // not a number
00606       L_ret = false ;
00607     }
00608     break ;
00609 
00610   case E_CFG_OPT_EXTERNAL_DATA_FILE :
00611     m_external_data_file = P_value ;
00612     break ;
00613 
00614   case E_CFG_OPT_EXTERNAL_DATA_SELECT :
00615     L_ret = false ;
00616     for (L_j = 0; L_j < E_NB_CHECK_DATA_SELECT ; L_j ++) {
00617       if(strcmp(P_value, _check_external_select[L_j]) == 0) {
00618         m_external_data_select = L_j ;
00619         L_ret = true ;
00620         break ;
00621       }
00622     }
00623 
00624       break ;
00625 
00626 
00627   case E_CFG_OPT_DATA_LOG_RTDISTRIB:
00628 
00629     m_data_log_rtdistrib = strtoul_f(P_value, &L_end_str, 10) ;
00630     if (L_end_str[0] != '\0') { // not a number
00631       L_ret = false ;
00632     }
00633     break ;
00634 
00635   case E_CFG_OPT_LOG_PROTOCOL_STAT_PERIOD:
00636 
00637     m_log_protocol_stat_period = strtoul_f(P_value, &L_end_str, 10) ;
00638     if (L_end_str[0] != '\0') { // not a number
00639       L_ret = false ;
00640     }
00641     break ;
00642 
00643   case E_CFG_OPT_LOG_PROTOCOL_STAT_NAME:
00644     m_log_protocol_stat_name = P_value ;
00645     break ;
00646 
00647   case E_CFG_OPT_LOG_PROTOCOL_STAT_FILE:
00648     m_log_protocol_stat_file = P_value ;
00649     break ;
00650 
00651   case E_CFG_OPT_DISPLAY_PROTOCOL_STAT:
00652     if(strcmp(P_value, (char *)"true") == 0) {
00653       m_display_protocol_stat = true ;
00654     } else {
00655       if(strcmp(P_value, (char *)"false") != 0) {
00656         L_ret = false ;
00657       }
00658     }
00659 
00660     break ;
00661 
00662   case E_CFG_OPT_DISPLAY_SCENARIO_STAT:
00663 
00664     if(strcmp(P_value, (char *)"true") == 0) {
00665       m_display_scenario_stat = true ;
00666     } else {
00667       if(strcmp(P_value, (char *)"false") != 0) {
00668         L_ret = false ;
00669       }
00670     }
00671     break ;
00672 
00673   case E_CFG_OPT_FILES_NO_TIMESTAMP:
00674 
00675     if(strcmp(P_value, (char *)"true") == 0) {
00676       m_files_no_timestamp = true ;
00677     } else {
00678       if(strcmp(P_value, (char *)"false") != 0) {
00679         L_ret = false ;
00680       }
00681     }
00682     break ;
00683 
00684 
00685   case E_CFG_OPT_CALL_TIMEOUT_BEH_ABR:
00686 
00687     if(strcmp(P_value, (char *)"true") == 0) {
00688       m_call_timeout_beh_abr = true ;
00689     } else {
00690       if(strcmp(P_value, (char *)"false") != 0) {
00691         L_ret = false ;
00692       }
00693     }
00694     break ;
00695 
00696   case E_CFG_OPT_OPEN_TIMEOUT :
00697     m_open_timeout = strtoul_f(P_value, &L_end_str, 10) ;
00698     if (L_end_str[0] != '\0') { // not a number
00699       L_ret = false ;
00700     }
00701     break ;
00702 
00703   case E_CFG_OPT_EXECUTE_CHECK_ACTION:
00704 
00705     if(strcmp(P_value, (char *)"false") == 0) {
00706       m_execute_check_action = false ;
00707     } else {
00708       if(strcmp(P_value, (char *)"true") != 0) {
00709         L_ret = false ;
00710       }
00711     }
00712     break ;
00713 
00714 
00715   case E_CFG_OPT_MAX_RETRANS :
00716     m_max_retrans = strtoul_f(P_value, &L_end_str, 10) ;
00717     if (L_end_str[0] != '\0') { // not a number
00718       L_ret = false ;
00719     }
00720     break ;
00721 
00722   case E_CFG_OPT_RETRANS_ENABLED:
00723 
00724     if(strcmp(P_value, (char *)"true") == 0) {
00725       m_retrans_enabled = true ;
00726     } else {
00727       if(strcmp(P_value, (char *)"false") != 0) {
00728         L_ret = false ;
00729       }
00730     }
00731     break ;
00732 
00733   case E_CFG_OPT_MODEL_TRAFFIC_SELECT :
00734     L_ret = false ;
00735     for (L_j = 0; L_j < E_NB_MODEL_TRAFFIC_SELECT ; L_j ++) {
00736       if(strcmp(P_value, _model_traffic_select[L_j]) == 0) {
00737         m_model_traffic_select = L_j ;
00738         L_ret = true ;
00739         break ;
00740       }
00741     }
00742 
00743       break ;
00744 
00745 
00746   default:
00747     L_ret = false ;
00748     break ;
00749   } // switch
00750 
00751   if (L_ret == true) {
00752     m_conf_opt_set[P_opt]=true ;
00753   }
00754 
00755   return (L_ret);
00756 
00757 }
00758 
00759 bool C_GeneratorConfig::is_value_set (T_GeneratorConfigOption  P_opt) {
00760   bool L_ret = false ;
00761   if (P_opt < E_CFG_OPT_Number) {
00762     L_ret = m_conf_opt_set[P_opt] ;
00763   }
00764   return (L_ret);
00765 }
00766 
00767 bool C_GeneratorConfig::get_value (T_GeneratorConfigOption  P_opt,
00768                                    unsigned long           *P_val) {
00769   bool L_ret = true ;
00770 
00771   switch (P_opt) {
00772   case E_CFG_OPT_CALL_RATE :
00773     *P_val = m_call_rate ;
00774     break ;
00775 
00776   case E_CFG_OPT_BURST_LIMIT :
00777     *P_val = m_burst_limit ;
00778     break ;
00779 
00780   case E_CFG_OPT_MAX_SEND :
00781     *P_val = m_max_send ;
00782     break ;
00783 
00784   case E_CFG_OPT_MAX_RECEIVE :
00785     *P_val = m_max_receive ;
00786     break ;
00787 
00788   case E_CFG_OPT_SELECT_TIMEOUT_MS :
00789     *P_val = m_select_timeout ;
00790     break ;
00791 
00792   case E_CFG_OPT_MAX_SIMULTANEOUS_CALLS :
00793     *P_val = m_max_simultaneous_calls ;
00794     break ;
00795 
00796   case E_CFG_OPT_CALL_TIMEOUT :
00797     *P_val = m_call_timeout ;
00798     break ;
00799 
00800   case E_CFG_OPT_MSG_BUFFER_SIZE :
00801     *P_val = m_msg_buffer_size ;
00802     break ;
00803 
00804   case E_CFG_OPT_DISPLAY_PERIOD :
00805     *P_val = m_display_period ;
00806     break ;
00807 
00808   case E_CFG_OPT_LOG_STAT_PERIOD :
00809     *P_val = m_log_stat_period ;
00810     break ;
00811 
00812   case E_CFG_OPT_NUMBER_CALLS:
00813     *P_val = m_number_calls ;
00814     break ;
00815 
00816   case E_CFG_OPT_DATA_LOG_PERIOD:
00817     *P_val = m_data_log_period ;
00818     break ;
00819 
00820   case E_CFG_OPT_DATA_LOG_NUMBER:
00821     *P_val = m_data_log_number ;
00822     break ;
00823 
00824   case E_CFG_OPT_CALL_RATE_SCALE :
00825     *P_val = m_call_rate_scale ;
00826     break ;
00827 
00828   case E_CFG_OPT_DATA_LOG_RTDISTRIB:
00829 
00830     *P_val = m_data_log_rtdistrib ;
00831     break ;
00832 
00833   case E_CFG_OPT_LOG_PROTOCOL_STAT_PERIOD :
00834     *P_val = m_log_protocol_stat_period ;
00835     break ;
00836 
00837   case E_CFG_OPT_OPEN_TIMEOUT :
00838     *P_val = m_open_timeout ;
00839     break ;
00840 
00841   case E_CFG_OPT_MAX_RETRANS :
00842     *P_val = m_max_retrans ;
00843     break ;
00844 
00845 
00846   default:
00847     L_ret = false ;
00848     break ;
00849   } // switch
00850 
00851   return (L_ret) ;
00852 
00853 }
00854 
00855 bool C_GeneratorConfig::get_value (T_GeneratorConfigOption  P_opt,
00856                                    unsigned int            *P_val) {
00857   bool L_ret = true ;
00858 
00859   switch (P_opt) {
00860   case E_CFG_OPT_CHECK_LEVEL:
00861     *P_val = m_check_level_mask ;
00862     break ;
00863 
00864   case E_CFG_OPT_CHECK_BEHAVIOUR:
00865     *P_val = m_check_behaviour ;
00866     break ;
00867 
00868   case E_CFG_OPT_EXTERNAL_DATA_SELECT :
00869     *P_val = m_external_data_select ;
00870     break ;
00871 
00872   case E_CFG_OPT_MODEL_TRAFFIC_SELECT :
00873     *P_val = m_model_traffic_select ;
00874     break ;
00875 
00876   default:
00877     L_ret = false ;
00878     break ;
00879   } // switch
00880 
00881   return (L_ret) ;
00882 
00883 }
00884 
00885 bool C_GeneratorConfig::get_value (T_GeneratorConfigOption  P_opt,
00886                                     char                    **P_val) {
00887 
00888   bool L_ret = true ;
00889 
00890   switch (P_opt) {
00891 
00892   case E_CFG_OPT_LOG_FILE :
00893     *P_val = m_option_log_file ;
00894     break ;
00895 
00896   case E_CFG_OPT_LOG_STAT_FILE :
00897     *P_val = m_log_stat_file ;
00898     break ;
00899 
00900   case E_CFG_OPT_RESP_TIME_REPART :
00901     *P_val = m_resp_time_repart ;
00902     break ;
00903 
00904   case E_CFG_OPT_EXTERNAL_DATA_FILE :
00905     *P_val = m_external_data_file ;
00906     break ;
00907 
00908   case E_CFG_OPT_LOG_PROTOCOL_STAT_NAME :
00909     *P_val = m_log_protocol_stat_name ;
00910     break ;
00911 
00912   default:
00913     L_ret = false ;
00914     break ;
00915   } // switch
00916 
00917   return (L_ret) ;
00918 
00919 }
00920 
00921 bool C_GeneratorConfig::get_value (T_GeneratorConfigOption  P_opt,
00922                                    string_t&             P_val) {
00923 
00924   bool L_ret = true ;
00925 
00926   switch (P_opt) {
00927 
00928   case E_CFG_OPT_LOG_FILE :
00929     P_val = "" ;
00930     if (m_option_log_file != NULL) {
00931       P_val.append(m_option_log_file);
00932     }
00933     break ;
00934 
00935   case E_CFG_OPT_LOG_STAT_FILE :
00936     P_val = "" ;
00937     if (m_log_stat_file != NULL) {
00938       P_val.append(m_log_stat_file);
00939     }
00940     break ;
00941 
00942   case E_CFG_OPT_RESP_TIME_REPART :
00943     P_val = "" ;
00944     if (m_resp_time_repart != NULL) {
00945       P_val.append(m_resp_time_repart);
00946     }
00947     break ;
00948 
00949   case E_CFG_OPT_DATA_LOG_FILE :
00950     P_val = "" ;
00951     if (m_data_log_file != NULL) {
00952       P_val.append(m_data_log_file);
00953     }
00954     break ;
00955 
00956   case E_CFG_OPT_LOG_PROTOCOL_STAT_FILE :
00957 
00958     P_val = "" ;
00959     if (m_log_protocol_stat_file != NULL) {
00960       P_val.append(m_log_protocol_stat_file);
00961     }
00962     break ;
00963 
00964   default:
00965     L_ret = false ;
00966     break ;
00967   } // switch
00968 
00969   return (L_ret) ;
00970 
00971 }
00972 
00973 T_GeneratorConfigOption C_GeneratorConfig::get_code (char* P_name) {
00974   T_GeneratorConfigOption L_ret = E_CFG_OPT_Number ;
00975   int                     L_i ;
00976 
00977   for (L_i = 0 ; L_i < E_CFG_OPT_Number; L_i++) {
00978     if (strcmp(P_name, config_opt_table[L_i])==0) {
00979       L_ret = (T_GeneratorConfigOption) L_i ; 
00980       break ;
00981     }
00982   }
00983   return (L_ret) ;
00984 }
00985 
00986 bool C_GeneratorConfig::fromXml (C_XmlData          *P_data) {
00987 
00988   bool                      L_ret = true ;
00989   T_pXmlData_List           L_sectionList, L_subSectionList            ;
00990   T_XmlData_List::iterator  L_sectionListIt, L_subSectionListIt ;
00991   C_XmlData                *L_section, *L_subSection ;
00992   char                     *L_entity_value ;
00993   char                     *L_param_name, *L_param_value ;
00994   T_GeneratorConfigOption   L_param_code ;
00995   bool                      L_decode_param ;
00996 
00997   T_ConfigValue             L_configValue     ;
00998   
00999   if (P_data != NULL) {
01000 
01001     if ((L_sectionList = P_data->get_sub_data()) != NULL) {
01002       
01003       for(L_sectionListIt  = L_sectionList->begin() ;
01004           L_sectionListIt != L_sectionList->end() ;
01005           L_sectionListIt++) {
01006         
01007         L_section = *L_sectionListIt ;
01008         if (L_section != NULL) {
01009           if (strcmp(L_section->get_name(), 
01010                      XML_CONFIG_SECTION) == 0) {
01011 
01012             L_subSectionList = L_section->get_sub_data() ;
01013             for(L_subSectionListIt  = L_subSectionList->begin() ;
01014                 L_subSectionListIt != L_subSectionList->end() ;
01015                 L_subSectionListIt++) {
01016               L_subSection = *L_subSectionListIt ;
01017               
01018               if (strcmp(L_subSection->get_name(), 
01019                          XML_CONFIG_SUBSECTION) == 0) {
01020 
01021                 L_entity_value = L_subSection->find_value(XML_CONFIG_ENTITY) ;
01022                 if (L_entity_value != NULL) {
01023 
01024                   if (strcmp(L_entity_value, XML_CONFIG_ENTITY_VALUE) == 0) {
01025                     L_param_name = L_subSection->find_value(XML_CONFIG_NAME);
01026                     L_param_value = L_subSection->find_value(XML_CONFIG_VALUE);
01027 
01028                     L_param_code = get_code(L_param_name);
01029 
01030                     if (L_param_code != E_CFG_OPT_Number) {
01031                       L_decode_param = set_value (L_param_code, L_param_value) ;
01032 
01033                       if (L_decode_param == false) {
01034                         GEN_ERROR(E_GEN_FATAL_ERROR, "Format incorrect for value ["
01035                                   << L_param_value << "] for parameter ["
01036                                   << L_param_name << "]");
01037                         L_ret = false ;
01038                         break ;
01039                       }
01040                     } else {
01041                       GEN_ERROR(E_GEN_FATAL_ERROR, "Unknown configuration parameter ["
01042                                 << L_param_name << "]");
01043                       L_ret = false ;
01044                       break ;
01045                     }
01046                   }
01047                    if (strcmp(L_entity_value, XML_CONFIG_PARAM_ENTITY_VALUE) == 0) {
01048                     L_configValue.m_name = L_subSection->find_value(XML_CONFIG_NAME);
01049                     L_configValue.m_value = L_subSection->find_value(XML_CONFIG_VALUE);
01050                     m_configValueList->push_back(L_configValue);
01051                    }
01052 
01053                 } 
01054               }
01055             }
01056           }
01057         } 
01058       }
01059 
01060     } else {
01061       GEN_ERROR(E_GEN_FATAL_ERROR, "No Xml data");
01062       L_ret = false ;
01063     }
01064   } else { // P_data == NULL
01065     GEN_ERROR(E_GEN_FATAL_ERROR, "No Xml data");
01066     L_ret = false ;
01067   }
01068 
01069 
01070   return (L_ret);
01071 }
01072 
01073 iostream_output& operator<< (iostream_output& P_ostream, 
01074                              C_GeneratorConfig & P_conf) {
01075 
01076   const char  novalue[]    = "none"    ;
01077   const char  truevalue[]  = "true"    ;
01078   const char  falsevalue[] = "false"   ;
01079   const char  warnvalue[]  = "warning" ;
01080   const char  errvalue[]   = "error"   ;
01081 
01082   const char  seqselect[]   = "sequential"   ;
01083   const char  ranselect[]   = "random"   ;
01084 
01085   char       *L_value                  ;
01086   string_t    logstring    = ""        ;
01087   string_t    checkstring  = ""        ;
01088   int         L_j                      ;
01089   T_charPlist::iterator     L_iterator ;
01090 
01091   P_ostream << "Configuration data:" << iostream_endl ;
01092 
01093 
01094   L_value = (P_conf.m_option_log_file == NULL) 
01095     ? (char*) novalue : P_conf.m_option_log_file ;
01096   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "option_log_file  ["
01097             <<  L_value
01098             << "]" << iostream_endl ;
01099 
01100   L_value = (P_conf.m_option_conf_file == NULL) 
01101     ? (char*) novalue : P_conf.m_option_conf_file ;
01102   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "option_conf_file ["
01103             << L_value 
01104             << "]" << iostream_endl ;
01105 
01106   if (P_conf.m_option_dico_file_list->empty()) {
01107     L_value = (char*) novalue ; 
01108     P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "option_dico_file ["
01109               << L_value 
01110               << "]" << iostream_endl ;
01111   } else {
01112     for (L_iterator = P_conf.m_option_dico_file_list->begin();
01113          L_iterator != P_conf.m_option_dico_file_list->end();
01114          L_iterator++) {
01115       P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "option_dico_file ["
01116                 << *L_iterator
01117                 << "]" << iostream_endl ;
01118     }
01119   }
01120   
01121   L_value = (P_conf.m_option_scen_file == NULL) 
01122     ? (char*)novalue : P_conf.m_option_scen_file ;
01123   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "option_scen_file ["
01124             << L_value 
01125             << "]" << iostream_endl ;
01126 
01127   L_value = (P_conf.m_log_stat_file == NULL) 
01128     ? (char*)novalue : P_conf.m_log_stat_file ;
01129   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "log_stat_file    ["
01130             << L_value 
01131             << "]" << iostream_endl ;
01132 
01133   if (P_conf.m_option_log_level == gen_mask_table[LOG_LEVEL_ALL]) {
01134     logstring += "A" ;
01135   } else {
01136     if (P_conf.m_option_log_level & gen_mask_table[LOG_LEVEL_ERR]) {
01137       logstring += "E" ;
01138     }
01139     if (P_conf.m_option_log_level & gen_mask_table[LOG_LEVEL_WAR]) {
01140       logstring += "W" ;
01141     }
01142     if (P_conf.m_option_log_level & gen_mask_table[LOG_LEVEL_MSG]) {
01143       logstring += "M" ;
01144     }
01145     if (P_conf.m_option_log_level & gen_mask_table[LOG_LEVEL_TRAFFIC_ERR]) {
01146       logstring += "T" ;
01147     }
01148     if (P_conf.m_option_log_level & gen_mask_table[LOG_LEVEL_BUF]) {
01149       logstring += "B" ;
01150     }
01151   }
01152   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "option_log_level ["
01153             << logstring << "]" << iostream_endl ;
01154 
01155   L_value = (P_conf.m_option_bg_mode == true) 
01156     ? (char*)truevalue : (char*)falsevalue ;
01157   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "option_bg_mode   ["
01158             << L_value << "]" << iostream_endl ;
01159 
01160   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "call_rate        ["
01161             << P_conf.m_call_rate << "]" << iostream_endl ;
01162   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "burst_limit      ["
01163             << P_conf.m_burst_limit << "]" << iostream_endl ;
01164   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "max_send         ["
01165             << P_conf.m_max_send << "]" << iostream_endl ;
01166   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "max_receive      ["
01167             << P_conf.m_max_receive << "]" << iostream_endl ;
01168   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "select_timeout   ["
01169             << P_conf.m_select_timeout << "]" << iostream_endl ;
01170   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "max_simult_calls ["
01171             << P_conf.m_max_simultaneous_calls << "]" << iostream_endl ;
01172   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "call_timeout_ms  ["
01173             << P_conf.m_call_timeout << "]" << iostream_endl ;
01174   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "msg_buffer_size  ["
01175             << P_conf.m_msg_buffer_size << "]" << iostream_endl ;
01176   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "display_period   ["
01177             << P_conf.m_display_period << "]" << iostream_endl ;
01178   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "log_stat_period  ["
01179             << P_conf.m_log_stat_period << "]" << iostream_endl ;
01180   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "resp_time_repart ["
01181             << P_conf.m_resp_time_repart << "]" << iostream_endl ;
01182   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "number_calls     ["
01183             << P_conf.m_number_calls << "]" << iostream_endl ;
01184 
01185   L_value = (P_conf.m_option_timestamp_log == true) ? 
01186     (char*)falsevalue : (char*)truevalue ;
01187 
01188   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "notimelog        ["
01189             << L_value << "]" << iostream_endl ;
01190 
01191   L_value = (P_conf.m_option_check_msg == false) ? 
01192     (char*)falsevalue : (char*)truevalue ;
01193 
01194   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "msg check        ["
01195             << L_value << "]" << iostream_endl ;
01196 
01197   for (L_j = 0; L_j < E_NB_CHECK_LEVEL; L_j++) {
01198     if (P_conf.m_check_level_mask & _check_level_mask[L_j]) {
01199       checkstring += _check_level_char[L_j] ;
01200     }
01201   }
01202   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "msg check mask   ["
01203             << checkstring << "]" << iostream_endl ;
01204 
01205   L_value = (char*)novalue ;
01206   if (P_conf.m_check_behaviour == E_CHECK_BEHAVIOUR_WARNING) {
01207     L_value = (char*)warnvalue ;
01208   }
01209   if (P_conf.m_check_behaviour == E_CHECK_BEHAVIOUR_ERROR) {
01210     L_value = (char*)errvalue ;
01211   }
01212 
01213   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "check behaviour  ["
01214             << L_value << "]" << iostream_endl ;
01215 
01216   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "call rate scale  ["
01217             << P_conf.m_call_rate_scale << "]" << iostream_endl ;
01218 
01219   L_value = (char*)(_model_traffic_select[P_conf.m_model_traffic_select]); 
01220   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "model traffic    ["
01221        << L_value << "]" << iostream_endl ;
01222 
01223   L_value = (P_conf.m_external_data_file == NULL) 
01224     ? (char*)novalue : P_conf.m_external_data_file ;
01225   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "external data file    ["
01226             << L_value 
01227             << "]" << iostream_endl ;
01228 
01229   
01230   L_value = (char*)novalue ;
01231   if (P_conf.m_external_data_select == 0) {
01232     L_value = (char*)seqselect ;
01233   }
01234   if (P_conf.m_external_data_select == 1) {
01235     L_value = (char*)ranselect ;
01236   }
01237 
01238   P_ostream << GEN_HEADER_LOG << GEN_HEADER_NO_LEVEL << "external data select  ["
01239             << L_value << "]" ;
01240 
01241 
01242   return (P_ostream) ;
01243 }
01244 
01245 int         C_GeneratorConfig::analyze_protocol_stat(char          *P_logProtocolStat,
01246                                                      T_charPlist   *P_protocol_list,
01247                                                      bool           *P_all_found) {
01248   regex_t                 *L_regExpr = NULL   ;
01249   regmatch_t               L_pmatch           ;
01250 
01251   char                    *L_search  = NULL   ;
01252   char                     L_buffer[100]      ;
01253   char                    *L_search_begin     ;
01254   char                    *L_search_end       ;
01255   char                    *L_string  = NULL   ;
01256 
01257   int                      L_status           ;
01258   int                      L_size             ;
01259   int                      L_ret      = 0     ;
01260 
01261   int                      L_result   = 0     ;
01262 
01263   ALLOC_VAR(L_regExpr, regex_t*, sizeof(regex_t));
01264 
01265   L_status = regcomp (L_regExpr, "[^;][^;]*[;]*", REG_EXTENDED) ;
01266 
01267   if (L_status != 0) {
01268     regerror(L_status, L_regExpr, L_buffer, 100);
01269     regfree (L_regExpr) ;
01270     FREE_VAR(L_regExpr);
01271     GEN_ERROR(E_GEN_FATAL_ERROR, "regcomp error: [" << L_buffer << "]");
01272     L_result = -1 ;
01273   } else {
01274     L_search = P_logProtocolStat ;
01275     do {
01276       L_status = regexec (L_regExpr, L_search, 1, &L_pmatch, 0) ;
01277       
01278       // matching is OK
01279       if (L_status == 0) {
01280         L_ret  = L_pmatch.rm_eo ;
01281         L_size = (L_pmatch.rm_eo - L_pmatch.rm_so) ;
01282         
01283         L_search_begin = L_search ;
01284         L_search_end = L_search + L_size - 1 ;
01285         
01286         while (L_search_end[0] == ';') L_search_end--;
01287         while (L_search_end[0] == ' ') L_search_end--;
01288 
01289         L_size = L_search_end - L_search + 1 ;
01290 
01291         while(isspace(*L_search_begin)) {
01292           L_search_begin++;
01293           L_size--;
01294         }
01295 
01296         if (L_size > 0) {
01297           ALLOC_TABLE(L_string, char*, sizeof(char), L_size+1);
01298           snprintf(L_string, L_size+1, "%s", L_search_begin);
01299           L_string[L_size+1] = 0 ;
01300           if (strcmp(L_string, (char*)"all") == 0) {
01301             (*P_all_found) = true ;         
01302             break;
01303           }
01304           P_protocol_list ->push_back(L_string) ;
01305         }
01306  
01307         L_search += L_ret ;     
01308 
01309         if (L_search[0] == '\0') break ;
01310         
01311       } else {
01312         L_result = -1 ;
01313       }
01314     } while (L_status == 0) ;
01315 
01316     if (L_regExpr) {
01317       regfree (L_regExpr) ;
01318       FREE_VAR(L_regExpr);
01319     }
01320   }
01321   
01322   return (L_result) ;
01323 }
01324 
01325 
01326 // End of file

Generated on Wed Mar 7 14:44:50 2007 for Seagull by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002