uiautomationcore: Put general purpose helper functions into separate source file.
[wine.git] / dlls / ctapi32 / unixlib.c
blobcdfe6e6eb73793fff9f2c42bf5e6341a4a1c68e9
1 /*
2 * WINE ct-api wrapper
4 * Copyright 2007 Christian Eggers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #if 0
22 #pragma makedep unix
23 #endif
25 #include "config.h"
27 #include <stdarg.h>
28 #include <stdlib.h>
29 #include <dlfcn.h>
31 #include "ntstatus.h"
32 #define WIN32_NO_STATUS
33 #include "unixlib.h"
35 static IS8 (*pCT_init)(IU16 ctn, IU16 pn);
36 static IS8 (*pCT_data)(IU16 ctn, IU8 *dad, IU8 *sad, IU16 lenc, IU8 *command, IU16 *lenr, IU8 *response);
37 static IS8 (*pCT_close)(IU16 ctn);
39 static void *ctapi_handle;
41 static NTSTATUS attach( void *args )
43 const char *libname = args;
45 if (!(ctapi_handle = dlopen( libname, RTLD_NOW ))) return STATUS_DLL_NOT_FOUND;
47 #define LOAD_FUNCPTR(f) if((p##f = dlsym(ctapi_handle, #f)) == NULL) return STATUS_ENTRYPOINT_NOT_FOUND
48 LOAD_FUNCPTR(CT_init);
49 LOAD_FUNCPTR(CT_data);
50 LOAD_FUNCPTR(CT_close);
51 #undef LOAD_FUNCPTR
52 return STATUS_SUCCESS;
55 static NTSTATUS detach( void *args )
57 dlclose( ctapi_handle );
58 return STATUS_SUCCESS;
61 static NTSTATUS ct_init( void *args )
63 const struct ct_init_params *params = args;
65 return pCT_init(params->ctn, params->pn);
68 static NTSTATUS ct_data( void *args )
70 const struct ct_data_params *params = args;
72 return pCT_data(params->ctn, params->dad, params->sad, params->lenc,
73 params->command, params->lenr, params->response);
76 static NTSTATUS ct_close( void *args )
78 const struct ct_close_params *params = args;
80 return pCT_close(params->ctn);
83 const unixlib_entry_t __wine_unix_call_funcs[] =
85 attach,
86 detach,
87 ct_init,
88 ct_data,
89 ct_close,
92 #ifdef _WIN64
94 typedef ULONG PTR32;
96 static NTSTATUS wow64_ct_data( void *args )
98 struct
100 IU16 ctn;
101 PTR32 dad;
102 PTR32 sad;
103 IU16 lenc;
104 PTR32 command;
105 PTR32 lenr;
106 PTR32 response;
107 } const *params32 = args;
109 struct ct_data_params params =
111 params32->ctn,
112 ULongToPtr(params32->dad),
113 ULongToPtr(params32->sad),
114 params32->lenc,
115 ULongToPtr(params32->command),
116 ULongToPtr(params32->lenr),
117 ULongToPtr(params32->response)
120 return ct_data( &params );
123 const unixlib_entry_t __wine_unix_call_wow64_funcs[] =
125 attach,
126 detach,
127 ct_init,
128 wow64_ct_data,
129 ct_close,
132 #endif /* _WIN64 */