Header And Logo

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

Defines | Functions

openbsd.h File Reference

#include <sys/types.h>
#include <nlist.h>
#include <link.h>
#include <dlfcn.h>
#include "utils/dynamic_loader.h"
Include dependency graph for openbsd.h:

Go to the source code of this file.

Defines

#define RTLD_NOW   1
#define RTLD_GLOBAL   0
#define pg_dlopen(f)   BSD44_derived_dlopen((f), RTLD_NOW | RTLD_GLOBAL)
#define pg_dlsym   BSD44_derived_dlsym
#define pg_dlclose   BSD44_derived_dlclose
#define pg_dlerror   BSD44_derived_dlerror

Functions

char * BSD44_derived_dlerror (void)
void * BSD44_derived_dlopen (const char *filename, int num)
void * BSD44_derived_dlsym (void *handle, const char *name)
void BSD44_derived_dlclose (void *handle)

Define Documentation

#define pg_dlclose   BSD44_derived_dlclose

Definition at line 51 of file openbsd.h.

#define pg_dlerror   BSD44_derived_dlerror

Definition at line 52 of file openbsd.h.

#define pg_dlopen (   f  )     BSD44_derived_dlopen((f), RTLD_NOW | RTLD_GLOBAL)

Definition at line 49 of file openbsd.h.

#define pg_dlsym   BSD44_derived_dlsym

Definition at line 50 of file openbsd.h.

#define RTLD_GLOBAL   0

Definition at line 46 of file openbsd.h.

#define RTLD_NOW   1

Definition at line 43 of file openbsd.h.


Function Documentation

void BSD44_derived_dlclose ( void *  handle  ) 

Definition at line 101 of file freebsd.c.

References dlclose().

{
#if defined(HAVE_DLOPEN)
    dlclose(handle);
#endif
}

char* BSD44_derived_dlerror ( void   ) 

Definition at line 48 of file freebsd.c.

References error_message, and NULL.

{
    static char ret[BUFSIZ];

    strcpy(ret, error_message);
    error_message[0] = 0;
    return (ret[0] == 0) ? NULL : ret;
}

void* BSD44_derived_dlopen ( const char *  filename,
int  num 
)

Definition at line 58 of file freebsd.c.

References dlerror(), dlopen(), error_message, NULL, and snprintf().

{
#if !defined(HAVE_DLOPEN)
    snprintf(error_message, sizeof(error_message),
             "dlopen (%s) not supported", file);
    return NULL;
#else
    void       *vp;

    if ((vp = dlopen((char *) file, num)) == NULL)
        snprintf(error_message, sizeof(error_message),
                 "dlopen (%s) failed: %s", file, dlerror());
    return vp;
#endif
}

void* BSD44_derived_dlsym ( void *  handle,
const char *  name 
)

Definition at line 75 of file freebsd.c.

References buf, dlsym(), error_message, NULL, and snprintf().

{
#if !defined(HAVE_DLOPEN)
    snprintf(error_message, sizeof(error_message),
             "dlsym (%s) failed", name);
    return NULL;
#else
    void       *vp;

#ifndef __ELF__
    char        buf[BUFSIZ];

    if (*name != '_')
    {
        snprintf(buf, sizeof(buf), "_%s", name);
        name = buf;
    }
#endif   /* !__ELF__ */
    if ((vp = dlsym(handle, (char *) name)) == NULL)
        snprintf(error_message, sizeof(error_message),
                 "dlsym (%s) failed", name);
    return vp;
#endif
}