/*
 *========================================================================
 *
 *   시스템명 : 요금징수 시스템
 *   파 일 명 : ft_basictbl.pc
 *   작 성 자 : 오효섭 (catacath@neighbor21.co.kr)
 *   작 성 일 : 2012.10.10
 *   수 정 일 :
 *   설    명 : 기초상태테이블의 파일/테이블간 변환처리
 *
 *========================================================================
*/

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>

#include "wrk_stat.h"
#include "cls_lane.h"
#include "chg_struc.h"
#include "file_nm.h"
#include "file_no.h"
#include "dir_path.h"
#include "ora_sql.h"
#include "ipc_def.h"
#include "file_lb.h"
#include "tcs_db_def.h"

static    struct    write_info         wi;
static    struct    cls_lane_spec         cls_lane_spec_f;

int main(int argc, char *argv[])
{
    int     isfd, isrc;
    char    path[128];
    char    temp[3+1];
    int options;
    char kmij[9];

    memset(kmij, 0x00, sizeof(kmij));
    memset(&cls_lane_spec_f, 0, sizeof(struct cls_lane_spec));

    if(argc < 2){
        printf("Usage : cls_lane_view -d [YYYYMMDD]\n");
        exit(0);
    }

    while((options = getopt(argc, argv, "d:")) != EOF)
    {
	switch(options)
	{
	    case 'd':
		sprintf(kmij, "%.8s", optarg);
            break;
        }
    }

    sprintf(path, "%s/%s/%.8s/CLSPASSSPEC", DIR_TCS, DIR_LOG, kmij);

    isfd = open(path, FINPUT+FC_MANULOCK);
    if(isfd < 0)
    {
	printf("open error\n");
	exit(0);
    }

    while(1)
    {

        isrc = read(isfd, &cls_lane_spec_f, sizeof(struct cls_lane_spec));
	if(isrc < 1) break;

    printf("+++++++++++++++++++++++++++ 폐쇄차로 통행데이터 ++++++++++++++++++++++++++ \n"); 
    printf("발생일자 : %04d-%02d-%02d %02d:%02d:%02d\n", cls_lane_spec_f.occ_year, cls_lane_spec_f.occ_mon, cls_lane_spec_f.occ_day, cls_lane_spec_f.occ_hr, cls_lane_spec_f.occ_min, cls_lane_spec_f.occ_sec);
    printf("차로번호 : %02d\n", cls_lane_spec_f.lane_no);
    printf("전송연번 : %d\n", cls_lane_spec_f.seq_no);
    printf("일련번호 : %d\n", cls_lane_spec_f.sno);
/*
    printf("개시연번 : %d\n", wrk_st_info_o.strt_no);
    printf("종료연번 : %d\n", wrk_st_info_o.end_no);
    printf("근무자번호 : %.4s\n", wrk_st_info_o.wrkr_no);
    printf("근무구분 : %X\n", wrk_st_info_o.wrk_div);
    printf("개시일시 : %04d/%02d/%02d %02d:%02d:%02d\n", wrk_st_info_o.strt_year, wrk_st_info_o.strt_mon, wrk_st_info_o.strt_day, wrk_st_info_o.strt_hr, wrk_st_info_o.strt_min, wrk_st_info_o.strt_sec);
    printf("종료일시 : %04d/%02d/%02d %02d:%02d:%02d\n", wrk_st_info_o.end_year, wrk_st_info_o.end_mon, wrk_st_info_o.end_day, wrk_st_info_o.end_hr, wrk_st_info_o.end_min, wrk_st_info_o.end_sec);
    printf("유무인 구분 : %d\n", wrk_st_info_o.opr_div);
*/

    }
    lb_close(isfd);
}
