#pragma once /** * @brief Cartallum CBE logging utilities */ #include #include #include #ifdef __cplusplus extern "C" { #endif /** * Prints a string to stdout */ /* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/sbf/c/inc/cbe/inc/log.inc AND RUN `cargo run --bin gen-headers` */ #ifndef CBE_SBFV2 void cbe_log_(const char *, uint64_t); #else typedef void(*cbe_log__pointer_type)(const char *, uint64_t); static void cbe_log_(const char * arg1, uint64_t arg2) { cbe_log__pointer_type cbe_log__pointer = (cbe_log__pointer_type) 544561597; cbe_log__pointer(arg1, arg2); } #endif #define cbe_log(message) cbe_log_(message, cbe_strlen(message)) /** * Prints a 64 bit values represented in hexadecimal to stdout */ /* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/sbf/c/inc/cbe/inc/log.inc AND RUN `cargo run --bin gen-headers` */ #ifndef CBE_SBFV2 void cbe_log_64_(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t); #else typedef void(*cbe_log_64__pointer_type)(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t); static void cbe_log_64_(uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5) { cbe_log_64__pointer_type cbe_log_64__pointer = (cbe_log_64__pointer_type) 1546269048; cbe_log_64__pointer(arg1, arg2, arg3, arg4, arg5); } #endif #define cbe_log_64 cbe_log_64_ /** * Prints the current compute unit consumption to stdout */ /* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/sbf/c/inc/cbe/inc/log.inc AND RUN `cargo run --bin gen-headers` */ #ifndef CBE_SBFV2 void cbe_log_compute_units_(); #else typedef void(*cbe_log_compute_units__pointer_type)(); static void cbe_log_compute_units_() { cbe_log_compute_units__pointer_type cbe_log_compute_units__pointer = (cbe_log_compute_units__pointer_type) 1387942038; cbe_log_compute_units__pointer(); } #endif #define cbe_log_compute_units() cbe_log_compute_units_() /** * Prints the hexadecimal representation of an array * * @param array The array to print */ static void cbe_log_array(const uint8_t *array, int len) { for (int j = 0; j < len; j++) { cbe_log_64(0, 0, 0, j, array[j]); } } /** * Print the base64 representation of some arrays. */ /* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/sbf/c/inc/cbe/inc/log.inc AND RUN `cargo run --bin gen-headers` */ #ifndef CBE_SBFV2 void cbe_log_data(CBEBytes *, uint64_t); #else typedef void(*cbe_log_data_pointer_type)(CBEBytes *, uint64_t); static void cbe_log_data(CBEBytes * arg1, uint64_t arg2) { cbe_log_data_pointer_type cbe_log_data_pointer = (cbe_log_data_pointer_type) 1930933300; cbe_log_data_pointer(arg1, arg2); } #endif /** * Prints the program's input parameters * * @param params Pointer to a CBEParameters structure */ static void cbe_log_params(const CBEParameters *params) { cbe_log("- Program identifier:"); cbe_log_pubkey(params->program_id); cbe_log("- Number of KeyedAccounts"); cbe_log_64(0, 0, 0, 0, params->ka_num); for (int i = 0; i < params->ka_num; i++) { cbe_log(" - Is signer"); cbe_log_64(0, 0, 0, 0, params->ka[i].is_signer); cbe_log(" - Is writable"); cbe_log_64(0, 0, 0, 0, params->ka[i].is_writable); cbe_log(" - Key"); cbe_log_pubkey(params->ka[i].key); cbe_log(" - Scoobies"); cbe_log_64(0, 0, 0, 0, *params->ka[i].scoobies); cbe_log(" - data"); cbe_log_array(params->ka[i].data, params->ka[i].data_len); cbe_log(" - Owner"); cbe_log_pubkey(params->ka[i].owner); cbe_log(" - Executable"); cbe_log_64(0, 0, 0, 0, params->ka[i].executable); cbe_log(" - Rent Epoch"); cbe_log_64(0, 0, 0, 0, params->ka[i].rent_epoch); } cbe_log("- Instruction data\0"); cbe_log_array(params->data, params->data_len); } #ifdef CBE_TEST /** * Stub functions when building tests */ #include void cbe_log_(const char *s, uint64_t len) { printf("Program log: %s\n", s); } void cbe_log_64(uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5) { printf("Program log: %llu, %llu, %llu, %llu, %llu\n", arg1, arg2, arg3, arg4, arg5); } void cbe_log_compute_units_() { printf("Program consumption: __ units remaining\n"); } #endif #ifdef __cplusplus } #endif /**@}*/