OpenersNotesSection(Spacer1)Details

WSGetFunction() allocates memory for the character string corresponding to the name of the head of the function. You must call (NonWLLink[WSReleaseSymbol(), paclet:ref/c/WSReleaseSymbol]) to disown this memory. If WSGetFunction() fails and the function's return value indicates an error, do not call (NonWLLink[WSReleaseSymbol(), paclet:ref/c/WSReleaseSymbol]) on the contents of s.

External programs should not modify the character string s.

WSGetFunction(link,&s,&n) has the same effect as (NonWLLink[WSGetNext, paclet:ref/c/WSGetNext])(link);(NonWLLink[WSGetArgCount, paclet:ref/c/WSGetArgCount])(link,&n);(NonWLLink[WSGetSymbol, paclet:ref/c/WSGetSymbol])(link,&s).

WSGetFunction() returns 0 in the event of an error, and a nonzero value if the function succeeds.

Use (NonWLLink[WSError(), paclet:ref/c/WSError]) to retrieve the error code if WSGetFunction() fails.

WSGetFunction() is declared in the WSTP header file (RefLink[wstp.h, paclet:ref/file/wstp.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)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 */
			return;
		}

	/* ... */

	WSReleaseSymbol(lp, f);
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSReleaseSymbol(), paclet:ref/c/WSReleaseSymbol])  ▪  (NonWLLink[WSGetNext(), paclet:ref/c/WSGetNext])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Manipulating Expressions in External Programs, paclet:tutorial/ManipulatingExpressionsInExternalPrograms])}, {▪(RefLinkPlain[Handling Lists, Arrays and Other Expressions, paclet:tutorial/HandlingListsArraysAndOtherExpressions])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Mac OS X), paclet:tutorial/WSTPDeveloperGuide-MacintoshOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Unix and Linux), paclet:tutorial/WSTPDeveloperGuide-UnixOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Windows), paclet:tutorial/WSTPDeveloperGuide-WindowsOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Alphabetical Listing of WSTP C Functions, paclet:guide/AlphabeticalListingOfWSTPCFunctions])}, {▪(RefLinkPlain[Installable WSTP Programs, paclet:guide/InstallableWSTPPrograms])}, {▪(RefLinkPlain[WSTP C Functions for Exchanging Data, paclet:guide/WSTPCFunctionsForExchangingData])}, {▪(RefLinkPlain[WSTP C Functions for Exchanging Expressions, paclet:guide/WSTPCFunctionsForExchangingExpressions])}, {▪(RefLinkPlain[WSTP C Language Functions, paclet:guide/WSTPCLanguageFunctions])}})}})