xref: /illumos-gate/usr/src/cmd/pgrep/psexp.h (revision 2a8bcb4e)
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 #include <sys/types.h>
31 #include <procfs.h>
32 #include <regex.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 #include "idtab.h"
39 
40 #define	PSEXP_PSARGS	0x1	/* Match against psargs rather than fname */
41 #define	PSEXP_EXACT	0x2	/* Match must be exact (entire string) */
42 
43 typedef struct psexp {
44 	idtab_t ps_euids;	/* Table of effective uids to match */
45 	idtab_t ps_ruids;	/* Table of real uids to match */
46 	idtab_t ps_rgids;	/* Table of real gids to match */
47 	idtab_t ps_ppids;	/* Table of parent process-ids to match */
48 	idtab_t ps_pgids;	/* Table of process group-ids to match */
49 	idtab_t ps_sids;	/* Table of process session-ids to match */
50 	idtab_t ps_ttys;	/* Table of tty dev_t values to match */
51 	idtab_t ps_projids;	/* Table of project ids to match */
52 	idtab_t ps_taskids;	/* Table of task ids to match */
53 	idtab_t ps_zoneids;	/* Table of zone ids to match */
54 	idtab_t ps_ctids;	/* Table of contract ids to match */
55 	const char *ps_pat;	/* Uncompiled fname/psargs regexp pattern */
56 	regex_t ps_reg;		/* Compiled fname/psargs regexp */
57 } psexp_t;
58 
59 extern void psexp_create(psexp_t *);
60 extern void psexp_destroy(psexp_t *);
61 extern int psexp_compile(psexp_t *);
62 extern int psexp_match(psexp_t *, psinfo_t *, int);
63 
64 #ifdef	__cplusplus
65 }
66 #endif
67 
68 #endif	/* _PSEXP_H */
69