mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
changed to perl for mkproto, patch from vance
This commit is contained in:
parent
60be15d306
commit
9386326868
@ -20,6 +20,7 @@ EXEEXT=@EXEEXT@
|
|||||||
LDFLAGS=@LDFLAGS@
|
LDFLAGS=@LDFLAGS@
|
||||||
LDSHFLAGS=@LDSHFLAGS@ @LDFLAGS@ @CFLAGS@
|
LDSHFLAGS=@LDSHFLAGS@ @LDFLAGS@ @CFLAGS@
|
||||||
AWK=@AWK@
|
AWK=@AWK@
|
||||||
|
PERL=@PERL@
|
||||||
DYNEXP=@DYNEXP@
|
DYNEXP=@DYNEXP@
|
||||||
PYTHON=@PYTHON@
|
PYTHON=@PYTHON@
|
||||||
|
|
||||||
@ -1101,7 +1102,7 @@ delheaders:
|
|||||||
|
|
||||||
include/proto.h:
|
include/proto.h:
|
||||||
@echo Building include/proto.h
|
@echo Building include/proto.h
|
||||||
@cd $(srcdir) && $(SHELL) script/mkproto.sh $(AWK) \
|
@cd $(srcdir) && $(SHELL) script/mkproto.sh $(PERL) \
|
||||||
-h _PROTO_H_ $(builddir)/include/proto.h \
|
-h _PROTO_H_ $(builddir)/include/proto.h \
|
||||||
$(PROTO_OBJ)
|
$(PROTO_OBJ)
|
||||||
|
|
||||||
@ -1111,37 +1112,37 @@ include/build_env.h:
|
|||||||
|
|
||||||
include/wrepld_proto.h:
|
include/wrepld_proto.h:
|
||||||
@echo Building include/wrepld_proto.h
|
@echo Building include/wrepld_proto.h
|
||||||
@cd $(srcdir) && $(SHELL) script/mkproto.sh $(AWK) \
|
@cd $(srcdir) && $(SHELL) script/mkproto.sh $(PERL) \
|
||||||
-h _WREPLD_PROTO_H_ $(builddir)/include/wrepld_proto.h \
|
-h _WREPLD_PROTO_H_ $(builddir)/include/wrepld_proto.h \
|
||||||
$(WREPL_OBJ1)
|
$(WREPL_OBJ1)
|
||||||
|
|
||||||
nsswitch/winbindd_proto.h:
|
nsswitch/winbindd_proto.h:
|
||||||
@cd $(srcdir) && $(SHELL) script/mkproto.sh $(AWK) \
|
@cd $(srcdir) && $(SHELL) script/mkproto.sh $(PERL) \
|
||||||
-h _WINBINDD_PROTO_H_ nsswitch/winbindd_proto.h \
|
-h _WINBINDD_PROTO_H_ nsswitch/winbindd_proto.h \
|
||||||
$(WINBINDD_OBJ1)
|
$(WINBINDD_OBJ1)
|
||||||
|
|
||||||
ntvfs/tank/vfs_tank_proto.h:
|
ntvfs/tank/vfs_tank_proto.h:
|
||||||
@cd $(srcdir) && $(SHELL) script/mkproto.sh $(AWK) \
|
@cd $(srcdir) && $(SHELL) script/mkproto.sh $(PERL) \
|
||||||
-h _VFS_TANK_PROTO_H_ ntvfs/tank/vfs_tank_proto.h \
|
-h _VFS_TANK_PROTO_H_ ntvfs/tank/vfs_tank_proto.h \
|
||||||
$(STFS_OBJS)
|
$(STFS_OBJS)
|
||||||
|
|
||||||
web/swat_proto.h:
|
web/swat_proto.h:
|
||||||
@cd $(srcdir) && $(SHELL) script/mkproto.sh $(AWK) \
|
@cd $(srcdir) && $(SHELL) script/mkproto.sh $(PERL) \
|
||||||
-h _SWAT_PROTO_H_ web/swat_proto.h \
|
-h _SWAT_PROTO_H_ web/swat_proto.h \
|
||||||
$(SWAT_OBJ1)
|
$(SWAT_OBJ1)
|
||||||
|
|
||||||
client/client_proto.h:
|
client/client_proto.h:
|
||||||
@cd $(srcdir) && $(SHELL) script/mkproto.sh $(AWK) \
|
@cd $(srcdir) && $(SHELL) script/mkproto.sh $(PERL) \
|
||||||
-h _CLIENT_PROTO_H_ client/client_proto.h \
|
-h _CLIENT_PROTO_H_ client/client_proto.h \
|
||||||
$(CLIENT_OBJ1)
|
$(CLIENT_OBJ1)
|
||||||
|
|
||||||
utils/net_proto.h:
|
utils/net_proto.h:
|
||||||
@cd $(srcdir) && $(SHELL) script/mkproto.sh $(AWK) \
|
@cd $(srcdir) && $(SHELL) script/mkproto.sh $(PERL) \
|
||||||
-h _CLIENT_PROTO_H_ utils/net_proto.h \
|
-h _CLIENT_PROTO_H_ utils/net_proto.h \
|
||||||
$(NET_OBJ1)
|
$(NET_OBJ1)
|
||||||
|
|
||||||
include/tdbsam2_parse_info.h:
|
include/tdbsam2_parse_info.h:
|
||||||
@cd $(srcdir) && @PERL@ -w script/genstruct.pl \
|
@cd $(srcdir) && $(PERL) -w script/genstruct.pl \
|
||||||
-o include/tdbsam2_parse_info.h $(CC) -E -g \
|
-o include/tdbsam2_parse_info.h $(CC) -E -g \
|
||||||
include/tdbsam2.h
|
include/tdbsam2.h
|
||||||
|
|
||||||
@ -1186,8 +1187,8 @@ distclean: realclean
|
|||||||
# range of machines and is used to produce a list of potentially
|
# range of machines and is used to produce a list of potentially
|
||||||
# dead (ie. unused) functions in the code. (tridge)
|
# dead (ie. unused) functions in the code. (tridge)
|
||||||
finddead:
|
finddead:
|
||||||
nm */*.o |grep 'U ' | awk '{print $$2}' | sort -u > nmused.txt
|
nm */*.o |grep 'U ' | $(AWK) '{print $$2}' | sort -u > nmused.txt
|
||||||
nm */*.o |grep 'T ' | awk '{print $$3}' | sort -u > nmfns.txt
|
nm */*.o |grep 'T ' | $(AWK) '{print $$3}' | sort -u > nmfns.txt
|
||||||
comm -13 nmused.txt nmfns.txt
|
comm -13 nmused.txt nmfns.txt
|
||||||
|
|
||||||
|
|
||||||
|
140
source/script/mkproto.pl
Normal file
140
source/script/mkproto.pl
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
my $header_name = '_PROTO_H_';
|
||||||
|
|
||||||
|
if ($ARGV[0] eq '-h') {
|
||||||
|
shift @ARGV;
|
||||||
|
$header_name = shift @ARGV;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub print_header {
|
||||||
|
print "#ifndef $header_name\n";
|
||||||
|
print "#define $header_name\n\n";
|
||||||
|
print "/* This file is automatically generated with \"make proto\". DO NOT EDIT */\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub print_footer {
|
||||||
|
printf "\n#endif /* %s */\n", $header_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub process_files {
|
||||||
|
my $line;
|
||||||
|
my $inheader;
|
||||||
|
my $gotstart;
|
||||||
|
|
||||||
|
FILE: foreach my $filename (@ARGV) {
|
||||||
|
next FILE unless (open(FH, "< $filename")); # skip over file unless it can be opened
|
||||||
|
print "\n/* The following definitions come from $filename */\n\n";
|
||||||
|
|
||||||
|
$inheader = 0;
|
||||||
|
$gotstart = 0;
|
||||||
|
LINE: while (defined($line = <FH>)) {
|
||||||
|
|
||||||
|
if ($inheader) {
|
||||||
|
# this chomp is somewhat expensive, so don't do it unless we know
|
||||||
|
# that we probably want to use it
|
||||||
|
chomp $line;
|
||||||
|
if ($line =~ /\)\s*$/o) {
|
||||||
|
$inheader = 0;
|
||||||
|
print "$line;\n";
|
||||||
|
} else {
|
||||||
|
print "$line\n";
|
||||||
|
}
|
||||||
|
next LINE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$gotstart = 0;
|
||||||
|
|
||||||
|
# ignore static and extern declarations
|
||||||
|
if ($line =~ /^static|^extern/o ||
|
||||||
|
$line !~ /^[a-zA-Z]/o ||
|
||||||
|
$line =~ /[;]/o) {
|
||||||
|
next LINE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($line =~ /^FN_GLOBAL_STRING/o) {
|
||||||
|
my $fnName = (split(/[\(,]/, $line))[1];
|
||||||
|
print "char *$fnName(void);\n";
|
||||||
|
}
|
||||||
|
elsif ($line =~ /^FN_LOCAL_STRING/o) {
|
||||||
|
my $fnName = (split(/[\(,]/, $line))[1];
|
||||||
|
print "char *$fnName(int );\n";
|
||||||
|
}
|
||||||
|
elsif ($line =~ /^FN_GLOBAL_BOOL/o) {
|
||||||
|
my $fnName = (split(/[\(,]/, $line))[1];
|
||||||
|
print "BOOL $fnName(void);\n";
|
||||||
|
}
|
||||||
|
elsif ($line =~ /^FN_LOCAL_BOOL/o) {
|
||||||
|
my $fnName = (split(/[\(,]/, $line))[1];
|
||||||
|
print "BOOL $fnName(int );\n";
|
||||||
|
}
|
||||||
|
elsif ($line =~ /^FN_GLOBAL_INTEGER/o) {
|
||||||
|
my $fnName = (split(/[\(,]/, $line))[1];
|
||||||
|
print "int $fnName(void);\n";
|
||||||
|
}
|
||||||
|
elsif ($line =~ /^FN_LOCAL_INTEGER/o) {
|
||||||
|
my $fnName = (split(/[\(,]/, $line))[1];
|
||||||
|
print "int $fnName(int );\n";
|
||||||
|
}
|
||||||
|
elsif ($line =~ /^FN_GLOBAL_LIST/o) {
|
||||||
|
my $fnName = (split(/[\(,]/, $line))[1];
|
||||||
|
print "const char **$fnName(void);\n";
|
||||||
|
}
|
||||||
|
elsif ($line =~ /^FN_LOCAL_LIST/o) {
|
||||||
|
my $fnName = (split(/[\(,]/, $line))[1];
|
||||||
|
print "const char **$fnName(int );\n";
|
||||||
|
}
|
||||||
|
elsif ($line =~ /^FN_GLOBAL_CONST_STRING/o) {
|
||||||
|
my $fnName = (split(/[\(,]/, $line))[1];
|
||||||
|
print "const char *$fnName(void);\n";
|
||||||
|
}
|
||||||
|
elsif ($line =~ /^FN_LOCAL_CONST_STRING/o) {
|
||||||
|
my $fnName = (split(/[\(,]/, $line))[1];
|
||||||
|
print "const char *$fnName(int );\n";
|
||||||
|
}
|
||||||
|
elsif ($line =~ /^FN_LOCAL_CHAR/o) {
|
||||||
|
my $fnName = (split(/[\(,]/, $line))[1];
|
||||||
|
print "char $fnName(int );\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# I'm going to leave these as is for now - perl can probably handle larger regex, though -- vance
|
||||||
|
# I've also sort of put these in approximate order of most commonly called
|
||||||
|
|
||||||
|
elsif ( $line =~ /^NTSTATUS|^void|^BOOL|^int|^struct|^char|^const|^PyObject|^ssize_t|^size_t|^uint|^ADS_STATUS|^ADS_STRUCT|^enum.*\(|^SMB_ACL_T|^time|^smb_ucs2_t|^DATA_BLOB|^WERROR/o ) {
|
||||||
|
$gotstart = 1;
|
||||||
|
} elsif ( $line =~ /^smb_iconv_t|^long|^CLI_POLICY_HND|^FILE|^XFILE|^SMB_OFF_T|^pipes_struct|^smb_np_struct|^file_fd_struct|^files_struct|^connection_struct|^uid_t|^gid_t|^unsigned|^DIR|^user/o) {
|
||||||
|
$gotstart = 1;
|
||||||
|
} elsif ( $line =~ /^pid_t|^ino_t|^off_t|^double|^TDB_CONTEXT|^TDB_DATA|^TALLOC_CTX|^NT_DEVICEMODE|^NT_USER_TOKEN|^ADS_MODLIST|^SORTED_TREE|^REGISTRY_HOOK|^REGISTRY_VALUE|^NTTIME|^UNISTR2|^SMB_STRUCT_DIRENT|^SEC_DESC|^DOM_SID/o ) {
|
||||||
|
$gotstart = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# goto next line if we don't have a start
|
||||||
|
next LINE unless $gotstart;
|
||||||
|
|
||||||
|
if ( $line =~ /\(.*\)\s*$/o ) {
|
||||||
|
# now that we're here, we know we
|
||||||
|
chomp $line;
|
||||||
|
print "$line;\n";
|
||||||
|
next LINE;
|
||||||
|
}
|
||||||
|
elsif ( $line =~ /\(/o ) {
|
||||||
|
|
||||||
|
$inheader = 1;
|
||||||
|
# line hasn't been chomped, so we can assume it already has the \n
|
||||||
|
print $line;
|
||||||
|
next LINE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_header();
|
||||||
|
process_files();
|
||||||
|
print_footer();
|
@ -6,16 +6,16 @@ LC_COLLATE=C; export LC_COLLATE
|
|||||||
|
|
||||||
if [ $# -lt 3 ]
|
if [ $# -lt 3 ]
|
||||||
then
|
then
|
||||||
echo "Usage: $0 awk [-h headerdefine] outputheader proto_obj"
|
echo "Usage: $0 perl [-h headerdefine] outputheader proto_obj"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
awk="$1"
|
perl="$1"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
if [ x"$1" = x-h ]
|
if [ x"$1" = x-h ]
|
||||||
then
|
then
|
||||||
headeropt="-v headername=$2"
|
headeropt="-h $2"
|
||||||
shift; shift;
|
shift; shift;
|
||||||
else
|
else
|
||||||
headeropt=""
|
headeropt=""
|
||||||
@ -31,8 +31,7 @@ echo creating $header
|
|||||||
|
|
||||||
mkdir -p `dirname $header`
|
mkdir -p `dirname $header`
|
||||||
|
|
||||||
${awk} $headeropt \
|
${perl} script/mkproto.pl $headeropt $proto_src > $headertmp
|
||||||
-f script/mkproto.awk $proto_src > $headertmp
|
|
||||||
|
|
||||||
if cmp -s $header $headertmp 2>/dev/null
|
if cmp -s $header $headertmp 2>/dev/null
|
||||||
then
|
then
|
||||||
|
Loading…
Reference in New Issue
Block a user