/****************************************************************
// source file name	: file_common.h
// date of preperation	: 2016.03.04
// date of last update	: 2016.03.04
// developer		: mskim
****************************************************************/
#ifndef __FILE_COMMON_H__
#define __FILE_COMMON_H__

/***************************************************************
// PL 파일
****************************************************************/
//2022.03.28 MODIFY 26->35
#define MAX_PL_FILE_CNT	35	// PL 전체 파일 수

#define FILE_WRITE_UNIT_SIZE	8040 // PLTPCARDMST_S 파일 쓰기 단위

#define PL_START_BUFFER_SIZE		30000000

// Alias No 30000001 ~ 550000000
#define WSSF_START_NO_GET(a)		30000001+(a-1)	//WSSF
#define WSSF_END_NO					90000000 
#define WTSF_START_NO_GET(a)		90000001+(a-1)	//WTSF
#define WTSF_END_NO					120000000
#define WXSF_SUB1_START_NO_GET(a)	120000001+(a-1)	//WXSF_SUB1
#define WXSF_SUB1_END_NO			140000000
#define WXSF_SUB2_START_NO_GET(a)	170000001+(a-1)	//WXSF_SUB2
#define WXSF_SUB2_END_NO			178500000
#define WYSF_START_NO_GET(a)		140000001+(a-1)	//WYSF
#define WYSF_END_NO					160000000
#define WBSF_SUB1_START_NO_GET(a)	160000001+(a-1)	//WBSF_SUB1
#define WBSF_SUB1_END_NO			170000000
#define WBSF_SUB2_START_NO_GET(a)	178500001+(a-1)	//WBSF_SUB2
#define WBSF_SUB2_END_NO			180000000
#define WZSF_START_NO_GET(a)		180000001+(a-1)	//WZSF
#define WZSF_END_NO					240000000
#define VWSF_START_NO_GET(a)		240000001+(a-1)	//VWSF
#define VWSF_END_NO					260000000
#define VXSF_START_NO_GET(a)		260000001+(a-1)	//VXSF
#define VXSF_END_NO					290000000
#define WASF_START_NO_GET(a)		340000001+(a-1)	//WASF
#define WASF_END_NO					380000000
#define NVSF_START_NO_GET(a)		290000001+(a-1)	//NVSF
#define NVSF_END_NO					320000000
#define NUSF_START_NO_GET(a)		320000001+(a-1)	//NUSF
#define NUSF_END_NO					340000000
#define NTSF_START_NO_GET(a)		380000001+(a-1)	//NTSF
#define NTSF_END_NO					430000000
#define BHSF_START_NO_GET(a)		430000001+(a-1) //BHSF
#define BHSF_END_NO					490000000
#define NSSF_START_NO_GET(a)		490000001+(a-1)	//NSSF
#define NSSF_END_NO					500000000
#define NRSF_START_NO_GET(a)		500000001+(a-1)	//NRSF
#define NRSF_END_NO					530000000
#define NQSF_START_NO_GET(a)		530000001+(a-1)	//NQSF
#define NQSF_END_NO					550000000

#define HLSF_START_NO_GET(a)		550000001+(a-1)	//HLSF
#define HLSF_END_NO					560000000

#define NPSF_START_NO_GET(a)		560000001+(a-1)	//NPSF
#define NPSF_END_NO					590000000
#define NOSF_START_NO_GET(a)		590000001+(a-1)	//NOSF
#define NOSF_END_NO					600000000

#define EPSF_START_NO_GET(a)		600000001+(a-1)	//EPSF
#define EPSF_END_NO					650000000
#define EQSF_START_NO_GET(a)		650000001+(a-1)	//EQSF
#define EQSF_END_NO					700000000

#define V3SF_START_NO_GET(a)		700000001+(a-1)	//V3SF
#define V3SF_END_NO					750000000
#define V4SF_START_NO_GET(a)		750000001+(a-1)	//V4SF
#define V4SF_END_NO					800000000
#define V5SF_START_NO_GET(a)		800000001+(a-1)	//V5SF
#define V5SF_END_NO					825000000
#define V6SF_START_NO_GET(a)		825000001+(a-1)	//V6SF
#define V6SF_END_NO					855000000
#define V7SF_START_NO_GET(a)		855000001+(a-1)	//V7SF
#define V7SF_END_NO					900000000

