XMMS2
utils_win32.c
Go to the documentation of this file.
1 /* XMMS2 - X Music Multiplexer System
2  * Copyright (C) 2003-2009 XMMS2 Team
3  *
4  * PLUGINS ARE NOT CONSIDERED TO BE DERIVED WORK !!!
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  */
16 
17 /** @file
18  * Miscellaneous internal utility functions.
19  */
20 
21 #include <stdlib.h>
22 #include <time.h>
23 
24 #include "xmmsc/xmmsc_util.h"
25 
26 /**
27  * Get the absolute path to the user config dir.
28  *
29  * @param buf A char buffer
30  * @param len The length of buf (PATH_MAX is a good choice)
31  * @return A pointer to buf, or NULL if an error occurred.
32  */
33 const char *
34 xmms_userconfdir_get (char *buf, int len)
35 {
36  char *config_home;
37 
38  if (!buf || len <= 0)
39  return NULL;
40 
41  config_home = getenv ("APPDATA");
42 
43  if (config_home && *config_home) {
44  snprintf (buf, len, "%s\\xmms2", config_home);
45 
46  return buf;
47  }
48 
49  return NULL;
50 }
51 
52 
53 /**
54  * Get the fallback connection path (if XMMS_PATH is not accessible)
55  *
56  * @param buf A char buffer
57  * @param len The length of buf (PATH_MAX is a good choice)
58  * @return A pointer to buf, or NULL if an error occured.
59  */
60 const char *
61 xmms_fallback_ipcpath_get (char *buf, int len)
62 {
63  snprintf (buf, len, "tcp://127.0.0.1:" XMMS_STRINGIFY (XMMS_DEFAULT_TCP_PORT));
64 
65  return buf;
66 }
67 
68 /**
69  * Sleep for n milliseconds.
70  *
71  * @param n The number of milliseconds to sleep.
72  * @return true when we waited the full time, false otherwise.
73  */
74 bool
76 {
77  Sleep (n);
78 
79  return true;
80 }
bool xmms_sleep_ms(int n)
Sleep for n milliseconds.
Definition: utils_unix.c:114
#define XMMS_STRINGIFY(x)
Definition: xmmsc_util.h:9
#define XMMS_DEFAULT_TCP_PORT
Definition: xmmsc_util.h:45
const char * xmms_userconfdir_get(char *buf, int len)
Get the absolute path to the user config dir.
Definition: utils_unix.c:80
const char * xmms_fallback_ipcpath_get(char *buf, int len)
Get the fallback connection path (if XMMS_PATH is not accessible)
Definition: utils_unix.c:93