WSGetFunction (C Function)

int WSGetFunction(WSLINK link,const char **s,int *n)

gets a function with a symbol as a head from the WSTP connection specified by link, storing the name of the symbol in s and the number of arguments of the function in n.


  • WSGetFunction() allocates memory for the character string corresponding to the name of the head of the function. You must call WSReleaseSymbol() to disown this memory. If WSGetFunction() fails and the function's return value indicates an error, do not call WSReleaseSymbol() on the contents of s.
  • External programs should not modify the character string s.
  • has the same effect as WSGetNext(link);WSGetArgCount(link,&n);WSGetSymbol(link,&s).
  • WSGetFunction() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSGetFunction() fails.
  • WSGetFunction() is declared in the WSTP header file wstp.h.


Basic Examples  (1)

#include "wstp.h"

/* read a function from a link */

void f(WSLINK lp)
    const char *f;
    int n;

    if(! WSGetFunction(lp, &f, &n))
            /* unable to read the function from lp */

    /* ... */

    WSReleaseSymbol(lp, f);