]> git.saurik.com Git - apple/xnu.git/blob - bsd/miscfs/devfs/reproto.sh
facf5f8ab21174da578273f35302a9e098ffdb30
[apple/xnu.git] / bsd / miscfs / devfs / reproto.sh
1 #!/bin/sh
2 #
3 # This used to be a shell script, but had to become more sophisticated
4 # to allow for KNF function definitions. So rewrote in perl, but wrapped
5 # as a shell script.
6 #
7 exec /usr/bin/perl << *EOF*
8 open(PROTO, ">devfs_proto.h") || die "Cannot open devfs_proto.h\n";
9
10 print PROTO "" .
11 "/*\n" .
12 " * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.\n" .
13 " *\n" .
14 " * \@APPLE_LICENSE_OSREFERENCE_HEADER_START\@\n" .
15 " *\n" .
16 " * This file contains Original Code and/or Modifications of Original Code\n" .
17 " * as defined in and that are subject to the Apple Public Source License\n" .
18 " * Version 2.0 (the \"License\"). You may not use this file except in\n" .
19 " * compliance with the License. The rights granted to you under the\n" .
20 " * License may not be used to create, or enable the creation or\n" .
21 " * redistribution of, unlawful or unlicensed copies of an Apple operating\n" .
22 " * system, or to circumvent, violate, or enable the circumvention or\n" .
23 " * violation of, any terms of an Apple operating system software license\n" .
24 " * agreement.\n" .
25 " *\n" .
26 " * Please obtain a copy of the License at\n" .
27 " * http://www.opensource.apple.com/apsl/ and read it before using this\n" .
28 " * file.\n" .
29 " *\n" .
30 " * The Original Code and all software distributed under the License are\n" .
31 " * distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, EITHER\n" .
32 " * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,\n" .
33 " * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,\n" .
34 " * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.\n" .
35 " * Please see the License for the specific language governing rights and\n" .
36 " * limitations under the License.\n" .
37 " *\n" .
38 " * \@APPLE_LICENSE_OSREFERENCE_HEADER_END\@\n" .
39 " */\n";
40
41 print PROTO "/* THIS FILE HAS BEEN PRODUCED AUTOMATICALLY */\n";
42
43 print PROTO "#ifndef __DEVFS_DEVFS_PROTO_H__\n";
44 print PROTO "#define __DEVFS_DEVFS_PROTO_H__\n";
45 print PROTO "\n#include <sys/appleapiopts.h>\n";
46 print PROTO "\n#ifdef __APPLE_API_PRIVATE\n";
47
48 while (\$file = <*.c>) {
49 if(open(F, \$file) == 0) {
50 warn "Cannot open \$file.\n";
51 next;
52 }
53
54 while(<F>) {
55 chop;
56 if (m|/\*proto\*/|) {
57 \$collecting = 1;
58 \$idx = 0;
59 } elsif (\$collecting) {
60 if (/^{/) {
61 \$text[\$idx - 1] .= ';';
62 for (\$i = 0; \$i < \$idx; \$i++) {
63 print PROTO "\$text[\$i]";
64 print PROTO \$i == 0? "\t": "\n";
65 }
66 \$collecting = 0;
67 next;
68 }
69 \$text[\$idx++] = \$_;
70 }
71 }
72 close F;
73 }
74
75 print PROTO "\n#endif /* __APPLE_API_PRIVATE */\n";
76 print PROTO "#endif /* __DEVFS_DEVFS_PROTO_H__ */\n";
77
78 print PROTO "/* THIS FILE PRODUCED AUTOMATICALLY */\n" .
79 "/* DO NOT EDIT (see reproto.sh) */\n";
80
81 *EOF*