xref: /illumos-gate/usr/src/cmd/pgrep/psexp.h (revision 628e3cbed6489fa1db545d8524a06cd6535af456)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_PSEXP_H
28 #define	_PSEXP_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <procfs.h>
34 #include <regex.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 #include "idtab.h"
41 
42 #define	PSEXP_PSARGS	0x1	/* Match against psargs rather than fname */
43 #define	PSEXP_EXACT	0x2	/* Match must be exact (entire string) */
44 
45 typedef struct psexp {
46 	idtab_t ps_euids;	/* Table of effective uids to match */
47 	idtab_t ps_ruids;	/* Table of real uids to match */
48 	idtab_t ps_rgids;	/* Table of real gids to match */
49 	idtab_t ps_ppids;	/* Table of parent process-ids to match */
50 	idtab_t ps_pgids;	/* Table of process group-ids to match */
51 	idtab_t ps_sids;	/* Table of process session-ids to match */
52 	idtab_t ps_ttys;	/* Table of tty dev_t values to match */
53 	idtab_t ps_projids;	/* Table of project ids to match */
54 	idtab_t ps_taskids;	/* Table of task ids to match */
55 	idtab_t ps_zoneids;	/* Table of zone ids to match */
56 	idtab_t ps_ctids;	/* Table of contract ids to match */
57 	const char *ps_pat;	/* Uncompiled fname/psargs regexp pattern */
58 	regex_t ps_reg;		/* Compiled fname/psargs regexp */
59 } psexp_t;
60 
61 extern void psexp_create(psexp_t *);
62 extern void psexp_destroy(psexp_t *);
63 extern int psexp_compile(psexp_t *);
64 extern int psexp_match(psexp_t *, psinfo_t *, int);
65 
66 #ifdef	__cplusplus
67 }
68 #endif
69 
70 #endif	/* _PSEXP_H */
71