<commit_before>//IBM_PROLOG_BEGIN_TAG
/* 
 * Copyright 2003,2016 IBM International Business Machines Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
//IBM_PROLOG_END_TAG



//--------------------------------------------------------------------
// Includes
//--------------------------------------------------------------------
#include <inttypes.h>
#include <stdio.h>

#include <ecmdDllCapi.H>
#include <ecmdStructs.H>
#include <ecmdReturnCodes.H>
#include <ecmdDataBuffer.H>
#include <ecmdSharedUtils.H>

#include <FSIInstruction.H>
#include <OutputLite.H>
#include <Controller.H>

OutputLite out;
Controller * controller = NULL;
//--------------------------------------------------------------------
//  Forward References                                                
//--------------------------------------------------------------------

//--------------------------------------------------------------------
//  Function Definitions                                               
//--------------------------------------------------------------------
/* For use by dllQueryConfig and dllQueryExist */
uint32_t queryConfigExist(ecmdChipTarget & target, ecmdQueryData & queryData, ecmdQueryDetail_t detail, bool allowDisabled);

//--------------------------------------------------------------------
//  Function Definitions                                               
//--------------------------------------------------------------------
//
//   These are just stubs, used for testing the out the DLL

uint32_t dllInitDll() {
  // initialize controller
  controller = new Controller("127.0.0.1");
  uint32_t rc = controller->initialize();
  return rc;
}

uint32_t dllFreeDll() {
  // destroy controller
  if (controller != NULL)
  {
    delete controller;
  }
  controller = NULL;
  return ECMD_SUCCESS;
}

uint32_t dllSpecificCommandArgs(int* argc, char** argv[]) {
  return ECMD_SUCCESS;
}

/* Dll Specific Return Codes */
std::string dllSpecificParseReturnCode(uint32_t i_returnCode) { return ""; }

uint32_t dllGetScom(ecmdChipTarget & i_target, uint64_t i_address, ecmdDataBuffer & o_data)
{
    uint32_t rc = 0;
    FSIInstruction * scomoutInstruction = new FSIInstruction();
    uint32_t scomlen = 64;
    uint32_t flags = 0x0;

    std::string deviceString = "L02C0";

    scomoutInstruction->setup(Instruction::SCOMOUT, deviceString, i_address, scomlen, flags);
    InstructionStatus resultStatus;

    std::list<Instruction *> instructionList;
    std::list<ecmdDataBuffer *> dataList;
    std::list<InstructionStatus *> statusList;

    statusList.push_back(&resultStatus);
    dataList.push_back(&o_data);
    instructionList.push_back(scomoutInstruction);

    /* --------------------------------------------------- */
    /* Call the server interface with the Instruction and  */
    /* result objects.                                     */
    /* --------------------------------------------------- */
    rc = controller->transfer_send(instructionList, dataList, statusList);
    //uint32_t status = resultStatus.data.getWord(0);
    delete scomoutInstruction;

    if (resultStatus.rc != SERVER_COMMAND_COMPLETE) {
        controller->extractError(resultStatus);
        return out.error(resultStatus.rc, "dllGetScom","Problem calling interface: rc = %d for %s\n", resultStatus.rc, ecmdWriteTarget(i_target,ECMD_DISPLAY_TARGET_HYBRID).c_str());
    }

    return rc;
}

uint32_t dllPutScom(ecmdChipTarget & i_target, uint64_t i_address, ecmdDataBuffer & i_data)
{
    uint32_t rc = 0;
    FSIInstruction * scominInstruction = new FSIInstruction();
    uint32_t scomlen = 64;
    uint32_t flags = 0x0;

    std::string deviceString = "L02C0";

    scominInstruction->setup(Instruction::SCOMIN, deviceString, i_address, scomlen, flags, &i_data);
    InstructionStatus resultStatus;
    ecmdDataBuffer data;

    std::list<Instruction *> instructionList;
    std::list<ecmdDataBuffer *> dataList;
    std::list<InstructionStatus *> statusList;

    statusList.push_back(&resultStatus);
    dataList.push_back(&data);
    instructionList.push_back(scominInstruction);

    /* --------------------------------------------------- */
    /* Call the server interface with the Instruction and  */
    /* result objects.                                     */
    /* --------------------------------------------------- */
    rc = controller->transfer_send(instructionList, dataList, statusList);
    //uint32_t status = resultStatus.data.getWord(0);
    delete scominInstruction;

    if (resultStatus.rc != SERVER_COMMAND_COMPLETE) {
        controller->extractError(resultStatus);
        return out.error(resultStatus.rc, "dllPutScom","Problem calling interface: rc = %d for %s\n", resultStatus.rc, ecmdWriteTarget(i_target,ECMD_DISPLAY_TARGET_HYBRID).c_str());
    }

    return rc;
}

