NAME

cxParamPathnameGet - expand a parameter string value as a Unix path name

C SPECIFICATION

#include <cx/DataAccess.h>

char *cxParamPathnameGet ( cxParameter *src )

FORTRAN SPECIFICATION

integer function cxParamPathnameGet( src, file )
integer src
character*(*) file

PARAMETERS

src
The input cxParameter value, assumed to contain a string value.
file
In Fortran, the output filename expanded from the cxParameter string.

FUNCTION RETURN VALUE

In C, the value of src as a file name. In Fortran, the length of the file name.

DESCRIPTION

cxParamPathnameGet takes a character string, possibly beginning with a tilde and possibly containing environment variables, and returns a string containing the same information, but with the tilde notation and environment variables expanded.

If the string begins with a tilde character, then it is expanded into a home directory name according to the same rules used by C-shell. If this expansion fails (perhaps because it references the home directory of an unknown user), the tilde notation is left alone in the result. Environment variables may be used in the input string as well, again using the notation used by C-shell. They are replaced with the values of those variables. If an undefined environment variable is encountered, it is replaced by an empty string.

For example, consider the following string:

If the home directory of the user named explorer is /usr/people/explorer, and the value of the USER environment variable is arnold, this string will expand into the following:

In C, the storage used by this routine for the return value is dynamically allocated. The module programmer is therefore responsible for freeing that storage when done with the contents, by using free(3E). In Fortran, the character variable file is declared by the user. Also, the returned value is the length of the string in the parameter, which may be longer than the character variable provided by the user, in which case the caller should try again to get the full file name.

SEE ALSO

csh(1), environ(5)
Last modified: Mon Nov 18 13:51:34 GMT 1996
[ Documentation Home ]
© The Numerical Algorithms Group Ltd, Oxford UK. 1996