]> git.pld-linux.org Git - packages/grace.git/blob - grace-home_etc.patch
- added ac+tirpc patch (autoconf fix + tirpc support)
[packages/grace.git] / grace-home_etc.patch
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
4 @@ -32,6 +32,12 @@
5  #include <stdlib.h>
6  #include <unistd.h>
7  #include <string.h>
8 +
9 +/* ETC-HOME support for PLD */
10 +#include <sys/types.h>
11 +#include <sys/stat.h>
12 +#include <errno.h>
13 +
14  #ifdef HAVE_FCNTL_H
15  #  include <fcntl.h>
16  #endif
17 @@ -76,7 +82,8 @@
18  
19  int main(int argc, char *argv[])
20  {
21 -    char *s;
22 +    char *s, *config_file;
23 +    struct stat statb;
24      int i, j;
25      int gno;
26      int fd;
27 @@ -223,9 +230,43 @@
28      /* default is POSIX */
29      set_locale_num(FALSE);
30      
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);
35 +      if (s[0] == '~')
36 +       strncat(config_file, s+1, GR_MAXPATHLEN - strlen(config_file) - 1);
37 +      else {     
38 +       strncat(config_file, "/", GR_MAXPATHLEN - strlen(config_file) - 1);
39 +       strncat(config_file, s, GR_MAXPATHLEN - strlen(config_file) - 1);
40 +      }
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");
50 +           }
51 +           else
52 +             fprintf(stderr, "Moved config file 'gracerc' to %s.\n", config_file);
53 +         }
54 +         else
55 +           strcpy(config_file, "gracerc");
56 +       }
57 +      }
58 +      else
59 +       strcpy(config_file, "gracerc");
60 +    }
61 +    else
62 +      strcpy(config_file, "gracerc");
63 +    
64      /* load startup file */
65 -    getparms("gracerc");
66 -
67 +    getparms(config_file);
68 +    free(config_file);
69 +    
70      /* load default template */
71      new_project(NULL);
72  
This page took 0.580702 seconds and 3 git commands to generate.