Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=yaxmenu.git;a=commitdiff;h=b293c5e148a7d05515594c39210b35073af24bdb

commit b293c5e148a7d05515594c39210b35073af24bdb
Author: James Buren <r...@frugalware.org>
Date:   Thu Dec 3 22:09:47 2009 -0600

xdg.c
* add _xdg_build_dirs

diff --git a/src/xdg.c b/src/xdg.c
index d35c0a1..808db6f 100644
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -14,6 +14,38 @@
// Designed for XDG Base Directory Specification Version 0.6
// Url: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

+static inline void _xdg_build_dirs(const char *home,as_t *dirs,bool mode) {
+  const char *home_env, *dirs_env, *home_default, *dirs_default, *env;
+
+  assert(home && dirs);
+
+  home_env = (mode) ? XDG_CONFIG_HOME_ENV : XDG_DATA_HOME_ENV;
+
+  dirs_env = (mode) ? XDG_CONFIG_DIRS_ENV : XDG_DATA_DIRS_ENV;
+
+  home_default = (mode) ? XDG_CONFIG_HOME_DEFAULT : XDG_DATA_HOME_DEFAULT;
+
+  dirs_default = (mode) ? XDG_CONFIG_DIRS_DEFAULT : XDG_DATA_DIRS_DEFAULT;
+
+  env = getenv(home_env);
+
+  if(env && *env)
+    as_puts(dirs,env);
+  else {
+    as_puts(dirs,home);
+    as_puts(dirs,home_default);
+  }
+
+  as_puts(dirs,":");
+
+  env = getenv(dirs_env);
+
+  if(env && *env)
+    as_puts(dirs,env);
+  else
+    as_puts(dirs,dirs_default);
+}
+
bool xdg_init(xdg_t *xdg) {
return true;
}
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to