scroll mode for very long start menus
[reactos.git] / posix / lib / psxdll / dlfcn / dlclose.c
1 /* $Id: dlclose.c,v 1.4 2002/10/29 04:45:28 rex Exp $
2 */
3 /*
4 * COPYRIGHT: See COPYING in the top level directory
5 * PROJECT: ReactOS POSIX+ Subsystem
6 * FILE: subsys/psx/lib/psxdll/dlfcn/dlclose.c
7 * PURPOSE: Close a dlopen() object
8 * PROGRAMMER: KJK::Hyperion <noog@libero.it>
9 * UPDATE HISTORY:
10 * 19/12/2001: Created
11 */
12
13 #include <ddk/ntddk.h>
14 #include <ntdll/rtl.h>
15 #include <ntdll/ldr.h>
16 #include <dlfcn.h>
17 #include <stdlib.h>
18 #include <psx/debug.h>
19 #include <psx/dlfcn.h>
20 #include <psx/errno.h>
21
22 int dlclose(void *handle)
23 {
24 if(handle == 0)
25 {
26 ERR("invalid handle passed to dlclose");
27
28 __dl_set_last_error(EFAULT); /* FIXME? maybe EINVAL? */
29 return (-1);
30 }
31
32 if(((struct __dlobj *)handle)->global)
33 {
34 TODO("global symbol matching not implemented");
35
36 __dl_set_last_error(EINVAL);
37 return (-1);
38 }
39 else
40 {
41 NTSTATUS nErrCode = LdrUnloadDll(((struct __dlobj *)handle)->handle);
42
43 if(!NT_SUCCESS(nErrCode))
44 {
45 ERR("LdrUnloadDll(%#x) failed with status %d", ((struct __dlobj *)handle)->handle, nErrCode);
46
47 free(handle);
48 __dl_set_last_error(__status_to_errno(nErrCode));
49 return (-1);
50 }
51 }
52
53 free(handle);
54
55 return (0);
56
57 }
58
59 /* EOF */
60