xref: /illumos-gate/usr/src/lib/libbsm/mkhdr.sh (revision ec71f88e58593e3077f03588d3c38e6cbd4e8c1a)
1#!/bin/sh
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance 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# Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
23#
24
25# Automagically generate the audit_uevents.h header file.
26#
27DATABASE=audit_event.txt
28HEADER_FILE=audit_uevents.h
29CR_YEAR=`/usr/bin/date '+%Y'`
30
31cat <<EOF > $HEADER_FILE
32/*
33 * CDDL HEADER START
34 *
35 * The contents of this file are subject to the terms of the
36 * Common Development and Distribution License (the "License").
37 * You may not use this file except in compliance with the License.
38 *
39 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
40 * or http://www.opensolaris.org/os/licensing.
41 * See the License for the specific language governing permissions
42 * and limitations under the License.
43 *
44 * When distributing Covered Code, include this CDDL HEADER in each
45 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
46 * If applicable, add the following below this CDDL HEADER, with the
47 * fields enclosed by brackets "[]" replaced with your own identifying
48 * information: Portions Copyright [yyyy] [name of copyright owner]
49 *
50 * CDDL HEADER END
51 */
52/*
53 * Copyright (c) 1992, $CR_YEAR, Oracle and/or its affiliates. All rights reserved.
54 */
55
56#ifndef	_BSM_AUDIT_UEVENTS_H
57#define	_BSM_AUDIT_UEVENTS_H
58
59EOF
60
61cat <<EOF >> $HEADER_FILE
62
63/*
64 * User level audit event numbers.
65 *
66 *     0		Reserved as an invalid event number.
67 *     1 - 2047		Reserved for the Solaris Kernel events.
68 *  2048 - 32767	Reserved for the Solaris TCB programs.
69 * 32768 - 65535	Available for third party TCB applications.
70 *
71 */
72
73#ifdef	__cplusplus
74extern "C" {
75#endif
76
77EOF
78
79nawk -F: '{if ((NF == 4) && substr($1,0,1) != "#")
80		if ($1 >= 2048) {
81			tlen = length($2);
82
83			printf("#define\t%s\t", $2)
84			if (tlen < 8)
85				printf("\t");
86			if (tlen < 16)
87				printf("\t");
88			if (tlen < 24)
89				printf("\t");
90			printf("%s\n", $1);
91		}
92	  }' \
93< $DATABASE >> $HEADER_FILE
94
95cat <<EOF >> $HEADER_FILE
96
97#ifdef	__cplusplus
98}
99#endif
100
101#endif	/* _BSM_AUDIT_UEVENTS_H */
102EOF
103
104exit 0
105