Merge from vendor branch OPENSSH:
[dragonfly.git] / contrib / top / patches / top.c.patch
1 Index: top.c
2 ===================================================================
3 RCS file: /cvs/DragonFly/src/contrib/top/top.c,v
4 retrieving revision 1.2
5 diff -u -p -u -r1.2 top.c
6 --- top.c       17 Jun 2003 04:24:07 -0000      1.2
7 +++ top.c       4 Jun 2004 12:09:22 -0000
8 @@ -193,9 +193,9 @@ char *argv[];
9      fd_set readfds;
10  
11  #ifdef ORDER
12 -    static char command_chars[] = "\f qh?en#sdkriIuto";
13 +    static char command_chars[] = "\f qh?en#sdkriIutTOSo";
14  #else
15 -    static char command_chars[] = "\f qh?en#sdkriIut";
16 +    static char command_chars[] = "\f qh?en#sdkriIutTOSO";
17  #endif
18  /* these defines enumerate the "strchr"s of the commands in command_chars */
19  #define CMD_redraw     0
20 @@ -215,8 +215,11 @@ char *argv[];
21  #define CMD_idletog2    13
22  #define CMD_user       14
23  #define CMD_selftog    15
24 +#define CMD_threads    16
25 +#define CMD_othreads   17
26 +#define CMD_system     18
27  #ifdef ORDER
28 -#define CMD_order       16
29 +#define CMD_order       19
30  #endif
31  
32      /* set the buffer for stdout */
33 @@ -245,6 +248,8 @@ char *argv[];
34      ps.idle    = Yes;
35      ps.self    = -1;
36      ps.system  = No;
37 +    ps.threads = No;
38 +       ps.only_threads = No;
39      ps.uid     = -1;
40      ps.command = NULL;
41  
42 @@ -271,7 +276,7 @@ char *argv[];
43             optind = 1;
44         }
45  
46 -       while ((i = getopt(ac, av, "SIbinquvs:d:U:o:t")) != EOF)
47 +       while ((i = getopt(ac, av, "SITONbinquvs:d:U:o:t")) != EOF)
48         {
49             switch(i)
50             {
51 @@ -301,6 +306,14 @@ char *argv[];
52                 ps.idle = !ps.idle;
53                 break;
54  
55 +                 case 'O':
56 +               ps.only_threads = !ps.only_threads; /* only threads */
57 +               break;
58 +       
59 +             case 'T':
60 +               ps.threads = !ps.threads;       /* show threads */
61 +           break;
62 +
63               case 'i':                 /* go interactive regardless */
64                 interactive = Yes;
65                 break;
66 @@ -928,6 +941,31 @@ restart:
67                                 putchar('\r');
68                                 break;
69  
70 +                           case CMD_threads:
71 +                               ps.threads = !ps.threads;
72 +                               new_message(MT_standout | MT_delayed,
73 +                                  " %sisplaying threads.",
74 +                                  ps.threads ? "D" : "Not d");
75 +                               putchar('\r');
76 +                               break;
77 +
78 +                               case CMD_othreads:
79 +                                       ps.only_threads = !ps.only_threads;
80 +                                       new_message(MT_standout | MT_delayed,
81 +                                       ps.only_threads ?
82 +                                         "Only displaying threads." :
83 +                                         "Displaying threads and processes.");
84 +                               putchar('\r');
85 +                               break;
86 +
87 +                           case CMD_system:
88 +                               ps.system = !ps.system;
89 +                               new_message(MT_standout | MT_delayed,
90 +                                  " %sisplaying system processes.",
91 +                                  ps.system ? "D" : "Not d");
92 +                               putchar('\r');
93 +                               break;
94 +
95                             case CMD_user:
96                                 new_message(MT_standout,
97                                     "Username to show: ");