Return to BSD News archive
Newsgroups: comp.os.386bsd.apps Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!spool.mu.edu!umn.edu!csus.edu!netcom.com!alm From: alm@netcom.com (Andrew Moore) Subject: Re: 386BSD versions of sources... Message-ID: <almCCDvz8.LAs@netcom.com> Organization: Netcom Online Communications Services (408-241-9760 login: guest) References: <CCB4ru.7K@sugar.NeoSoft.COM> <2179@foxim.nl> <CCDDt4.3rv@unx.sas.com> Date: Thu, 26 Aug 1993 20:37:56 GMT Lines: 54 In article <CCDDt4.3rv@unx.sas.com> sastdr@torpid.unx.sas.com (Thomas David Rivers) writes: > > In regards to C news; I had almost no problem building it on > 386bsd. > > The only difficulties are: > > 1) the flock() function has been deprecated in 386bsd, > (C news provides a nice clone one in the Sys V specific > directory) Oh, I think you mean ftime(3). flock is not deprecated, I believe. Here is a version of ftime for 386bsd which looks a little cleaner than the one included with C News: /* * 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); }