diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-12-27 20:29:19 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:47:51 -0500 |
commit | 10c183d9ae941f0ef143b2d50aebfcaf550c72b3 (patch) | |
tree | 604e40ec0aa035de6df204a50e5e55d7a3ff3706 /source4/script | |
parent | d49f11df218699014af32d19eef8dcc0a70ff38f (diff) | |
download | samba-10c183d9ae941f0ef143b2d50aebfcaf550c72b3.tar.gz samba-10c183d9ae941f0ef143b2d50aebfcaf550c72b3.tar.bz2 samba-10c183d9ae941f0ef143b2d50aebfcaf550c72b3.zip |
r12520: Add support for --help to mkproto.pl
Allow the use of {PRIVATE,PUBLIC}_PROTO_HEADER for [SUBSYSTEM]
and [LIBRARY] sections in .mk files. Public functions can be marked
by adding _PUBLIC_ between their return type and function name.
This should eventually make include/proto.h and include/structs.h obsolete.
(This used to be commit cdfd20fa17c5c4655689e8611e0106d5716b6995)
Diffstat (limited to 'source4/script')
-rwxr-xr-x | source4/script/mkproto.pl | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/source4/script/mkproto.pl b/source4/script/mkproto.pl index 7d80c63f99..479d53da32 100755 --- a/source4/script/mkproto.pl +++ b/source4/script/mkproto.pl @@ -15,6 +15,19 @@ my $private_define = undef; my $public_fd = \*STDOUT; my $private_fd = \*STDOUT; +sub usage() +{ + print "Usage: mkproto.pl [options] [c files]\n"; + print "OPTIONS:\n"; + print " --public=FILE Write prototypes for public functions to FILE\n"; + print " --private=FILE Write prototypes for private functions to FILE\n"; + print " --define=DEF Use DEF to check whether header was already included\n"; + print " --public-define=DEF Same as --define, but just for public header\n"; + print " --private-define=DEF Same as --define, but just for private header\n"; + print " --help Print this help message\n\n"; + exit 0; +} + GetOptions( 'public=s' => sub { my ($f,$v) = @_; $public_file = $v; }, 'private=s' => sub { my ($f,$v) = @_; $private_file = $v; }, @@ -24,18 +37,19 @@ GetOptions( $private_define = "$v\_PRIVATE"; }, 'public-define=s' => \$public_define, - 'private-define=s' => \$private_define -); + 'private-define=s' => \$private_define, + 'help' => \&usage +) or exit(1); if (not defined($public_define) and defined($public_file)) { - $public_define = $public_file; + $public_define = ".." . uc($public_file) . "__"; $public_define =~ tr{./}{__}; } elsif (not defined($public_define)) { $public_define = '_PROTO_H_'; } if (not defined($private_define) and defined($private_file)) { - $private_define = $private_file; + $private_define = "__" . uc($private_file) . "__"; $private_define =~ tr{./}{__}; } elsif (not defined($public_define)) { $public_define = '_PROTO_H_'; @@ -48,7 +62,7 @@ if (defined($public_file)) { if ($private_file eq $public_file) { $private_fd = $public_fd; -} elsif (not defined($private_file)) { +} elsif (defined($private_file)) { open PRIVATE, ">$private_file"; $private_fd = \*PRIVATE; } @@ -58,7 +72,7 @@ sub print_header($$) my ($file, $header_name) = @_; print $file "#ifndef $header_name\n"; print $file "#define $header_name\n\n"; - print $file "/* This file is automatically generated with \"make proto\". DO NOT EDIT */\n\n"; + print $file "/* This file was automatically generated by mkproto.pl. DO NOT EDIT */\n\n"; } sub print_footer($$) @@ -153,10 +167,17 @@ sub process_file($$$) close(FH); } +print_header($public_fd, $public_define); if ($public_file ne $private_file) { print_header($private_fd, $private_define); + + print $private_fd "/* this file contains prototypes for functions that " . + "are private \n * to this subsystem or library. These functions " . + "should not be \n * used outside this particular subsystem! */\n\n"; + + print $public_fd "/* this file contains prototypes for functions that " . + "are part of \n * the public API of this subsystem or library. */\n\n"; } -print_header($public_fd, $public_define); process_file($public_fd, $private_fd, $_) foreach (@ARGV); print_footer($public_fd, $public_define); if ($public_file ne $private_file) { |