<commit_before>// Copyright **********************************************************
//                                                                      
// File ecmdDataBuffer.C                                               
//                                                                      
// IBM Confidential                                                     
// OCO Source Materials                                                 
// 9400 Licensed Internal Code                                          
// (C) COPYRIGHT IBM CORP. 2003
//                                                                      
// The source code for this program is not published or otherwise       
// divested of its trade secrets, irrespective of what has been         
// deposited with the U.S. Copyright Office.                             
//                                                                      
// End Copyright ******************************************************

/* $Header$ */

/**
 * @file ecmdUtils.C
 * @brief Useful functions for use throughout the ecmd C API
 *
 */

//--------------------------------------------------------------------
// Includes
//--------------------------------------------------------------------
#include <inttypes.h>
#include <string>
#include <vector>
#include <list>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>

#include <ecmdUtils.H>
#include <ecmdSharedUtils.H>
#include <ecmdClientCapi.H>
#include <ecmdReturnCodes.H>
//----------------------------------------------------------------------
//  Constants
//----------------------------------------------------------------------



typedef enum {
  ECMD_FORMAT_NONE,
  ECMD_FORMAT_X,
  ECMD_FORMAT_XR,
  ECMD_FORMAT_XW,
  ECMD_FORMAT_XRW,
  ECMD_FORMAT_B,
  ECMD_FORMAT_BN,
  ECMD_FORMAT_BW,
  ECMD_FORMAT_BX,
  ECMD_FORMAT_BXN,
  ECMD_FORMAT_BXW,
  ECMD_FORMAT_MEM,
  ECMD_FORMAT_MEMA,
  ECMD_FORMAT_MEMD,
  ECMD_FORMAT_MEME
} ecmdFormatState_t;


char frontFPPTxt[35];
int  fppCallCount;


//--------------------------------------------------------------------
// Macros
//--------------------------------------------------------------------

void ecmdIncrementLooperIterators (uint8_t level, ecmdLooperData& io_state);
std::string printEcmdChipTargetState_t(ecmdChipTargetState_t state);
/**
 @brief Print ecmdDataBuffer's for the EFPP
 @param i_data Databuffer to print
 @param i_tabStop Any additional spacing that should be done in display (ie "  \t")
*/
void printEcmdDataBuffer(std::string variableType, std::string variableName, ecmdDataBuffer & i_data, std::string i_tabStop);

//----------------------------------------------------------------------
//  Global Variables
//----------------------------------------------------------------------
#ifdef FIPSODE
tracDesc_t g_ptrc; /** Procedure Trace Descriptor **/
TRAC_INIT(&g_ptrc, "PTRC", 0x8000);
#endif

#ifndef ECMD_STRIP_DEBUG
/* This is from ecmdClientCapi.C */
extern int ecmdClientDebug;
#endif

//----------------------------------------------------------------------
//  User Types
//----------------------------------------------------------------------



