• Eli Zaretskii's avatar
    Improve MS-Windows implementation in dynlib.c · 24be1c84
    Eli Zaretskii authored
    * src/dynlib.c [WINDOWSNT]: Include errno.h, lisp.h, and w32.h.
    No need to include windows.h, as w32.h already does that.
    <dynlib_last_err>: New static variable.
    (dynlib_reset_last_error): New function.
    (dynlib_open): Convert forward slashes to backslashes.  Convert
    file names from UTF-8 to either UTF-16 or the current ANSI
    codepage, and call either LoadLibraryW or LoadLibraryA.  If the
    argument is NULL, return a handle to the main module, like
    'dlopen' does.  Record the error, if any, for use by dynlib_error.
    (dynlib_sym): Check the handle for validity. Record the error, if
    any, for use by dynlib_error.
    (dynlib_error): Call w32_strerror to produce the error string, and
    zero out the last error code, like dlerror does.
    (dynlib_close): Check the handle for validity.  Record the error,
    if any, for use by dynlib_error.  Don't call FreeLibrary with a
    handle for the main module.
    * src/w32.c (globals_of_w32): Call dynlib_reset_last_error.
    24be1c84
w32.c 257 KB