XMMS2
utils_win32.c
Go to the documentation of this file.
1 /* XMMS2 - X Music Multiplexer System
2  * Copyright (C) 2003-2011 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 <windows.h>
23 #include <time.h>
24 
25 #include "xmmsc/xmmsc_util.h"
26 
27 /**
28  * Get the absolute path to the user config dir.
29  *
30  * @param buf A char buffer
31  * @param len The length of buf (XMMS_PATH_MAX is a good choice)
32  * @return A pointer to buf, or NULL if an error occurred.
33  */
34 const char *
35 xmms_userconfdir_get (char *buf, int len)
36 {
37  char *config_home;
38 
39  if (!buf || len <= 0)
40  return NULL;
41 
42  config_home = getenv ("APPDATA");
43 
44  if (config_home && *config_home) {
45  snprintf (buf, len, "%s\\xmms2", config_home);
46 
47  return buf;
48  }
49 
50  return NULL;
51 }
52 
53 
54 /**
55  * Get the fallback connection path (if XMMS_PATH is not accessible)
56  *
57  * @param buf A char buffer
58  * @param len The length of buf (XMMS_PATH_MAX is a good choice)
59  * @return A pointer to buf, or NULL if an error occured.
60  */
61 const char *
62 xmms_fallback_ipcpath_get (char *buf, int len)
63 {
64  snprintf (buf, len, "tcp://127.0.0.1:" XMMS_STRINGIFY (XMMS_DEFAULT_TCP_PORT));
65 
66  return buf;
67 }
68 
69 /**
70  * Sleep for n milliseconds.
71  *
72  * @param n The number of milliseconds to sleep.
73  * @return true when we waited the full time, false otherwise.
74  */
75 bool
77 {
78  Sleep (n);
79 
80  return true;
81 }
const char * xmms_fallback_ipcpath_get(char *buf, int len)
Get the fallback connection path (if XMMS_PATH is not accessible)
Definition: utils_win32.c:62
#define XMMS_STRINGIFY(x)
Definition: xmmsc_util.h:10
#define XMMS_DEFAULT_TCP_PORT
Definition: xmmsc_util.h:46
bool xmms_sleep_ms(int n)
Sleep for n milliseconds.
Definition: utils_win32.c:76
const char * xmms_userconfdir_get(char *buf, int len)
Get the absolute path to the user config dir.
Definition: utils_win32.c:35