This repository has been archived on 2026-07-19. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
acquire-core-full/app/online/mg_ol_0011.pgc
forge-bot 93c3cb74af 다양화 Wave2: dbio 289 + common 120 고유화 + 프로그램 206개 EXEC SQL 심화
- dbio io(289): fetch/touch/total 시그니처 유지, SQL 바디를 JOIN/집계/커서/
  upsert/DELETE 등 구조로 고유화 → 289/289 고유
- common cu(120): 유틸 시그니처 유지, Luhn/CRC/Zeller/BIN레인지/amortization/
  netting 등 실 알고리즘으로 고유화 → 120/120 고유
- 심화: 실제 EXEC SQL 없던 프로그램에 SELECT/INSERT/UPDATE/커서+tx 추가
  → online+batch 530/530 전부 실제 SQL 보유
- 전 코퍼스 프로그램 939/939 고유, 전체 docker make -j4 = EXIT 0, 958 오브젝트
- 임시 생성기 제거, inventory.json loc 실측 갱신

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-19 04:54:59 +00:00

100 lines
3.2 KiB
Text

/* @tier medium @module mg @transform msg-gateway-online */
/*
* mg_ol_0011.pgc - ISO8583식 필드 파싱 서비스 (MG_OL_0011) [tier=medium]
*
* 요청의 primary bitmap(16 hex 문자 = 64bit)을 파싱하여 present 필드
* 번호 목록을 추출하고, 비트온 개수/이차비트맵 사용여부를 응답한다.
*/
#include <stdio.h>
#include <string.h>
#include "txcore.h"
#include "txcore_dbio.h"
#include "acq_util.h"
#include "mg_core.h"
EXEC SQL INCLUDE sqlca;
TX_SERVICE(MG_OL_0011, ctx)
{
char bitmap[24];
char present[160];
char hexbuf[8];
int i, nib, bit, fieldno, cnt = 0;
int secondary = 0;
tx_log(TX_LOG_INFO, "[MG_OL_0011] ISO8583 비트맵 파싱 진입");
if (tx_buf_get(ctx->in, "BITMAP", bitmap, sizeof(bitmap)) != TX_OK) {
tx_log(TX_LOG_ERROR, "[MG_OL_0011] BITMAP 누락");
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
if (strlen(bitmap) < 16) {
tx_log(TX_LOG_WARN, "[MG_OL_0011] 비트맵 길이부족 len=%d", (int)strlen(bitmap));
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
present[0] = '\0';
/* 16 hex 문자 -> 64 bit, MSB = 필드1 */
for (i = 0; i < 16; i++) {
char c = bitmap[i];
if (c >= '0' && c <= '9') nib = c - '0';
else if (c >= 'A' && c <= 'F') nib = c - 'A' + 10;
else if (c >= 'a' && c <= 'f') nib = c - 'a' + 10;
else {
tx_log(TX_LOG_WARN, "[MG_OL_0011] 비16진 문자 pos=%d", i);
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
for (bit = 0; bit < 4; bit++) {
if (nib & (1 << (3 - bit))) {
fieldno = i * 4 + bit + 1;
if (fieldno == 1)
secondary = 1; /* 필드1 온 = secondary bitmap 존재 */
snprintf(hexbuf, sizeof(hexbuf), "%d ", fieldno);
if (strlen(present) + strlen(hexbuf) < sizeof(present))
strcat(present, hexbuf);
cnt++;
}
}
}
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "FIELDS", present);
tx_buf_setlong(ctx->out, "COUNT", (long)cnt);
tx_buf_setlong(ctx->out, "SECONDARY", (long)secondary);
/* 비트맵 파싱 결과(mg_bitmap_log)를 임베디드 SQL 로 적재 */
{
EXEC SQL BEGIN DECLARE SECTION;
char h_bm_bitmap[24];
long h_bm_count;
long h_bm_secondary;
EXEC SQL END DECLARE SECTION;
strncpy(h_bm_bitmap, bitmap, sizeof(h_bm_bitmap) - 1);
h_bm_bitmap[sizeof(h_bm_bitmap) - 1] = '\0';
h_bm_count = (long)cnt;
h_bm_secondary = (long)secondary;
if (tx_begin() == TX_OK) {
EXEC SQL INSERT INTO mg_bitmap_log
(primary_bitmap, field_count, secondary_yn)
VALUES (:h_bm_bitmap, :h_bm_count, :h_bm_secondary);
if (sqlca.sqlcode != TX_SQL_OK) {
TX_DBIO_LOG_ERR("INSERT mg_bitmap_log");
tx_abort();
} else {
tx_commit();
}
}
}
tx_log(TX_LOG_INFO, "[MG_OL_0011] 파싱완료 present=%d secondary=%d", cnt, secondary);
tx_return(ctx, TX_OK, ctx->out);
}