1*a739efc5Salnsn /* $NetBSD: subr.c,v 1.18 2011/06/01 21:28:33 alnsn Exp $ */
29cffeee5Sjtc
311424948Scgd /*-
411424948Scgd * Copyright (c) 1988, 1993
511424948Scgd * The Regents of the University of California. All rights reserved.
611424948Scgd *
711424948Scgd * Redistribution and use in source and binary forms, with or without
811424948Scgd * modification, are permitted provided that the following conditions
911424948Scgd * are met:
1011424948Scgd * 1. Redistributions of source code must retain the above copyright
1111424948Scgd * notice, this list of conditions and the following disclaimer.
1211424948Scgd * 2. Redistributions in binary form must reproduce the above copyright
1311424948Scgd * notice, this list of conditions and the following disclaimer in the
1411424948Scgd * documentation and/or other materials provided with the distribution.
1589aaa1bbSagc * 3. Neither the name of the University nor the names of its contributors
1611424948Scgd * may be used to endorse or promote products derived from this software
1711424948Scgd * without specific prior written permission.
1811424948Scgd *
1911424948Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2011424948Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2111424948Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2211424948Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2311424948Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2411424948Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2511424948Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2611424948Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2711424948Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2811424948Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2911424948Scgd * SUCH DAMAGE.
3011424948Scgd */
3111424948Scgd
32ecebe744Smikel #include <sys/cdefs.h>
3311424948Scgd #ifndef lint
349cffeee5Sjtc #if 0
359cffeee5Sjtc static char sccsid[] = "@(#)subr.c 8.2 (Berkeley) 4/28/95";
36ecebe744Smikel #else
37*a739efc5Salnsn __RCSID("$NetBSD: subr.c,v 1.18 2011/06/01 21:28:33 alnsn Exp $");
389cffeee5Sjtc #endif
3911424948Scgd #endif /* not lint */
4011424948Scgd
4111424948Scgd #include <sys/param.h>
4211424948Scgd #include <sys/time.h>
4349cee5daSyamt #include <sys/uio.h>
4411424948Scgd #include <sys/ktrace.h>
457e8a9d0dSglass
4611424948Scgd #include <stdio.h>
477e8a9d0dSglass
4811424948Scgd #include "ktrace.h"
4911424948Scgd
50ecebe744Smikel int
getpoints(int facs,char * s)51fde07830Sdsl getpoints(int facs, char *s)
5211424948Scgd {
53fde07830Sdsl int fac;
54fde07830Sdsl int add = 1;
5511424948Scgd
56fde07830Sdsl /* Make -t-x equivalent to -t+-x since that is rather more useful */
57fde07830Sdsl if (*s == '-' && (facs & ALL_POINTS) == 0)
58fde07830Sdsl facs |= DEF_POINTS;
59fde07830Sdsl
60fde07830Sdsl for (;;) {
61fde07830Sdsl switch (*s++) {
62fde07830Sdsl case 0:
63fde07830Sdsl return facs;
64fde07830Sdsl case 'A':
65fde07830Sdsl fac = ALL_POINTS;
66fde07830Sdsl break;
67fde07830Sdsl case 'a':
68fde07830Sdsl fac = KTRFAC_EXEC_ARG;
69fde07830Sdsl break;
7011424948Scgd case 'c':
71fde07830Sdsl fac = KTRFAC_SYSCALL | KTRFAC_SYSRET;
7211424948Scgd break;
737e8c6bf1Schristos case 'e':
74fde07830Sdsl fac = KTRFAC_EMUL;
7511424948Scgd break;
76*a739efc5Salnsn case 'f':
77*a739efc5Salnsn fac = KTRFAC_EXEC_FD;
78*a739efc5Salnsn break;
7911424948Scgd case 'i':
80fde07830Sdsl fac = KTRFAC_GENIO;
8111424948Scgd break;
82fde07830Sdsl case 'n':
83fde07830Sdsl fac = KTRFAC_NAMEI;
8433150ddaSjdolecek break;
85fde07830Sdsl case 's':
86fde07830Sdsl fac = KTRFAC_PSIG;
87fde07830Sdsl break;
88fde07830Sdsl case 'u':
89fde07830Sdsl fac = KTRFAC_USER;
90fde07830Sdsl break;
918a1037a4Smanu case 'S':
928a1037a4Smanu fac = KTRFAC_MIB;
938a1037a4Smanu break;
94fde07830Sdsl case 'v':
95fde07830Sdsl fac = KTRFAC_EXEC_ENV;
966492e217Smanu break;
9711424948Scgd case 'w':
98fde07830Sdsl fac = KTRFAC_CSW;
9911424948Scgd break;
10011424948Scgd case '+':
101fde07830Sdsl if (!add) {
102fde07830Sdsl add = 1;
103fde07830Sdsl continue;
104fde07830Sdsl }
105fde07830Sdsl fac = DEF_POINTS;
10611424948Scgd break;
107fde07830Sdsl case '-':
108fde07830Sdsl add = 0;
109fde07830Sdsl continue;
11011424948Scgd default:
11111424948Scgd return (-1);
11211424948Scgd }
113fde07830Sdsl if (add)
114fde07830Sdsl facs |= fac;
115fde07830Sdsl else
116fde07830Sdsl facs &= ~fac;
11711424948Scgd }
11811424948Scgd }
119