uint32_t dllPutScomUnderMask(ecmdChipTarget & i_target, uint64_t i_address, ecmdDataBuffer & i_data, ecmdDataBuffer & i_mask)
{
    uint32_t rc = 0;
    FSIInstruction * scominInstruction = new FSIInstruction();
    uint32_t scomlen = 64;
    uint32_t flags = 0x0;

    std::string deviceString = "L02C0";

    scominInstruction->setup(Instruction::SCOMIN_MASK, deviceString, i_address, scomlen, flags, &i_data, &i_mask);
    InstructionStatus resultStatus;
    ecmdDataBuffer data;

    std::list<Instruction *> instructionList;
    std::list<ecmdDataBuffer *> dataList;
    std::list<InstructionStatus *> statusList;
<commit_msg>update dllNetwork example for bmc device string<commit_after>//IBM_PROLOG_BEGIN_TAG
/* 
 * Copyright 2003,2016 IBM International Business Machines Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
//IBM_PROLOG_END_TAG



//--------------------------------------------------------------------
// Includes
//--------------------------------------------------------------------
#include <inttypes.h>
#include <stdio.h>

#include <ecmdDllCapi.H>
#include <ecmdStructs.H>
#include <ecmdReturnCodes.H>
#include <ecmdDataBuffer.H>
#include <ecmdSharedUtils.H>

#include <FSIInstruction.H>
#include <OutputLite.H>
#include <Controller.H>

OutputLite out;
Controller * controller = NULL;
//--------------------------------------------------------------------
//  Forward References                                                
//--------------------------------------------------------------------

//--------------------------------------------------------------------
//  Function Definitions                                               
//--------------------------------------------------------------------
/* For use by dllQueryConfig and dllQueryExist */
uint32_t queryConfigExist(ecmdChipTarget & target, ecmdQueryData & queryData, ecmdQueryDetail_t detail, bool allowDisabled);

//--------------------------------------------------------------------
//  Function Definitions                                               
//--------------------------------------------------------------------
//
//   These are just stubs, used for testing the out the DLL

uint32_t dllInitDll() {
  // initialize controller
  controller = new Controller("127.0.0.1");
  uint32_t rc = controller->initialize();
  return rc;
}

uint32_t dllFreeDll() {
  // destroy controller
  if (controller != NULL)
  {
    delete controller;
  }
  controller = NULL;
  return ECMD_SUCCESS;
}

uint32_t dllSpecificCommandArgs(int* argc, char** argv[]) {
  return ECMD_SUCCESS;
}

/* Dll Specific Return Codes */
std::string dllSpecificParseReturnCode(uint32_t i_returnCode) { return ""; }

uint32_t dllGetScom(ecmdChipTarget & i_target, uint64_t i_address, ecmdDataBuffer & o_data)
{
    uint32_t rc = 0;
    FSIInstruction * scomoutInstruction = new FSIInstruction();
    uint32_t scomlen = 64;
    uint32_t flags = 0x0;

    std::string deviceString = "1";

    scomoutInstruction->setup(Instruction::SCOMOUT, deviceString, i_address, scomlen, flags);
    InstructionStatus resultStatus;

    std::list<Instruction *> instructionList;
    std::list<ecmdDataBuffer *> dataList;
    std::list<InstructionStatus *> statusList;

    statusList.push_back(&resultStatus);
    dataList.push_back(&o_data);
    instructionList.push_back(scomoutInstruction);

    /* --------------------------------------------------- */
    /* Call the server interface with the Instruction and  */
    /* result objects.                                     */
    /* --------------------------------------------------- */
    rc = controller->transfer_send(instructionList, dataList, statusList);
    //uint32_t status = resultStatus.data.getWord(0);
    delete scomoutInstruction;

    if (resultStatus.rc != SERVER_COMMAND_COMPLETE) {
        controller->extractError(resultStatus);
        return out.error(resultStatus.rc, "dllGetScom","Problem calling interface: rc = %d for %s\n", resultStatus.rc, ecmdWriteTarget(i_target,ECMD_DISPLAY_TARGET_HYBRID).c_str());
    }

    return rc;
}

uint32_t dllPutScom(ecmdChipTarget & i_target, uint64_t i_address, ecmdDataBuffer & i_data)
{
    uint32_t rc = 0;
    FSIInstruction * scominInstruction = new FSIInstruction();
    uint32_t scomlen = 64;
    uint32_t flags = 0x0;

    std::string deviceString = "1";

    scominInstruction->setup(Instruction::SCOMIN, deviceString, i_address, scomlen, flags, &i_data);
    InstructionStatus resultStatus;
    ecmdDataBuffer data;

    std::list<Instruction *> instructionList;
    std::list<ecmdDataBuffer *> dataList;
    std::list<InstructionStatus *> statusList;

    statusList.push_back(&resultStatus);
    dataList.push_back(&data);
    instructionList.push_back(scominInstruction);

    /* --------------------------------------------------- */
    /* Call the server interface with the Instruction and  */
    /* result objects.                                     */
    /* --------------------------------------------------- */
    rc = controller->transfer_send(instructionList, dataList, statusList);
    //uint32_t status = resultStatus.data.getWord(0);
    delete scominInstruction;

    if (resultStatus.rc != SERVER_COMMAND_COMPLETE) {
        controller->extractError(resultStatus);
        return out.error(resultStatus.rc, "dllPutScom","Problem calling interface: rc = %d for %s\n", resultStatus.rc, ecmdWriteTarget(i_target,ECMD_DISPLAY_TARGET_HYBRID).c_str());
    }

    return rc;
}

uint32_t dllPutScomUnderMask(ecmdChipTarget & i_target, uint64_t i_address, ecmdDataBuffer & i_data, ecmdDataBuffer & i_mask)
{
    uint32_t rc = 0;
    FSIInstruction * scominInstruction = new FSIInstruction();
    uint32_t scomlen = 64;
    uint32_t flags = 0x0;

    std::string deviceString = "1";

    scominInstruction->setup(Instruction::SCOMIN_MASK, deviceString, i_address, scomlen, flags, &i_data, &i_mask);
    InstructionStatus resultStatus;
    ecmdDataBuffer data;

    std::list<Instruction *> instructionList;
    std::list<ecmdDataBuffer *> dataList;
    std::list<InstructionStatus *> statusList;

{'fraction_non_alphanumeric': 0.2163067135442826, 'fraction_numerical': 0.014565544952285283, 'mean_word_length': 2.083096774193548, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7219284', 'n_tokens_mistral': 3390, 'n_tokens_neox': 3266, 'n_words': 766}