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

/* 15. CM_MASK - 카드번호 마스킹 (순수 계산): 앞6 뒤4 노출. */
void CM_MASK(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char pan[32], out[32];
    int n, i;
    gets_(b, T_STR5, pan, sizeof(pan));
    n = (int)strlen(pan);
    for (i = 0; i < n && i < (int)sizeof(out) - 1; i++)
        out[i] = (i < 6 || i >= n - 4) ? pan[i] : '*';
    out[(n < (int)sizeof(out)-1) ? n : (int)sizeof(out)-1] = 0;
    sets_(b, T_STR4, out);
    OK(b);
}
