1#!/bin/ksh
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, Version 1.0 only
7# (the "License").  You may not use this file except in compliance
8# with the License.
9#
10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11# or http://www.opensolaris.org/os/licensing.
12# See the License for the specific language governing permissions
13# and limitations under the License.
14#
15# When distributing Covered Code, include this CDDL HEADER in each
16# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17# If applicable, add the following below this CDDL HEADER, with the
18# fields enclosed by brackets "[]" replaced with your own identifying
19# information: Portions Copyright [yyyy] [name of copyright owner]
20#
21# CDDL HEADER END
22#
23#
24# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27#ident	"%Z%%M%	%I%	%E% SMI"
28#
29
30#
31# Create dummy functions for each of the functions in the module API.  We can
32# then link a module against an object file created from the output of this
33# script to determine whether or not that module restricts itself to the API.
34# If the module uses functions outside of the module API, then it cannot be
35# used as a kmdb module.
36#
37nawk '
38	/^[ 	]*global:[ 	]*$/ {
39		printing = 1;
40		next;
41	}
42
43	/^[	]*local:[ 	]*$/ {
44		printing = 0;
45		next;
46	}
47
48	# Skip blank lines and comments
49	/^$/ { next; }
50	/^[ 	]*#/ { next;}
51
52	# Print globals only
53	printing == 0 { next; }
54
55	# Symbols beginning with "kmdb_" are not in the module API - they are
56	# private to kmdb.
57	$1 ~ /^kmdb_/ { next; }
58
59	$1 !~ /;$/ { next; }
60
61	# Print everything else that we have not already seen as a function
62	# definition so we can create our filter.
63	{
64		if (seen[$1]) {
65			next;
66		}
67
68		seen[$1] = 1;
69
70		printf("void %s(void) {}\n", substr($1, 1, length($1) - 1));
71	}
72'
73
74#
75# kmdb modules cannot have their own _init, _fini, or _info routines.  By
76# creating dummies for them here, a link against an object file created from
77# the output of this script will fail if the module defines one of them.
78#
79echo "void _init(void) {}"
80echo "void _info(void) {}"
81echo "void _fini(void) {}"
82