home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / contrib / samba / samba-1.8 / samba-1 / samba-1.8.05 / timetest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-27  |  1.3 KB  |  64 lines

  1. #include "local.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <ctype.h>
  5. #include <time.h>
  6. #ifndef sun386
  7. #include <utime.h>
  8. #endif
  9. #include <sys/types.h>
  10. #include <sys/socket.h>
  11. #include <sys/ioctl.h>
  12. #include <sys/time.h>
  13. #include <netinet/in.h>
  14. #include <netdb.h>
  15. #include <signal.h>
  16. #include <errno.h>
  17. #include <sys/file.h>
  18. #include <sys/stat.h>
  19. #include <sys/param.h>
  20. #include <sys/mount.h>
  21. #include <pwd.h>
  22. #ifdef __STDC__
  23. #include <stdarg.h>
  24. #else
  25. #include <varargs.h>
  26. #endif
  27. #include <unistd.h>
  28. #include <sys/wait.h>
  29. #ifdef ISC
  30. #include <sys/stream.h>
  31. #endif
  32. #include <net/if.h>
  33.  
  34. /****************************************************************************
  35. set the time on a file
  36. ****************************************************************************/
  37. int set_filetime(char *fname,time_t mtime)
  38. {
  39.   struct utimbuf times;
  40.  
  41.   times.modtime = times.actime = mtime;
  42.  
  43.   return(utime(fname,×) == 0);
  44. }
  45.  
  46. /****************************************************************************
  47. get the time on a file
  48. ****************************************************************************/
  49. int get_filetime(char *fname)
  50. {
  51.   struct stat st;
  52.   if (stat(fname,&st) != 0) 
  53.     return(0);
  54.   
  55.   return(st.st_mtime);
  56. }
  57.  
  58.  
  59. main()
  60. {
  61.   set_filetime("timetest.c",100000);
  62.   printf("%d\n",get_filetime("timetest.c"));
  63. }
  64.