1#include "singular_resourcesconfig.h"
13#if defined(HAVE_PWD_H) && defined(HAVE_GETPWNAM)
29 fwrite(
" ? ",1,5,stderr);
30 fwrite((
char *)
s,1,strlen((
char *)
s),stderr);
31 fwrite(
"\n",1,1,stderr);
47FILE *
feFopen(
const char *path,
const char *mode,
char *where,
48 short useWerror,
short path_only)
55 const char* home =
getenv(
"HOME");
57 if ((home==
NULL)||(!access(home,X_OK)))
62 strcpy(longpath, home);
63 strcat(longpath, &(path[1]));
67#if defined(HAVE_PWD_H) && defined(HAVE_GETPWNAM)
71 struct passwd *pw_entry;
72 strcpy (longpath, path);
73 dir_sep = strchr(longpath,
DIR_SEP);
77 strcpy(
buf,
"illegal ~ in filename >>");
78 strncat(
buf,longpath,235);
84 pw_entry = getpwnam(&longpath[1]);
87 strcpy(longpath, pw_entry->pw_dir);
88 dir_sep = strchr((
char *)path,
DIR_SEP);
89 strcat(longpath, dir_sep);
102 res = stat(path,&statbuf);
103 }
while((
res < 0) and (errno == EINTR));
105 && (S_ISREG(statbuf.st_mode)))
108 if (where!=
NULL) strcpy(where,path);
111 ! (path[0] ==
'.' && path[1] ==
DIR_SEP) &&
132 if(!access(
s, R_OK)) {
found++;
break; }
150 if (where!=
NULL) strcpy(
s,path);
155 if ((
f==
NULL)&&(useWerror))
158 strcpy(
buf,
"cannot open `");
159 strncat(
buf,path,240);
167FILE*
myfopen(
const char *path,
const char *mode)
169#if (defined(__CUGWIN__))
177 if (mode[
i] ==
'\0')
break;
178 if (mode[
i] ==
'w') done = 1;
179 if (mode[
i] ==
'a') done = 1;
180 if (mode[
i] ==
'b') done = 1;
188 return fopen(path, mmode);
190 return fopen(path, mode);
197 size_t got = fread(ptr,
size, nmemb, stream) *
size;
200 for (
i=0;
i<got;
i++)
202 if ( ((
char*) ptr)[
i] ==
'\r')
204 if (
i+1 < got && ((
char*) ptr)[
i+1] ==
'\n')
205 ((
char*) ptr)[
i] =
' ';
207 ((
char*) ptr)[
i] =
'\n';
const CanonicalForm int s
VAR void(* WerrorS_callback)(const char *s)
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
void WerrorS(const char *s)
FILE * myfopen(const char *path, const char *mode)
VAR void(* PrintS_callback)(const char *s)
size_t myfread(void *ptr, size_t size, size_t nmemb, FILE *stream)
static char * feResource(feResourceConfig config, int warn)
int status int void * buf