Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0f4bc21
JSON Schema Updates (see PR for details)
ElijahSwiftIBM Jul 8, 2026
a944713
Merge branch 'dev' into feat/json-schema
ElijahSwiftIBM Oct 23, 2026
98b403c
Testing Resolving Merge Conflict?
ElijahSwiftIBM Oct 23, 2026
3619110
Testing Resolving Merge Conflict 2
ElijahSwiftIBM Oct 23, 2026
d0f4ecc
Testing Resolving Merge Conflict 3
ElijahSwiftIBM Oct 23, 2026
63655c9
Post code review tweaks 1
ElijahSwiftIBM Nov 2, 2026
cd9dddc
Post code review tweaks 1.1
ElijahSwiftIBM Nov 2, 2026
677938f
Post code review tweaks 2 - SPI only
ElijahSwiftIBM Nov 2, 2026
2974506
Post code review tweaks 2.1 - SPI only
ElijahSwiftIBM Nov 2, 2026
9a9e8c4
Post code review tweaks 2.2 - SPI only
ElijahSwiftIBM Nov 2, 2026
ebf06a3
Post code review tweaks 3 - logging and naming
ElijahSwiftIBM Nov 3, 2026
e8f0e8b
Post code review tweaks 3.1 - logging and naming
ElijahSwiftIBM Nov 3, 2026
fe703ae
Post code review tweaks 3.2 - logging and naming
ElijahSwiftIBM Nov 3, 2026
21a7752
Post code review tweaks 4 - Abend Handling
ElijahSwiftIBM Nov 3, 2026
c6bb6f5
Change schema name
ElijahSwiftIBM Nov 6, 2026
e0030bb
Address Util
ElijahSwiftIBM Nov 6, 2026
4a3717e
Error restructure
ElijahSwiftIBM Nov 6, 2026
88fa419
Error restructure 1
ElijahSwiftIBM Nov 6, 2026
76783dc
Error restructure 2
ElijahSwiftIBM Nov 6, 2026
dbe3a3d
Error restructure 3
ElijahSwiftIBM Nov 6, 2026
7801678
Error restructure 4
ElijahSwiftIBM Nov 6, 2026
643ec66
Error restructure 5
ElijahSwiftIBM Nov 6, 2026
35c2dfd
Error restructure 6
ElijahSwiftIBM Nov 6, 2026
94331ca
Error restructure 7
ElijahSwiftIBM Nov 6, 2026
f87e78a
Error restructure 8
ElijahSwiftIBM Nov 6, 2026
dc3c781
Error restructure 9
ElijahSwiftIBM Nov 6, 2026
0a11b9a
Contribution Guidelines
ElijahSwiftIBM Nov 6, 2026
8549bb8
Repo Reorg
ElijahSwiftIBM Nov 6, 2026
5b9ef2b
Test Fixture Rearchitect (python)
ElijahSwiftIBM Nov 6, 2026
7866e81
Test Fixture Rearchitect (python) 1
ElijahSwiftIBM Nov 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ artifacts
dist
cbxp-*
*egg-info/
cbxp/mappings/*.hpp
cbxp/schemas/*.hpp
*.DS_Store
*.txt

# CMake
CMakeLists.txt.user
Expand All @@ -50,6 +54,7 @@ compile_commands.json
CTestTestfile.cmake
_deps
CMakeUserPresets.json
DartConfiguration.tcl

# Virtual Environment
env/
62 changes: 60 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ file(
GLOB CBXP_SRC_LIB
"cbxp/*.cpp"
"cbxp/control_blocks/*.cpp"
"cbxp/traversal/*.cpp"
"cbxp/util/*.cpp"
"externals/json-schema-validator/*.cpp"
)

file(
Expand All @@ -63,18 +66,73 @@ file(
# ============================================================================
# Build '/lib/libcbxp.a'
# ============================================================================
# ============================================================================
# Generate schema header from cbxp/schemas/control_block.json
# ============================================================================
set(CBXP_SCHEMAS_GENERATED_DIR "${CMAKE_BINARY_DIR}/cbxp/schemas")
file(MAKE_DIRECTORY "${CBXP_SCHEMAS_GENERATED_DIR}")

file(READ "${CMAKE_CURRENT_SOURCE_DIR}/cbxp/schemas/control_block.json" CBXP_SCHEMA_JSON)

file(WRITE "${CBXP_SCHEMAS_GENERATED_DIR}/control_block.hpp"
"#ifndef CBXP_SCHEMA_CONTROL_BLOCK_V1_JSON_HPP\n\
#define CBXP_SCHEMA_CONTROL_BLOCK_V1_JSON_HPP\n\
\n\
#define CBXP_SCHEMA_JSON R\"JSON(${CBXP_SCHEMA_JSON})JSON\"\n\
\n\
#endif // CBXP_SCHEMA_CONTROL_BLOCK_V1_JSON_HPP\n"
)

# ============================================================================
# Generate mapping headers from JSON files in cbxp/mappings/
# ============================================================================
set(CBXP_MAPPINGS_GENERATED_DIR "${CMAKE_BINARY_DIR}/cbxp/mappings")
file(MAKE_DIRECTORY "${CBXP_MAPPINGS_GENERATED_DIR}")

file(GLOB CBXP_MAPPING_JSON_FILES "${CMAKE_CURRENT_SOURCE_DIR}/cbxp/mappings/*.json")

set(CBXP_MAPPING_FORCED_INCLUDES "")

foreach(MAPPING_JSON_FILE ${CBXP_MAPPING_JSON_FILES})
get_filename_component(MAPPING_NAME "${MAPPING_JSON_FILE}" NAME_WE)
string(TOUPPER "${MAPPING_NAME}" MAPPING_NAME_UPPER)

file(READ "${MAPPING_JSON_FILE}" MAPPING_JSON)

set(MAPPING_GUARD "${MAPPING_NAME_UPPER}_JSON_HPP")
set(MAPPING_MACRO "${MAPPING_NAME_UPPER}_JSON")
set(MAPPING_HEADER_PATH "${CBXP_MAPPINGS_GENERATED_DIR}/${MAPPING_NAME}.hpp")

file(WRITE "${MAPPING_HEADER_PATH}"
"#ifndef ${MAPPING_GUARD}\n\
#define ${MAPPING_GUARD}\n\
\n\
#define ${MAPPING_MACRO} R\"JSON(${MAPPING_JSON})JSON\"\n\
\n\
#endif // ${MAPPING_GUARD}\n"
)

list(APPEND CBXP_MAPPING_FORCED_INCLUDES "--include=${MAPPING_HEADER_PATH}")
endforeach()

add_library(libcbxp STATIC ${CBXP_SRC_LIB})
set_target_properties(libcbxp PROPERTIES OUTPUT_NAME "cbxp")

target_include_directories(
libcbxp PUBLIC
cbxp
cbxp/control_blocks
externals
externals/json
externals/json-schema-validator
/usr/include/zos
)

target_compile_options(libcbxp PUBLIC ${COMPILE_OPTIONS})
target_compile_options(
libcbxp PUBLIC
${COMPILE_OPTIONS}
"--include=${CBXP_SCHEMAS_GENERATED_DIR}/control_block_v1.hpp"
${CBXP_MAPPING_FORCED_INCLUDES}
)
target_link_options(libcbxp PUBLIC ${LINK_OPTIONS})

# ============================================================================
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ If you fix a bug, open a GitHub pull request against the `dev` branch with the f

### Testing

CBXP is tested using automated functional tests. Test cases for new functionality and bug fixes should be added to [`tests/test.py`](tests/test.py) and [`tests/test.sh`](tests/test.sh).
CBXP is tested using automated functional tests. Test cases for new functionality and bug fixes should be added to [`tests/test.py`](tests/test.py) and [`tests/CMakeLists.txt`](tests/CMakeLists.txt).

#### Python Interface Testing
1. Add new test cases to [`tests/test.py`](tests/test.py).
Expand All @@ -98,7 +98,7 @@ CBXP is tested using automated functional tests. Test cases for new functionalit
```

#### CLI Interface Testing
1. Add new tests cases to [`tests/test.sh`](tests/test.sh).
1. Add new test cases to [`tests/CMakeLists.txt`](tests/CMakeLists.txt) or as a shared fixture under `tests/fixtures/cbxppath/`.
2. Run the test suite using `cmake` and `gmake`.

```shell
Expand Down
41 changes: 24 additions & 17 deletions cbxp/cbxp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#include <nlohmann/json.hpp>

#include "control_block_explorer.hpp"
#include "logger.hpp"
#include "util/control_block_error.hpp"
#include "util/logger.hpp"

cbxp_result_t* cbxp_extract(const char* control_block_name,
const size_t control_block_name_length,
Expand Down Expand Up @@ -31,11 +32,14 @@ cbxp_result_t* cbxp_extract(const char* control_block_name,
CBXP::Logger::getInstance().debugAllocate(p_cbxp_result, 64,
sizeof(cbxp_result_t));

CBXP::ControlBlockExplorer explorer =
CBXP::ControlBlockExplorer(p_cbxp_result);

explorer.extractControlBlock(control_block_name_string,
includes_string_string, filters_string_string);
try {
CBXP::ControlBlockExplorer explorer =
CBXP::ControlBlockExplorer(p_cbxp_result);
explorer.extractControlBlock(control_block_name_string,
includes_string_string, filters_string_string);
} catch (const CBXP::CBXPError& e) {
p_cbxp_result->return_code = e.getErrorCode();
}

return p_cbxp_result;
}
Expand All @@ -57,23 +61,26 @@ cbxp_result_t* cbxp_format(const char* control_block_name,
CBXP::Logger::getInstance().debugAllocate(p_cbxp_result, 64,
sizeof(cbxp_result_t));

CBXP::ControlBlockExplorer explorer =
CBXP::ControlBlockExplorer(p_cbxp_result);

explorer.formatControlBlock(control_block_name_string, data, data_length);
try {
CBXP::ControlBlockExplorer explorer =
CBXP::ControlBlockExplorer(p_cbxp_result);
explorer.formatControlBlock(control_block_name_string, data, data_length);
} catch (const CBXP::CBXPError& e) {
p_cbxp_result->return_code = e.getErrorCode();
}

return p_cbxp_result;
}

void cbxp_free(cbxp_result_t* cbxp_result, bool debug) {
void cbxp_free(cbxp_result_t* p_cbxp_result, bool debug) {
CBXP::Logger::getInstance().setDebug(debug);

if (cbxp_result != nullptr) {
if (cbxp_result->result_json != nullptr) {
CBXP::Logger::getInstance().debugFree(cbxp_result->result_json);
delete cbxp_result->result_json;
if (p_cbxp_result != nullptr) {
if (p_cbxp_result->result_json != nullptr) {
CBXP::Logger::getInstance().debugFree(p_cbxp_result->result_json);
delete p_cbxp_result->result_json;
}
CBXP::Logger::getInstance().debugFree(cbxp_result);
delete cbxp_result;
CBXP::Logger::getInstance().debugFree(p_cbxp_result);
delete p_cbxp_result;
}
}
2 changes: 1 addition & 1 deletion cbxp/cbxp.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ cbxp_result_t* cbxp_format(const char* control_block_name,
const void* data, const size_t data_length,
bool debug);

void cbxp_free(cbxp_result_t* cbxp_result, bool debug);
void cbxp_free(cbxp_result_t* p_cbxp_result, bool debug);

#ifdef __cplusplus
}
Expand Down
17 changes: 17 additions & 0 deletions cbxp/cbxp_types.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef __CBXP_TYPES_H_
#define __CBXP_TYPES_H_

#include <string>
#include <vector>

namespace CBXP {

typedef struct {
std::vector<std::string> include_patterns;
std::vector<std::string> filters;
bool skip_buffer_length_check;
} cbxp_options_t;

} // namespace CBXP

#endif
32 changes: 24 additions & 8 deletions cbxp/cli/command_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <iostream>

#include "cbxp.h"
#include "control_block_error.hpp"
#include "util/control_block_error.hpp"

namespace CBXP {

Expand Down Expand Up @@ -409,30 +409,30 @@ bool CommandProcessor::checkForComma(const std::string& string) {
}

void CommandProcessor::run() {
cbxp_result_t* cbxp_result;
cbxp_result_t* p_cbxp_result;

if (command_ == "extract") {
cbxp_result = cbxp_extract(
p_cbxp_result = cbxp_extract(
control_block_name_.c_str(), control_block_name_.length(),
extract_options_.include.c_str(), extract_options_.include.length(),
extract_options_.filter.c_str(), extract_options_.filter.length(),
global_options_.debug);
} else {
cbxp_result =
p_cbxp_result =
cbxp_format(control_block_name_.c_str(), control_block_name_.length(),
static_cast<void*>(format_options_.data_buffer.data() +
format_options_.offset),
format_options_.data_buffer.size() - format_options_.offset,
global_options_.debug);
}

unsigned int return_code = cbxp_result->return_code;
unsigned int return_code = p_cbxp_result->return_code;

if (return_code == 0) {
std::cout << cbxp_result->result_json << std::endl;
std::cout << p_cbxp_result->result_json << std::endl;
}

cbxp_free(cbxp_result, global_options_.debug);
cbxp_free(p_cbxp_result, global_options_.debug);

switch (return_code) {
case 0:
Expand All @@ -450,8 +450,24 @@ void CommandProcessor::run() {
case CBXP::Error::DataTooSmall:
std::cerr << ERROR_DATA_TOO_SMALL_ << control_block_name_ << std::endl;
throw CLIExitFailure();
case CBXP::Error::BadCbxpPath:
std::cerr << ERROR_BAD_CBXP_ENV_PATH_ << std::endl;
throw CLIExitFailure();
case CBXP::Error::BlockUnreachable:
std::cerr << ERROR_CANT_REACH_BLOCK_ << std::endl;
throw CLIExitFailure();
case CBXP::Error::JsonFailParse:
std::cerr << ERROR_PARSE_JSON_FILE_ << std::endl;
throw CLIExitFailure();
case CBXP::Error::JsonFailSchema:
std::cerr << ERROR_VALIDATE_JSON_FILE_ << std::endl;
throw CLIExitFailure();
case CBXP::Error::JsonBadValue:
std::cerr << ERROR_JSON_FILE_VALUES_ << std::endl;
throw CLIExitFailure();
default:
std::cerr << ERROR_UNKNOWN_ERROR_ << control_block_name_ << std::endl;
std::cerr << ERROR_UNKNOWN_ERROR_ << " " << control_block_name_
<< std::endl;
throw CLIExitFailure();
}
throw CLIExitSuccess();
Expand Down
7 changes: 7 additions & 0 deletions cbxp/cli/command_processor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ class CommandProcessor {
const std::string ERROR_CONTROL_BLOCK_EXPECTED_ =
"Positional argument <control block> expected";
const std::string ERROR_UNKNOWN_ERROR_ = "An unknown error occurred";
const std::string ERROR_BAD_CBXP_ENV_PATH_ =
"Error with your CBXPPATH environment variable";
const std::string ERROR_CANT_REACH_BLOCK_ = "Cannot reach control block";
const std::string ERROR_PARSE_JSON_FILE_ = "Could not parse a JSON file";
const std::string ERROR_VALIDATE_JSON_FILE_ =
"Could not validate a JSON file";
const std::string ERROR_JSON_FILE_VALUES_ = "Could not load a JSON file";
// Format
const std::string ERROR_OFFSET_MUST_BE_A_POSITIVE_INTEGER_ =
"Offset must be a positive integer";
Expand Down
44 changes: 0 additions & 44 deletions cbxp/control_block_error.hpp

This file was deleted.

Loading
Loading