home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume11 / zoo / part01 / bsd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-08-16  |  1.7 KB  |  80 lines

  1. #ifndef LINT
  2. static char bsdid[]="@(#) bsd.c 1.4 87/07/12 15:05:42";
  3. #endif /* LINT */
  4.  
  5. /* machine.c for 4.3BSD. */
  6.  
  7. /*
  8. The contents of this file are hereby released to the public domain.
  9.  
  10.                                     -- Rahul Dhesi  1986/12/31
  11. */
  12.  
  13. long tell();
  14.  
  15. /****************
  16. function trunc() truncates a file.
  17. */
  18.  
  19. int trunc (handle)
  20. int handle;
  21. {
  22.    ftruncate (handle, tell(handle));
  23. }
  24.  
  25. /****************
  26. Function fixfname() converts the supplied filename to a syntax
  27. legal for the host system.  It is used during extraction.
  28. */
  29.  
  30. char *fixfname(fname)
  31. char *fname;
  32. {
  33.    return (fname); /* default is no-op */
  34. }
  35.  
  36. /****************
  37. Date and time functions are standard UNIX-style functions.  "nixtime.i"
  38. will be included by machine.c.
  39. */
  40.  
  41. #include <sys/types.h>
  42. #include <sys/stat.h>
  43. #include <sys/time.h>
  44.  
  45. /* Function isadir() returns 1 if the supplied handle is a directory, 
  46. else it returns 0.  
  47. */
  48.  
  49. int isadir (handle)
  50. int handle;
  51. {
  52.    struct stat buf;           /* buffer to hold file information */
  53.    if (fstat (handle, &buf) == -1) {
  54.       return (0);             /* inaccessible -- assume not dir */
  55.    } else {
  56.       if (buf.st_mode & S_IFDIR)
  57.          return (1);
  58.       else
  59.          return (0);
  60.    }
  61. }
  62.  
  63. /* Function gettz(), returns the offset from GMT in seconds */
  64. long gettz()
  65. {
  66.    struct timeval tp;
  67.    struct timezone tzp;
  68.    gettimeofday (&tp, &tzp);              /* specific to 4.3BSD */
  69.  
  70.    /* return (tzp.tz_minuteswest * 60); */ /* old incorrect code fixed below */
  71.     /*
  72.     Timezone fix thanks to Bill Davidsen <wedu@ge-crd.ARPA>
  73.     {uunet | philabs | seismo!rochester}!steinmetz!crdos1!davidsen
  74.     */
  75.    return (tzp.tz_minuteswest * 60 - tzp.tz_dsttime * 3600L);
  76. }
  77.  
  78. /* Standard UNIX-compatible time routines */
  79. #include "nixtime.i"
  80.