*BSD News Article 23119


Return to BSD News archive

Newsgroups: comp.os.386bsd.questions
Path: sserve!newshost.anu.edu.au!munnari.oz.au!constellation!convex!convex!cs.utexas.edu!uwm.edu!spool.mu.edu!umn.edu!csus.edu!netcom.com!alm
From: alm@netcom.com (Andrew Moore)
Subject: Re: FreeBSD: where is ftime?????
Message-ID: <almCFt7rz.JqA@netcom.com>
Organization: Netcom Online Communications Services (408-241-9760 login: guest)
References: <2b2odb$1g0@Tut.MsState.Edu>
Date: Mon, 1 Nov 1993 10:57:34 GMT
Lines: 78

In article <2b2odb$1g0@Tut.MsState.Edu> root@cy.cs.olemiss.edu (Priviledged Acct.) writes:
>I think this question prob. holds for all BSDs...
>
>I was trying to port some x-apps over to my FreeBSDe system, but quite
>a few of them didn't compile cause they couldn't find 'ftime'. What
>can i use instead of ftime? or is ftime there, but not in a standard
>place?

From: spedpr@thor.cf.ac.uk (Paul Richards)
Date: 26 Nov 92 12:45:07 GMT
Sender: news@cm.cf.ac.uk (Network News System)
References: <1992Nov24.093116.226@otago.ac.nz> <1992Nov24.223305.5227@mnemosyne.cs.du.edu> <ByA03o.BoL@unx.sas.com>
Organization: University of Wales College at Cardiff
X-Mailer: Cardiff Computing Maths PP Mail Open News Gateway
Lines: 60

In article <ByA03o.BoL@unx.sas.com> sastdr@torpid.unx.sas.com (Thomas David Rivers) writes:
|
| 
| There is a nice ftime() replacement in the Cnews source.  It is in
|the "faked-up" library for SysV boxes, but works well on 386BSD.
|

I found a ftime using archie that was coded up for BSDI. I've contacted
the author and he's happy to let us use it for 386bsd. I've included the
source below.

The author's mail address is:
>From erik@com.retix.eab Thu Nov 12 18:16:45 1992

/*
 *  A reimplementation of the 'deprecated' ftime
 *  system call using modern BSD 4.3 and later calls.
 *  Note that under BSDI/386, the kernel runs on UTC
 *  time so we cannot really use the time zone info
 *  from the gettimeofday system call. Therefore we
 *  use the localtime library function which does
 *  all appropriate conversions.
 *  Erik Forsberg.
 */

#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/timeb.h>

int ftime(tbp)
	struct timeb *tbp;
	{
	struct timeval tv;
	struct tm *tmp;

	if (tbp == NULL)
		return(-1);

	if (gettimeofday(&tv, (struct timezone *) NULL) < 0)
		return(-1);

	if ((tmp = localtime(&tv.tv_sec)) == NULL)
		return(-1);

	tbp->time = tv.tv_sec;
	tbp->millitm = tv.tv_usec / 1000;

	tbp->timezone = - tmp->tm_gmtoff / 60;
	tbp->dstflag = tmp->tm_isdst;

	return(0);
	}

-- 
  Paul Richards at Cardiff university, UK.

  spedpr@uk.ac.cf.thor	Internet: spedpr@thor.cf.ac.uk
  UUCP:     spedpr@cf-thor.UUCP or ...!uunet!mcsun!uknet!cf!thor!spedpr
+++