Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
29daf1b1
Commit
29daf1b1
authored
Nov 04, 2006
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add utf8_open wrapper
parent
7c9438e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
18 deletions
+76
-18
include/charset.h
include/charset.h
+2
-0
include/vlc_symbols.h
include/vlc_symbols.h
+3
-0
src/misc/unicode.c
src/misc/unicode.c
+71
-18
No files found.
include/charset.h
View file @
29daf1b1
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#define __VLC_CHARSET_H 1
#define __VLC_CHARSET_H 1
#include <stdarg.h>
#include <stdarg.h>
#include <sys/types.h>
# ifdef __cplusplus
# ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -36,6 +37,7 @@ VLC_EXPORT( char *, FromLocale, ( const char * ) );
...
@@ -36,6 +37,7 @@ VLC_EXPORT( char *, FromLocale, ( const char * ) );
VLC_EXPORT
(
char
*
,
FromLocaleDup
,
(
const
char
*
)
);
VLC_EXPORT
(
char
*
,
FromLocaleDup
,
(
const
char
*
)
);
VLC_EXPORT
(
char
*
,
ToLocale
,
(
const
char
*
)
);
VLC_EXPORT
(
char
*
,
ToLocale
,
(
const
char
*
)
);
VLC_EXPORT
(
int
,
utf8_open
,
(
const
char
*
filename
,
int
flags
,
mode_t
mode
)
);
VLC_EXPORT
(
FILE
*
,
utf8_fopen
,
(
const
char
*
filename
,
const
char
*
mode
)
);
VLC_EXPORT
(
FILE
*
,
utf8_fopen
,
(
const
char
*
filename
,
const
char
*
mode
)
);
VLC_EXPORT
(
void
*
,
utf8_opendir
,
(
const
char
*
dirname
)
);
VLC_EXPORT
(
void
*
,
utf8_opendir
,
(
const
char
*
dirname
)
);
VLC_EXPORT
(
const
char
*
,
utf8_readdir
,
(
void
*
dir
)
);
VLC_EXPORT
(
const
char
*
,
utf8_readdir
,
(
void
*
dir
)
);
...
...
include/vlc_symbols.h
View file @
29daf1b1
...
@@ -553,6 +553,7 @@ struct module_symbols_t
...
@@ -553,6 +553,7 @@ struct module_symbols_t
void
(
*
__config_ChainParse_inner
)
(
vlc_object_t
*
,
char
*
psz_prefix
,
const
char
**
ppsz_options
,
config_chain_t
*
);
void
(
*
__config_ChainParse_inner
)
(
vlc_object_t
*
,
char
*
psz_prefix
,
const
char
**
ppsz_options
,
config_chain_t
*
);
void
(
*
config_ChainDestroy_inner
)
(
config_chain_t
*
);
void
(
*
config_ChainDestroy_inner
)
(
config_chain_t
*
);
char
*
(
*
config_ChainCreate_inner
)
(
char
**
,
config_chain_t
**
,
char
*
);
char
*
(
*
config_ChainCreate_inner
)
(
char
**
,
config_chain_t
**
,
char
*
);
int
(
*
utf8_open_inner
)
(
const
char
*
filename
,
int
flags
,
mode_t
mode
);
};
};
# if defined (__PLUGIN__)
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
...
@@ -1029,6 +1030,7 @@ struct module_symbols_t
...
@@ -1029,6 +1030,7 @@ struct module_symbols_t
# define __config_ChainParse (p_symbols)->__config_ChainParse_inner
# define __config_ChainParse (p_symbols)->__config_ChainParse_inner
# define config_ChainDestroy (p_symbols)->config_ChainDestroy_inner
# define config_ChainDestroy (p_symbols)->config_ChainDestroy_inner
# define config_ChainCreate (p_symbols)->config_ChainCreate_inner
# define config_ChainCreate (p_symbols)->config_ChainCreate_inner
# define utf8_open (p_symbols)->utf8_open_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
...
@@ -1508,6 +1510,7 @@ struct module_symbols_t
...
@@ -1508,6 +1510,7 @@ struct module_symbols_t
((p_symbols)->__config_ChainParse_inner) = __config_ChainParse; \
((p_symbols)->__config_ChainParse_inner) = __config_ChainParse; \
((p_symbols)->config_ChainDestroy_inner) = config_ChainDestroy; \
((p_symbols)->config_ChainDestroy_inner) = config_ChainDestroy; \
((p_symbols)->config_ChainCreate_inner) = config_ChainCreate; \
((p_symbols)->config_ChainCreate_inner) = config_ChainCreate; \
((p_symbols)->utf8_open_inner) = utf8_open; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->__sout_CfgParse_deprecated = NULL; \
(p_symbols)->__sout_CfgParse_deprecated = NULL; \
(p_symbols)->sout_CfgCreate_deprecated = NULL; \
(p_symbols)->sout_CfgCreate_deprecated = NULL; \
...
...
src/misc/unicode.c
View file @
29daf1b1
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
* unicode.c: Unicode <-> locale functions
* unicode.c: Unicode <-> locale functions
*****************************************************************************
*****************************************************************************
* Copyright (C) 2005-2006 the VideoLAN team
* Copyright (C) 2005-2006 the VideoLAN team
* Copyright © 2005-2006 Rémi Denis-Courmont
* $Id$
* $Id$
*
*
* Authors: Rémi Denis-Courmont <rem # videolan.org>
* Authors: Rémi Denis-Courmont <rem # videolan.org>
...
@@ -46,6 +47,12 @@
...
@@ -46,6 +47,12 @@
#ifdef HAVE_SYS_STAT_H
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
# include <sys/stat.h>
#endif
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef WIN32
# include <io.h>
#endif
#ifndef HAVE_LSTAT
#ifndef HAVE_LSTAT
# define lstat( a, b ) stat(a, b)
# define lstat( a, b ) stat(a, b)
...
@@ -302,20 +309,17 @@ void LocaleFree( const char *str )
...
@@ -302,20 +309,17 @@ void LocaleFree( const char *str )
}
}
/**
/**
* utf8_
fopen: Calls fopen() after conversion of file name to OS locale
* utf8_
open: open() wrapper for UTF-8 filenames
*/
*/
FILE
*
utf8_fopen
(
const
char
*
filename
,
const
char
*
mode
)
int
utf8_open
(
const
char
*
filename
,
int
flags
,
mode_t
mode
)
{
{
#if defined (WIN32) || defined (UNDER_CE)
#if defined (WIN32) || defined (UNDER_CE)
if
(
GetVersion
()
<
0x80000000
)
if
(
GetVersion
()
<
0x80000000
)
{
{
/* for Windows NT and above */
/* for Windows NT and above */
wchar_t
wpath
[
MAX_PATH
+
1
];
wchar_t
wpath
[
MAX_PATH
+
1
];
size_t
len
=
strlen
(
mode
)
+
1
;
wchar_t
wmode
[
len
];
if
(
!
MultiByteToWideChar
(
CP_UTF8
,
0
,
filename
,
-
1
,
wpath
,
MAX_PATH
)
if
(
!
MultiByteToWideChar
(
CP_UTF8
,
0
,
filename
,
-
1
,
wpath
,
MAX_PATH
))
||
!
MultiByteToWideChar
(
CP_ACP
,
0
,
mode
,
len
,
wmode
,
len
)
)
{
{
errno
=
ENOENT
;
errno
=
ENOENT
;
return
NULL
;
return
NULL
;
...
@@ -323,24 +327,73 @@ FILE *utf8_fopen( const char *filename, const char *mode )
...
@@ -323,24 +327,73 @@ FILE *utf8_fopen( const char *filename, const char *mode )
wpath
[
MAX_PATH
]
=
L'\0'
;
wpath
[
MAX_PATH
]
=
L'\0'
;
/*
/*
*
f
open() cannot open files with non-“ANSI” characters on Windows.
* open() cannot open files with non-“ANSI” characters on Windows.
* We use _w
f
open() instead. Same thing for mkdir() and stat().
* We use _wopen() instead. Same thing for mkdir() and stat().
*/
*/
return
_w
fopen
(
wpath
,
wmode
);
return
_w
open
(
wpath
,
flags
,
mode
);
}
}
#endif
#endif
const
char
*
local_name
=
ToLocale
(
filename
);
const
char
*
local_name
=
ToLocale
(
filename
);
if
(
local_name
!=
NULL
)
if
(
local_name
==
NULL
)
{
{
FILE
*
stream
=
fopen
(
local_name
,
mode
);
LocaleFree
(
local_name
);
return
stream
;
}
else
errno
=
ENOENT
;
errno
=
ENOENT
;
return
NULL
;
}
return
NULL
;
int
fd
=
open
(
local_name
,
flags
,
mode
);
LocaleFree
(
local_name
);
return
fd
;
}
/**
* utf8_fopen: fopen() wrapper for UTF-8 filenames
*/
FILE
*
utf8_fopen
(
const
char
*
filename
,
const
char
*
mode
)
{
int
rwflags
=
0
,
oflags
=
0
;
vlc_bool_t
append
=
VLC_FALSE
;
for
(
const
char
*
ptr
=
mode
;
*
ptr
;
ptr
++
)
{
switch
(
*
ptr
)
{
case
'r'
:
rwflags
=
O_RDONLY
;
break
;
case
'a'
:
rwflags
=
O_WRONLY
;
oflags
|=
O_CREAT
;
append
=
VLC_TRUE
;
break
;
case
'w'
:
rwflags
=
O_WRONLY
;
oflags
|=
O_CREAT
|
O_TRUNC
;
break
;
case
'+'
:
rwflags
=
O_RDWR
;
break
;
}
}
int
fd
=
utf8_open
(
filename
,
rwflags
|
oflags
,
0666
);
if
(
fd
==
-
1
)
return
NULL
;
if
(
append
&&
(
lseek
(
fd
,
0
,
SEEK_END
)
==
-
1
))
{
close
(
fd
);
return
NULL
;
}
FILE
*
stream
=
fdopen
(
fd
,
mode
);
if
(
stream
==
NULL
)
close
(
fd
);
return
stream
;
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment