Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Marvin Scholz
libaacs
Commits
cd6b9a7a
Commit
cd6b9a7a
authored
Jan 21, 2015
by
npzacs
Browse files
Merge config dir changes from libbluray
parent
7f901697
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/file/dirs.h
View file @
cd6b9a7a
...
...
@@ -30,9 +30,10 @@ AACS_PRIVATE int win32_mkdir(const char *dir);
* Config, cache and data dirs
*/
AACS_PRIVATE
const
char
*
file_get_config_home
(
void
);
AACS_PRIVATE
const
char
*
file_get_config_system
(
const
char
*
dir
);
AACS_PRIVATE
const
char
*
file_get_cache_home
(
void
);
AACS_PRIVATE
const
char
*
file_get_data_home
(
void
);
AACS_PRIVATE
char
*
file_get_config_home
(
void
)
AACS_ATTR_MALLOC
;
AACS_PRIVATE
char
*
file_get_cache_home
(
void
)
AACS_ATTR_MALLOC
;
AACS_PRIVATE
char
*
file_get_data_home
(
void
)
AACS_ATTR_MALLOC
;
#endif
src/file/dirs_darwin.c
View file @
cd6b9a7a
...
...
@@ -38,61 +38,37 @@
#define SYSTEM_CFG_DIR "/Library/Preferences"
const
char
*
file_get_config_home
(
void
)
char
*
file_get_config_home
(
void
)
{
static
char
*
dir
=
NULL
;
static
int
init_done
=
0
;
if
(
!
init_done
)
{
init_done
=
1
;
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
dir
=
str_printf
(
"%s/%s"
,
user_home
,
USER_CFG_DIR
);
}
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
str_printf
(
"%s/%s"
,
user_home
,
USER_CFG_DIR
);
}
return
dir
;
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
return
NULL
;
}
const
char
*
file_get_data_home
(
void
)
char
*
file_get_data_home
(
void
)
{
static
char
*
dir
=
NULL
;
static
int
init_done
=
0
;
if
(
!
init_done
)
{
init_done
=
1
;
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
dir
=
str_printf
(
"%s/%s"
,
user_home
,
USER_DATA_DIR
);
}
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
str_printf
(
"%s/%s"
,
user_home
,
USER_DATA_DIR
);
}
return
dir
;
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
return
NULL
;
}
const
char
*
file_get_cache_home
(
void
)
char
*
file_get_cache_home
(
void
)
{
static
char
*
dir
=
NULL
;
static
int
init_done
=
0
;
if
(
!
init_done
)
{
init_done
=
1
;
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
dir
=
str_printf
(
"%s/%s"
,
user_home
,
USER_CACHE_DIR
);
}
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
str_printf
(
"%s/%s"
,
user_home
,
USER_CACHE_DIR
);
}
return
dir
;
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
return
NULL
;
}
const
char
*
file_get_config_system
(
const
char
*
dir
)
...
...
src/file/dirs_win32.c
View file @
cd6b9a7a
...
...
@@ -42,24 +42,20 @@ int win32_mkdir(const char *dir)
return
_wmkdir
(
wdir
);
}
const
char
*
file_get_config_home
(
void
)
char
*
file_get_config_home
(
void
)
{
return
file_get_data_home
();
}
const
char
*
file_get_data_home
(
void
)
char
*
file_get_data_home
(
void
)
{
static
char
*
appdir
=
NULL
;
wchar_t
wdir
[
MAX_PATH
];
if
(
appdir
)
return
appdir
;
/* Get the "Application Data" folder for the user */
if
(
S_OK
==
SHGetFolderPathW
(
NULL
,
CSIDL_APPDATA
|
CSIDL_FLAG_CREATE
,
NULL
,
SHGFP_TYPE_CURRENT
,
wdir
))
{
int
len
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
wdir
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
appdir
=
malloc
(
len
);
char
*
appdir
=
malloc
(
len
);
WideCharToMultiByte
(
CP_UTF8
,
0
,
wdir
,
-
1
,
appdir
,
len
,
NULL
,
NULL
);
return
appdir
;
}
...
...
@@ -68,7 +64,7 @@ const char *file_get_data_home(void)
return
NULL
;
}
const
char
*
file_get_cache_home
(
void
)
char
*
file_get_cache_home
(
void
)
{
return
file_get_data_home
();
}
...
...
src/file/dirs_xdg.c
View file @
cd6b9a7a
...
...
@@ -41,76 +41,52 @@
#define SYSTEM_CFG_DIR "/etc/xdg"
const
char
*
file_get_config_home
(
void
)
char
*
file_get_config_home
(
void
)
{
static
char
*
dir
=
NULL
;
static
int
init_done
=
0
;
if
(
!
init_done
)
{
init_done
=
1
;
const
char
*
xdg_home
=
getenv
(
"XDG_CONFIG_HOME"
);
if
(
xdg_home
&&
*
xdg_home
)
{
return
dir
=
str_printf
(
"%s"
,
xdg_home
);
}
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
dir
=
str_printf
(
"%s/%s"
,
user_home
,
USER_CFG_DIR
);
}
const
char
*
xdg_home
=
getenv
(
"XDG_CONFIG_HOME"
);
if
(
xdg_home
&&
*
xdg_home
)
{
return
str_printf
(
"%s"
,
xdg_home
);
}
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
str_printf
(
"%s/%s"
,
user_home
,
USER_CFG_DIR
);
}
return
dir
;
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
return
NULL
;
}
const
char
*
file_get_data_home
(
void
)
char
*
file_get_data_home
(
void
)
{
static
char
*
dir
=
NULL
;
static
int
init_done
=
0
;
if
(
!
init_done
)
{
init_done
=
1
;
const
char
*
xdg_home
=
getenv
(
"XDG_DATA_HOME"
);
if
(
xdg_home
&&
*
xdg_home
)
{
return
dir
=
str_printf
(
"%s"
,
xdg_home
);
}
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
dir
=
str_printf
(
"%s/%s"
,
user_home
,
USER_DATA_DIR
);
}
const
char
*
xdg_home
=
getenv
(
"XDG_DATA_HOME"
);
if
(
xdg_home
&&
*
xdg_home
)
{
return
str_printf
(
"%s"
,
xdg_home
);
}
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
str_printf
(
"%s/%s"
,
user_home
,
USER_DATA_DIR
);
}
return
dir
;
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
return
NULL
;
}
const
char
*
file_get_cache_home
(
void
)
char
*
file_get_cache_home
(
void
)
{
static
char
*
dir
=
NULL
;
static
int
init_done
=
0
;
if
(
!
init_done
)
{
init_done
=
1
;
const
char
*
xdg_cache
=
getenv
(
"XDG_CACHE_HOME"
);
if
(
xdg_cache
&&
*
xdg_cache
)
{
return
dir
=
str_printf
(
"%s"
,
xdg_cache
);
}
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
dir
=
str_printf
(
"%s/%s"
,
user_home
,
USER_CACHE_DIR
);
}
const
char
*
xdg_cache
=
getenv
(
"XDG_CACHE_HOME"
);
if
(
xdg_cache
&&
*
xdg_cache
)
{
return
str_printf
(
"%s"
,
xdg_cache
);
}
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
str_printf
(
"%s/%s"
,
user_home
,
USER_CACHE_DIR
);
}
return
dir
;
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
return
NULL
;
}
const
char
*
file_get_config_system
(
const
char
*
dir
)
...
...
src/file/keydbcfg.c
View file @
cd6b9a7a
...
...
@@ -111,13 +111,16 @@ static char *_load_file(FILE *fp)
static
char
*
_config_file_user
(
const
char
*
file_name
)
{
const
char
*
cfg_dir
=
file_get_config_home
();
char
*
cfg_dir
=
file_get_config_home
();
char
*
result
;
if
(
!
cfg_dir
)
{
return
NULL
;
}
return
str_printf
(
"%s"
DIR_SEP
"%s"
DIR_SEP
"%s"
,
cfg_dir
,
CFG_DIR
,
file_name
);
result
=
str_printf
(
"%s"
DIR_SEP
"%s"
DIR_SEP
"%s"
,
cfg_dir
,
CFG_DIR
,
file_name
);
X_FREE
(
cfg_dir
);
return
result
;
}
static
FILE
*
_open_cfg_file_user
(
const
char
*
file_name
,
char
**
path
,
const
char
*
mode
)
...
...
@@ -338,7 +341,8 @@ static int _load_cert_file(config_file *cf)
static
char
*
_keycache_file
(
const
char
*
type
,
const
uint8_t
*
disc_id
)
{
const
char
*
cache_dir
=
file_get_cache_home
();
char
*
cache_dir
=
file_get_cache_home
();
char
*
result
;
char
disc_id_str
[
41
];
if
(
!
cache_dir
)
{
...
...
@@ -347,7 +351,9 @@ static char *_keycache_file(const char *type, const uint8_t *disc_id)
hex_array_to_hexstring
(
disc_id_str
,
disc_id
,
20
);
return
str_printf
(
"%s"
DIR_SEP
"%s"
DIR_SEP
"%s"
DIR_SEP
"%s"
,
cache_dir
,
CFG_DIR
,
type
,
disc_id_str
);
result
=
str_printf
(
"%s"
DIR_SEP
"%s"
DIR_SEP
"%s"
DIR_SEP
"%s"
,
cache_dir
,
CFG_DIR
,
type
,
disc_id_str
);
X_FREE
(
cache_dir
);
return
result
;
}
int
keycache_save
(
const
char
*
type
,
const
uint8_t
*
disc_id
,
const
uint8_t
*
key
,
unsigned
int
len
)
...
...
@@ -423,13 +429,16 @@ int keycache_find(const char *type, const uint8_t *disc_id, uint8_t *key, unsign
static
char
*
_cache_file
(
const
char
*
name
)
{
const
char
*
cache_dir
=
file_get_cache_home
();
char
*
cache_dir
=
file_get_cache_home
();
char
*
result
;
if
(
!
cache_dir
)
{
return
NULL
;
}
return
str_printf
(
"%s"
DIR_SEP
"%s"
DIR_SEP
"%s"
,
cache_dir
,
CFG_DIR
,
name
);
result
=
str_printf
(
"%s"
DIR_SEP
"%s"
DIR_SEP
"%s"
,
cache_dir
,
CFG_DIR
,
name
);
X_FREE
(
cache_dir
);
return
result
;
}
int
cache_save
(
const
char
*
name
,
uint32_t
version
,
const
void
*
data
,
uint32_t
len
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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