Added a framework for testing CreateProcess and a few tests.
[wine] / dlls / avifil32 / string.c
1 /*
2  * Copyright 2001 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #include <string.h>
20 #include <stdio.h>
21 #include <assert.h>
22
23 #include "winbase.h"
24 #include "winnls.h"
25 #include "mmsystem.h"
26 #include "winerror.h"
27 #include "vfw.h"
28 #include "wine/debug.h"
29 #include "avifile_private.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(avifile);
32
33
34 /****************************************************************************
35  * string APIs (internal) - Copied from wine/dlls/imm32/string.c
36  */
37
38 INT AVIFILE_strlenAtoW( LPCSTR lpstr )
39 {
40         INT     len;
41
42         len = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, NULL, 0 );
43         return ( len > 0 ) ? (len-1) : 0;
44 }
45
46 INT AVIFILE_strlenWtoA( LPCWSTR lpwstr )
47 {
48         INT     len;
49
50         len = WideCharToMultiByte( CP_ACP, 0, lpwstr, -1,
51                                    NULL, 0, NULL, NULL );
52         return ( len > 0 ) ? (len-1) : 0;
53 }
54
55 LPWSTR AVIFILE_strncpyAtoW( LPWSTR lpwstr, LPCSTR lpstr, INT wbuflen )
56 {
57         INT     len;
58
59         len = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, lpwstr, wbuflen );
60         if ( len == 0 )
61                 *lpwstr = 0;
62         return lpwstr;
63 }
64
65 LPSTR AVIFILE_strncpyWtoA( LPSTR lpstr, LPCWSTR lpwstr, INT abuflen )
66 {
67         INT     len;
68
69         len = WideCharToMultiByte( CP_ACP, 0, lpwstr, -1,
70                                    lpstr, abuflen, NULL, NULL );
71         if ( len == 0 )
72                 *lpstr = 0;
73         return lpstr;
74 }
75
76 LPWSTR AVIFILE_strdupAtoW( LPCSTR lpstr )
77 {
78         INT len;
79         LPWSTR lpwstr = NULL;
80
81         len = AVIFILE_strlenAtoW( lpstr );
82         if ( len > 0 )
83         {
84                 lpwstr = (LPWSTR)HeapAlloc( AVIFILE_data.hHeap, 0, sizeof(WCHAR)*(len+1) );
85                 if ( lpwstr != NULL )
86                         (void)AVIFILE_strncpyAtoW( lpwstr, lpstr, len+1 );
87         }
88
89         return lpwstr;
90 }
91
92 LPSTR AVIFILE_strdupWtoA( LPCWSTR lpwstr )
93 {
94         INT len;
95         LPSTR lpstr = NULL;
96
97         len = AVIFILE_strlenWtoA( lpwstr );
98         if ( len > 0 )
99         {
100                 lpstr = (LPSTR)HeapAlloc( AVIFILE_data.hHeap, 0, sizeof(CHAR)*(len+1) );
101                 if ( lpstr != NULL )
102                         (void)AVIFILE_strncpyWtoA( lpstr, lpwstr, len+1 );
103         }
104
105         return lpstr;
106 }
107
108
109