1 | /* $Id: string.c,v 1.2 2001-09-05 14:16:46 bird Exp $ */
|
---|
2 | /*
|
---|
3 | * Copyright 2001 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
|
---|
4 | */
|
---|
5 |
|
---|
6 | #include <string.h>
|
---|
7 | #include <stdio.h>
|
---|
8 | #include <assert.h>
|
---|
9 |
|
---|
10 | #include "winbase.h"
|
---|
11 | #include "winnls.h"
|
---|
12 | #include "mmsystem.h"
|
---|
13 | #include "winerror.h"
|
---|
14 | #include "vfw.h"
|
---|
15 | #include "debugtools.h"
|
---|
16 | #include "avifile_private.h"
|
---|
17 |
|
---|
18 | DEFAULT_DEBUG_CHANNEL(avifile);
|
---|
19 |
|
---|
20 |
|
---|
21 | /****************************************************************************
|
---|
22 | * string APIs (internal) - Copied from wine/dlls/imm32/string.c
|
---|
23 | */
|
---|
24 |
|
---|
25 | INT AVIFILE_strlenAtoW( LPCSTR lpstr )
|
---|
26 | {
|
---|
27 | INT len;
|
---|
28 |
|
---|
29 | len = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, NULL, 0 );
|
---|
30 | return ( len > 0 ) ? (len-1) : 0;
|
---|
31 | }
|
---|
32 |
|
---|
33 | INT AVIFILE_strlenWtoA( LPCWSTR lpwstr )
|
---|
34 | {
|
---|
35 | INT len;
|
---|
36 |
|
---|
37 | len = WideCharToMultiByte( CP_ACP, 0, lpwstr, -1,
|
---|
38 | NULL, 0, NULL, NULL );
|
---|
39 | return ( len > 0 ) ? (len-1) : 0;
|
---|
40 | }
|
---|
41 |
|
---|
42 | LPWSTR AVIFILE_strncpyAtoW( LPWSTR lpwstr, LPCSTR lpstr, INT wbuflen )
|
---|
43 | {
|
---|
44 | INT len;
|
---|
45 |
|
---|
46 | len = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, lpwstr, wbuflen );
|
---|
47 | if ( len == 0 )
|
---|
48 | *lpwstr = 0;
|
---|
49 | return lpwstr;
|
---|
50 | }
|
---|
51 |
|
---|
52 | LPSTR AVIFILE_strncpyWtoA( LPSTR lpstr, LPCWSTR lpwstr, INT abuflen )
|
---|
53 | {
|
---|
54 | INT len;
|
---|
55 |
|
---|
56 | len = WideCharToMultiByte( CP_ACP, 0, lpwstr, -1,
|
---|
57 | lpstr, abuflen, NULL, NULL );
|
---|
58 | if ( len == 0 )
|
---|
59 | *lpstr = 0;
|
---|
60 | return lpstr;
|
---|
61 | }
|
---|
62 |
|
---|
63 | LPWSTR AVIFILE_strdupAtoW( LPCSTR lpstr )
|
---|
64 | {
|
---|
65 | INT len;
|
---|
66 | LPWSTR lpwstr = NULL;
|
---|
67 |
|
---|
68 | len = AVIFILE_strlenAtoW( lpstr );
|
---|
69 | if ( len > 0 )
|
---|
70 | {
|
---|
71 | lpwstr = (LPWSTR)HeapAlloc( AVIFILE_data.hHeap, 0, sizeof(WCHAR)*(len+1) );
|
---|
72 | if ( lpwstr != NULL )
|
---|
73 | (void)AVIFILE_strncpyAtoW( lpwstr, lpstr, len+1 );
|
---|
74 | }
|
---|
75 |
|
---|
76 | return lpwstr;
|
---|
77 | }
|
---|
78 |
|
---|
79 | LPSTR AVIFILE_strdupWtoA( LPCWSTR lpwstr )
|
---|
80 | {
|
---|
81 | INT len;
|
---|
82 | LPSTR lpstr = NULL;
|
---|
83 |
|
---|
84 | len = AVIFILE_strlenWtoA( lpwstr );
|
---|
85 | if ( len > 0 )
|
---|
86 | {
|
---|
87 | lpstr = (LPSTR)HeapAlloc( AVIFILE_data.hHeap, 0, sizeof(CHAR)*(len+1) );
|
---|
88 | if ( lpstr != NULL )
|
---|
89 | (void)AVIFILE_strncpyWtoA( lpstr, lpwstr, len+1 );
|
---|
90 | }
|
---|
91 |
|
---|
92 | return lpstr;
|
---|
93 | }
|
---|
94 |
|
---|
95 |
|
---|
96 |
|
---|