char *datafile = NULL;
char *rcfile = NULL;
-int alternative_datafile = FALSE;
-int alternative_rcfile = FALSE;
+bool alternative_datafile = FALSE;
+bool alternative_rcfile = FALSE;
static int
datafile_writeable()
cwd = my_getcwd();
- *var = strconcat(cwd, path, NULL);
+ *var = strconcat(cwd, "/", path, NULL);
free(cwd);
}
{
struct stat s;
- if( ! strchr(mode, 'r') )
- return fopen(path, mode);
-
- if ( (stat(path, &s)) == -1 )
+ if((stat(path, &s)) == -1)
return NULL;
-
- return S_ISREG(s.st_mode) ? fopen(path, mode) : NULL;
+
+ if(strchr(mode, 'r'))
+ return S_ISREG(s.st_mode) ? fopen(path, mode) : NULL;
+ else
+ return S_ISDIR(s.st_mode) ? NULL : fopen(path, mode);
}
{
char *line;
char *name = NULL, *email = NULL;
+ struct stat s;
+
+ if( (fstat(fileno(stdin), &s)) == -1 || S_ISDIR(s.st_mode)) {
+ fprintf(stderr, "stdin is a directory or cannot stat stdin\n");
+ exit(1);
+ }
init_add_email();