libaacs | branch: master | npzacs <[email protected]> | Tue Oct  8 11:20:10 2013 
+0300| [f26483a0a96559cf6f7af8ff1bf7df10cafc957c] | committer: npzacs

Simplify building system-specific config dir stuff

> http://git.videolan.org/gitweb.cgi/libaacs.git/?a=commit;h=f26483a0a96559cf6f7af8ff1bf7df10cafc957c
---

 src/Makefile.am              |   10 ++++------
 src/file/darwin.c            |    8 ++++----
 src/file/darwin.h            |   29 -----------------------------
 src/file/{win32.h => dirs.h} |   12 ++++++++----
 src/file/keydbcfg.c          |   17 +----------------
 src/file/win32.c             |   11 ++++++++---
 src/file/xdg.c               |    8 ++++----
 src/file/xdg.h               |   29 -----------------------------
 8 files changed, 29 insertions(+), 95 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 882bab1..24f3fe4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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
 
diff --git a/src/file/darwin.c b/src/file/darwin.c
index ed0fd7d..a92dd5c 100644
--- a/src/file/darwin.c
+++ b/src/file/darwin.c
@@ -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"
 
diff --git a/src/file/darwin.h b/src/file/darwin.h
deleted file mode 100644
index 87384e7..0000000
--- a/src/file/darwin.h
+++ /dev/null
@@ -1,29 +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
diff --git a/src/file/win32.h b/src/file/dirs.h
similarity index 79%
rename from src/file/win32.h
rename to src/file/dirs.h
index 85effde..6b21fbd 100644
--- a/src/file/win32.h
+++ b/src/file/dirs.h
@@ -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
diff --git a/src/file/keydbcfg.c b/src/file/keydbcfg.c
index ddac497..bf41b93 100644
--- a/src/file/keydbcfg.c
+++ b/src/file/keydbcfg.c
@@ -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"
diff --git a/src/file/win32.c b/src/file/win32.c
index 31c8e5c..7646616 100644
--- a/src/file/win32.c
+++ b/src/file/win32.c
@@ -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];
diff --git a/src/file/xdg.c b/src/file/xdg.c
index bbb1dd2..b7bf76f 100644
--- a/src/file/xdg.c
+++ b/src/file/xdg.c
@@ -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"
 
diff --git a/src/file/xdg.h b/src/file/xdg.h
deleted file mode 100644
index d19db5c..0000000
--- a/src/file/xdg.h
+++ /dev/null
@@ -1,29 +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

_______________________________________________
libaacs-devel mailing list
[email protected]
https://mailman.videolan.org/listinfo/libaacs-devel

Reply via email to