Appendix A. 헤더 파일

내용 목차

A.1. TCPHDR.H 파일

A.1. TCPHDR.H 파일

#ifndef  _TCPHDR_H_
#define  _TCPHDR_H_

#ifndef _WIN32
#define __cdecl
#endif
    
#define CLIENT_ID_SIZE          15
    
/*      THREAD status */
#define WTHR_START              2
#define WTHR_READY              3
#define WTHR_RUNNING            4

/*      SELECT status */
#define WTHR_SELECT_ERROR      -1
#define WTHR_SELECT_TIMEOUT     1
#define WTHR_TMAX_REQUEST       2
#define WTHR_USER_REQUEST       3
    
/*      READ   status */
#define WTHR_CLIENT_CLOSE       0
#define WTHR_READ_ERROR        -1
#define WTHR_READ_TIMEOUT      -2
    
/*      WRITE   status */
#define WTHR_WRITE_ERROR       -1

struct workwthrinfo {
    int   idx;
    int   status;
    int   fd;
    int   portno;
    unsigned int ipaddr;
    char  clientid[CLIENT_ID_SIZE+1];
};
typedef struct workwthrinfo WORKTHRINFO;

#define SHMHEAD_SIZE  sizeof(struct shmhead)
struct shmhead {
    char  shmdate[8];
    int   shmsize;
    int   handler_num;
    int   maxnum;
    int   resvd; 
};
typedef struct shmhead SHMHEAD;

#define HANDLERINFO_SIZE  sizeof(struct handler_info)
struct handler_info {
    int   status;
    int   fd;
    int   svrn;
    int   pid;
    int   portno;
    int   num;
};
typedef struct handler_info HANDLERINFO;

#define CLIENTINFO_SIZE  sizeof(struct clientinfo)
struct clientinfo {
    int   status;
    int   thridx;
    int   svridx;
    int   rcount;
    int   scount;
    int   pid;
    int   portno;
    unsigned int ipaddr;
    int   utime;
    int   resvd;
    char  clientid[CLIENT_ID_SIZE+1];
};
typedef struct clientinfo CLIENTINFO;

#if defined(__cplusplus)
extern "C" {
#endif

/* ------------------ function prototypes ------------------- */
int __cdecl tcpgw_tpcall(WORKTHRINFO *wthrinfo, char *svc, char *ptr,
                 long alen, char *optr, long *olen);
int __cdecl tcpgw_tpacall(WORKTHRINFO *wthrinfo, char *svc, char *ptr, long alen);
int __cdecl tcpgw_tpreply(WORKTHRINFO *wthrinfo, char *ptr, long alen, int err);
int __cdecl tcpgw_select(WORKTHRINFO *wthrinfo, int sec, int usec);
int __cdecl tcpgw_get_svcdata(WORKTHRINFO *wthrinfo, char *ptr, int *err, 
                              int *flags);
int __cdecl tcpgw_network_connect(char *host, int port, int sec);
int __cdecl tcpgw_read(int fd, char *ptr, int nbytes, int sec, int usec);
int __cdecl tcpgw_write(int fd, char *ptr, int nbytes);
int __cdecl tcpgw_portno_ipaddr(char *ipaddr);
int __cdecl tcpgw_getaddr_from_winfo(WORKTHRINFO *winfo, char *ipaddr); 
int __cdecl tcpgw_client_id(WORKTHRINFO *winfo, char *id);

#if defined (__cplusplus)
}
#endif 
    
#endif  /* _TCPHDR_H_ */