Ignore:
Timestamp:
Dec 6, 2011, 10:00:10 AM (14 years ago)
Author:
Herwig Bauernfeind
Message:

Samba Server 3.5: Move fix for Ticket #182 to os2helper.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/lib/os2helper.c

    r664 r672  
    66 *                Yuri Dario
    77 *                Paul Smedley
     8 *                Herwig Bauernfeind
    89 *
    910 *  This program is free software; you can redistribute it and/or modify
     
    2930#define INCL_DOSMISC
    3031#define INCL_DOSMODULEMGR
     32#define INCL_DOSDATETIME
    3133#define INCL_DOSERRORS
    3234
     
    3537#include <stdlib.h>
    3638#include <errno.h>
     39#include <time.h>
    3740#include <types.h>
    3841#include <string.h>
     
    558561}
    559562
     563/* set date/time on OS/2 */
     564int os2_setdatetime(time_t t)
     565{
     566        struct tm *tm;
     567
     568        tm = localtime(&t);
     569        if (!tm) {
     570                return -1;
     571        }
     572
     573        DATETIME   DateTime = {0};
     574        APIRET     rc       = NO_ERROR;
     575
     576        /* Get current date/time to properly fill structure */
     577        rc = DosGetDateTime(&DateTime);
     578        if (rc != NO_ERROR) {
     579                return rc;
     580        }
     581
     582        DateTime.year    = (USHORT) ((BYTE) tm->tm_year+1900);
     583        DateTime.month   = (UCHAR) ((BYTE) tm->tm_mon+1);
     584        DateTime.day     = (UCHAR) ((BYTE) tm->tm_mday);
     585        DateTime.hours   = (UCHAR) ((BYTE) tm->tm_hour);
     586        DateTime.minutes = (UCHAR) ((BYTE) tm->tm_min);
     587        DateTime.seconds = (UCHAR) ((BYTE) tm->tm_sec);
     588
     589        rc = DosSetDateTime(&DateTime);  /* Update the date and time */
     590
     591        if (rc!= NO_ERROR) {
     592                printf ("DosSetDateTime error : return code = %u\n", rc);
     593        }
     594        return rc;
     595}
     596
    560597#endif
Note: See TracChangeset for help on using the changeset viewer.