/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 1990, 19934* The Regents of the University of California. All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14* 3. Neither the name of the University nor the names of its contributors15* may be used to endorse or promote products derived from this software16* without specific prior written permission.17*18* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND19* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE20* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE21* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE22* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL23* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS24* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)25* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT26* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF28* SUCH DAMAGE.29*/3031#include <sys/queue.h>3233#define UNLIMITED 0 /* unlimited terminal width */34enum type { UNSPEC, /* For output routines that don't care and aliases. */35CHAR, UCHAR, SHORT, USHORT, INT, UINT, LONG, ULONG, KPTR, PGTOK };3637typedef struct kinfo_str {38STAILQ_ENTRY(kinfo_str) ks_next;39char *ks_str; /* formatted string */40} KINFO_STR;4142typedef struct kinfo {43struct kinfo_proc *ki_p; /* kinfo_proc structure */44const char *ki_args; /* exec args */45const char *ki_env; /* environment */46int ki_valid; /* 1 => uarea stuff valid */47double ki_pcpu; /* calculated in main() */48segsz_t ki_memsize; /* calculated in main() */49union {50int level; /* used in decendant_sort() */51char *prefix; /* calculated in decendant_sort() */52} ki_d;53STAILQ_HEAD(, kinfo_str) ki_ks;54} KINFO;5556/* Keywords/variables to be printed. */57typedef struct varent {58STAILQ_ENTRY(varent) next_ve;59const char *header;60const struct var *var;61u_int width;62#define VE_KEEP (1 << 0)63uint16_t flags;64} VARENT;65STAILQ_HEAD(velisthead, varent);6667struct var;68typedef struct var VAR;69/* Structure representing one available keyword. */70struct var {71const char *name; /* name(s) of variable */72union {73/* Valid field depends on RESOLVED_ALIAS' presence. */74const char *aliased; /* keyword this one is an alias to */75const VAR *final_kw; /* final aliased keyword */76};77const char *header; /* default header */78const char *field; /* xo field name */79#define COMM 0x01 /* needs exec arguments and environment (XXX) */80#define LJUST 0x02 /* left adjust on output (trailing blanks) */81#define USER 0x04 /* needs user structure */82#define INF127 0x10 /* values >127 displayed as 127 */83#define NOINHERIT 0x1000 /* Don't inherit flags from aliased keyword. */84#define RESOLVING_ALIAS 0x10000 /* Used transiently to resolve aliases. */85#define RESOLVED_ALIAS 0x20000 /* Mark that an alias has been resolved. */86u_int flag;87/* output routine */88char *(*oproc)(struct kinfo *, struct varent *);89/*90* The following (optional) elements are hooks for passing information91* to the generic output routine pvar (which prints simple elements92* from the well known kinfo_proc structure).93*/94size_t off; /* offset in structure */95enum type type; /* type of element */96const char *fmt; /* printf format (depends on output routine) */97};9899#include "extern.h"100101102