Commit f26483a0 authored by npzacs's avatar npzacs
Browse files

Simplify building system-specific config dir stuff

parent 2a4ef4b0
......@@ -14,6 +14,7 @@ libaacs_la_SOURCES=\
libaacs/crypto.c \
libaacs/crypto.h \
libaacs/mkb.c \
file/dirs.h \
file/file.h \
file/filesystem.h \
file/file_posix.c \
......@@ -33,17 +34,14 @@ EXTRA_libaacs_la_SOURCES=\
if HAVE_DARWIN
libaacs_la_SOURCES+= \
file/darwin.c \
file/darwin.h
file/darwin.c
else
if HAVE_WIN32
libaacs_la_SOURCES+= \
file/win32.c \
file/win32.h
file/win32.c
else
libaacs_la_SOURCES+= \
file/xdg.c \
file/xdg.h
file/xdg.c
endif
endif
......
......@@ -17,7 +17,7 @@
* <http://www.gnu.org/licenses/>.
*/
#include "darwin.h"
#include "dirs.h"
#include <CoreFoundation/CoreFoundation.h>
......@@ -33,7 +33,7 @@
#define SYSTEM_CFG_DIR "/Library/Preferences"
const char *darwin_get_config_home(void)
const char *get_config_home(void)
{
static char *dir = NULL;
static int init_done = 0;
......@@ -52,7 +52,7 @@ const char *darwin_get_config_home(void)
return dir;
}
const char *darwin_get_cache_home(void)
const char *get_cache_home(void)
{
static char *dir = NULL;
static int init_done = 0;
......@@ -71,7 +71,7 @@ const char *darwin_get_cache_home(void)
return dir;
}
const char *darwin_get_config_system(const char *dir)
const char *get_config_system(const char *dir)
{
static char *dirs = NULL; // "dir1\0dir2\0...\0dirN\0\0"
......
/*
* This file is part of libaacs
* Copyright (C) 2012 Konstantin Pavlov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef AACS_DARWIN_H
#define AACS_DARWIN_H
#include <util/attributes.h>
AACS_PRIVATE const char *darwin_get_config_home(void);
AACS_PRIVATE const char *darwin_get_config_system(const char *dir);
AACS_PRIVATE const char *darwin_get_cache_home(void);
#endif
......@@ -17,13 +17,17 @@
* <http://www.gnu.org/licenses/>.
*/
#ifndef AACS_WIN32_H
#define AACS_WIN32_H
#ifndef AACS_DIRS_H
#define AACS_DIRS_H
#include <util/attributes.h>
#ifdef _WIN32
AACS_PRIVATE int win32_mkdir(const char *dir);
AACS_PRIVATE const char *win32_get_config_home(void);
AACS_PRIVATE const char *win32_get_config_system(const char *dir);
#endif
AACS_PRIVATE const char *get_config_home(void);
AACS_PRIVATE const char *get_config_system(const char *dir);
AACS_PRIVATE const char *get_cache_home(void);
#endif
......@@ -19,22 +19,7 @@
#include "keydbcfg.h"
#if defined(__APPLE__)
# include "darwin.h"
# define get_config_home darwin_get_config_home
# define get_cache_home darwin_get_cache_home
# define get_config_system darwin_get_config_system
#elif defined(_WIN32)
# include "win32.h"
# define get_config_home win32_get_config_home
# define get_cache_home win32_get_config_home
# define get_config_system win32_get_config_system
#else
# include "xdg.h"
# define get_config_home xdg_get_config_home
# define get_cache_home xdg_get_cache_home
# define get_config_system xdg_get_config_system
#endif
#include "dirs.h"
#include "util/strutl.h"
#include "util/logging.h"
......
......@@ -17,7 +17,7 @@
* <http://www.gnu.org/licenses/>.
*/
#include "win32.h"
#include "dirs.h"
#include "util/logging.h"
......@@ -41,7 +41,12 @@ int win32_mkdir(const char *dir)
return _wmkdir(wdir);
}
const char *win32_get_config_home(void)
const char *get_cache_home(void)
{
return get_config_home();
}
const char *get_config_home(void)
{
static char appdir[PATH_MAX] = "";
wchar_t wdir[MAX_PATH];
......@@ -60,7 +65,7 @@ const char *win32_get_config_home(void)
return NULL;
}
const char *win32_get_config_system(const char *dir)
const char *get_config_system(const char *dir)
{
static char appdir[PATH_MAX] = "";
wchar_t wdir[MAX_PATH];
......
......@@ -17,7 +17,7 @@
* <http://www.gnu.org/licenses/>.
*/
#include "xdg.h"
#include "dirs.h"
#include "util/strutl.h"
#include "util/logging.h"
......@@ -36,7 +36,7 @@
#define SYSTEM_CFG_DIR "/etc/xdg"
const char *xdg_get_config_home(void)
const char *get_config_home(void)
{
static char *dir = NULL;
static int init_done = 0;
......@@ -60,7 +60,7 @@ const char *xdg_get_config_home(void)
return dir;
}
const char *xdg_get_cache_home(void)
const char *get_cache_home(void)
{
static char *dir = NULL;
static int init_done = 0;
......@@ -84,7 +84,7 @@ const char *xdg_get_cache_home(void)
return dir;
}
const char *xdg_get_config_system(const char *dir)
const char *get_config_system(const char *dir)
{
static char *dirs = NULL; // "dir1\0dir2\0...\0dirN\0\0"
......
/*
* This file is part of libaacs
* Copyright (C) 2010 npzacs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef AACS_XDG_H
#define AACS_XDG_H
#include <util/attributes.h>
AACS_PRIVATE const char *xdg_get_config_home(void);
AACS_PRIVATE const char *xdg_get_config_system(const char *dir);
AACS_PRIVATE const char *xdg_get_cache_home(void);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment