From 55d9fcb126247041a8934a060e1a441a26b2be8d Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 11 Sep 2007 01:00:33 +0000 Subject: [PATCH] add globally defined PA_PATH_SEP macro, replacing private per-file macros git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1801 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/daemon/daemon-conf.c | 14 ++++---------- src/pulse/client-conf.c | 8 +------- src/pulse/util.c | 8 +------- src/pulsecore/core-util.c | 8 +++----- src/pulsecore/macro.h | 8 ++++++++ 5 files changed, 17 insertions(+), 29 deletions(-) diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index 7b503f8..ff62816 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -42,16 +42,10 @@ #include "daemon-conf.h" -#ifndef OS_IS_WIN32 -# define PATH_SEP "/" -#else -# define PATH_SEP "\\" -#endif - -#define DEFAULT_SCRIPT_FILE PA_DEFAULT_CONFIG_DIR PATH_SEP "default.pa" -#define DEFAULT_SCRIPT_FILE_USER PATH_SEP "default.pa" -#define DEFAULT_CONFIG_FILE PA_DEFAULT_CONFIG_DIR PATH_SEP "daemon.conf" -#define DEFAULT_CONFIG_FILE_USER PATH_SEP "daemon.conf" +#define DEFAULT_SCRIPT_FILE PA_DEFAULT_CONFIG_DIR PA_PATH_SEP "default.pa" +#define DEFAULT_SCRIPT_FILE_USER PA_PATH_SEP "default.pa" +#define DEFAULT_CONFIG_FILE PA_DEFAULT_CONFIG_DIR PA_PATH_SEP "daemon.conf" +#define DEFAULT_CONFIG_FILE_USER PA_PATH_SEP "daemon.conf" #define ENV_SCRIPT_FILE "PULSE_SCRIPT" #define ENV_CONFIG_FILE "PULSE_CONFIG" diff --git a/src/pulse/client-conf.c b/src/pulse/client-conf.c index d1e9969..447d185 100644 --- a/src/pulse/client-conf.c +++ b/src/pulse/client-conf.c @@ -42,13 +42,7 @@ #include "client-conf.h" -#ifndef OS_IS_WIN32 -# define PATH_SEP "/" -#else -# define PATH_SEP "\\" -#endif - -#define DEFAULT_CLIENT_CONFIG_FILE PA_DEFAULT_CONFIG_DIR PATH_SEP "client.conf" +#define DEFAULT_CLIENT_CONFIG_FILE PA_DEFAULT_CONFIG_DIR PA_PATH_SEP "client.conf" #define DEFAULT_CLIENT_CONFIG_FILE_USER "client.conf" #define ENV_CLIENT_CONFIG_FILE "PULSE_CLIENTCONFIG" diff --git a/src/pulse/util.c b/src/pulse/util.c index 879b7bf..32f4137 100644 --- a/src/pulse/util.c +++ b/src/pulse/util.c @@ -64,12 +64,6 @@ #include "util.h" -#ifndef OS_IS_WIN32 -#define PATH_SEP '/' -#else -#define PATH_SEP '\\' -#endif - char *pa_get_user_name(char *s, size_t l) { char *p; char buf[1024]; @@ -217,7 +211,7 @@ char *pa_path_get_filename(const char *p) { pa_assert(p); - if ((fn = strrchr(p, PATH_SEP))) + if ((fn = strrchr(p, PA_PATH_SEP_CHAR))) return fn+1; return (char*) p; diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 13a7252..d37a11c 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -100,10 +100,8 @@ #ifndef OS_IS_WIN32 #define PA_USER_RUNTIME_PATH_PREFIX "/tmp/pulse-" -#define PATH_SEP '/' #else #define PA_USER_RUNTIME_PATH_PREFIX "%TEMP%\\pulse-" -#define PATH_SEP '\\' #endif #ifdef OS_IS_WIN32 @@ -118,7 +116,7 @@ int pa_set_root(HANDLE handle) { if (!GetModuleFileName(handle, library_path + sizeof(PULSE_ROOTENV), MAX_PATH)) return 0; - sep = strrchr(library_path, '\\'); + sep = strrchr(library_path, PA_PATH_SEP_CHAR); if (sep) *sep = '\0'; @@ -1123,7 +1121,7 @@ char *pa_runtime_path(const char *fn, char *s, size_t l) { if ((e = getenv("PULSE_RUNTIME_PATH"))) { if (fn) - pa_snprintf(s, l, "%s%c%s", e, PATH_SEP, fn); + pa_snprintf(s, l, "%s%c%s", e, PA_PATH_SEP_CHAR, fn); else pa_snprintf(s, l, "%s", e); @@ -1131,7 +1129,7 @@ char *pa_runtime_path(const char *fn, char *s, size_t l) { char u[256]; if (fn) - pa_snprintf(s, l, "%s%s%c%s", PA_USER_RUNTIME_PATH_PREFIX, pa_get_user_name(u, sizeof(u)), PATH_SEP, fn); + pa_snprintf(s, l, "%s%s%c%s", PA_USER_RUNTIME_PATH_PREFIX, pa_get_user_name(u, sizeof(u)), PA_PATH_SEP_CHAR, fn); else pa_snprintf(s, l, "%s%s", PA_USER_RUNTIME_PATH_PREFIX, pa_get_user_name(u, sizeof(u))); } diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h index c1bdb14..c46ae52 100644 --- a/src/pulsecore/macro.h +++ b/src/pulsecore/macro.h @@ -114,4 +114,12 @@ static inline size_t pa_page_align(size_t l) { #define PA_PTR_TO_INT32(p) ((int32_t) PA_PTR_TO_UINT(p)) #define PA_INT32_TO_PTR(u) PA_UINT_TO_PTR((int32_t) u) +#ifdef OS_IS_WIN32 +#define PA_PATH_SEP "\\" +#define PA_PATH_SEP_CHAR '\\' +#else +#define PA_PATH_SEP "/" +#define PA_PATH_SEP_CHAR '/' +#endif + #endif -- 2.7.4