cdash@boulder.Colorado.EDU (Charles Shub) (03/02/88)
i got bit by the "you have been relocated" trick today. Several things did not work (the stuff I use often) The major problem is describing a path in a header file, a path that will be used as an argument to open(2). Since the program will be run from many directories, a relative path is out. Since the path is an argument to a system call, there is no good opportunity for environment variable substitution. How do you get around this short of editing the header files when something has to move? thanks... -- cdash aka cdash@boulder.colorado.edu aka ...hao!boulder!cdash aka ...nbires!boulder!cdash aka (303) 593-3492
cdash@boulder.Colorado.EDU (Charles Shub) (03/03/88)
several days ago, I posted a question about pathnames being immune to one being relocated to another directory. Several solutions were posed via mail and this composite of the ideas seems to work well. It doesn't clutter up the environment with lots of path name variables and is minimal overhead: #define RELPATH a/b/c /* path from your home directory */ if (!(home = getenv("HOME"))) syserr("HOME not defined"); if (!(abs = malloc((unsigned) (strlen(RELPATH) + strlen(home) + 2)))) syserr("could not get path storage"); open(strcat(strcat(strcpy(abs,home),"/"),RELPATH),FLAGS,MODE); -- cdash aka cdash@boulder.colorado.edu aka ...hao!boulder!cdash aka ...nbires!boulder!cdash aka (303) 593-3492