/*
 * cm_svc.h - cm (공통) 서비스 공통 카피북 (shared copybook for all cm svc/*.pgc).
 *
 * Every per-service file (svc/<SVCNAME>.pgc) includes its own copybook header
 * (svc/<SVCNAME>.h), which in turn includes THIS shared base. It pulls in the
 * ATMI/UBF runtime, the acq.fd field ids, the cm dbio layer (libcmdbio.a)
 * and the common math (libacqcommon.a), and provides the tiny UBF helpers +
 * tpreturn macros every service uses. No business logic lives here.
 */
#ifndef CM_SVC_H
#define CM_SVC_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include <ubf.h>
#include <userlog.h>
#include <ndebug.h>
#include "acq.fd.h"
#include "cm_dbio.h"
#include "acq_common.h"

/* ----- small UBF helpers (one copy per service TU) ----------------------- */
static long getl(UBFH *b, BFLDID f) { long v = 0; Bget(b, f, 0, (char *)&v, 0L); return v; }
static void gets_(UBFH *b, BFLDID f, char *out, int cap)
{ BFLDLEN l = cap; out[0] = 0; Bget(b, f, 0, out, &l); }
static void setl(UBFH *b, BFLDID f, long v) { Bchg(b, f, 0, (char *)&v, 0L); }
static void sets_(UBFH *b, BFLDID f, const char *s) { Bchg(b, f, 0, (char *)s, 0L); }

#define FAIL(b) do { tpreturn(TPFAIL, 0, (char *)(b), 0L, 0L); return; } while (0)
#define OK(b)   do { tpreturn(TPSUCCESS, 0, (char *)(b), 0L, 0L); return; } while (0)

#endif /* CM_SVC_H */
