Loading...
Searching...
No Matches
mod_lib.h File Reference
`#include "kernel/mod2.h"`
`#include "polys/mod_raw.h"`

Go to the source code of this file.

## Macros

#define | SI_MOD_INIT0(name)
#define | SI_FOREACH_BUILTIN(add)
| Data for `type_of_LIB` to determine built-in modules, use `add(name)` to add built-in library to macro.

## Functions

lib_types | type_of_LIB (const char *newlib, char *fullname)

## Macro Definition Documentation

## SI_FOREACH_BUILTIN

#define SI_FOREACH_BUILTIN | ( |  | add | ) |

Value:
SI_BUILTINMODULES_ADD(add)
add
STATIC_VAR unsigned add[]
Definition misc_ip.cc:108

Data for `type_of_LIB` to determine built-in modules, use `add(name)` to add built-in library to macro.

Definition at line 17 of file mod_lib.h.

## SI_MOD_INIT0

#define SI_MOD_INIT0 | ( |  | name | ) |

Value:
name##_mod_init
name
char name(const Variable &v)
Definition factory.h:189

Definition at line 4 of file mod_lib.h.

## Function Documentation

## type_of_LIB()

lib_types type_of_LIB | ( | const char * | newlib,
|  | char * | fullname )

Definition at line 27 of file mod_lib.cc.

{
const unsigned char mach_o[]={0xfe,0xed,0xfa,0xce,0};
const unsigned char mach_O[]={0xce,0xfa,0xed,0xfe,0};
const unsigned char mach_o64[]={0xfe,0xed,0xfa,0xcf,0};
const unsigned char mach_O64[]={0xcf,0xfa,0xed,0xfe,0};
const unsigned char mach_FAT[]={0xca,0xfe,0xba,0xbe,0};
const unsigned char mach_fat[]={0xbe,0xba,0xfe,0xca,0};
const unsigned char utf16be[]={0xfe,0xff,0};
const unsigned char utf16le[]={0xff,0xfe,0};
const unsigned char utf8ms[]={0xEF,0xBB,0xBF,0};
const unsigned char dll[]={'M','Z',0};
int i=0;
while(si_builtin_libs[i]!=NULL)
{
if (strcmp(newlib,si_builtin_libs[i])==0)
{
if(libnamebuf!=NULL) strcpy(libnamebuf,newlib);
return LT_BUILTIN;
}
i++;
}
char buf[BYTES_TO_CHECK+1]; /* one extra for terminating '\0' */
struct stat sb;
int nbytes = 0;
int ret;
lib_types LT=LT_NONE;
FILE * fp = feFopen( newlib, "r", libnamebuf, FALSE );
do
{
ret = stat(libnamebuf, &sb);
} while((ret < 0) and (errno == EINTR));
if (fp==NULL)
{
return LT_NOTFOUND;
}
if((sb.st_mode & S_IFMT) != S_IFREG)
{
goto lib_type_end;
}
if ((nbytes = fread((char *)buf, sizeof(char), BYTES_TO_CHECK, fp)) == -1)
{
goto lib_type_end;
/*NOTREACHED*/
}
if (nbytes == 0)
goto lib_type_end;
else
{
buf[nbytes++] = '\0'; /* null-terminate it */
}
if( (strncmp(buf, "\177ELF", 4)==0)) /* generic ELF */
{
LT = LT_ELF;
//omFree(newlib);
//newlib = omStrDup(libnamebuf);
goto lib_type_end;
}
if( (strncmp(buf, (const char *)mach_o, 4)==0) || (strncmp(buf, (const char *)mach_O, 4)==0)) /* generic Mach-O module */
{
LT = LT_MACH_O;
//omFree(newlib);
//newlib = omStrDup(libnamebuf);
goto lib_type_end;
}
if( (strncmp(buf, (const char *)mach_o64, 4)==0) || (strncmp(buf, (const char *)mach_O64, 4)==0)) /* generic Mach-O 64-bit module */
{
LT = LT_MACH_O;
//omFree(newlib);
//newlib = omStrDup(libnamebuf);
goto lib_type_end;
}
if( (strncmp(buf, (const char *)mach_FAT, 4)==0) || (strncmp(buf, (const char *)mach_fat, 4)==0)) /* generic Mach-O fat universal module */
{
LT = LT_MACH_O;
//omFree(newlib);
//newlib = omStrDup(libnamebuf);
goto lib_type_end;
}
if( (strncmp(buf, "\02\020\01\016\05\022@", 7)==0))
{
LT = LT_HPUX;
//omFree(newlib);
//newlib = omStrDup(libnamebuf);
goto lib_type_end;
}
if ((strncmp(buf,(const char *)utf16be,2)==0)
||(strncmp(buf,(const char *)utf16le,2)==0))
{
WerrorS("UTF-16 not supported");
LT=LT_NOTFOUND;
goto lib_type_end;
}
if (strncmp(buf,(const char *)utf8ms,3)==0)
{
WarnS("UTF-8 detected - may not work");
LT=LT_SINGULAR;
goto lib_type_end;
}
if (strncmp(buf,(const char *)dll,2)==0)
{
LT=LT_DLL;
goto lib_type_end;
}
if(isprint(buf[0]) || buf[0]=='\n')
{ LT = LT_SINGULAR; goto lib_type_end; }
lib_type_end:
fclose(fp);
return LT;
}
FALSE
#define FALSE
Definition auxiliary.h:97
i
int i
Definition cfEzgcd.cc:132
fp
CanonicalForm fp
Definition cfModGcd.cc:4110
WarnS
#define WarnS
Definition emacs.cc:78
feFopen
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition feFopen.cc:47
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
libnamebuf
VAR char libnamebuf[1024]
Definition libparse.cc:1098
si_builtin_libs
const char *const si_builtin_libs[]
Definition mod_lib.cc:16
BYTES_TO_CHECK
#define BYTES_TO_CHECK
Definition mod_lib.cc:25
lib_types
lib_types
Definition mod_raw.h:16
LT_MACH_O
@ LT_MACH_O
Definition mod_raw.h:16
LT_HPUX
@ LT_HPUX
Definition mod_raw.h:16
LT_DLL
@ LT_DLL
Definition mod_raw.h:16
LT_SINGULAR
@ LT_SINGULAR
Definition mod_raw.h:16
LT_BUILTIN
@ LT_BUILTIN
Definition mod_raw.h:16
LT_ELF
@ LT_ELF
Definition mod_raw.h:16
LT_NONE
@ LT_NONE
Definition mod_raw.h:16
LT_NOTFOUND
@ LT_NOTFOUND
Definition mod_raw.h:16
NULL
#define NULL
Definition omList.c:12
buf
int status int void * buf
Definition si_signals.h:69