ReactOS 0.4.17-dev-966-gf06eace
name.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "ole2.h"
#include "winsxs.h"
#include "wine/debug.h"
#include "sxs_private.h"
Include dependency graph for name.c:

Go to the source code of this file.

Classes

struct  name
 

Macros

#define COBJMACROS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (sxs)
 
static struct name * impl_from_IAssemblyName (IAssemblyName *iface)
 
static HRESULT WINAPI name_QueryInterface (IAssemblyName *iface, REFIID riid, void **ret_iface)
 
static ULONG WINAPI name_AddRef (IAssemblyName *iface)
 
static ULONG WINAPI name_Release (IAssemblyName *iface)
 
static HRESULT WINAPI name_SetProperty (IAssemblyName *iface, DWORD id, LPVOID property, DWORD size)
 
static HRESULT WINAPI name_GetProperty (IAssemblyName *iface, DWORD id, LPVOID buffer, LPDWORD buflen)
 
static HRESULT WINAPI name_Finalize (IAssemblyName *iface)
 
static HRESULT WINAPI name_GetDisplayName (IAssemblyName *iface, LPOLESTR buffer, LPDWORD buflen, DWORD flags)
 
static HRESULT WINAPI name_Reserved (IAssemblyName *iface, REFIID riid, IUnknown *pUnkReserved1, IUnknown *pUnkReserved2, LPCOLESTR szReserved, LONGLONG llReserved, LPVOID pvReserved, DWORD cbReserved, LPVOID *ppReserved)
 
const WCHAR * get_name_attribute (IAssemblyName *iface, enum name_attr_id id)
 
static HRESULT WINAPI name_GetName (IAssemblyName *iface, LPDWORD buflen, WCHAR *buffer)
 
static HRESULT parse_version (WCHAR *version, DWORD *high, DWORD *low)
 
static HRESULT WINAPI name_GetVersion (IAssemblyName *iface, LPDWORD high, LPDWORD low)
 
static HRESULT WINAPI name_IsEqual (IAssemblyName *name1, IAssemblyName *name2, DWORD flags)
 
static HRESULT WINAPI name_Clone (IAssemblyName *iface, IAssemblyName **name)
 
static WCHAR * parse_value (const WCHAR *str, unsigned int *len)
 
static HRESULT parse_displayname (struct name *name, const WCHAR *displayname)
 
HRESULT WINAPI CreateAssemblyNameObject (LPASSEMBLYNAME *obj, LPCWSTR assembly, DWORD flags, LPVOID reserved)
 

Variables

static const IAssemblyNameVtbl name_vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 26 of file name.c.

Function Documentation

◆ CreateAssemblyNameObject()

HRESULT WINAPI CreateAssemblyNameObject ( LPASSEMBLYNAME *  obj,
LPCWSTR  assembly,
DWORD  flags,
LPVOID  reserved 
)

Definition at line 360 of file name.c.

365{
366 struct name *name;
367 HRESULT hr;
368
369 TRACE("%p, %s, 0x%08lx, %p\n", obj, debugstr_w(assembly), flags, reserved);
370
371 if (!obj) return E_INVALIDARG;
372
373 *obj = NULL;
375 return E_INVALIDARG;
376
377 if (!(name = calloc(1, sizeof(*name) )))
378 return E_OUTOFMEMORY;
379
381 name->refs = 1;
382
384 if (hr != S_OK)
385 {
386 free( name->name );
387 free( name->arch );
388 free( name->token );
389 free( name->type );
390 free( name->version );
391 free( name );
392 return hr;
393 }
395 return S_OK;
396}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define free
Definition: debug_ros.c:5
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
static HRESULT parse_displayname(struct name *name, const WCHAR *displayname)
Definition: name.c:307
static const IAssemblyNameVtbl name_vtbl
Definition: name.c:275
r reserved
Definition: btrfs.c:3006
GLbitfield flags
Definition: glext.h:7161
#define S_OK
Definition: intsafe.h:52
#define debugstr_w
Definition: kernel32.h:32
#define calloc
Definition: rosglue.h:14
#define TRACE(s)
Definition: solgame.cpp:4
Definition: name.c:39
WCHAR * arch
Definition: name.c:43
WCHAR * type
Definition: name.c:45
WCHAR * token
Definition: name.c:44
WCHAR * name
Definition: name.c:42
WCHAR * version
Definition: name.c:46
LONG refs
Definition: name.c:41
IAssemblyName IAssemblyName_iface
Definition: name.c:40
@ CANOF_PARSE_DISPLAY_NAME
Definition: winsxs.idl:193

