home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / gnu / utils / bug / 2024 < prev    next >
Encoding:
Text File  |  1992-11-09  |  5.5 KB  |  209 lines

  1. Newsgroups: gnu.utils.bug
  2. Path: sparky!uunet!stanford.edu!agate!spool.mu.edu!nigel.msen.com!emory!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!devon.lns.pa.US!paul
  3. From: paul@devon.lns.pa.US (Paul Sutcliffe Jr.)
  4. Subject: changes to shellutils-1.8
  5. Message-ID: <9211090953.AA24643@hobbes.cert.org>
  6. Sender: gnulists@ai.mit.edu
  7. Reply-To: paul@devon.lns.pa.us (Paul Sutcliffe Jr.)
  8. Organization: GNUs Not Usenet
  9. Distribution: gnu
  10. Date: Sun, 8 Nov 1992 19:36:47 GMT
  11. Approved: bug-gnu-utils@prep.ai.mit.edu
  12. Lines: 195
  13.  
  14. While porting SHELLUTILS-1.8 to my ESIX 4.0.3a (SYS V/386 R4.0 V3.0)
  15. system, I made some changes to allow "who" to use the ut_host member in
  16. the utmpx structure.  Here are unified diffs of the changes.
  17.  
  18. The changes aren't elegant.  They allow "who" to function with the
  19. utmpx file instead of the utmp file, while retaining the output format
  20. (WRT field sizes) of the utmp fields.
  21.  
  22. - paul
  23.  
  24. --- Makefile.in.orig    Fri Sep 11 00:09:59 1992
  25. +++ Makefile.in    Sun Nov  8 23:19:26 1992
  26. @@ -52,7 +52,8 @@
  27.  # -DHAVE_TZNAME        If you have tm_zone and tzname but not tm_zone;
  28.  #            otherwise uses tm_isdst and timezone.
  29.  # -DHAVE_C_LINE        If you have struct termios with the c_line member.
  30. -# -DHAVE_UT_HOST    If you have ut_host in struct utmp.
  31. +# -DHAVE_UTMPX        If you have struct utmpx.
  32. +# -DHAVE_UT_HOST    If you have ut_host in struct utmp/utmpx.
  33.  # -DNICE_PRIORITY    If you lack getpriority and setpriority system
  34.  #            calls but have nice system call.
  35.  # -DWINSIZE_IN_PTEM    If your system defines `struct winsize' in sys/ptem.h.
  36.  
  37. --- configure.in.orig    Thu Oct  1 20:56:22 1992
  38. +++ configure.in    Sun Nov  8 23:19:14 1992
  39. @@ -44,7 +44,12 @@
  40.  AC_COMPILE_CHECK(ut_host in struct utmp,
  41.  [#include <sys/types.h>
  42.  #include <utmp.h>], [struct utmp ut; ut.ut_host;],
  43. -AC_DEFINE(HAVE_UT_HOST))
  44. +AC_DEFINE(HAVE_UT_HOST),
  45. +AC_COMPILE_CHECK(ut_host in struct utmpx,
  46. +[#include <sys/types.h>
  47. +#include <utmpx.h>], [struct utmpx ut; ut.ut_host;],
  48. +[AC_DEFINE(HAVE_UT_HOST)
  49. +AC_DEFINE(HAVE_UTMPX)]))
  50.  
  51.  AC_COMPILE_CHECK(POSIX termios,
  52.  [#include <sys/types.h>
  53.  
  54. --- src/who.c.orig    Wed Oct 28 15:02:50 1992
  55. +++ src/who.c    Sun Nov  8 16:35:16 1992
  56. @@ -34,7 +34,16 @@
  57.  
  58.  #include <stdio.h>
  59.  #include <sys/types.h>
  60. +#ifdef HAVE_UTMPX
  61. +#include <utmpx.h>
  62. +#define UTMP struct utmpx
  63. +#undef  UTMP_FILE
  64. +#define UTMP_FILE UTMPX_FILE
  65. +#define ut_time ut_xtime
  66. +#else
  67.  #include <utmp.h>
  68. +#define UTMP struct utmp
  69. +#endif
  70.  #include <time.h>
  71.  #include <getopt.h>
  72.  #ifndef _POSIX_SOURCE
  73. @@ -60,7 +69,7 @@
  74.  
  75.  char *idle_string ();
  76.  char *xmalloc ();
  77. -struct utmp *search_entries ();
  78. +UTMP *search_entries ();
  79.  void error ();
  80.  void list_entries ();
  81.  void print_entry ();
  82. @@ -176,7 +185,7 @@
  83.    exit (0);
  84.  }
  85.  
  86. -static struct utmp *utmp_contents;
  87. +static UTMP *utmp_contents;
  88.  
  89.  /* Display a list of who is on the system, according to utmp file FILENAME. */
  90.  
  91. @@ -209,7 +218,7 @@
  92.  
  93.    fstat (desc, &file_stats);
  94.    if (file_stats.st_size > 0)
  95. -    utmp_contents = (struct utmp *) xmalloc ((unsigned) file_stats.st_size);
  96. +    utmp_contents = (UTMP *) xmalloc ((unsigned) file_stats.st_size);
  97.    else
  98.      {
  99.        close (desc);
  100. @@ -223,7 +232,7 @@
  101.    if (close (desc))
  102.      error (1, errno, "%s", filename);
  103.  
  104. -  return file_stats.st_size / sizeof (struct utmp);
  105. +  return file_stats.st_size / sizeof (UTMP);
  106.  }
  107.  
  108.  /* Display a line of information about entry THIS. */
  109. @@ -230,8 +239,9 @@
  110.  
  111.  void
  112.  print_entry (this)
  113. -     struct utmp *this;
  114. +     UTMP *this;
  115.  {
  116. +  struct utmp *ut;
  117.    struct stat stats;
  118.    time_t last_change;
  119.    char mesg;
  120. @@ -251,12 +261,12 @@
  121.      }
  122.    
  123.    printf ("%-*.*s",
  124. -      sizeof (this->ut_name), sizeof (this->ut_name),
  125. +      sizeof (ut->ut_name), sizeof (ut->ut_name),
  126.        this->ut_name);
  127.    if (include_mesg)
  128.      printf ("  %c  ", mesg);
  129.    printf (" %-*.*s",
  130. -      sizeof (this->ut_line), sizeof (this->ut_line),
  131. +      sizeof (ut->ut_line), sizeof (ut->ut_line),
  132.        this->ut_line);
  133.    printf (" %-12.12s", ctime (&this->ut_time) + 4);
  134.    if (include_idle)
  135. @@ -265,10 +275,11 @@
  136.      printf (" %s", idle_string (last_change));
  137.        else
  138.      printf ("   .  ");
  139. +      printf ( "  %5d", this->ut_pid);
  140.      }
  141.  #ifdef HAVE_UT_HOST
  142.    if (this->ut_host[0])
  143. -    printf (" (%-.*s)", sizeof (this->ut_host), this->ut_host);
  144. +    printf ("  (%-.*s)", sizeof (this->ut_host), this->ut_host);
  145.  #endif
  146.  
  147.    putchar ('\n');
  148. @@ -281,7 +292,7 @@
  149.  list_entries (n)
  150.       int n;
  151.  {
  152. -  register struct utmp *this = utmp_contents;
  153. +  register UTMP *this = utmp_contents;
  154.    register int entries = 0;
  155.  
  156.    while (n--)
  157. @@ -311,8 +322,11 @@
  158.    printf ("%-*s ", sizeof (ut->ut_line), "LINE");
  159.    printf ("LOGIN-TIME   ");
  160.    if (include_idle)
  161. -    printf ("IDLE  ");
  162. -  printf ("FROM\n");
  163. +    printf (" IDLE    PID ");
  164. +#ifdef HAVE_UT_HOST
  165. +  printf (" FROM");
  166. +#endif
  167. +  putchar ('\n');
  168.  }
  169.  
  170.  /* Display `utmp_contents', which should have N entries. */
  171. @@ -321,7 +335,7 @@
  172.  scan_entries (n)
  173.       int n;
  174.  {
  175. -  register struct utmp *this = utmp_contents;
  176. +  register UTMP *this = utmp_contents;
  177.  
  178.    if (include_heading)
  179.      print_heading ();
  180. @@ -343,12 +357,12 @@
  181.     Return the first matching entry found, or NULL if there
  182.     is no matching entry. */
  183.  
  184. -struct utmp *
  185. +UTMP *
  186.  search_entries (n, line)
  187.       int n;
  188.       char *line;
  189.  {
  190. -  register struct utmp *this = utmp_contents;
  191. +  register UTMP *this = utmp_contents;
  192.  
  193.    while (n--)
  194.      {
  195. @@ -370,7 +384,7 @@
  196.  who_am_i (filename)
  197.       char *filename;
  198.  {
  199. -  register struct utmp *utmp_entry;
  200. +  register UTMP *utmp_entry;
  201.    char hostname[MAXHOSTNAMELEN + 1];
  202.    char *tty;
  203.  
  204.  
  205. -- 
  206. INTERNET:  paul@devon.lns.pa.us      |    Why doesn't anything ever
  207. UUCP:      ...!rutgers!devon!paul    |    vanish into THICK air?  --Me
  208.  
  209.