source: trunk/src/avifil32/string.c@ 6712

Last change on this file since 6712 was 6712, checked in by sandervl, 24 years ago

restored old version

File size: 1.8 KB
Line 
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
17DEFAULT_DEBUG_CHANNEL(avifile);
18
19
20/****************************************************************************
21 * string APIs (internal) - Copied from wine/dlls/imm32/string.c
22 */
23
24INT 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
32INT 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
41LPWSTR 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
51LPSTR 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
62LPWSTR 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
78LPSTR 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
Note: See TracBrowser for help on using the repository browser.