Referenced by test_CreateAssemblyNameObject().

◆ get_name_attribute()

const WCHAR * get_name_attribute ( IAssemblyName *  iface,
enum name_attr_id  id 
)

Definition at line 177 of file name.c.

178{
179 struct name *name = impl_from_IAssemblyName( iface );
180
181 switch (id)
182 {
183 case NAME_ATTR_ID_NAME: return name->name;
184 case NAME_ATTR_ID_ARCH: return name->arch;
185 case NAME_ATTR_ID_TOKEN: return name->token;
186 case NAME_ATTR_ID_TYPE: return name->type;
187 case NAME_ATTR_ID_VERSION: return name->version;
188 default:
189 ERR("unhandled name attribute %u\n", id);
190 break;
191 }
192 return NULL;
193}
#define ERR(fmt,...)
Definition: precomp.h:57
static struct name * impl_from_IAssemblyName(IAssemblyName *iface)
Definition: name.c:49
@ NAME_ATTR_ID_VERSION
Definition: sxs_private.h:27
@ NAME_ATTR_ID_NAME
Definition: sxs_private.h:23
@ NAME_ATTR_ID_TYPE
Definition: sxs_private.h:26
@ NAME_ATTR_ID_ARCH
Definition: sxs_private.h:24
@ NAME_ATTR_ID_TOKEN
Definition: sxs_private.h:25

Referenced by cache_QueryAssemblyInfo(), cache_UninstallAssembly(), and name_GetName().

◆ impl_from_IAssemblyName()

static struct name * impl_from_IAssemblyName ( IAssemblyName *  iface)
inlinestatic

Definition at line 49 of file name.c.

50{
51 return CONTAINING_RECORD( iface, struct name, IAssemblyName_iface );
52}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by get_name_attribute(), name_AddRef(), name_GetDisplayName(), name_GetVersion(), and name_Release().

◆ name_AddRef()

static ULONG WINAPI name_AddRef ( IAssemblyName *  iface)
static

Definition at line 74 of file name.c.

76{
77 struct name *name = impl_from_IAssemblyName( iface );
78 return InterlockedIncrement( &name->refs );
79}
#define InterlockedIncrement
Definition: armddk.h:53

◆ name_Clone()

static HRESULT WINAPI name_Clone ( IAssemblyName *  iface,
IAssemblyName **  name 
)
static

Definition at line 267 of file name.c.

270{
271 FIXME("%p, %p\n", iface, name);
272 return E_NOTIMPL;
273}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ name_Finalize()

static HRESULT WINAPI name_Finalize ( IAssemblyName *  iface)
static

Definition at line 119 of file name.c.

121{
122 FIXME("%p\n", iface);
123 return E_NOTIMPL;
124}

◆ name_GetDisplayName()

static HRESULT WINAPI name_GetDisplayName ( IAssemblyName *  iface,
LPOLESTR  buffer,
LPDWORD  buflen,
DWORD  flags 
)
static

Definition at line 126 of file name.c.

