- 템플릿 클론(정규화 후 0줄 상이) → 전 코퍼스 530/530 고유 바디 - 11개 모듈(mg/au/ac/rc/vl/st/py/lg/mm/cm/cl) 각 파일이 distinct한 매입·대사·정산·수수료·지급·원장·마감·마스터·정합성·전문게이트웨이·공통 업무 - TxCore(ATMI 유사) + ECPG(EXEC SQL) 관용구, 프레임워크/헤더/DBIO API/파일ID·경로 유지 - 전체 docker make -j4 = EXIT 0, 958 오브젝트, 데모 바이너리 링크 - inventory.json loc 실측 갱신 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
79 lines
2.9 KiB
Text
79 lines
2.9 KiB
Text
/* @tier easy @module mg @transform msg-gateway-online */
|
|
/*
|
|
* mg_ol_0007.pgc - 오류전문 생성 서비스 (MG_OL_0007) [tier=easy]
|
|
*
|
|
* 원전문(RAWMSG)과 오류코드(ERRCODE)를 받아 응답전문(0210)의 오류회신을
|
|
* 구성한다. 원전문 식별필드는 그대로 보존하고 전문종별을 0210 으로 바꾼 뒤
|
|
* resp_code 에 오류코드를 세팅하여 msg_pack 후 RAWMSG 로 반환한다.
|
|
*/
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "txcore.h"
|
|
#include "acq_util.h"
|
|
#include "mg_core.h"
|
|
|
|
EXEC SQL INCLUDE sqlca;
|
|
|
|
TX_SERVICE(MG_OL_0007, ctx)
|
|
{
|
|
char raw[MSG_ACQ_LEN + 8];
|
|
char out[MSG_ACQ_LEN + 8];
|
|
char errcode[8];
|
|
int rawlen;
|
|
acq_msg_t msg;
|
|
|
|
tx_log(TX_LOG_INFO, "[MG_OL_0007] 오류전문 생성 서비스 진입");
|
|
|
|
/* 1) 원전문 + 오류코드 수신 */
|
|
rawlen = tx_buf_get(ctx->in, "RAWMSG", raw, sizeof(raw));
|
|
if (rawlen != TX_OK) {
|
|
tx_log(TX_LOG_ERROR, "[MG_OL_0007] 원전문(RAWMSG) 누락 rc=%d", rawlen);
|
|
tx_return(ctx, TX_EINVAL, ctx->out);
|
|
return;
|
|
}
|
|
if (tx_buf_get(ctx->in, "ERRCODE", errcode, sizeof(errcode)) != TX_OK ||
|
|
errcode[0] == '\0') {
|
|
/* 오류코드 미지정 시 시스템오류로 간주 */
|
|
strncpy(errcode, RESP_SYSERR, sizeof(errcode) - 1);
|
|
errcode[sizeof(errcode) - 1] = '\0';
|
|
}
|
|
|
|
/* 2) 오류코드 4자리 정규화 (부족분 zero-fill, 초과분 절단) */
|
|
if ((int)strlen(errcode) != FLD_RESP_LEN) {
|
|
char norm[FLD_RESP_LEN + 1];
|
|
msg_field_set_num(norm, errcode, FLD_RESP_LEN);
|
|
norm[FLD_RESP_LEN] = '\0';
|
|
strncpy(errcode, norm, sizeof(errcode) - 1);
|
|
errcode[sizeof(errcode) - 1] = '\0';
|
|
}
|
|
|
|
/* 3) 원전문 언팩 (식별필드 보존 목적) */
|
|
memset(&msg, 0, sizeof(msg));
|
|
if (msg_unpack(&msg, raw, MSG_ACQ_LEN) != 0) {
|
|
tx_log(TX_LOG_ERROR, "[MG_OL_0007] 원전문 언팩 실패");
|
|
tx_return(ctx, TX_EINVAL, ctx->out);
|
|
return;
|
|
}
|
|
|
|
/* 4) 오류응답으로 변환: 종별 0210, 응답코드 세팅, 금액 영처리 */
|
|
msg_field_set(msg.msg_type, MSG_TYPE_RESP, FLD_MSG_TYPE_LEN);
|
|
memcpy(msg.resp_code, errcode, FLD_RESP_LEN);
|
|
msg_field_set_num(msg.amount, "0", FLD_AMOUNT_LEN);
|
|
msg_field_set(msg.filler, "ERR", sizeof(msg.filler));
|
|
|
|
/* 5) 팩 후 오류 RAWMSG 반환 */
|
|
if (msg_pack(&msg, out, MSG_ACQ_LEN) != 0) {
|
|
tx_log(TX_LOG_ERROR, "[MG_OL_0007] 오류전문 팩 실패");
|
|
tx_return(ctx, TX_FAIL, ctx->out);
|
|
return;
|
|
}
|
|
|
|
tx_buf_reset(ctx->out);
|
|
tx_buf_set(ctx->out, "RAWMSG", out, MSG_ACQ_LEN);
|
|
tx_buf_setlong(ctx->out, "RAWLEN", (long)MSG_ACQ_LEN);
|
|
tx_buf_sets(ctx->out, "MSGTYPE", MSG_TYPE_RESP);
|
|
tx_buf_set(ctx->out, "RESPCODE", errcode, FLD_RESP_LEN);
|
|
tx_log(TX_LOG_INFO, "[MG_OL_0007] 오류전문 생성완료 respcode=%.4s", errcode);
|
|
tx_return(ctx, TX_OK, ctx->out);
|
|
}
|