/* @tier easy @module cm @transform common-online */ /* * cm_ol_0028.pgc - 시간 포맷 변환 서비스 (CM_OL_0028) [tier=easy] * * 입력 시각(HHMMSS 6자리)을 HH:MM:SS 로 변환하고 각 필드의 범위를 * 검증(시 0~23, 분/초 0~59)하여 포맷 결과와 총 경과초를 응답한다. * DB 접근 없는 순수 로직 서비스. (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" #include "acq_util.h" #include "cm_core.h" EXEC SQL INCLUDE sqlca; TX_SERVICE(CM_OL_0028, ctx) { char hms[16]; char formatted[16]; int hh; int mm; int ss; int i; long secs; tx_log(TX_LOG_INFO, "[CM_OL_0028] 시간 포맷 변환 서비스 진입"); if (tx_buf_get(ctx->in, "HMS", hms, sizeof(hms)) != TX_OK) { tx_log(TX_LOG_ERROR, "[CM_OL_0028] HMS 누락"); tx_return(ctx, TX_EINVAL, ctx->out); return; } /* 정확히 6자리 숫자여야 한다 */ if (strlen(hms) != 6) { tx_log(TX_LOG_WARN, "[CM_OL_0028] 길이 오류 hms=%s", hms); tx_return(ctx, TX_EINVAL, ctx->out); return; } for (i = 0; i < 6; i++) { if (hms[i] < '0' || hms[i] > '9') { tx_log(TX_LOG_WARN, "[CM_OL_0028] 숫자 아님 hms=%s", hms); tx_return(ctx, TX_EINVAL, ctx->out); return; } } hh = (hms[0] - '0') * 10 + (hms[1] - '0'); mm = (hms[2] - '0') * 10 + (hms[3] - '0'); ss = (hms[4] - '0') * 10 + (hms[5] - '0'); if (hh > 23 || mm > 59 || ss > 59) { tx_log(TX_LOG_WARN, "[CM_OL_0028] 시간 범위 오류 %02d:%02d:%02d", hh, mm, ss); tx_return(ctx, TX_EINVAL, ctx->out); return; } sprintf(formatted, "%02d:%02d:%02d", hh, mm, ss); secs = (long)hh * 3600 + (long)mm * 60 + ss; tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "HMS", hms); tx_buf_sets(ctx->out, "FORMATTED", formatted); tx_buf_setlong(ctx->out, "SECONDS", secs); tx_log(TX_LOG_INFO, "[CM_OL_0028] 변환완료 %s -> %s (%ld초)", hms, formatted, secs); tx_return(ctx, TX_OK, ctx->out); }