11556Srgrimes/*-
21556Srgrimes * Copyright (c) 1990, 1993
31556Srgrimes *	The Regents of the University of California.  All rights reserved.
41556Srgrimes *
51556Srgrimes * Redistribution and use in source and binary forms, with or without
61556Srgrimes * modification, are permitted provided that the following conditions
71556Srgrimes * are met:
81556Srgrimes * 1. Redistributions of source code must retain the above copyright
91556Srgrimes *    notice, this list of conditions and the following disclaimer.
101556Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111556Srgrimes *    notice, this list of conditions and the following disclaimer in the
121556Srgrimes *    documentation and/or other materials provided with the distribution.
131556Srgrimes * 4. Neither the name of the University nor the names of its contributors
141556Srgrimes *    may be used to endorse or promote products derived from this software
151556Srgrimes *    without specific prior written permission.
161556Srgrimes *
171556Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181556Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191556Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201556Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211556Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221556Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231556Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241556Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251556Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261556Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271556Srgrimes * SUCH DAMAGE.
281556Srgrimes *
291556Srgrimes *	@(#)ps.h	8.1 (Berkeley) 5/31/93
3050471Speter * $FreeBSD$
311556Srgrimes */
321556Srgrimes
33130999Sgad#include <sys/queue.h>
34130999Sgad
351556Srgrimes#define	UNLIMITED	0	/* unlimited terminal width */
36103497Sjmallettenum type { CHAR, UCHAR, SHORT, USHORT, INT, UINT, LONG, ULONG, KPTR, PGTOK };
371556Srgrimes
38225868Strasztypedef struct kinfo_str {
39225868Strasz	STAILQ_ENTRY(kinfo_str) ks_next;
40225868Strasz	char *ks_str;	/* formatted string */
41225868Strasz} KINFO_STR;
42225868Strasz
431556Srgrimestypedef struct kinfo {
4469896Smckusick	struct kinfo_proc *ki_p;	/* kinfo_proc structure */
451556Srgrimes	char *ki_args;		/* exec args */
461556Srgrimes	char *ki_env;		/* environment */
4769896Smckusick	int ki_valid;		/* 1 => uarea stuff valid */
48130816Sgad	double	 ki_pcpu;	/* calculated in main() */
49130816Sgad	segsz_t	 ki_memsize;	/* calculated in main() */
50192239Sbrian	union {
51192239Sbrian		int level;	/* used in decendant_sort() */
52192239Sbrian		char *prefix;	/* calculated in decendant_sort() */
53192239Sbrian	} ki_d;
54225868Strasz	STAILQ_HEAD(, kinfo_str) ki_ks;
551556Srgrimes} KINFO;
561556Srgrimes
571556Srgrimes/* Variables. */
581556Srgrimestypedef struct varent {
59130999Sgad	STAILQ_ENTRY(varent) next_ve;
60109504Sjmallett	const char *header;
611556Srgrimes	struct var *var;
621556Srgrimes} VARENT;
631556Srgrimes
641556Srgrimestypedef struct var {
6590143Smarkm	const char *name;	/* name(s) of variable */
6690143Smarkm	const char *header;	/* default header */
6790143Smarkm	const char *alias;	/* aliases */
681556Srgrimes#define	COMM	0x01		/* needs exec arguments and environment (XXX) */
691556Srgrimes#define	LJUST	0x02		/* left adjust on output (trailing blanks) */
701556Srgrimes#define	USER	0x04		/* needs user structure */
71113395Stjr#define	INF127	0x10		/* values >127 displayed as 127 */
721556Srgrimes	u_int	flag;
731556Srgrimes				/* output routine */
74225868Strasz	char 	*(*oproc)(struct kinfo *, struct varent *);
751556Srgrimes	/*
761556Srgrimes	 * The following (optional) elements are hooks for passing information
7769896Smckusick	 * to the generic output routine pvar (which prints simple elements
7869896Smckusick	 * from the well known kinfo_proc structure).
791556Srgrimes	 */
80104414Sbde	size_t	off;		/* offset in structure */
811556Srgrimes	enum	type type;	/* type of element */
8290143Smarkm	const char *fmt;	/* printf format */
83225868Strasz
84225868Strasz	short	width;		/* calculated width */
851556Srgrimes} VAR;
861556Srgrimes
871556Srgrimes#include "extern.h"
88