server: Add a helper function for creating a Unicode string.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7b41b7510f
commit
faaea5cd00
|
@ -270,12 +270,12 @@ static void create_session( unsigned int id )
|
|||
static const struct unicode_str link_local_str = {link_localW, sizeof(link_localW)};
|
||||
static const struct unicode_str link_session_str = {link_sessionW, sizeof(link_sessionW)};
|
||||
|
||||
static const WCHAR fmt_u[] = {'%','u',0};
|
||||
static struct directory *dir_bno_global, *dir_sessions, *dir_bnolinks;
|
||||
struct directory *dir_id, *dir_bno, *dir_dosdevices, *dir_windows, *dir_winstation;
|
||||
struct object *link_global, *link_local, *link_session, *link_bno, *link_windows;
|
||||
struct unicode_str id_str;
|
||||
WCHAR id_strW[10];
|
||||
char id_strA[10];
|
||||
WCHAR *id_strW;
|
||||
|
||||
if (!id)
|
||||
{
|
||||
|
@ -287,9 +287,8 @@ static void create_session( unsigned int id )
|
|||
make_object_static( (struct object *)dir_sessions );
|
||||
}
|
||||
|
||||
sprintfW( id_strW, fmt_u, id );
|
||||
id_str.str = id_strW;
|
||||
id_str.len = strlenW( id_strW ) * sizeof(WCHAR);
|
||||
sprintf( id_strA, "%u", id );
|
||||
id_strW = ascii_to_unicode_str( id_strA, &id_str );
|
||||
dir_id = create_directory( &dir_sessions->obj, &id_str, 0, HASH_SIZE, NULL );
|
||||
dir_dosdevices = create_directory( &dir_id->obj, &dir_dosdevices_str, 0, HASH_SIZE, NULL );
|
||||
|
||||
|
@ -325,6 +324,7 @@ static void create_session( unsigned int id )
|
|||
release_object( dir_windows );
|
||||
release_object( dir_bno );
|
||||
release_object( dir_id );
|
||||
free( id_strW );
|
||||
}
|
||||
|
||||
void init_directories(void)
|
||||
|
|
|
@ -1740,25 +1740,16 @@ static int load_init_registry_from_file( const char *filename, struct key *key )
|
|||
|
||||
static WCHAR *format_user_registry_path( const SID *sid, struct unicode_str *path )
|
||||
{
|
||||
static const WCHAR prefixW[] = {'U','s','e','r','\\','S',0};
|
||||
static const WCHAR formatW[] = {'-','%','u',0};
|
||||
WCHAR buffer[7 + 10 + 10 + 10 * SID_MAX_SUB_AUTHORITIES];
|
||||
WCHAR *p = buffer;
|
||||
char buffer[7 + 11 + 11 + 11 * SID_MAX_SUB_AUTHORITIES], *p = buffer;
|
||||
unsigned int i;
|
||||
|
||||
strcpyW( p, prefixW );
|
||||
p += strlenW( prefixW );
|
||||
p += sprintfW( p, formatW, sid->Revision );
|
||||
p += sprintfW( p, formatW, MAKELONG( MAKEWORD( sid->IdentifierAuthority.Value[5],
|
||||
p += sprintf( p, "User\\S-%u-%u", sid->Revision,
|
||||
MAKELONG( MAKEWORD( sid->IdentifierAuthority.Value[5],
|
||||
sid->IdentifierAuthority.Value[4] ),
|
||||
MAKEWORD( sid->IdentifierAuthority.Value[3],
|
||||
sid->IdentifierAuthority.Value[2] )));
|
||||
for (i = 0; i < sid->SubAuthorityCount; i++)
|
||||
p += sprintfW( p, formatW, sid->SubAuthority[i] );
|
||||
|
||||
path->len = (p - buffer) * sizeof(WCHAR);
|
||||
path->str = p = memdup( buffer, path->len );
|
||||
return p;
|
||||
for (i = 0; i < sid->SubAuthorityCount; i++) p += sprintf( p, "-%u", sid->SubAuthority[i] );
|
||||
return ascii_to_unicode_str( buffer, path );
|
||||
}
|
||||
|
||||
/* get the cpu architectures that can be supported in the current prefix */
|
||||
|
|
|
@ -51,6 +51,17 @@ static inline char to_hex( char ch )
|
|||
return tolower(ch) - 'a' + 10;
|
||||
}
|
||||
|
||||
WCHAR *ascii_to_unicode_str( const char *str, struct unicode_str *ret )
|
||||
{
|
||||
data_size_t i, len = strlen(str);
|
||||
WCHAR *p;
|
||||
|
||||
ret->len = len * sizeof(WCHAR);
|
||||
ret->str = p = mem_alloc( ret->len );
|
||||
if (p) for (i = 0; i < len; i++) p[i] = (unsigned char)str[i];
|
||||
return p;
|
||||
}
|
||||
|
||||
/* parse an escaped string back into Unicode */
|
||||
/* return the number of chars read from the input, or -1 on output overflow */
|
||||
int parse_strW( WCHAR *buffer, data_size_t *len, const char *src, char endchar )
|
||||
|
|
|
@ -27,12 +27,7 @@
|
|||
#include "wine/unicode.h"
|
||||
#include "object.h"
|
||||
|
||||
static inline WCHAR *strdupW( const WCHAR *str )
|
||||
{
|
||||
size_t len = (strlenW(str) + 1) * sizeof(WCHAR);
|
||||
return memdup( str, len );
|
||||
}
|
||||
|
||||
extern WCHAR *ascii_to_unicode_str( const char *str, struct unicode_str *ret );
|
||||
extern int parse_strW( WCHAR *buffer, data_size_t *len, const char *src, char endchar );
|
||||
extern int dump_strW( const WCHAR *str, data_size_t len, FILE *f, const char escape[2] );
|
||||
|
||||
|
|
Loading…
Reference in New Issue