1 /***************************************************************************
2 * Copyright (C) 2007 by Arep *
3 * Support is provided through the forums at *
4 * http://www.console-tribe.com *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program 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 *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20 ***************************************************************************/
25 #include "win32compat.h"
29 #include <sys/timeb.h>
32 char *strndup (const char *src, int c) {
35 if ((dest = (char *) malloc ((c + 1) * sizeof (char)))) {
36 memcpy (dest, src, c);
44 int ftruncate (int fd, __int64 size) {
45 return (_chsize_s (fd, size));
50 /* The following gettimeofday() replacement function was taken from Snort, GPLv2 */
51 /****************************************************************************
53 * Function: gettimeofday(struct timeval *, struct timezone *)
55 * Purpose: Get current time of day.
57 * Arguments: tv => Place to store the curent time of day.
60 * Returns: 0 => Success.
62 ****************************************************************************/
63 int gettimeofday(struct timeval *tv, struct timezone *tz) {
70 tv->tv_sec = (long) tb.time;
71 tv->tv_usec = ((int) tb.millitm) * 1000;