home *** CD-ROM | disk | FTP | other *** search
- #ifndef LINT
- static char bsdid[]="@(#) bsd.c 1.4 87/07/12 15:05:42";
- #endif /* LINT */
-
- /* machine.c for 4.3BSD. */
-
- /*
- The contents of this file are hereby released to the public domain.
-
- -- Rahul Dhesi 1986/12/31
- */
-
- long tell();
-
- /****************
- function trunc() truncates a file.
- */
-
- int trunc (handle)
- int handle;
- {
- ftruncate (handle, tell(handle));
- }
-
- /****************
- Function fixfname() converts the supplied filename to a syntax
- legal for the host system. It is used during extraction.
- */
-
- char *fixfname(fname)
- char *fname;
- {
- return (fname); /* default is no-op */
- }
-
- /****************
- Date and time functions are standard UNIX-style functions. "nixtime.i"
- will be included by machine.c.
- */
-
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/time.h>
-
- /* Function isadir() returns 1 if the supplied handle is a directory,
- else it returns 0.
- */
-
- int isadir (handle)
- int handle;
- {
- struct stat buf; /* buffer to hold file information */
- if (fstat (handle, &buf) == -1) {
- return (0); /* inaccessible -- assume not dir */
- } else {
- if (buf.st_mode & S_IFDIR)
- return (1);
- else
- return (0);
- }
- }
-
- /* Function gettz(), returns the offset from GMT in seconds */
- long gettz()
- {
- struct timeval tp;
- struct timezone tzp;
- gettimeofday (&tp, &tzp); /* specific to 4.3BSD */
-
- /* return (tzp.tz_minuteswest * 60); */ /* old incorrect code fixed below */
- /*
- Timezone fix thanks to Bill Davidsen <wedu@ge-crd.ARPA>
- {uunet | philabs | seismo!rochester}!steinmetz!crdos1!davidsen
- */
- return (tzp.tz_minuteswest * 60 - tzp.tz_dsttime * 3600L);
- }
-
- /* Standard UNIX-compatible time routines */
- #include "nixtime.i"
-