]>
Commit | Line | Data |
---|---|---|
aa32874b DD |
1 | /* |
2 | * Copyright (c) 2000, Red Hat, Inc. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * A copy of the GNU General Public License can be found at | |
10 | * http://www.gnu.org/ | |
11 | * | |
12 | * Written by DJ Delorie <dj@cygnus.com> | |
13 | * | |
14 | */ | |
15 | ||
16 | #include <windows.h> | |
17 | #include <stdio.h> | |
18 | ||
19 | static HINSTANCE cygwin_dll = 0; | |
20 | static char *cygwin_dll_name = 0; | |
21 | ||
22 | static void (*cygwin_dll_init_proc) (); | |
23 | static int (*mount_proc) (const char *win32_path, const char *posix_path, unsigned flags); | |
24 | static int (*umount_proc) (const char *posix_path); | |
25 | static int (*cygwin_umount_proc) (const char *posix_path, unsigned flags); | |
26 | static FILE * (*setmntent_proc) (const char *, const char *); | |
27 | static struct mntent * (*getmntent_proc) (FILE *); | |
28 | static int (*endmntent_proc) (FILE *); | |
29 | ||
30 | static void | |
31 | one (void *fp, char *name) | |
32 | { | |
33 | int a; | |
34 | *(int *)fp = a = (int) GetProcAddress (cygwin_dll, name); | |
35 | if (!a) | |
36 | { | |
37 | fprintf (stderr, "error: unable to find `%s' in %s\n", name, cygwin_dll_name); | |
38 | exit (1); | |
39 | } | |
40 | } | |
41 | ||
42 | int | |
43 | cygcall_load_dll (char *name) | |
44 | { | |
45 | /* This forces the dll to use a private "shared" area, avoiding version conflicts */ | |
46 | SetEnvironmentVariable("CYGWIN_TESTING", "1"); | |
47 | ||
48 | cygwin_dll = LoadLibrary (name); | |
49 | if (cygwin_dll == 0) | |
50 | return 1; | |
51 | cygwin_dll_name = name; | |
52 | ||
53 | one (&cygwin_dll_init_proc, "cygwin_dll_init"); | |
54 | one (&mount_proc, "mount"); | |
55 | one (&umount_proc, "umount"); | |
56 | one (&cygwin_umount_proc, "cygwin_umount"); | |
57 | one (&setmntent_proc, "setmntent"); | |
58 | one (&getmntent_proc, "getmntent"); | |
59 | one (&endmntent_proc, "endmntent"); | |
60 | ||
61 | cygwin_dll_init_proc (); | |
62 | ||
63 | return 0; | |
64 | } | |
65 | ||
66 | int | |
67 | cygcall_unload_dll () | |
68 | { | |
69 | FreeLibrary (cygwin_dll); | |
70 | } | |
71 | ||
72 | int | |
73 | mount (const char *win32_path, const char *posix_path, unsigned flags) | |
74 | { | |
75 | return mount_proc (win32_path, posix_path, flags); | |
76 | } | |
77 | ||
78 | int | |
79 | umount (const char *posix_path) | |
80 | { | |
81 | return umount_proc (posix_path); | |
82 | } | |
83 | ||
84 | int | |
85 | cygwin_umount (const char *posix_path, unsigned flags) | |
86 | { | |
87 | return cygwin_umount_proc (posix_path, flags); | |
88 | } | |
89 | ||
90 | FILE * | |
91 | setmntent (const char *__filep, const char *__type) | |
92 | { | |
93 | return setmntent_proc (__filep, __type); | |
94 | } | |
95 | ||
96 | struct mntent * | |
97 | getmntent (FILE *__filep) | |
98 | { | |
99 | return getmntent_proc (__filep); | |
100 | } | |
101 | ||
102 | int | |
103 | endmntent (FILE *__filep) | |
104 | { | |
105 | return endmntent_proc (__filep); | |
106 | } | |
107 |