/*
*========================================================================
*
*   SYSTEM   : AZN_PLAZA_LANE APP
*   FILE     : lb_func_list.h
*   Progrmer : JBY (baarong@neighbor21.co.kr)
*   Date     : 2018.07.13
*   Modified :
*   Remark   : Libraty   
*
*========================================================================
*/

#include <dirent.h>
#include "file_ctrl.h"
//#include "eps_ftp.h"
#include "chg_struc.h"
#include "ipc_def.h"
#include "Common.h"
#include "StringUtil.h"
#include "Log.h"
#include "MessageQueue.h"
#include "SystemUtil.h"
#include "SecureCodingUtil.h"

/* lb_common.c function list */
char *get_current_time(char *time_buf);
char *get_yesterday_date(char *date_buf);
char *get_gmt(char *time_buf, int size);
char *conv_localtime(time_t raw_time);
char *conv_localtime_ymd(time_t raw_time);
char *conv_localtime_hms(time_t raw_time);
char *get_current_time_sec();
char *conv_localtime2(time_t raw_time, int n);
char *conv_localtime3(time_t raw_time, char *time_buf);
time_t get_dsnt_time(char *dsnt_buf);
int   get_week();
int   open_log_file();
void  close_log_file();
int   LOGGING(char *str);
void  log_write_stderr(char *str);
void  proc_log(char *str, ...);
int   atoi_str_len(char *str, int len_str);
void  non_block(int s);
char *rtrim(register char *str);
void  del_space(char *str);
int   get_wday(char *daystr);

/* lb_conv.c function list */
int lb_hexa2string(unsigned char *str1, unsigned char val, int len);
int lb_string2hexa(unsigned char *str, int len);
int lb_ymd2str_date(char *t_date, struct f_date *f_date);
int lb_ymd2date(struct f_date *t_date, char *f_date);
int lb_hms2str_tm(char *t_tm, struct f_tm *f_tm);
int lb_hms2tm(struct f_tm *t_tm, char *f_tm);
int lb_hm2str_tm(char *t_tm, struct f_tm *f_tm);
int lb_hm2tm(struct f_tm *t_tm, char *f_tm);
int lb_char2string(char *tbl_str, unsigned char f_char, int tbl_len);
int lb_ymdhm2str_date(char *t_date, struct f_date *f_date);
int l_str2ytb(struct f_date *t_date, char *f_date);
int lb_ymdhms2str_date(char *t_date, struct f_date *f_date);
int lb_ymdhms2date(struct f_date *f_date, char *t_date);
int lb_char2an_bit(char *s, int len);
int lb_char2bit(char *s, int len);
int lb_data2atoi(char *buff, int len);
int lb_hex2dec(unsigned char *src, unsigned int *dst, int len);
void lb_string2bcd(char *bcd, char *str, int len);
int lb_strtonum(char *target, char *result, int len, int limit);

/* lb_date.c function list */
int lb_get_nowdate(char *time_buf);
int lb_oper_date(char *ndate, char oper, int oday, char *cdate);
int lb_get_nowdate_tm(char time_buf[15]);
int lb_date_chk(char *chkdate);
int lb_getdate2int( void );
struct tm *chk_date_tm();
struct tm *lintGetTime();
int checkDate4H(int hour, int min);
int checkTime4M(int min, int sec);
int checkDate4HSEC(int hour, int min, int sec);
int checkTime4MSEC(int min, int sec);

/* lb_debug.c function list */
int lb_nowork( char *fmt, ... );
FILE *lb_log_open( char *path, char *firstname );
int lb_log_close( void );
int lb_log_write_tm( char *fmt, ... );
int lb_log_write( char *fmt, ... );
int hex_dump( void *ptr, int size );

/* lb_err_log.c function list */
void lb_debug_log_dump(char *fmt, ...);
void lb_core_dump(char *fmt, ...);
void lb_error_exit(char *buf);
void lb_err_log(char *icp_pgm_id, char *icp_err_msg, int in_where);

