xref: /titanic_51/usr/src/lib/libbsm/mkhdr.sh (revision ad4023c40b055806dce2bde9ee9e87e5016b5135)
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#
23# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26# ident	"%Z%%M%	%I%	%E% SMI"
27#
28
29# Automagically generate the audit_uevents.h header file.
30#
31DATABASE=audit_event.txt
32HEADER_FILE=audit_uevents.h
33
34cat <<EOF > $HEADER_FILE
35/*
36 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
37 * Use is subject to license terms.
38 */
39
40#ifndef	_BSM_AUDIT_UEVENTS_H
41#define	_BSM_AUDIT_UEVENTS_H
42
43#pragma ident	"%Z%$HEADER_FILE	%I%	%E% SMI"
44
45/*
46 * User level audit event numbers.
47 *
48 *     0		Reserved as an invalid event number.
49 *     1 - 2047		Reserved for the Solaris Kernel events.
50 *  2048 - 32767	Reserved for the Solaris TCB programs.
51 * 32768 - 65535	Available for third party TCB applications.
52 *
53 */
54
55#ifdef	__cplusplus
56extern "C" {
57#endif
58
59EOF
60
61nawk -F: '{if ((NF == 4) && substr($1,0,1) != "#")
62		if ($1 >= 2048) {
63			# compute total output line length first
64			tlen = length($2);
65			llen = 8 + tlen;
66			llen += 8 - (llen % 8);
67			if (llen < 32)
68				llen = 32;
69			llen += length($1);
70			llen += 8 - (llen % 8);
71			llen += 5 + length($4) + length($3) + 3;
72
73			# if line is too long, then print the comment first
74			if (llen > 80)
75				printf("/* =%s %s */\n", $4, $3);
76
77			printf("#define\t%s\t", $2)
78			if (tlen < 8)
79				printf("\t");
80			if (tlen < 16)
81				printf("\t")
82			printf("%s", $1);
83
84			if (llen > 80)
85				printf("\n");
86			else
87				printf("\t/* =%s %s */\n", $4, $3);
88		}
89	  }' \
90< $DATABASE >> $HEADER_FILE
91
92cat <<EOF >> $HEADER_FILE
93
94#ifdef	__cplusplus
95}
96#endif
97
98#endif	/* _BSM_AUDIT_UEVENTS_H */
99EOF
100
101exit 0
102