diff options
author | Elrond <elrond@samba.org> | 2000-03-31 17:02:43 +0000 |
---|---|---|
committer | Elrond <elrond@samba.org> | 2000-03-31 17:02:43 +0000 |
commit | 29bfe52a01dacd1c1400724d4f688d1f951cd10e (patch) | |
tree | 7a4c6a1a3ca59fd97cb57dee2d38dd219c625f5a | |
parent | e8eab20d17ca4cab4be5f4843ea3e8143fdac45b (diff) | |
download | samba-29bfe52a01dacd1c1400724d4f688d1f951cd10e.tar.gz |
rpcclient wanted to open a logfile in /usr/local/samba/var,
when called without -l and as a normal user, you can't
create one there.
time.c: merged some things from HEAD, now "debug hires
timestamp" works.
system.c: merge sys_usleep from HEAD
-rw-r--r-- | source/lib/cmd_interp.c | 3 | ||||
-rw-r--r-- | source/lib/system.c | 34 | ||||
-rw-r--r-- | source/lib/time.c | 46 |
3 files changed, 77 insertions, 6 deletions
diff --git a/source/lib/cmd_interp.c b/source/lib/cmd_interp.c index 0a74fbc52cf..a173367fb13 100644 --- a/source/lib/cmd_interp.c +++ b/source/lib/cmd_interp.c @@ -1293,7 +1293,8 @@ static void cmd_set(struct client_info *info, int argc, char *argv[]) if (IS_BITS_SET_ALL(cmd_set_options, CMD_INTER)) { setup_logging(debugf, interactive); - reopen_logs(); + if (! interactive) + reopen_logs(); } strupper(global_myname); diff --git a/source/lib/system.c b/source/lib/system.c index 94e1899022e..802a5a89127 100644 --- a/source/lib/system.c +++ b/source/lib/system.c @@ -141,6 +141,40 @@ int sys_select(int maxfd, fd_set *r_fds, fd_set *w_fds, struct timeval *tval) #endif /* NO_SELECT */ /******************************************************************* + A wrapper for usleep in case we don't have one. +********************************************************************/ + +int sys_usleep(long usecs) +{ +#ifndef HAVE_USLEEP + struct timeval tval; +#endif + + /* + * We need this braindamage as the glibc usleep + * is not SPEC1170 complient... grumble... JRA. + */ + + if(usecs < 0 || usecs > 1000000) { + errno = EINVAL; + return -1; + } + +#if HAVE_USLEEP + usleep(usecs); + return 0; +#else /* HAVE_USLEEP */ + /* + * Fake it with select... + */ + tval.tv_sec = 0; + tval.tv_usec = usecs/1000; + select(0,NULL,NULL,NULL,&tval); + return 0; +#endif /* HAVE_USLEEP */ +} + +/******************************************************************* A stat() wrapper that will deal with 64 bit filesizes. ********************************************************************/ diff --git a/source/lib/time.c b/source/lib/time.c index 99d6c2e2716..bf1b4312c2d 100644 --- a/source/lib/time.c +++ b/source/lib/time.c @@ -517,19 +517,55 @@ char *http_timestring(time_t t) /**************************************************************************** Return the date and time as a string ****************************************************************************/ + char *timestring(BOOL hires) { static fstring TimeBuf; - time_t t = time(NULL); - struct tm *tm = LocalTime(&t); + struct timeval tp; + time_t t; + struct tm *tm; + if (hires) { + GetTimeOfDay(&tp); + t = (time_t)tp.tv_sec; + } else { + t = time(NULL); + } + tm = LocalTime(&t); if (!tm) { - slprintf(TimeBuf,sizeof(TimeBuf)-1,"%ld seconds since the Epoch",(long)t); + if (hires) { + slprintf(TimeBuf, + sizeof(TimeBuf)-1, + "%ld.%06ld seconds since the Epoch", + (long)tp.tv_sec, + (long)tp.tv_usec); + } else { + slprintf(TimeBuf, + sizeof(TimeBuf)-1, + "%ld seconds since the Epoch", + (long)t); + } } else { #ifdef HAVE_STRFTIME - strftime(TimeBuf,100,"%Y/%m/%d %T",tm); + if (hires) { + strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %H:%M:%S",tm); + slprintf(TimeBuf+strlen(TimeBuf), + sizeof(TimeBuf)-1 - strlen(TimeBuf), + ".%06ld", + (long)tp.tv_usec); + } else { + strftime(TimeBuf,100,"%Y/%m/%d %H:%M:%S",tm); + } #else - fstrcpy(TimeBuf, asctime(tm)); + if (hires) { + slprintf(TimeBuf, + sizeof(TimeBuf)-1, + "%s.%06ld", + asctime(tm), + (long)tp.tv_usec); + } else { + fstrcpy(TimeBuf, asctime(tm)); + } #endif } return(TimeBuf); |