/* lb_file_ctrl.c function list */
int   lb_file_exist_chk(struct write_info *wf, int file_no);
int   lb_fopen(struct write_info *wf, int file_no, int mode);
int   lb_fbuild(struct write_info *wf, int file_no, int mode);
int   lb_fread(int isfd, int file_no, void *record);
int   lb_freadi(int isfd, struct keydesc *key, int size, void *record, int opt);
int   lb_freadx(struct write_info *wf, int file_no, void *record, int mode);
int   lb_fwrite(int isfd, int file_no, void *record, int flag);
int   lb_fwritex(struct write_info *wf, int file_no, void *record, int falg);
int   lb_frewritex(struct write_info *wf, int file_no, void *record);
int   lb_frewcurr(int isfd, int file_no, void *record);
int   lb_frewrec(int isfd, int file_no, struct keydesc *key, void *record);
int   lb_fchk(struct write_info *wf, int file_no, int mode);
int   lb_fpath(struct write_info *wf, int file_no, char *path);
int   lb_read_trmn(int isfd, TRMNRCV *trmn_r);
int   lb_read_passraw(int isfd, PASSRAW *passraw_r);
int   lb_fbrewrite(int isfd, struct keydesc *key, void *record, int size);
int   lb_write(int isfd, void *record, int size);
int   lb_writeL(int isfd, void *record, int size);
int   lb_writel(int isfd, void *record, int size);
int   lb_read(int isfd, void *record, int mode, int size);
int   lb_readfw(int isfd, void *record, int mode, int size);
int   lb_readl(int isfd, void *record, int mode, int size);
int   lb_dummy_chk(void *dummy, int size);
int   lb_open(char *file_name, int mod);
int   lb_build(char *file_name, int mod);
int   lb_erase(char *file_name);
int   lb_close(int isfd);
int   lb_rename(char *old_name, char *new_name);
int   lb_start(int isfd, struct keydesc *key, int size, void *record, int mode);
int   lb_record_cnt(int isfd, int fno);
int   lb_get_txpos(int isfd, int file_no, char *lbyb, int *pos);
int   lb_get_xposint(int isfd, int file_no, int *lbyb, int *pos);
int   lb_delete(int isfd, int file_no, struct keydesc *key, void *record);

/* lb_fileq.c function list */
int lb_file_que_chk(char *que_name);
int lb_readchk_fileq_dt(int que_fd);
int lb_poschk_fileq_dt(int que_fd, long *que_read_pos, long *que_read_cnt);
int lb_poschk_fileq_dt2(int que_fd, long *que_read_pos, long *que_read_cnt);
int lb_read_fileq_dt(int que_fd, char *que_buffer, long que_read_pos, long que_read_cnt, int frame_size);
int lb_set_fileq_front(int que_fd, long front_pos);
int lb_set_fileq_pos(int que_fd, long *que_write_pos);
int lb_set_fileq(int que_fd, char *que_buffer, long que_write_pos, long que_write_cnt, int frame_size);
int lb_set_fileq_rear(int que_fd, long rear_pos);
int fque_write(int isfd, char *record, int size);

/* lb_ini_mgr.c function list */
char *lb_get_inifile(char *file_name, char *sec_name, char *var_name);

/* lb_oracle.sc function list */
int sqlcode(char *query);
int disconnect_db();
int c_DbConnect();
int cen_DbConnect();
//int connect_db();

/* lb_proc.c function list */
int lb_get_pid(char * pid_name, char *args1, char * args2);
int lb_user_chg();
int lb_proc_ctrl(struct srch_admin *srch_admin, struct reply_admin *reply_admin);
int lb_low_proc_reply(struct write_info *wf, struct lo_lane_ctrl_cmd *lc_cmd, struct lo_lane_ctrl_reply *lc_reply);
int lb_low_proc(struct write_info *wf, struct lo_lane_ctrl_cmd *lc_cmd, struct lo_lane_ctrl_reply *lc_reply);
int lb_low_connect(int caller, unsigned char *plz_id, int lane_no);

/* lb_sema_ctrl.c function list */
int   lb_get_right(int id, int lock);
int   lb_rel_right(int id);
int   l_chk_rights(int id);
int   lb_cnt_redolog(int inc_or_dec);

/* lb_shm.c function list */
int lb_attach_shm(key_t shm_key, int shm_size, void **ptr);
int lb_clear_shm(void *ptr);

/* lb_signal.c function list */
void  signalSet(void (*func) ());

/* lb_svr_socket.c function list */
int   lb_file2tbl(struct chg_struc *chg_struc);
int   lb_file2tbl_bl(struct chg_struc *chg_struc);
int   lb_tbl2file_bl(struct chg_struc *chg_struc);
int   lb_tbl2file(struct chg_struc *chg_struc);
int   lb_rehndlog(struct chg_struc *chg_struc);
int   lb_call_svr_proc(char *svr_name, struct write_info *qwf);
int   lb_svr_snd(char *svr_name, struct write_info *qwf);
int   lb_svr_sndm(char *svr_name, char *buff, int len);
int   lb_con_hnd_svr(char *svr_name);
int   lb_con_hnd_svr2(char *svr_name, int lane_no);
int   lb_svr_sndt(char *svr_name, char *buff, int len);
int   lb_con_tcp_svr(char *svr_name);
void  lb_close_socket(int sd);
int   lb_tcp_con(char *host_name, char *port_alias);
int   lb_select_socket(int sockfd, int sec, int usec);
int   readn(int sockfd, char *buff, int len);
int   writen(int sd, void *data, int data_size);
void  lb_packet_dump(unsigned char *data, int lsize, int ldiv);
int   lb_select(int sockfd,int sec,int usec);
int   lb_tcp_snd(int sd, void *data, int data_size);
int   lb_file_save(char *file_name, void *data, int lsize);
int   lb_file_size(char *file_name);
int   lb_file2shared(char *file_name, void *shared, int lsize);
int   lb_snd_eps_file(int _client_socket, char *file_name, struct  dirent *d);
/*int   lb_rcv_eps_file(int _client_socket, _FTSHEAD *fts, char work_path[128]);*/

