[xml] Creating Win32 wrapper function for exported variables



In Win32 you can import only functions from a library (.DLL) and not
variables.  This causes problems if libxml2 is built as a dll, and a program
attempts to use an exported variable.  It will compile/link, but will fail
at runtime.

I propose creating simple wrappers for global parsing variables.  A good
example program is xsltproc, which has a line

if (novalid == 0)
  xmlLoadExtDtdDefaultValue = 6;
else
  xmlLoadExtDtdDefaultValue = 0;

If xsltproc is linked against libxml2 as a .DLL (not as a .lib), this will
cause a segv.

I created a wrapper function in parserInternals so the code now looks like

if (novalid == 0)
  xmlSetLoadExtDtdDefaultValue(6);
else
  xmlSetLoadExtDtdDefaultValue(0);

Extremely simple, but saves us win32 programmers some troubles. (I also have
a xmlGetLoadExtDtdDefaultValue wrapper).

What do you think?  




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]