fdopen: don't rewind the file after creating the FILE* handle. Added
[wine] / dlls / oleaut32 / typelib16.c
1 /*
2  *      TYPELIB 16bit part.
3  *
4  * Copyright 1997 Marcus Meissner
5  * Copyright 1999 Rein Klazes
6  * Copyright 2000 Francois Jacques
7  * Copyright 2001 Huw D M Davies for CodeWeavers
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23
24 #include "config.h"
25 #include "wine/port.h"
26
27 #include <stdlib.h>
28 #include <string.h>
29 #include <stdio.h>
30 #include <ctype.h>
31
32 #include "winerror.h"
33 #include "winnls.h"         /* for PRIMARYLANGID */
34 #include "winreg.h"         /* for HKEY_LOCAL_MACHINE */
35 #include "winuser.h"
36
37 #include "objbase.h"
38 #include "ole2disp.h"
39 #include "typelib.h"
40 #include "wine/debug.h"
41
42 WINE_DEFAULT_DEBUG_CHANNEL(ole);
43
44 /****************************************************************************
45  *              QueryPathOfRegTypeLib   [TYPELIB.14]
46  *
47  * the path is "Classes\Typelib\<guid>\<major>.<minor>\<lcid>\win16\"
48  * RETURNS
49  *      path of typelib
50  */
51 HRESULT WINAPI
52 QueryPathOfRegTypeLib16(
53         REFGUID guid,   /* [in] referenced guid */
54         WORD wMaj,      /* [in] major version */
55         WORD wMin,      /* [in] minor version */
56         LCID lcid,      /* [in] locale id */
57         LPBSTR16 path   /* [out] path of typelib */
58 ) {
59         char    xguid[80];
60         char    typelibkey[100],pathname[260];
61         DWORD   plen;
62
63         TRACE("\n");
64
65         if (HIWORD(guid)) {
66             sprintf( typelibkey, "SOFTWARE\\Classes\\Typelib\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\%d.%d\\%lx\\win16",
67                      guid->Data1, guid->Data2, guid->Data3,
68                      guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
69                      guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7],
70                      wMaj,wMin,lcid);
71         } else {
72                 sprintf(xguid,"<guid 0x%08lx>",(DWORD)guid);
73                 FIXME("(%s,%d,%d,0x%04lx,%p),can't handle non-string guids.\n",xguid,wMaj,wMin,(DWORD)lcid,path);
74                 return E_FAIL;
75         }
76         plen = sizeof(pathname);
77         if (RegQueryValueA(HKEY_LOCAL_MACHINE,typelibkey,pathname,&plen)) {
78                 /* try again without lang specific id */
79                 if (SUBLANGID(lcid))
80                         return QueryPathOfRegTypeLib16(guid,wMaj,wMin,PRIMARYLANGID(lcid),path);
81                 FIXME("key %s not found\n",typelibkey);
82                 return E_FAIL;
83         }
84         *path = SysAllocString16(pathname);
85         return S_OK;
86 }
87
88 /******************************************************************************
89  * LoadTypeLib [TYPELIB.3]  Loads and registers a type library
90  * NOTES
91  *    Docs: OLECHAR FAR* szFile
92  *    Docs: iTypeLib FAR* FAR* pptLib
93  *
94  * RETURNS
95  *    Success: S_OK
96  *    Failure: Status
97  */
98 HRESULT WINAPI LoadTypeLib16(
99     LPOLESTR szFile, /* [in] Name of file to load from */
100     ITypeLib** pptLib) /* [out] Pointer to pointer to loaded type library */
101 {
102     FIXME("(%s,%p): stub\n",debugstr_w((LPWSTR)szFile),pptLib);
103
104     if (pptLib!=0)
105       *pptLib=0;
106
107     return E_FAIL;
108 }
109
110 /****************************************************************************
111  *      OaBuildVersion                          (TYPELIB.15)
112  *
113  * known TYPELIB.DLL versions:
114  *
115  * OLE 2.01 no OaBuildVersion() avail   1993    --      ---
116  * OLE 2.02                             1993-94 02     3002
117  * OLE 2.03                                     23      730
118  * OLE 2.03                                     03     3025
119  * OLE 2.03 W98 SE orig. file !!        1993-95 10     3024
120  * OLE 2.1   NT                         1993-95 ??      ???
121  * OLE 2.3.1 W95                                23      700
122  * OLE2 4.0  NT4SP6                     1993-98 40     4277
123  */
124 DWORD WINAPI OaBuildVersion16(void)
125 {
126     /* FIXME: I'd like to return the highest currently known version value
127      * in case the user didn't force a --winver, but I don't know how
128      * to retrieve the "versionForced" info from misc/version.c :(
129      * (this would be useful in other places, too) */
130     FIXME("If you get version error messages, please report them\n");
131     switch(GetVersion() & 0x8000ffff)  /* mask off build number */
132     {
133     case 0x80000a03:  /* WIN31 */
134                 return MAKELONG(3027, 3); /* WfW 3.11 */
135     case 0x80000004:  /* WIN95 */
136                 return MAKELONG(700, 23); /* Win95A */
137     case 0x80000a04:  /* WIN98 */
138                 return MAKELONG(3024, 10); /* W98 SE */
139     case 0x00000004:  /* NT4 */
140                 return MAKELONG(4277, 40); /* NT4 SP6 */
141     default:
142         FIXME("Version value not known yet. Please investigate it!\n");
143                 return 0;
144     }
145 }