1 diff -urN grace-5.1.2/src/main.c grace-5.1.2-HOME-ETC/src/main.c
2 --- grace-5.1.2/src/main.c Mon Aug 14 00:53:13 2000
3 +++ grace-5.1.2-HOME-ETC/src/main.c Thu Dec 7 14:56:29 2000
9 +/* ETC-HOME support for PLD */
10 +#include <sys/types.h>
11 +#include <sys/stat.h>
19 int main(int argc, char *argv[])
22 + char *s, *config_file;
28 /* default is POSIX */
29 set_locale_num(FALSE);
31 + /* HOME-ETC support for PLD */
32 + config_file = (char *) malloc(sizeof(char) * GR_MAXPATHLEN);
33 + if ((s = getenv("CONFIG_DIR")) != NULL) {
34 + strncpy(config_file, getenv("HOME"), GR_MAXPATHLEN - 1);
36 + strncat(config_file, s+1, GR_MAXPATHLEN - strlen(config_file) - 1);
38 + strncat(config_file, "/", GR_MAXPATHLEN - strlen(config_file) - 1);
39 + strncat(config_file, s, GR_MAXPATHLEN - strlen(config_file) - 1);
41 + if (config_file[strlen(s) - 1] == '/')
42 + config_file[strlen(s) - 1] = 0;
43 + if (stat(config_file, &statb) != -1) {
44 + strncat(config_file, "/gracerc", GR_MAXPATHLEN - strlen(config_file) - 1);
45 + if (stat(config_file, &statb) == -1) {
46 + if (stat("gracerc", &statb) != -1) {
47 + if (rename("gracerc", config_file) == -1) {
48 + fprintf(stderr, "Couldn't create file %s: %s\n", config_file, strerror(errno));
49 + strcpy(config_file, "gracerc");
52 + fprintf(stderr, "Moved config file 'gracerc' to %s.\n", config_file);
55 + strcpy(config_file, "gracerc");
59 + strcpy(config_file, "gracerc");
62 + strcpy(config_file, "gracerc");
64 /* load startup file */
65 - getparms("gracerc");
67 + getparms(config_file);
70 /* load default template */