static void _print_music_dir(void) { const char *s = efreet_music_dir_get(); if (!s) return; fputs(s, stdout); }
E_API char * e_util_shell_env_path_eval(const char *path) { /* evaluate things like: * $HOME/bling -> /home/user/bling * $HOME/bin/$HOSTNAME/blah -> /home/user/bin/localhost/blah * etc. etc. */ const char *p, *v2, *v1 = NULL; char buf[PATH_MAX], *pd, *s, *vp; char *v = NULL; int esc = 0, invar = 0; for (p = path, pd = buf; (pd < (buf + sizeof(buf) - 1)); p++) { if (invar) { if (!((isalnum(*p)) || (*p == '_'))) { v2 = p; invar = 0; if ((v2 - v1) > 1) { s = alloca(v2 - v1); strncpy(s, v1 + 1, v2 - v1 - 1); s[v2 - v1 - 1] = 0; if (strncmp(s, "XDG", 3)) v = getenv(s); else { if (!strcmp(s, "XDG_CONFIG_HOME")) v = (char *)efreet_config_home_get(); else if (!strcmp(s, "XDG_CACHE_HOME")) v = (char *)efreet_cache_home_get(); else if (!strcmp(s, "XDG_DATA_HOME")) v = (char *)efreet_data_home_get(); else if (!strcmp(s, "XDG_DESKTOP_DIR")) v = (char *)efreet_desktop_dir_get(); else if (!strcmp(s, "XDG_DOWNLOAD_DIR")) v = (char *)efreet_download_dir_get(); else if (!strcmp(s, "XDG_TEMPLATES_DIR")) v = (char *)efreet_templates_dir_get(); else if (!strcmp(s, "XDG_PUBLICSHARE_DIR")) v = (char *)efreet_public_share_dir_get(); else if (!strcmp(s, "XDG_DOCUMENTS_DIR")) v = (char *)efreet_documents_dir_get(); else if (!strcmp(s, "XDG_MUSIC_DIR")) v = (char *)efreet_music_dir_get(); else if (!strcmp(s, "XDG_PICTURES_DIR")) v = (char *)efreet_pictures_dir_get(); else if (!strcmp(s, "XDG_VIDEOS_DIR")) v = (char *)efreet_videos_dir_get(); else if (!strcmp(s, "XDG_RUNTIME_DIR")) v = (char *)efreet_runtime_dir_get(); } if (v) { vp = v; while ((*vp) && (pd < (buf + sizeof(buf) - 1))) { *pd = *vp; vp++; pd++; } } } if (pd < (buf + sizeof(buf) - 1)) { *pd = *p; pd++; } } } else { if (esc) { *pd = *p; pd++; } else { if (*p == '\\') esc = 1; else if (*p == '$') { invar = 1; v1 = p; } else { *pd = *p; pd++; } } } if (*p == 0) break; } *pd = 0; return strdup(buf); }