Transfer TDS login information from a DBLOGINFO structure to a LOGINREC structure.
RETCODE dbsetloginfo(loginrec, loginfo) LOGINREC *login; DBLOGINFO *loginfo;
A pointer to a LOGINREC structure. This pointer will be passed as an argument to dbopen. You can allocate a LOGINREC structure by calling dblogin.
A pointer to a DBLOGINFO structure that contains login parameter information.
SUCCEED or FAIL.
dbsetloginfo transfers TDS login information from a DBLOGINFO structure to a LOGINREC structure. After the information is transferred, dbsetloginfo frees the DBLOGINFO structure.
An application needs to call dbsetloginfo only if (1) it is an Open Server gateway application and (2) it is using TDS passthrough.
TDS (Tabular Data Stream) is an application protocol used for the transfer of requests and request results between clients and servers.
When a client connects directly to a server, the two programs negotiate the TDS format they will use to send and receive data. When a gateway application uses TDS passthrough, the application forwards TDS packets between the client and a remote server without examining or processing them. For this reason, the remote server and the client must agree on a TDS format to use.
dbsetloginfo is the second of four calls, two of them Server Library calls, that allow a client and remote server to negotiate a TDS format. The calls, which can only be made in a SRV_CONNECT event handler, are described here:
srv_getloginfo allocates a DBLOGINFO structure and fills it with TDS information from a client SRV_PROC.
dbsetloginfo transfers the TDS information retrieved by srv_getloginfo from the DBLOGINFO structure to a DB-Library/C LOGINREC structure, and then frees the DBLOGINFO structure. After the information is transferred, the application can use this LOGINREC structure in the dbopen call that establishes its connection with the remote server.
dbgetloginfo transfers the remote server’s response to the client’s TDS information from a DBPROCESS structure into a newly-allocated DBLOGINFO structure.
srv_setloginfo sends the remote server’s response, retrieved by dbgetloginfo, to the client, and then frees the DBLOGINFO structure.
This is an example of a SRV_CONNECT handler preparing a remote connection for TDS passthrough:
RETCODE connect_handler(srvproc)
SRVPROC *srvproc;
{
SYBLOGINFO *loginfo;
LOGINREC *loginrec;
DBPROCESS *dbproc;
/*
** Get the TDS login information from the
** client SRV_PROC.
*/
srv_getloginfo(srvproc, &loginfo);
/* Get a LOGINREC structure */
loginrec = dblogin();
/*
** Initialize the LOGINREC with the logininfo
** from the SRV_PROC.
*/
dbsetloginfo(loginrec, loginfo);
/* Connect to the remote server */
dbproc = dbopen(loginrec, REMOTE_SERVER_NAME)
/*
** Get the TDS login response informationfrom
** the remote connection.
*/
dbgetloginfo(dbproc, &loginfo);
/*
** Return the login response information to
** the SRV_PROC.
*/
srv_setloginfo(srvproc, loginfo);
/* Accept the connection and return */
srv_senddone(srvproc, 0, 0, 0);
return(SRV_CONTINUE);
}