131{
132 static const WCHAR fmtW[] = {',','%','s','=','\"','%','s','\"',0};
133 struct name *name = impl_from_IAssemblyName( iface );
134 unsigned int len;
135
136 TRACE("%p, %p, %p, 0x%08lx\n", iface, buffer, buflen, flags);
137
138 if (!buflen || flags) return E_INVALIDARG;
139
140 len = lstrlenW( name->name ) + 1;
141 if (name->arch) len += lstrlenW( L"processorArchitecture" ) + lstrlenW( name->arch ) + 4;
142 if (name->token) len += lstrlenW( L"publicKeyToken" ) + lstrlenW( name->token ) + 4;
143 if (name->type) len += lstrlenW( L"type" ) + lstrlenW( name->type ) + 4;
144 if (name->version) len += lstrlenW( L"version" ) + lstrlenW( name->version ) + 4;
145 if (len > *buflen)
146 {
147 *buflen = len;
149 }
151 len = lstrlenW( buffer );
152 if (name->arch) len += swprintf( buffer + len, *buflen - len, fmtW, L"processorArchitecture", name->arch );
153 if (name->token) len += swprintf( buffer + len, *buflen - len, fmtW, L"publicKeyToken", name->token );
154 if (name->type) len += swprintf( buffer + len, *buflen - len, fmtW, L"type", name->type );
155 if (name->version) len += swprintf( buffer + len, *buflen - len, fmtW, L"version", name->version );
156 return S_OK;
157}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
#define swprintf
Definition: precomp.h:40
#define L(x)
Definition: resources.c:13
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
short WCHAR
Definition: pedump.c:58
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

◆ name_GetName()

static HRESULT WINAPI name_GetName ( IAssemblyName *  iface,
LPDWORD  buflen,
WCHAR *  buffer 
)
static

Definition at line 195 of file name.c.

199{
200 const WCHAR *name;
201 int len;
202
203 TRACE("%p, %p, %p\n", iface, buflen, buffer);
204
205 if (!buflen || !buffer) return E_INVALIDARG;
206
208 len = lstrlenW( name ) + 1;
209 if (len > *buflen)
210 {
211 *buflen = len;
213 }
214 lstrcpyW( buffer, name );
215 *buflen = len + 3;
216 return S_OK;
217}
const WCHAR * get_name_attribute(IAssemblyName *iface, enum name_attr_id id)
Definition: name.c:177

◆ name_GetProperty()

static HRESULT WINAPI name_GetProperty ( IAssemblyName *  iface,
DWORD  id,
LPVOID  buffer,
LPDWORD  buflen 
)
static

Definition at line 109 of file name.c.

114{
115 FIXME("%p, %ld, %p, %p\n", iface, id, buffer, buflen);
116 return E_NOTIMPL;
117}

◆ name_GetVersion()

static HRESULT WINAPI name_GetVersion ( IAssemblyName *  iface,
LPDWORD  high,
LPDWORD  low 
)
static

Definition at line 240 of file name.c.

244{
245 struct name *name = impl_from_IAssemblyName( iface );
246 WCHAR *version;
247 HRESULT hr;
248
249 TRACE("%p, %p, %p\n", iface, high, low);
250
252 if (!(version = wcsdup( name->version ))) return E_OUTOFMEMORY;
253 hr = parse_version( version, high, low );
254 free( version );
255 return hr;
256}
static const WCHAR version[]
Definition: asmname.c:66
static wchar_t * wcsdup(const wchar_t *str)
Definition: string.h:94
static HRESULT parse_version(WCHAR *version, DWORD *high, DWORD *low)
Definition: name.c:219
#define ERROR_NOT_FOUND
Definition: winerror.h:1014

◆ name_IsEqual()

static HRESULT WINAPI name_IsEqual ( IAssemblyName *  name1,
IAssemblyName *  name2,
DWORD  flags 
)
static

Definition at line 258 of file name.c.

262{
263 FIXME("%p, %p, 0x%08lx\n", name1, name2, flags);
264 return E_NOTIMPL;
265}
static WCHAR name1[]
Definition: record.c:34
static WCHAR name2[]
Definition: record.c:35

◆ name_QueryInterface()

static HRESULT WINAPI name_QueryInterface ( IAssemblyName *  iface,
REFIID  riid,
void **  ret_iface 
)
static

Definition at line 54 of file name.c.

58{
59 TRACE("%p, %s, %p\n", iface, debugstr_guid(riid), ret_iface);
60
61 *ret_iface = NULL;
62
63 if (IsEqualIID( riid, &IID_IUnknown ) ||
64 IsEqualIID( riid, &IID_IAssemblyName ))
65 {
66 IAssemblyName_AddRef( iface );
67 *ret_iface = iface;
68 return S_OK;
69 }
70
71 return E_NOINTERFACE;
72}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ name_Release()

