2001-03-17 17:26:34 +00:00
#! /bin/sh
2001-08-03 21:53:26 +00:00
#
# Copyright (c) 2001 Wichert Akkerman <wichert@cistron.nl>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# $Id$
#
1999-02-19 00:21:36 +00:00
2001-08-03 21:49:34 +00:00
dir = "/usr/include"
2001-10-09 23:47:38 +00:00
files = "asm/ioctls.h /dev/null"
# Build the list of all ioctls
regexp = '^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*[[:space:]]\+0x54..\>'
( cd $dir ; grep $regexp $files 2>/dev/null ) | \
sed -ne 's/^\(.*\):[[:space:]]*#[[:space:]]*define[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*\(0x54..\).*/ { "\1", "\2", \3 },/p' \
> ioctls.h
2001-03-17 17:26:34 +00:00
files = "linux/* asm/* scsi/*"
1999-02-19 00:21:36 +00:00
2001-03-17 17:26:34 +00:00
# Build the list of all ioctls
2001-08-03 21:49:34 +00:00
regexp = '^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*[[:space:]]\+_S\?\(IO\|IOW\|IOR\|IOWR\)\>'
2001-03-31 16:14:55 +00:00
( cd $dir ; grep $regexp $files 2>/dev/null ) | \
2001-08-03 21:49:34 +00:00
sed -ne 's/^\(.*\):[[:space:]]*#[[:space:]]*define[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*_S\?I.*(\([^[,]*\)[[:space:]]*,[[:space:]]*\([^,)]*\).*/ { "\1", "\2", _IOC(_IOC_NONE,\3,\4,0) },/p' \
2001-10-09 23:47:38 +00:00
>> ioctls.h
1999-02-19 00:21:36 +00:00
2001-03-17 17:26:34 +00:00
# Some use a special base to offset their ioctls on. Extract that as well.
: > ioctldefs.h
1999-02-19 00:21:36 +00:00
2001-08-03 21:49:34 +00:00
bases = $( sed -ne 's/.*_IOC_NONE.*,[[:space:]]*\([A-Z][A-Z0-9_]\+\)[[:space:]+,].*/\1/p' ioctls.h | uniq | sort)
2001-03-17 17:26:34 +00:00
for base in $bases ; do
echo " Looking for $base "
regexp = " ^[[:space:]]*#[[:space:]]*define[[:space:]]\+ $base "
2001-03-31 16:14:55 +00:00
( cd $dir ; grep -h $regexp 2>/dev/null $files ) | \
grep -v '\<_IO' >> ioctldefs.h
2001-03-17 17:26:34 +00:00
done
1999-02-19 00:21:36 +00:00