ReactOS 0.4.17-dev-357-ga8f14ff
url.c
Go to the documentation of this file.
1/*
2 * Url functions
3 *
4 * Copyright 2000 Huw D M Davies for CodeWeavers.
5 *
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.
10 *
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.
15 *
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
19 */
20
21#include <stdarg.h>
22#include <string.h>
23#include <stdlib.h>
24#include "windef.h"
25#include "winbase.h"
26#include "winnls.h"
27#include "winerror.h"
28#include "wininet.h"
29#include "winreg.h"
30#include "winternl.h"
31#define NO_SHLWAPI_STREAM
32#include "shlwapi.h"
33#include "intshcut.h"
34#include "wine/debug.h"
35
39
41
42#ifndef __REACTOS__
43/*************************************************************************
44 * SHAutoComplete [SHLWAPI.@]
45 *
46 * Enable auto-completion for an edit control.
47 *
48 * PARAMS
49 * hwndEdit [I] Handle of control to enable auto-completion for
50 * dwFlags [I] SHACF_ flags from "shlwapi.h"
51 *
52 * RETURNS
53 * Success: S_OK. Auto-completion is enabled for the control.
54 * Failure: An HRESULT error code indicating the error.
55 */
57{
58 FIXME("stub\n");
59 return S_FALSE;
60}
61#endif
62
63/*************************************************************************
64 * MLBuildResURLA [SHLWAPI.405]
65 *
66 * Create a Url pointing to a resource in a module.
67 *
68 * PARAMS
69 * lpszLibName [I] Name of the module containing the resource
70 * hMod [I] Callers module handle
71 * dwFlags [I] Undocumented flags for loading the module
72 * lpszRes [I] Resource name
73 * lpszDest [O] Destination for resulting Url
74 * dwDestLen [I] Length of lpszDest
75 *
76 * RETURNS
77 * Success: S_OK. lpszDest contains the resource Url.
78 * Failure: E_INVALIDARG, if any argument is invalid, or
79 * E_FAIL if dwDestLen is too small.
80 */
82 LPCSTR lpszRes, LPSTR lpszDest, DWORD dwDestLen)
83{
84 WCHAR szLibName[MAX_PATH], szRes[MAX_PATH], szDest[MAX_PATH];
85 HRESULT hRet;
86
87 if (lpszLibName)
88 MultiByteToWideChar(CP_ACP, 0, lpszLibName, -1, szLibName, ARRAY_SIZE(szLibName));
89
90 if (lpszRes)
91 MultiByteToWideChar(CP_ACP, 0, lpszRes, -1, szRes, ARRAY_SIZE(szRes));
92
93 if (dwDestLen > ARRAY_SIZE(szLibName))
94 dwDestLen = ARRAY_SIZE(szLibName);
95
96 hRet = MLBuildResURLW(lpszLibName ? szLibName : NULL, hMod, dwFlags,
97 lpszRes ? szRes : NULL, lpszDest ? szDest : NULL, dwDestLen);
98 if (SUCCEEDED(hRet) && lpszDest)
99 WideCharToMultiByte(CP_ACP, 0, szDest, -1, lpszDest, dwDestLen, NULL, NULL);
100
101 return hRet;
102}
103
104/*************************************************************************
105 * MLBuildResURLA [SHLWAPI.406]
106 *
107 * See MLBuildResURLA.
108 */
110 LPCWSTR lpszRes, LPWSTR lpszDest, DWORD dwDestLen)
111{
112 static const WCHAR szRes[] = { 'r','e','s',':','/','/','\0' };
113 static const unsigned int szResLen = ARRAY_SIZE(szRes) - 1;
114 HRESULT hRet = E_FAIL;
115
116 TRACE("(%s,%p,0x%08lx,%s,%p,%ld)\n", debugstr_w(lpszLibName), hMod, dwFlags,
117 debugstr_w(lpszRes), lpszDest, dwDestLen);
118
119 if (!lpszLibName || !hMod || hMod == INVALID_HANDLE_VALUE || !lpszRes ||
120 !lpszDest || (dwFlags && dwFlags != 2))
121 return E_INVALIDARG;
122
123 if (dwDestLen >= szResLen + 1)
124 {
125 dwDestLen -= (szResLen + 1);
126 memcpy(lpszDest, szRes, sizeof(szRes));
127
128 hMod = MLLoadLibraryW(lpszLibName, hMod, dwFlags);
129
130 if (hMod)
131 {
132 WCHAR szBuff[MAX_PATH];
133 DWORD len;
134
135 len = GetModuleFileNameW(hMod, szBuff, ARRAY_SIZE(szBuff));
136 if (len && len < ARRAY_SIZE(szBuff))
137 {
138 DWORD dwPathLen = lstrlenW(szBuff) + 1;
139
140 if (dwDestLen >= dwPathLen)
141 {
142 DWORD dwResLen;
143
144 dwDestLen -= dwPathLen;
145 memcpy(lpszDest + szResLen, szBuff, dwPathLen * sizeof(WCHAR));
146
147 dwResLen = lstrlenW(lpszRes) + 1;
148 if (dwDestLen >= dwResLen + 1)
149 {
150 lpszDest[szResLen + dwPathLen-1] = '/';
151 memcpy(lpszDest + szResLen + dwPathLen, lpszRes, dwResLen * sizeof(WCHAR));
152 hRet = S_OK;
153 }
154 }
155 }
156 MLFreeLibrary(hMod);
157 }
158 }
159 return hRet;
160}
WCHAR lpszDest[260]
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
HWND hwndEdit
Definition: combotst.c:65
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define CP_ACP
Definition: compat.h:109
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define lstrlenW
Definition: compat.h:750
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HRESULT WINAPI MLBuildResURLA(LPCSTR lpszLibName, HMODULE hMod, DWORD dwFlags, LPCSTR lpszRes, LPSTR lpszDest, DWORD dwDestLen)
Definition: url.c:81
HRESULT WINAPI SHAutoComplete(HWND hwndEdit, DWORD dwFlags)
Definition: url.c:56
HMODULE WINAPI MLLoadLibraryW(LPCWSTR, HMODULE, DWORD)
Definition: ordinal.c:3298
HRESULT WINAPI MLBuildResURLW(LPCWSTR, HMODULE, DWORD, LPCWSTR, LPWSTR, DWORD)
Definition: url.c:109
BOOL WINAPI MLFreeLibrary(HMODULE)
Definition: ordinal.c:3555
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_w
Definition: kernel32.h:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
short WCHAR
Definition: pedump.c:58
#define TRACE(s)
Definition: solgame.cpp:4
const char * LPCSTR
Definition: typedefs.h:52
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint16_t * LPWSTR
Definition: typedefs.h:56
char * LPSTR
Definition: typedefs.h:51
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:3451