top(1): Remove whitespace from local modifications
[dragonfly.git] / contrib / top / machine.h
1 /*
2  * Copyright (c) 1984 through 2008, William LeFebvre
3  * All rights reserved.
4  * 
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * 
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 
11  *     * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following disclaimer
13  * in the documentation and/or other materials provided with the
14  * distribution.
15  * 
16  *     * Neither the name of William LeFebvre nor the names of other
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  * 
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 /*
34  *  This file defines the interface between top and the machine-dependent
35  *  module.  It is NOT machine dependent and should not need to be changed
36  *  for any specific machine.
37  */
38
39 #ifndef _MACHINE_H_
40 #define _MACHINE_H_
41
42 #include "top.h"
43
44 /*
45  * The statics struct is filled in by machine_init.  Fields marked as
46  * "optional" are not filled in by every module.
47  */
48 struct statics
49 {
50     char **procstate_names;
51     char **cpustate_names;
52     char **memory_names;
53     char **swap_names;          /* optional */
54     char **order_names;         /* optional */
55     char **top_color_names;     /* optional */
56     char **kernel_names;        /* optional */
57     time_t boottime;            /* optional */
58     int modemax;                /* optional */
59     struct {
60         unsigned int fullcmds : 1;
61         unsigned int idle : 1;
62         unsigned int warmup : 1;
63         unsigned int threads : 1;
64     } flags;
65 };
66
67 /*
68  * the system_info struct is filled in by a machine dependent routine.
69  */
70
71 #ifdef p_active     /* uw7 define macro p_active */
72 #define P_ACTIVE p_pactive
73 #else
74 #define P_ACTIVE p_active
75 #endif
76
77 struct system_info
78 {
79     int    last_pid;
80     double load_avg[NUM_AVERAGES];
81     int    p_total;
82     int    P_ACTIVE;     /* number of procs considered "active" */
83     int    *procstates;
84     int    *cpustates;
85     int    *kernel;
86     long   *memory;
87     long   *swap;
88 };
89
90 /* cpu_states is an array of percentages * 10.  For example, 
91    the (integer) value 105 is 10.5% (or .105).
92  */
93
94 /*
95  * the process_select struct tells get_process_info what processes we
96  * are interested in seeing
97  */
98
99 struct process_select
100 {
101     int idle;           /* show idle processes */
102     int system;         /* show system processes */
103     int fullcmd;        /* show full command */
104     int usernames;      /* show usernames */
105     int uid;            /* only this uid (unless uid == -1) */
106     char *command;      /* only this command (unless == NULL) */
107     int mode;           /* select display mode (0 is default) */
108     int threads;        /* show threads separately */
109 };
110
111 /* routines defined by the machine dependent module */
112 int machine_init(struct statics *);
113 void get_system_info(struct system_info *);
114 caddr_t get_process_info(struct system_info *, struct process_select *, int);
115 char *format_header(char *);
116 char *format_next_process(caddr_t, char *(*)(int));
117 int proc_owner(int);
118 #ifdef HAVE_FORMAT_PROCESS_HEADER
119
120 #endif /* _MACHINE_H_ */
121 char *format_process_header(struct process_select *sel, caddr_t handle, int count);
122 #endif