xref: /illumos-gate/usr/src/cmd/truss/listopts.c (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.2	*/
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate #include <stdio.h>
34*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
35*7c478bd9Sstevel@tonic-gate #include <unistd.h>
36*7c478bd9Sstevel@tonic-gate #include <ctype.h>
37*7c478bd9Sstevel@tonic-gate #include <string.h>
38*7c478bd9Sstevel@tonic-gate #include <memory.h>
39*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
40*7c478bd9Sstevel@tonic-gate #include <signal.h>
41*7c478bd9Sstevel@tonic-gate #include <libproc.h>
42*7c478bd9Sstevel@tonic-gate #include "ramdata.h"
43*7c478bd9Sstevel@tonic-gate #include "systable.h"
44*7c478bd9Sstevel@tonic-gate #include "proto.h"
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate /* XXX A bug in the <string.h> header file requires this */
47*7c478bd9Sstevel@tonic-gate extern char *strtok_r(char *s1, const char *s2, char **lasts);
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate /*
50*7c478bd9Sstevel@tonic-gate  * option procesing ---
51*7c478bd9Sstevel@tonic-gate  * Routines for scanning syscall, signal, fault
52*7c478bd9Sstevel@tonic-gate  * and file descriptor lists.
53*7c478bd9Sstevel@tonic-gate  */
54*7c478bd9Sstevel@tonic-gate 
55*7c478bd9Sstevel@tonic-gate /*
56*7c478bd9Sstevel@tonic-gate  * Function prototypes for static routines in this module.
57*7c478bd9Sstevel@tonic-gate  */
58*7c478bd9Sstevel@tonic-gate void	upcase(char *);
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate const char white[] = " \t\n";	/* white space characters */
61*7c478bd9Sstevel@tonic-gate const char sepr[] = " ,\t\n";	/* list separator characters */
62*7c478bd9Sstevel@tonic-gate const char csepr[] = " :,\t\n";	/* same, with ':' added */
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate /*
65*7c478bd9Sstevel@tonic-gate  * Scan list of syscall names.
66*7c478bd9Sstevel@tonic-gate  * Return 0 on success, != 0 on any failure.
67*7c478bd9Sstevel@tonic-gate  */
68*7c478bd9Sstevel@tonic-gate int
69*7c478bd9Sstevel@tonic-gate syslist(char *str,			/* string of syscall names */
70*7c478bd9Sstevel@tonic-gate 	sysset_t *setp,			/* syscall set */
71*7c478bd9Sstevel@tonic-gate 	int *fp)			/* first-time flag */
72*7c478bd9Sstevel@tonic-gate {
73*7c478bd9Sstevel@tonic-gate 	char *name;
74*7c478bd9Sstevel@tonic-gate 	int exclude = FALSE;
75*7c478bd9Sstevel@tonic-gate 	int rc = 0;
76*7c478bd9Sstevel@tonic-gate 	char *lasts;
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate 	name = strtok_r(str, sepr, &lasts);
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate 	if (name != NULL && *name == '!') {	/* exclude from set */
81*7c478bd9Sstevel@tonic-gate 		exclude = TRUE;
82*7c478bd9Sstevel@tonic-gate 		if (*++name == '\0')
83*7c478bd9Sstevel@tonic-gate 			name = strtok_r(NULL, sepr, &lasts);
84*7c478bd9Sstevel@tonic-gate 	} else if (!*fp) {	/* first time, clear the set */
85*7c478bd9Sstevel@tonic-gate 		premptyset(setp);
86*7c478bd9Sstevel@tonic-gate 		*fp = TRUE;
87*7c478bd9Sstevel@tonic-gate 	}
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate 	for (; name; name = strtok_r(NULL, sepr, &lasts)) {
90*7c478bd9Sstevel@tonic-gate 		int sys;
91*7c478bd9Sstevel@tonic-gate 		int sysx;
92*7c478bd9Sstevel@tonic-gate 		int sys64;
93*7c478bd9Sstevel@tonic-gate 		char *next;
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate 		if (*name == '!') {	/* exclude remainder from set */
96*7c478bd9Sstevel@tonic-gate 			exclude = TRUE;
97*7c478bd9Sstevel@tonic-gate 			while (*++name == '!')
98*7c478bd9Sstevel@tonic-gate 				/* empty */;
99*7c478bd9Sstevel@tonic-gate 			if (*name == '\0')
100*7c478bd9Sstevel@tonic-gate 				continue;
101*7c478bd9Sstevel@tonic-gate 		}
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate 		sys = strtol(name, &next, 0);
104*7c478bd9Sstevel@tonic-gate 		sysx = sys64 = 0;
105*7c478bd9Sstevel@tonic-gate 		if (sys < 0 || sys > PRMAXSYS || *next != '\0')
106*7c478bd9Sstevel@tonic-gate 			sys = 0;
107*7c478bd9Sstevel@tonic-gate 		if (sys == 0) {
108*7c478bd9Sstevel@tonic-gate 			const struct systable *stp = systable;
109*7c478bd9Sstevel@tonic-gate 			for (; sys == 0 && stp->nargs >= 0; stp++)
110*7c478bd9Sstevel@tonic-gate 				if (stp->name && strcmp(stp->name, name) == 0)
111*7c478bd9Sstevel@tonic-gate 					sys = stp-systable;
112*7c478bd9Sstevel@tonic-gate 		}
113*7c478bd9Sstevel@tonic-gate 		if (sys == 0) {
114*7c478bd9Sstevel@tonic-gate 			const struct sysalias *sap = sysalias;
115*7c478bd9Sstevel@tonic-gate 			for (; sys == 0 && sap->name; sap++)
116*7c478bd9Sstevel@tonic-gate 				if (strcmp(sap->name, name) == 0)
117*7c478bd9Sstevel@tonic-gate 					sys = sap->number;
118*7c478bd9Sstevel@tonic-gate 		}
119*7c478bd9Sstevel@tonic-gate 		if (sys > 0 && sys <= PRMAXSYS) {
120*7c478bd9Sstevel@tonic-gate 			switch (sys) {
121*7c478bd9Sstevel@tonic-gate 			case SYS_xstat:		/* set all if any */
122*7c478bd9Sstevel@tonic-gate 			case SYS_stat:
123*7c478bd9Sstevel@tonic-gate 			case SYS_stat64:
124*7c478bd9Sstevel@tonic-gate 				sys = SYS_stat;
125*7c478bd9Sstevel@tonic-gate 				sysx = SYS_xstat;
126*7c478bd9Sstevel@tonic-gate 				sys64 = SYS_stat64;
127*7c478bd9Sstevel@tonic-gate 				goto def;
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate 			case SYS_lxstat:	/* set all if any */
130*7c478bd9Sstevel@tonic-gate 			case SYS_lstat:
131*7c478bd9Sstevel@tonic-gate 			case SYS_lstat64:
132*7c478bd9Sstevel@tonic-gate 				sys = SYS_lstat;
133*7c478bd9Sstevel@tonic-gate 				sysx = SYS_lxstat;
134*7c478bd9Sstevel@tonic-gate 				sys64 = SYS_lstat64;
135*7c478bd9Sstevel@tonic-gate 				goto def;
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate 			case SYS_fxstat:	/* set all if any */
138*7c478bd9Sstevel@tonic-gate 			case SYS_fstat:
139*7c478bd9Sstevel@tonic-gate 			case SYS_fstat64:
140*7c478bd9Sstevel@tonic-gate 				sys = SYS_fstat;
141*7c478bd9Sstevel@tonic-gate 				sysx = SYS_fxstat;
142*7c478bd9Sstevel@tonic-gate 				sys64 = SYS_fstat64;
143*7c478bd9Sstevel@tonic-gate 				goto def;
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate 			case SYS_getdents:	/* set both if either */
146*7c478bd9Sstevel@tonic-gate 			case SYS_getdents64:
147*7c478bd9Sstevel@tonic-gate 				sys = SYS_getdents;
148*7c478bd9Sstevel@tonic-gate 				sys64 = SYS_getdents64;
149*7c478bd9Sstevel@tonic-gate 				goto def;
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate 			case SYS_mmap:		/* set both if either */
152*7c478bd9Sstevel@tonic-gate 			case SYS_mmap64:
153*7c478bd9Sstevel@tonic-gate 				sys = SYS_mmap;
154*7c478bd9Sstevel@tonic-gate 				sys64 = SYS_mmap64;
155*7c478bd9Sstevel@tonic-gate 				goto def;
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate 			case SYS_statvfs:	/* set both if either */
158*7c478bd9Sstevel@tonic-gate 			case SYS_statvfs64:
159*7c478bd9Sstevel@tonic-gate 				sys = SYS_statvfs;
160*7c478bd9Sstevel@tonic-gate 				sys64 = SYS_statvfs64;
161*7c478bd9Sstevel@tonic-gate 				goto def;
162*7c478bd9Sstevel@tonic-gate 
163*7c478bd9Sstevel@tonic-gate 			case SYS_fstatvfs:	/* set both if either */
164*7c478bd9Sstevel@tonic-gate 			case SYS_fstatvfs64:
165*7c478bd9Sstevel@tonic-gate 				sys = SYS_fstatvfs;
166*7c478bd9Sstevel@tonic-gate 				sys64 = SYS_fstatvfs64;
167*7c478bd9Sstevel@tonic-gate 				goto def;
168*7c478bd9Sstevel@tonic-gate 
169*7c478bd9Sstevel@tonic-gate 			case SYS_setrlimit:	/* set both if either */
170*7c478bd9Sstevel@tonic-gate 			case SYS_setrlimit64:
171*7c478bd9Sstevel@tonic-gate 				sys = SYS_setrlimit;
172*7c478bd9Sstevel@tonic-gate 				sys64 = SYS_setrlimit64;
173*7c478bd9Sstevel@tonic-gate 				goto def;
174*7c478bd9Sstevel@tonic-gate 
175*7c478bd9Sstevel@tonic-gate 			case SYS_getrlimit:	/* set both if either */
176*7c478bd9Sstevel@tonic-gate 			case SYS_getrlimit64:
177*7c478bd9Sstevel@tonic-gate 				sys = SYS_getrlimit;
178*7c478bd9Sstevel@tonic-gate 				sys64 = SYS_getrlimit64;
179*7c478bd9Sstevel@tonic-gate 				goto def;
180*7c478bd9Sstevel@tonic-gate 
181*7c478bd9Sstevel@tonic-gate 			case SYS_pread:		/* set both if either */
182*7c478bd9Sstevel@tonic-gate 			case SYS_pread64:
183*7c478bd9Sstevel@tonic-gate 				sys = SYS_pread;
184*7c478bd9Sstevel@tonic-gate 				sys64 = SYS_pread64;
185*7c478bd9Sstevel@tonic-gate 				goto def;
186*7c478bd9Sstevel@tonic-gate 
187*7c478bd9Sstevel@tonic-gate 			case SYS_pwrite:	/* set both if either */
188*7c478bd9Sstevel@tonic-gate 			case SYS_pwrite64:
189*7c478bd9Sstevel@tonic-gate 				sys = SYS_pwrite;
190*7c478bd9Sstevel@tonic-gate 				sys64 = SYS_pwrite64;
191*7c478bd9Sstevel@tonic-gate 				goto def;
192*7c478bd9Sstevel@tonic-gate 
193*7c478bd9Sstevel@tonic-gate 			case SYS_creat:		/* set both if either */
194*7c478bd9Sstevel@tonic-gate 			case SYS_creat64:
195*7c478bd9Sstevel@tonic-gate 				sys = SYS_creat;
196*7c478bd9Sstevel@tonic-gate 				sys64 = SYS_creat64;
197*7c478bd9Sstevel@tonic-gate 				goto def;
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate 			case SYS_open:		/* set both if either */
200*7c478bd9Sstevel@tonic-gate 			case SYS_open64:
201*7c478bd9Sstevel@tonic-gate 				sys = SYS_open;
202*7c478bd9Sstevel@tonic-gate 				sys64 = SYS_open64;
203*7c478bd9Sstevel@tonic-gate 				goto def;
204*7c478bd9Sstevel@tonic-gate 
205*7c478bd9Sstevel@tonic-gate 			case SYS_xmknod:	/* set both if either */
206*7c478bd9Sstevel@tonic-gate 			case SYS_mknod:
207*7c478bd9Sstevel@tonic-gate 				sysx = SYS_xmknod;
208*7c478bd9Sstevel@tonic-gate 				sys = SYS_mknod;
209*7c478bd9Sstevel@tonic-gate 				goto def;
210*7c478bd9Sstevel@tonic-gate 
211*7c478bd9Sstevel@tonic-gate 			case SYS_forkall:	/* set all if any */
212*7c478bd9Sstevel@tonic-gate 			case SYS_fork1:
213*7c478bd9Sstevel@tonic-gate 			case SYS_vfork:
214*7c478bd9Sstevel@tonic-gate 				sys = SYS_forkall;
215*7c478bd9Sstevel@tonic-gate 				sysx = SYS_fork1;
216*7c478bd9Sstevel@tonic-gate 				sys64 = SYS_vfork;
217*7c478bd9Sstevel@tonic-gate 				goto def;
218*7c478bd9Sstevel@tonic-gate 
219*7c478bd9Sstevel@tonic-gate 			case SYS_exec:		/* set both if either */
220*7c478bd9Sstevel@tonic-gate 			case SYS_execve:
221*7c478bd9Sstevel@tonic-gate 				sysx = SYS_exec;
222*7c478bd9Sstevel@tonic-gate 				sys = SYS_execve;
223*7c478bd9Sstevel@tonic-gate 				goto def;
224*7c478bd9Sstevel@tonic-gate 
225*7c478bd9Sstevel@tonic-gate 			case SYS_poll:		/* set both if either */
226*7c478bd9Sstevel@tonic-gate 			case SYS_pollsys:
227*7c478bd9Sstevel@tonic-gate 				sysx = SYS_poll;
228*7c478bd9Sstevel@tonic-gate 				sys = SYS_pollsys;
229*7c478bd9Sstevel@tonic-gate 				goto def;
230*7c478bd9Sstevel@tonic-gate 
231*7c478bd9Sstevel@tonic-gate 			case SYS_sigprocmask:	/* set both if either */
232*7c478bd9Sstevel@tonic-gate 			case SYS_lwp_sigmask:
233*7c478bd9Sstevel@tonic-gate 				sysx = SYS_sigprocmask;
234*7c478bd9Sstevel@tonic-gate 				sys = SYS_lwp_sigmask;
235*7c478bd9Sstevel@tonic-gate 				goto def;
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate 			case SYS_wait:		/* set both if either */
238*7c478bd9Sstevel@tonic-gate 			case SYS_waitsys:
239*7c478bd9Sstevel@tonic-gate 				sysx = SYS_wait;
240*7c478bd9Sstevel@tonic-gate 				sys = SYS_waitsys;
241*7c478bd9Sstevel@tonic-gate 				goto def;
242*7c478bd9Sstevel@tonic-gate 
243*7c478bd9Sstevel@tonic-gate 			case SYS_lseek:		/* set both if either */
244*7c478bd9Sstevel@tonic-gate 			case SYS_llseek:
245*7c478bd9Sstevel@tonic-gate 				sysx = SYS_lseek;
246*7c478bd9Sstevel@tonic-gate 				sys = SYS_llseek;
247*7c478bd9Sstevel@tonic-gate 				goto def;
248*7c478bd9Sstevel@tonic-gate 
249*7c478bd9Sstevel@tonic-gate 			case SYS_lwp_mutex_lock: /* set both if either */
250*7c478bd9Sstevel@tonic-gate 			case SYS_lwp_mutex_timedlock:
251*7c478bd9Sstevel@tonic-gate 				sysx = SYS_lwp_mutex_lock;
252*7c478bd9Sstevel@tonic-gate 				sys = SYS_lwp_mutex_timedlock;
253*7c478bd9Sstevel@tonic-gate 				goto def;
254*7c478bd9Sstevel@tonic-gate 
255*7c478bd9Sstevel@tonic-gate 			case SYS_lwp_sema_wait: /* set both if either */
256*7c478bd9Sstevel@tonic-gate 			case SYS_lwp_sema_timedwait:
257*7c478bd9Sstevel@tonic-gate 				sysx = SYS_lwp_sema_wait;
258*7c478bd9Sstevel@tonic-gate 				sys = SYS_lwp_sema_timedwait;
259*7c478bd9Sstevel@tonic-gate 				goto def;
260*7c478bd9Sstevel@tonic-gate 
261*7c478bd9Sstevel@tonic-gate 			default:
262*7c478bd9Sstevel@tonic-gate 			def:
263*7c478bd9Sstevel@tonic-gate 				if (exclude) {
264*7c478bd9Sstevel@tonic-gate 					prdelset(setp, sys);
265*7c478bd9Sstevel@tonic-gate 					if (sysx)
266*7c478bd9Sstevel@tonic-gate 						prdelset(setp, sysx);
267*7c478bd9Sstevel@tonic-gate 					if (sys64)
268*7c478bd9Sstevel@tonic-gate 						prdelset(setp, sys64);
269*7c478bd9Sstevel@tonic-gate 				} else {
270*7c478bd9Sstevel@tonic-gate 					praddset(setp, sys);
271*7c478bd9Sstevel@tonic-gate 					if (sysx)
272*7c478bd9Sstevel@tonic-gate 						praddset(setp, sysx);
273*7c478bd9Sstevel@tonic-gate 					if (sys64)
274*7c478bd9Sstevel@tonic-gate 						praddset(setp, sys64);
275*7c478bd9Sstevel@tonic-gate 				}
276*7c478bd9Sstevel@tonic-gate 				break;
277*7c478bd9Sstevel@tonic-gate 			}
278*7c478bd9Sstevel@tonic-gate 		} else if (strcmp(name, "all") == 0 ||
279*7c478bd9Sstevel@tonic-gate 		    strcmp(name, "ALL") == 0) {
280*7c478bd9Sstevel@tonic-gate 			if (exclude) {
281*7c478bd9Sstevel@tonic-gate 				premptyset(setp);
282*7c478bd9Sstevel@tonic-gate 			} else {
283*7c478bd9Sstevel@tonic-gate 				prfillset(setp);
284*7c478bd9Sstevel@tonic-gate 			}
285*7c478bd9Sstevel@tonic-gate 		} else {
286*7c478bd9Sstevel@tonic-gate 			(void) fprintf(stderr,
287*7c478bd9Sstevel@tonic-gate 				"%s: unrecognized syscall: %s\n",
288*7c478bd9Sstevel@tonic-gate 				command, name);
289*7c478bd9Sstevel@tonic-gate 			rc = -1;
290*7c478bd9Sstevel@tonic-gate 		}
291*7c478bd9Sstevel@tonic-gate 	}
292*7c478bd9Sstevel@tonic-gate 
293*7c478bd9Sstevel@tonic-gate 	return (rc);
294*7c478bd9Sstevel@tonic-gate }
295*7c478bd9Sstevel@tonic-gate 
296*7c478bd9Sstevel@tonic-gate /*
297*7c478bd9Sstevel@tonic-gate  * List of signals to trace.
298*7c478bd9Sstevel@tonic-gate  * Return 0 on success, != 0 on any failure.
299*7c478bd9Sstevel@tonic-gate  */
300*7c478bd9Sstevel@tonic-gate int
301*7c478bd9Sstevel@tonic-gate siglist(private_t *pri,
302*7c478bd9Sstevel@tonic-gate 	char *str,			/* string of signal names */
303*7c478bd9Sstevel@tonic-gate 	sigset_t *setp,			/* signal set */
304*7c478bd9Sstevel@tonic-gate 	int *fp)			/* first-time flag */
305*7c478bd9Sstevel@tonic-gate {
306*7c478bd9Sstevel@tonic-gate 	char *name;
307*7c478bd9Sstevel@tonic-gate 	int exclude = FALSE;
308*7c478bd9Sstevel@tonic-gate 	int rc = 0;
309*7c478bd9Sstevel@tonic-gate 	char *lasts;
310*7c478bd9Sstevel@tonic-gate 
311*7c478bd9Sstevel@tonic-gate 	upcase(str);
312*7c478bd9Sstevel@tonic-gate 	name = strtok_r(str, sepr, &lasts);
313*7c478bd9Sstevel@tonic-gate 
314*7c478bd9Sstevel@tonic-gate 	if (name != NULL && *name == '!') {	/* exclude from set */
315*7c478bd9Sstevel@tonic-gate 		exclude = TRUE;
316*7c478bd9Sstevel@tonic-gate 		if (*++name == '\0')
317*7c478bd9Sstevel@tonic-gate 			name = strtok_r(NULL, sepr, &lasts);
318*7c478bd9Sstevel@tonic-gate 	} else if (!*fp) {	/* first time, clear the set */
319*7c478bd9Sstevel@tonic-gate 		premptyset(setp);
320*7c478bd9Sstevel@tonic-gate 		*fp = TRUE;
321*7c478bd9Sstevel@tonic-gate 	}
322*7c478bd9Sstevel@tonic-gate 
323*7c478bd9Sstevel@tonic-gate 	for (; name; name = strtok_r(NULL, sepr, &lasts)) {
324*7c478bd9Sstevel@tonic-gate 		int sig;
325*7c478bd9Sstevel@tonic-gate 		char *next;
326*7c478bd9Sstevel@tonic-gate 
327*7c478bd9Sstevel@tonic-gate 		if (*name == '!') {	/* exclude remainder from set */
328*7c478bd9Sstevel@tonic-gate 			exclude = TRUE;
329*7c478bd9Sstevel@tonic-gate 			while (*++name == '!')
330*7c478bd9Sstevel@tonic-gate 				/* empty */;
331*7c478bd9Sstevel@tonic-gate 			if (*name == '\0')
332*7c478bd9Sstevel@tonic-gate 				continue;
333*7c478bd9Sstevel@tonic-gate 		}
334*7c478bd9Sstevel@tonic-gate 
335*7c478bd9Sstevel@tonic-gate 		sig = strtol(name, &next, 0);
336*7c478bd9Sstevel@tonic-gate 		if (sig <= 0 || sig > PRMAXSIG || *next != '\0') {
337*7c478bd9Sstevel@tonic-gate 			for (sig = 1; sig <= PRMAXSIG; sig++) {
338*7c478bd9Sstevel@tonic-gate 				const char *sname = rawsigname(pri, sig);
339*7c478bd9Sstevel@tonic-gate 				if (sname == NULL)
340*7c478bd9Sstevel@tonic-gate 					continue;
341*7c478bd9Sstevel@tonic-gate 				if (strcmp(sname, name) == 0 ||
342*7c478bd9Sstevel@tonic-gate 				    strcmp(sname+3, name) == 0)
343*7c478bd9Sstevel@tonic-gate 					break;
344*7c478bd9Sstevel@tonic-gate 			}
345*7c478bd9Sstevel@tonic-gate 			if (sig > PRMAXSIG)
346*7c478bd9Sstevel@tonic-gate 				sig = 0;
347*7c478bd9Sstevel@tonic-gate 		}
348*7c478bd9Sstevel@tonic-gate 		if (sig > 0 && sig <= PRMAXSIG) {
349*7c478bd9Sstevel@tonic-gate 			if (exclude) {
350*7c478bd9Sstevel@tonic-gate 				prdelset(setp, sig);
351*7c478bd9Sstevel@tonic-gate 			} else {
352*7c478bd9Sstevel@tonic-gate 				praddset(setp, sig);
353*7c478bd9Sstevel@tonic-gate 			}
354*7c478bd9Sstevel@tonic-gate 		} else if (strcmp(name, "ALL") == 0) {
355*7c478bd9Sstevel@tonic-gate 			if (exclude) {
356*7c478bd9Sstevel@tonic-gate 				premptyset(setp);
357*7c478bd9Sstevel@tonic-gate 			} else {
358*7c478bd9Sstevel@tonic-gate 				prfillset(setp);
359*7c478bd9Sstevel@tonic-gate 			}
360*7c478bd9Sstevel@tonic-gate 		} else {
361*7c478bd9Sstevel@tonic-gate 			(void) fprintf(stderr,
362*7c478bd9Sstevel@tonic-gate 				"%s: unrecognized signal name/number: %s\n",
363*7c478bd9Sstevel@tonic-gate 				command, name);
364*7c478bd9Sstevel@tonic-gate 			rc = -1;
365*7c478bd9Sstevel@tonic-gate 		}
366*7c478bd9Sstevel@tonic-gate 	}
367*7c478bd9Sstevel@tonic-gate 
368*7c478bd9Sstevel@tonic-gate 	return (rc);
369*7c478bd9Sstevel@tonic-gate }
370*7c478bd9Sstevel@tonic-gate 
371*7c478bd9Sstevel@tonic-gate /*
372*7c478bd9Sstevel@tonic-gate  * List of faults to trace.
373*7c478bd9Sstevel@tonic-gate  * return 0 on success, != 0 on any failure.
374*7c478bd9Sstevel@tonic-gate  */
375*7c478bd9Sstevel@tonic-gate int
376*7c478bd9Sstevel@tonic-gate fltlist(char *str,			/* string of fault names */
377*7c478bd9Sstevel@tonic-gate 	fltset_t *setp,			/* fault set */
378*7c478bd9Sstevel@tonic-gate 	int *fp)			/* first-time flag */
379*7c478bd9Sstevel@tonic-gate {
380*7c478bd9Sstevel@tonic-gate 	char *name;
381*7c478bd9Sstevel@tonic-gate 	int exclude = FALSE;
382*7c478bd9Sstevel@tonic-gate 	int rc = 0;
383*7c478bd9Sstevel@tonic-gate 	char *lasts;
384*7c478bd9Sstevel@tonic-gate 
385*7c478bd9Sstevel@tonic-gate 	upcase(str);
386*7c478bd9Sstevel@tonic-gate 	name = strtok_r(str, sepr, &lasts);
387*7c478bd9Sstevel@tonic-gate 
388*7c478bd9Sstevel@tonic-gate 	if (name != NULL && *name == '!') {	/* exclude from set */
389*7c478bd9Sstevel@tonic-gate 		exclude = TRUE;
390*7c478bd9Sstevel@tonic-gate 		if (*++name == '\0')
391*7c478bd9Sstevel@tonic-gate 			name = strtok_r(NULL, sepr, &lasts);
392*7c478bd9Sstevel@tonic-gate 	} else if (!*fp) {	/* first time, clear the set */
393*7c478bd9Sstevel@tonic-gate 		premptyset(setp);
394*7c478bd9Sstevel@tonic-gate 		*fp = TRUE;
395*7c478bd9Sstevel@tonic-gate 	}
396*7c478bd9Sstevel@tonic-gate 
397*7c478bd9Sstevel@tonic-gate 	for (; name; name = strtok_r(NULL, sepr, &lasts)) {
398*7c478bd9Sstevel@tonic-gate 		int flt;
399*7c478bd9Sstevel@tonic-gate 		char *next;
400*7c478bd9Sstevel@tonic-gate 
401*7c478bd9Sstevel@tonic-gate 		if (*name == '!') {	/* exclude remainder from set */
402*7c478bd9Sstevel@tonic-gate 			exclude = TRUE;
403*7c478bd9Sstevel@tonic-gate 			while (*++name == '!')
404*7c478bd9Sstevel@tonic-gate 				/* empty */;
405*7c478bd9Sstevel@tonic-gate 			if (*name == '\0')
406*7c478bd9Sstevel@tonic-gate 				continue;
407*7c478bd9Sstevel@tonic-gate 		}
408*7c478bd9Sstevel@tonic-gate 
409*7c478bd9Sstevel@tonic-gate 		flt = strtol(name, &next, 0);
410*7c478bd9Sstevel@tonic-gate 		if (flt <= 0 || flt > PRMAXFAULT || *next != '\0') {
411*7c478bd9Sstevel@tonic-gate 			for (flt = 1; flt <= PRMAXFAULT; flt++) {
412*7c478bd9Sstevel@tonic-gate 				char fname[32];
413*7c478bd9Sstevel@tonic-gate 
414*7c478bd9Sstevel@tonic-gate 				if (proc_fltname(flt, fname,
415*7c478bd9Sstevel@tonic-gate 				    sizeof (fname)) == NULL)
416*7c478bd9Sstevel@tonic-gate 					continue;
417*7c478bd9Sstevel@tonic-gate 
418*7c478bd9Sstevel@tonic-gate 				if (strcmp(fname, name) == 0 ||
419*7c478bd9Sstevel@tonic-gate 				    strcmp(fname+3, name) == 0)
420*7c478bd9Sstevel@tonic-gate 					break;
421*7c478bd9Sstevel@tonic-gate 			}
422*7c478bd9Sstevel@tonic-gate 			if (flt > PRMAXFAULT)
423*7c478bd9Sstevel@tonic-gate 				flt = 0;
424*7c478bd9Sstevel@tonic-gate 		}
425*7c478bd9Sstevel@tonic-gate 		if (flt > 0 && flt <= PRMAXFAULT) {
426*7c478bd9Sstevel@tonic-gate 			if (exclude) {
427*7c478bd9Sstevel@tonic-gate 				prdelset(setp, flt);
428*7c478bd9Sstevel@tonic-gate 			} else {
429*7c478bd9Sstevel@tonic-gate 				praddset(setp, flt);
430*7c478bd9Sstevel@tonic-gate 			}
431*7c478bd9Sstevel@tonic-gate 		} else if (strcmp(name, "ALL") == 0) {
432*7c478bd9Sstevel@tonic-gate 			if (exclude) {
433*7c478bd9Sstevel@tonic-gate 				premptyset(setp);
434*7c478bd9Sstevel@tonic-gate 			} else {
435*7c478bd9Sstevel@tonic-gate 				prfillset(setp);
436*7c478bd9Sstevel@tonic-gate 			}
437*7c478bd9Sstevel@tonic-gate 		} else {
438*7c478bd9Sstevel@tonic-gate 			(void) fprintf(stderr,
439*7c478bd9Sstevel@tonic-gate 				"%s: unrecognized fault name/number: %s\n",
440*7c478bd9Sstevel@tonic-gate 				command, name);
441*7c478bd9Sstevel@tonic-gate 			rc = -1;
442*7c478bd9Sstevel@tonic-gate 		}
443*7c478bd9Sstevel@tonic-gate 	}
444*7c478bd9Sstevel@tonic-gate 
445*7c478bd9Sstevel@tonic-gate 	return (rc);
446*7c478bd9Sstevel@tonic-gate }
447*7c478bd9Sstevel@tonic-gate 
448*7c478bd9Sstevel@tonic-gate /*
449*7c478bd9Sstevel@tonic-gate  * Gather file descriptors to dump.
450*7c478bd9Sstevel@tonic-gate  * Return 0 on success, != 0 on any failure.
451*7c478bd9Sstevel@tonic-gate  */
452*7c478bd9Sstevel@tonic-gate int
453*7c478bd9Sstevel@tonic-gate fdlist(char *str,		/* string of filedescriptors */
454*7c478bd9Sstevel@tonic-gate 	fileset_t *setp)	/* set of boolean flags */
455*7c478bd9Sstevel@tonic-gate {
456*7c478bd9Sstevel@tonic-gate 	char *name;
457*7c478bd9Sstevel@tonic-gate 	int exclude = FALSE;
458*7c478bd9Sstevel@tonic-gate 	int rc = 0;
459*7c478bd9Sstevel@tonic-gate 	char *lasts;
460*7c478bd9Sstevel@tonic-gate 
461*7c478bd9Sstevel@tonic-gate 	upcase(str);
462*7c478bd9Sstevel@tonic-gate 	name = strtok_r(str, sepr, &lasts);
463*7c478bd9Sstevel@tonic-gate 
464*7c478bd9Sstevel@tonic-gate 	if (name != NULL && *name == '!') {	/* exclude from set */
465*7c478bd9Sstevel@tonic-gate 		exclude = TRUE;
466*7c478bd9Sstevel@tonic-gate 		if (*++name == '\0')
467*7c478bd9Sstevel@tonic-gate 			name = strtok_r(NULL, sepr, &lasts);
468*7c478bd9Sstevel@tonic-gate 	}
469*7c478bd9Sstevel@tonic-gate 
470*7c478bd9Sstevel@tonic-gate 	for (; name; name = strtok_r(NULL, sepr, &lasts)) {
471*7c478bd9Sstevel@tonic-gate 		int fd;
472*7c478bd9Sstevel@tonic-gate 		char *next;
473*7c478bd9Sstevel@tonic-gate 
474*7c478bd9Sstevel@tonic-gate 		if (*name == '!') {	/* exclude remainder from set */
475*7c478bd9Sstevel@tonic-gate 			exclude = TRUE;
476*7c478bd9Sstevel@tonic-gate 			while (*++name == '!')
477*7c478bd9Sstevel@tonic-gate 				/* empty */;
478*7c478bd9Sstevel@tonic-gate 			if (*name == '\0')
479*7c478bd9Sstevel@tonic-gate 				continue;
480*7c478bd9Sstevel@tonic-gate 		}
481*7c478bd9Sstevel@tonic-gate 
482*7c478bd9Sstevel@tonic-gate 		fd = strtol(name, &next, 0);
483*7c478bd9Sstevel@tonic-gate 		if (fd >= 0 && fd < NOFILES_MAX && *next == '\0') {
484*7c478bd9Sstevel@tonic-gate 			fd++;
485*7c478bd9Sstevel@tonic-gate 			if (exclude) {
486*7c478bd9Sstevel@tonic-gate 				prdelset(setp, fd);
487*7c478bd9Sstevel@tonic-gate 			} else {
488*7c478bd9Sstevel@tonic-gate 				praddset(setp, fd);
489*7c478bd9Sstevel@tonic-gate 			}
490*7c478bd9Sstevel@tonic-gate 		} else if (strcmp(name, "ALL") == 0) {
491*7c478bd9Sstevel@tonic-gate 			if (exclude) {
492*7c478bd9Sstevel@tonic-gate 				premptyset(setp);
493*7c478bd9Sstevel@tonic-gate 			} else {
494*7c478bd9Sstevel@tonic-gate 				prfillset(setp);
495*7c478bd9Sstevel@tonic-gate 			}
496*7c478bd9Sstevel@tonic-gate 		} else {
497*7c478bd9Sstevel@tonic-gate 			(void) fprintf(stderr,
498*7c478bd9Sstevel@tonic-gate 				"%s: filedescriptor not in range[0..%d]: %s\n",
499*7c478bd9Sstevel@tonic-gate 				command, NOFILES_MAX-1, name);
500*7c478bd9Sstevel@tonic-gate 			rc = -1;
501*7c478bd9Sstevel@tonic-gate 		}
502*7c478bd9Sstevel@tonic-gate 	}
503*7c478bd9Sstevel@tonic-gate 
504*7c478bd9Sstevel@tonic-gate 	return (rc);
505*7c478bd9Sstevel@tonic-gate }
506*7c478bd9Sstevel@tonic-gate 
507*7c478bd9Sstevel@tonic-gate void
508*7c478bd9Sstevel@tonic-gate upcase(char *str)
509*7c478bd9Sstevel@tonic-gate {
510*7c478bd9Sstevel@tonic-gate 	int c;
511*7c478bd9Sstevel@tonic-gate 
512*7c478bd9Sstevel@tonic-gate 	while ((c = *str) != '\0')
513*7c478bd9Sstevel@tonic-gate 		*str++ = toupper(c);
514*7c478bd9Sstevel@tonic-gate }
515*7c478bd9Sstevel@tonic-gate 
516*7c478bd9Sstevel@tonic-gate /*
517*7c478bd9Sstevel@tonic-gate  * 'arg' points to a string like:
518*7c478bd9Sstevel@tonic-gate  *	libc,libnsl,... : printf,read,write,...
519*7c478bd9Sstevel@tonic-gate  * or
520*7c478bd9Sstevel@tonic-gate  *	libc,libnsl,... :: printf,read,write,...
521*7c478bd9Sstevel@tonic-gate  * with possible filename pattern-matching metacharacters.
522*7c478bd9Sstevel@tonic-gate  *
523*7c478bd9Sstevel@tonic-gate  * Assumption:  No library or function name can contain ',' or ':'.
524*7c478bd9Sstevel@tonic-gate  */
525*7c478bd9Sstevel@tonic-gate int
526*7c478bd9Sstevel@tonic-gate liblist(char *arg, int hang)
527*7c478bd9Sstevel@tonic-gate {
528*7c478bd9Sstevel@tonic-gate 	const char *star = "*";
529*7c478bd9Sstevel@tonic-gate 	struct dynpat *Dyp;
530*7c478bd9Sstevel@tonic-gate 	char *pat;
531*7c478bd9Sstevel@tonic-gate 	char *fpat;
532*7c478bd9Sstevel@tonic-gate 	char *lasts;
533*7c478bd9Sstevel@tonic-gate 	uint_t maxpat;
534*7c478bd9Sstevel@tonic-gate 
535*7c478bd9Sstevel@tonic-gate 	/* append a new dynpat structure to the end of the Dynpat list */
536*7c478bd9Sstevel@tonic-gate 	Dyp = my_malloc(sizeof (struct dynpat), NULL);
537*7c478bd9Sstevel@tonic-gate 	Dyp->next = NULL;
538*7c478bd9Sstevel@tonic-gate 	if (Lastpat == NULL)
539*7c478bd9Sstevel@tonic-gate 		Dynpat = Lastpat = Dyp;
540*7c478bd9Sstevel@tonic-gate 	else {
541*7c478bd9Sstevel@tonic-gate 		Lastpat->next = Dyp;
542*7c478bd9Sstevel@tonic-gate 		Lastpat = Dyp;
543*7c478bd9Sstevel@tonic-gate 	}
544*7c478bd9Sstevel@tonic-gate 	Dyp->flag = hang? BPT_HANG : 0;
545*7c478bd9Sstevel@tonic-gate 	Dyp->exclude_lib = 0;
546*7c478bd9Sstevel@tonic-gate 	Dyp->exclude = 0;
547*7c478bd9Sstevel@tonic-gate 	Dyp->internal = 0;
548*7c478bd9Sstevel@tonic-gate 	Dyp->Dp = NULL;
549*7c478bd9Sstevel@tonic-gate 
550*7c478bd9Sstevel@tonic-gate 	/*
551*7c478bd9Sstevel@tonic-gate 	 * Find the beginning of the filename patterns
552*7c478bd9Sstevel@tonic-gate 	 * and null-terminate the library name patterns.
553*7c478bd9Sstevel@tonic-gate 	 */
554*7c478bd9Sstevel@tonic-gate 	if ((fpat = strchr(arg, ':')) != NULL)
555*7c478bd9Sstevel@tonic-gate 		*fpat++ = '\0';
556*7c478bd9Sstevel@tonic-gate 
557*7c478bd9Sstevel@tonic-gate 	/*
558*7c478bd9Sstevel@tonic-gate 	 * Library name patterns.
559*7c478bd9Sstevel@tonic-gate 	 */
560*7c478bd9Sstevel@tonic-gate 	pat = strtok_r(arg, sepr, &lasts);
561*7c478bd9Sstevel@tonic-gate 
562*7c478bd9Sstevel@tonic-gate 	/* '!' introduces an exclusion list */
563*7c478bd9Sstevel@tonic-gate 	if (pat != NULL && *pat == '!') {
564*7c478bd9Sstevel@tonic-gate 		Dyp->exclude_lib = 1;
565*7c478bd9Sstevel@tonic-gate 		pat += strspn(pat, "!");
566*7c478bd9Sstevel@tonic-gate 		if (*pat == '\0')
567*7c478bd9Sstevel@tonic-gate 			pat = strtok_r(NULL, sepr, &lasts);
568*7c478bd9Sstevel@tonic-gate 		/* force exclusion of all functions as well */
569*7c478bd9Sstevel@tonic-gate 		Dyp->exclude = 1;
570*7c478bd9Sstevel@tonic-gate 		Dyp->internal = 1;
571*7c478bd9Sstevel@tonic-gate 		fpat = NULL;
572*7c478bd9Sstevel@tonic-gate 	}
573*7c478bd9Sstevel@tonic-gate 
574*7c478bd9Sstevel@tonic-gate 	if (pat == NULL) {
575*7c478bd9Sstevel@tonic-gate 		/* empty list means all libraries */
576*7c478bd9Sstevel@tonic-gate 		Dyp->libpat = my_malloc(sizeof (char *), NULL);
577*7c478bd9Sstevel@tonic-gate 		Dyp->libpat[0] = star;
578*7c478bd9Sstevel@tonic-gate 		Dyp->nlibpat = 1;
579*7c478bd9Sstevel@tonic-gate 	} else {
580*7c478bd9Sstevel@tonic-gate 		/*
581*7c478bd9Sstevel@tonic-gate 		 * We are now at the library list.
582*7c478bd9Sstevel@tonic-gate 		 * Generate the list and count the library name patterns.
583*7c478bd9Sstevel@tonic-gate 		 */
584*7c478bd9Sstevel@tonic-gate 		maxpat = 1;
585*7c478bd9Sstevel@tonic-gate 		Dyp->libpat = my_malloc(maxpat * sizeof (char *), NULL);
586*7c478bd9Sstevel@tonic-gate 		Dyp->nlibpat = 0;
587*7c478bd9Sstevel@tonic-gate 		Dyp->libpat[Dyp->nlibpat++] = pat;
588*7c478bd9Sstevel@tonic-gate 		while ((pat = strtok_r(NULL, sepr, &lasts)) != NULL) {
589*7c478bd9Sstevel@tonic-gate 			if (Dyp->nlibpat == maxpat) {
590*7c478bd9Sstevel@tonic-gate 				maxpat *= 2;
591*7c478bd9Sstevel@tonic-gate 				Dyp->libpat = my_realloc(Dyp->libpat,
592*7c478bd9Sstevel@tonic-gate 					maxpat * sizeof (char *), NULL);
593*7c478bd9Sstevel@tonic-gate 			}
594*7c478bd9Sstevel@tonic-gate 			Dyp->libpat[Dyp->nlibpat++] = pat;
595*7c478bd9Sstevel@tonic-gate 		}
596*7c478bd9Sstevel@tonic-gate 	}
597*7c478bd9Sstevel@tonic-gate 
598*7c478bd9Sstevel@tonic-gate 	/*
599*7c478bd9Sstevel@tonic-gate 	 * Function name patterns.
600*7c478bd9Sstevel@tonic-gate 	 */
601*7c478bd9Sstevel@tonic-gate 	if (fpat == NULL)
602*7c478bd9Sstevel@tonic-gate 		pat = NULL;
603*7c478bd9Sstevel@tonic-gate 	else {
604*7c478bd9Sstevel@tonic-gate 		/*
605*7c478bd9Sstevel@tonic-gate 		 * We have already seen a ':'.  Look for another.
606*7c478bd9Sstevel@tonic-gate 		 * Double ':' means trace internal calls.
607*7c478bd9Sstevel@tonic-gate 		 */
608*7c478bd9Sstevel@tonic-gate 		fpat += strspn(fpat, white);
609*7c478bd9Sstevel@tonic-gate 		if (*fpat == ':') {
610*7c478bd9Sstevel@tonic-gate 			Dyp->internal = 1;
611*7c478bd9Sstevel@tonic-gate 			*fpat++ = '\0';
612*7c478bd9Sstevel@tonic-gate 		}
613*7c478bd9Sstevel@tonic-gate 		pat = strtok_r(fpat, csepr, &lasts);
614*7c478bd9Sstevel@tonic-gate 	}
615*7c478bd9Sstevel@tonic-gate 
616*7c478bd9Sstevel@tonic-gate 	/* '!' introduces an exclusion list */
617*7c478bd9Sstevel@tonic-gate 	if (pat != NULL && *pat == '!') {
618*7c478bd9Sstevel@tonic-gate 		Dyp->exclude = 1;
619*7c478bd9Sstevel@tonic-gate 		Dyp->internal = 1;
620*7c478bd9Sstevel@tonic-gate 		pat += strspn(pat, "!");
621*7c478bd9Sstevel@tonic-gate 		if (*pat == '\0')
622*7c478bd9Sstevel@tonic-gate 			pat = strtok_r(NULL, sepr, &lasts);
623*7c478bd9Sstevel@tonic-gate 	}
624*7c478bd9Sstevel@tonic-gate 
625*7c478bd9Sstevel@tonic-gate 	if (pat == NULL) {
626*7c478bd9Sstevel@tonic-gate 		/* empty function list means exclude all functions */
627*7c478bd9Sstevel@tonic-gate 		Dyp->sympat = my_malloc(sizeof (char *), NULL);
628*7c478bd9Sstevel@tonic-gate 		Dyp->sympat[0] = star;
629*7c478bd9Sstevel@tonic-gate 		Dyp->nsympat = 1;
630*7c478bd9Sstevel@tonic-gate 	} else {
631*7c478bd9Sstevel@tonic-gate 		/*
632*7c478bd9Sstevel@tonic-gate 		 * We are now at the function list.
633*7c478bd9Sstevel@tonic-gate 		 * Generate the list and count the symbol name patterns.
634*7c478bd9Sstevel@tonic-gate 		 */
635*7c478bd9Sstevel@tonic-gate 		maxpat = 1;
636*7c478bd9Sstevel@tonic-gate 		Dyp->sympat = my_malloc(maxpat * sizeof (char *), NULL);
637*7c478bd9Sstevel@tonic-gate 		Dyp->nsympat = 0;
638*7c478bd9Sstevel@tonic-gate 		Dyp->sympat[Dyp->nsympat++] = pat;
639*7c478bd9Sstevel@tonic-gate 		while ((pat = strtok_r(NULL, sepr, &lasts)) != NULL) {
640*7c478bd9Sstevel@tonic-gate 			if (Dyp->nsympat == maxpat) {
641*7c478bd9Sstevel@tonic-gate 				maxpat *= 2;
642*7c478bd9Sstevel@tonic-gate 				Dyp->sympat = my_realloc(Dyp->sympat,
643*7c478bd9Sstevel@tonic-gate 					maxpat * sizeof (char *), NULL);
644*7c478bd9Sstevel@tonic-gate 			}
645*7c478bd9Sstevel@tonic-gate 			Dyp->sympat[Dyp->nsympat++] = pat;
646*7c478bd9Sstevel@tonic-gate 		}
647*7c478bd9Sstevel@tonic-gate 	}
648*7c478bd9Sstevel@tonic-gate 
649*7c478bd9Sstevel@tonic-gate 	return (0);
650*7c478bd9Sstevel@tonic-gate }
651