Changeset adc0a4 in git for libpolys/polys/mod_raw.cc
- Timestamp:
- Jun 19, 2013, 3:43:25 PM (11 years ago)
- Branches:
- (u'spielwiese', '6e5adcba05493683b94648c659a729c189812c77')
- Children:
- 10b169a45a513bb611a4166d85796ae81990344d
- Parents:
- 593701c3d9a3d7851247b1e1603c209005e89f8e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/mod_raw.cc
r593701 radc0a4 36 36 #endif 37 37 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ 38 #define BYTES_TO_CHECK 739 40 #define SI_BUILTIN_LIBSTR(name) (char*) #name ".so",41 42 char* si_builtin_libs[]={ SI_FOREACH_BUILTIN(SI_BUILTIN_LIBSTR) NULL };43 44 #undef SI_BUILTIN_LIBSTR45 46 lib_types type_of_LIB(char *newlib, char *libnamebuf)47 {48 const unsigned char mach_o[]={0xfe,0xed,0xfa,0xce,0};49 const unsigned char mach_O[]={0xce,0xfa,0xed,0xfe,0};50 51 const unsigned char mach_o64[]={0xfe,0xed,0xfa,0xcf,0};52 const unsigned char mach_O64[]={0xcf,0xfa,0xed,0xfe,0};53 54 int i=0;55 while(si_builtin_libs[i]!=NULL)56 {57 if (strcmp(newlib,si_builtin_libs[i])==0)58 {59 if(libnamebuf!=NULL) strcpy(libnamebuf,newlib);60 return LT_BUILTIN;61 }62 i++;63 }64 char buf[BYTES_TO_CHECK+1]; /* one extra for terminating '\0' */65 struct stat sb;66 int nbytes = 0;67 int ret;68 lib_types LT=LT_NONE;69 70 FILE * fp = feFopen( newlib, "r", libnamebuf, FALSE );71 72 do73 {74 ret = stat(libnamebuf, &sb);75 } while((ret < 0) and (errno == EINTR));76 77 if (fp==NULL)78 {79 return LT_NOTFOUND;80 }81 if((sb.st_mode & S_IFMT) != S_IFREG)82 {83 goto lib_type_end;84 }85 if ((nbytes = fread((char *)buf, sizeof(char), BYTES_TO_CHECK, fp)) == -1)86 {87 goto lib_type_end;88 /*NOTREACHED*/89 }90 if (nbytes == 0)91 goto lib_type_end;92 else93 {94 buf[nbytes++] = '\0'; /* null-terminate it */95 }96 if( (strncmp(buf, "\177ELF", 4)==0)) /* generic ELF */97 {98 LT = LT_ELF;99 //omFree(newlib);100 //newlib = omStrDup(libnamebuf);101 goto lib_type_end;102 }103 104 if( (strncmp(buf, (const char *)mach_o, 4)==0) || (strncmp(buf, (const char *)mach_O, 4)==0)) /* generic Mach-O module */105 {106 LT = LT_MACH_O;107 //omFree(newlib);108 //newlib = omStrDup(libnamebuf);109 goto lib_type_end;110 }111 112 if( (strncmp(buf, (const char *)mach_o64, 4)==0) || (strncmp(buf, (const char *)mach_O64, 4)==0)) /* generic Mach-O 64-bit module */113 {114 LT = LT_MACH_O;115 //omFree(newlib);116 //newlib = omStrDup(libnamebuf);117 goto lib_type_end;118 }119 120 121 if( (strncmp(buf, "\02\020\01\016\05\022@", 7)==0))122 {123 LT = LT_HPUX;124 //omFree(newlib);125 //newlib = omStrDup(libnamebuf);126 goto lib_type_end;127 }128 if(isprint(buf[0]) || buf[0]=='\n')129 { LT = LT_SINGULAR; goto lib_type_end; }130 131 lib_type_end:132 fclose(fp);133 return LT;134 }135 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/136 38 #if defined(HAVE_DL) 137 39
Note: See TracChangeset
for help on using the changeset viewer.