r4728: split up server_services into:
[gd/samba-autobuild/.git] / source4 / smb_server / srvtime.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    server side time handling
5
6    Copyright (C) Andrew Tridgell 2004
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24 #include "smb_server/smb_server.h"
25
26
27 /*******************************************************************
28 put a dos date into a buffer (time/date format)
29 This takes GMT time and puts local time for zone_offset in the buffer
30 ********************************************************************/
31 void srv_push_dos_date(struct smbsrv_connection *smb_server,
32                       uint8_t *buf, int offset, time_t unixdate)
33 {
34         push_dos_date(buf, offset, unixdate, smb_server->negotiate.zone_offset);
35 }
36
37 /*******************************************************************
38 put a dos date into a buffer (date/time format)
39 This takes GMT time and puts local time in the buffer
40 ********************************************************************/
41 void srv_push_dos_date2(struct smbsrv_connection *smb_server,
42                        uint8_t *buf, int offset, time_t unixdate)
43 {
44         push_dos_date2(buf, offset, unixdate, smb_server->negotiate.zone_offset);
45 }
46
47 /*******************************************************************
48 put a dos 32 bit "unix like" date into a buffer. This routine takes
49 GMT and converts it to LOCAL time in zone_offset before putting it
50 ********************************************************************/
51 void srv_push_dos_date3(struct smbsrv_connection *smb_server,
52                        uint8_t *buf, int offset, time_t unixdate)
53 {
54         push_dos_date3(buf, offset, unixdate, smb_server->negotiate.zone_offset);
55 }
56
57 /*******************************************************************
58 convert a dos date
59 ********************************************************************/
60 time_t srv_pull_dos_date(struct smbsrv_connection *smb_server, 
61                          const uint8_t *date_ptr)
62 {
63         return pull_dos_date(date_ptr, smb_server->negotiate.zone_offset);
64 }
65
66 /*******************************************************************
67 like srv_pull_dos_date() but the words are reversed
68 ********************************************************************/
69 time_t srv_pull_dos_date2(struct smbsrv_connection *smb_server, 
70                           const uint8_t *date_ptr)
71 {
72         return pull_dos_date2(date_ptr, smb_server->negotiate.zone_offset);
73 }
74
75 /*******************************************************************
76   create a unix GMT date from a dos date in 32 bit "unix like" format
77   these arrive in server zone, with corresponding DST
78   ******************************************************************/
79 time_t srv_pull_dos_date3(struct smbsrv_connection *smb_server,
80                           const uint8_t *date_ptr)
81 {
82         return pull_dos_date3(date_ptr, smb_server->negotiate.zone_offset);
83 }