OpenersNotesSection(Spacer1)Details

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

MLGetLinkedEnvIDString() returns an immutable string.

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

MLGetLinkedEnvIDString() will not work until link is connected.

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

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

MLGetLinkedEnvIDString() is declared in the MathLink header file (RefLink[mathlink.h, paclet:ref/file/mathlink.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include <string.h>
#include "mathlink.h"

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

#define ERROR -1

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

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

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

	MLReleaseEnvIDString(lp, e, length);

	return isCorrectProg;
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLSetEnvIDString(), paclet:ref/c/MLSetEnvIDString])  ▪  (NonWLLink[MLReleaseEnvIDString(), paclet:ref/c/MLReleaseEnvIDString])  ▪  (NonWLLink[MLActivate(), paclet:ref/c/MLActivate])}})}})