PostgreSQL Source Code  git master
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

◆ dlclose()

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().

42 {
43  if (!FreeLibrary((HMODULE) handle))
44  {
45  set_dl_error();
46  return 1;
47  }
48  last_dyn_error[0] = 0;
49  return 0;
50 }
static char last_dyn_error[512]
Definition: win32.c:10
static void set_dl_error(void)
Definition: win32.c:13

◆ dlerror()

char * dlerror ( void  )

Definition at line 32 of file win32.c.

References last_dyn_error.

Referenced by BSD44_derived_dlopen().

33 {
34  if (last_dyn_error[0])
35  return last_dyn_error;
36  else
37  return NULL;
38 }
static char last_dyn_error[512]
Definition: win32.c:10

◆ dlopen()

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().

69 {
70  HMODULE h;
71  int prevmode;
72 
73  /* Disable popup error messages when loading DLLs */
74  prevmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
75  h = LoadLibrary(path);
76  SetErrorMode(prevmode);
77 
78  if (!h)
79  {
80  set_dl_error();
81  return NULL;
82  }
83  last_dyn_error[0] = 0;
84  return (void *) h;
85 }
static char last_dyn_error[512]
Definition: win32.c:10
static void set_dl_error(void)
Definition: win32.c:13

◆ dlsym()

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().

54 {
55  void *ptr;
56 
57  ptr = GetProcAddress((HMODULE) handle, symbol);
58  if (!ptr)
59  {
60  set_dl_error();
61  return NULL;
62  }
63  last_dyn_error[0] = 0;
64  return ptr;
65 }
static char last_dyn_error[512]
Definition: win32.c:10
static void set_dl_error(void)
Definition: win32.c:13
unsigned char symbol
Definition: api.h:2

◆ set_dl_error()

static void set_dl_error ( void  )
static

Definition at line 13 of file win32.c.

References last_dyn_error, and snprintf().

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

14 {
15  DWORD err = GetLastError();
16 
17  if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS |
18  FORMAT_MESSAGE_FROM_SYSTEM,
19  NULL,
20  err,
21  MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
23  sizeof(last_dyn_error) - 1,
24  NULL) == 0)
25  {
27  "unknown error %lu", err);
28  }
29 }
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
static char last_dyn_error[512]
Definition: win32.c:10

Variable Documentation

◆ last_dyn_error

char last_dyn_error[512]
static

Definition at line 10 of file win32.c.

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