r11511: A classic "friday night check-in" :-). This moves much
authorJeremy Allison <jra@samba.org>
Sat, 5 Nov 2005 04:21:55 +0000 (04:21 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:05:19 +0000 (11:05 -0500)
of the Samba4 timezone handling code back into Samba3.
Gets rid of "kludge-gmt" and removes the effectiveness
of the parameter "time offset" (I can add this back
in very easily if needed) - it's no longer being
looked at. I'm hoping this will fix the problems people
have been having with DST transitions. I'll start comprehensive
testing tomorrow, but for now all modifications are done.
Splits time get/set functions into srv_XXX and cli_XXX
as they need to look at different timezone offsets.
Get rid of much of the "efficiency" cruft that was
added to Samba back in the day when the C library
timezone handling functions were slow.
Jeremy.
(This used to be commit 414303bc0272f207046b471a0364fa296b67c1f8)

24 files changed:
source3/client/client.c
source3/client/clitar.c
source3/client/smbctool.c
source3/lib/replace.c
source3/lib/time.c
source3/libsmb/cliconnect.c
source3/libsmb/clifile.c
source3/libsmb/clilist.c
source3/libsmb/cliprint.c
source3/libsmb/clirap.c
source3/nmbd/nmbd.c
source3/nmbd/nmbd_namelistdb.c
source3/nmbd/nmbd_winsserver.c
source3/nsswitch/winbindd.c
source3/rpc_server/srv_srvsvc_nt.c
source3/smbd/dir.c
source3/smbd/lanman.c
source3/smbd/negprot.c
source3/smbd/pipes.c
source3/smbd/reply.c
source3/smbd/trans2.c
source3/utils/net_status.c
source3/utils/status.c
source3/web/statuspage.c

index e2b348699074a961c44341a337f7f4ca085509c7..f849738da0a090e120360affa973167512c362c9 100644 (file)
@@ -378,7 +378,7 @@ static void display_finfo(file_info *finfo)
                         finfo->name,
                         attrib_string(finfo->mode),
                         (double)finfo->size,
-                        asctime(LocalTime(&t)));
+                        asctime(localtime(&t)));
                dir_total += finfo->size;
        }
 }
@@ -2340,7 +2340,7 @@ static int cmd_newer(void)
        if (ok && (sys_stat(buf,&sbuf) == 0)) {
                newer_than = sbuf.st_mtime;
                DEBUG(1,("Getting files newer than %s",
-                        asctime(LocalTime(&newer_than))));
+                        asctime(localtime(&newer_than))));
        } else {
                newer_than = 0;
        }
index b241bd0ec2a281aa79dd73614bc001559323c4ed..ad3387ffdda605060e14abfe7966208d59fae36a 100644 (file)
@@ -1626,7 +1626,7 @@ int tar_parseargs(int argc, char *argv[], const char *Optarg, int Optind)
                                        if (sys_stat(argv[Optind], &stbuf) == 0) {
                                                newer_than = stbuf.st_mtime;
                                                DEBUG(1,("Getting files newer than %s",
-                                                       asctime(LocalTime(&newer_than))));
+                                                       asctime(localtime(&newer_than))));
                                                newOptind++;
                                                Optind++;
                                        } else {
index fb396be1501d3bda72bd2e7bda79614a90d1af58..db938dd809662ed1e3647d736b6ea895ac4348e7 100644 (file)
@@ -447,7 +447,7 @@ static void display_finfo(file_info *finfo)
                         finfo->name,
                         attrib_string(finfo->mode),
                         (double)finfo->size,
-                        asctime(LocalTime(&t)));
+                        asctime(localtime(&t)));
                dir_total += finfo->size;
        }
 }
@@ -460,7 +460,7 @@ static void display_stat(char *name, struct stat *st)
 {
        time_t t = st->st_mtime;
        pstring time_str;
-       pstrcpy(time_str, asctime(LocalTime(&t)));
+       pstrcpy(time_str, asctime(localtime(&t)));
        time_str[strlen(time_str)-1] = 0;
        d_printf("> %-30s", name);
        d_printf("%10.10s %8.0f  %s\n", *mode_t_string(st->st_mode), (double)st->st_size, time_str);
@@ -2542,7 +2542,7 @@ static int cmd_newer(void)
        if (ok && (sys_stat(buf,&sbuf) == 0)) {
                newer_than = sbuf.st_mtime;
                DEBUG(1,("Getting files newer than %s",
-                        asctime(LocalTime(&newer_than))));
+                        asctime(localtime(&newer_than))));
        } else {
                newer_than = 0;
        }
index b7695bd8dd04296af37ec307b67953e453687d17..57ee6ea11e631099800f054c6b3ff7e0ab1bef47 100644 (file)
@@ -453,7 +453,7 @@ char *rep_inet_ntoa(struct in_addr ip)
        tm2 = *tm;
        tm2.tm_isdst = tm3.tm_isdst;
        t = mktime(&tm2);
-       t -= TimeDiff(t);
+       t -= get_time_zone(t);
 
        return t;
 }
index 385762e82c2e2fe4d04ccb702f5b13327d90244c..2bc4d47143ac70a000889e79a6ba1bb279985aef 100644 (file)
@@ -25,7 +25,6 @@
   in May 1996 
   */
 
-
 int extra_time_offset = 0;
 
 #ifndef CHAR_BIT
@@ -92,42 +91,42 @@ static int tm_diff(struct tm *a, struct tm *b)
  Return the UTC offset in seconds west of UTC, or 0 if it cannot be determined.
 ******************************************************************/
 
-static int TimeZone(time_t t)
+int get_time_zone(time_t t)
 {
        struct tm *tm = gmtime(&t);
        struct tm tm_utc;
-       if (!tm)
+
+       if (!tm) {
                return 0;
+       }
        tm_utc = *tm;
        tm = localtime(&t);
-       if (!tm)
+       if (!tm) {
                return 0;
+       }
        return tm_diff(&tm_utc,tm);
 }
 
-static BOOL done_serverzone_init;
-
 /*******************************************************************
- Return the smb serverzone value.
+ Accessor function for the server time zone offset.
+ set_server_zone_offset() must have been called first.
 ******************************************************************/
 
-static int get_serverzone(void)
-{
-        static int serverzone;
-
-        if (!done_serverzone_init) {
-                serverzone = TimeZone(time(NULL));
-
-                if ((serverzone % 60) != 0) {
-                        DEBUG(1,("WARNING: Your timezone is not a multiple of 1 minute.\n"));
-                }
+static int server_zone_offset;
 
-                DEBUG(4,("Serverzone is %d\n",serverzone));
+int get_server_zone_offset(void)
+{
+       return server_zone_offset;
+}
 
-                done_serverzone_init = True;
-        }
+/*******************************************************************
+ Initialize the server time zone offset. Called when a client connects.
+******************************************************************/
 
-        return serverzone;
+int set_server_zone_offset(time_t t)
+{
+       server_zone_offset = get_time_zone(t);
+       return server_zone_offset;
 }
 
 /*******************************************************************
@@ -138,11 +137,14 @@ static struct timeval start_time_hires;
 
 void TimeInit(void)
 {
-       done_serverzone_init = False;
-       get_serverzone();
+       set_server_zone_offset(time(NULL));
+
+       DEBUG(4,("TimeInit: Serverzone is %d\n", server_zone_offset));
+
        /* Save the start time of this process. */
-       if (start_time_hires.tv_sec == 0 && start_time_hires.tv_usec == 0)
+       if (start_time_hires.tv_sec == 0 && start_time_hires.tv_usec == 0) {
                GetTimeOfDay(&start_time_hires);
+       }
 }
 
 /**********************************************************************
@@ -161,140 +163,21 @@ void get_process_uptime(struct timeval *ret_time)
        if (time_now_hires.tv_usec < start_time_hires.tv_usec) {
                ret_time->tv_sec -= 1;
                ret_time->tv_usec = 1000000 + (time_now_hires.tv_usec - start_time_hires.tv_usec);
-       } else
-               ret_time->tv_usec = time_now_hires.tv_usec - start_time_hires.tv_usec;
-}
-
-/*******************************************************************
- Return the same value as TimeZone, but it should be more efficient.
-
- We keep a table of DST offsets to prevent calling localtime() on each 
- call of this function. This saves a LOT of time on many unixes.
-
- Updated by Paul Eggert <eggert@twinsun.com>
-********************************************************************/
-
-static int TimeZoneFaster(time_t t)
-{
-       static struct dst_table {time_t start,end; int zone;} *tdt, *dst_table = NULL;
-       static int table_size = 0;
-       int i;
-       int zone = 0;
-
-       if (t == 0)
-               t = time(NULL);
-
-       /* Tunis has a 8 day DST region, we need to be careful ... */
-#define MAX_DST_WIDTH (365*24*60*60)
-#define MAX_DST_SKIP (7*24*60*60)
-
-       for (i=0;i<table_size;i++)
-               if (t >= dst_table[i].start && t <= dst_table[i].end)
-                       break;
-
-       if (i<table_size) {
-               zone = dst_table[i].zone;
        } else {
-               time_t low,high;
-
-               zone = TimeZone(t);
-               tdt = SMB_REALLOC_ARRAY(dst_table, struct dst_table, i+1);
-               if (!tdt) {
-                       DEBUG(0,("TimeZoneFaster: out of memory!\n"));
-                       SAFE_FREE(dst_table);
-                       table_size = 0;
-               } else {
-                       dst_table = tdt;
-                       table_size++;
-
-                       dst_table[i].zone = zone; 
-                       dst_table[i].start = dst_table[i].end = t;
-    
-                       /* no entry will cover more than 6 months */
-                       low = t - MAX_DST_WIDTH/2;
-                       if (t < low)
-                               low = TIME_T_MIN;
-      
-                       high = t + MAX_DST_WIDTH/2;
-                       if (high < t)
-                               high = TIME_T_MAX;
-      
-                       /* widen the new entry using two bisection searches */
-                       while (low+60*60 < dst_table[i].start) {
-                               if (dst_table[i].start - low > MAX_DST_SKIP*2)
-                                       t = dst_table[i].start - MAX_DST_SKIP;
-                               else
-                                       t = low + (dst_table[i].start-low)/2;
-                               if (TimeZone(t) == zone)
-                                       dst_table[i].start = t;
-                               else
-                                       low = t;
-                       }
-
-                       while (high-60*60 > dst_table[i].end) {
-                               if (high - dst_table[i].end > MAX_DST_SKIP*2)
-                                       t = dst_table[i].end + MAX_DST_SKIP;
-                               else
-                                       t = high - (high-dst_table[i].end)/2;
-                               if (TimeZone(t) == zone)
-                                       dst_table[i].end = t;
-                               else
-                                       high = t;
-                       }
-#if 0
-      DEBUG(1,("Added DST entry from %s ",
-              asctime(localtime(&dst_table[i].start))));
-      DEBUG(1,("to %s (%d)\n",asctime(localtime(&dst_table[i].end)),
-              dst_table[i].zone));
-#endif
-               }
+               ret_time->tv_usec = time_now_hires.tv_usec - start_time_hires.tv_usec;
        }
-       return zone;
 }
 
