Syslog Client DLL 1.2

I provide this syslog client support DLL free of charge for everyone who can make use of it. The purpose of this DLL is to make it for developers of Windows 95/98 or Windows NT/2000 applications as easy as possible to implement the functionality of a syslog client into their applications.

Features:

A developer can use this DLL to generate syslog messages by calling three of the four provided functions documented below. The function SlDNSLookup is not neccessary for generating syslog messages but it may be helpful in some cases by performing hostname-to-IP-address or IP-address-to-hostname (reverse lookup) functionality.


SlInitialize

The SlInitialize function initializes the Windows Sockets environment.

DWORD SlInitialize(

    void    // no parameters
   );

Parameters

None

Return Values

If the function succeeds, the return value is SL_ERROR_SUCCESS.

If the function fails, the return value is SL_ERROR_INITIALIZE_WINSOCKETS if the initalization of the WinSock environment failed or SL_ERROR_SOCKET_OPERATION if an socket related error happened.

Remarks

This function initializes the Windows Sockets environment and allocates necessary resources for sending syslog messages. This function has to be called by an application before any of the other two functions. It's sufficient to call this function one time for the whole application but it can be called more than once. As often as this functions is called as often must the function SlUninitialize be called.


SlUninitialize

The SlUninitialize function deinitializes the Windows Sockets environment.

DWORD SlUninitialize(

    void     // no parameters
   );

Parameters

None

Return Values

If the function succeeds, the return value is SL_ERROR_SUCCESS.

If the function fails, the return value is SL_ERROR_NOT_INITIALIZED which happens if the function is called without a preceding call to SlInitialize.

Remarks

This function frees allocated resources and deinitializes the Windows Sockets environment. It must be called as often as SlInitialize has been called.


SlSendMessage

The SlSendMessage function sends one syslog message to the specified host..

DWORD SlSendMessage(

    PTSTR pszHostName    // hostname or ip-address of syslog message destination
    int nFacility // facility code
    int nPriority // priority code
    PTSTR pszText // pointer to message text
   );

Parameters

pszHostName
Pointer to a zero terminated string which can be the hostname (for example: "logserver.netal.com") or the IP-address in string representation (for example: "10.0.1.151") of the destination host.
 
nFacility
Specifies the facility code of the syslog message (see ClSyslog.h for possible values).
 
nPriority
Specifies the priority code of the syslog message (see ClSyslog.h for possible values).
 
pszText
Pointer to a zero terminated string which contains the message text for the syslog message.

Return Values

If the function succeeds, the return value is SL_ERROR_SUCCESS.

If the function fails, the return value is SL_ERROR_NOT_INITIALIZED if called without a preceding call to SlInitialize, SL_ERROR_INVALID_PARAMETER if one or more of the function parameters are invalid, SL_ERROR_RESOLVE_HOSTNAME if the given hostname could not be successfully resolved to an IP-address or SL_ERROR_SOCKET_OPERATION if a socket related error occurred in sending the message.

Remarks

This function is used to send one syslog message. It can only successfully be called after the Windows Sockets environment has been initialized, e.g. after a call to SlInitialize.


SlDNSLookup

The SlDNSLookup functions resolves a hostname to an IP-address or an IP-address to a hostname (reverse lookup).

DWORD SlDNSLookup(

    PTSTR pszInput    // hostname or ip-address to lookup
    PTSTR pszOutput    // result of lookup operation (hostname or IP-address)
    DWORD cchOutputLength    // size of output buffer in characters
   );

Parameters

pszInput
Pointer to a zero terminated string which can be a hostname (for example: "logserver.netal.com") or an IP-address in string representation (for example: "10.0.1.151") for which to perform DNS lookup.
 
pszOutput
Pointer to a buffer which is filled by the function, if successful, with the outcome of the lookup operation.
 
cchOutputLength
Specifies the length in characters of the supplied buffer pointed to by pszOutput.
 

Return Values

If the function succeeds, the return value is SL_ERROR_SUCCESS.

If the function fails, the return value is SL_ERROR_NOT_INITIALIZED if called without a preceding call to SlInitialize, SL_ERROR_INVALID_PARAMETER if one or more of the function parameters are invalid, SL_ERROR_RESOLVE_HOSTNAME if the given hostname could not be successfully resolved to an IP-address or the given IP-address could not be resolved to a hostname or SL_ERROR_OUTPUT_BUFFER_TOO_SMALL if the size of the supplied output buffer is too small.

Remarks

This function is used to perform DNSLookup. It can only successfully be called after the Windows Sockets environment has been initialized, e.g. after a call to SlInitialize. If the input string is a hostname a lookup is performed for the corresponding IP-address, if the input string is an IP-address a lookup is performed for the corresponding hostname (reverse lookup).