OpenersNotesSection(Spacer1)Details

WSGetData() does not allocate b; b must be provided.

WSGetData() 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 WSGetData() fails.

WSGetData() 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 data from a link in textual form */

void f(WSLINK lp)
{
	int size, count;
	char *buff;

	switch(WSGetType(lp))
	{
		case WSTKSTR:
			if(! WSBytesToGet(lp, &size))
				{
					/* unable to read the number of bytes from lp */
					return;
				}

			buff = (char *)malloc(size * sizeof(char));
			if(buff == (char *)0)
				{
					/* unable to allocate mmemory */
					return;
				}

			if(! WSGetData(lp, buff, size &count))
				{
					/* unable to read the string data from lp */
					free(buff);
					return;
				}

			/* ... */

			free(buff);

			break;
	}

	/* ... */
}

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

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(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[Low-Level WSTP Operations, paclet:guide/LowLevelWSTPOperations])}, {▪(RefLinkPlain[WSTP C Functions for Exchanging Expressions, paclet:guide/WSTPCFunctionsForExchangingExpressions])}})}})