本文整理汇总了C++中NSLinkEditError函数的典型用法代码示例。如果您正苦于以下问题:C++ NSLinkEditError函数的具体用法?C++ NSLinkEditError怎么用?C++ NSLinkEditError使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NSLinkEditError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dlerror
const char*
dlerror()
{
NSLinkEditErrors c;
int errorNumber;
const char *fileName, *errorString;
char *result = NULL;
if (last_error) {
NSLinkEditError(&c, &errorNumber, &fileName, &errorString);
/* The errorString obtained by the above is too verbose for
* our needs, so we just translate the errno.
*
* We also have simple fallbacks in case we've somehow lost
* the context before this point. */
if (errorNumber) {
result = strerror(errorNumber);
} else if (DLSYM_ERROR == last_error) {
result = "dlsym(3) failed";
} else if (DLOPEN_ERROR == last_error) {
result = "dlopen(3) failed";
}
last_error = 0;
}
return result;
}
示例2: pr_LoadMachDyldModule
static NSModule
pr_LoadMachDyldModule(const char *name)
{
NSObjectFileImage ofi;
NSModule h = NULL;
if (NSCreateObjectFileImageFromFile(name, &ofi)
== NSObjectFileImageSuccess) {
h = NSLinkModule(ofi, name, NSLINKMODULE_OPTION_PRIVATE
| NSLINKMODULE_OPTION_RETURN_ON_ERROR);
if (h == NULL) {
NSLinkEditErrors linkEditError;
int errorNum;
const char *fileName;
const char *errorString;
NSLinkEditError(&linkEditError, &errorNum, &fileName, &errorString);
PR_LOG(_pr_linker_lm, PR_LOG_MIN,
("LoadMachDyldModule error %d:%d for file %s:\n%s",
linkEditError, errorNum, fileName, errorString));
}
if (NSDestroyObjectFileImage(ofi) == FALSE) {
if (h) {
(void)NSUnLinkModule(h, NSUNLINKMODULE_OPTION_NONE);
h = NULL;
}
}
}
return h;
}
示例3: OW_LOG_DEBUG
SharedLibraryRef
dyldSharedLibraryLoader::loadSharedLibrary(const String& filename,
const LoggerRef& logger) const
{
OW_LOG_DEBUG(logger, Format("Load request for %1 received.", filename));
NSObjectFileImage image = 0;
NSObjectFileImageReturnCode dsoerr = NSCreateObjectFileImageFromFile(filename.c_str(), &image);
const char* err_msg = NULL;
NSModule libhandle = NULL;
if (dsoerr == NSObjectFileImageSuccess)
{
libhandle = NSLinkModule(image, filename.c_str(), NSLINKMODULE_OPTION_RETURN_ON_ERROR | NSLINKMODULE_OPTION_PRIVATE);
if (!libhandle)
{
NSLinkEditErrors errors;
int errorNumber;
const char *fileName;
NSLinkEditError(&errors, &errorNumber, &fileName, &err_msg);
}
NSDestroyObjectFileImage(image);
}
else if ((dsoerr == NSObjectFileImageFormat ||
dsoerr == NSObjectFileImageInappropriateFile) &&
NSAddLibrary(filename.c_str()) == TRUE)
{
OW_LOG_ERROR(logger, Format("NSCreateObject: %1 failed with error \"%2\"",
filename, dsoerr));
// libhandle = (NSModule)DYLD_LIBRARY_HANDLE;
}
else
{
err_msg = "cannot create object file image or add library";
OW_LOG_ERROR(logger, Format("NSCreateObject: %1 failed with error %2",
filename, dsoerr));
}
if (libhandle)
{
try
{
return SharedLibraryRef( new dyldSharedLibrary(libhandle,
filename));
}
catch (...)
{
NSUnLinkModule(libhandle, FALSE);
throw;
}
}
else
{
OW_LOG_ERROR(logger, Format("dyldSharedLibraryLoader::loadSharedLibrary:"
" %1", err_msg));
return SharedLibraryRef( 0 );
}
}
示例4: _CFBundleDYLDLoadFramework
CF_PRIVATE Boolean _CFBundleDYLDLoadFramework(CFBundleRef bundle, CFErrorRef *error) {
// !!! Framework loading should be better. Can't unload frameworks.
CFErrorRef localError = NULL, *subError = (error ? &localError : NULL);
NSLinkEditErrors c = NSLinkEditUndefinedError;
int errorNumber = 0;
const char *fileName = NULL;
const char *errorString = NULL;
if (!bundle->_isLoaded) {
CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
char buff[CFMaxPathSize];
if (executableURL && CFURLGetFileSystemRepresentation(executableURL, true, (uint8_t *)buff, CFMaxPathSize)) {
void *image = (void *)NSAddImage(buff, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
#if LOG_BUNDLE_LOAD
printf("dyld load framework %p, add image of %s returns image %p\n", bundle, buff, image);
#endif /* LOG_BUNDLE_LOAD */
if (image) {
bundle->_imageCookie = image;
bundle->_isLoaded = true;
} else {
NSLinkEditError(&c, &errorNumber, &fileName, &errorString);
if (error) {
#if defined(BINARY_SUPPORT_DLFCN)
_CFBundleDlfcnPreflight(bundle, subError);
#endif /* BINARY_SUPPORT_DLFCN */
if (!localError) {
CFStringRef tempString = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, errorString), debugString = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("error code %d, error number %d (%@)"), c, errorNumber, tempString);
localError = _CFBundleCreateErrorDebug(CFGetAllocator(bundle), bundle, CFBundleExecutableLinkError, debugString);
if (tempString) CFRelease(tempString);
if (debugString) CFRelease(debugString);
}
} else {
CFStringRef tempString = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, errorString), executableString = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, fileName);
CFLog(__kCFLogBundle, CFSTR("Error loading %@: error code %d, error number %d (%@)"), executableString, c, errorNumber, tempString);
if (tempString) CFRelease(tempString);
if (executableString) CFRelease(executableString);
}
}
} else {
if (error) {
localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotFoundError);
} else {
CFLog(__kCFLogBundle, CFSTR("Cannot find executable for bundle %@"), bundle);
}
}
if (executableURL) CFRelease(executableURL);
}
if (!bundle->_isLoaded && error) *error = localError;
return bundle->_isLoaded;
}
示例5: NSLinkEditError
const char *vmddlerror( void ) {
NSLinkEditErrors c;
int errorNumber;
const char *fileName;
const char *errorString = NULL;
NSLinkEditError(&c, &errorNumber, &fileName, &errorString);
return errorString;
}
示例6: pusherror
static void pusherror (lua_State *L) {
const char* err_str;
const char* err_file;
NSLinkEditErrors err;
int err_num;
NSLinkEditError(&err, &err_num, &err_file, &err_str);
lua_pushstring(L, err_str);
}
示例7: logDyldError
static void
logDyldError (const char *action) {
NSLinkEditErrors errors;
int number;
const char *file;
const char *message;
NSLinkEditError(&errors, &number, &file, &message);
logMessage(LOG_ERR, "%.*s", (int)(strlen(message)-1), message);
}
示例8: caml_dlerror
char * caml_dlerror(void)
{
NSLinkEditErrors c;
int errnum;
const char *fileName, *errorString;
if (dlerror_string != NULL) return dlerror_string;
NSLinkEditError(&c,&errnum,&fileName,&errorString);
return (char *) errorString;
}
示例9: WXUNUSED
static void *wx_darwin_dlopen(const char *path, int WXUNUSED(mode) /* mode is ignored */)
{
NSObjectFileImage ofile;
NSModule handle = NULL;
unsigned dyld_result = NSCreateObjectFileImageFromFile(path, &ofile);
if ( dyld_result != NSObjectFileImageSuccess )
{
handle = NULL;
static const char *const errorStrings[] =
{
"%d: Object Image Load Failure",
"%d: Object Image Load Success",
"%d: Not an recognisable object file",
"%d: No valid architecture",
"%d: Object image has an invalid format",
"%d: Invalid access (permissions?)",
"%d: Unknown error code from NSCreateObjectFileImageFromFile"
};
const int index = dyld_result < WXSIZEOF(errorStrings)
? dyld_result
: WXSIZEOF(errorStrings) - 1;
// this call to sprintf() is safe as strings above are fixed at
// compile-time and are shorter than WXSIZEOF(dl_last_error)
sprintf(dl_last_error, errorStrings[index], dyld_result);
}
else
{
handle = NSLinkModule
(
ofile,
path,
NSLINKMODULE_OPTION_BINDNOW |
NSLINKMODULE_OPTION_RETURN_ON_ERROR
);
if ( !handle )
{
NSLinkEditErrors err;
int code;
const char *filename;
const char *errmsg;
NSLinkEditError(&err, &code, &filename, &errmsg);
strncpy(dl_last_error, errmsg, WXSIZEOF(dl_last_error)-1);
dl_last_error[WXSIZEOF(dl_last_error)-1] = '\0';
}
}
return handle;
}
示例10: dyld_dlerror
static const char * dyld_dlerror()
{
NSLinkEditErrors ler;
int lerno;
const char *errstr;
const char *file;
NSLinkEditError(&ler, &lerno, &file, &errstr);
if (!dyld_error_set) errstr=NULL;
dyld_error_set=0;
return errstr;
}
示例11: NSLinkEditError
/* Up to the caller to free() returned string */
static inline const char *dyld_error_str()
{
NSLinkEditErrors dylder;
int dylderno;
const char *dylderrstr;
const char *dyldfile;
const char* retStr = NULL;
NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr);
if (dylderrstr && strlen(dylderrstr))
{
retStr = malloc(strlen(dylderrstr) +1);
strcpy((char*)retStr,dylderrstr);
}
return retStr;
}
示例12: dylderror
/* Return the dyld error string, or the passed in error string if none. */
static const char *
dylderror (const char *errmsg)
{
NSLinkEditErrors ler;
int lerno;
const char *file;
const char *errstr;
NSLinkEditError (&ler, &lerno, &file, &errstr);
if (! (errstr && *errstr))
{
errstr = errmsg;
}
return errstr;
}
示例13: XPCOMGlueLoad
nsresult
XPCOMGlueLoad(const char *xpcomFile, GetFrozenFunctionsFunc *func)
{
const mach_header* lib = nsnull;
if (xpcomFile[0] != '.' || xpcomFile[1] != '\0') {
char xpcomDir[PATH_MAX];
if (realpath(xpcomFile, xpcomDir)) {
char *lastSlash = strrchr(xpcomDir, '/');
if (lastSlash) {
*lastSlash = '\0';
XPCOMGlueLoadDependentLibs(xpcomDir, ReadDependentCB);
snprintf(lastSlash, PATH_MAX - strlen(xpcomDir), "/" XUL_DLL);
sXULLibImage = NSAddImage(xpcomDir,
NSADDIMAGE_OPTION_RETURN_ON_ERROR |
NSADDIMAGE_OPTION_WITH_SEARCHING |
NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME);
}
}
lib = NSAddImage(xpcomFile,
NSADDIMAGE_OPTION_RETURN_ON_ERROR |
NSADDIMAGE_OPTION_WITH_SEARCHING |
NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME);
if (!lib) {
NSLinkEditErrors linkEditError;
int errorNum;
const char *errorString;
const char *fileName;
NSLinkEditError(&linkEditError, &errorNum, &fileName, &errorString);
fprintf(stderr, "XPCOMGlueLoad error %d:%d for file %s:\n%s\n",
linkEditError, errorNum, fileName, errorString);
}
}
*func = (GetFrozenFunctionsFunc) LookupSymbol(lib, "_NS_GetFrozenFunctions");
return *func ? NS_OK : NS_ERROR_NOT_AVAILABLE;
}
示例14: pg_dlerror
char *
pg_dlerror(void)
{
NSLinkEditErrors c;
int errorNumber;
const char *fileName;
const char *errorString = NULL;
switch (cofiff_result)
{
case NSObjectFileImageSuccess:
/* must have failed in NSLinkModule */
NSLinkEditError(&c, &errorNumber, &fileName, &errorString);
if (errorString == NULL || *errorString == '\0')
errorString = "unknown link-edit failure";
break;
case NSObjectFileImageFailure:
errorString = "failed to open object file";
break;
case NSObjectFileImageInappropriateFile:
errorString = "inappropriate object file";
break;
case NSObjectFileImageArch:
errorString = "object file is for wrong architecture";
break;
case NSObjectFileImageFormat:
errorString = "object file has wrong format";
break;
case NSObjectFileImageAccess:
errorString = "insufficient permissions for object file";
break;
default:
errorString = "unknown failure to open object file";
break;
}
return (char *) errorString;
}
示例15: va_start
/* Set and get the error string for use by dlerror */
static const char *error(int setget, const char *str, ...)
{
static char errstr[ERR_STR_LEN];
static int err_filled = 0;
const char *retval;
NSLinkEditErrors ler;
int lerno;
const char *dylderrstr;
const char *file;
va_list arg;
if (setget <= 0)
{
va_start(arg, str);
strncpy(errstr, "dlsimple: ", ERR_STR_LEN);
str_vsnprintf(errstr + 10, ERR_STR_LEN - 10, str, arg);
va_end(arg);
/* We prefer to use the dyld error string if setget is 0 */
if (setget == 0) {
NSLinkEditError(&ler, &lerno, &file, &dylderrstr);
fprintf(stderr,"dyld: %s\n",dylderrstr);
if (dylderrstr && str_len(dylderrstr))
strncpy(errstr,dylderrstr,ERR_STR_LEN);
}
err_filled = 1;
retval = NULL;
}
else
{
if (!err_filled)
retval = NULL;
else
retval = errstr;
err_filled = 0;
}
return retval;
}