OpenersNotesSection(Spacer1)Details

WSGetLinkedEnvIDString() allocates the memory for the string eid. You must call (NonWLLink[WSReleaseEnvIDString(), paclet:ref/c/WSReleaseEnvIDString]) to disown this memory. If WSGetLinkedEnvIDString() fails and the function's return value indicates an error, do not call (NonWLLink[WSReleaseEnvIDString(), paclet:ref/c/WSReleaseEnvIDString]) on the contents of e.

WSGetLinkedEnvIDString() returns an immutable string.

The environment identification returned by WSGetLinkedEnvIDString() is a null-terminated ASCII string.

WSGetLinkedEnvIDString() will not work until link is connected.

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

WSGetLinkedEnvIDString() 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 <string.h>
#include "wstp.h"

/* read the id from a link and check for "My Remote Program" */

#define ERROR -1

int f(WSLINK lp)
{
	int isCorrectProg;
	const char *e;

	if(! WSGetLinkedEnvIDString(lp, &e))
		{
			/* unable to read the link id from lp */
			return ERROR;
		}

	isCorrectProg = strcmp(envid, "My Remote Program") == 0;

	WSReleaseEnvIDString(lp, e, length);

	return isCorrectProg;
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSSetEnvIDString(), paclet:ref/c/WSSetEnvIDString])  ▪  (NonWLLink[WSReleaseEnvIDString(), paclet:ref/c/WSReleaseEnvIDString])  ▪  (NonWLLink[WSActivate(), paclet:ref/c/WSActivate])}})}})

({{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])}})}})