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