xref: /freebsd/bin/ps/ps.h (revision 044fce530f89a819827d351de364d208a30e9645)
14b88c807SRodney W. Grimes /*-
24b88c807SRodney W. Grimes  * Copyright (c) 1990, 1993
34b88c807SRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
44b88c807SRodney W. Grimes  *
54b88c807SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
64b88c807SRodney W. Grimes  * modification, are permitted provided that the following conditions
74b88c807SRodney W. Grimes  * are met:
84b88c807SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
94b88c807SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
104b88c807SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
114b88c807SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
124b88c807SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
134b88c807SRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
144b88c807SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
154b88c807SRodney W. Grimes  *    without specific prior written permission.
164b88c807SRodney W. Grimes  *
174b88c807SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
184b88c807SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
194b88c807SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
204b88c807SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
214b88c807SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
224b88c807SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
234b88c807SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
244b88c807SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
254b88c807SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
264b88c807SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
274b88c807SRodney W. Grimes  * SUCH DAMAGE.
284b88c807SRodney W. Grimes  *
294b88c807SRodney W. Grimes  *	@(#)ps.h	8.1 (Berkeley) 5/31/93
302a456239SPeter Wemm  * $FreeBSD$
314b88c807SRodney W. Grimes  */
324b88c807SRodney W. Grimes 
33bdf8ab46SGarance A Drosehn #include <sys/queue.h>
34bdf8ab46SGarance A Drosehn 
354b88c807SRodney W. Grimes #define	UNLIMITED	0	/* unlimited terminal width */
36362d62baSJuli Mallett enum type { CHAR, UCHAR, SHORT, USHORT, INT, UINT, LONG, ULONG, KPTR, PGTOK };
374b88c807SRodney W. Grimes 
384b88c807SRodney W. Grimes typedef struct kinfo {
391f7d2501SKirk McKusick 	struct kinfo_proc *ki_p;	/* kinfo_proc structure */
404b88c807SRodney W. Grimes 	char *ki_args;		/* exec args */
414b88c807SRodney W. Grimes 	char *ki_env;		/* environment */
421f7d2501SKirk McKusick 	int ki_valid;		/* 1 => uarea stuff valid */
434bac4483SGarance A Drosehn 	double	 ki_pcpu;	/* calculated in main() */
444bac4483SGarance A Drosehn 	segsz_t	 ki_memsize;	/* calculated in main() */
45044fce53SBrian Somers 	union {
46044fce53SBrian Somers 		int level;	/* used in decendant_sort() */
47044fce53SBrian Somers 		char *prefix;	/* calculated in decendant_sort() */
48044fce53SBrian Somers 	} ki_d;
494b88c807SRodney W. Grimes } KINFO;
504b88c807SRodney W. Grimes 
514b88c807SRodney W. Grimes /* Variables. */
524b88c807SRodney W. Grimes typedef struct varent {
53bdf8ab46SGarance A Drosehn 	STAILQ_ENTRY(varent) next_ve;
5478b1878aSJuli Mallett 	const char *header;
554b88c807SRodney W. Grimes 	struct var *var;
564b88c807SRodney W. Grimes } VARENT;
574b88c807SRodney W. Grimes 
584b88c807SRodney W. Grimes typedef struct var {
59871e8d8cSMark Murray 	const char *name;	/* name(s) of variable */
60871e8d8cSMark Murray 	const char *header;	/* default header */
61871e8d8cSMark Murray 	const char *alias;	/* aliases */
624b88c807SRodney W. Grimes #define	COMM	0x01		/* needs exec arguments and environment (XXX) */
634b88c807SRodney W. Grimes #define	LJUST	0x02		/* left adjust on output (trailing blanks) */
644b88c807SRodney W. Grimes #define	USER	0x04		/* needs user structure */
656a2d726bSJordan K. Hubbard #define	DSIZ	0x08		/* field size is dynamic*/
66e2c9ac69STim J. Robbins #define	INF127	0x10		/* values >127 displayed as 127 */
674b88c807SRodney W. Grimes 	u_int	flag;
684b88c807SRodney W. Grimes 				/* output routine */
6946251ddeSWarner Losh 	void	(*oproc)(struct kinfo *, struct varent *);
706a2d726bSJordan K. Hubbard 				/* sizing routine*/
7146251ddeSWarner Losh 	int	(*sproc)(struct kinfo *);
724b88c807SRodney W. Grimes 	short	width;		/* printing width */
734b88c807SRodney W. Grimes 	/*
744b88c807SRodney W. Grimes 	 * The following (optional) elements are hooks for passing information
751f7d2501SKirk McKusick 	 * to the generic output routine pvar (which prints simple elements
761f7d2501SKirk McKusick 	 * from the well known kinfo_proc structure).
774b88c807SRodney W. Grimes 	 */
78bb2d6f21SBruce Evans 	size_t	off;		/* offset in structure */
794b88c807SRodney W. Grimes 	enum	type type;	/* type of element */
80871e8d8cSMark Murray 	const char *fmt;	/* printf format */
816a2d726bSJordan K. Hubbard 	short	dwidth;		/* dynamic printing width */
824b88c807SRodney W. Grimes 	/*
834b88c807SRodney W. Grimes 	 * glue to link selected fields together
844b88c807SRodney W. Grimes 	 */
854b88c807SRodney W. Grimes } VAR;
864b88c807SRodney W. Grimes 
874b88c807SRodney W. Grimes #include "extern.h"
88