/*
 * MG_NACK.pgc - mg 모듈 서비스 MG_NACK (one service = one file).
 * Split out of the former inline mg_svr.pgc; runs on the caller's XA
 * branch (no EXEC SQL CONNECT). Advertised by mg_svr at tpsvrinit.
 */
#include "MG_NACK.h"

/* 14. MG_NACK - 부정 응답 (status=N, rc=입력). */
void MG_NACK(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char rc[4];
    long msg_id = getl(b, T_ID1), rcnum = getl(b, T_RC);
    if (rcnum <= 0) rcnum = 91;
    sprintf(rc, "%02ld", rcnum % 100);
    if (mgdb_update_msg_rc(msg_id, rc, "N") < 0) FAIL(b);
    sets_(b, T_STATUS, "N");
    OK(b);
}
