28{
29 const unsigned char mach_o[]={0xfe,0xed,0xfa,0xce,0};
30 const unsigned char mach_O[]={0xce,0xfa,0xed,0xfe,0};
31
32 const unsigned char mach_o64[]={0xfe,0xed,0xfa,0xcf,0};
33 const unsigned char mach_O64[]={0xcf,0xfa,0xed,0xfe,0};
34
35 const unsigned char mach_FAT[]={0xca,0xfe,0xba,0xbe,0};
36 const unsigned char mach_fat[]={0xbe,0xba,0xfe,0xca,0};
37
38 const unsigned char utf16be[]={0xfe,0xff,0};
39 const unsigned char utf16le[]={0xff,0xfe,0};
40 const unsigned char utf8ms[]={0xEF,0xBB,0xBF,0};
41
42 const unsigned char dll[]={'M','Z',0};
45 {
47 {
50 }
52 }
54 struct stat sb;
55 int nbytes = 0;
56 int ret;
58
60
61 do
62 {
64 } while((ret < 0) and (errno == EINTR));
65
67 {
69 }
70 if((sb.st_mode & S_IFMT) != S_IFREG)
71 {
72 goto lib_type_end;
73 }
75 {
76 goto lib_type_end;
77
78 }
79 if (nbytes == 0)
80 goto lib_type_end;
81 else
82 {
84 }
85 if( (strncmp(
buf,
"\177ELF", 4)==0))
86 {
88
89
90 goto lib_type_end;
91 }
92
93 if( (strncmp(
buf, (
const char *)mach_o, 4)==0) || (strncmp(
buf, (
const char *)mach_O, 4)==0))
94 {
96
97
98 goto lib_type_end;
99 }
100
101 if( (strncmp(
buf, (
const char *)mach_o64, 4)==0) || (strncmp(
buf, (
const char *)mach_O64, 4)==0))
102 {
104
105
106 goto lib_type_end;
107 }
108
109 if( (strncmp(
buf, (
const char *)mach_FAT, 4)==0) || (strncmp(
buf, (
const char *)mach_fat, 4)==0))
110 {
112
113
114 goto lib_type_end;
115 }
116
117 if( (strncmp(
buf,
"\02\020\01\016\05\022@", 7)==0))
118 {
120
121
122 goto lib_type_end;
123 }
124 if ((strncmp(
buf,(
const char *)utf16be,2)==0)
125 ||(strncmp(
buf,(
const char *)utf16le,2)==0))
126 {
127 WerrorS(
"UTF-16 not supported");
129 goto lib_type_end;
130 }
131 if (strncmp(
buf,(
const char *)utf8ms,3)==0)
132 {
133 WarnS(
"UTF-8 detected - may not work");
135 goto lib_type_end;
136 }
137 if (strncmp(
buf,(
const char *)dll,2)==0)
138 {
140 goto lib_type_end;
141 }
142 if(isprint(
buf[0]) ||
buf[0]==
'\n')
144
145 lib_type_end:
147 return LT;
148}
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
void WerrorS(const char *s)
VAR char libnamebuf[1024]
const char *const si_builtin_libs[]
int status int void * buf