put a dos date into a buffer (time/date format)
This takes GMT time and puts local time in the buffer
********************************************************************/
-void push_dos_date(char *buf, int offset, time_t unixdate, int zone_offset)
+void push_dos_date(uint8_t *buf, int offset, time_t unixdate, int zone_offset)
{
uint32_t x = make_dos_date(unixdate, zone_offset);
SIVAL(buf,offset,x);
put a dos date into a buffer (date/time format)
This takes GMT time and puts local time in the buffer
********************************************************************/
-void push_dos_date2(char *buf,int offset,time_t unixdate, int zone_offset)
+void push_dos_date2(uint8_t *buf,int offset,time_t unixdate, int zone_offset)
{
uint32_t x;
x = make_dos_date(unixdate, zone_offset);
GMT and converts it to LOCAL time before putting it (most SMBs assume
localtime for this sort of date)
********************************************************************/
-void push_dos_date3(char *buf,int offset,time_t unixdate, int zone_offset)
+void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset)
{
if (!null_time(unixdate)) {
unixdate -= zone_offset;
tm->tm_sec);
}
-/*
- a hack to move the stupid gcc strftime warning to one place - see manual page
-*/
-#ifdef HAVE_STRFTIME
-size_t sys_strftime(char *s, size_t max, const char *fmt, const struct tm *tm)
-{
- return strftime(s, max, fmt, tm);
-}
-#endif
-
/****************************************************************************
Return the date and time as a string
****************************************************************************/
in the gcc warning, not a bug in this code. See a recent
strftime() manual page for details.
*/
- sys_strftime(tempTime,sizeof(tempTime)-1,"%c %Z",tm);
+ strftime(tempTime,sizeof(tempTime)-1,"%c %Z",tm);
TimeBuf = talloc_strdup(mem_ctx, tempTime);
#else
TimeBuf = talloc_strdup(mem_ctx, asctime(tm));
const char *nt_time_string(TALLOC_CTX *mem_ctx, NTTIME nt)
{
time_t t = nt_time_to_unix(nt);
- return talloc_strdup(mem_ctx, timestring(mem_ctx, t));
+ return timestring(mem_ctx, t);
}
/*
put a NTTIME into a packet
*/
-void push_nttime(void *base, uint16_t offset, NTTIME t)
+void push_nttime(uint8_t *base, uint16_t offset, NTTIME t)
{
SBVAL(base, offset, t);
}
/*
pull a NTTIME from a packet
*/
-NTTIME pull_nttime(void *base, uint16_t offset)
+NTTIME pull_nttime(uint8_t *base, uint16_t offset)
{
NTTIME ret = BVAL(base, offset);
return ret;
return (tv2.tv_usec >= tv->tv_usec);
}
+/*
+ return the number of seconds elapsed between two times
+*/
+double timeval_elapsed2(struct timeval *tv1, struct timeval *tv2)
+{
+ return (tv2->tv_sec - tv1->tv_sec) +
+ (tv2->tv_usec - tv1->tv_usec)*1.0e-6;
+}
+
/*
return the number of seconds elapsed since a given time
*/
double timeval_elapsed(struct timeval *tv)
{
struct timeval tv2 = timeval_current();
- return (tv2.tv_sec - tv->tv_sec) +
- (tv2.tv_usec - tv->tv_usec)*1.0e-6;
+ return timeval_elapsed2(tv, &tv2);
}
/*
return *tv2;
}
+/*
+ return the greater of two timevals
+*/
+struct timeval timeval_max(struct timeval *tv1, 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;
+ return *tv2;
+}
+
/*
return the difference between two timevals as a timeval
if tv2 comes after tv1, then return a zero timeval
}
return t;
}
+
+
+/*
+ convert a timeval to a NTTIME
+*/
+NTTIME timeval_to_nttime(struct timeval *tv)
+{
+ return 10*(tv->tv_usec +
+ ((TIME_FIXUP_CONSTANT + (uint64_t)tv->tv_sec) * 1000000));
+}