Back to index

nagios-plugins  1.4.16
time_r.c
Go to the documentation of this file.
00001 /* Reentrant time functions like localtime_r.
00002 
00003    Copyright (C) 2003, 2006-2007, 2010 Free Software Foundation, Inc.
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 3, or (at your option)
00008    any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License along
00016    with this program; if not, write to the Free Software Foundation,
00017    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
00018 
00019 /* Written by Paul Eggert.  */
00020 
00021 #include <config.h>
00022 
00023 #include <time.h>
00024 
00025 static struct tm *
00026 copy_tm_result (struct tm *dest, struct tm const *src)
00027 {
00028   if (! src)
00029     return 0;
00030   *dest = *src;
00031   return dest;
00032 }
00033 
00034 
00035 struct tm *
00036 gmtime_r (time_t const * restrict t, struct tm * restrict tp)
00037 {
00038   return copy_tm_result (tp, gmtime (t));
00039 }
00040 
00041 struct tm *
00042 localtime_r (time_t const * restrict t, struct tm * restrict tp)
00043 {
00044   return copy_tm_result (tp, localtime (t));
00045 }