xref: /titanic_51/usr/src/lib/libbsm/mkhdr.sh (revision 45916cd2fec6e79bca5dee0421bd39e3c2910d1e)
17c478bd9Sstevel@tonic-gate#!/bin/sh
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*45916cd2Sjpk# Common Development and Distribution License (the "License").
7*45916cd2Sjpk# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
227c478bd9Sstevel@tonic-gate#
23*45916cd2Sjpk# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24*45916cd2Sjpk# Use is subject to license terms.
25*45916cd2Sjpk#
267c478bd9Sstevel@tonic-gate# ident	"%Z%%M%	%I%	%E% SMI"
277c478bd9Sstevel@tonic-gate#
28*45916cd2Sjpk
297c478bd9Sstevel@tonic-gate# Automagically generate the audit_uevents.h header file.
307c478bd9Sstevel@tonic-gate#
317c478bd9Sstevel@tonic-gateDATABASE=audit_event.txt
327c478bd9Sstevel@tonic-gateHEADER_FILE=audit_uevents.h
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gatecat <<EOF > $HEADER_FILE
357c478bd9Sstevel@tonic-gate/*
36*45916cd2Sjpk * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
37*45916cd2Sjpk * Use is subject to license terms.
387c478bd9Sstevel@tonic-gate */
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate#ifndef	_BSM_AUDIT_UEVENTS_H
417c478bd9Sstevel@tonic-gate#define	_BSM_AUDIT_UEVENTS_H
427c478bd9Sstevel@tonic-gate
437c478bd9Sstevel@tonic-gate#pragma ident	"%Z%$HEADER_FILE	%I%	%E% SMI"
447c478bd9Sstevel@tonic-gate
457c478bd9Sstevel@tonic-gate/*
467c478bd9Sstevel@tonic-gate * User level audit event numbers.
477c478bd9Sstevel@tonic-gate *
487c478bd9Sstevel@tonic-gate *     0		Reserved as an invalid event number.
497c478bd9Sstevel@tonic-gate *     1 - 2047		Reserved for the Solaris Kernel events.
507c478bd9Sstevel@tonic-gate *  2048 - 32767	Reserved for the Solaris TCB programs.
517c478bd9Sstevel@tonic-gate * 32768 - 65535	Available for third party TCB applications.
527c478bd9Sstevel@tonic-gate *
537c478bd9Sstevel@tonic-gate */
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gate#ifdef	__cplusplus
567c478bd9Sstevel@tonic-gateextern "C" {
577c478bd9Sstevel@tonic-gate#endif
587c478bd9Sstevel@tonic-gate
597c478bd9Sstevel@tonic-gateEOF
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gatenawk -F: '{if ((NF == 4) && substr($1,0,1) != "#")
627c478bd9Sstevel@tonic-gate		if ($1 >= 2048) {
63*45916cd2Sjpk			# compute total output line length first
64*45916cd2Sjpk			tlen = length($2);
65*45916cd2Sjpk			llen = 8 + tlen;
66*45916cd2Sjpk			llen += 8 - (llen % 8);
67*45916cd2Sjpk			if (llen < 32)
68*45916cd2Sjpk				llen = 32;
69*45916cd2Sjpk			llen += length($1);
70*45916cd2Sjpk			llen += 8 - (llen % 8);
71*45916cd2Sjpk			llen += 5 + length($4) + length($3) + 3;
72*45916cd2Sjpk
73*45916cd2Sjpk			# if line is too long, then print the comment first
74*45916cd2Sjpk			if (llen > 80)
75*45916cd2Sjpk				printf("/* =%s %s */\n", $4, $3);
76*45916cd2Sjpk
77*45916cd2Sjpk			printf("#define\t%s\t", $2)
78*45916cd2Sjpk			if (tlen < 8)
79*45916cd2Sjpk				printf("\t");
80*45916cd2Sjpk			if (tlen < 16)
81*45916cd2Sjpk				printf("\t")
82*45916cd2Sjpk			printf("%s", $1);
83*45916cd2Sjpk
84*45916cd2Sjpk			if (llen > 80)
85*45916cd2Sjpk				printf("\n");
86*45916cd2Sjpk			else
87*45916cd2Sjpk				printf("\t/* =%s %s */\n", $4, $3);
887c478bd9Sstevel@tonic-gate		}
897c478bd9Sstevel@tonic-gate	  }' \
907c478bd9Sstevel@tonic-gate< $DATABASE >> $HEADER_FILE
917c478bd9Sstevel@tonic-gate
927c478bd9Sstevel@tonic-gatecat <<EOF >> $HEADER_FILE
937c478bd9Sstevel@tonic-gate
947c478bd9Sstevel@tonic-gate#ifdef	__cplusplus
957c478bd9Sstevel@tonic-gate}
967c478bd9Sstevel@tonic-gate#endif
977c478bd9Sstevel@tonic-gate
987c478bd9Sstevel@tonic-gate#endif	/* _BSM_AUDIT_UEVENTS_H */
997c478bd9Sstevel@tonic-gateEOF
1007c478bd9Sstevel@tonic-gate
1017c478bd9Sstevel@tonic-gateexit 0
102