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/vl_ol_0016.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

108 lines
3.6 KiB
Text

/* @tier easy @module vl @transform validation-online */
/*
* vl_ol_0016.pgc - 전문 포맷 검증 서비스 (VL_OL_0016)
*
* 입력 RAW 전문을 고정길이 레이아웃(acq_msg_t) 으로 언팩하여 길이/필수필드
* (msg_validate) 를 검증하고, 전문유형코드(msg_type) 를 전문유형 마스터
* (vl_msg_type) 에서 조회하여 등록/사용 여부를 확인한다. 실패 시 불일치(VL16xx).
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "txcore.h"
#include "txcore_dbio.h"
#include "acq_util.h"
#include "vl_core.h"
EXEC SQL INCLUDE sqlca;
TX_SERVICE(VL_OL_0016, ctx)
{
EXEC SQL BEGIN DECLARE SECTION;
char h_msg_type[5];
char h_use_yn[2];
char h_type_name[41];
EXEC SQL END DECLARE SECTION;
acq_msg_t msg;
char raw[128];
int rawlen;
tx_log(TX_LOG_INFO, "[VL_OL_0016] 전문 포맷 검증 서비스 진입");
if (tx_buf_get(ctx->in, "RAW", raw, sizeof(raw)) != TX_OK) {
tx_log(TX_LOG_ERROR, "[VL_OL_0016] RAW 전문 누락");
tx_buf_sets(ctx->out, "ERRCODE", "VL1600");
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
/* 1) 길이 검증 */
rawlen = (int)strlen(raw);
if (rawlen < MSG_ACQ_LEN) {
tx_log(TX_LOG_WARN, "[VL_OL_0016] 전문 길이 부족 len=%d need=%d",
rawlen, MSG_ACQ_LEN);
tx_buf_sets(ctx->out, "RESULT", "MISMATCH");
tx_buf_sets(ctx->out, "ERRCODE", "VL1601");
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
/* 2) 언팩 + 필수필드 검증 */
memset(&msg, 0, sizeof(msg));
if (msg_unpack(&msg, raw, rawlen) != 0 || msg_validate(&msg) != 0) {
tx_log(TX_LOG_WARN, "[VL_OL_0016] 전문 검증 실패(msg_validate)");
tx_buf_sets(ctx->out, "RESULT", "MISMATCH");
tx_buf_sets(ctx->out, "ERRCODE", "VL1602");
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
/* 3) 전문유형코드 유효성 조회 */
memset(h_msg_type, 0, sizeof(h_msg_type));
memcpy(h_msg_type, msg.msg_type, FLD_MSG_TYPE_LEN);
h_msg_type[FLD_MSG_TYPE_LEN] = '\0';
memset(h_use_yn, 0, sizeof(h_use_yn));
memset(h_type_name, 0, sizeof(h_type_name));
EXEC SQL SELECT use_yn, type_name
INTO :h_use_yn, :h_type_name
FROM vl_msg_type
WHERE msg_type = :h_msg_type;
if (sqlca.sqlcode == TX_SQL_NOTFOUND) {
tx_log(TX_LOG_WARN, "[VL_OL_0016] 미등록 전문유형 type=%s", h_msg_type);
tx_buf_sets(ctx->out, "RESULT", "MISMATCH");
tx_buf_sets(ctx->out, "ERRCODE", "VL1603");
tx_return(ctx, TX_ENOENT, ctx->out);
return;
}
if (sqlca.sqlcode != TX_SQL_OK) {
TX_DBIO_LOG_ERR("SELECT vl_msg_type");
tx_buf_sets(ctx->out, "ERRCODE", "VL1609");
tx_return(ctx, TX_EDB, ctx->out);
return;
}
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "MSGTYPE", h_msg_type);
tx_buf_sets(ctx->out, "TYPENAME", h_type_name);
tx_buf_sets(ctx->out, "USEYN", h_use_yn);
tx_buf_setlong(ctx->out, "RAWLEN", (long)rawlen);
if (memcmp(h_use_yn, "Y", 1) != 0) {
tx_log(TX_LOG_WARN, "[VL_OL_0016] 비활성 전문유형 type=%s use=%s",
h_msg_type, h_use_yn);
tx_buf_sets(ctx->out, "RESULT", "MISMATCH");
tx_buf_sets(ctx->out, "ERRCODE", "VL1604");
tx_return(ctx, TX_OK, ctx->out);
return;
}
tx_buf_sets(ctx->out, "RESULT", "MATCH");
tx_buf_sets(ctx->out, "ERRCODE", RESP_OK);
tx_log(TX_LOG_INFO, "[VL_OL_0016] 전문 포맷 정상 type=%s name=%s",
h_msg_type, h_type_name);
tx_return(ctx, TX_OK, ctx->out);
}