uint32_t ecmdConfigLooperInit (ecmdChipTarget & io_target, ecmdConfigLoopType_t i_looptype, ecmdLooperData& io_state) {

  uint32_t rc = ECMD_SUCCESS;
  ecmdChipTarget queryTarget;

#ifndef ECMD_STRIP_DEBUG
  if (ecmdClientDebug >= 8) {
    std::vector< void * > args;
    args.push_back((void*) &io_target);
    args.push_back((void*) &i_looptype);
    args.push_back((void*) &io_state);
    args.push_back((void*) &rc);

    ecmdFunctionParmPrinter(ECMD_FPP_FUNCTIONIN,"uint32_t ecmdConfigLooperInit (ecmdChipTarget & io_target, ecmdConfigLoopType_t i_looptype, ecmdLooperData& io_state)",args);
  }

#endif

  /* Are we using a unitid ? */
  if ((io_target.chipTypeState == ECMD_TARGET_QUERY_FIELD_VALID) && (io_target.chipType.length() > 0) && (io_target.chipType[0] == 'u')) {

    /* Ok, we need to strip the u off the front for this call */
    std::string unitid = io_target.chipType.substr(1);
    io_state.unitIdTargets.clear();
    rc = ecmdUnitIdStringToTarget(unitid, io_state.unitIdTargets);
    if (rc) return rc;
    io_state.ecmdUseUnitid = true;
    io_state.ecmdLooperInitFlag = true;
    io_state.prevTarget = io_target;
    io_state.curUnitIdTarget = io_state.unitIdTargets.begin();


    /* Ok, we still need to call queryconfig, we will use this to make sure the targets that come back actually exist */
    queryTarget.cageState = ECMD_TARGET_QUERY_WILDCARD;
    queryTarget.nodeState = ECMD_TARGET_QUERY_WILDCARD;
    queryTarget.slotState = ECMD_TARGET_QUERY_WILDCARD;
    queryTarget.chipTypeState = ECMD_TARGET_QUERY_WILDCARD;
    queryTarget.posState = ECMD_TARGET_QUERY_WILDCARD;
    queryTarget.coreState = ECMD_TARGET_QUERY_WILDCARD;
    queryTarget.threadState = ECMD_TARGET_QUERY_WILDCARD;

    rc = ecmdQueryConfig(queryTarget, io_state.ecmdSystemConfigData);
    if (rc) return rc;

    /* Standard physical targets */
  } else {

    queryTarget = io_target;


    /* Setup the Query target */
    if (queryTarget.cageState == ECMD_TARGET_FIELD_UNUSED)        queryTarget.cageState = ECMD_TARGET_QUERY_IGNORE;<commit_msg>Fixed problem where UseUnitid not set when not using it<commit_after>// Copyright **********************************************************
//                                                                      
// File ecmdDataBuffer.C                                               
//                                                                      
// IBM Confidential                                                     
// OCO Source Materials                                                 
// 9400 Licensed Internal Code                                          
// (C) COPYRIGHT IBM CORP. 2003
//                                                                      
// The source code for this program is not published or otherwise       
// divested of its trade secrets, irrespective of what has been         
// deposited with the U.S. Copyright Office.                             
//                                                                      
// End Copyright ******************************************************

/* $Header$ */

/**
 * @file ecmdUtils.C
 * @brief Useful functions for use throughout the ecmd C API
 *
 */

//--------------------------------------------------------------------
// Includes
//--------------------------------------------------------------------
#include <inttypes.h>
#include <string>
#include <vector>
#include <list>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>

#include <ecmdUtils.H>
#include <ecmdSharedUtils.H>
#include <ecmdClientCapi.H>
#include <ecmdReturnCodes.H>
//----------------------------------------------------------------------
//  Constants
//----------------------------------------------------------------------



typedef enum {
  ECMD_FORMAT_NONE,
  ECMD_FORMAT_X,
  ECMD_FORMAT_XR,
  ECMD_FORMAT_XW,
  ECMD_FORMAT_XRW,
  ECMD_FORMAT_B,
  ECMD_FORMAT_BN,
  ECMD_FORMAT_BW,
  ECMD_FORMAT_BX,
  ECMD_FORMAT_BXN,
  ECMD_FORMAT_BXW,
  ECMD_FORMAT_MEM,
  ECMD_FORMAT_MEMA,
  ECMD_FORMAT_MEMD,
  ECMD_FORMAT_MEME
} ecmdFormatState_t;


char frontFPPTxt[35];
int  fppCallCount;


//--------------------------------------------------------------------
// Macros
//--------------------------------------------------------------------

void ecmdIncrementLooperIterators (uint8_t level, ecmdLooperData& io_state);
std::string printEcmdChipTargetState_t(ecmdChipTargetState_t state);
/**
 @brief Print ecmdDataBuffer's for the EFPP
 @param i_data Databuffer to print
 @param i_tabStop Any additional spacing that should be done in display (ie "  \t")
*/
void printEcmdDataBuffer(std::string variableType, std::string variableName, ecmdDataBuffer & i_data, std::string i_tabStop);

//----------------------------------------------------------------------
//  Global Variables
//----------------------------------------------------------------------
#ifdef FIPSODE
tracDesc_t g_ptrc; /** Procedure Trace Descriptor **/
TRAC_INIT(&g_ptrc, "PTRC", 0x8000);
#endif

#ifndef ECMD_STRIP_DEBUG
/* This is from ecmdClientCapi.C */
extern int ecmdClientDebug;
#endif

//----------------------------------------------------------------------
//  User Types
//----------------------------------------------------------------------



uint32_t ecmdConfigLooperInit (ecmdChipTarget & io_target, ecmdConfigLoopType_t i_looptype, ecmdLooperData& io_state) {

  uint32_t rc = ECMD_SUCCESS;
  ecmdChipTarget queryTarget;

#ifndef ECMD_STRIP_DEBUG
  if (ecmdClientDebug >= 8) {
    std::vector< void * > args;
    args.push_back((void*) &io_target);
    args.push_back((void*) &i_looptype);
    args.push_back((void*) &io_state);
    args.push_back((void*) &rc);

    ecmdFunctionParmPrinter(ECMD_FPP_FUNCTIONIN,"uint32_t ecmdConfigLooperInit (ecmdChipTarget & io_target, ecmdConfigLoopType_t i_looptype, ecmdLooperData& io_state)",args);
  }

#endif

  /* Are we using a unitid ? */
  if ((io_target.chipTypeState == ECMD_TARGET_QUERY_FIELD_VALID) && (io_target.chipType.length() > 0) && (io_target.chipType[0] == 'u')) {

    /* Ok, we need to strip the u off the front for this call */
    std::string unitid = io_target.chipType.substr(1);
    io_state.unitIdTargets.clear();
    rc = ecmdUnitIdStringToTarget(unitid, io_state.unitIdTargets);
    if (rc == ECMD_INVALID_ARGS)
      ecmdOutputError("ecmdConfigLooperInit - Invalid Unitid specified\n");
    else if (rc == ECMD_FUNCTION_NOT_SUPPORTED)
      ecmdOutputError("ecmdConfigLooperInit - Current plugin doesn't support Unitid's\n");

    if (rc) return rc;
    io_state.ecmdUseUnitid = true;
    io_state.ecmdLooperInitFlag = true;
    io_state.prevTarget = io_target;
    io_state.curUnitIdTarget = io_state.unitIdTargets.begin();


    /* Ok, we still need to call queryconfig, we will use this to make sure the targets that come back actually exist */
    queryTarget.cageState = ECMD_TARGET_QUERY_WILDCARD;
    queryTarget.nodeState = ECMD_TARGET_QUERY_WILDCARD;
    queryTarget.slotState = ECMD_TARGET_QUERY_WILDCARD;
    queryTarget.chipTypeState = ECMD_TARGET_QUERY_WILDCARD;
    queryTarget.posState = ECMD_TARGET_QUERY_WILDCARD;
    queryTarget.coreState = ECMD_TARGET_QUERY_WILDCARD;
    queryTarget.threadState = ECMD_TARGET_QUERY_WILDCARD;

    rc = ecmdQueryConfig(queryTarget, io_state.ecmdSystemConfigData);
    if (rc) return rc;

    /* Standard physical targets */
  } else {


    io_state.ecmdUseUnitid = false;
    queryTarget = io_target;


    /* Setup the Query target */
    if (queryTarget.cageState == ECMD_TARGET_FIELD_UNUSED)        queryTarget.cageState = ECMD_TARGET_QUERY_IGNORE;
{'fraction_non_alphanumeric': 0.22811401073477697, 'fraction_numerical': 0.004812141402924301, 'mean_word_length': 1.7283514264074729, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1018281', 'n_tokens_mistral': 3092, 'n_tokens_neox': 2970, 'n_words': 657}