Main Page Modules Data Structures File List Data Fields Globals Related Pages

# beecrypt/timestamp.c

Go to the documentation of this file.

    00001 /*
    00002  * timestamp.c
    00003  *
    00004  * Java compatible 64-bit timestamp, code
    00005  *
    00006  * Copyright (c) 1999, 2000, 2002 Virtual Unlimited B.V.
    00007  *
    00008  * Author: Bob Deblier <bob@virtualunlimited.com>
    00009  *
    00010  * This library is free software; you can redistribute it and/or
    00011  * modify it under the terms of the GNU Lesser General Public
    00012  * License as published by the Free Software Foundation; either
    00013  * version 2.1 of the License, or (at your option) any later version.
    00014  *
    00015  * This library is distributed in the hope that it will be useful,
    00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00018  * Lesser General Public License for more details.
    00019  *
    00020  * You should have received a copy of the GNU Lesser General Public
    00021  * License along with this library; if not, write to the Free Software
    00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00023  *
    00024  */
    00025
    00026 #include "system.h"
    00027 #include "timestamp.h"
    00028 #include "debug.h"
    00029
    00030 javalong timestamp()
    00031 {
    00032         javalong tmp;
    00033         #if HAVE_SYS_TIME_H
    00034         # if HAVE_GETTIMEOFDAY
    00035         struct timeval now;
    00036
    00037         (void) gettimeofday(&now, 0);
    00038
    00039         tmp = ((javalong) now.tv_sec) * 1000 + (now.tv_usec / 1000);
    00040         # else
    00041         #  error
    00042         # endif
    00043         #elif HAVE_TIME_H
    00044         tmp = ((javalong) time(0)) * 1000;
    00045         #else
    00046         # error implement other time function
    00047         #endif
    00048
    00049         return tmp;
    00050 }