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/cm_ol_0013.c
forge-bot c3a0259e95 다양화: 530개 online/batch 프로그램을 모듈별 고유 실업무 로직으로 재작성
- 템플릿 클론(정규화 후 0줄 상이) → 전 코퍼스 530/530 고유 바디
- 11개 모듈(mg/au/ac/rc/vl/st/py/lg/mm/cm/cl) 각 파일이 distinct한
  매입·대사·정산·수수료·지급·원장·마감·마스터·정합성·전문게이트웨이·공통 업무
- TxCore(ATMI 유사) + ECPG(EXEC SQL) 관용구, 프레임워크/헤더/DBIO API/파일ID·경로 유지
- 전체 docker make -j4 = EXIT 0, 958 오브젝트, 데모 바이너리 링크
- inventory.json loc 실측 갱신

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

153 lines
3.9 KiB
C

/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
/* These include files are added by the preprocessor */
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
/* End of automatic include section */
#line 1 "app/online/cm_ol_0013.pgc"
/* @tier easy @module cm @transform common-online */
/*
* cm_ol_0013.pgc - 체크섬(LRC) 검증 서비스 (CM_OL_0013) [tier=easy]
*
* 요청의 원문(DATA) 에 대해 바이트 XOR 누적(LRC) 체크섬을 순수 로직으로
* 계산하고, 기대값(EXPECT, 16진 2자리) 과 비교하여 일치여부(MATCH=Y/N)를
* 응답한다. 대외 전문 무결성 검증 공통 루틴. DB 접근 없음.
* (ATMI void SVC(TPSVCINFO*) 대응)
*/
#include <stdio.h>
#include <string.h>
#include "txcore.h"
#include "acq_util.h"
#include "cm_core.h"
#line 1 "/usr/include/postgresql/sqlca.h"
#ifndef POSTGRES_SQLCA_H
#define POSTGRES_SQLCA_H
#ifndef PGDLLIMPORT
#if defined(WIN32) || defined(__CYGWIN__)
#define PGDLLIMPORT __declspec (dllimport)
#else
#define PGDLLIMPORT
#endif /* __CYGWIN__ */
#endif /* PGDLLIMPORT */
#define SQLERRMC_LEN 150
#ifdef __cplusplus
extern "C"
{
#endif
struct sqlca_t
{
char sqlcaid[8];
long sqlabc;
long sqlcode;
struct
{
int sqlerrml;
char sqlerrmc[SQLERRMC_LEN];
} sqlerrm;
char sqlerrp[8];
long sqlerrd[6];
/* Element 0: empty */
/* 1: OID of processed tuple if applicable */
/* 2: number of rows processed */
/* after an INSERT, UPDATE or */
/* DELETE statement */
/* 3: empty */
/* 4: empty */
/* 5: empty */
char sqlwarn[8];
/* Element 0: set to 'W' if at least one other is 'W' */
/* 1: if 'W' at least one character string */
/* value was truncated when it was */
/* stored into a host variable. */
/*
* 2: if 'W' a (hopefully) non-fatal notice occurred
*/ /* 3: empty */
/* 4: empty */
/* 5: empty */
/* 6: empty */
/* 7: empty */
char sqlstate[5];
};
struct sqlca_t *ECPGget_sqlca(void);
#ifndef POSTGRES_ECPG_INTERNAL
#define sqlca (*ECPGget_sqlca())
#endif
#ifdef __cplusplus
}
#endif
#endif
#line 17 "app/online/cm_ol_0013.pgc"
/* 문자열 전 구간 바이트 XOR 로 LRC(종방향 중복검사) 계산 */
static unsigned char lrc_calc(const char *data, int len)
{
unsigned char lrc = 0;
int i;
for (i = 0; i < len; i++)
lrc ^= (unsigned char)data[i];
return lrc;
}
TX_SERVICE(CM_OL_0013, ctx)
{
char data[256];
char expect[8];
unsigned char lrc;
unsigned int exp_val = 0;
char calc_hex[4];
int match;
tx_log(TX_LOG_INFO, "[CM_OL_0013] 체크섬 검증 서비스 진입");
if (tx_buf_get(ctx->in, "DATA", data, sizeof(data)) != TX_OK) {
tx_log(TX_LOG_ERROR, "[CM_OL_0013] DATA 누락");
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
lrc = lrc_calc(data, (int)strlen(data));
snprintf(calc_hex, sizeof(calc_hex), "%02X", (unsigned int)lrc);
/* 기대값(EXPECT)은 선택 입력: 없으면 계산만 수행 */
if (tx_buf_get(ctx->in, "EXPECT", expect, sizeof(expect)) == TX_OK) {
if (sscanf(expect, "%x", &exp_val) != 1) {
tx_log(TX_LOG_WARN, "[CM_OL_0013] EXPECT 형식 오류 val=%s", expect);
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
match = ((unsigned int)lrc == (exp_val & 0xFF)) ? 1 : 0;
} else {
match = -1; /* 비교 미수행 */
}
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "LRC", calc_hex);
tx_buf_setlong(ctx->out, "LRCDEC", (long)lrc);
if (match < 0) {
tx_buf_sets(ctx->out, "MATCH", "N/A");
tx_log(TX_LOG_INFO, "[CM_OL_0013] LRC 계산 lrc=%s (비교 미수행)", calc_hex);
} else {
tx_buf_sets(ctx->out, "MATCH", match ? "Y" : "N");
tx_log(TX_LOG_INFO, "[CM_OL_0013] LRC=%s 기대=%02X 일치=%s",
calc_hex, exp_val & 0xFF, match ? "Y" : "N");
}
tx_return(ctx, TX_OK, ctx->out);
}