Header And Logo

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

Functions | Variables

win32.c File Reference

#include "postgres.h"
Include dependency graph for win32.c:

Go to the source code of this file.

Functions

char * dlerror (void)
int dlclose (void *handle)
void * dlsym (void *handle, const char *symbol)
void * dlopen (const char *path, int mode)
static void set_dl_error (void)

Variables

static char last_dyn_error [512]

Function Documentation

int dlclose ( void *  handle  ) 

Definition at line 41 of file win32.c.

References last_dyn_error, and set_dl_error().

Referenced by BSD44_derived_dlclose().

{
    if (!FreeLibrary((HMODULE) handle))
    {
        set_dl_error();
        return 1;
    }
    last_dyn_error[0] = 0;
    return 0;
}

char * dlerror ( void   ) 

Definition at line 32 of file win32.c.

References last_dyn_error.

Referenced by BSD44_derived_dlopen().

{
    if (last_dyn_error[0])
        return last_dyn_error;
    else
        return NULL;
}

void * dlopen ( const char *  path,
int  mode 
)

Definition at line 68 of file win32.c.

References last_dyn_error, and set_dl_error().

Referenced by BSD44_derived_dlopen().

{
    HMODULE     h;
    int         prevmode;

    /* Disable popup error messages when loading DLLs */
    prevmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
    h = LoadLibrary(path);
    SetErrorMode(prevmode);

    if (!h)
    {
        set_dl_error();
        return NULL;
    }
    last_dyn_error[0] = 0;
    return (void *) h;
}

void * dlsym ( void *  handle,
const char *  symbol 
)

Definition at line 53 of file win32.c.

References last_dyn_error, and set_dl_error().

Referenced by BSD44_derived_dlsym().

{
    void       *ptr;

    ptr = GetProcAddress((HMODULE) handle, symbol);
    if (!ptr)
    {
        set_dl_error();
        return NULL;
    }
    last_dyn_error[0] = 0;
    return ptr;
}

static void set_dl_error ( void   )  [static]

Definition at line 13 of file win32.c.

References last_dyn_error, NULL, and snprintf().

Referenced by dlclose(), dlopen(), and dlsym().

{
    DWORD       err = GetLastError();

    if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS |
                      FORMAT_MESSAGE_FROM_SYSTEM,
                      NULL,
                      err,
                      MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
                      last_dyn_error,
                      sizeof(last_dyn_error) - 1,
                      NULL) == 0)
    {
        snprintf(last_dyn_error, sizeof(last_dyn_error) - 1,
                 "unknown error %lu", err);
    }
}


Variable Documentation

char last_dyn_error[512] [static]

Definition at line 10 of file win32.c.

Referenced by dlclose(), dlerror(), dlopen(), dlsym(), and set_dl_error().