+#if 0
 /****************************************************************************
  Return the UTC offset in seconds west of UTC, adjusted for extra time offset.
 **************************************************************************/
 
 int TimeDiff(time_t t)
 {
-       return TimeZoneFaster(t) + 60*extra_time_offset;
-}
-
-/****************************************************************************
- Return the UTC offset in seconds west of UTC, adjusted for extra time
- offset, for a local time value.  If ut = lt + LocTimeDiff(lt), then
- lt = ut - TimeDiff(ut), but the converse does not necessarily hold near
- daylight savings transitions because some local times are ambiguous.
- LocTimeDiff(t) equals TimeDiff(t) except near daylight savings transitions.
-**************************************************************************/
-
-static int LocTimeDiff(time_t lte)
-{
-       time_t lt = lte - 60*extra_time_offset;
-       int d = TimeZoneFaster(lt);
-       time_t t = lt + d;
-
-       /* if overflow occurred, ignore all the adjustments so far */
-       if (((lte < lt) ^ (extra_time_offset < 0))  |  ((t < lt) ^ (d < 0)))
-               t = lte;
-
-       /* now t should be close enough to the true UTC to yield the right answer */
-       return TimeDiff(t);
-}
-
-/****************************************************************************
- Try to optimise the localtime call, it can be quite expensive on some machines.
-****************************************************************************/
-
-struct tm *LocalTime(time_t *t)
-{
-       time_t t2 = *t;
-
-       t2 -= TimeDiff(t2);
-
-       return(gmtime(&t2));
+       return get_time_zone(t);
 }
+#endif
 
 #define TIME_FIXUP_CONSTANT (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60))
 
@@ -304,10 +187,7 @@ struct tm *LocalTime(time_t *t)
 
  An 8 byte value of 0xffffffffffffffff will be returned as (time_t)0.
 
- It appears to be kludge-GMT (at least for file listings). This means
- its the GMT you get by taking a localtime and adding the
- serverzone. This is NOT the same as GMT in some cases. This routine
- converts this to real GMT.
+ Returns GMT.
 ****************************************************************************/
 
 time_t nt_time_to_unix(NTTIME *nt)
@@ -319,8 +199,9 @@ time_t nt_time_to_unix(NTTIME *nt)
        time_t l_time_min = TIME_T_MIN;
        time_t l_time_max = TIME_T_MAX;
 
-       if (nt->high == 0 || (nt->high == 0xffffffff && nt->low == 0xffffffff))
+       if (nt->high == 0 || (nt->high == 0xffffffff && nt->low == 0xffffffff)) {
                return(0);
+       }
 
        d = ((double)nt->high)*4.0*(double)(1<<30);
        d += (nt->low&0xFFF00000);
@@ -329,18 +210,15 @@ time_t nt_time_to_unix(NTTIME *nt)
        /* now adjust by 369 years to make the secs since 1970 */
        d -= TIME_FIXUP_CONSTANT;
 
-       if (d <= l_time_min)
+       if (d <= l_time_min) {
                return (l_time_min);
+       }
 
-       if (d >= l_time_max)
+       if (d >= l_time_max) {
                return (l_time_max);
+       }
 
        ret = (time_t)(d+0.5);
-
-       /* this takes us from kludge-GMT to real GMT */
-       ret -= get_serverzone();
-       ret += LocTimeDiff(ret);
-
        return(ret);
 }
 
@@ -362,11 +240,13 @@ time_t nt_time_to_unix_abs(NTTIME *nt)
        time_t l_time_min = TIME_T_MIN;
        time_t l_time_max = TIME_T_MAX;
 
-       if (nt->high == 0)
+       if (nt->high == 0) {
                return(0);
+       }
 
-       if (nt->high==0x80000000 && nt->low==0)
+       if (nt->high==0x80000000 && nt->low==0) {
                return (time_t)-1;
+       }
 
        /* reverse the time */
        /* it's a negative value, turn it to positive */
@@ -377,8 +257,9 @@ time_t nt_time_to_unix_abs(NTTIME *nt)
        d += (nt->low&0xFFF00000);
        d *= 1.0e-7;
   
-       if (!(l_time_min <= d && d <= l_time_max))
+       if (!(l_time_min <= d && d <= l_time_max)) {
                return(0);
+       }
 
        ret = (time_t)(d+0.5);
 
@@ -403,8 +284,7 @@ time_t interpret_long_date(char *p)
 }
 
 /****************************************************************************
- Put a 8 byte filetime from a time_t
- This takes real GMT as input and converts to kludge-GMT
+ Put a 8 byte filetime from a time_t. Uses GMT.
 ****************************************************************************/
 
 void unix_to_nt_time(NTTIME *nt, time_t t)
@@ -427,9 +307,6 @@ void unix_to_nt_time(NTTIME *nt, time_t t)
                return;
        }               
 
-       /* this converts GMT to kludge-GMT */
-       t -= TimeDiff(t) - get_serverzone(); 
-
        d = (double)(t);
        d += TIME_FIXUP_CONSTANT;
        d *= 1.0e7;
@@ -485,7 +362,7 @@ void unix_to_nt_time_abs(NTTIME *nt, time_t t)
  pointed to by p.
 ****************************************************************************/
 
