Header And Logo

PostgreSQL
| The world's most advanced open source database.

Functions

dynamic_loader.h File Reference

#include "fmgr.h"
Include dependency graph for dynamic_loader.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void * pg_dlopen (char *filename)
PGFunction pg_dlsym (void *handle, char *funcname)
void pg_dlclose (void *handle)
char * pg_dlerror (void)

Function Documentation

void pg_dlclose ( void *  handle  ) 

Definition at line 70 of file darwin.c.

References FALSE, and free.

{
    NSUnLinkModule(handle, FALSE);
}

char* pg_dlerror ( void   ) 

Definition at line 97 of file darwin.c.

References cofiff_result, errmsg(), NULL, and strerror().

{
    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;
}

void* pg_dlopen ( char *  filename  ) 

Definition at line 57 of file darwin.c.

References cofiff_result, elog, ERROR, sort-test::list, my_exec_path, and WARNING.

{
    NSObjectFileImage image;

    cofiff_result = NSCreateObjectFileImageFromFile(filename, &image);
    if (cofiff_result != NSObjectFileImageSuccess)
        return NULL;
    return NSLinkModule(image, filename,
                        NSLINKMODULE_OPTION_BINDNOW |
                        NSLINKMODULE_OPTION_RETURN_ON_ERROR);
}

PGFunction pg_dlsym ( void *  handle,
char *  funcname 
)

Definition at line 76 of file darwin.c.

References free, malloc, and NULL.

{
    NSSymbol symbol;
    char       *symname = (char *) malloc(strlen(funcname) + 2);

    sprintf(symname, "_%s", funcname);
    if (NSIsSymbolNameDefined(symname))
    {
        symbol = NSLookupAndBindSymbol(symname);

        free(symname);
        return (PGFunction) NSAddressOfSymbol(symbol);
    }
    else
    {
        free(symname);
        return NULL;
    }
}