Port Windows IPC Apps to Linux, Part 1: Processes and Threads
By Srinivasan S. Muthuswamy, Kavitha Varadarajan2005-06-16
In Windows, you can use GetEnvironmentVariable() and SetEnvironmentVariable() to get and set the environment variables.
|
This function returns the size of the value buffer on success and 0 if the name specified is not a valid environment variable name. The SetEnvironmentVariable() function sets the contents of the specified environment variable for the current process.
|
If the function succeeds, the return value is non-zero. If the function fails, the return value is zero.
In Linux, getenv() and setenv() system calls provide the equivalent functionality.
|
The getenv() function searches the environment list for a string that matches the string pointed to by name. This function returns a pointer to the value in the environment or NULL if there is no match. The setenv() function adds the variable name to the environment with the value if the name does not already exist. If the name does exist in the environment, then its value is changed to value if overwrite is non-zero. If overwrite is zero, then the value of name is not changed. The setenv() function returns zero on success or -1 if there was insufficient space in the environment.
Tutorial pages:
|
First published by IBM DeveloperWorks
|
|||||||||
You might also want to check these out:
|
Link to This Tutorial Page!

