Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2003 - 2006 Pekka Riikonen
+ Copyright (C) 2003 - 2007 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
*
* SYNOPSIS
*
- * const char *silc_time_string(SilcInt64 time_val);
+ * const char *silc_time_string(SilcInt64 time_val_sec);
*
* DESCRIPTION
*
* Returns time and date as string. The caller must not free the string
* and next call to this function will delete the old string. If the
- * `time_val' is zero (0) returns current time as string, otherwise the
- * `time_val' as string. The `time_val' is in seconds since Epoch.
+ * `time_val_sec' is zero (0) returns current time as string, otherwise the
+ * `time_val_sec' as string. The `time_val_sec' is in seconds since Epoch.
* Returns NULL on error.
*
***/
-const char *silc_time_string(SilcInt64 time_val);
+const char *silc_time_string(SilcInt64 time_val_sec);
/****f* silcutil/SilcTimeAPI/silc_time_value
*
* SYNOPSIS
*
- * SilcBool silc_time_value(SilcInt64 time_val, SilcTime ret_time);
+ * SilcBool silc_time_value(SilcInt64 time_val_msec, SilcTime ret_time);
*
* DESCRIPTION
*
- * Returns time and date as SilcTime. If the `time_val' is zero (0)
- * returns current time as SilcTime, otherwise the `time_val' as SilcTime.
- * The `time_val' is in milliseconds since Epoch. Returns FALSE on error,
- * TRUE otherwise.
+ * Returns time and date as SilcTime. If the `time_val_msec' is zero (0)
+ * returns current time as SilcTime, otherwise the `time_val_msec' as
+ * SilcTime. The `time_val_msec' is in milliseconds since Epoch. Returns
+ * FALSE on error, TRUE otherwise.
*
***/
-SilcBool silc_time_value(SilcInt64 time_val, SilcTime ret_time);
+SilcBool silc_time_value(SilcInt64 time_val_msec, SilcTime ret_time);
+
+/****f* silcutil/SilcTimeAPI/silc_timezone
+ *
+ * SYNOPSIS
+ *
+ * SilcBool silc_timezone(char *timezone, SilcUInt32 timezone_size);
+ *
+ * DESCRIPTION
+ *
+ * Returns current timezone in Universal time format into the `timezone'
+ * buffer of size of `timezone_size'. The possible values this function
+ * returns are: Z (For UTC timezone), +hh (UTC + hours) -hh (UTC - hours),
+ * +hh:mm (UTC + hours:minutes) or -hh:mm (UTC - hours:minutes).
+ *
+ * Returns FALSE on error, TRUE otherwise.
+ *
+ ***/
+SilcBool silc_timezone(char *timezone, SilcUInt32 timezone_size);
/****f* silcutil/SilcTimeAPI/silc_time_universal
*
***/
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
+ User::After(microseconds / 1000);
+#endif /* SILC_SYMBIAN */
+}
+
#endif /* SILCTIME_H */