/[ipchat]/ipchat/src/misc.c
ViewVC logotype

Diff of /ipchat/src/misc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by beatk, Fri Feb 11 00:01:04 2005 UTC revision 1.5 by beatk, Sun Feb 27 21:20:36 2005 UTC
# Line 67  home_path (char *file) Line 67  home_path (char *file)
67  error:  error:
68          return NULL;          return NULL;
69  }  }
70    
71                    
72    char *
73    home_path2 (char *dir, char *file)
74    {
75            struct passwd *pass;
76            size_t size;
77            char *buf;
78            
79            pass = getpwuid (getuid());
80            CHECK (pass != NULL);
81                                    
82            size = strlen (pass->pw_dir);
83            buf = malloc ((size + strlen(dir) + strlen(file) + 2) * sizeof (char));
84            CHECK (buf != NULL);
85    
86            strcpy (buf, pass->pw_dir);
87            
88            buf [size] = '/';
89            buf [size + 1] = '\0';
90    
91            strcat (buf, dir);
92            strcat (buf, file);
93    
94            return buf;
95    
96    error:
97            return NULL;
98    }
99    
100    
101  int  int
102  check_dir ()  check_dir (char *dirname)
103  {  {
104          struct stat str;          struct stat str;
105          char *dir;                char *dir;      
106          int ret;          int ret;
107                    
108          dir = home_path (".ipchat");          dir = home_path (dirname);
109          CHECK_J (dir != NULL, error_r);          CHECK_J (dir != NULL, error_r);
110                    
111          if (stat (dir, &str) == 0) {          if (stat (dir, &str) == 0) {

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26