//2022.03.28 ADD
#define W1SF_START_NO_GET(a)		900000001+(a-1)	//W1SF
#define W1SF_END_NO					950000000
#define W2SF_START_NO_GET(a)		950000001+(a-1)	//W2SF
#define W2SF_END_NO					1000000000
#define W3SF_START_NO_GET(a)		1000000001+(a-1)	//W3SF
#define W3SF_END_NO					1050000000
#define W4SF_START_NO_GET(a)		1050000001+(a-1)	//W4SF
#define W4SF_END_NO					1110000000
#define W5SF_START_NO_GET(a)		1110000001+(a-1)	//W5SF
#define W5SF_END_NO					1160000000
#define W6SF_START_NO_GET(a)		1160000001+(a-1)	//W6SF
#define W6SF_END_NO					1200000000
#define W7SF_START_NO_GET(a)		1200000001+(a-1)	//W7SF
#define W7SF_END_NO					1225000000
#define W8SF_START_NO_GET(a)		1225000001+(a-1)	//W8SF
#define W8SF_END_NO					1255000000
#define W9SF_START_NO_GET(a)		1255000001+(a-1)	//W9SF
#define W9SF_END_NO					1300000000
//2022.03.28 MODIFY 900000000->1300000000
#define PL_END_NO					1300000000
// END

typedef struct _pl_record
{
	char	acData[512];	
} PL_RECORD;

typedef struct _iss_record
{
	char	acData[21];	
} ISS_COMP;

typedef struct _pl_file_recv_list
{
	char	acFileNameList[MAX_PL_FILE_CNT][8];
} PL_FILE_RECV_LIST;

enum FILE_ID
{
	 UNKNOWN = 0
	,WSSF
    ,WTSF
    ,WXSF
    ,WYSF
    ,WBSF
    ,WZSF
    ,VWSF
    ,VXSF
    ,WASF
    ,NVSF
    ,NUSF
    ,NTSF
    ,NSSF
    ,NRSF
    ,NQSF
    ,NPSF
    ,NOSF
    ,BHSF
    ,EPSF
    ,EQSF
    ,HLSF
    ,V3SF
    ,V4SF
    ,V5SF
    ,V6SF
    ,V7SF
    ,W1SF
    ,W2SF
	,W3SF
	,W4SF
	,W5SF
	,W6SF
	,W7SF
	,W8SF
	,W9SF
};

typedef struct _pl_file_check_list
{
	char	*pcFileName;
	int		iReadFlag;
	enum	FILE_ID iId;
} PL_FILE_CHECK_LIST;

#define		PROC_RUNNING				1
#define		PROC_STOP					0

#ifdef __MAIN__
long        glRunning    = PROC_RUNNING;
#else /* __MAIN__ */
extern long        glRunning;
#endif /* End __MAIN__ */

/***************************************************************
// BL 수신						                                        
****************************************************************/

typedef struct _bl_header
{
	char	cGubun;
	char	acWGubun[4];
	char	acFDate[6];
	char	acReserved[7];
	char	cELine;
} BL_HEADER;

typedef struct _bl_data
{
	char	cGubun;
	char	acCrdNo[16];
	char	cRCode;
	char	cELine;
} BL_DATA;

typedef	struct _bl_trail
{
	char	cGubun;
	char	acTotCnt[7];
	char	acReserved[10];
	char	cELine;
} BL_TRAIL;

/***************************************************************
// 선/후불발행사 수신
****************************************************************/

typedef struct _s_issuer_head
{
	unsigned char	acAppltnDtime[7];		//적용일시
	unsigned char	acAppltnSeq[1];			//적용 일련번호
	unsigned char	acIssCnt[3];			//선불 발행사 개수
} S_ISSUER_HEAD;

typedef struct _s_issuer_data
{
	unsigned char	acPcardPubcomId[7];		//선불 발행사 코드
	unsigned char	acAssocClassCd[1];		//단말기 소속 조합 구분코드
	unsigned char	acStuPpcardUseCd[1];	//환승할인/학생카드 적용유무
} S_ISSUER_DATA;

typedef struct _e_issuer_head
{
	unsigned char	acAppltnDtime[7];		//후불 발행사 적용일시
	unsigned char	acIssCnt[2];			//후불 발행사 Prefix 갯수
} E_ISSUER_HEAD;

typedef struct  _e_issuer_data
{
	unsigned char	acPrefixNo[3];			//Prefix 번호
	unsigned char	acCompCd[2];			//압축코드
	unsigned char	acPcardPuvcomId[4];		//교통카드 발행사
} E_ISSUER_DATA;

typedef struct _bltm_bintbl
{
	char			acCrdCd[7];				//발행사 코드
	char			acBinCd[6];				//BIN 코드
	char			acCrdDesc[30];			//카드설명
} BLTM_BINTBL;

#endif
