XMMS2
|
00001 /* XMMS2 - X Music Multiplexer System 00002 * Copyright (C) 2003-2011 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 /* Have thread safe localtime when POSIX localtime_r isn't available */ 00018 00019 #include "xmmspriv/xmms_localtime.h" 00020 00021 static GStaticMutex mutex = G_STATIC_MUTEX_INIT; 00022 00023 gboolean 00024 xmms_localtime (const time_t *tt, struct tm *res) 00025 { 00026 struct tm *ret = NULL; 00027 00028 g_static_mutex_lock (&mutex); 00029 if ((ret = localtime (tt))) { 00030 memcpy (res, ret, sizeof (struct tm)); 00031 ret = res; 00032 } 00033 g_static_mutex_unlock (&mutex); 00034 00035 if (ret) { 00036 return TRUE; 00037 } else { 00038 return FALSE; 00039 } 00040 }