zsh-workers
 help / color / mirror / code / Atom feed
* A simpler watch log
@ 1996-06-11 15:55 Hrvoje Niksic
  0 siblings, 0 replies; only message in thread
From: Hrvoje Niksic @ 1996-06-11 15:55 UTC (permalink / raw)
  To: ZSH Workers Mailing List

A friend of mine (joe@fly.cc.fer.hr) has suggested that the log
command should accept a parameter to tell it to print the log in a
simple format, like the 'users' command.

I have implemented a '-u' option to the log builtin which makes it
print only the username on each line. It adds an argument to the
dowatch(), which, if set, means "simple" watch, which in turns sets
the fmt to "%n".

This is not completely compatible with 'users' output, since each
username is on a separate line. A little more tweaking by someone who
knows more about watch.c could result in dowatch() not calling
watchlog() at all, if simple is set.

Here is the patch:
*** watch.c.orig	Tue Jun 11 17:46:28 1996
--- watch.c	Tue Jun 11 17:18:37 1996
***************
*** 374,380 ****
  
  /**/
  void
! dowatch(void)
  {
      FILE *in;
      STRUCT_UTMP *utab, *uptr, *wptr;
--- 374,380 ----
  
  /**/
  void
! dowatch(int simple_format)
  {
      FILE *in;
      STRUCT_UTMP *utab, *uptr, *wptr;
***************
*** 385,391 ****
      int uct, wct;
  
      s = watch;
!     if (!(fmt = getsparam("WATCHFMT")))
  	fmt = DEFAULT_WATCHFMT;
  
      holdintr();
--- 385,393 ----
      int uct, wct;
  
      s = watch;
!     if (simple_format)
!     	fmt = SIMPLE_WATCHFMT;
!     else if (!(fmt = getsparam("WATCHFMT")))
  	fmt = DEFAULT_WATCHFMT;
  
      holdintr();
***************
*** 460,466 ****
      wtab = (STRUCT_UTMP *)zalloc(1);
      wtabsz = 0;
      lastutmpcheck = 0;
!     dowatch();
      return 0;
  }
  
--- 462,471 ----
      wtab = (STRUCT_UTMP *)zalloc(1);
      wtabsz = 0;
      lastutmpcheck = 0;
!     if (ops['u'])
!     	dowatch(1);
!     else
!     	dowatch(0);
      return 0;
  }
  
*** hashtable.h.orig	Tue Jun 11 17:46:49 1996
--- hashtable.h	Tue Jun 11 17:35:32 1996
***************
*** 282,288 ****
      {NULL, "let", 0, bin_let, 1, -1, 0, NULL, NULL},
      {NULL, "limit", 0, bin_limit, 0, -1, 0, "sh", NULL},
      {NULL, "local", BINF_TYPEOPTS | BINF_MAGICEQUALS, bin_typeset, 0, -1, 0, "LRUZilrtu", NULL},
!     {NULL, "log", 0, bin_log, 0, 0, 0, NULL, NULL},
      {NULL, "logout", 0, bin_break, 0, 1, BIN_LOGOUT, NULL, NULL},
  
  #if defined(ZSH_MEM) & defined(ZSH_MEM_DEBUG)
--- 282,288 ----
      {NULL, "let", 0, bin_let, 1, -1, 0, NULL, NULL},
      {NULL, "limit", 0, bin_limit, 0, -1, 0, "sh", NULL},
      {NULL, "local", BINF_TYPEOPTS | BINF_MAGICEQUALS, bin_typeset, 0, -1, 0, "LRUZilrtu", NULL},
!     {NULL, "log", 0, bin_log, 0, 0, 0, "u", NULL},
      {NULL, "logout", 0, bin_break, 0, 1, BIN_LOGOUT, NULL, NULL},
  
  #if defined(ZSH_MEM) & defined(ZSH_MEM_DEBUG)
*** system.h.orig	Tue Jun 11 17:47:02 1996
--- system.h	Tue Jun 11 17:14:13 1996
***************
*** 305,310 ****
--- 305,312 ----
  # define DEFAULT_WATCHFMT "%n has %a %l."
  #endif
  
+ #define SIMPLE_WATCHFMT "%n"
+ 
  #define DEFAULT_WORDCHARS "*?_-.[]~=/&;!#$%^(){}<>"
  #define DEFAULT_TIMEFMT   "%J  %U user %S system %P cpu %*E total"
  


-- 
hniksic@srce.hr              |  Student of electrical engineering
hniksic@fly.cc.fer.hr        |  University of Zagreb, Croatia
------------------------------------------------------------------
I'm a Lisp variable -- bind me!



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-06-11 16:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-06-11 15:55 A simpler watch log Hrvoje Niksic

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).