/*
 * AUTH_ROUTE.pgc - au 모듈 서비스 AUTH_ROUTE (one service = one file).
 * 승인 라우팅(발급사 BIN 기준 라우팅 코드 산출).
 * Moved verbatim from the former inline au_svr.pgc; runs on the caller's XA
 * branch (no EXEC SQL CONNECT). Advertised by au_svr at tpsvrinit.
 */
#include "AUTH_ROUTE.h"

void AUTH_ROUTE(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char card[24], route[8];
    long bin;
    gets_(b, T_KEY1, card, sizeof(card));
    bin = atol(card) / 1000000000L;    /* 앞 6자리 근사 BIN */
    if (card[0] == '4') strcpy(route, "VISA");
    else if (card[0] == '5') strcpy(route, "MC");
    else if (card[0] == '3') strcpy(route, "AMEX");
    else strcpy(route, "LOCAL");
    Bchg(b, T_STR1, 0, route, 0L);
    setl(b, T_ARG1, bin);
    OK(b);
}
