home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / EXTRAS / UUCODE / UUPC / TEST / UPC12ES1.ZIP / LIB / dos2unix.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-11  |  4.4 KB  |  128 lines

  1. /*--------------------------------------------------------------------*/
  2. /*      d o s 2 u n i x . c                                           */
  3. /*--------------------------------------------------------------------*/
  4.  
  5. /*--------------------------------------------------------------------*/
  6. /*    Changes Copyright (c) 1989 by Andrew H. Derbyshire.             */
  7. /*                                                                    */
  8. /*    Changes Copyright (c) 1990-1993 by Kendra Electronic            */
  9. /*    Wonderworks.                                                    */
  10. /*                                                                    */
  11. /*    All rights reserved except those explicitly granted by the      */
  12. /*    UUPC/extended license agreement.                                */
  13. /*--------------------------------------------------------------------*/
  14.  
  15. /*--------------------------------------------------------------------*/
  16. /*                          RCS Information                           */
  17. /*--------------------------------------------------------------------*/
  18.  
  19. /*
  20.  *    $Id: dos2unix.c 1.4 1993/04/10 21:22:29 dmwatt Exp $
  21.  *
  22.  *    Revision history:
  23.  *    $Log: dos2unix.c $
  24.  *     Revision 1.4  1993/04/10  21:22:29  dmwatt
  25.  *     Windows/NT fixes
  26.  *
  27.  * Revision 1.4  1993/04/10  21:22:29  dmwatt
  28.  * Windows/NT fixes
  29.  *
  30.  * Revision 1.3  1993/04/05  12:26:01  ahd
  31.  * Correct headers to match gpkt
  32.  *
  33.  * Revision 1.2  1993/04/05  04:32:19  ahd
  34.  * Add timestamp, size to information returned by directory searches
  35.  *
  36.  * Revision 1.1  1993/04/04  19:35:14  ahd
  37.  * Initial revision
  38.  *
  39.  */
  40.  
  41. /*--------------------------------------------------------------------*/
  42. /*                        System include files                        */
  43. /*--------------------------------------------------------------------*/
  44.  
  45. #include <stdio.h>
  46. #include <time.h>
  47. #include <string.h>
  48.  
  49. /*--------------------------------------------------------------------*/
  50. /*                         OS/2 include files                         */
  51. /*--------------------------------------------------------------------*/
  52.  
  53. #ifdef FAMILY_API
  54. #define INCL_BASE
  55. #include <os2.h>
  56. #endif
  57.  
  58. /*--------------------------------------------------------------------*/
  59. /*                      Windows/NT include files                      */
  60. /*--------------------------------------------------------------------*/
  61.  
  62. #ifdef WIN32
  63. #include <windows.h>
  64. #endif
  65.  
  66. /*--------------------------------------------------------------------*/
  67. /*                    UUPC/extended include files                     */
  68. /*--------------------------------------------------------------------*/
  69.  
  70. #include "lib.h"
  71. #include "dos2unix.h"
  72.  
  73. /*--------------------------------------------------------------------*/
  74. /*       d o s 2 u n i x                                              */
  75. /*                                                                    */
  76. /*       Convert a DOS file time stamp to unix t_time                 */
  77. /*--------------------------------------------------------------------*/
  78.  
  79. time_t dos2unix( const FDATE ddmmyy,
  80.                  const FTIME ssmmhh )
  81. {
  82.  
  83.    struct tm  time_record;
  84.  
  85.    time_record.tm_sec = ssmmhh.twosecs * 2;
  86.    time_record.tm_min = ssmmhh.minutes;
  87.    time_record.tm_hour= ssmmhh.hours;
  88.  
  89.    time_record.tm_mday = ddmmyy.day;
  90.    time_record.tm_mon  = ddmmyy.month - 1;
  91.    time_record.tm_year = 80 + ddmmyy.year;
  92.  
  93.    time_record.tm_isdst = -1;
  94.  
  95.    return mktime(&time_record);
  96.  
  97. } /* dos2unix */
  98.  
  99. #ifdef WIN32
  100.  
  101. /*--------------------------------------------------------------------*/
  102. /*       n t 2 u n i x                                              */
  103. /*                                                                    */
  104. /*       Convert an NT file time stamp to unix t_time                 */
  105. /*--------------------------------------------------------------------*/
  106.  
  107. time_t nt2unix( FILETIME *nsec )
  108. {
  109.    SYSTEMTIME sysTime;
  110.    struct tm  time_record;
  111.  
  112.    FileTimeToSystemTime(nsec, &sysTime);
  113.  
  114.    time_record.tm_sec = sysTime.wSecond;
  115.    time_record.tm_min = sysTime.wMinute;
  116.    time_record.tm_hour= sysTime.wHour;
  117.  
  118.    time_record.tm_mday = sysTime.wDay;
  119.    time_record.tm_mon  = sysTime.wMonth - 1;
  120.    time_record.tm_year = sysTime.wYear - 1900;
  121.  
  122.    time_record.tm_isdst = -1;
  123.  
  124.    return mktime(&time_record);
  125.  
  126. } /* nt2unix */
  127. #endif
  128.