static ULONG WINAPI name_Release ( IAssemblyName *  iface)
static

Definition at line 81 of file name.c.

82{
83 struct name *name = impl_from_IAssemblyName( iface );
85
86 if (!refs)
87 {
88 TRACE("destroying %p\n", name);
89 free( name->name );
90 free( name->arch );
91 free( name->token );
92 free( name->type );
93 free( name->version );
94 free( name );
95 }
96 return refs;
97}
#define InterlockedDecrement
Definition: armddk.h:52
LONG refs
Definition: port.c:62
uint32_t ULONG
Definition: typedefs.h:59

◆ name_Reserved()

static HRESULT WINAPI name_Reserved ( IAssemblyName *  iface,
REFIID  riid,
IUnknown *  pUnkReserved1,
IUnknown *  pUnkReserved2,
LPCOLESTR  szReserved,
LONGLONG  llReserved,
LPVOID  pvReserved,
DWORD  cbReserved,
LPVOID *  ppReserved 
)
static

Definition at line 159 of file name.c.

169{
170 FIXME("%p, %s, %p, %p, %s, %s, %p, %ld, %p\n", iface,
171 debugstr_guid(riid), pUnkReserved1, pUnkReserved2,
172 debugstr_w(szReserved), wine_dbgstr_longlong(llReserved),
173 pvReserved, cbReserved, ppReserved);
174 return E_NOTIMPL;
175}
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
static LPCWSTR LPVOID pvReserved
Definition: asmcache.c:749

◆ name_SetProperty()

static HRESULT WINAPI name_SetProperty ( IAssemblyName *  iface,
DWORD  id,
LPVOID  property,
DWORD  size 
)
static

Definition at line 99 of file name.c.

104{
105 FIXME("%p, %ld, %p, %ld\n", iface, id, property, size);
106 return E_NOTIMPL;
107}
GLsizeiptr size
Definition: glext.h:5919

◆ parse_displayname()

static HRESULT parse_displayname ( struct name *  name,
const WCHAR *  displayname 
)
static

Definition at line 307 of file name.c.

