Novell is now a part of Micro Focus

Is there a function I can call from...

Articles and Tips: qna

01 Dec 2002


Q.

Is there a function I can call from my NLM that will return a list of variables that are normally accessed by LIBC@getenv()?

A.

Here are two approaches. You can either do something like:

#include <stdio.h>
#include <stdlib.h>
#include <screen.h>
	
	int main( int argc, char* argv[], char*
environ[]) {
	
int i;
for ( i = 0; i < argc; ++i) printf( 	"argv[ %d] = %s\n", i, argv[ i]);
for ( i = 0; environ[ i] != NULL; ++i) 	printf( "environ[ %d] = %s\n", i,
	
	environ[ i]);
	
pressanykey();
	
	return EXIT_SUCCESS;
}
	
Or you can access the global environ
variable:
	
extern char **environ;
	
char	  **p;
	
for (p = environ; *p; ++p)
	fprintf(stdout, "\t%s\n", *p);

* Originally published in Novell AppNotes


Disclaimer

The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.

© Copyright Micro Focus or one of its affiliates