Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2003 - 2007 Pekka Riikonen
+ Copyright (C) 2003 - 2008 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
-/****h* silcutil/SILC Time Interface
+/****h* silcutil/Time Interface
*
* DESCRIPTION
*
#ifndef SILCTIME_H
#define SILCTIME_H
-/****s* silcutil/SilcTimeAPI/SilcTime
+/****s* silcutil/SilcTime
*
* NAME
*
*
* SOURCE
*
- ***/
+ */
typedef struct SilcTimeObject {
unsigned int year : 15; /* Year, 0 - 32768 */
unsigned int month : 4; /* Month, 1 - 12 */
} *SilcTime, SilcTimeStruct;
/***/
-/****f* silcutil/SilcTimeAPI/silc_time
+/****s* silcutil/SilcTimeStruct
+ *
+ * NAME
+ *
+ * typedef struct { ... } *SilcTime, SilcTimeStruct;
+ *
+ * DESCRIPTION
+ *
+ * This context represents time value. It includes date and time
+ * down to millisecond precision. The structure size is 64 bits.
+ *
+ ***/
+
+/****f* silcutil/silc_time
*
* SYNOPSIS
*
***/
SilcInt64 silc_time(void);
-/****f* silcutil/SilcTimeAPI/silc_time_msec
+/****f* silcutil/silc_time_msec
*
* SYNOPSIS
*
***/
SilcInt64 silc_time_msec(void);
-/****f* silcutil/SilcTimeAPI/silc_time_usec
+/****f* silcutil/silc_time_usec
*
* SYNOPSIS
*
***/
SilcInt64 silc_time_usec(void);
-/****f* silcutil/SilcTimeAPI/silc_time_string
+/****f* silcutil/silc_time_string
*
* SYNOPSIS
*
***/
const char *silc_time_string(SilcInt64 time_val_sec);
-/****f* silcutil/SilcTimeAPI/silc_time_value
+/****f* silcutil/silc_time_value
*
* SYNOPSIS
*
- * SilcBool silc_time_value(SilcInt64 time_val_msec, SilcTime ret_time);
+ * SilcBool silc_time_value(SilcInt64 time_val_msec, SilcTime ret_time);
*
* DESCRIPTION
*
***/
SilcBool silc_time_value(SilcInt64 time_val_msec, SilcTime ret_time);
-/****f* silcutil/SilcTimeAPI/silc_timezone
+/****f* silcutil/silc_time_epoch
+ *
+ * SYNOPSIS
+ *
+ * SilcUInt64 silc_time_epoch(SilcTime timeval);
+ *
+ * DESCRIPTION
+ *
+ * Converts SilcTime into Epoch time value and returns the converted
+ * value.
+ *
+ ***/
+SilcUInt64 silc_time_epoch(SilcTime timeval);
+
+/****f* silcutil/silc_timezone
*
* SYNOPSIS
*
***/
SilcBool silc_timezone(char *timezone, SilcUInt32 timezone_size);
-/****f* silcutil/SilcTimeAPI/silc_time_universal
+/****f* silcutil/silc_time_universal
*
* SYNOPSIS
*
***/
SilcBool silc_time_universal(const char *universal_time, SilcTime ret_time);
-/****f* silcutil/SilcTimeAPI/silc_time_universal_string
+/****f* silcutil/silc_time_universal_string
*
* SYNOPSIS
*
SilcBool silc_time_universal_string(SilcTime time_val, char *ret_string,
SilcUInt32 ret_string_size);
-/****f* silcutil/SilcTimeAPI/silc_time_generalized
+/****f* silcutil/silc_time_generalized
*
* SYNOPSIS
*
SilcBool
silc_time_generalized(const char *generalized_time, SilcTime ret_time);
-/****f* silcutil/SilcTimeAPI/silc_time_generalized_string
+/****f* silcutil/silc_time_generalized_string
*
* SYNOPSIS
*
SilcBool silc_time_generalized_string(SilcTime time_val, char *ret_string,
SilcUInt32 ret_string_size);
-/****f* silcutil/SilcTimeAPI/silc_compare_timeval
+/****f* silcutil/silc_compare_timeval
*
* SYNOPSIS
*
***/
int silc_compare_timeval(struct timeval *t1, struct timeval *t2);
-/****f* silcutil/SilcTimeAPI/silc_gettimeofday
+/****f* silcutil/silc_gettimeofday
*
* SYNOPSIS
*
***/
int silc_gettimeofday(struct timeval *p);
-/****f* silcutil/SilcTimeAPI/silc_usleep
- *
- * SYNOPSIS
- *
- * void silc_usleep(long microseconds);
- *
- * DESCRIPTION
- *
- * Delays the execution of process/thread for the specified amount of
- * time, which is in microseconds.
- *
- * NOTES
- *
- * The delay is only approximate and on some platforms the resolution is
- * in fact milliseconds.
- *
- ***/
-static inline
-void silc_usleep(long microseconds)
-{
-#ifdef SILC_UNIX
-#ifdef HAVE_NANOSLEEP
- struct timespec tv;
- tv.tv_sec = 0;
- tv.tv_nsec = microseconds * 1000;
-#endif /* HAVE_NANOSLEEP */
-#endif /* SILC_UNIX */
-
-#ifdef SILC_UNIX
-#ifdef HAVE_NANOSLEEP
- nanosleep(&tv, NULL);
-#else
- usleep(microseconds);
-#endif /* HAVE_NANOSLEEP */
-#endif /* SILC_UNIX */
-#ifdef SILC_WIN32
- Sleep(microseconds / 1000);
-#endif /* SILC_WIN32 */
-#ifdef SILC_SYMBIAN
- silc_symbian_usleep(microseconds);
-#endif /* SILC_SYMBIAN */
-}
-
#endif /* SILCTIME_H */