#endif
/* Indicate that we are a C module for any header specifics.
*/
#define TEST_MON_C
/* Bring in local specific header files.
*/
#include "test_mon.h"
/******************************************************************************
* Function: _HTML_GetHandler
* Description: Call back to override default HTML GET handler. This function
* works out what the client browser requires and tries to
* satisfy it.
*
* Returns: R_OK - Configuration obtained.
* R_FAIL - Failure, see error message.
******************************************************************************/
int _HTML_GetHandler( UINT nChanId, /* I: Channel Id of new con */
UCHAR *szData, /* I: Data received by WWW */
UINT nMonPort ) /* I: Monitor Port Number */
{
/* Local variables.
*/
int nCnt=0;
int nChar;
UINT nPos = 0;
UINT nTokType;
UCHAR *spEndStr;
UCHAR *spMsgBuf = NULL;
UCHAR szFileName[MAX_FILENAMELEN+1];
char *szFunc = "_HTML_GetHandler";
FILE *fp;
/* Log a debug message to indicate details of this connection.
*/
Lgr(LOG_DEBUG, szFunc,
"GET Handler called: Data=%s, nChanId=%d, MonPort=%d\n",
szData, nChanId, nMonPort);
/* Setup HTML content type.
*/
ML_Send(nChanId, "Content-type: text/html\n\n", 0);
/* Scan the buffer for the recognised browser end of stream:
* HTTP/version. If it doesn't exist, send an error message to client
* and exit.
*/
if( (spMsgBuf=(UCHAR *)malloc((strlen(szData)*3)+1)) == NULL )
{
/* Get out with a failure, memory exhausted.
*/
ML_Send(nChanId, "Out of Memory"
"Out of Memory, Re-Try Later/n/n", 0);
if(spMsgBuf != NULL) free(spMsgBuf);
return(R_FAIL);
}
if((spEndStr=strstr(szData, "HTTP")) != NULL)
{
/* Command we are required to understand lies between the beginning
* of the buffer and where HTTP starts, extract it.
*/
FFwdOverWhiteSpace(szData, &nPos);
strncpy(spMsgBuf, &szData[nPos], ((spEndStr - szData)-nPos));
spMsgBuf[(spEndStr - szData)-nPos] = '\0';
} else
{
/* Dispatch an error message to the client as their is not much
* we can do.
*/
ML_Send(nChanId, "Illegal HTML"
"The HTML that your browser issued is illegal, or it is from"
" a newer version not supported by this product\n\n", 0);
return(R_FAIL);
}
/* Trim off the fat and open file.
*/
strcpy(szFileName, StrRTrim(spMsgBuf));
if((fp=fopen(szFileName, "r")) == NULL)
{
sprintf(spMsgBuf, "Cannot access %s"
"File Not Available
\n"
"The file requested (%s) cannot be accessed.\n\n",
szFileName, szFileName);
ML_Send(nChanId, spMsgBuf, 0);
return(R_FAIL);
} else
{
/* Crude but effective, read 1 byte at a time and fire it off,
* wrapped in a HTML structure.
*/
ML_Send(nChanId, "\n\n", 0);
spMsgBuf[1]='\0';
while((nChar=fgetc(fp)) != EOF)
{
nCnt++;
spMsgBuf[0]=nChar;
ML_Send(nChanId, spMsgBuf, 1);
}
ML_Send(nChanId, "", 0);
fclose(fp);
}
/* All done, get out!
*/
return(R_OK);
}
/******************************************************************************
* Function: _HTML_ConnectCB
* Description: Call back for when an incoming WWW browser makes a connection
* with us.
*
* Returns: R_OK - Configuration obtained.
* R_FAIL - Failure, see error message.
******************************************************************************/
int _HTML_ConnectCB( UINT nChanId, /* I: Channel Id of new con */
UINT nMonPort ) /* I: Monitor Port Number */
{
/* Local variables.
*/
char *szFunc = "_HTML_ConnectCB";
/* Log a debug message to indicate details of this connection.
*/
Lgr(LOG_DEBUG, szFunc, "New Connection: ChanID=%d, MonPort=%d\n",
nChanId, nMonPort);
/* All done, get out!
*/
return;
}
/******************************************************************************
* Function: _HTML_DisconnectCB
* Description: Call back for when an existing WWW browser connection ceases
* to exist.
*
* Returns: R_OK - Configuration obtained.
* R_FAIL - Failure, see error message.
******************************************************************************/
int _HTML_DisconnectCB( UINT nChanId, /* I: Channel Id of new con */
UINT nMonPort ) /* I: Monitor Port Number */
{
/* Local variables.
*/
char *szFunc = "_HTML_DisconnectCB";
/* Log a debug message to indicate details of this connection.
*/
Lgr(LOG_DEBUG, szFunc, "Connection Closed: ChanID=%d, MonPort=%d\n",
nChanId, nMonPort);
/* All done, get out!
*/
return;
}
/******************************************************************************
* Function: _NL_HelpHandler
* Description: Call back to implement a HELP feature in the natural
* language command interface. This command basically lists
* global or specific help according to the arguments of the
* command and fires it back to the client.
*
* Returns: R_OK - Configuration obtained.
* R_FAIL - Failure, see error message.
******************************************************************************/
int _NL_HelpHandler( UINT nChanId, /* I: Channel Id of new con */
UCHAR *szData, /* I: Data received by WWW */
UINT nMonPort ) /* I: Monitor Port Number */
{
/* Local variables.
*/
char *szFunc = "_NL_HelpHandler";
/* Log a debug message to indicate details of this connection.
*/
Lgr(LOG_DEBUG, szFunc,
"Help Handler called: Data=%s, nChanId=%d, MonPort=%d\n",
szData, nChanId, nMonPort);
/* All done, get out!
*/
return(R_OK);
}
/******************************************************************************
* Function: _NL_ConnectCB
* Description: Call back for when an incoming WWW browser makes a connection
* with us.
*
* Returns: R_OK - Configuration obtained.
* R_FAIL - Failure, see error message.
******************************************************************************/
int _NL_ConnectCB( UINT nChanId, /* I: Channel Id of new con */
UINT nMonPort ) /* I: Monitor Port Number */
{
/* Local variables.
*/
char *szFunc = "_NL_ConnectCB";
/* Log a debug message to indicate details of this connection.
*/
Lgr(LOG_DEBUG, szFunc, "New Connection: ChanID=%d, MonPort=%d\n",
nChanId, nMonPort);
/* All done, get out!
*/
return;
}
/******************************************************************************
* Function: _NL_DisconnectCB
* Description: Call back for when an existing WWW browser connection ceases
* to exist.
*
* Returns: R_OK - Configuration obtained.
* R_FAIL - Failure, see error message.
******************************************************************************/
int _NL_DisconnectCB( UINT nChanId, /* I: Channel Id of new con */
UINT nMonPort ) /* I: Monitor Port Number */
{
/* Local variables.
*/
char *szFunc = "_NL_DisconnectCB";
/* Log a debug message to indicate details of this connection.
*/
Lgr(LOG_DEBUG, szFunc, "Connection Closed: ChanID=%d, MonPort=%d\n",
nChanId, nMonPort);
/* All done, get out!
*/
return;
}
/******************************************************************************
* Function: GetConfig
* Description: Get configuration information from the OS or command line
* flags.
*
* Returns: R_OK - Configuration obtained.
* R_FAIL - Failure, see error message.
******************************************************************************/
int GetConfig( int argc, /* I: CLI argument count */
UCHAR **argv, /* I: CLI argument contents */
char **envp, /* I: Environment variables */
UCHAR *szErrMsg ) /* O: Any generated error message */
{
/* Local variables.
*/
int nReturn = R_OK;
FILE *fp;
UCHAR *szFunc = "GetConfig";
/* See if the user wishes to use a logfile?
*/
if( GetCLIParam(argc, argv, FLG_LOGFILE, T_STR, TMON.szLogFile,
MAX_LOGFILELEN, FALSE) == R_OK )
{
/* Check to see if the filename is valid.
*/
if((fp=fopen(TMON.szLogFile, "a")) == NULL)
{
sprintf(szErrMsg, "Cannot write to logfile (%s)", TMON.szLogFile);
return(R_FAIL);
}
/* Close the file as test complete.
*/
fclose(fp);
} else
{
/* Set logfile to a default, dependant on OS.
*/
strcpy(TMON.szLogFile, DEF_LOGFILE);
}
/* Get log mode from command line.
*/
if(GetCLIParam(argc, argv, FLG_LOGMODE, T_INT, (UCHAR *)&TMON.nLogMode,
0, 0) == R_OK)
{
/* Check the validity of the mode.
*/
if((TMON.nLogMode < LOG_OFF || TMON.nLogMode > LOG_FATAL) &&
TMON.nLogMode != LOG_CONFIG)
{
sprintf(szErrMsg, "Illegal Logger mode (%d)", TMON.nLogMode);
return(R_FAIL);
}
} else
{
/* Setup default log mode.
*/
TMON.nLogMode = LOG_DEBUG;
}
/* Get the port to be used for HTML monitoring.
*/
if(GetCLIParam(argc, argv, FLG_HTMLPORT, T_INT, (UCHAR *)&TMON.nHtmlPort,
0, 0) == R_OK)
{
/* Check the validity of the port.
*/
if((TMON.nHtmlPort < 2000 || TMON.nHtmlPort > 10000))
{
sprintf(szErrMsg, "Illegal HTML TCP Port (%d)", TMON.nHtmlPort);
return(R_FAIL);
}
} else
{
/* Setup default port.
*/
TMON.nHtmlPort = DEF_HTML_PORT;
}
/* Get the port to be used for HTML monitoring.
*/
if(GetCLIParam(argc, argv, FLG_NLPORT, T_INT, (UCHAR *)&TMON.nNLPort,
0, 0) == R_OK)
{
/* Check the validity of the port.
*/
if((TMON.nNLPort < 2000 || TMON.nNLPort > 10000))
{
sprintf(szErrMsg, "Illegal Natural Language TCP Port (%d)",
TMON.nNLPort);
return(R_FAIL);
}
} else
{
/* Setup default port.
*/
TMON.nNLPort = DEF_NL_PORT;
}
/* Finished, get out!
*/
return( nReturn );
}
/******************************************************************************
* Function: TMONInit
* Description: Initialisation of variables, functionality, communications etc.
*
* Returns: VDWD_OK - Initialised successfully.
* VDWD_FAIL - Failure, see error message.
******************************************************************************/
int TMONInit( UCHAR *szErrMsg ) /* O: Generated error message */
{
/* Local variables.
*/
char *szFunc = "TMONInit";
/* Setup logger mode.
*/
Lgr(LOG_CONFIG, LGM_FLATFILE, TMON.nLogMode, TMON.szLogFile);
/* Initialise Socket Library.
*/
if(SL_Init(TMON_SRV_KEEPALIVE, (UCHAR *)NULL) != R_OK)
{
sprintf(szErrMsg, "SL_Init failed");
Lgr(LOG_DEBUG, szFunc, szErrMsg);
return(R_FAIL);
}
/* Initialise Monitor Library for HTML servicing.
*/
if(ML_Init(TMON.nHtmlPort, MON_SERVICE_HTML, "Test Monitor Program (HTML)",
_HTML_ConnectCB, _HTML_DisconnectCB, NULL) == R_FAIL)
{
sprintf(szErrMsg, "ML_Init failed for HTML service");
Lgr(LOG_DEBUG, szFunc, szErrMsg);
return(R_FAIL);
}
/* Initialise Monitor Library for Natural Language servicing.
*/
if(ML_Init(TMON.nNLPort, MON_SERVICE_NL, "Test Monitor Program (NL)",
_NL_ConnectCB, _NL_DisconnectCB, NULL) == R_FAIL)
{
sprintf(szErrMsg, "ML_Init failed for NL service");
Lgr(LOG_DEBUG, szFunc, szErrMsg);
return(R_FAIL);
}
/* Add test commands for HTML.
*/
ML_AddMonCommand(TMON.nHtmlPort, MC_HTMLGET, _HTML_GetHandler);
/* Add test commands for Natural Language.
*/
ML_AddMonCommand(TMON.nNLPort, MC_NLHELP, _NL_HelpHandler);
/* All done, lets get out.
*/
return(R_OK);
}
/******************************************************************************
* Function: TMONClose
* Description: Function to perform closure of all used resources within the
* program.
*
* Returns: R_OK - Closed successfully.
* R_FAIL - Failure, see error message.
******************************************************************************/
int TMONClose( UCHAR *szErrMsg ) /* O: Generated error message */
{
/* Local variables.
*/
char *szFunc = "TMONClose";
/* Call monitor library to close and tidy up.
*/
if(ML_Exit(NULL) == R_FAIL)
{
Lgr(LOG_DEBUG, szFunc, "Failed to close Monitor Library");
}
/* Exit with success.
*/
return(R_OK);
}
/******************************************************************************
* Function: main
* Description: Entry point into the Monitor facility Test program. Basic
* purpose is to invoke intialisation, enter the main program
* loop and finally tidy up and close down.
*
* Returns: 0 - Program completed successfully without errors.
* -1 - Program terminated with errors, see logged message.
******************************************************************************/
int main( int argc, /* I: Count of available arguments */
char **argv, /* I: Array of arguments */
char **envp ) /* I: Array of environment parameters */
{
/* Local variables.
*/
UCHAR szErrMsg[MAX_ERRMSG_LEN];
UCHAR *szFunc = "main";
/* Bring in any configuration parameters passed on the command line etc.
*/
if( GetConfig(argc, (UCHAR **)argv, envp, szErrMsg) == R_FAIL )
{
printf( "%s\n"
"Usage: %s \n"
": -l\n"
" -m\n"
" -html_port\n"
" -nl_port\n",
szErrMsg, argv[0]);
}
/* Initialise variables, communications etc.
*/
if( TMONInit(szErrMsg) == R_FAIL )
{
/* Log an error message to indicate reason for failure.
*/
Lgr(LOG_DIRECT, szFunc, "%s: %s", argv[0], szErrMsg);
exit(-1);
}
/* Do nothing basically, where testing monitor functionality, so just loop.
*/
while(TRUE)
{
SL_Poll(DEF_POLLTIME);
}
/* Perform close down of used facilities ready for exit.
*/
if( TMONClose(szErrMsg) == R_FAIL )
{
/* Log an error message to indicate reason for failure.
*/
Lgr(LOG_DIRECT, szFunc, "%s: %s", argv[0], szErrMsg);
exit(-1);
}
/* All done, go bye bye's.
*/
#if defined(SOLARIS) || defined(SUNOS) || defined(LINUX) || defined(ZPU)
exit;
#endif
#if defined(_WIN32)
return(0);
#endif
}
````
## SDD Library
The Server Data-source Driver library is a set of API's for communicating with a data source. Currently drivers have been written for:
- Audio Playback - not technically a data source, more a data target but the SDD library is bi-directional in nature.
- FTP - allows data to be transmitted and received from a remote source via the File Transfer Protocol.
- Java - allows a java program to be run on a remote source to provide and receive data. Useful when a data source is not standard.
- ODBC - allows connection to any database supported by the Open Database Connectivity drivers.
- SCMD - System Commands, allows a System (Linux, Solaris, Windows) command to be run on a remote server to extract or receive data.
- SYBC - Sybase database, allows native connection to a Sybase database for data storage and extraction.
Additonal drivers can be written using the templates in the templates/ directory.
The drivers are opened via the MDC layer or directly in an application wishing to use a given data source (ie. an admin application issuing commands to a remote server via the SCMD driver - an early version of Ansible!).
The methods in the SDD Library are described below ordered by the driver to which they belong. If a method begins with '_' then it is internal and normally not called directly, albeit being C there is no Private definition to methods or their data so you can call them if it helps.
### Audio driver sdd_aupl
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_AUPL_GetStrArg**|
|Description: |Function to scan an input buffer and extract a string based argument. |
|Returns: |SDD_FAIL- Couldn't obtain argument.
SDD_OK - Argument obtained. |
|Prototype: |`int _AUPL_GetStrArg( UCHAR *snzDataBuf /* I: Input buffer */, int nDataLen /* I: Len of data */, UCHAR *szArg /* I: Arg to look for */, UCHAR **pszPath ) /* O: Pointer to argument */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_AUPL_ValidatePath**|
|Description: |Function to validate the existence of a path. |
|Returns: |SDD_FAIL- Couldn't validate PATH.
SDD_OK - PATH validated. |
|Prototype: |`int _AUPL_ValidatePath( UCHAR *pszPath ) /* I: Path to validate */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_AUPL_ValidateFile**|
|Description: |Function to validate the existence of a file or to validate that a file can be created. |
|Returns: |SDD_FAIL- Couldn't obtain Filename or validate it.
SDD_OK - Filename obtained and validated. |
|Prototype: |`int _AUPL_ValidateFile( UCHAR *pszPath /* I: Path to file */, UCHAR *pszFile /* I: File to validate */, UINT nWriteFlag ) /* I: Read = 0, Write = 1 */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_AUPL_PlayZ**|
|Description: |Function to play a compressed audio file. Method of attach is to launch a child which is the actual decompressor, this feeds data back via the stdout of the child to our stdin. The data is then buffered in a round robin fashion and fed to the audio DSP hardware. |
|Returns: |SDD_FAIL- Command failed during execution.
SDD_OK - Command executed successfully. |
|Prototype: |`int _AUPL_PlayZ( UCHAR *pszAudioPath /* I: Path to Audio File */, UCHAR *pszAudioFile /* I: Audio Filename */, int (*fSendDataCB)(UCHAR *, UINT) /* I: Func for returning data */, UCHAR *szErrMsg ) /* O: Error message generated */`jjjjj |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**aupl_InitService**|
|Description: |Entry point which initialises the driver into a defined state. It is mandatory that this function is called before any other in order for the driver to function correctly. The caller provides it with two types of data, 1) A structure containing data for it to use in initialising itself, 2) a pointer to a buffer which the driver uses to place an error message should it not be able to complete initialisation. |
|Returns: |SDD_FAIL- An error occurred in initialising the driver and an error message is stored in szErrStr.
SDD_OK - Driver initialised successfully. |
|Prototype: |`int aupl_InitService( SERVICEDETAILS *sServiceDet /* I: Init data */, UCHAR *szErrStr ) /* O: Error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**aupl_CloseService**|
|Description: |Entry point which performs a drive closedown. The closedown procedure ensure that the driver returns to a virgin state (ie.like at power up) so that InitService can be called again. |
|Returns: |SDD_FAIL- An error occurred in closing the driver and an error message is stored in szErrStr.
SDD_OK - Driver successfully closed. |
|Prototype: |`int aupl_CloseService( UCHAR *szErrMsg ) /* O: Error message if failed */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**aupl_ProcessRequest**|
|Description: |Entry point into driver to initiate the driver into processing a request. A data block is passed as a parameter to the driver which represents a request with relevant parameters. The data within the structure is only relevant to the original client and this driver code. |
|Returns: |SDD_FAIL- An error occurred within the driver whilst trying to process the request, see error text.
SDD_OK - Request processed successfully. |
|Prototype: |`int aupl_ProcessRequest( UCHAR *snzDataBuf /* I: Input data */, int nDataLen /* I: Len of data */, int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send reply*/, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**aupl_ProcessOOB**|
|Description: |Entry point into driver to process an out of band command that may or may not be relevant to current state of operation. The task of this function is to decipher the command and act on it immediately, ie. a cancel command would abort any ProcessRequest that is in process and clean up. |
|Returns: |No returns. |
|Prototype: |`void aupl_ProcessOOB( UCHAR nCommand ) /* I: OOB Command */` |
### FTP Protocol driver sdd_ftpx
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_GetStrArg**|
|Description: |Function to scan an input buffer and extract a string based argument. |
|Returns: |SDD_FAIL- Couldn't obtain argument.
SDD_OK - Argument obtained. |
|Prototype: |`int _FTPX_GetStrArg( UCHAR *snzDataBuf /* I: Input buffer */, int nDataLen /* I: Len of data */, UCHAR *szArg /* I: Arg to look for */, UCHAR **pszPath ) /* O: Pointer to argument */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_GetMode**|
|Description: |Function to scan an input buffer and determine the mode of FTP operation that the caller requires (Binary or Ascii). If no mode is provided then default to binary. |
|Returns: |Mode Flag - 1 = Binary mode selected.
- 0 = Ascii mode selected. |
|Prototype: |`int _FTPX_GetMode( UCHAR *snzDataBuf /* I: Input buffer */, int nDataLen ) /* I: Len of data */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_GetWriteData**|
|Description: |Function to scan an input buffer, verify that it has data in it, extract the data and store in the opened file stream and set the start flag if the block is the final block. |
|Returns: |SDD_FAIL- Bad block of data or error writing to file.
SDD_OK - Block obtained and stored. |
|Prototype: |`int _FTPX_GetWriteData( UCHAR *snzDataBuf /* I: Input buffer */, int nDataLen /* I: Len of data */, FILE *fpFile /* IO: Opened file stream */, int *nLast /* O: Last block flag */, UCHAR *szErrMsg ) /* O: Any resultant error msg */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_PutReadData**|
|Description: |Function to read an open stream and transmit the data contents to the caller via the callback mechanism. |
|Returns: |SDD_FAIL- Couldn't obtain PATH.
SDD_OK - PATH obtained. |
|Prototype: |`int _FTPX_PutReadData( FILE *fpFile /* I: Stream to read from */, int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send data to */, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_PIDataCB**|
|Description: |Function to handle any control information passed back from the FTP server. |
|Returns: |No returns. |
|Prototype: |`void _FTPX_PIDataCB( UINT nChanId /* I: Channel data arrived on */, UCHAR *szData /* I: Actual data */, UINT nDataLen ) /* I: Length of data */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_PICtrlCB**|
|Description: |Function to handle any control callbacks during connectivity with the FTP server. |
|Returns: |No returns. |
|Prototype: |`void _FTPX_PICtrlCB( int nType /* I: Type of callback */, ... ) /* I: Var args */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_DTPDataCB**|
|Description: |Function to handle any data passed back from the FTP server on the data transfer connection.. |
|Returns: |No returns. |
|Prototype: |`void _FTPX_DTPDataCB( UINT nChanId /* I: Channel data arrived on */, UCHAR *szData /* I: Actual data */, UINT nDataLen ) /* I: Length of data */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_DTPCtrlCB**|
|Description: |Function to handle any control callbacks on the Data Transfer connection with the FTP server. |
|Returns: |No returns. |
|Prototype: |`void _FTPX_DTPCtrlCB( int nType /* I: Type of callback */, ... ) /* I: Var args */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_PIGetResponse**|
|Description: |Function to get a response code from the FTP server. |
|Returns: |Response Code. |
|Prototype: |`int _FTPX_PIGetResponse( void )` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_PISendCmd**|
|Description: |Function to send a command to an FTP server. |
|Returns: |SDD_FAIL - FTP Server failed to respond, see szErrMsg.
SDD_OK - Command sent successfully. |
|Prototype: |`int _FTPX_PISendCmd( UCHAR *szCmd /* I: Command to send */, UINT *panReqResponses /* I: Array of req resp */, UCHAR *szErrMsg ) /* O: Error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_PIGetDTPResponse**|
|Description: |Function to get a response code during a DTP transfer. |
|Returns: |Response Code. |
|Prototype: |`int _FTPX_PIGetDTPResponse( void )` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_PISendDTPCmd**|
|Description: |Function to send a command to an FTP server which will invoke a DTP channel for data transfer. |
|Returns: |SDD_FAIL - FTP Server failed to respond, see szErrMsg.
SDD_OK - Command sent successfully. |
|Prototype: |`int _FTPX_PISendDTPCmd( UCHAR *szCmd /* I: Command to send */, UINT *panReqResponses /* I: Allowed responses */, UCHAR *szErrMsg ) /* O: Error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_SetMode**|
|Description: |Function to setup the transfer mode between the FTP server and the driver. |
|Returns: |SDD_FAIL - Failed to set transfer mode, critical error.
SDD_OK - Mode set. |
|Prototype: |`int _FTPX_SetMode( UINT nBinaryMode /* I: Select binary mode = TRUE */, UCHAR *szErrMsg ) /* O: Generated error messages */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_SetCwd**|
|Description: |Function to set the FTP servers current working directory. |
|Returns: |SDD_FAIL - Failed to set directory to that specified.
SDD_OK - Current Working Directory set. |
|Prototype: |`int _FTPX_SetCwd( UCHAR *szPath /* I: Path to set CWD */, UCHAR *szErrMsg ) /* O: Generated error messages */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_FTPInit**|
|Description: |Function to initialise a connection with an FTP server. The caller provides the name/IP address of the server and the user name/password to complete the connection. |
|Returns: |SDD_FAIL - Couldn't make connection with given details.
SDD_OK - FTP connection made. |
|Prototype: |`int _FTPX_FTPInit( UCHAR *szFTPServer /* I: Name of FTP server */, UCHAR *szUserName /* I: User name to login with */, UCHAR *szPassword /* I: Password for login */, UCHAR *szErrMsg ) /* O: Error message if failed */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_FTPClose**|
|Description: |Function to close a connected FTP connection and tidy up in preparation for next task. |
|Returns: |SDD_FAIL - Failed to close properly, library won't work again.
SDD_OK - Closed. |
|Prototype: |`int _FTPX_FTPClose( UCHAR *szErrMsg ) /* O: Generated error messages */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_FTPRenFile**|
|Description: |Function to rename a file on a remote FTP server. |
|Returns: |SDD_FAIL - Failed to rename the required file.
SDD_OK - File renamed successfully. |
|Prototype: |`int _FTPX_FTPRenFile( UCHAR *szPath /* I: Path to remote file */, UCHAR *szSrcFile /* I: Original remote file name */, UCHAR *szDstFile /* I: New remote file name */, UCHAR *szErrMsg ) /* O: Generated error messages */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_FTPRcvFile**|
|Description: |Function to initiate a file transfer from the FTP server to the current machine file system. |
|Returns: |SDD_FAIL - Failed to complete file transfer.
SDD_OK - File received successfully. |
|Prototype: |`int _FTPX_FTPRcvFile( UCHAR *szRcvFile /* I: Name of file to store in */, UCHAR *szPath /* I: Path to remote file */, UCHAR *szFile /* I: Remote file */, UINT nBinaryMode /* I: Select binary transfer mode */, UCHAR *szErrMsg ) /* O: Generated error messages */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_FTPX_FTPXmitFile**|
|Description: |Function to initiate a file transfer from the current machine file system to the FTP server. |
|Returns: |SDD_FAIL - Failed to complete file transfer.
SDD_OK - File transmitted successfully. |
|Prototype: |`int _FTPX_FTPXmitFile( UCHAR *szXmitFile /* I: Name of file to transmit */, UCHAR *szPath /* I: Path to remote destination */, UCHAR *szFile /* I: Remote file */, UINT nBinaryMode /* I: Select binary transfer Mode */, UCHAR *szErrMsg ) /* O: Generated error messages */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**ftpx_InitService**|
|Description: |Entry point which initialises the driver into a defined state. It is mandatory that this function is called before any other in order for the driver to function correctly. The caller provides it with two types of data, 1) A structure containing data for it to use in initialising itself, 2) a pointer to a buffer which the driver uses to place an error message should it not be able to complete initialisation. |
|Returns: |SDD_FAIL- An error occurred in initialising the driver and an error message is stored in szErrStr.
SDD_OK - Driver initialised successfully. |
|Prototype: |`int ftpx_InitService( SERVICEDETAILS *sServiceDet /* I: Init data */, UCHAR *szErrStr ) /* O: Error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**ftpx_CloseService**|
|Description: |Entry point which performs a drive closedown. The closedown procedure ensure that the driver returns to a virgin state (ie.like at power up) so that InitService can be called again. |
|Returns: |SDD_FAIL- An error occurred in closing the driver and an error message is stored in szErrStr.
SDD_OK - Driver successfully closed. |
|Prototype: |`int ftpx_CloseService( UCHAR *szErrMsg ) /* O: Error message if failed */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**ftpx_ProcessRequest**|
|Description: |Entry point into driver to initiate the driver into processing a request. A data block is passed as a parameter to the driver which represents a request with relevant parameters. The data within the structure is only relevant to the original client and this driver code. |
|Returns: |SDD_FAIL- An error occurred within the driver whilst trying to process the request, see error text.
SDD_OK - Request processed successfully. |
|Prototype: |`int ftpx_ProcessRequest( UCHAR *snzDataBuf /* I: Input data */, int nDataLen /* I: Len of data */, int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send reply*/, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**ftpx_ProcessOOB**|
|Description: |Entry point into driver to process an out of band command that may or may not be relevant to current state of operation. The task of this function is to decipher the command and act on it immediately, ie. a cancel command would abort any ProcessRequest that is in process and clean up. |
|Returns: |No returns. |
|Prototype: |`void ftpx_ProcessOOB( UCHAR nCommand ) /* I: OOB Command */` |
### Java driver sdd_java
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**java_InitService**|
|Description: |Entry point which initialises the driver into a defined state. It is mandatory that this function is called before any other in order for the driver to function correctly. The caller provides it with two types of data, 1) A structure containing data for it to use in initialising itself, 2) a pointer to a buffer which the driver uses to place an error message should it not be able to complete initialisation. |
|Returns: |SDD_FAIL- An error occurred in initialising the driver and an error message is stored in szErrStr.
SDD_OK - Driver initialised successfully. |
|Prototype: |`int java_InitService( SERVICEDETAILS *sServiceDet /* I: Init data */, UCHAR *szErrStr ) /* O: Error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**java_CloseService**|
|Description: |Entry point which performs a drive closedown. The closedown procedure ensure that the driver returns to a virgin state (ie.like at power up) so that InitService can be called again. |
|Returns: |SDD_FAIL- An error occurred in closing the driver and an error message is stored in szErrStr.
SDD_OK - Driver successfully closed. |
|Prototype: |`int java_CloseService( UCHAR *szErrMsg ) /* O: Error message if failed */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**java_ProcessRequest**|
|Description: |Entry point into driver to initiate the driver into processing a request. A data block is passed as a parameter to the driver which represents a request with relevant parameters. The data within the structure is only relevant to the original client and this driver code. |
|Returns: |SDD_FAIL- An error occurred within the driver whilst trying to process the request, see error text.
SDD_OK - Request processed successfully. |
|Prototype: |`int java_ProcessRequest( UCHAR *snzDataBuf /* I: Input data */, int nDataLen /* I: Len of data */, int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send reply*/, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**java_ProcessOOB**|
|Description: |Entry point into driver to process an out of band command that may or may not be relevant to current state of operation. The task of this function is to decipher the command and act on it immediately, ie. a cancel command would abort any ProcessRequest that is in process and clean up. |
|Returns: |No returns. |
|Prototype: |`void java_ProcessOOB( UCHAR nCommand ) /* I: OOB Command */` |
### ODBC driver sdd_odbc
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_ODBC_GetArg**|
|Description: |Function to scan an input buffer and extract a required argument from it. |
|Returns: |SDD_FAIL- Couldn't obtain argument.
SDD_OK - Argument obtained and validated. |
|Prototype: |`int _ODBC_GetArg( UCHAR *szArgType /* I: Type of Arg to scan for */, UCHAR *snzDataBuf /* I: Input buffer */, int nDataLen /* I: Len of data */, UCHAR **pszArg ) /* O: Pointer to Arg */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_ODBC_LogODBCError**|
|Description: |Function to dump an error message/code from the ODBC driver to the log device. Typically used for debugging. |
|Returns: |No returns. |
|Prototype: |`void _ODBC_LogODBCError( HSTMT hStmt )` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_ODBC_RunSql**|
|Description: |Function to execute a given buffer of SQL on the current database and return resultant data to the original caller. |
|Returns: |SDD_FAIL- SQL execution failed, see error message.
SDD_OK - SQL execution succeeded. |
|Prototype: |`int _ODBC_RunSql( UCHAR *snzDataBuf /* I: Input data */, int nDataLen /* I: Len of data */, int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send reply */, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_ODBC_ListDB**|
|Description: |Function to list all the names of databases available on the currently open data source. |
|Returns: |SDD_FAIL- SQL execution failed, see error message.
SDD_OK - SQL execution succeeded. |
|Prototype: |`int _ODBC_ListDB( int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send reply */, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_ODBC_ListTables**|
|Description: |Function to list all names of tables in a given database (or current database if no database name given). |
|Returns: |SDD_FAIL- SQL execution failed, see error message.
SDD_OK - SQL execution succeeded. |
|Prototype: |`int _ODBC_ListTables( UCHAR *snzDataBuf /* I: Input data */, int nDataLen /* I: Len of data */, int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send reply */, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_ODBC_ListCols**|
|Description: |Function to list all names and attributes of columns in a given table in a given database (or current database/table if no database name given). |
|Returns: |SDD_FAIL- SQL execution failed, see error message.
SDD_OK - SQL execution succeeded. |
|Prototype: |`int _ODBC_ListCols( UCHAR *snzDataBuf /* I: Input data */, int nDataLen /* I: Len of data */, int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send reply */, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**odbc_InitService**|
|Description: |Entry point which initialises the driver into a defined state. It is mandatory that this function is called before any other in order for the driver to function correctly. The caller provides it with two types of data, 1) A structure containing data for it to use in initialising itself, 2) a pointer to a buffer which the driver uses to place an error message should it not be able to complete initialisation. |
|Returns: |SDD_FAIL- An error occurred in initialising the driver and an error message is stored in szErrMsg.
SDD_OK - Driver initialised successfully. |
|Prototype: |`int odbc_InitService( SERVICEDETAILS *sServiceDet /* I: Init data */, UCHAR *szErrMsg ) /* O: Error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**odbc_CloseService**|
|Description: |Entry point which performs a drive closedown. The closedown procedure ensure that the driver returns to a virgin state (ie.like at power up) so that InitService can be called again. |
|Returns: |SDD_FAIL- An error occurred in closing the driver and an error message is stored in szErrMsg.
SDD_OK - Driver successfully closed. |
|Prototype: |`int odbc_CloseService( UCHAR *szErrMsg ) /* O: Error message if failed */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**odbc_ProcessRequest**|
|Description: |Entry point into driver to initiate the driver into processing a request. A data block is passed as a parameter to the driver which represents a request with relevant parameters. The data within the structure is only relevant to the original client and this driver code. |
|Returns: |SDD_FAIL- An error occurred within the driver whilst trying to process the request, see error text.
SDD_OK - Request processed successfully. |
|Prototype: |`int odbc_ProcessRequest( UCHAR *snzDataBuf /* I: Input data */, int nDataLen /* I: Len of data */, int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send reply*/, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**odbc_ProcessOOB**|
|Description: |Entry point into driver to process an out of band command that may or may not be relevant to current state of operation. The task of this function is to decipher the command and act on it immediately, ie. a cancel command would abort any ProcessRequest that is in process and clean up. |
|Returns: |No returns. |
|Prototype: |`void odbc_ProcessOOB( UCHAR nCommand ) /* I: OOB Command */` |
### SCMD driver sdd_scmd
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_SCMD_GetStrArg**|
|Description: |Function to scan an input buffer and extract a string based argument. |
|Returns: |SDD_FAIL- Couldn't obtain argument.
SDD_OK - Argument obtained. |
|Prototype: |`int _SCMD_GetStrArg( UCHAR *snzDataBuf /* I: Input buffer */, int nDataLen /* I: Len of data */, UCHAR *szArg /* I: Arg to look for */, UCHAR **pszPath ) /* O: Pointer to argument */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_SCMD_ValidatePath**|
|Description: |Function to validate the existence of a path. |
|Returns: |SDD_FAIL- Couldn't validate PATH.
SDD_OK - PATH validated. |
|Prototype: |`int _SCMD_ValidatePath( UCHAR *pszPath ) /* I: Path to validate */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_SCMD_ValidateFile**|
|Description: |Function to validate the existence of a file or to validate that a file can be created. |
|Returns: |SDD_FAIL- Couldn't obtain Filename or validate it.
SDD_OK - Filename obtained and validated. |
|Prototype: |`int _SCMD_ValidateFile( UCHAR *pszPath /* I: Path to file */, UCHAR *pszFile /* I: File to validate */, UINT nWriteFlag ) /* I: Read = 0, Write = 1 */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_SCMD_ValidateTime**|
|Description: |Function to validate a time value given as an ascii string. |
|Returns: |SDD_FAIL- Couldn't obtain a TIME or validate it.
SDD_OK - TIME obtained and validated. |
|Prototype: |`int _SCMD_ValidateTime( UCHAR *pszTime /* I: Time to verify */, ULNG *lTime ) /* O: Time in seconds */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_SCMD_Exec**|
|Description: |Function to execute a given command via a fork and exec, attaching the parent to the childs I/O so that any data output by the child can be captured by the parent and fed back to the caller. |
|Returns: |SDD_FAIL- Command failed during execution.
SDD_OK - Command executed successfully. |
|Prototype: |`int _SCMD_Exec( int nTimedExec /* I: Is this a timed exec (T/F)? */, UCHAR *pszPath /* I: Path to command */, UCHAR *pszCmd /* I: Command name */, UCHAR *pszArgs /* I: Arguments to command */, ULNG lTimeToExec /* I: Time to execution */, int (*fSendDataCB)(UCHAR *, UINT) /* I: Func for returning data */, UCHAR *szErrMsg ) /* O: Error message generated */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_SCMD_GetWriteData**|
|Description: |Function to scan an input buffer, verify that it has data in it, extract the data and store in the opened file stream and set the start flag if the block is the final block. |
|Returns: |SDD_FAIL- Bad block of data or error writing to file.
SDD_OK - Block obtained and stored. |
|Prototype: |`int _SCMD_GetWriteData( UCHAR *snzDataBuf /* I: Input buffer */, int nDataLen /* I: Len of data */, FILE *fpFile /* IO: Opened file stream */, int *nLast /* O: Last block flag */, UCHAR *szErrMsg ) /* O: Any resultant error msg */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_SCMD_PutReadData**|
|Description: |Function to read an open stream and transmit the data contents to the caller via the callback mechanism. |
|Returns: |SDD_FAIL- Couldn't obtain PATH.
SDD_OK - PATH obtained. |
|Prototype: |`int _SCMD_PutReadData( FILE *fpFile /* I: Stream to read from */, int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send data to */, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_SCMD_MoveFile**|
|Description: |Function to move a file from one location/name to another. This is performed as a copy and unlink operation because the underlying may not support moves across file systems. |
|Returns: |SDD_FAIL- An error whilst moving file, see szErrMsg.
SDD_OK - File moved successfully. |
|Prototype: |`int _SCMD_MoveFile( UCHAR *pszSrcPath /* I: Path to source file */, UCHAR *pszSrcFile /* I: Source File */, UCHAR *pszDstPath /* I: Path to dest file */, UCHAR *pszDstFile /* I: Dest File */, UCHAR *szErrMsg ) /* O: Error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_SCMD_DeleteFile**|
|Description: |Function to delete a file from the given path. |
|Returns: |SDD_FAIL- An error whilst moving file, see szErrMsg.
SDD_OK - File moved successfully. |
|Prototype: |`int _SCMD_DeleteFile( UCHAR *pszDelPath /* I: Path to file */, UCHAR *pszDelFile /* I: File to delete */, UCHAR *szErrMsg ) /* O: Error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**scmd_InitService**|
|Description: |Entry point which initialises the driver into a defined state. It is mandatory that this function is called before any other in order for the driver to function correctly. The caller provides it with two types of data, 1) A structure containing data for it to use in initialising itself, 2) a pointer to a buffer which the driver uses to place an error message should it not be able to complete initialisation. |
|Returns: |SDD_FAIL- An error occurred in initialising the driver and an error message is stored in szErrStr.
SDD_OK - Driver initialised successfully. |
|Prototype: |`int scmd_InitService( SERVICEDETAILS *sServiceDet /* I: Init data */, UCHAR *szErrStr ) /* O: Error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**scmd_CloseService**|
|Description: |Entry point which performs a drive closedown. The closedown procedure ensure that the driver returns to a virgin state (ie.like at power up) so that InitService can be called again. |
|Returns: |SDD_FAIL- An error occurred in closing the driver and an error message is stored in szErrStr.
SDD_OK - Driver successfully closed. |
|Prototype: |`int scmd_CloseService( UCHAR *szErrMsg ) /* O: Error message if failed */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**scmd_ProcessRequest**|
|Description: |Entry point into driver to initiate the driver into processing a request. A data block is passed as a parameter to the driver which represents a request with relevant parameters. The data within the structure is only relevant to the original client and this driver code. |
|Returns: |SDD_FAIL- An error occurred within the driver whilst trying to process the request, see error text.
SDD_OK - Request processed successfully. |
|Prototype: |`int scmd_ProcessRequest( UCHAR *snzDataBuf /* I: Input data */, int nDataLen /* I: Len of data */, int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send reply*/, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**scmd_ProcessOOB**|
|Description: |Entry point into driver to process an out of band command that may or may not be relevant to current state of operation. The task of this function is to decipher the command and act on it immediately, ie. a cancel command would abort any ProcessRequest that is in process and clean up. |
|Returns: |No returns. |
|Prototype: |`void scmd_ProcessOOB( UCHAR nCommand ) /* I: OOB Command */` |
### Sybase driver sdd_sybc
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_SYBC_GetArg**|
|Description: |Function to scan an input buffer and extract a required argument from it. |
|Returns: |SDD_FAIL- Couldn't obtain argument.
SDD_OK - Argument obtained and validated. |
|Prototype: |`int _SYBC_GetArg( UCHAR *szArgType /* I: Type of Arg to scan for */, UCHAR *snzDataBuf /* I: Input buffer */, int nDataLen /* I: Len of data */, UCHAR **pszArg ) /* O: Pointer to Arg */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_SYBC_RunSql**|
|Description: |Function to execute a given buffer of SQL on the current database and return resultant data to the original caller. |
|Returns: |SDD_FAIL- SQL execution failed, see error message.
SDD_OK - SQL execution succeeded. |
|Prototype: |`int _SYBC_RunSql( UCHAR *snzDataBuf /* I: Input data */, int nDataLen /* I: Len of data */, int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send reply */, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**sybc_InitService**|
|Description: |Entry point which initialises the driver into a defined state. It is mandatory that this function is called before any other in order for the driver to function correctly. The caller provides it with two types of data, 1) A structure containing data for it to use in initialising itself, 2) a pointer to a buffer which the driver uses to place an error message should it not be able to complete initialisation. |
|Returns: |SDD_FAIL- An error occurred in initialising the driver and an error message is stored in szErrStr.
SDD_OK - Driver initialised successfully. |
|Prototype: |`int sybc_InitService( SERVICEDETAILS *sServiceDet /* I: Init data */, UCHAR *szErrStr ) /* O: Error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_SYBC_ListDB**|
|Description: |Function to list all the names of databases available on the currently open data source. |
|Returns: |SDD_FAIL- SQL execution failed, see error message.
SDD_OK - SQL execution succeeded. |
|Prototype: |`int _SYBC_ListDB( int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send reply */, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_SYBC_ListTables**|
|Description: |Function to list all names of tables in a given database (or current database if no database name given). |
|Returns: |SDD_FAIL- SQL execution failed, see error message.
SDD_OK - SQL execution succeeded. |
|Prototype: |`int _SYBC_ListTables( UCHAR *snzDataBuf /* I: Input data */, int nDataLen /* I: Len of data */, int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send reply */, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_SYBC_ListCols**|
|Description: |Function to list all names and attributes of columns in a given table in a given database (or current database/table if no database name given). |
|Returns: |SDD_FAIL- SQL execution failed, see error message.
SDD_OK - SQL execution succeeded. |
|Prototype: |`int _SYBC_ListCols( UCHAR *snzDataBuf /* I: Input data */, int nDataLen /* I: Len of data */, int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send reply */, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**sybc_CloseService**|
|Description: |Entry point which performs a drive closedown. The closedown procedure ensure that the driver returns to a virgin state (ie.like at power up) so that InitService can be called again. |
|Returns: |SDD_FAIL- An error occurred in closing the driver and an error message is stored in szErrStr.
SDD_OK - Driver successfully closed. |
|Prototype: |`int sybc_CloseService( UCHAR *szErrMsg ) /* O: Error message if failed */ |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**sybc_ProcessRequest**|
|Description: |Entry point into driver to initiate the driver into processing a request. A data block is passed as a parameter to the driver which represents a request with relevant parameters. The data within the structure is only relevant to the original client and this driver code. |
|Returns: |SDD_FAIL- An error occurred within the driver whilst trying to process the request, see error text.
SDD_OK - Request processed successfully. |
|Prototype: |`int sybc_ProcessRequest( UCHAR *snzDataBuf /* I: Input data */, int nDataLen /* I: Len of data */, int (*fSendDataCB)(UCHAR *, UINT) /* I: CB to send reply */, UCHAR *szErrMsg ) /* O: Error text */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**sybc_ProcessOOB**|
|Description: |Entry point into driver to process an out of band command that may or may not be relevant to current state of operation. The task of this function is to decipher the command and act on it immediately, ie. a cancel command would abort any ProcessRequest that is in process and clean up. |
|Returns: |No returns. |
|Prototype: |`void sybc_ProcessOOB( UCHAR nCommand ) /* I: OOB Command */` |
## VDW Library
The Virtual Data Warehouse Library was a set of API's to build a Virtual Data Warehouse. Typically these methods are used to build a set of cross platform (Linux, SunOS, Solaris, Windows) daemons each sited on a server with a data source. The daemon would have a set of SDD drivers built in and would open the required data sources and communicate with an application or the MDC layer and serve accordingly.
ie. A SQL Server on Network A, a Sybase Server on Network B, an FTP source on Network C, a VDW daemon would be placed on a server in all the 3 networks and open connections with the data source. Via routing, an MDC application sat on Network D would be able to query all the sources as needed.
At the moment I can see no use for the VDW library in the ZPU Evo but it may be useful if your trying to create a network of decentralized data sources.
The methods in the VDW Library are as follows. If a method begins with '_' then it is internal and normally not called directly, albeit being C there is no Private definition to methods or their data so you can call them if it helps.
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**GetConfig**|
|Description: |Get configuration information from the OS or command line flags. |
|Returns: |VDWD_OK - Configuration obtained.
VDWD_FAIL - Failure, see error message. |
|Prototype: |`int GetConfig( int argc /* I: CLI argument count */. UCHAR **argv /* I: CLI argument contents */, char **envp /* I: Environment variables */, UCHAR *szErrMsg ) /* O: Any generated error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**VDWDInit**|
|Description: |Initialisation of variables, functionality, communications and turning the process into a daemon. |
|Returns: |VDWD_OK - Initialised successfully.
VDWD_FAIL - Failure, see error message. |
|Prototype: |`int VDWDInit( UCHAR *szErrMsg ) /* O: Generated error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**VDWDClose**|
|Description: |Function to perform closure of all used resources within the module. |
|Returns: |VDWD_OK - Closed successfully.
VDWD_FAIL - Failure, see error message. |
|Prototype: |`int VDWDClose( UCHAR *szErrMsg ) /* O: Generated error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**VDWDSentToClient**|
|Description: |Function to send data from this daemon back to the relevant client. |
|Returns: |SDD_OK - Data sent successfully.
SDD_FAIL - Failure in sending data. |
|Prototype: |`int VDWDSendToClient( UCHAR *snzData /* I: Data to send */, UINT nDataLen ) /* I: Length of data */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**VDWDInitService**|
|Description: |Function to call a given drivers initialisation function. |
|Returns: |VDWD_OK - Service was initialised successfully.
VDWD_FAIL - Failure, see error message. |
|Prototype: |`int VDWDInitService( int nServiceType /* I: Type of service*/, SERVICEDETAILS *sServiceDet /* I: Service Data */, UCHAR *szErrMsg ) /* O: Error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**VDWDCloseService**|
|Description: |Function to call a given drivers closedown function. |
|Returns: |VDWD_OK - Service was closed successfully.
VDWD_FAIL - Failure, see error message. |
|Prototype: |`int VDWDCloseService( int nServiceType /* I: Type of service*/, UCHAR *szErrMsg ) /* O: Error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**VDWDProcessRequest**|
|Description: |Function to call a given drivers function to process a service request. |
|Returns: |VDWD_OK - Request was processed successfully.
VDWD_FAIL - Failure, see error message. |
|Prototype: |`int VDWDProcessRequest( int nServiceType /* I: Type of service */, UCHAR *snzData /* I: Data Buffer */, UINT nDataLen /* I: Len of Data */, UCHAR *szErrMsg ) /* O: Error message */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**VDWDDataCallback**|
|Description: |Function which is registered as a callback and is called every time data arrives from a new client. |
|Returns: |MDC_OK - Closed successfully.
MDC_FAIL - Failure, see error message. |
|Prototype: |`int VDWDDataCallback( UCHAR *snzData /* I: Buffer containing data */, int nDataLen /* I: Length of data in buffer */, UCHAR *szErrMsg ) /* O: Error messages generated */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**VDWDOOBCallback**|
|Description: |Function to take action on out of band commands from the MDC layer. Out of band messages are generally commands which need to be actioned upon immediately, so they are passed up into the Drivers out of band processing function. |
|Returns: |No returns. |
|Prototype: |`void VDWDOOBCallback( UCHAR cCmd ) /* I: Command to action upon */` |
## MDC Library
The Meta Data Communications API was part of my Virtual Data Warehouse design which sought to encapsulate disparate systems and data sources and through the MDC API's provide a central uniform way of querying them, ie. Sybase, SQL Server, FTP CSV, Flat File etc. The application would make a normalized request, irrespective of data source, to the MDC layer and the MDC would take care of targetting the correct source and any needed transalations.
At the moment I can see no use for it in the ZPU Evo but it may be useful if your trying to join disparate data sources using the VDW daemons.
The methods in the MDC Library are described below ordered by the functionality to which they belong. If a method begins with '_' then it is internal and normally not called directly, albeit being C there is no Private definition to methods or their data so you can call them if it helps.
### MDC Server API
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_SendACK** |
|Description: |Function to send an acknowledge to the client in response to a data block received correctly or a request processed successfully. |
|Returns: |MDC_FAIL- Couldn't transmit an ACK message to the client.
MDC_OK - ACK sent successfully. |
|Prototype: |`int _MDC_SendACK( void )` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_SendNAK** |
|Description: |Function to send a negative acknowledge to the client in to a data block which arrived incorrectly or a request which couldn't be processed successfully. |
|Returns: |MDC_FAIL- Couldn't transmit a NAK message to the client.
MDC_OK - NAK sent successfully. |
|Prototype: |`int _MDC_SendNAK( UCHAR szErrMsg /* I: Error msg to send with NAK */ )` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_ServerCntlCB** |
|Description: |A function to handle any communications control callbacks that are generated as a result of MDC_Server being executed. |
|Returns: |No Returns. |
|Prototype: | `void _MDC_ServerCntlCB( int nType /* I: Type of callback */, ... /* I: Arg list according to type */` ) |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_ServerDataCB** |
|Description: |A function to handle any data callbacks that are generated as a result of data arriving during an MDC_Server execution. |
|Returns: |No Returns. |
|Prototype: |`void _MDC_ServerDataCB( UINT nChanId / I: Channel data rcv on */, UCHAR szData /* I: Rcvd data */, UINT nDataLen /* I: Rcvd data length */)` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**MDC_Server** |
|Description: |Entry point into the Meta Data Communications for a server process. This function initialises all communications etc and then runs the given user callback to perform any required actions. |
|Returns: |MDC_FAIL- Function terminated due to a critical error, see Errno for exact reason code.
MDC_OK - Function completed successfully without error. |
|Prototype: |`int MDC_Server( UINT nPortNo /* I: TCP/IP port number */, UCHAR szService /* I: Name of TCP/IP Service */, int (fLinkDataCB) /* I: User function callback */, (UCHAR , int, UCHAR ), void (fControlCB)(UCHAR) /* I: User control callback */ )` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**MDC_ReturnData** |
|Description: |Function called by user code to return any required data to a connected client. This function can only be called in response to a callback 'from the MDC layer to the user code' which has provided data. |
|Returns: |MDC_FAIL- An error occurred in transmitting the given data block to the client process, see Errno for exact reason code.
MDC_OK - Data packet was transmitted successfully. |
|Prototype: |`int MDC_ReturnData( UCHAR snzDataBuf /* I: Data to return */, int nDataLen /* I: Length of data */ )` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**MDC_TimerCB** |
|Description: |Function to allow user code to register a callback event which is activated upon a timer expiring. The user provides the frequency and a function to callback and the MDC schedules it. |
|Returns: |No Return Values. |
|Prototype: |`int MDC_TimerCB( ULNG lTimePeriod /* I: CB Time in Millseconds */, UINT nEnable /* I: Enable(TRUE)/Dis(FALSE) CB */, UINT nAstable /* I: Astable(TRUE) or Mono CB */, void (fTimerCB)(void) /* I: Function to call back */ )` |
### MDC Client API
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_DataCB** |
|Description: |This function is called back when data is received on any of the service connections |
|Returns: | void |
|Prototype: |`void _MDC_DataCB(UINT nChanId, UCHAR *szData, UINT nDataLen) |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_CtrlCB** |
|Description: |This function is called back when control information is received on any of the service connections |
|Returns: | void |
|Prototype: |`void _MDC_CtrlCB(int nType, ...) |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_SendPacket** |
|Description: |Send a packet to a daemon |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int _MDC_SendPacket(UINT nChanId, char cPacketType, UCHAR *psnzBuf, UINT nBuflen) |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_GetSrvRqtReply** |
|Description: |Get reply to a service request packet |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int _MDC_GetSrvRqtReply(UINT nChanId, char *pcPacketType) |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_CreateChStatus** |
|Description: |Make a new Channel status structure and add to linked list |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int _MDC_CreateChStatus(UINT nChanId) /* Channel ID */ |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_DelChStatus** |
|Description: |Delete an item from the Channel status linked list |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int _MDC_DelChStatus(UINT nChanId) /* Channel ID */ |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_SetChState** |
|Description: |Set Channel State to the given value |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int _MDC_SetChState( UINT nChanId /* Channel ID */, CHSTATE eNewState /* New state */ ) |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_SetSRResult** |
|Description: |Set Channel Send Request result |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int _MDC_SetSRResult( UINT nChanId /* Channel ID */, UINT bResult /* Send Request result */) |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_GetSRResult** |
|Description: |Get Channel Send Request result |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int _MDC_GetSRResult( UINT nChanId /* Channel ID */, UINT *bResult /* Send Request result */) |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_SetUserCB** |
|Description: |Set Send Request call back to the given value |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int _MDC_SetUserCB( UINT nChanId /* Channel ID */, void (*UserCB) (UINT, UCHAR *, UINT) /* call back */) |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_GetChState** |
|Description: |Get Channel State for a given channel |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int _MDC_GetChState( UINT nChanId /* Channel ID */, CHSTATE *eState /* Channel state */) |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_GetNAKErrStr** |
|Description: |Get pointer to NAK error string |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int _MDC_GetNAKErrStr( UINT nChanId /* Channel ID */, UCHAR **ppszErrStr /* pointer to pointer to error string */) |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_GetUserCB** |
|Description: |Get User call back for the channel |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int _MDC_GetUserCB( UINT nChanId /* Channel ID */, void (**UserCB) (UINT, UCHAR *, UINT /* User call back */) |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_PrintErrMsg** |
|Description: |Print error message text |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int _MDC_PrintErrMsg( UCHAR *psnzErrMsg /* Error message none terminated */, UINT nBufLen /* Buffer Length */) |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_WaitOnSndReq** |
|Description: |Block until send request completes |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int _MDC_WaitOnSndReq(UINT nChanId) /* Channel ID */ |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**MDC_SendRequest** |
|Description: |Send a request to a driver |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int MDC_SendRequest( UINT nChanId /* I: Channel to send message on */, UCHAR *szData /* I: Data to send */, UINT nDataLen /* I: Length of data */, void (*DataCB) (UINT, UCHAR *, UINT) /* I: call back function for data */ ) |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**MDC_GetResult** |
|Description: |Wait for all replies to a send request and then return result |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int MDC_GetResult( UINT nChanId /* I: Channel ID */, UCHAR **ppszErrorMsg /* O: Associated error message */)` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**MDC_GetStatus** |
|Description: |Returns a boolean that indicates whether the Send Request for given channel has completed. |
|Returns: | MDC_OK or MDC_FAIL |
|Prototype: |`int MDC_GetStatus( UINT nChanId /* I: Channel ID */, UINT *bSndReqCom /* O: Indicates whether Send Request has completed */ )` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**MDC_CreateService** |
|Description: |Create a connection to a daemon so that service requests can be issued |
|Returns: | Channel ID, or negative error code |
|Prototype: |`int MDC_CreateService( UCHAR *szHostName /* I: Host for connect*/, UINT *nPortNo /* I: Port host on */, SERVICEDETAILS *serviceDet /* I: Service details */ )` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**MDC_SetTimeout** |
|Description: |Function to program one of the system timeout values from the default to a user setting. |
|Returns: | MDC_OK - Setting changed.
MDC_FAIL - Setting couldn't be changed, see error message. |
|Prototype: |`int MDC_SetTimeout( UCHAR *pszWhichTimeout /* I: Timeout to set */, UINT nTimeoutValue /* I: New value */, UCHAR *pszErrMsg /* O: Error message */ )` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**MDC_CloseService** |
|Description: |Close a service channel |
|Returns: | MDC_FAIL or MDC_OK or MDC_BADCONTEXT |
|Prototype: |`int MDC_CloseService( UINT nChanId ) /* I: Channel to close */` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**MDC_Start** |
|Description: |This is called to initialise the MDC Comms. |
|Returns: | MDC_FAIL or MDC_OK |
|Prototype: |`int MDC_Start( void )` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**MDC_End** |
|Description: |This is called to shutdown the MDC Comms. |
|Returns: | MDC_FAIL or MDC_OK |
|Prototype: |`int MDC_End( void )` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**MDC_ChangeService** |
|Description: |Change Service for an existing daemon connection |
|Returns: | MDC_OK, MDC_FAIL, MDC_NODAEMON, MDC_NOSERVICE, MDC_BADPARMS |
|Prototype: |`int MDC_ChangeService( UINT nChanId /* I: Chan ID of srvc */, SERVICEDETAILS *serviceDet /* I: Service details */ )` |
### MDC Common API
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_Init** |
|Description: |Function to perform MDC initialisation. The library performs checking to ensure that initialisation only occurs once prior to an _MDC_Terminate. |
|Returns: |MDC_FAIL- Couldn't initialise library.
MDC_OK - Library initialised. |
|Prototype: |`int _MDC_Init( void )` |
| | |
| ---------- | ----------------------------------------------------------------------------- |
|**Function**: |**_MDC_Terminate** |
|Description: |Function to shutdown the MDC library. After a successful shutdown, _MDC_Init may be called to re-initialise the library. If MDC_Terminate fails, program exit is advised. |
|Returns: |MDC_FAIL- Couldn't perform a clean shutdown.
MDC_OK - Library successfully shutdown. |
|Prototype: |`int _MDC_Terminate( void )` |
## Licenses
These software libraries are licensed under the GNU Public Licence v3.
### The Gnu Public License v3
The source and binary files in this project marked as GPL v3 are free software: you can redistribute it and-or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The source files are distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.