1 #include "resourcesconfig.h"
13 #if defined(HAVE_PWD_H) && defined(HAVE_GETPWNAM)
27 fwrite(
" ? ",1,5,stderr);
28 fwrite((
char *)s,1,strlen((
char *)s),stderr);
29 fwrite(
"\n",1,1,stderr);
46 FILE *
feFopen(
const char *path,
const char *mode,
char *where,
47 short useWerror,
short path_only)
54 const char* home =
getenv(
"HOME");
56 if ((home==
NULL)||(!access(home,X_OK)))
61 strcpy(longpath, home);
62 strcat(longpath, &(path[1]));
66 #if defined(HAVE_PWD_H) && defined(HAVE_GETPWNAM)
70 struct passwd *pw_entry;
71 strcpy (longpath, path);
72 dir_sep = strchr(longpath,
DIR_SEP);
76 strcpy(buf,
"illegal ~ in filename >>");
77 strncat(buf,longpath,235);
83 pw_entry = getpwnam(&longpath[1]);
86 strcpy(longpath, pw_entry->pw_dir);
87 dir_sep = strchr((
char *)path,
DIR_SEP);
88 strcat(longpath, dir_sep);
101 res = stat(path,&statbuf);
102 }
while((res < 0) and (errno == EINTR));
104 && (S_ISREG(statbuf.st_mode)))
107 if (where!=
NULL) strcpy(where,path);
110 ! (path[0] ==
'.' && path[1] ==
DIR_SEP) &&
131 if(!access(s, R_OK)) { found++;
break; }
149 if (where!=
NULL) strcpy(s,path);
154 if ((f==
NULL)&&(useWerror))
157 strcpy(buf,
"cannot open `");
158 strncat(buf,path,240);
166 FILE*
myfopen(
const char *path,
const char *mode)
168 #if (defined(__CUGWIN__))
176 if (mode[i] ==
'\0')
break;
177 if (mode[i] ==
'w') done = 1;
178 if (mode[i] ==
'a') done = 1;
179 if (mode[i] ==
'b') done = 1;
187 return fopen(path, mmode);
189 return fopen(path, mode);
194 size_t myfread(
void *ptr,
size_t size,
size_t nmemb, FILE *stream)
196 size_t got = fread(ptr, size, nmemb, stream) *
size;
199 for (i=0; i<got; i++)
201 if ( ((
char*) ptr)[i] ==
'\r')
203 if (i+1 < got && ((
char*) ptr)[i+1] ==
'\n')
204 ((
char*) ptr)[
i] =
' ';
206 ((
char*) ptr)[i] =
'\n';
const CanonicalForm int s
static char * feResource(feResourceConfig config, int warn)
void WerrorS(const char *s)
size_t myfread(void *ptr, size_t size, size_t nmemb, FILE *stream)
FILE * myfopen(const char *path, const char *mode)
int status int void * buf
void * malloc(size_t size)
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
void(* WerrorS_callback)(const char *s)