XMMS2
|
00001 /* XMMS2 - X Music Multiplexer System 00002 * Copyright (C) 2003-2009 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 #include <time.h> 00023 00024 #include "xmmsc/xmmsc_util.h" 00025 00026 /** 00027 * Get the absolute path to the user config dir. 00028 * 00029 * @param buf A char buffer 00030 * @param len The length of buf (PATH_MAX is a good choice) 00031 * @return A pointer to buf, or NULL if an error occurred. 00032 */ 00033 const char * 00034 xmms_userconfdir_get (char *buf, int len) 00035 { 00036 char *config_home; 00037 00038 if (!buf || len <= 0) 00039 return NULL; 00040 00041 config_home = getenv ("APPDATA"); 00042 00043 if (config_home && *config_home) { 00044 snprintf (buf, len, "%s\\xmms2", config_home); 00045 00046 return buf; 00047 } 00048 00049 return NULL; 00050 } 00051 00052 00053 /** 00054 * Get the fallback connection path (if XMMS_PATH is not accessible) 00055 * 00056 * @param buf A char buffer 00057 * @param len The length of buf (PATH_MAX is a good choice) 00058 * @return A pointer to buf, or NULL if an error occured. 00059 */ 00060 const char * 00061 xmms_fallback_ipcpath_get (char *buf, int len) 00062 { 00063 snprintf (buf, len, "tcp://127.0.0.1:" XMMS_STRINGIFY (XMMS_DEFAULT_TCP_PORT)); 00064 00065 return buf; 00066 } 00067 00068 /** 00069 * Sleep for n milliseconds. 00070 * 00071 * @param n The number of milliseconds to sleep. 00072 * @return true when we waited the full time, false otherwise. 00073 */ 00074 bool 00075 xmms_sleep_ms (int n) 00076 { 00077 Sleep (n); 00078 00079 return true; 00080 }