14b88c807SRodney W. Grimes /*- 2*8a16b7a1SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 3*8a16b7a1SPedro F. Giffuni * 44b88c807SRodney W. Grimes * Copyright (c) 1990, 1993 54b88c807SRodney W. Grimes * The Regents of the University of California. All rights reserved. 64b88c807SRodney W. Grimes * 74b88c807SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 84b88c807SRodney W. Grimes * modification, are permitted provided that the following conditions 94b88c807SRodney W. Grimes * are met: 104b88c807SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 114b88c807SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 124b88c807SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 134b88c807SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 144b88c807SRodney W. Grimes * documentation and/or other materials provided with the distribution. 15fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors 164b88c807SRodney W. Grimes * may be used to endorse or promote products derived from this software 174b88c807SRodney W. Grimes * without specific prior written permission. 184b88c807SRodney W. Grimes * 194b88c807SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 204b88c807SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 214b88c807SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 224b88c807SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 234b88c807SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 244b88c807SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 254b88c807SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 264b88c807SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 274b88c807SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 284b88c807SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 294b88c807SRodney W. Grimes * SUCH DAMAGE. 304b88c807SRodney W. Grimes */ 314b88c807SRodney W. Grimes 32bdf8ab46SGarance A Drosehn #include <sys/queue.h> 33bdf8ab46SGarance A Drosehn 344b88c807SRodney W. Grimes #define UNLIMITED 0 /* unlimited terminal width */ 35362d62baSJuli Mallett enum type { CHAR, UCHAR, SHORT, USHORT, INT, UINT, LONG, ULONG, KPTR, PGTOK }; 364b88c807SRodney W. Grimes 371d1143ecSEdward Tomasz Napierala typedef struct kinfo_str { 381d1143ecSEdward Tomasz Napierala STAILQ_ENTRY(kinfo_str) ks_next; 391d1143ecSEdward Tomasz Napierala char *ks_str; /* formatted string */ 401d1143ecSEdward Tomasz Napierala } KINFO_STR; 411d1143ecSEdward Tomasz Napierala 424b88c807SRodney W. Grimes typedef struct kinfo { 431f7d2501SKirk McKusick struct kinfo_proc *ki_p; /* kinfo_proc structure */ 445912ca59SDon Lewis const char *ki_args; /* exec args */ 455912ca59SDon Lewis const char *ki_env; /* environment */ 461f7d2501SKirk McKusick int ki_valid; /* 1 => uarea stuff valid */ 474bac4483SGarance A Drosehn double ki_pcpu; /* calculated in main() */ 484bac4483SGarance A Drosehn segsz_t ki_memsize; /* calculated in main() */ 49044fce53SBrian Somers union { 50044fce53SBrian Somers int level; /* used in decendant_sort() */ 51044fce53SBrian Somers char *prefix; /* calculated in decendant_sort() */ 52044fce53SBrian Somers } ki_d; 531d1143ecSEdward Tomasz Napierala STAILQ_HEAD(, kinfo_str) ki_ks; 544b88c807SRodney W. Grimes } KINFO; 554b88c807SRodney W. Grimes 564b88c807SRodney W. Grimes /* Variables. */ 574b88c807SRodney W. Grimes typedef struct varent { 58bdf8ab46SGarance A Drosehn STAILQ_ENTRY(varent) next_ve; 5978b1878aSJuli Mallett const char *header; 604b88c807SRodney W. Grimes struct var *var; 614b88c807SRodney W. Grimes } VARENT; 624b88c807SRodney W. Grimes 634b88c807SRodney W. Grimes typedef struct var { 64871e8d8cSMark Murray const char *name; /* name(s) of variable */ 65871e8d8cSMark Murray const char *header; /* default header */ 66871e8d8cSMark Murray const char *alias; /* aliases */ 678beb1a2fSMarcel Moolenaar const char *field; /* xo field name */ 684b88c807SRodney W. Grimes #define COMM 0x01 /* needs exec arguments and environment (XXX) */ 694b88c807SRodney W. Grimes #define LJUST 0x02 /* left adjust on output (trailing blanks) */ 704b88c807SRodney W. Grimes #define USER 0x04 /* needs user structure */ 71e2c9ac69STim J. Robbins #define INF127 0x10 /* values >127 displayed as 127 */ 724b88c807SRodney W. Grimes u_int flag; 734b88c807SRodney W. Grimes /* output routine */ 741d1143ecSEdward Tomasz Napierala char *(*oproc)(struct kinfo *, struct varent *); 754b88c807SRodney W. Grimes /* 764b88c807SRodney W. Grimes * The following (optional) elements are hooks for passing information 771f7d2501SKirk McKusick * to the generic output routine pvar (which prints simple elements 781f7d2501SKirk McKusick * from the well known kinfo_proc structure). 794b88c807SRodney W. Grimes */ 80bb2d6f21SBruce Evans size_t off; /* offset in structure */ 814b88c807SRodney W. Grimes enum type type; /* type of element */ 82871e8d8cSMark Murray const char *fmt; /* printf format */ 831d1143ecSEdward Tomasz Napierala 841d1143ecSEdward Tomasz Napierala short width; /* calculated width */ 854b88c807SRodney W. Grimes } VAR; 864b88c807SRodney W. Grimes 874b88c807SRodney W. Grimes #include "extern.h" 88