User Functions
This chapter describes the user functions used in SNA LU 0 and SNA LU 6.2.
1. SNA LU 0
Header File
The following is the header file for using user functions.
<lu0gw_prototype.h>
#ifndef _LU0GW_PROTOTYPE_H_ #define _LU0GW_PROTOTYPE_H_ #ifndef _WIN32 int get_msg_info(char *header, char *snddata, char *rcvdata); #endif #endif /* _LU0GW_PROTOTYPE_H_ */
Source Code File
The following is the source code file for using user functions.
<custom.c>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <sys/types.h>
#include "lu0gw_prototype.h"
/* ---------------------------------------------------------------
get_msg_info: This function is called when a response data is received from the host.
header : User header, NULL check is required
snddata : Data to be sent to the host.
rcvdata : Data to be received from the host.
return : A message is normally returned when the value is greater than 0.
If it is 0, the data received from the host is discarded. (treated as NOREPLY)
If it is -1, the data received from the host is discarded. (Continues to wait for a message)
--------------------------------------------------------------- */
int get_msg_info(char *header, char *snddata, char *rcvdata)
{
/* If there is no data to send: already timed out */
if (snddata == NULL)
return 1; /* must 1 return */
return 1;
}
2. SNA LU 6.2
Header File
The following is the header file for using user functions.
<lu62sgw_prototype.h>
#ifndef _LU62SGW_PROTOTYPE_H_ #define _LU62SGW_PROTOTYPE_H_ #ifndef _WIN32 int get_wsname(char *uhead, char *wsname); int get_msg_info(char *data, int len); int put_msg_info(char *data, int len, char *luname); int get_msg_info2(TPGWINFO_T *gwinfo, char *data, int len); int put_msg_info2(TPGWINFO_T *gwinfo, char *data, int len, char *luname); #endif #endif /* _LU62SGW_PROTOTYPE_H_ */
Source Code File
The following is the source code file for using user functions.
<custom.c>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <sys/types.h>
#include <usrinc/atmi.h>
#include <usrinc/hlinkapi.h>
#include "lu62sgw_prototype.h"
/* get_msg_info() return value */
#define DATA_INCOMPLETE 0
#define DATA_COMPLETE 1
/* ---------------------------------------------------------------
To use get_msg_info2/put_msg_info2,
change it to _tmax_custom_version = 2
---------------------------------------------------------------- */
int _tmax_custom_version = 0;
/* ---------------------------------------------------------------
get_wsname : Returns the name of the client who requested a service to
the host from the user header. This function is called before sending data to the hotst.
uhead: User header data
wsname : Buffer to store the client name.
---------------------------------------------------------------- */
int get_wsname(char *uhead, char *wsname)
{
if (uhead == NULL)
return 1;
return 1;
}
/* ---------------------------------------------------------------
get_msg_info : This function allows user to process the data to
be received from the host. In an interactive mode,
the end of successive messages must be returned.
The data to be received from the host is EBCDIC code.
If the host calls dealloc, the data will be processed
via DATA_COMPLETE even if this function returns
DATA_INCOMPLETE.
data: Data received from the host
len : Length of data received from the host
return: Completed to receive the data (DATA_COMPLETE), Not completed to receive the data (DATA_INCOMPLETE)
---------------------------------------------------------------- */
int get_msg_info(char *data, int len)
{
return DATA_COMPLETE;
}
/* ---------------------------------------------------------------
put_msg_info : This function allows user process data before
they are sent to the host.
data: Data sent to the host.
len : Length of data sent to the host
luname : LU name sent to the host
return : If this function succeeds, the length of the actual data to be sent
to the host is returned.
If this function returns -1,
it does not send the data to the host bue returns it to the client.
---------------------------------------------------------------- */
int put_msg_info(char *data, int len, char *luname)
{
return len;
}
/* ---------------------------------------------------------------
get_msg_info2 : This function allows user to process the data to
be received from the host. In an interactive mode,
the end of successive messages must be returned.
The data to be received from the host is EBCDIC code.
If the host calls dealloc, the data will be processed
via DATA_COMPLETE even if this function returns
DATA_INCOMPLETE.
gwinfo: TPGWINFO_T information structure
data: Data received from the host
len : Length of data received from the host.
return : Completed to receive the data (DATA_COMPLETE), Not completed to receive the data (DATA_INCOMPLETE)
---------------------------------------------------------------- */
int get_msg_info2(TPGWINFO_T *gwinfo, char *data, int len)
{
return DATA_COMPLETE;
}
/* ---------------------------------------------------------------
put_msg_info2 : This function allows user process data before
they are sent to a host.
gwinfo: TPGWINFO_T information structure
data: Data sent to the host.
len : Length of data sent to the host.
luname : LU name to be sent to the host.
return : If this function succeeds, the length of the actual data to be sent
to a host is returned.
If this function returns -1,
it does not send the data to the host but returns it to the client.
---------------------------------------------------------------- */
int put_msg_info2(TPGWINFO_T *gwinfo, char *data, int len, char *luname)
{
return len;
}