#include "resourcesconfig.h"
#include "feResource.h"
#include "feFopen.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
Go to the source code of this file.
FILE* feFopen |
( |
const char * |
path, |
|
|
const char * |
mode, |
|
|
char * |
where, |
|
|
short |
useWerror, |
|
|
short |
path_only |
|
) |
| |
Definition at line 46 of file feFopen.cc.
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);
const CanonicalForm int s
static char * feResource(feResourceConfig config, int warn)
void WerrorS(const char *s)
FILE * myfopen(const char *path, const char *mode)
int status int void * buf
void * malloc(size_t size)
FILE* myfopen |
( |
const char * |
path, |
|
|
const char * |
mode |
|
) |
| |
Definition at line 166 of file feFopen.cc.
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);
size_t myfread |
( |
void * |
ptr, |
|
|
size_t |
size, |
|
|
size_t |
nmemb, |
|
|
FILE * |
stream |
|
) |
| |
Definition at line 194 of file feFopen.cc.
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';
void WerrorS |
( |
const char * |
s | ) |
|
Definition at line 23 of file feFopen.cc.
27 fwrite(
" ? ",1,5,stderr);
28 fwrite((
char *)
s,1,strlen((
char *)
s),stderr);
29 fwrite(
"\n",1,1,stderr);
const CanonicalForm int s
void(* WerrorS_callback)(const char *s)