-void put_long_date(char *p,time_t t)
+void put_long_date(char *p, time_t t)
 {
        NTTIME nt;
        unix_to_nt_time(&nt, t);
@@ -533,14 +410,20 @@ static uint16 make_dos_time1(struct tm *t)
  This takes a GMT time and returns a packed localtime structure.
 ********************************************************************/
 
-static uint32 make_dos_date(time_t unixdate)
+static uint32 make_dos_date(time_t unixdate, int zone_offset)
 {
        struct tm *t;
        uint32 ret=0;
 
-       t = LocalTime(&unixdate);
-       if (!t)
+       if (unixdate == 0) {
+               return 0;
+       }
+
+       unixdate -= zone_offset;
+       t = gmtime(&unixdate);
+       if (!t) {
                return 0xFFFFFFFF;
+       }
 
        ret = make_dos_date1(t);
        ret = ((ret&0xFFFF)<<16) | make_dos_time1(t);
@@ -553,9 +436,9 @@ static uint32 make_dos_date(time_t unixdate)
  This takes GMT time and puts local time in the buffer.
 ********************************************************************/
 
-void put_dos_date(char *buf,int offset,time_t unixdate)
+static void put_dos_date(char *buf,int offset,time_t unixdate, int zone_offset)
 {
-       uint32 x = make_dos_date(unixdate);
+       uint32 x = make_dos_date(unixdate, zone_offset);
        SIVAL(buf,offset,x);
 }
 
@@ -564,9 +447,9 @@ void put_dos_date(char *buf,int offset,time_t unixdate)
  This takes GMT time and puts local time in the buffer.
 ********************************************************************/
 
-void put_dos_date2(char *buf,int offset,time_t unixdate)
+static void put_dos_date2(char *buf,int offset,time_t unixdate, int zone_offset)
 {
-       uint32 x = make_dos_date(unixdate);
+       uint32 x = make_dos_date(unixdate, zone_offset);
        x = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
        SIVAL(buf,offset,x);
 }
@@ -577,10 +460,11 @@ void put_dos_date2(char *buf,int offset,time_t unixdate)
  localtime for this sort of date)
 ********************************************************************/
 
-void put_dos_date3(char *buf,int offset,time_t unixdate)
+static void put_dos_date3(char *buf,int offset,time_t unixdate, int zone_offset)
 {
-       if (!null_mtime(unixdate))
-               unixdate -= TimeDiff(unixdate);
+       if (!null_mtime(unixdate)) {
+               unixdate -= zone_offset;
+       }
        SIVAL(buf,offset,unixdate);
 }
 
@@ -608,7 +492,7 @@ static void interpret_dos_date(uint32 date,int *year,int *month,int *day,int *ho
  localtime).
 ********************************************************************/
 
-time_t make_unix_date(void *date_ptr)
+static time_t make_unix_date(void *date_ptr, int zone_offset)
 {
        uint32 dos_date=0;
        struct tm t;
@@ -616,15 +500,17 @@ time_t make_unix_date(void *date_ptr)
 
        dos_date = IVAL(date_ptr,0);
 
-       if (dos_date == 0)
-               return(0);
+       if (dos_date == 0) {
+               return 0;
+       }
   
        interpret_dos_date(dos_date,&t.tm_year,&t.tm_mon,
                        &t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec);
        t.tm_isdst = -1;
   
-       /* mktime() also does the local to GMT time conversion for us */
-       ret = mktime(&t);
+       ret = timegm(&t);
+
+       ret += zone_offset;
 
        return(ret);
 }
@@ -633,7 +519,7 @@ time_t make_unix_date(void *date_ptr)
  Like make_unix_date() but the words are reversed.
 ********************************************************************/
 
-time_t make_unix_date2(void *date_ptr)
+static time_t make_unix_date2(void *date_ptr, int zone_offset)
 {
        uint32 x,x2;
 
@@ -641,7 +527,7 @@ time_t make_unix_date2(void *date_ptr)
        x2 = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
        SIVAL(&x,0,x2);
 
-       return(make_unix_date((void *)&x));
+       return(make_unix_date((void *)&x, zone_offset));
 }
 
 /*******************************************************************
@@ -649,14 +535,83 @@ time_t make_unix_date2(void *date_ptr)
  these generally arrive as localtimes, with corresponding DST.
 ******************************************************************/
 
-time_t make_unix_date3(void *date_ptr)
+static time_t make_unix_date3(void *date_ptr, int zone_offset)
 {
        time_t t = (time_t)IVAL(date_ptr,0);
-       if (!null_mtime(t))
-               t += LocTimeDiff(t);
+       if (!null_mtime(t)) {
+               t += zone_offset;
+       }
        return(t);
 }
 
+/***************************************************************************
+ Server versions of the above functions.
+***************************************************************************/
+
+void srv_put_dos_date(char *buf,int offset,time_t unixdate)
+{
+       put_dos_date(buf, offset, unixdate, server_zone_offset);
+}
+
+void srv_put_dos_date2(char *buf,int offset, time_t unixdate)
+{
+       put_dos_date2(buf, offset, unixdate, server_zone_offset);
+}
+
+void srv_put_dos_date3(char *buf,int offset,time_t unixdate)
+{
+       put_dos_date3(buf, offset, unixdate, server_zone_offset);
+}
+
+time_t srv_make_unix_date(void *date_ptr)
+{
+       return make_unix_date(date_ptr, server_zone_offset);
+}
+
+time_t srv_make_unix_date2(void *date_ptr)
+{
+       return make_unix_date2(date_ptr, server_zone_offset);
+}
+
+time_t srv_make_unix_date3(void *date_ptr)
+{
+       return make_unix_date3(date_ptr, server_zone_offset);
+}
+
+/***************************************************************************
+ Client versions of the above functions.
+***************************************************************************/
+
+void cli_put_dos_date(struct cli_state *cli, char *buf, int offset, time_t unixdate)
+{
+       put_dos_date(buf, offset, unixdate, cli->serverzone);
+}
+
+void cli_put_dos_date2(struct cli_state *cli, char *buf, int offset, time_t unixdate)
+{
+       put_dos_date2(buf, offset, unixdate, cli->serverzone);
+}
+
+void cli_put_dos_date3(struct cli_state *cli, char *buf, int offset, time_t unixdate)
+{
+       put_dos_date3(buf, offset, unixdate, cli->serverzone);
+}
+
+time_t cli_make_unix_date(struct cli_state *cli, void *date_ptr)
+{
+       return make_unix_date(date_ptr, cli->serverzone);
+}
+
+time_t cli_make_unix_date2(struct cli_state *cli, void *date_ptr)
+{
+       return make_unix_date2(date_ptr, cli->serverzone);
+}
+
+time_t cli_make_unix_date3(struct cli_state *cli, void *date_ptr)
+{
+       return make_unix_date3(date_ptr, cli->serverzone);
+}
+
 /***************************************************************************
  Return a HTTP/1.0 time string.
 ***************************************************************************/
@@ -664,7 +619,7 @@ time_t make_unix_date3(void *date_ptr)
 char *http_timestring(time_t t)
 {
        static fstring buf;
-       struct tm *tm = LocalTime(&t);
+       struct tm *tm = localtime(&t);
 
        if (!tm)
                slprintf(buf,sizeof(buf)-1,"%ld seconds since the Epoch",(long)t);
@@ -696,7 +651,7 @@ char *timestring(BOOL hires)
        } else {
                t = time(NULL);
        }
-       tm = LocalTime(&t);
+       tm = localtime(&t);
        if (!tm) {
                if (hires) {
                        slprintf(TimeBuf,
@@ -745,14 +700,16 @@ time_t get_create_time(SMB_STRUCT_STAT *st,BOOL fake_dirs)
 {
        time_t ret, ret1;
 
-       if(S_ISDIR(st->st_mode) && fake_dirs)
+       if(S_ISDIR(st->st_mode) && fake_dirs) {
                return (time_t)315493200L;          /* 1/1/1980 */
+       }
     
        ret = MIN(st->st_ctime, st->st_mtime);
        ret1 = MIN(ret, st->st_atime);
 
-       if(ret1 != (time_t)0)
+       if(ret1 != (time_t)0) {
                return ret1;
+       }
 
        /*
         * One of ctime, mtime or atime was zero (probably atime).
@@ -777,8 +734,9 @@ void init_nt_time(NTTIME *nt)
 
 BOOL nt_time_is_zero(NTTIME *nt)
 {
-       if(nt->high==0) 
+       if(nt->high==0) {
                return True;
+       }
        return False;
 }
 
@@ -801,9 +759,10 @@ SMB_BIG_INT usec_time_diff(const struct timeval *larget, const struct timeval *s
        return (sec_diff * 1000000) + (SMB_BIG_INT)(larget->tv_usec - smallt->tv_usec);
 }
 
-/*
-  return a timeval struct with the given elements
-*/
+/****************************************************************************
+ Return a timeval struct with the given elements.
+****************************************************************************/
+
 struct timeval timeval_set(uint32_t secs, uint32_t usecs)
 {
        struct timeval tv;
@@ -812,25 +771,28 @@ struct timeval timeval_set(uint32_t secs, uint32_t usecs)
        return tv;
 }
 
-/*
-  return a zero timeval
-*/
+/****************************************************************************
+ Return a zero timeval.
+****************************************************************************/
+
 struct timeval timeval_zero(void)
 {
        return timeval_set(0,0);
 }
 
-/*
-  return True if a timeval is zero
-*/
+/****************************************************************************
+ Return True if a timeval is zero.
+****************************************************************************/
+
 BOOL timeval_is_zero(const struct timeval *tv)
 {
        return tv->tv_sec == 0 && tv->tv_usec == 0;
 }
 
-/*
-  return a timeval for the current time
-*/
+/****************************************************************************
+ Return a timeval for the current time.
+****************************************************************************/
+
 struct timeval timeval_current(void)
 {
        struct timeval tv;
@@ -838,9 +800,10 @@ struct timeval timeval_current(void)
        return tv;
 }
 
-/*
-  return a timeval ofs microseconds after tv
-*/
+/****************************************************************************
+ Return a timeval ofs microseconds after tv.
+****************************************************************************/
+
 struct timeval timeval_add(const struct timeval *tv,
                           uint32_t secs, uint32_t usecs)
 {
@@ -852,44 +815,56 @@ struct timeval timeval_add(const struct timeval *tv,
        return tv2;
 }
 
-/*
-  return the sum of two timeval structures
-*/
+/****************************************************************************
+ Return the sum of two timeval structures.
+****************************************************************************/
+
 struct timeval timeval_sum(const struct timeval *tv1,
                           const struct timeval *tv2)
 {
        return timeval_add(tv1, tv2->tv_sec, tv2->tv_usec);
 }
 
-/*
-  return a timeval secs/usecs into the future
-*/
+/****************************************************************************
+ Return a timeval secs/usecs into the future.
+****************************************************************************/
+
 struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs)
 {
        struct timeval tv = timeval_current();
        return timeval_add(&tv, secs, usecs);
 }
 
-/*
-  compare two timeval structures. 
-  Return -1 if tv1 < tv2
-  Return 0 if tv1 == tv2
-  Return 1 if tv1 > tv2
-*/
+/****************************************************************************
+ Compare two timeval structures. 
+ Return -1 if tv1 < tv2
+ Return 0 if tv1 == tv2
+ Return 1 if tv1 > tv2
+****************************************************************************/
+
 int timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
 {
-       if (tv1->tv_sec  > tv2->tv_sec)  return 1;
-       if (tv1->tv_sec  < tv2->tv_sec)  return -1;
-       if (tv1->tv_usec > tv2->tv_usec) return 1;
-       if (tv1->tv_usec < tv2->tv_usec) return -1;
+       if (tv1->tv_sec  > tv2->tv_sec) {
+               return 1;
+       }
+       if (tv1->tv_sec  < tv2->tv_sec) {
+               return -1;
+       }
+       if (tv1->tv_usec > tv2->tv_usec) {
+               return 1;
+       }
+       if (tv1->tv_usec < tv2->tv_usec) {
+               return -1;
+       }
        return 0;
 }
 
-/*
-  return the difference between two timevals as a timeval
-  if tv1 comes after tv2, then return a zero timeval
-  (this is *tv2 - *tv1)
-*/
+/****************************************************************************
+ Return the difference between two timevals as a timeval.
+ If tv1 comes after tv2, then return a zero timeval
+ (this is *tv2 - *tv1).
+****************************************************************************/
+
 struct timeval timeval_until(const struct timeval *tv1,
                             const struct timeval *tv2)
 {
@@ -907,34 +882,49 @@ struct timeval timeval_until(const struct timeval *tv1,
        return t;
 }
 
-/*
-  return the lesser of two timevals
-*/
+/****************************************************************************
+ Return the lesser of two timevals.
+****************************************************************************/
+
 struct timeval timeval_min(const struct timeval *tv1,
                           const struct timeval *tv2)
 {
-       if (tv1->tv_sec < tv2->tv_sec) return *tv1;
-       if (tv1->tv_sec > tv2->tv_sec) return *tv2;
-       if (tv1->tv_usec < tv2->tv_usec) return *tv1;
+       if (tv1->tv_sec < tv2->tv_sec) {
+               return *tv1;
+       }
+       if (tv1->tv_sec > tv2->tv_sec) {
+               return *tv2;
+       }
+       if (tv1->tv_usec < tv2->tv_usec) {
+               return *tv1;
+       }
        return *tv2;
 }
 
-/*
-  return the greater of two timevals
-*/
+/****************************************************************************
+ Return the greater of two timevals.
+****************************************************************************/
+
 struct timeval timeval_max(const struct timeval *tv1,
                           const struct timeval *tv2)
 {
-       if (tv1->tv_sec > tv2->tv_sec) return *tv1;
-       if (tv1->tv_sec < tv2->tv_sec) return *tv2;
-       if (tv1->tv_usec > tv2->tv_usec) return *tv1;
+       if (tv1->tv_sec > tv2->tv_sec) {
+               return *tv1;
+       }
+       if (tv1->tv_sec < tv2->tv_sec) {
+               return *tv2;
+       }
+       if (tv1->tv_usec > tv2->tv_usec) {
+               return *tv1;
+       }
        return *tv2;
 }
 
 /****************************************************************************
- convert ASN.1 GeneralizedTime string to unix-time
returns 0 on failure; Currently ignores timezone. 
+ Convert ASN.1 GeneralizedTime string to unix-time.
Returns 0 on failure; Currently ignores timezone. 
 ****************************************************************************/
+
 time_t generalized_to_unix_time(const char *str)
 { 
        struct tm tm;
index 8118f073dfa24d1ef8bbce01d2ccb73e6b962e83..b352d3572a7d490e03e81a4a7ac98fee82acd284 100644 (file)
@@ -1170,7 +1170,7 @@ BOOL cli_negprot(struct cli_state *cli)
                cli->serverzone = SVALS(cli->inbuf,smb_vwv10);
                cli->serverzone *= 60;
                /* this time is converted to GMT by make_unix_date */
-               cli->servertime = make_unix_date(cli->inbuf+smb_vwv8);
+               cli->servertime = cli_make_unix_date(cli,cli->inbuf+smb_vwv8);
                cli->readbraw_supported = ((SVAL(cli->inbuf,smb_vwv5) & 0x1) != 0);
                cli->writebraw_supported = ((SVAL(cli->inbuf,smb_vwv5) & 0x2) != 0);
                cli->secblob = data_blob(smb_buf(cli->inbuf),smb_buflen(cli->inbuf));
@@ -1178,7 +1178,7 @@ BOOL cli_negprot(struct cli_state *cli)
                /* the old core protocol */
                cli->use_spnego = False;
                cli->sec_mode = 0;
-               cli->serverzone = TimeDiff(time(NULL));
+               cli->serverzone = get_time_zone(time(NULL));
        }
 
        cli->max_xmit = MIN(cli->max_xmit, CLI_BUFFER_SIZE);
index ff42e6414376a9aab443c877004d048cd058f5ea..443f51566534177c52bb8f9391054d525f2df351 100644 (file)
@@ -1106,15 +1106,15 @@ BOOL cli_getattrE(struct cli_state *cli, int fd,
        }
 
        if (c_time) {
-               *c_time = make_unix_date2(cli->inbuf+smb_vwv0);
+               *c_time = cli_make_unix_date2(cli, cli->inbuf+smb_vwv0);
        }
 
        if (a_time) {
-               *a_time = make_unix_date2(cli->inbuf+smb_vwv2);
+               *a_time = cli_make_unix_date2(cli, cli->inbuf+smb_vwv2);
        }
 
        if (m_time) {
-               *m_time = make_unix_date2(cli->inbuf+smb_vwv4);
+               *m_time = cli_make_unix_date2(cli, cli->inbuf+smb_vwv4);
        }
 
        return True;
@@ -1158,7 +1158,7 @@ BOOL cli_getatr(struct cli_state *cli, const char *fname,
        }
 
        if (t) {
-               *t = make_unix_date3(cli->inbuf+smb_vwv1);
+               *t = cli_make_unix_date3(cli, cli->inbuf+smb_vwv1);
        }
 
        if (attr) {
@@ -1189,9 +1189,9 @@ BOOL cli_setattrE(struct cli_state *cli, int fd,
        cli_setup_packet(cli);
 
        SSVAL(cli->outbuf,smb_vwv0, fd);
-       put_dos_date2(cli->outbuf,smb_vwv1, c_time);
-       put_dos_date2(cli->outbuf,smb_vwv3, a_time);
-       put_dos_date2(cli->outbuf,smb_vwv5, m_time);
+       cli_put_dos_date2(cli, cli->outbuf,smb_vwv1, c_time);
+       cli_put_dos_date2(cli, cli->outbuf,smb_vwv3, a_time);
+       cli_put_dos_date2(cli, cli->outbuf,smb_vwv5, m_time);
 
        p = smb_buf(cli->outbuf);
        *p++ = 4;
@@ -1228,7 +1228,7 @@ BOOL cli_setatr(struct cli_state *cli, const char *fname, uint16 attr, time_t t)
        cli_setup_packet(cli);
 
        SSVAL(cli->outbuf,smb_vwv0, attr);
-       put_dos_date3(cli->outbuf,smb_vwv1, t);
+       cli_put_dos_date3(cli, cli->outbuf,smb_vwv1, t);
 
        p = smb_buf(cli->outbuf);
        *p++ = 4;
index a0be40bdc9f5128241a0ef2e59ed3c22120d433b..e09a6514ad9f6dfc7ed8315bbc26f006c6120567 100644 (file)
@@ -49,9 +49,9 @@ static size_t interpret_long_filename(struct cli_state *cli, int level,char *p,f
                case 1: /* OS/2 understands this */
                        /* these dates are converted to GMT by
                            make_unix_date */
-                       finfo->ctime = make_unix_date2(p+4);
-                       finfo->atime = make_unix_date2(p+8);
-                       finfo->mtime = make_unix_date2(p+12);
+                       finfo->ctime = cli_make_unix_date2(cli, p+4);
+                       finfo->atime = cli_make_unix_date2(cli, p+8);
+                       finfo->mtime = cli_make_unix_date2(cli, p+12);
                        finfo->size = IVAL(p,16);
                        finfo->mode = CVAL(p,24);
                        len = CVAL(p, 26);
@@ -70,9 +70,9 @@ static size_t interpret_long_filename(struct cli_state *cli, int level,char *p,f
                case 2: /* this is what OS/2 uses mostly */
                        /* these dates are converted to GMT by
                            make_unix_date */
-                       finfo->ctime = make_unix_date2(p+4);
-                       finfo->atime = make_unix_date2(p+8);
-                       finfo->mtime = make_unix_date2(p+12);
+                       finfo->ctime = cli_make_unix_date2(cli, p+4);
+                       finfo->atime = cli_make_unix_date2(cli, p+8);
+                       finfo->mtime = cli_make_unix_date2(cli, p+12);
                        finfo->size = IVAL(p,16);
                        finfo->mode = CVAL(p,24);
                        len = CVAL(p, 30);
@@ -380,7 +380,7 @@ static int interpret_short_filename(struct cli_state *cli, char *p,file_info *fi
        finfo->mode = CVAL(p,21);
        
        /* this date is converted to GMT by make_unix_date */
-       finfo->ctime = make_unix_date(p+22);
+       finfo->ctime = cli_make_unix_date(cli, p+22);
        finfo->mtime = finfo->atime = finfo->ctime;
        finfo->size = IVAL(p,26);
        clistr_pull(cli, finfo->name, p+30, sizeof(finfo->name), 12, STR_ASCII);
index 4a5ee5ae08c3bac158c127e0f1473450fc20bcf3..5798e945541fe8ebb40db26b4a97344b606ddfc2 100644 (file)
@@ -97,7 +97,7 @@ int cli_print_queue(struct cli_state *cli,
                                fstrcpy(job.user,
                                        fix_char_ptr(SVAL(p,4), converter, 
                                                     rdata, rdrcnt));
-                               job.t = make_unix_date3(p + 12);
+                               job.t = cli_make_unix_date3(cli, p + 12);
                                job.size = IVAL(p,16);
                                fstrcpy(job.name,fix_char_ptr(SVAL(p,24), 
                                                              converter, 
index 34f73cfafee21074d4ad298689941aad4290ac18..172dea4090ab62d1f7a9df8aa6c8eb2a54cfa7d1 100644 (file)
@@ -390,7 +390,7 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname,
        char *rparam=NULL, *rdata=NULL;
        int count=8;
        BOOL ret;
-       time_t (*date_fn)(void *);
+       time_t (*date_fn)(struct cli_state *, void *);
        char *p;
 
        p = param;
@@ -429,19 +429,19 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname,
        }
 
        if (cli->win95) {
-               date_fn = make_unix_date;
+               date_fn = cli_make_unix_date;
        } else {
-               date_fn = make_unix_date2;
+               date_fn = cli_make_unix_date2;
        }
 
        if (c_time) {
-               *c_time = date_fn(rdata+0);
+               *c_time = date_fn(cli, rdata+0);
        }
        if (a_time) {
-               *a_time = date_fn(rdata+4);
+               *a_time = date_fn(cli, rdata+4);
        }
        if (m_time) {
-               *m_time = date_fn(rdata+8);
+               *m_time = date_fn(cli, rdata+8);
        }
        if (size) {
                *size = IVAL(rdata, 12);
@@ -471,7 +471,7 @@ BOOL cli_setpathinfo(struct cli_state *cli, const char *fname,
        char *rparam=NULL, *rdata=NULL;
        int count=8;
        BOOL ret;
-        void (*date_fn)(char *buf,int offset,time_t unixdate);
+        void (*date_fn)(struct cli_state *, char *buf,int offset,time_t unixdate);
        char *p;
 
        memset(param, 0, sizeof(param));
@@ -493,15 +493,15 @@ BOOL cli_setpathinfo(struct cli_state *cli, const char *fname,
         p = data;
 
        if (cli->win95) {
-               date_fn = put_dos_date;
+               date_fn = cli_put_dos_date;
        } else {
-               date_fn = put_dos_date2;
+               date_fn = cli_put_dos_date2;
        }
 
         /* Add the create, last access, and modification times */
-        (*date_fn)(p, 0, c_time);
-        (*date_fn)(p, 4, a_time);
-        (*date_fn)(p, 8, m_time);
+        (*date_fn)(cli, p, 0, c_time);
+        (*date_fn)(cli, p, 4, a_time);
+        (*date_fn)(cli, p, 8, m_time);
         p += 12;
 
         /* Skip DataSize and AllocationSize */
index 086878e221a1a818bec9a28c73260275713a4f09..282857ef98319b2b9e7281cdac9aebb1a50c3aa2 100644 (file)
@@ -776,6 +776,8 @@ static BOOL open_sockets(BOOL isdaemon, int port)
        message_register(MSG_SMB_CONF_UPDATED, msg_reload_nmbd_services);
        message_register(MSG_SEND_PACKET, msg_nmbd_send_packet);
 
+       TimeInit();
+
        DEBUG( 3, ( "Opening sockets %d\n", global_nmb_port ) );
 
        if ( !open_sockets( is_daemon, global_nmb_port ) ) {
index bdb308a2ea02c8f6c6bfa148387c4f9867d094d0..344d3c7ca195df6b71ee6c4b95f8cdfc08d0f819 100644 (file)
@@ -530,14 +530,14 @@ static void dump_subnet_namelist( struct subnet_record *subrec, XFILE *fp)
                x_fprintf(fp,"Source = %s\nb_flags = %x\t", src_type, namerec->data.nb_flags);
 
                if(namerec->data.death_time != PERMANENT_TTL) {
-                       tm = LocalTime(&namerec->data.death_time);
+                       tm = localtime(&namerec->data.death_time);
                        x_fprintf(fp, "death_time = %s\t", asctime(tm));
                } else {
                        x_fprintf(fp, "death_time = PERMANENT\t");
                }
 
                if(namerec->data.refresh_time != PERMANENT_TTL) {
-                       tm = LocalTime(&namerec->data.refresh_time);
+                       tm = localtime(&namerec->data.refresh_time);
                        x_fprintf(fp, "refresh_time = %s\n", asctime(tm));
                } else {
                        x_fprintf(fp, "refresh_time = PERMANENT\n");
index d76cb8f03226c30db9412c8feb95c915678fa418..8a1f82c8b17c68794007ce0eba9cbeb63b7f1921 100644 (file)
@@ -1835,7 +1835,7 @@ void wins_write_database(BOOL background)
                if( namerec->data.death_time != PERMANENT_TTL ) {
                        char *ts, *nl;
 
-                       tm = LocalTime(&namerec->data.death_time);
+                       tm = localtime(&namerec->data.death_time);
                        ts = asctime(tm);
                        nl = strrchr( ts, '\n' );
                        if( NULL != nl )
index a62fd32b20df6ce1654751111da2a934ddc695db..7f2f3d780e14829516bab67c43752d0cd41aca13 100644 (file)
@@ -1047,6 +1047,8 @@ int main(int argc, char **argv)
                setpgid( (pid_t)0, (pid_t)0);
 #endif
 
+       TimeInit();
+
        /* Initialise messaging system */
 
        if (!message_init()) {
index 1022cb960d356df4797e742c63461477fa062135..a7162c929db8e2f1da49b2659ce54f2efba79178 100644 (file)
@@ -1,5 +1,5 @@
-/* 
- *  Unix SMB/CIFS implementation.
+ /* 
 *  Unix SMB/CIFS implementation.
  *  RPC Pipe client / server routines
  *  Copyright (C) Andrew Tridgell              1992-1997,
  *  Copyright (C) Jeremy Allison                                       2001.
@@ -1947,7 +1947,7 @@ WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET
                              t->tm_min,
                              t->tm_sec,
                              0,
-                             TimeDiff(unixdate)/60,
+                             get_time_zone(unixdate)/60,
                              10000,
                              t->tm_mday,
                              t->tm_mon + 1,
index 7ea97e69b01059d43b364dc14fd2672e103db618..c993012a2548891435e678e1d7ffb4beb9e8fc25 100644 (file)
@@ -94,7 +94,7 @@ void make_dir_struct(char *buf, const char *mask, const char *fname,SMB_OFF_T si
 
        memset(buf+21,'\0',DIR_STRUCT_SIZE-21);
        SCVAL(buf,21,mode);
-       put_dos_date(buf,22,date);
+       srv_put_dos_date(buf,22,date);
        SSVAL(buf,26,size & 0xFFFF);
        SSVAL(buf,28,(size >> 16)&0xFFFF);
        /* We only uppercase if FLAGS2_LONG_PATH_COMPONENTS is zero in the input buf.
index 3e1174b22fd5dbdbc29e92d1b3f3b2b618e092c0..1e2a2488515f72f45f163a522a6d24bab8035788 100644 (file)
@@ -50,23 +50,25 @@ extern userdom_struct current_user_info;
 
 #define SHPWLEN 8              /* share password length */
 
-static BOOL api_Unsupported(connection_struct *conn,uint16 vuid, char *param,char *data,
-                           int mdrcnt,int mprcnt,
-                           char **rdata,char **rparam,
-                           int *rdata_len,int *rparam_len);
-static BOOL api_TooSmall(connection_struct *conn,uint16 vuid, char *param,char *data,
-                        int mdrcnt,int mprcnt,
-                        char **rdata,char **rparam,
-                        int *rdata_len,int *rparam_len);
+static BOOL api_Unsupported(connection_struct *conn,uint16 vuid, char *param, char *data,
+                           int mdrcnt, int mprcnt,
+                           char **rdata, char **rparam,
+                           int *rdata_len, int *rparam_len);
+static BOOL api_TooSmall(connection_struct *conn, uint16 vuid, char *param, char *data,
+                        int mdrcnt, int mprcnt,
+                        char **rdata, char **rparam,
+                        int *rdata_len, int *rparam_len);
 
 
 static int CopyExpanded(connection_struct *conn, 
-                       int snum, char** dst, char* src, int* n)
+                       int snum, char **dst, char *src, int *n)
 {
        pstring buf;
        int l;
 
-       if (!src || !dst || !n || !(*dst)) return(0);
+       if (!src || !dst || !n || !(*dst)) {
+               return 0;
+       }
 
        StrnCpy(buf,src,sizeof(buf)/2);
        pstring_sub(buf,"%S",lp_servicename(snum));
@@ -77,30 +79,36 @@ static int CopyExpanded(connection_struct *conn,
        return l;
 }
 
-static int CopyAndAdvance(char** dst, char* src, int* n)
+static int CopyAndAdvance(char **dst, char *src, int *n)
 {
-  int l;
-  if (!src || !dst || !n || !(*dst)) return(0);
-  l = push_ascii(*dst,src,*n, STR_TERMINATE);
-  (*dst) += l;
-  (*n) -= l;
-  return l;
+       int l;
+       if (!src || !dst || !n || !(*dst)) {
+               return 0;
+       }
+       l = push_ascii(*dst,src,*n, STR_TERMINATE);
+       (*dst) += l;
+       (*n) -= l;
+       return l;
 }
 
-static int StrlenExpanded(connection_struct *conn, int snum, chars)
+static int StrlenExpanded(connection_struct *conn, int snum, char *s)
 {
        pstring buf;
-       if (!s) return(0);
+       if (!s) {
+               return 0;
+       }
        StrnCpy(buf,s,sizeof(buf)/2);
        pstring_sub(buf,"%S",lp_servicename(snum));
        standard_sub_conn(conn,buf,sizeof(buf));
        return strlen(buf) + 1;
 }
 
-static char* Expand(connection_struct *conn, int snum, char* s)
+static char *Expand(connection_struct *conn, int snum, char *s)
 {
        static pstring buf;
-       if (!s) return(NULL);
+       if (!s) {
+               return NULL;
+       }
        StrnCpy(buf,s,sizeof(buf)/2);
        pstring_sub(buf,"%S",lp_servicename(snum));
        standard_sub_conn(conn,buf,sizeof(buf));
@@ -108,218 +116,248 @@ static char* Expand(connection_struct *conn, int snum, char* s)
 }
 
 /*******************************************************************
-  check a API string for validity when we only need to check the prefix
-  ******************************************************************/
+ Check a API string for validity when we only need to check the prefix.
+******************************************************************/
+
 static BOOL prefix_ok(const char *str, const char *prefix)
 {
-  return(strncmp(str,prefix,strlen(prefix)) == 0);
+       return(strncmp(str,prefix,strlen(prefix)) == 0);
 }
 
 struct pack_desc {
-  const char* format;      /* formatstring for structure */
-  const char* subformat;  /* subformat for structure */
-  char* base;      /* baseaddress of buffer */
-  int buflen;     /* remaining size for fixed part; on init: length of base */
-  int subcount;            /* count of substructures */
-  char* structbuf;  /* pointer into buffer for remaining fixed part */
-  int stringlen;    /* remaining size for variable part */             
-  char* stringbuf;  /* pointer into buffer for remaining variable part */
-  int neededlen;    /* total needed size */
-  int usedlen;     /* total used size (usedlen <= neededlen and usedlen <= buflen) */
-  const char* curpos;      /* current position; pointer into format or subformat */
-  int errcode;
+       const char *format;         /* formatstring for structure */
+       const char *subformat;  /* subformat for structure */
+       char *base;         /* baseaddress of buffer */
+       int buflen;        /* remaining size for fixed part; on init: length of base */
+       int subcount;       /* count of substructures */
+       char *structbuf;  /* pointer into buffer for remaining fixed part */
+       int stringlen;    /* remaining size for variable part */                
+       char *stringbuf;  /* pointer into buffer for remaining variable part */
+       int neededlen;    /* total needed size */
+       int usedlen;        /* total used size (usedlen <= neededlen and usedlen <= buflen) */
+       const char *curpos;         /* current position; pointer into format or subformat */
+       int errcode;
 };
 
-static int get_counter(const char** p)
+static int get_counter(const char **p)
 {
-  int i, n;
-  if (!p || !(*p)) return(1);
-  if (!isdigit((int)**p)) return 1;
-  for (n = 0;;) {
-    i = **p;
-    if (isdigit(i))
-      n = 10 * n + (i - '0');
-    else
-      return n;
-    (*p)++;
-  }
+       int i, n;
+       if (!p || !(*p)) {
+               return 1;
+       }
+       if (!isdigit((int)**p)) {
+               return 1;
+       }
+       for (n = 0;;) {
+               i = **p;
+               if (isdigit(i)) {
+                       n = 10 * n + (i - '0');
+               } else {
+                       return n;
+               }
+               (*p)++;
+       }
 }
 
-static int getlen(const charp)
+static int getlen(const char *p)
 {
-  int n = 0;
-  if (!p) return(0);
-  while (*p) {
-    switch( *p++ ) {
-    case 'W':                  /* word (2 byte) */
-      n += 2;
-      break;
-    case 'K':                  /* status word? (2 byte) */
-      n += 2;
-      break;
-    case 'N':                  /* count of substructures (word) at end */
-      n += 2;
-      break;
-    case 'D':                  /* double word (4 byte) */
-    case 'z':                  /* offset to zero terminated string (4 byte) */
-    case 'l':                  /* offset to user data (4 byte) */
-      n += 4;
-      break;
-    case 'b':                  /* offset to data (with counter) (4 byte) */
-      n += 4;
-      get_counter(&p);
-      break;
-    case 'B':                  /* byte (with optional counter) */
-      n += get_counter(&p);
-      break;
-    }
-  }
-  return n;
+       int n = 0;
+       if (!p) {
+               return 0;
+       }
+
+       while (*p) {
+               switch( *p++ ) {
+               case 'W':                       /* word (2 byte) */
+                       n += 2;
+                       break;
+               case 'K':                       /* status word? (2 byte) */
+                       n += 2;
+                       break;
+               case 'N':                       /* count of substructures (word) at end */
+                       n += 2;
+                       break;
+               case 'D':                       /* double word (4 byte) */
+               case 'z':                       /* offset to zero terminated string (4 byte) */
+               case 'l':                       /* offset to user data (4 byte) */
+                       n += 4;
+                       break;
+               case 'b':                       /* offset to data (with counter) (4 byte) */
+                       n += 4;
+                       get_counter(&p);
+                       break;
+               case 'B':                       /* byte (with optional counter) */
+                       n += get_counter(&p);
+                       break;
+               }
+       }
+       return n;
 }
 
-static BOOL init_package(struct pack_descp, int count, int subcount)
+static BOOL init_package(struct pack_desc *p, int count, int subcount)
 {
-  int n = p->buflen;
-  int i;
+       int n = p->buflen;
+       int i;
+
+       if (!p->format || !p->base) {
+               return False;
+       }
 
-  if (!p->format || !p->base) return(False);
-
-  i = count * getlen(p->format);
-  if (p->subformat) i += subcount * getlen(p->subformat);
-  p->structbuf = p->base;
-  p->neededlen = 0;
-  p->usedlen = 0;
-  p->subcount = 0;
-  p->curpos = p->format;
-  if (i > n) {
-    p->neededlen = i;
-    i = n = 0;
+       i = count * getlen(p->format);
+       if (p->subformat) {
+               i += subcount * getlen(p->subformat);
+       }
+       p->structbuf = p->base;
+       p->neededlen = 0;
+       p->usedlen = 0;
+       p->subcount = 0;
+       p->curpos = p->format;
+       if (i > n) {
+               p->neededlen = i;
+               i = n = 0;
 #if 0
-    /*
-     * This is the old error code we used. Aparently
-     * WinNT/2k systems return ERRbuftoosmall (2123) and
-     * OS/2 needs this. I'm leaving this here so we can revert
-     * if needed. JRA.
-     */
-    p->errcode = ERRmoredata;
+               /*
+                * This is the old error code we used. Aparently
+                * WinNT/2k systems return ERRbuftoosmall (2123) and
+                * OS/2 needs this. I'm leaving this here so we can revert
+                * if needed. JRA.
+                */
+               p->errcode = ERRmoredata;
 #else
-       p->errcode = ERRbuftoosmall;
+               p->errcode = ERRbuftoosmall;
 #endif
-  }
-  else
-    p->errcode = NERR_Success;
-  p->buflen = i;
-  n -= i;
-  p->stringbuf = p->base + i;
-  p->stringlen = n;
-  return(p->errcode == NERR_Success);
+       } else {
+               p->errcode = NERR_Success;
+       }
+       p->buflen = i;
+       n -= i;
+       p->stringbuf = p->base + i;
+       p->stringlen = n;
+       return (p->errcode == NERR_Success);
 }
 
-static int package(struct pack_descp, ...)
+static int package(struct pack_desc *p, ...)
 {
-  va_list args;
-  int needed=0, stringneeded;
-  const char* str=NULL;
-  int is_string=0, stringused;
-  int32 temp;
+       va_list args;
+       int needed=0, stringneeded;
+       const char *str=NULL;
+       int is_string=0, stringused;
+       int32 temp;
 
-  va_start(args,p);
+       va_start(args,p);
 
-  if (!*p->curpos) {
-    if (!p->subcount)
-      p->curpos = p->format;
-    else {
-      p->curpos = p->subformat;
-      p->subcount--;
-    }
-  }
+       if (!*p->curpos) {
+               if (!p->subcount) {
+                       p->curpos = p->format;
+               } else {
+                       p->curpos = p->subformat;
+                       p->subcount--;
+               }
+       }
 #if CHECK_TYPES
-  str = va_arg(args,char*);
-  SMB_ASSERT(strncmp(str,p->curpos,strlen(str)) == 0);
+       str = va_arg(args,char*);
+       SMB_ASSERT(strncmp(str,p->curpos,strlen(str)) == 0);
 #endif
-  stringneeded = -1;
+       stringneeded = -1;
 
-  if (!p->curpos) {
-    va_end(args);
-    return(0);
-  }
+       if (!p->curpos) {
+               va_end(args);
+               return 0;
+       }
 
-  switch( *p->curpos++ ) {
-  case 'W':                    /* word (2 byte) */
-    needed = 2;
-    temp = va_arg(args,int);
-    if (p->buflen >= needed) SSVAL(p->structbuf,0,temp);
-    break;
-  case 'K':                    /* status word? (2 byte) */
-    needed = 2;
-    temp = va_arg(args,int);
-    if (p->buflen >= needed) SSVAL(p->structbuf,0,temp);
-    break;
-  case 'N':                    /* count of substructures (word) at end */
-    needed = 2;
-    p->subcount = va_arg(args,int);
-    if (p->buflen >= needed) SSVAL(p->structbuf,0,p->subcount);
-    break;
-  case 'D':                    /* double word (4 byte) */
-    needed = 4;
-    temp = va_arg(args,int);
-    if (p->buflen >= needed) SIVAL(p->structbuf,0,temp);
-    break;
-  case 'B':                    /* byte (with optional counter) */
-    needed = get_counter(&p->curpos);
-    {
-      char *s = va_arg(args,char*);
-      if (p->buflen >= needed) StrnCpy(p->structbuf,s?s:"",needed-1);
-    }
-    break;
-  case 'z':                    /* offset to zero terminated string (4 byte) */
-    str = va_arg(args,char*);
-    stringneeded = (str ? strlen(str)+1 : 0);
-    is_string = 1;
-    break;
-  case 'l':                    /* offset to user data (4 byte) */
-    str = va_arg(args,char*);
-    stringneeded = va_arg(args,int);
-    is_string = 0;
-    break;
-  case 'b':                    /* offset to data (with counter) (4 byte) */
-    str = va_arg(args,char*);
-    stringneeded = get_counter(&p->curpos);
-    is_string = 0;
-    break;
-  }
-  va_end(args);
-  if (stringneeded >= 0) {
-    needed = 4;
-    if (p->buflen >= needed) {
-      stringused = stringneeded;
-      if (stringused > p->stringlen) {
-       stringused = (is_string ? p->stringlen : 0);
-       if (p->errcode == NERR_Success) p->errcode = ERRmoredata;
-      }
-      if (!stringused)
-       SIVAL(p->structbuf,0,0);
-      else {
-       SIVAL(p->structbuf,0,PTR_DIFF(p->stringbuf,p->base));
-       memcpy(p->stringbuf,str?str:"",stringused);
-       if (is_string) p->stringbuf[stringused-1] = '\0';
-       p->stringbuf += stringused;
-       p->stringlen -= stringused;
-       p->usedlen += stringused;
-      }
-    }
-    p->neededlen += stringneeded;
-  }
-  p->neededlen += needed;
-  if (p->buflen >= needed) {
-    p->structbuf += needed;
-    p->buflen -= needed;
-    p->usedlen += needed;
-  }
-  else {
-    if (p->errcode == NERR_Success) p->errcode = ERRmoredata;
-  }
-  return 1;
+       switch( *p->curpos++ ) {
+               case 'W':                       /* word (2 byte) */
+                       needed = 2;
+                       temp = va_arg(args,int);
+                       if (p->buflen >= needed) {
+                               SSVAL(p->structbuf,0,temp);
+                       }
+                       break;
+               case 'K':                       /* status word? (2 byte) */
+                       needed = 2;
+                       temp = va_arg(args,int);
+                       if (p->buflen >= needed) {
+                               SSVAL(p->structbuf,0,temp);
+                       }
+                       break;
+               case 'N':                       /* count of substructures (word) at end */
+                       needed = 2;
+                       p->subcount = va_arg(args,int);
+                       if (p->buflen >= needed) {
+                               SSVAL(p->structbuf,0,p->subcount);
+                       }
+                       break;
+               case 'D':                       /* double word (4 byte) */
+                       needed = 4;
+                       temp = va_arg(args,int);
+                       if (p->buflen >= needed) {
+                               SIVAL(p->structbuf,0,temp);
+                       }
+                       break;
+               case 'B':                       /* byte (with optional counter) */
+                       needed = get_counter(&p->curpos);
+                       {
+                               char *s = va_arg(args,char*);
+                               if (p->buflen >= needed) {
+                                       StrnCpy(p->structbuf,s?s:"",needed-1);
+                               }
+                       }
+                       break;
+               case 'z':                       /* offset to zero terminated string (4 byte) */
+                       str = va_arg(args,char*);
+                       stringneeded = (str ? strlen(str)+1 : 0);
+                       is_string = 1;
+                       break;
+               case 'l':                       /* offset to user data (4 byte) */
+                       str = va_arg(args,char*);
+                       stringneeded = va_arg(args,int);
+                       is_string = 0;
+                       break;
+               case 'b':                       /* offset to data (with counter) (4 byte) */
+                       str = va_arg(args,char*);
+                       stringneeded = get_counter(&p->curpos);
+                       is_string = 0;
+                       break;
+       }
+
+       va_end(args);
+       if (stringneeded >= 0) {
+               needed = 4;
+               if (p->buflen >= needed) {
+                       stringused = stringneeded;
+                       if (stringused > p->stringlen) {
+                               stringused = (is_string ? p->stringlen : 0);
+                               if (p->errcode == NERR_Success) {
+                                       p->errcode = ERRmoredata;
+                               }
+                       }
+                       if (!stringused) {
+                               SIVAL(p->structbuf,0,0);
+                       } else {
+                               SIVAL(p->structbuf,0,PTR_DIFF(p->stringbuf,p->base));
+                               memcpy(p->stringbuf,str?str:"",stringused);
+                               if (is_string) {
+                                       p->stringbuf[stringused-1] = '\0';
+                               }
+                               p->stringbuf += stringused;
+                               p->stringlen -= stringused;
+                               p->usedlen += stringused;
+                       }
+               }
+               p->neededlen += stringneeded;
+       }
+
+       p->neededlen += needed;
+       if (p->buflen >= needed) {
+               p->structbuf += needed;
+               p->buflen -= needed;
+               p->usedlen += needed;
+       } else {
+               if (p->errcode == NERR_Success) {
+                       p->errcode = ERRmoredata;
+               }
+       }
+       return 1;
 }
 
 #if CHECK_TYPES
@@ -340,10 +378,10 @@ static void PACKS(struct pack_desc* desc,const char *t,const char *v)
        PACK(desc,t,v);
 }
 
-
 /****************************************************************************
-  get a print queue
-  ****************************************************************************/
+ Get a print queue.
+****************************************************************************/
+
 static void PackDriverData(struct pack_desc* desc)
 {
        char drivdata[4+4+32];
@@ -439,61 +477,61 @@ static int printq_status(int v)
 }
 
 static void fill_printjob_info(connection_struct *conn, int snum, int uLevel,
-                              struct pack_descdesc,
-                              print_queue_structqueue, int n)
+                              struct pack_desc *desc,
+                              print_queue_struct *queue, int n)
 {
-  time_t t = queue->time;
-
-  /* the client expects localtime */
-  t -= TimeDiff(t);
-
-  PACKI(desc,"W",pjobid_to_rap(lp_const_servicename(snum),queue->job)); /* uJobId */
-  if (uLevel == 1) {
-    PACKS(desc,"B21",queue->fs_user); /* szUserName */
-    PACKS(desc,"B","");                /* pad */
-    PACKS(desc,"B16","");      /* szNotifyName */
-    PACKS(desc,"B10","PM_Q_RAW"); /* szDataType */
-    PACKS(desc,"z","");                /* pszParms */
-    PACKI(desc,"W",n+1);               /* uPosition */
-    PACKI(desc,"W",printj_status(queue->status)); /* fsStatus */
-    PACKS(desc,"z","");                /* pszStatus */
-    PACKI(desc,"D",t); /* ulSubmitted */
-    PACKI(desc,"D",queue->size); /* ulSize */
-    PACKS(desc,"z",queue->fs_file); /* pszComment */
-  }
-  if (uLevel == 2 || uLevel == 3 || uLevel == 4) {
-    PACKI(desc,"W",queue->priority);           /* uPriority */
-    PACKS(desc,"z",queue->fs_user); /* pszUserName */
-    PACKI(desc,"W",n+1);               /* uPosition */
-    PACKI(desc,"W",printj_status(queue->status)); /* fsStatus */
-    PACKI(desc,"D",t); /* ulSubmitted */
-    PACKI(desc,"D",queue->size); /* ulSize */
-    PACKS(desc,"z","Samba");   /* pszComment */
-    PACKS(desc,"z",queue->fs_file); /* pszDocument */
-    if (uLevel == 3) {
-      PACKS(desc,"z","");      /* pszNotifyName */
-      PACKS(desc,"z","PM_Q_RAW"); /* pszDataType */
-      PACKS(desc,"z","");      /* pszParms */
-      PACKS(desc,"z","");      /* pszStatus */
-      PACKS(desc,"z",SERVICE(snum)); /* pszQueue */
-      PACKS(desc,"z","lpd");   /* pszQProcName */
-      PACKS(desc,"z","");      /* pszQProcParms */
-      PACKS(desc,"z","NULL"); /* pszDriverName */
-      PackDriverData(desc);    /* pDriverData */
-      PACKS(desc,"z","");      /* pszPrinterName */
-    } else if (uLevel == 4) {   /* OS2 */
-      PACKS(desc,"z","");       /* pszSpoolFileName  */
-       PACKS(desc,"z","");       /* pszPortName       */
-       PACKS(desc,"z","");       /* pszStatus         */
-       PACKI(desc,"D",0);        /* ulPagesSpooled    */
-       PACKI(desc,"D",0);        /* ulPagesSent       */
-       PACKI(desc,"D",0);        /* ulPagesPrinted    */
-       PACKI(desc,"D",0);        /* ulTimePrinted     */
-       PACKI(desc,"D",0);        /* ulExtendJobStatus */
-       PACKI(desc,"D",0);        /* ulStartPage       */
-       PACKI(desc,"D",0);        /* ulEndPage         */
-    }
-  }
+       time_t t = queue->time;
+
+       /* the client expects localtime */
+       t -= get_time_zone(t);
+
+       PACKI(desc,"W",pjobid_to_rap(lp_const_servicename(snum),queue->job)); /* uJobId */
+       if (uLevel == 1) {
+               PACKS(desc,"B21",queue->fs_user); /* szUserName */
+               PACKS(desc,"B","");             /* pad */
+               PACKS(desc,"B16","");   /* szNotifyName */
+               PACKS(desc,"B10","PM_Q_RAW"); /* szDataType */
+               PACKS(desc,"z","");             /* pszParms */
+               PACKI(desc,"W",n+1);            /* uPosition */
+               PACKI(desc,"W",printj_status(queue->status)); /* fsStatus */
+               PACKS(desc,"z","");             /* pszStatus */
+               PACKI(desc,"D",t); /* ulSubmitted */
+               PACKI(desc,"D",queue->size); /* ulSize */
+               PACKS(desc,"z",queue->fs_file); /* pszComment */
+       }
+       if (uLevel == 2 || uLevel == 3 || uLevel == 4) {
+               PACKI(desc,"W",queue->priority);                /* uPriority */
+               PACKS(desc,"z",queue->fs_user); /* pszUserName */
+               PACKI(desc,"W",n+1);            /* uPosition */
+               PACKI(desc,"W",printj_status(queue->status)); /* fsStatus */
+               PACKI(desc,"D",t); /* ulSubmitted */
+               PACKI(desc,"D",queue->size); /* ulSize */
+               PACKS(desc,"z","Samba");        /* pszComment */
+               PACKS(desc,"z",queue->fs_file); /* pszDocument */
+               if (uLevel == 3) {
+                       PACKS(desc,"z","");     /* pszNotifyName */
+                       PACKS(desc,"z","PM_Q_RAW"); /* pszDataType */
+                       PACKS(desc,"z","");     /* pszParms */
+                       PACKS(desc,"z","");     /* pszStatus */
+                       PACKS(desc,"z",SERVICE(snum)); /* pszQueue */
+                       PACKS(desc,"z","lpd");  /* pszQProcName */
+                       PACKS(desc,"z","");     /* pszQProcParms */
+                       PACKS(desc,"z","NULL"); /* pszDriverName */
+                       PackDriverData(desc);   /* pDriverData */
+                       PACKS(desc,"z","");     /* pszPrinterName */
+               } else if (uLevel == 4) {   /* OS2 */
+                       PACKS(desc,"z","");       /* pszSpoolFileName  */
+                       PACKS(desc,"z","");       /* pszPortName       */
+                       PACKS(desc,"z","");       /* pszStatus         */
+                       PACKI(desc,"D",0);        /* ulPagesSpooled    */
+                       PACKI(desc,"D",0);        /* ulPagesSent       */
+                       PACKI(desc,"D",0);        /* ulPagesPrinted    */
+                       PACKI(desc,"D",0);        /* ulTimePrinted     */
+                       PACKI(desc,"D",0);        /* ulExtendJobStatus */
+                       PACKI(desc,"D",0);        /* ulStartPage       */
+                       PACKI(desc,"D",0);        /* ulEndPage         */
+               }
+       }
 }
 
 /********************************************************************
@@ -2001,20 +2039,20 @@ static BOOL api_NetRemoteTOD(connection_struct *conn,uint16 vuid, char *param,ch
     struct tm *t;
     time_t unixdate = time(NULL);
 
-    put_dos_date3(p,0,unixdate); /* this is the time that is looked at
+    srv_put_dos_date3(p,0,unixdate); /* this is the time that is looked at
                                    by NT in a "net time" operation,
                                    it seems to ignore the one below */
 
     /* the client expects to get localtime, not GMT, in this bit 
        (I think, this needs testing) */
-    t = LocalTime(&unixdate);
+    t = localtime(&unixdate);
 
     SIVAL(p,4,0);              /* msecs ? */
     SCVAL(p,8,t->tm_hour);
     SCVAL(p,9,t->tm_min);
     SCVAL(p,10,t->tm_sec);
     SCVAL(p,11,0);             /* hundredths of seconds */
-    SSVALS(p,12,TimeDiff(unixdate)/60); /* timezone in minutes from GMT */
+    SSVALS(p,12,get_time_zone(unixdate)/60); /* timezone in minutes from GMT */
     SSVAL(p,14,10000);         /* timer interval in 0.0001 of sec */
     SCVAL(p,16,t->tm_mday);
     SCVAL(p,17,t->tm_mon + 1);
@@ -2737,23 +2775,25 @@ static BOOL api_RNetUserGetInfo(connection_struct *conn,uint16 vuid, char *param
        char *p2;
        const char *level_string;
 
-    /* get NIS home of a previously validated user - simeon */
-    /* With share level security vuid will always be zero.
-       Don't depend on vuser being non-null !!. JRA */
-    user_struct *vuser = get_valid_user_struct(vuid);
-    if(vuser != NULL)
-      DEBUG(3,("  Username of UID %d is %s\n", (int)vuser->uid, 
-              vuser->user.unix_name));
+       /* get NIS home of a previously validated user - simeon */
+       /* With share level security vuid will always be zero.
+          Don't depend on vuser being non-null !!. JRA */
+       user_struct *vuser = get_valid_user_struct(vuid);
+       if(vuser != NULL) {
+               DEBUG(3,("  Username of UID %d is %s\n", (int)vuser->uid, 
+                       vuser->user.unix_name));
+       }
 
-    *rparam_len = 6;
-    *rparam = SMB_REALLOC_LIMIT(*rparam,*rparam_len);
+       *rparam_len = 6;
+       *rparam = SMB_REALLOC_LIMIT(*rparam,*rparam_len);
 
-    DEBUG(4,("RNetUserGetInfo level=%d\n", uLevel));
+       DEBUG(4,("RNetUserGetInfo level=%d\n", uLevel));
   
        /* check it's a supported variant */
-       if (strcmp(str1,"zWrLh") != 0) return False;
-       switch( uLevel )
-       {
+       if (strcmp(str1,"zWrLh") != 0) {
+               return False;
+       }
+       switch( uLevel ) {
                case 0: level_string = "B21"; break;
                case 1: level_string = "B21BB16DWzzWz"; break;
                case 2: level_string = "B21BB16DWzzWzDzzzzDDDDWb21WWzWW"; break;
@@ -2762,7 +2802,9 @@ static BOOL api_RNetUserGetInfo(connection_struct *conn,uint16 vuid, char *param
                default: return False;
        }
 
-       if (strcmp(level_string,str2) != 0) return False;
+       if (strcmp(level_string,str2) != 0) {
+               return False;
+       }
 
        *rdata_len = mdrcnt + 1024;
        *rdata = SMB_REALLOC_LIMIT(*rdata,*rdata_len);
@@ -2776,13 +2818,12 @@ static BOOL api_RNetUserGetInfo(connection_struct *conn,uint16 vuid, char *param
        memset(p,0,21); 
        fstrcpy(p+usri11_name,UserName); /* 21 bytes - user name */
 
-       if (uLevel > 0)
-       {
+       if (uLevel > 0) {
                SCVAL(p,usri11_pad,0); /* padding - 1 byte */
                *p2 = 0;
        }
-       if (uLevel >= 10)
-       {
+
+       if (uLevel >= 10) {
                SIVAL(p,usri11_comment,PTR_DIFF(p2,p)); /* comment */
                pstrcpy(p2,"Comment");
                p2 = skip_string(p2,1);
@@ -2797,8 +2838,8 @@ static BOOL api_RNetUserGetInfo(connection_struct *conn,uint16 vuid, char *param
                p2 = skip_string(p2,1);
        }
 
-       if (uLevel == 11) /* modelled after NTAS 3.51 reply */
-       {         
+       if (uLevel == 11) {
+               /* modelled after NTAS 3.51 reply */
                SSVAL(p,usri11_priv,conn->admin_user?USER_PRIV_ADMIN:USER_PRIV_USER); 
                SIVAL(p,usri11_auth_flags,AF_OP_PRINT);         /* auth flags */
                SIVALS(p,usri11_password_age,-1);               /* password age */
@@ -2832,8 +2873,8 @@ static BOOL api_RNetUserGetInfo(connection_struct *conn,uint16 vuid, char *param
 
                SSVAL(p,usri11_code_page,0);            /* code page */
        }
-       if (uLevel == 1 || uLevel == 2)
-       {
+
+       if (uLevel == 1 || uLevel == 2) {
                memset(p+22,' ',16);    /* password */
                SIVALS(p,38,-1);                /* password age */
                SSVAL(p,42,
@@ -2847,8 +2888,7 @@ static BOOL api_RNetUserGetInfo(connection_struct *conn,uint16 vuid, char *param
                SIVAL(p,54,PTR_DIFF(p2,*rdata));                /* script_path */
                pstrcpy(p2,vuser && vuser->logon_script ? vuser->logon_script : "");
                p2 = skip_string(p2,1);
-               if (uLevel == 2)
-               {
+               if (uLevel == 2) {
                        SIVAL(p,60,0);          /* auth_flags */
                        SIVAL(p,64,PTR_DIFF(p2,*rdata)); /* full_name */
                        pstrcpy(p2,((vuser != NULL) ? vuser->user.full_name : UserName));
@@ -3506,47 +3546,46 @@ static BOOL api_RNetSessionEnum(connection_struct *conn,uint16 vuid, char *param
 
 
 /****************************************************************************
- The buffer was too small
+ The buffer was too small.
  ****************************************************************************/
 
-static BOOL api_TooSmall(connection_struct *conn,uint16 vuid, char *param,char *data,
-                        int mdrcnt,int mprcnt,
-                        char **rdata,char **rparam,
-                        int *rdata_len,int *rparam_len)
+static BOOL api_TooSmall(connection_struct *conn,uint16 vuid, char *param, char *data,
+                        int mdrcnt, int mprcnt,
+                        char **rdata, char **rparam,
+                        int *rdata_len, int *rparam_len)
 {
-  *rparam_len = MIN(*rparam_len,mprcnt);
-  *rparam = SMB_REALLOC_LIMIT(*rparam,*rparam_len);
+       *rparam_len = MIN(*rparam_len,mprcnt);
+       *rparam = SMB_REALLOC_LIMIT(*rparam,*rparam_len);
 
-  *rdata_len = 0;
+       *rdata_len = 0;
 
-  SSVAL(*rparam,0,NERR_BufTooSmall);
+       SSVAL(*rparam,0,NERR_BufTooSmall);
 
-  DEBUG(3,("Supplied buffer too small in API command\n"));
+       DEBUG(3,("Supplied buffer too small in API command\n"));
 
-  return(True);
+       return True;
 }
 
-
 /****************************************************************************
- The request is not supported
+ The request is not supported.
  ****************************************************************************/
 
-static BOOL api_Unsupported(connection_struct *conn,uint16 vuid, char *param,char *data,
-                           int mdrcnt,int mprcnt,
-                           char **rdata,char **rparam,
-                           int *rdata_len,int *rparam_len)
+static BOOL api_Unsupported(connection_struct *conn, uint16 vuid, char *param, char *data,
+                           int mdrcnt, int mprcnt,
+                           char **rdata, char **rparam,
+                           int *rdata_len, int *rparam_len)
 {
-  *rparam_len = 4;
-  *rparam = SMB_REALLOC_LIMIT(*rparam,*rparam_len);
+       *rparam_len = 4;
+       *rparam = SMB_REALLOC_LIMIT(*rparam,*rparam_len);
 
-  *rdata_len = 0;
+       *rdata_len = 0;
 
-  SSVAL(*rparam,0,NERR_notsupported);
-  SSVAL(*rparam,2,0);          /* converter word */
+       SSVAL(*rparam,0,NERR_notsupported);
+       SSVAL(*rparam,2,0);             /* converter word */
 
-  DEBUG(3,("Unsupported API command\n"));
+       DEBUG(3,("Unsupported API command\n"));
 
-  return(True);
+       return True;
 }
 
 static const struct {
index 65c31449bb2949cdb7e2c8a78d11cc6924d6520a..db061cb1b8c0b8e3926eda13bbe9a98662217ccf 100644 (file)
@@ -23,6 +23,7 @@
 extern fstring remote_proto;
 extern enum protocol_types Protocol;
 extern int max_recv;
+
 BOOL global_encrypted_passwords_negotiated = False;
 BOOL global_spnego_negotiated = False;
 struct auth_context *negprot_global_auth_context = NULL;
@@ -115,9 +116,9 @@ static int reply_lanman1(char *inbuf, char *outbuf)
        SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support
                readbraw writebraw (possibly) */
        SIVAL(outbuf,smb_vwv6,sys_getpid());
-       SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60);
+       SSVAL(outbuf,smb_vwv10, set_server_zone_offset(t)/60);
 
-       put_dos_date(outbuf,smb_vwv8,t);
+       srv_put_dos_date(outbuf,smb_vwv8,t);
 
        return (smb_len(outbuf)+4);
 }
@@ -157,8 +158,8 @@ static int reply_lanman2(char *inbuf, char *outbuf)
        SSVAL(outbuf,smb_vwv3,lp_maxmux()); 
        SSVAL(outbuf,smb_vwv4,1);
        SSVAL(outbuf,smb_vwv5,raw); /* readbraw and/or writebraw */
-       SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60);
-       put_dos_date(outbuf,smb_vwv8,t);
+       SSVAL(outbuf,smb_vwv10, set_server_zone_offset(t)/60);
+       srv_put_dos_date(outbuf,smb_vwv8,t);
 
        return (smb_len(outbuf)+4);
 }
@@ -245,9 +246,9 @@ static int reply_nt1(char *inbuf, char *outbuf)
                CAP_LEVEL_II_OPLOCKS;
 
        int secword=0;
-       time_t t = time(NULL);
        char *p, *q;
        BOOL negotiate_spnego = False;
+       time_t t = time(NULL);
 
        global_encrypted_passwords_negotiated = lp_encrypted_passwords();
 
@@ -321,7 +322,7 @@ static int reply_nt1(char *inbuf, char *outbuf)
        SIVAL(outbuf,smb_vwv7+1,sys_getpid()); /* session key */
        SIVAL(outbuf,smb_vwv9+1,capabilities); /* capabilities */
        put_long_date(outbuf+smb_vwv11+1,t);
-       SSVALS(outbuf,smb_vwv15+1,TimeDiff(t)/60);
+       SSVALS(outbuf,smb_vwv15+1,set_server_zone_offset(t)/60);
        
        p = q = smb_buf(outbuf);
        if (!negotiate_spnego) {
index 951c192e396b905733fb5c28d79ac536521ae0bd..12f3d180b1ed33c2d4d362338e1070ad759ab466 100644 (file)
@@ -106,7 +106,7 @@ int reply_open_pipe_and_X(connection_struct *conn,
 
        SSVAL(outbuf,smb_vwv2, p->pnum);
        SSVAL(outbuf,smb_vwv3,fmode);
-       put_dos_date3(outbuf,smb_vwv4,mtime);
+       srv_put_dos_date3(outbuf,smb_vwv4,mtime);
        SIVAL(outbuf,smb_vwv6,size);
        SSVAL(outbuf,smb_vwv8,rmode);
        SSVAL(outbuf,smb_vwv11,0x0001);
index f83b0ff74650a196bb271058fc19d812644f4792..81240fcb92de7475ed3876cb15fdb3aec9c9849f 100644 (file)
@@ -914,14 +914,16 @@ int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
        outsize = set_message(outbuf,10,0,True);
 
        SSVAL(outbuf,smb_vwv0,mode);
-       if(lp_dos_filetime_resolution(SNUM(conn)) )
-               put_dos_date3(outbuf,smb_vwv1,mtime & ~1);
-       else
-               put_dos_date3(outbuf,smb_vwv1,mtime);
+       if(lp_dos_filetime_resolution(SNUM(conn)) ) {
+               srv_put_dos_date3(outbuf,smb_vwv1,mtime & ~1);
+       } else {
+               srv_put_dos_date3(outbuf,smb_vwv1,mtime);
+       }
        SIVAL(outbuf,smb_vwv3,(uint32)size);
 
-       if (Protocol >= PROTOCOL_NT1)
+       if (Protocol >= PROTOCOL_NT1) {
                SSVAL(outbuf,smb_flg2,SVAL(outbuf, smb_flg2) | FLAGS2_IS_LONG_NAME);
+       }
   
        DEBUG( 3, ( "getatr name=%s mode=%d size=%d\n", fname, mode, (uint32)size ) );
   
@@ -963,7 +965,7 @@ int reply_setatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
        }
 
        mode = SVAL(inbuf,smb_vwv0);
-       mtime = make_unix_date3(inbuf+smb_vwv1);
+       mtime = srv_make_unix_date3(inbuf+smb_vwv1);
   
        if (mode != FILE_ATTRIBUTE_NORMAL) {
                if (VALID_STAT_OF_DIR(sbuf))
@@ -1393,9 +1395,9 @@ int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
        SSVAL(outbuf,smb_vwv0,fsp->fnum);
        SSVAL(outbuf,smb_vwv1,fattr);
        if(lp_dos_filetime_resolution(SNUM(conn)) ) {
-               put_dos_date3(outbuf,smb_vwv2,mtime & ~1);
+               srv_put_dos_date3(outbuf,smb_vwv2,mtime & ~1);
        } else {
-               put_dos_date3(outbuf,smb_vwv2,mtime);
+               srv_put_dos_date3(outbuf,smb_vwv2,mtime);
        }
        SIVAL(outbuf,smb_vwv4,(uint32)size);
        SSVAL(outbuf,smb_vwv6,deny_mode);
@@ -1563,9 +1565,9 @@ int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
        SSVAL(outbuf,smb_vwv2,fsp->fnum);
        SSVAL(outbuf,smb_vwv3,fattr);
        if(lp_dos_filetime_resolution(SNUM(conn)) ) {
-               put_dos_date3(outbuf,smb_vwv4,mtime & ~1);
+               srv_put_dos_date3(outbuf,smb_vwv4,mtime & ~1);
        } else {
-               put_dos_date3(outbuf,smb_vwv4,mtime);
+               srv_put_dos_date3(outbuf,smb_vwv4,mtime);
        }
        SIVAL(outbuf,smb_vwv6,(uint32)size);
        SSVAL(outbuf,smb_vwv8,GET_OPENX_MODE(deny_mode));
@@ -3272,7 +3274,7 @@ int reply_close(connection_struct *conn, char *inbuf,char *outbuf, int size,
                 * Take care of any time sent in the close.
                 */
 
-               mtime = make_unix_date3(inbuf+smb_vwv1);
+               mtime = srv_make_unix_date3(inbuf+smb_vwv1);
                fsp_set_pending_modtime(fsp, mtime);
 
                /*
@@ -3322,7 +3324,7 @@ int reply_writeclose(connection_struct *conn,
 
        numtowrite = SVAL(inbuf,smb_vwv1);
        startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv2);
-       mtime = make_unix_date3(inbuf+smb_vwv4);
+       mtime = srv_make_unix_date3(inbuf+smb_vwv4);
        data = smb_buf(inbuf) + 1;
   
        if (numtowrite && is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) {
@@ -3639,7 +3641,7 @@ int reply_printqueue(connection_struct *conn,
     
 
                for (i=first;i<first+num_to_get;i++) {
-                       put_dos_date2(p,0,queue[i].time);
+                       srv_put_dos_date2(p,0,queue[i].time);
                        SCVAL(p,4,(queue[i].status==LPQ_PRINTING?2:3));
                        SSVAL(p,5, queue[i].job);
                        SIVAL(p,7,queue[i].size);
@@ -5444,8 +5446,8 @@ int reply_setattrE(connection_struct *conn, char *inbuf,char *outbuf, int size,
         * time as UNIX can't set this.
         */
 
-       unix_times.actime = make_unix_date2(inbuf+smb_vwv3);
-       unix_times.modtime = make_unix_date2(inbuf+smb_vwv5);
+       unix_times.actime = srv_make_unix_date2(inbuf+smb_vwv3);
+       unix_times.modtime = srv_make_unix_date2(inbuf+smb_vwv5);
   
        /* 
         * Patch from Ray Frush <frush@engr.colostate.edu>
@@ -5713,10 +5715,10 @@ int reply_getattrE(connection_struct *conn, char *inbuf,char *outbuf, int size,
         * this.
         */
 
-       put_dos_date2(outbuf,smb_vwv0,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))));
-       put_dos_date2(outbuf,smb_vwv2,sbuf.st_atime);
+       srv_put_dos_date2(outbuf,smb_vwv0,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))));
+       srv_put_dos_date2(outbuf,smb_vwv2,sbuf.st_atime);
        /* Should we check pending modtime here ? JRA */
-       put_dos_date2(outbuf,smb_vwv4,sbuf.st_mtime);
+       srv_put_dos_date2(outbuf,smb_vwv4,sbuf.st_mtime);
 
        if (mode & aDIR) {
                SIVAL(outbuf,smb_vwv6,0);
index beaf35caa22f2b672148f9ad228fe428127f0bb3..ee6bed9afdf2ac8a6dced570deafe372ff085ecf 100644 (file)
@@ -878,7 +878,7 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
 
        SSVAL(params,0,fsp->fnum);
        SSVAL(params,2,open_attr);
-       put_dos_date2(params,4, mtime);
+       srv_put_dos_date2(params,4, mtime);
        SIVAL(params,8, (uint32)size);
        SSVAL(params,12,deny_mode);
        SSVAL(params,14,0); /* open_type - file or directory. */
@@ -1186,9 +1186,9 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
                                SIVAL(p,0,reskey);
                                p += 4;
                        }
-                       put_dos_date2(p,0,cdate);
-                       put_dos_date2(p,4,adate);
-                       put_dos_date2(p,8,mdate);
+                       srv_put_dos_date2(p,0,cdate);
+                       srv_put_dos_date2(p,4,adate);
+                       srv_put_dos_date2(p,8,mdate);
                        SIVAL(p,12,(uint32)file_size);
                        SIVAL(p,16,(uint32)allocation_size);
                        SSVAL(p,20,mode);
@@ -1218,9 +1218,9 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
                                SIVAL(p,0,reskey);
                                p += 4;
                        }
-                       put_dos_date2(p,0,cdate);
-                       put_dos_date2(p,4,adate);
-                       put_dos_date2(p,8,mdate);
+                       srv_put_dos_date2(p,0,cdate);
+                       srv_put_dos_date2(p,4,adate);
+                       srv_put_dos_date2(p,8,mdate);
                        SIVAL(p,12,(uint32)file_size);
                        SIVAL(p,16,(uint32)allocation_size);
                        SSVAL(p,20,mode);
@@ -1262,9 +1262,9 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
                                SIVAL(p,0,reskey);
                                p += 4;
                        }
-                       put_dos_date2(p,0,cdate);
-                       put_dos_date2(p,4,adate);
-                       put_dos_date2(p,8,mdate);
+                       srv_put_dos_date2(p,0,cdate);
+                       srv_put_dos_date2(p,4,adate);
+                       srv_put_dos_date2(p,8,mdate);
                        SIVAL(p,12,(uint32)file_size);
                        SIVAL(p,16,(uint32)allocation_size);
                        SSVAL(p,20,mode);
@@ -3016,9 +3016,9 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                case SMB_INFO_STANDARD:
                        DEBUG(10,("call_trans2qfilepathinfo: SMB_INFO_STANDARD\n"));
                        data_size = 22;
-                       put_dos_date2(pdata,l1_fdateCreation,c_time);
-                       put_dos_date2(pdata,l1_fdateLastAccess,sbuf.st_atime);
-                       put_dos_date2(pdata,l1_fdateLastWrite,sbuf.st_mtime); /* write time */
+                       srv_put_dos_date2(pdata,l1_fdateCreation,c_time);
+                       srv_put_dos_date2(pdata,l1_fdateLastAccess,sbuf.st_atime);
+                       srv_put_dos_date2(pdata,l1_fdateLastWrite,sbuf.st_mtime); /* write time */
                        SIVAL(pdata,l1_cbFile,(uint32)file_size);
                        SIVAL(pdata,l1_cbFileAlloc,(uint32)allocation_size);
                        SSVAL(pdata,l1_attrFile,mode);
@@ -3029,9 +3029,9 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                        unsigned int ea_size = estimate_ea_size(conn, fsp, fname);
                        DEBUG(10,("call_trans2qfilepathinfo: SMB_INFO_QUERY_EA_SIZE\n"));
                        data_size = 26;
-                       put_dos_date2(pdata,0,c_time);
-                       put_dos_date2(pdata,4,sbuf.st_atime);
-                       put_dos_date2(pdata,8,sbuf.st_mtime); /* write time */
+                       srv_put_dos_date2(pdata,0,c_time);
+                       srv_put_dos_date2(pdata,4,sbuf.st_atime);
+                       srv_put_dos_date2(pdata,8,sbuf.st_mtime); /* write time */
                        SIVAL(pdata,12,(uint32)file_size);
                        SIVAL(pdata,16,(uint32)allocation_size);
                        SSVAL(pdata,20,mode);
@@ -3730,9 +3730,9 @@ static int call_trans2setfilepathinfo(connection_struct *conn, char *inbuf, char
                        }
 
                        /* access time */
-                       tvs.actime = make_unix_date2(pdata+l1_fdateLastAccess);
+                       tvs.actime = srv_make_unix_date2(pdata+l1_fdateLastAccess);
                        /* write time */
-                       tvs.modtime = make_unix_date2(pdata+l1_fdateLastWrite);
+                       tvs.modtime = srv_make_unix_date2(pdata+l1_fdateLastWrite);
                        break;
                }
 
index 960379b3838e01e533a95bc9c54702a7d7f865c8..31693affe739d2951f06bd2d8c6631ab1025316c 100644 (file)
@@ -104,7 +104,7 @@ static int show_share(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
        d_printf("%-10.10s   %s   %-12s  %s",
               crec.name,procid_str_static(&crec.pid),
               crec.machine,
-              asctime(LocalTime(&crec.start)));
+              asctime(localtime(&crec.start)));
 
        return 0;
 }
@@ -169,7 +169,7 @@ static int show_share_parseable(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
                 guest ? "" : gidtoname(ids->entries[i].gid),
                 crec.machine, 
                 guest ? "" : ids->entries[i].hostname,
-                asctime(LocalTime(&crec.start)));
+                asctime(localtime(&crec.start)));
 
        return 0;
 }
index 4709cfbaee105840c3c3935535ab6ea8bb19b105..a495d07f0475779b9a88b4c593fcef9830e24358 100644 (file)
@@ -150,7 +150,7 @@ static void print_share_mode(const struct share_mode_entry *e, char *fname)
                        d_printf("NONE            ");
                }
 
-               d_printf(" %s   %s",fname, asctime(LocalTime((time_t *)&e->time.tv_sec)));
+               d_printf(" %s   %s",fname, asctime(localtime((time_t *)&e->time.tv_sec)));
        }
 }
 
@@ -553,7 +553,7 @@ static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *st
        d_printf("%-10s   %s   %-12s  %s",
               crec.name,procid_str_static(&crec.pid),
               crec.machine,
-              asctime(LocalTime(&crec.start)));
+              asctime(localtime(&crec.start)));
 
        return 0;
 }
index edc03183730d14c97a7eabf7bd772c1d65cfae0a..6447f95bac4c332d470e858e6c2d9c6c7915c0e2 100644 (file)
@@ -101,7 +101,7 @@ static char *mapPid2Machine (struct process_id pid)
 static char *tstring(time_t t)
 {
        static pstring buf;
-       pstrcpy(buf, asctime(LocalTime(&t)));
+       pstrcpy(buf, asctime(localtime(&t)));
        all_string_sub(buf," ","&nbsp;",sizeof(buf));
        return buf;
 }