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

commit c6b9b4617b0d7e92d65f4e70424fa9b8ec7f5102
Author: James Buren <r...@frugalware.org>
Date:   Thu Dec 3 23:07:13 2009 -0600

xdg.c
* add _xdg_build_program_dirs
* add new macro constants

diff --git a/src/xdg.c b/src/xdg.c
index 808db6f..0c6e5ff 100644
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -1,6 +1,9 @@
#include "autostring.h"
#include "xdg.h"

+#define HOME_ENV                "HOME"
+#define MODE_CONFIG             true
+#define MODE_DATA               false
#define XDG_CONFIG_HOME_DEFAULT "/.config"
#define XDG_CONFIG_HOME_ENV     "XDG_CONFIG_HOME"
#define XDG_CONFIG_DIRS_DEFAULT "/etc/xdg"
@@ -46,6 +49,44 @@ static inline void _xdg_build_dirs(const char *home,as_t 
*dirs,bool mode) {
as_puts(dirs,dirs_default);
}

+static inline char **_xdg_build_program_dirs(const char *odirs) {
+  const char *s;
+  size_t i;
+  as_t buf;
+  char **ndirs;
+  char *tmp;
+
+  assert(odirs);
+
+  for( s = odirs, i = 0 ; *s ; ++s )
+    if(*s == ':')
+      ++i;
+
+  if(!i)
+    return NULL;
+
+  as_init(&buf);
+
+  for( s = odirs ; *s ; ++s ) {
+    if(*s == ':')
+      as_puts(&buf,PROGRAM_DIRECTORY);
+    as_putc(&buf,*s);
+  }
+
+  as_compact(&buf);
+
+  ndirs = xnew(char *,i + 1);
+
+  ndirs[i = 0] = as_gets(&buf);
+
+  ndirs[++i] = strtok_r(*ndirs,":",&tmp);
+
+  while((ndirs[i++] = strtok_r(NULL,":",&tmp)))
+    ;
+
+  return ndirs;
+}
+
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