00001 /* XMMS2 - X Music Multiplexer System 00002 * Copyright (C) 2003-2008 XMMS2 Team 00003 * 00004 * PLUGINS ARE NOT CONSIDERED TO BE DERIVED WORK !!! 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 */ 00016 00017 /** @file 00018 * Miscellaneous internal utility functions. 00019 */ 00020 00021 #include <stdlib.h> 00022 00023 #include "xmmsc/xmmsc_util.h" 00024 00025 /** 00026 * Get the absolute path to the user config dir. 00027 * 00028 * @param buf A char buffer 00029 * @param len The length of buf (PATH_MAX is a good choice) 00030 * @return A pointer to buf, or NULL if an error occurred. 00031 */ 00032 const char * 00033 xmms_userconfdir_get (char *buf, int len) 00034 { 00035 char *config_home; 00036 00037 if (!buf || len <= 0) 00038 return NULL; 00039 00040 config_home = getenv ("APPDATA"); 00041 00042 if (config_home && *config_home) { 00043 snprintf (buf, len, "%s\\xmms2", config_home); 00044 00045 return buf; 00046 } 00047 00048 return NULL; 00049 } 00050 00051 00052 /** 00053 * Get the fallback connection path (if XMMS_PATH is not accessible) 00054 * 00055 * @param buf A char buffer 00056 * @param len The length of buf (PATH_MAX is a good choice) 00057 * @return A pointer to buf, or NULL if an error occured. 00058 */ 00059 const char * 00060 xmms_fallback_ipcpath_get (char *buf, int len) 00061 { 00062 snprintf (buf, len, "tcp://127.0.0.1:" XMMS_STRINGIFY (XMMS_DEFAULT_TCP_PORT)); 00063 00064 return buf; 00065 }