Atmel CAVR-4 Manual De Usuario

Descargar
Página de 323
CAVR-4
Part 1. Using the compiler
The DLIB runtime environment
73
Environment interaction
According to the C standard, your application can interact with the environment using 
the functions 
getenv
 and 
system
.
Note: The 
putenv
 function is not required by the standard, and the library does not 
provide an implementation of it.
The 
getenv
 function searches the string, pointed to by the global variable 
_ _environ
for the key that was passed as argument. If the key is found, the value of it is returned, 
otherwise 0 (zero) is returned. By default, the string is empty.
To create or edit keys in the string, you must create a sequence of null terminated strings 
where each string has the format:
key=value\0
The last string must be empty. Assign the created sequence of strings to the 
_ _environ
 
variable.
For example:
const char MyEnv[] = ”Key=Value\0Key2=Value2\0”;
_ _environ = MyEnv;
If you need a more sophisticated environment variable handling, you should implement 
your own 
getenv
, and possibly 
putenv
 function. This does not require that you rebuild 
the library. You can find source templates in the files 
getenv.c
 and 
environ.c
 in the 
avr\src\lib
 directory. For information about overriding default library modules, see 
If you need to use the 
system
 function, you need to implement it yourself. The 
system
 
function available in the library simply returns -1.
If you decide to rebuild the library, you can find source templates in the library project 
template. For further information, see Building and using a customized library, page 62.
Note: If you link your application with support for I/O debugging, the functions 
getenv
 and 
system
 will be replaced by C-SPY variants. For further information, see 
Signal and raise
There are default implementations of the functions 
signal
 and 
raise
 available. If 
these functions do not provide the functionality that you need, you can implement your 
own versions.