/*
 *========================================================================
 *
 *   시스템명 : 요금징수 시스템
 *   파 일 명 : ft_main.c
 *   작 성 자 : 오효섭 (catacath@neighbor21.co.kr)
 *   작 성 일 : 2012.10.10
 *   수 정 일 :
 *   설    명 : File & DB Table간 변환 Main
 *
 *========================================================================
*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <signal.h>
#include <arpa/inet.h>

#include "chg_struc.h"
#include "file_lb.h"
#include "dir_path.h"
#include "debug_def.h"
#include "path_def.h"
#include "lb_func_list.h"
#include "func_list.h"

struct   sockaddr_un   sock_svr;   /* socket for me               */

void   SIG_term();             /* signal handler               */

int    init_sock();
int    chk_event();
int    file_tbl_chng();

/*******************************************************************************
** 1. 모 듈 명 :  main
** 2. 모듈기능 :  File & DB Table간 변환 Main
** 3. 입    력 :
**
** 4. 입 출 력 :
**
** 5. 출    력 :
**
** 6. Fuction Return:
**
** 7. 변경이력 :
**------------------------------------------------------------------------------
** Version  Date        Comment
** 1.00     2012/07/23  - TCS VERSION(C/S 환경)
*******************************************************************************/
int main()
{
    struct  chg_struc  *pcs =  malloc(sizeof(struct chg_struc));
    int ret;
    char plid[6];
    time_t ctime;
    struct tm *struc_tm;

    ctime = time(0);
    struc_tm = local_time(&ctime);

    while((ret = c_DbConnect()) <0)
    {
        printf("oltp_svr db connect error\n");
        sleep(1);
    }

    //inst_plmst();
    //inst_blmst();

    printf("GROUP CODE:");
    scanf("%s",(char *)&plid);

    memcpy(pcs->grp_id, plid, sizeof(pcs->grp_id));
    memcpy(pcs->plz_id, plid, sizeof(pcs->plz_id));
    sprintf((char *)pcs->file_year, "%04d", struc_tm->tm_year + 1900);
    sprintf((char *)pcs->file_mon,  "%02d", struc_tm->tm_mon+1);
    sprintf((char *)pcs->file_day,  "%02d", struc_tm->tm_mday);
    printf("PLAZA [%.6s]\n", pcs->plz_id);
    pcs->gdiv = '0';
    printf("%.4s/%.2s/%.2s\n", pcs->file_year, pcs->file_mon, pcs->file_day);

    ret = chng_t2f_basictbl(pcs);
#if 0
    ret = chng_t2f_wrkrpersonalinfo(pcs);
    ret = chng_t2f_passfaretbl(pcs);
    ret = chng_t2f_isscomptbl();
    ret = chng_t2f_rtagmst();
    ret = chng_t2f_rtagcng();
    ret = chng_t2f_ptagmst();
    ret = chng_t2f_ptagcng();
#endif
    disconnect_db();   /* Disconnect Oracle */
    return 0;
}