308{
309 const WCHAR *p, *q;
310 unsigned int len;
311
312 p = q = displayname;
313 while (*q && *q != ',') q++;
314 len = q - p;
315 if (!(name->name = malloc( (len + 1) * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
316 memcpy( name->name, p, len * sizeof(WCHAR) );
317 name->name[len] = 0;
318 if (!*q) return S_OK;
319
320 for (;;)
321 {
322 p = ++q;
323 while (*q && *q != '=') q++;
324 if (!*q) return E_INVALIDARG;
325 len = q - p;
326 if (len == ARRAY_SIZE(L"processorArchitecture") - 1 && !memcmp( p, L"processorArchitecture", len * sizeof(WCHAR) ))
327 {
328 p = ++q;
329 if (!(name->arch = parse_value( p, &len ))) return E_INVALIDARG;
330 q += len;
331 }
332 else if (len == ARRAY_SIZE(L"publicKeyToken") - 1 && !memcmp( p, L"publicKeyToken", len * sizeof(WCHAR) ))
333 {
334 p = ++q;
335 if (!(name->token = parse_value( p, &len ))) return E_INVALIDARG;
336 q += len;
337 }
338 else if (len == ARRAY_SIZE(L"type") - 1 && !memcmp( p, L"type", len * sizeof(WCHAR) ))
339 {
340 p = ++q;
341 if (!(name->type = parse_value( p, &len ))) return E_INVALIDARG;
342 q += len;
343 }
344 else if (len == ARRAY_SIZE(L"version") - 1 && !memcmp( p, L"version", len * sizeof(WCHAR) ))
345 {
346 p = ++q;
347 if (!(name->version = parse_value( p, &len ))) return E_INVALIDARG;
348 q += len;
349 }
351 while (*q && *q != ',') q++;
352 if (!*q) break;
353 }
354 return S_OK;
355}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define malloc
Definition: debug_ros.c:4
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
static WCHAR * parse_value(const WCHAR *str, unsigned int *len)
Definition: name.c:291
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat GLfloat p
Definition: glext.h:8902
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME
Definition: winerror.h:3174

Referenced by CreateAssemblyNameObject().

◆ parse_value()

static WCHAR * parse_value ( const WCHAR *  str,
unsigned int *  len 
)
static

Definition at line 291 of file name.c.

292{
293 WCHAR *ret;
294 const WCHAR *p = str;
295
296 if (*p++ != '\"') return NULL;
297 while (*p && *p != '\"') p++;
298 if (!*p) return NULL;
299
300 *len = p - str;
301 if (!(ret = malloc( *len * sizeof(WCHAR) ))) return NULL;
302 memcpy( ret, str + 1, (*len - 1) * sizeof(WCHAR) );
303 ret[*len - 1] = 0;
304 return ret;
305}
return ret
Definition: mutex.c:147
const WCHAR * str

Referenced by parse_displayname().

◆ parse_version()

static HRESULT parse_version ( WCHAR *  version,
DWORD *  high,
DWORD *  low 
)
static

Definition at line 219 of file name.c.

220{
221 WORD ver[4];
222 WCHAR *p, *q;
223 unsigned int i;
224
225 memset( ver, 0, sizeof(ver) );
226 for (i = 0, p = version; i < 4; i++)
227 {
228 if (!*p) break;
229 q = wcschr( p, '.' );
230 if (q) *q = 0;
231 ver[i] = wcstol( p, NULL, 10 );
232 if (!q && i < 3) break;
233 p = q + 1;
234 }
235 *high = (ver[0] << 16) + ver[1];
236 *low = (ver[2] << 16) + ver[3];
237 return S_OK;
238}
#define wcschr
Definition: compat.h:17
_ACRTIMP __msvcrt_long __cdecl wcstol(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2752
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define memset(x, y, z)
Definition: compat.h:39

Referenced by name_GetVersion().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( sxs  )

Variable Documentation

◆ name_vtbl

const IAssemblyNameVtbl name_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI name_AddRef(IAssemblyName *iface)
Definition: name.c:74
static HRESULT WINAPI name_QueryInterface(IAssemblyName *iface, REFIID riid, void **ret_iface)
Definition: name.c:54
static HRESULT WINAPI name_Clone(IAssemblyName *iface, IAssemblyName **name)
Definition: name.c:267
static HRESULT WINAPI name_GetVersion(IAssemblyName *iface, LPDWORD high, LPDWORD low)
Definition: name.c:240
static HRESULT WINAPI name_Reserved(IAssemblyName *iface, REFIID riid, IUnknown *pUnkReserved1, IUnknown *pUnkReserved2, LPCOLESTR szReserved, LONGLONG llReserved, LPVOID pvReserved, DWORD cbReserved, LPVOID *ppReserved)
Definition: name.c:159
static HRESULT WINAPI name_Finalize(IAssemblyName *iface)
Definition: name.c:119
static HRESULT WINAPI name_GetProperty(IAssemblyName *iface, DWORD id, LPVOID buffer, LPDWORD buflen)
Definition: name.c:109
static HRESULT WINAPI name_IsEqual(IAssemblyName *name1, IAssemblyName *name2, DWORD flags)
Definition: name.c:258
static ULONG WINAPI name_Release(IAssemblyName *iface)
Definition: name.c:81
static HRESULT WINAPI name_GetDisplayName(IAssemblyName *iface, LPOLESTR buffer, LPDWORD buflen, DWORD flags)
Definition: name.c:126
static HRESULT WINAPI name_SetProperty(IAssemblyName *iface, DWORD id, LPVOID property, DWORD size)
Definition: name.c:99
static HRESULT WINAPI name_GetName(IAssemblyName *iface, LPDWORD buflen, WCHAR *buffer)
Definition: name.c:195

Definition at line 275 of file name.c.

Referenced by CreateAssemblyNameObject().