diff --git a/src/utilities/common/cmd_util.cpp b/src/utilities/common/cmd_util.cpp index 81bc4c60fd..be3626be5f 100644 --- a/src/utilities/common/cmd_util.cpp +++ b/src/utilities/common/cmd_util.cpp @@ -28,6 +28,7 @@ #include "../jrd/gds_proto.h" #include "../jrd/msg_encode.h" #include "../jrd/iberr.h" +#include "../jrd/err_proto.h" #ifndef INCLUDE_FB_BLK #include "../include/fb_blk.h" @@ -75,7 +76,7 @@ void CMD_UTIL_put_svc_status(ISC_STATUS* svc_status, // Don't want to overflow the status vector. for (unsigned int loop = 0; loop < 5 && loop < arg.getCount(); ++loop) { - SVC_STATUS_ARG(status, arg.getCell(loop)); + CMD_UTIL_put_status_arg(status, arg.getCell(loop)); tmp_status_len += 2; } @@ -146,3 +147,41 @@ void CMD_UTIL_put_svc_status(ISC_STATUS* svc_status, } } + +void CMD_UTIL_put_status_arg(ISC_STATUS*& status, const MsgFormat::safe_cell& value) +{ + using MsgFormat::safe_cell; + + switch (value.type) + { + case safe_cell::at_int64: + case safe_cell::at_uint64: + *status++ = isc_arg_number; + *status++ = static_cast(value.i_value); // May truncate number! + break; + case safe_cell::at_str: + { + *status++ = isc_arg_string; + const char* s = value.st_value.s_string; + *status++ = (ISC_STATUS) ERR_cstring(s); + } + break; + case safe_cell::at_counted_str: + { + *status++ = isc_arg_string; + const char* s = value.st_value.s_string; + *status++ = (ISC_STATUS) ERR_string(s, value.st_value.s_len); + } + break; + + default: + break; + } +} + + +void CMD_UTIL_put_status_arg(ISC_STATUS*& status, const char* value) +{ + *status++ = isc_arg_string; + *status++ = (ISC_STATUS) ERR_cstring(value); +} diff --git a/src/utilities/common/cmd_util_proto.h b/src/utilities/common/cmd_util_proto.h index 465beb16e6..38b9766659 100644 --- a/src/utilities/common/cmd_util_proto.h +++ b/src/utilities/common/cmd_util_proto.h @@ -31,5 +31,8 @@ void CMD_UTIL_put_svc_status(ISC_STATUS* svc_status, USHORT errcode, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); +void CMD_UTIL_put_status_arg(ISC_STATUS*& status, const MsgFormat::safe_cell& value); +void CMD_UTIL_put_status_arg(ISC_STATUS*& status, const char* value); + #endif // UTILITIES_CMD_UTIL_PROTO_H