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

Samba Server 3.3: Fix for Ticket #182

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.3.x/source/lib/os2helper.c

    r644 r673  
    1 /* This file contains helper functions for OS/2 -
    2    do not try to compile on other platforms! */
     1/*  This file contains Samba helper functions for eComStation (OS/2) -
     2 *  do not try to compile on other platforms!
     3 * 
     4 *  Copyright (C) 2007-2011
     5 *                Silvan Scherrer
     6 *                Yuri Dario
     7 *                Paul Smedley
     8 *                Herwig Bauernfeind
     9 *
     10 *  This program is free software; you can redistribute it and/or modify
     11 *  it under the terms of the GNU General Public License as published by
     12 *  the Free Software Foundation; either version 3 of the License, or
     13 *  (at your option) any later version.
     14 *
     15 *  This program is distributed in the hope that it will be useful,
     16 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     17 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     18 *  GNU General Public License for more details.
     19 *
     20 *  You should have received a copy of the GNU General Public License
     21 *  along with this program; if not, see <http://www.gnu.org/licenses/>.
     22 */
    323
    424#ifdef __OS2__
     
    1030#define INCL_DOSMISC
    1131#define INCL_DOSMODULEMGR
     32#define INCL_DOSDATETIME
    1233#define INCL_DOSERRORS
    1334
     
    1637#include <stdlib.h>
    1738#include <errno.h>
     39#include <time.h>
    1840#include <types.h>
    1941#include <string.h>
     
    503525}
    504526
     527/* set date/time on OS/2 */
     528int os2_setdatetime(time_t t)
     529{
     530        struct tm *tm;
     531
     532        tm = localtime(&t);
     533        if (!tm) {
     534                return -1;
     535        }
     536
     537        DATETIME   DateTime = {0};
     538        APIRET     rc       = NO_ERROR;
     539
     540        /* Get current date/time to properly fill structure */
     541        rc = DosGetDateTime(&DateTime);
     542        if (rc != NO_ERROR) {
     543                return rc;
     544        }
     545
     546        DateTime.year    = (USHORT) ((BYTE) tm->tm_year+1900);
     547        DateTime.month   = (UCHAR) ((BYTE) tm->tm_mon+1);
     548        DateTime.day     = (UCHAR) ((BYTE) tm->tm_mday);
     549        DateTime.hours   = (UCHAR) ((BYTE) tm->tm_hour);
     550        DateTime.minutes = (UCHAR) ((BYTE) tm->tm_min);
     551        DateTime.seconds = (UCHAR) ((BYTE) tm->tm_sec);
     552
     553        rc = DosSetDateTime(&DateTime);  /* Update the date and time */
     554
     555        if (rc!= NO_ERROR) {
     556                printf ("DosSetDateTime error : return code = %u\n", rc);
     557        }
     558        return rc;
     559}
     560
    505561#endif
Note: See TracChangeset for help on using the changeset viewer.