WSLogFileNameForLink (C Function)

int WSLogFileNameForLink( WSLINK l , const char ** name )

computes a suitable name and (optionally) a location in the file system for a log file to log the WSTP data stream in the WSTP connection specified by l and stores the name in name.

Details

  • WSLogFileNameForLink() allocates memory for the name of the log file that must be released by calling WSReleaseLogFileNameForLink(). If WSLogFileNameForLink() fails and returns an error, do not use WSReleaseLogFileNameForLink() to release the contents of name.
  • WSLogFileNameForLink() returns 1 on success and 0 on failure.
  • WSLogFileNameForLink() is declared in the WSTP header file wstp.h.

Examples

Basic Examples  (1)

#include "wstp.h"

int main(int argc, char **argv)
{
    WSENV env;
    WSLINK link;
    int error;
    const char *logFileName;
    int apiResult;

    env = WSInitialize((WSEnvironmentParameter)0);
    if(env == (WSENV)0)
    { /* Unable to create WSTP environment object */ }

    link = WSOpenArgcArgv(env, argc, argv, &error);
    if(link == (WSLINK)0 || error != WSEOK)
    { /* Unable to create link object */ }

    WSActivate(link);

    /* ... */

    apiResult = WSLogFileNameForLink(link, &logFileName);
    if(! apiResult =)
    { /* Unable to generate a file name */ }

    apiResult = WSLogStreamToFile(link, logFileName);
    { /* unable to log to logFileName */ }

    WSReleaseLogFileNameForLink(link, logFileName);

    /* ... */

    WSClose(link);
    WSDeinitialize(env);

    return 0;
}