summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/Makefile13
-rw-r--r--source4/aclocal.m42
-rwxr-xr-xsource4/autogen.sh2
-rw-r--r--source4/build/m4/check_path.m45
-rw-r--r--source4/cluster/ctdb/brlock_ctdb.c2
-rw-r--r--source4/cluster/ctdb/client/ctdb_client.c2
-rw-r--r--source4/cluster/ctdb/common/ctdb_io.c2
-rw-r--r--source4/cluster/ctdb/common/ctdb_ltdb.c2
-rw-r--r--source4/cluster/ctdb/common/ctdb_message.c2
-rw-r--r--source4/cluster/ctdb/common/ctdb_util.c2
-rw-r--r--source4/cluster/ctdb/ctdb_cluster.c2
-rw-r--r--source4/cluster/ctdb/opendb_ctdb.c2
-rw-r--r--source4/cluster/ctdb/server/ctdb_call.c2
-rw-r--r--source4/cluster/ctdb/server/ctdb_control.c2
-rw-r--r--source4/cluster/ctdb/server/ctdb_daemon.c2
-rw-r--r--source4/cluster/ctdb/server/ctdb_freeze.c2
-rw-r--r--source4/cluster/ctdb/server/ctdb_lockwait.c2
-rw-r--r--source4/cluster/ctdb/server/ctdb_ltdb_server.c2
-rw-r--r--source4/cluster/ctdb/server/ctdb_recover.c2
-rw-r--r--source4/cluster/ctdb/server/ctdb_server.c2
-rw-r--r--source4/cluster/ctdb/server/ctdb_takeover.c2
-rw-r--r--source4/cluster/ctdb/server/ctdb_traverse.c2
-rw-r--r--source4/cluster/ctdb/takeover/ctdb_takeover.c2
-rw-r--r--source4/cluster/ctdb/tcp/tcp_connect.c2
-rw-r--r--source4/cluster/ctdb/tcp/tcp_init.c2
-rw-r--r--source4/cluster/ctdb/tcp/tcp_io.c2
-rw-r--r--source4/cluster/local.c2
-rw-r--r--source4/configure.ac22
-rw-r--r--source4/heimdal_build/config.h2
-rw-r--r--source4/heimdal_build/gssapi-glue.c2
-rw-r--r--source4/include/includes.h2
-rw-r--r--source4/lib/com/main.c3
-rw-r--r--source4/lib/com/tables.c2
-rw-r--r--source4/lib/compression/lzxpress.c312
-rw-r--r--source4/lib/compression/lzxpress.h50
-rw-r--r--source4/lib/compression/mszip.c676
-rw-r--r--source4/lib/compression/mszip.h33
-rw-r--r--source4/lib/compression/testsuite.c30
-rw-r--r--source4/lib/dbwrap/dbwrap.c2
-rw-r--r--source4/lib/dbwrap/dbwrap_ctdb.c2
-rw-r--r--source4/lib/dbwrap/dbwrap_tdb.c2
-rw-r--r--source4/lib/messaging/messaging.c3
-rw-r--r--source4/lib/nss_wrapper/config.m419
-rw-r--r--source4/lib/nss_wrapper/config.mk7
-rw-r--r--source4/lib/nss_wrapper/nss_wrapper.c1130
-rw-r--r--source4/lib/nss_wrapper/nss_wrapper.h165
-rw-r--r--source4/lib/nss_wrapper/nss_wrapper.pl265
-rw-r--r--source4/lib/popt/CHANGES46
-rw-r--r--source4/lib/popt/COPYING22
-rw-r--r--source4/lib/popt/README18
-rw-r--r--source4/lib/popt/config.mk5
-rw-r--r--source4/lib/popt/findme.c50
-rw-r--r--source4/lib/popt/findme.h20
-rw-r--r--source4/lib/popt/libpopt.m443
-rw-r--r--source4/lib/popt/popt.c1238
-rw-r--r--source4/lib/popt/popt.h541
-rw-r--r--source4/lib/popt/poptconfig.c190
-rw-r--r--source4/lib/popt/popthelp.c742
-rw-r--r--source4/lib/popt/poptint.h116
-rw-r--r--source4/lib/popt/poptparse.c227
-rw-r--r--source4/lib/popt/samba.m48
-rw-r--r--source4/lib/popt/system.h74
-rw-r--r--source4/lib/replace/.checker_innocent4
-rw-r--r--source4/lib/replace/Makefile.in63
-rw-r--r--source4/lib/replace/README113
-rw-r--r--source4/lib/replace/aclocal.m41
-rw-r--r--source4/lib/replace/autoconf-2.60.m4210
-rwxr-xr-xsource4/lib/replace/autogen.sh13
-rwxr-xr-xsource4/lib/replace/config.guess1464
-rwxr-xr-xsource4/lib/replace/config.sub1577
-rw-r--r--source4/lib/replace/configure.ac30
-rw-r--r--source4/lib/replace/dlfcn.c75
-rw-r--r--source4/lib/replace/dlfcn.m431
-rw-r--r--source4/lib/replace/getaddrinfo.c497
-rw-r--r--source4/lib/replace/getaddrinfo.h89
-rw-r--r--source4/lib/replace/getifaddrs.c361
-rw-r--r--source4/lib/replace/getpass.c222
-rw-r--r--source4/lib/replace/getpass.m424
-rw-r--r--source4/lib/replace/inet_aton.c33
-rw-r--r--source4/lib/replace/inet_ntoa.c39
-rw-r--r--source4/lib/replace/inet_ntop.c191
-rw-r--r--source4/lib/replace/inet_pton.c213
-rwxr-xr-xsource4/lib/replace/install-sh238
-rw-r--r--source4/lib/replace/libreplace.m4303
-rw-r--r--source4/lib/replace/libreplace_cc.m4182
-rw-r--r--source4/lib/replace/libreplace_ld.m4319
-rw-r--r--source4/lib/replace/libreplace_macros.m4332
-rw-r--r--source4/lib/replace/libreplace_network.m4377
-rw-r--r--source4/lib/replace/repdir.m478
-rw-r--r--source4/lib/replace/repdir_getdents.c166
-rw-r--r--source4/lib/replace/repdir_getdirentries.c183
-rw-r--r--source4/lib/replace/replace.c616
-rw-r--r--source4/lib/replace/replace.h582
-rw-r--r--source4/lib/replace/samba.m435
-rw-r--r--source4/lib/replace/snprintf.c1530
-rw-r--r--source4/lib/replace/socket.c35
-rw-r--r--source4/lib/replace/socketpair.c46
-rw-r--r--source4/lib/replace/strptime.c990
-rw-r--r--source4/lib/replace/strptime.m413
-rw-r--r--source4/lib/replace/system/README4
-rw-r--r--source4/lib/replace/system/aio.h32
-rw-r--r--source4/lib/replace/system/capability.h55
-rw-r--r--source4/lib/replace/system/config.m4130
-rw-r--r--source4/lib/replace/system/dir.h67
-rw-r--r--source4/lib/replace/system/filesys.h182
-rw-r--r--source4/lib/replace/system/glob.h37
-rw-r--r--source4/lib/replace/system/iconv.h57
-rw-r--r--source4/lib/replace/system/kerberos.h137
-rw-r--r--source4/lib/replace/system/locale.h38
-rw-r--r--source4/lib/replace/system/network.h332
-rw-r--r--source4/lib/replace/system/passwd.h110
-rw-r--r--source4/lib/replace/system/readline.h52
-rw-r--r--source4/lib/replace/system/select.h41
-rw-r--r--source4/lib/replace/system/shmem.h59
-rw-r--r--source4/lib/replace/system/syslog.h70
-rw-r--r--source4/lib/replace/system/terminal.h46
-rw-r--r--source4/lib/replace/system/time.h69
-rw-r--r--source4/lib/replace/system/wait.h55
-rw-r--r--source4/lib/replace/test/getifaddrs.c100
-rw-r--r--source4/lib/replace/test/os2_delete.c124
-rw-r--r--source4/lib/replace/test/shared_mmap.c68
-rw-r--r--source4/lib/replace/test/strptime.c172
-rw-r--r--source4/lib/replace/test/testsuite.c1080
-rw-r--r--source4/lib/replace/timegm.c78
-rw-r--r--source4/lib/replace/timegm.m41
-rw-r--r--source4/lib/replace/win32.m420
-rw-r--r--source4/lib/replace/win32_replace.h159
-rw-r--r--source4/lib/socket_wrapper/config.m422
-rw-r--r--source4/lib/socket_wrapper/config.mk8
-rw-r--r--source4/lib/socket_wrapper/socket_wrapper.c1841
-rw-r--r--source4/lib/socket_wrapper/socket_wrapper.h136
-rw-r--r--source4/lib/socket_wrapper/testsuite.c105
-rw-r--r--source4/lib/talloc/Makefile.in43
-rw-r--r--source4/lib/talloc/NEWS13
-rw-r--r--source4/lib/talloc/aclocal.m41
-rwxr-xr-xsource4/lib/talloc/autogen.sh14
-rwxr-xr-xsource4/lib/talloc/config.guess1464
-rw-r--r--source4/lib/talloc/config.mk7
-rwxr-xr-xsource4/lib/talloc/config.sub1577
-rw-r--r--source4/lib/talloc/configure.ac24
-rwxr-xr-xsource4/lib/talloc/install-sh238
-rw-r--r--source4/lib/talloc/libtalloc.m433
-rw-r--r--source4/lib/talloc/rules.mk18
-rw-r--r--source4/lib/talloc/talloc.3.xml738
-rw-r--r--source4/lib/talloc/talloc.c1732
-rw-r--r--source4/lib/talloc/talloc.h183
-rw-r--r--source4/lib/talloc/talloc.i31
-rw-r--r--source4/lib/talloc/talloc.mk37
-rw-r--r--source4/lib/talloc/talloc.pc.in11
-rw-r--r--source4/lib/talloc/talloc_guide.txt685
-rw-r--r--source4/lib/talloc/testsuite.c1152
-rw-r--r--source4/lib/talloc/web/index.html46
-rw-r--r--source4/lib/tdb/Makefile.in59
-rw-r--r--source4/lib/tdb/aclocal.m41
-rwxr-xr-xsource4/lib/tdb/autogen.sh16
-rw-r--r--source4/lib/tdb/common/dump.c137
-rw-r--r--source4/lib/tdb/common/error.c57
-rw-r--r--source4/lib/tdb/common/freelist.c382
-rw-r--r--source4/lib/tdb/common/freelistcheck.c107
-rw-r--r--source4/lib/tdb/common/io.c473
-rw-r--r--source4/lib/tdb/common/lock.c553
-rw-r--r--source4/lib/tdb/common/open.c488
-rw-r--r--source4/lib/tdb/common/tdb.c802
-rw-r--r--source4/lib/tdb/common/tdb_private.h213
-rw-r--r--source4/lib/tdb/common/transaction.c1119
-rw-r--r--source4/lib/tdb/common/traverse.c348
-rwxr-xr-xsource4/lib/tdb/config.guess1464
-rw-r--r--source4/lib/tdb/config.mk57
-rwxr-xr-xsource4/lib/tdb/config.sub1577
-rw-r--r--source4/lib/tdb/configure.ac30
-rw-r--r--source4/lib/tdb/docs/README238
-rw-r--r--source4/lib/tdb/docs/tdb.magic10
-rw-r--r--source4/lib/tdb/include/tdb.h167
-rwxr-xr-xsource4/lib/tdb/install-sh238
-rw-r--r--source4/lib/tdb/libtdb.m430
-rw-r--r--source4/lib/tdb/python.mk10
-rw-r--r--source4/lib/tdb/python/tdbdump.py12
-rw-r--r--source4/lib/tdb/python/tests/simple.py152
-rw-r--r--source4/lib/tdb/rules.mk21
-rw-r--r--source4/lib/tdb/tdb.i323
-rw-r--r--source4/lib/tdb/tdb.mk86
-rw-r--r--source4/lib/tdb/tdb.pc.in11
-rw-r--r--source4/lib/tdb/tdb.py341
-rw-r--r--source4/lib/tdb/tdb_wrap.c4307
-rw-r--r--source4/lib/tdb/tools/tdbbackup.c300
-rw-r--r--source4/lib/tdb/tools/tdbdump.c116
-rw-r--r--source4/lib/tdb/tools/tdbtest.c265
-rw-r--r--source4/lib/tdb/tools/tdbtool.c659
-rw-r--r--source4/lib/tdb/tools/tdbtorture.c318
-rw-r--r--source4/lib/tdb/web/index.html42
-rw-r--r--source4/lib/tdb_wrap.c2
-rw-r--r--source4/lib/util/util_tdb.c2
-rw-r--r--source4/librpc/idl/dfs.idl3
-rw-r--r--source4/librpc/idl/drsuapi.idl12
-rw-r--r--source4/librpc/idl/eventlog.idl5
-rw-r--r--source4/librpc/idl/lsa.idl18
-rw-r--r--source4/librpc/idl/netlogon.idl30
-rw-r--r--source4/librpc/idl/ntsvcs.idl59
-rw-r--r--source4/librpc/idl/svcctl.idl27
-rw-r--r--source4/librpc/ndr/libndr.h1
-rw-r--r--source4/librpc/ndr/ndr_compression.c2
-rw-r--r--source4/librpc/ndr/ndr_misc.c6
-rw-r--r--source4/librpc/tests/samr-CreateUser-in.datbin0 -> 60 bytes
-rw-r--r--source4/librpc/tests/samr-CreateUser-out.datbin0 -> 32 bytes
-rwxr-xr-xsource4/librpc/tests/test_ndrdump.sh20
-rw-r--r--source4/main.mk4
-rw-r--r--source4/nsswitch/winbind_nss_config.h2
-rw-r--r--source4/ntvfs/common/brlock.c2
-rw-r--r--source4/ntvfs/common/brlock_tdb.c2
-rw-r--r--source4/ntvfs/common/notify.c2
-rw-r--r--source4/ntvfs/common/opendb_tdb.c2
-rw-r--r--source4/ntvfs/posix/vfs_posix.c2
-rw-r--r--source4/ntvfs/posix/xattr_tdb.c2
-rw-r--r--source4/param/secrets.c2
-rw-r--r--source4/pidl/MANIFEST43
-rw-r--r--source4/pidl/META.yml18
-rwxr-xr-xsource4/pidl/Makefile.PL17
-rw-r--r--source4/pidl/README64
-rw-r--r--source4/pidl/TODO47
-rw-r--r--source4/pidl/config.m49
-rw-r--r--source4/pidl/config.mk31
-rw-r--r--source4/pidl/expr.yp150
-rw-r--r--source4/pidl/idl.yp497
-rw-r--r--source4/pidl/lib/Parse/Pidl.pm38
-rw-r--r--source4/pidl/lib/Parse/Pidl/CUtil.pm52
-rw-r--r--source4/pidl/lib/Parse/Pidl/Compat.pm163
-rw-r--r--source4/pidl/lib/Parse/Pidl/Dump.pm294
-rw-r--r--source4/pidl/lib/Parse/Pidl/Expr.pm1442
-rw-r--r--source4/pidl/lib/Parse/Pidl/IDL.pm2534
-rw-r--r--source4/pidl/lib/Parse/Pidl/NDR.pm1235
-rw-r--r--source4/pidl/lib/Parse/Pidl/ODL.pm117
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm243
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm268
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4.pm119
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm155
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm221
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm327
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Header.pm475
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm156
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm2695
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm328
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Python.pm1216
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/SWIG.pm177
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm281
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Template.pm98
-rw-r--r--source4/pidl/lib/Parse/Pidl/Typelist.pm301
-rw-r--r--source4/pidl/lib/Parse/Pidl/Util.pm182
-rw-r--r--source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm439
-rw-r--r--source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm1141
-rw-r--r--source4/pidl/lib/Parse/Yapp/Driver.pm471
-rwxr-xr-xsource4/pidl/pidl796
-rw-r--r--source4/pidl/tests/Util.pm179
-rwxr-xr-xsource4/pidl/tests/cutil.pl21
-rwxr-xr-xsource4/pidl/tests/dump.pl15
-rwxr-xr-xsource4/pidl/tests/header.pl108
-rwxr-xr-xsource4/pidl/tests/ndr.pl558
-rwxr-xr-xsource4/pidl/tests/ndr_align.pl143
-rwxr-xr-xsource4/pidl/tests/ndr_alloc.pl118
-rwxr-xr-xsource4/pidl/tests/ndr_array.pl37
-rwxr-xr-xsource4/pidl/tests/ndr_compat.pl21
-rwxr-xr-xsource4/pidl/tests/ndr_deprecations.pl26
-rwxr-xr-xsource4/pidl/tests/ndr_fullptr.pl44
-rwxr-xr-xsource4/pidl/tests/ndr_refptr.pl526
-rwxr-xr-xsource4/pidl/tests/ndr_represent.pl71
-rwxr-xr-xsource4/pidl/tests/ndr_simple.pl28
-rwxr-xr-xsource4/pidl/tests/ndr_string.pl90
-rwxr-xr-xsource4/pidl/tests/ndr_tagtype.pl66
-rwxr-xr-xsource4/pidl/tests/parse_idl.pl164
-rwxr-xr-xsource4/pidl/tests/samba-ejs.pl37
-rwxr-xr-xsource4/pidl/tests/samba-ndr.pl296
-rwxr-xr-xsource4/pidl/tests/samba3-cli.pl126
-rw-r--r--source4/pidl/tests/samba3-srv.pl18
-rwxr-xr-xsource4/pidl/tests/tdr.pl49
-rwxr-xr-xsource4/pidl/tests/test_util.pl21
-rwxr-xr-xsource4/pidl/tests/typelist.pl85
-rwxr-xr-xsource4/pidl/tests/util.pl115
-rwxr-xr-xsource4/pidl/tests/wireshark-conf.pl205
-rwxr-xr-xsource4/pidl/tests/wireshark-ndr.pl274
-rw-r--r--source4/samba4-knownfail6
-rwxr-xr-xsource4/script/build_smb_interfaces.pl161
-rwxr-xr-xsource4/script/harness2subunit.pl4
-rw-r--r--source4/scripting/python/config.m42
-rwxr-xr-xsource4/selftest/samba4_tests.sh17
-rw-r--r--source4/smbd/process_prefork.c2
-rw-r--r--source4/smbd/process_standard.c2
-rw-r--r--source4/torture/basic/delaywrite.c208
-rw-r--r--source4/torture/basic/mangle_test.c2
-rw-r--r--source4/torture/local/config.mk14
-rw-r--r--source4/torture/local/dbspeed.c2
-rwxr-xr-xsource4/torture/tests/test_gentest.sh34
-rwxr-xr-xsource4/torture/tests/test_locktest.sh28
-rwxr-xr-xsource4/torture/tests/test_masktest.sh28
292 files changed, 450 insertions, 67023 deletions
diff --git a/source4/Makefile b/source4/Makefile
index 1c4c2611b0..bc470742c6 100644
--- a/source4/Makefile
+++ b/source4/Makefile
@@ -8,7 +8,7 @@ default: all
include mkconfig.mk
-pidldir := $(srcdir)/pidl
+pidldir := $(srcdir)/../pidl
BASEDIR = $(prefix)
TORTUREDIR = $(libdir)/torture
@@ -61,7 +61,7 @@ libsrcdir := lib
libsocketsrcdir := lib/socket
libcharsetsrcdir := lib/charset
ldb_sambasrcdir := lib/ldb-samba
-tdbsrcdir := lib/tdb
+tdbsrcdir := ../lib/tdb
ldbsrcdir := lib/ldb
libtlssrcdir := lib/tls
libregistrysrcdir := lib/registry
@@ -69,9 +69,9 @@ smbreadlinesrcdir := lib/smbreadline
libmessagingsrcdir := lib/messaging
libeventssrcdir := lib/events
libcmdlinesrcdir := lib/cmdline
-poptsrcdir := lib/popt
-socketwrappersrcdir := lib/socket_wrapper
-nsswrappersrcdir := lib/nss_wrapper
+poptsrcdir := ../lib/popt
+socketwrappersrcdir := ../lib/socket_wrapper
+nsswrappersrcdir := ../lib/nss_wrapper
appwebsrcdir := lib/appweb
libstreamsrcdir := lib/stream
libutilsrcdir := lib/util
@@ -80,7 +80,7 @@ libdbwrapsrcdir := lib/dbwrap
libcryptosrcdir := lib/crypto
libtorturesrcdir := lib/torture
smb_serversrcdir := smb_server
-libcompressionsrcdir := lib/compression
+libcompressionsrcdir := ../lib/compression
libgencachesrcdir := lib
paramsrcdir := param
rpc_serversrcdir := rpc_server
@@ -101,6 +101,7 @@ pyscriptsrcdir := $(srcdir)/scripting/python
kdcsrcdir := kdc
ntp_signdsrcdir := ntp_signd
wmisrcdir := lib/wmi
+tallocsrcdir := ../lib/talloc
include data.mk
diff --git a/source4/aclocal.m4 b/source4/aclocal.m4
index 57a66439a1..240a994f9d 100644
--- a/source4/aclocal.m4
+++ b/source4/aclocal.m4
@@ -53,7 +53,7 @@ AC_DEFUN(LIB_REMOVE_USR_LIB,[
$1=[$]ac_new_flags
])
-m4_include(lib/replace/libreplace.m4)
+m4_include(../lib/replace/libreplace.m4)
m4_include(build/m4/ax_cflags_gcc_option.m4)
m4_include(build/m4/ax_cflags_irix_option.m4)
m4_include(build/m4/public.m4)
diff --git a/source4/autogen.sh b/source4/autogen.sh
index b721a45a99..a56c5a2238 100755
--- a/source4/autogen.sh
+++ b/source4/autogen.sh
@@ -53,7 +53,7 @@ echo "$0: running script/mkversion.sh"
rm -rf autom4te*.cache
rm -f configure include/config_tmp.h*
-IPATHS="-I. -Ilib/replace"
+IPATHS="-I. -I../lib/replace"
echo "$0: running $AUTOHEADER $IPATHS"
$AUTOHEADER $IPATHS || exit 1
diff --git a/source4/build/m4/check_path.m4 b/source4/build/m4/check_path.m4
index c45a803633..51d5daa913 100644
--- a/source4/build/m4/check_path.m4
+++ b/source4/build/m4/check_path.m4
@@ -23,6 +23,11 @@ winbindd_socket_dir="${localstatedir}/run/winbindd"
winbindd_privileged_socket_dir="${localstatedir}/lib/winbindd_privileged"
ntp_signd_socket_dir="${localstatedir}/run/ntp_signd"
+# Check to prevent installing directly under /usr without the FHS
+AS_IF([test ${prefix} == /usr],[
+ AC_MSG_ERROR([Don't install directly under "/usr" without using the FHS option (--with-fhs). This could lead to file loss!])
+])
+
AC_ARG_WITH(fhs,
[AS_HELP_STRING([--with-fhs],[Use FHS-compliant paths (default=no)])],
lockdir="${localstatedir}/lib/samba"
diff --git a/source4/cluster/ctdb/brlock_ctdb.c b/source4/cluster/ctdb/brlock_ctdb.c
index 1b22c6c727..01d60901a6 100644
--- a/source4/cluster/ctdb/brlock_ctdb.c
+++ b/source4/cluster/ctdb/brlock_ctdb.c
@@ -21,7 +21,7 @@
#include "includes.h"
#include "system/filesys.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "messaging/messaging.h"
#include "lib/messaging/irpc.h"
#include "libcli/libcli.h"
diff --git a/source4/cluster/ctdb/client/ctdb_client.c b/source4/cluster/ctdb/client/ctdb_client.c
index 2af0d418a8..a22cd09745 100644
--- a/source4/cluster/ctdb/client/ctdb_client.c
+++ b/source4/cluster/ctdb/client/ctdb_client.c
@@ -20,7 +20,7 @@
#include "includes.h"
#include "tdb_wrap.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/util/dlinklist.h"
#include "lib/events/events.h"
#include "system/network.h"
diff --git a/source4/cluster/ctdb/common/ctdb_io.c b/source4/cluster/ctdb/common/ctdb_io.c
index ca9c635878..ecdbeae516 100644
--- a/source4/cluster/ctdb/common/ctdb_io.c
+++ b/source4/cluster/ctdb/common/ctdb_io.c
@@ -21,7 +21,7 @@
*/
#include "includes.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/events/events.h"
#include "lib/util/dlinklist.h"
#include "system/network.h"
diff --git a/source4/cluster/ctdb/common/ctdb_ltdb.c b/source4/cluster/ctdb/common/ctdb_ltdb.c
index 92adc4a12a..cae0aea0d9 100644
--- a/source4/cluster/ctdb/common/ctdb_ltdb.c
+++ b/source4/cluster/ctdb/common/ctdb_ltdb.c
@@ -19,7 +19,7 @@
#include "includes.h"
#include "lib/events/events.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "system/network.h"
#include "system/filesys.h"
#include "../include/ctdb_private.h"
diff --git a/source4/cluster/ctdb/common/ctdb_message.c b/source4/cluster/ctdb/common/ctdb_message.c
index 1aea28fd35..28811b77f1 100644
--- a/source4/cluster/ctdb/common/ctdb_message.c
+++ b/source4/cluster/ctdb/common/ctdb_message.c
@@ -22,7 +22,7 @@
*/
#include "includes.h"
#include "lib/events/events.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "system/network.h"
#include "system/filesys.h"
#include "../include/ctdb_private.h"
diff --git a/source4/cluster/ctdb/common/ctdb_util.c b/source4/cluster/ctdb/common/ctdb_util.c
index f11388331d..67eb32221a 100644
--- a/source4/cluster/ctdb/common/ctdb_util.c
+++ b/source4/cluster/ctdb/common/ctdb_util.c
@@ -19,7 +19,7 @@
#include "includes.h"
#include "lib/events/events.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "system/network.h"
#include "system/filesys.h"
#include "../include/ctdb_private.h"
diff --git a/source4/cluster/ctdb/ctdb_cluster.c b/source4/cluster/ctdb/ctdb_cluster.c
index ce295c4474..e782091eec 100644
--- a/source4/cluster/ctdb/ctdb_cluster.c
+++ b/source4/cluster/ctdb/ctdb_cluster.c
@@ -24,7 +24,7 @@
#include "cluster/cluster.h"
#include "system/filesys.h"
#include "cluster/cluster_private.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "include/ctdb.h"
#include "tdb_wrap.h"
#include "lib/util/dlinklist.h"
diff --git a/source4/cluster/ctdb/opendb_ctdb.c b/source4/cluster/ctdb/opendb_ctdb.c
index b1faf9e0e6..3313798bee 100644
--- a/source4/cluster/ctdb/opendb_ctdb.c
+++ b/source4/cluster/ctdb/opendb_ctdb.c
@@ -40,7 +40,7 @@
#include "includes.h"
#include "system/filesys.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "messaging/messaging.h"
#include "tdb_wrap.h"
#include "lib/messaging/irpc.h"
diff --git a/source4/cluster/ctdb/server/ctdb_call.c b/source4/cluster/ctdb/server/ctdb_call.c
index bbe07717ed..0d09241d52 100644
--- a/source4/cluster/ctdb/server/ctdb_call.c
+++ b/source4/cluster/ctdb/server/ctdb_call.c
@@ -22,7 +22,7 @@
*/
#include "includes.h"
#include "lib/events/events.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/util/dlinklist.h"
#include "system/network.h"
#include "system/filesys.h"
diff --git a/source4/cluster/ctdb/server/ctdb_control.c b/source4/cluster/ctdb/server/ctdb_control.c
index 4b826b5187..ba94b9dd24 100644
--- a/source4/cluster/ctdb/server/ctdb_control.c
+++ b/source4/cluster/ctdb/server/ctdb_control.c
@@ -18,7 +18,7 @@
*/
#include "includes.h"
#include "lib/events/events.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "system/network.h"
#include "system/filesys.h"
#include "system/wait.h"
diff --git a/source4/cluster/ctdb/server/ctdb_daemon.c b/source4/cluster/ctdb/server/ctdb_daemon.c
index f96cd86916..46e81ab3c3 100644
--- a/source4/cluster/ctdb/server/ctdb_daemon.c
+++ b/source4/cluster/ctdb/server/ctdb_daemon.c
@@ -18,7 +18,7 @@
*/
#include "includes.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/events/events.h"
#include "lib/util/dlinklist.h"
#include "system/network.h"
diff --git a/source4/cluster/ctdb/server/ctdb_freeze.c b/source4/cluster/ctdb/server/ctdb_freeze.c
index 2294266890..391c6b86d0 100644
--- a/source4/cluster/ctdb/server/ctdb_freeze.c
+++ b/source4/cluster/ctdb/server/ctdb_freeze.c
@@ -18,7 +18,7 @@
*/
#include "includes.h"
#include "lib/events/events.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "system/network.h"
#include "system/filesys.h"
#include "system/wait.h"
diff --git a/source4/cluster/ctdb/server/ctdb_lockwait.c b/source4/cluster/ctdb/server/ctdb_lockwait.c
index 2fc3e7a3ed..1112ab2054 100644
--- a/source4/cluster/ctdb/server/ctdb_lockwait.c
+++ b/source4/cluster/ctdb/server/ctdb_lockwait.c
@@ -21,7 +21,7 @@
#include "lib/events/events.h"
#include "system/filesys.h"
#include "system/wait.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "../include/ctdb_private.h"
diff --git a/source4/cluster/ctdb/server/ctdb_ltdb_server.c b/source4/cluster/ctdb/server/ctdb_ltdb_server.c
index 68ed546b27..cabdeb124c 100644
--- a/source4/cluster/ctdb/server/ctdb_ltdb_server.c
+++ b/source4/cluster/ctdb/server/ctdb_ltdb_server.c
@@ -19,7 +19,7 @@
#include "includes.h"
#include "lib/events/events.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "system/network.h"
#include "system/filesys.h"
#include "../include/ctdb_private.h"
diff --git a/source4/cluster/ctdb/server/ctdb_recover.c b/source4/cluster/ctdb/server/ctdb_recover.c
index 6065016e1f..1e70d1de7a 100644
--- a/source4/cluster/ctdb/server/ctdb_recover.c
+++ b/source4/cluster/ctdb/server/ctdb_recover.c
@@ -19,7 +19,7 @@
*/
#include "includes.h"
#include "lib/events/events.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "system/network.h"
#include "system/filesys.h"
#include "system/wait.h"
diff --git a/source4/cluster/ctdb/server/ctdb_server.c b/source4/cluster/ctdb/server/ctdb_server.c
index 1480127327..0cfbdc0f2f 100644
--- a/source4/cluster/ctdb/server/ctdb_server.c
+++ b/source4/cluster/ctdb/server/ctdb_server.c
@@ -18,7 +18,7 @@
*/
#include "includes.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/events/events.h"
#include "lib/util/dlinklist.h"
#include "system/network.h"
diff --git a/source4/cluster/ctdb/server/ctdb_takeover.c b/source4/cluster/ctdb/server/ctdb_takeover.c
index 42a23808dd..53a5a1dc3c 100644
--- a/source4/cluster/ctdb/server/ctdb_takeover.c
+++ b/source4/cluster/ctdb/server/ctdb_takeover.c
@@ -19,7 +19,7 @@
*/
#include "includes.h"
#include "lib/events/events.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/util/dlinklist.h"
#include "system/network.h"
#include "system/filesys.h"
diff --git a/source4/cluster/ctdb/server/ctdb_traverse.c b/source4/cluster/ctdb/server/ctdb_traverse.c
index 233de62e2b..d735594e73 100644
--- a/source4/cluster/ctdb/server/ctdb_traverse.c
+++ b/source4/cluster/ctdb/server/ctdb_traverse.c
@@ -21,7 +21,7 @@
#include "lib/events/events.h"
#include "system/filesys.h"
#include "system/wait.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "../include/ctdb_private.h"
typedef void (*ctdb_traverse_fn_t)(void *private_data, TDB_DATA key, TDB_DATA data);
diff --git a/source4/cluster/ctdb/takeover/ctdb_takeover.c b/source4/cluster/ctdb/takeover/ctdb_takeover.c
index 862382d90a..ae68725271 100644
--- a/source4/cluster/ctdb/takeover/ctdb_takeover.c
+++ b/source4/cluster/ctdb/takeover/ctdb_takeover.c
@@ -19,7 +19,7 @@
*/
#include "includes.h"
#include "lib/events/events.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "system/network.h"
#include "system/filesys.h"
#include "system/wait.h"
diff --git a/source4/cluster/ctdb/tcp/tcp_connect.c b/source4/cluster/ctdb/tcp/tcp_connect.c
index 2f828e5717..3c167532ba 100644
--- a/source4/cluster/ctdb/tcp/tcp_connect.c
+++ b/source4/cluster/ctdb/tcp/tcp_connect.c
@@ -19,7 +19,7 @@
#include "includes.h"
#include "lib/events/events.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "system/network.h"
#include "system/filesys.h"
#include "../include/ctdb_private.h"
diff --git a/source4/cluster/ctdb/tcp/tcp_init.c b/source4/cluster/ctdb/tcp/tcp_init.c
index f5d4e4c1d6..b8296d5244 100644
--- a/source4/cluster/ctdb/tcp/tcp_init.c
+++ b/source4/cluster/ctdb/tcp/tcp_init.c
@@ -18,7 +18,7 @@
*/
#include "includes.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/events/events.h"
#include "system/network.h"
#include "system/filesys.h"
diff --git a/source4/cluster/ctdb/tcp/tcp_io.c b/source4/cluster/ctdb/tcp/tcp_io.c
index c10afb3425..d3afdc165a 100644
--- a/source4/cluster/ctdb/tcp/tcp_io.c
+++ b/source4/cluster/ctdb/tcp/tcp_io.c
@@ -20,7 +20,7 @@
#include "includes.h"
#include "lib/events/events.h"
#include "lib/util/dlinklist.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "system/network.h"
#include "system/filesys.h"
#include "../include/ctdb_private.h"
diff --git a/source4/cluster/local.c b/source4/cluster/local.c
index 96636927f1..f0357f0b07 100644
--- a/source4/cluster/local.c
+++ b/source4/cluster/local.c
@@ -22,7 +22,7 @@
#include "includes.h"
#include "cluster/cluster.h"
#include "cluster/cluster_private.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "tdb_wrap.h"
#include "system/filesys.h"
#include "param/param.h"
diff --git a/source4/configure.ac b/source4/configure.ac
index cfae02bb6c..fa2d8d9950 100644
--- a/source4/configure.ac
+++ b/source4/configure.ac
@@ -11,7 +11,7 @@ AC_DEFINE(CONFIG_H_IS_FROM_SAMBA,1,[Marker for samba's config.h])
# Configuration rules.
m4_include(build/m4/env.m4)
-m4_include(lib/replace/samba.m4)
+m4_include(../lib/replace/samba.m4)
m4_include(lib/smbreadline/readline.m4)
m4_include(heimdal_build/config.m4)
m4_include(lib/util/fault.m4)
@@ -21,12 +21,12 @@ m4_include(lib/util/fsusage.m4)
m4_include(lib/util/xattr.m4)
m4_include(lib/util/capability.m4)
m4_include(lib/util/time.m4)
-m4_include(lib/popt/samba.m4)
+m4_include(../lib/popt/samba.m4)
m4_include(lib/charset/config.m4)
m4_include(lib/socket/config.m4)
m4_include(lib/zlib.m4)
m4_include(nsswitch/nsstest.m4)
-m4_include(pidl/config.m4)
+m4_include(../pidl/config.m4)
AC_CONFIG_FILES(lib/registry/registry.pc)
AC_CONFIG_FILES(lib/events/events.pc)
@@ -41,20 +41,20 @@ AC_CONFIG_FILES(librpc/dcerpc_atsvc.pc)
SMB_EXT_LIB_FROM_PKGCONFIG(LIBTALLOC, talloc >= 1.2.0,
[],
[
- m4_include(lib/talloc/libtalloc.m4)
- SMB_INCLUDE_MK(lib/talloc/config.mk)
+ m4_include(../lib/talloc/libtalloc.m4)
+ SMB_INCLUDE_MK(../lib/talloc/config.mk)
]
)
SMB_EXT_LIB_FROM_PKGCONFIG(LIBTDB, tdb >= 1.1.0,
[],
[
- m4_include(lib/tdb/libtdb.m4)
- SMB_INCLUDE_MK(lib/tdb/config.mk)
+ m4_include(../lib/tdb/libtdb.m4)
+ SMB_INCLUDE_MK(../lib/tdb/config.mk)
]
)
-SMB_INCLUDE_MK(lib/tdb/python.mk)
+SMB_INCLUDE_MK(../lib/tdb/python.mk)
SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb >= 0.9.1,
[
@@ -99,8 +99,8 @@ m4_include(auth/gensec/config.m4)
m4_include(smbd/process_model.m4)
m4_include(ntvfs/posix/config.m4)
m4_include(ntvfs/unixuid/config.m4)
-m4_include(lib/socket_wrapper/config.m4)
-m4_include(lib/nss_wrapper/config.m4)
+m4_include(../lib/socket_wrapper/config.m4)
+m4_include(../lib/nss_wrapper/config.m4)
m4_include(auth/config.m4)
m4_include(kdc/config.m4)
m4_include(ntvfs/sysdep/config.m4)
@@ -158,7 +158,7 @@ then
builddir_headers="-I\$(builddir)/include -I\$(builddir) -I\$(builddir)/lib ";
fi
-CPPFLAGS="$builddir_headers-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -I\$(srcdir)/lib/replace -I\$(srcdir)/lib/talloc -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H $CPPFLAGS"
+CPPFLAGS="$builddir_headers-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -I\$(srcdir)/../lib/replace -I\$(srcdir)/../lib/talloc -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H $CPPFLAGS"
SMB_WRITE_PERLVARS(build/smb_build/config.pm)
diff --git a/source4/heimdal_build/config.h b/source4/heimdal_build/config.h
index 38cdfbb6a6..e15c6effa8 100644
--- a/source4/heimdal_build/config.h
+++ b/source4/heimdal_build/config.h
@@ -7,7 +7,7 @@
#define HAVE_HEIMDAL_CONFIG_H
#include "include/config.h"
-#include "lib/replace/replace.h"
+#include "../replace/replace.h"
#define RCSID(msg) struct __rcsid { int __rcsdi; }
#define KRB5
diff --git a/source4/heimdal_build/gssapi-glue.c b/source4/heimdal_build/gssapi-glue.c
index 0885c2165b..c71b69463c 100644
--- a/source4/heimdal_build/gssapi-glue.c
+++ b/source4/heimdal_build/gssapi-glue.c
@@ -19,7 +19,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "lib/replace/replace.h"
+#include "../replace/replace.h"
void *__gss_ntlm_initialize(void)
{
diff --git a/source4/include/includes.h b/source4/include/includes.h
index df0d8f7713..750ebc4137 100644
--- a/source4/include/includes.h
+++ b/source4/include/includes.h
@@ -20,7 +20,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "lib/replace/replace.h"
+#include "../replace/replace.h"
/* make sure we have included the correct config.h */
#ifndef NO_CONFIG_H /* for some tests */
diff --git a/source4/lib/com/main.c b/source4/lib/com/main.c
index 3e4127f246..882b479cfe 100644
--- a/source4/lib/com/main.c
+++ b/source4/lib/com/main.c
@@ -19,11 +19,10 @@
*/
#include "includes.h"
-#include "dlinklist.h"
+#include "lib/util/dlinklist.h"
#include "lib/com/com.h"
#include "lib/events/events.h"
#include "librpc/gen_ndr/com_dcom.h"
-#include "build.h"
WERROR com_init_ctx(struct com_context **ctx, struct event_context *event_ctx)
{
diff --git a/source4/lib/com/tables.c b/source4/lib/com/tables.c
index d9989ecdbe..11bf95c4d6 100644
--- a/source4/lib/com/tables.c
+++ b/source4/lib/com/tables.c
@@ -19,7 +19,7 @@
*/
#include "includes.h"
-#include "dlinklist.h"
+#include "lib/util/dlinklist.h"
#include "lib/com/com.h"
#include "librpc/gen_ndr/ndr_misc.h"
diff --git a/source4/lib/compression/lzxpress.c b/source4/lib/compression/lzxpress.c
deleted file mode 100644
index 0abbfc4d3d..0000000000
--- a/source4/lib/compression/lzxpress.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Copyright (C) Matthieu Suiche 2008
- *
- * 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. Neither the name of the author nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- */
-
-#include "replace.h"
-#include "lzxpress.h"
-
-
-#define __BUF_POS_CONST(buf,ofs)(((const uint8_t *)buf)+(ofs))
-#define __PULL_BYTE(buf,ofs) \
- ((uint8_t)((*__BUF_POS_CONST(buf,ofs)) & 0xFF))
-
-#ifndef PULL_LE_UINT16
-#define PULL_LE_UINT16(buf,ofs) ((uint16_t)( \
- ((uint16_t)(((uint16_t)(__PULL_BYTE(buf,(ofs)+0))) << 0)) | \
- ((uint16_t)(((uint16_t)(__PULL_BYTE(buf,(ofs)+1))) << 8)) \
-))
-#endif
-
-#ifndef PULL_LE_UINT32
-#define PULL_LE_UINT32(buf,ofs) ((uint32_t)( \
- ((uint32_t)(((uint32_t)(__PULL_BYTE(buf,(ofs)+0))) << 0)) | \
- ((uint32_t)(((uint32_t)(__PULL_BYTE(buf,(ofs)+1))) << 8)) | \
- ((uint32_t)(((uint32_t)(__PULL_BYTE(buf,(ofs)+2))) << 16)) | \
- ((uint32_t)(((uint32_t)(__PULL_BYTE(buf,(ofs)+3))) << 24)) \
-))
-#endif
-
-ssize_t lzxpress_compress(const uint8_t *uncompressed,
- uint32_t uncompressed_size,
- uint8_t *compressed,
- uint32_t max_compressed_size)
-{
- uint32_t uncompressed_pos, compressed_pos, byte_left;
- uint32_t max_offset, best_offset;
- int32_t offset;
- uint32_t max_len, len, best_len;
- const uint8_t *str1, *str2;
- uint32_t indic;
- uint8_t *indic_pos;
- uint32_t indic_bit, nibble_index;
-
- uint32_t metadata_size;
- uint16_t metadata;
- uint16_t *dest;
-
- if (!uncompressed_size) {
- return 0;
- }
-
- uncompressed_pos = 0;
- indic = 0;
- compressed_pos = sizeof(uint32_t);
- indic_pos = &compressed[0];
-
- byte_left = uncompressed_size;
- indic_bit = 0;
- nibble_index = 0;
-
- if (uncompressed_pos > XPRESS_BLOCK_SIZE)
- return 0;
-
- do {
- bool found = false;
-
- max_offset = uncompressed_pos;
-
- str1 = &uncompressed[uncompressed_pos];
-
- best_len = 2;
- best_offset = 0;
-
- max_offset = MIN(0x1FFF, max_offset);
-
- /* search for the longest match in the window for the lookahead buffer */
- for (offset = 1; (uint32_t)offset <= max_offset; offset++) {
- str2 = &str1[-offset];
-
- /* maximum len we can encode into metadata */
- max_len = MIN((255 + 15 + 7 + 3), byte_left);
-
- for (len = 0; (len < max_len) && (str1[len] == str2[len]); len++);
-
- /*
- * We check if len is better than the value found before, including the
- * sequence of identical bytes
- */
- if (len > best_len) {
- found = true;
- best_len = len;
- best_offset = offset;
- }
- }
-
- if (found) {
- metadata_size = 0;
- dest = (uint16_t *)&compressed[compressed_pos];
-
- if (best_len < 10) {
- /* Classical meta-data */
- metadata = (uint16_t)(((best_offset - 1) << 3) | (best_len - 3));
- dest[metadata_size / sizeof(uint16_t)] = metadata;
- metadata_size += sizeof(uint16_t);
- } else {
- metadata = (uint16_t)(((best_offset - 1) << 3) | 7);
- dest[metadata_size / sizeof(uint16_t)] = metadata;
- metadata_size = sizeof(uint16_t);
-
- if (best_len < (15 + 7 + 3)) {
- /* Shared byte */
- if (!nibble_index) {
- compressed[compressed_pos + metadata_size] = (best_len - (3 + 7)) & 0xF;
- metadata_size += sizeof(uint8_t);
- } else {
- compressed[nibble_index] &= 0xF;
- compressed[nibble_index] |= (best_len - (3 + 7)) * 16;
- }
- } else if (best_len < (3 + 7 + 15 + 255)) {
- /* Shared byte */
- if (!nibble_index) {
- compressed[compressed_pos + metadata_size] = 15;
- metadata_size += sizeof(uint8_t);
- } else {
- compressed[nibble_index] &= 0xF;
- compressed[nibble_index] |= (15 * 16);
- }
-
- /* Additionnal best_len */
- compressed[compressed_pos + metadata_size] = (best_len - (3 + 7 + 15)) & 0xFF;
- metadata_size += sizeof(uint8_t);
- } else {
- /* Shared byte */
- if (!nibble_index) {
- compressed[compressed_pos + metadata_size] |= 15;
- metadata_size += sizeof(uint8_t);
- } else {
- compressed[nibble_index] |= 15 << 4;
- }
-
- /* Additionnal best_len */
- compressed[compressed_pos + metadata_size] = 255;
-
- metadata_size += sizeof(uint8_t);
-
- compressed[compressed_pos + metadata_size] = (best_len - 3) & 0xFF;
- compressed[compressed_pos + metadata_size + 1] = ((best_len - 3) >> 8) & 0xFF;
- metadata_size += sizeof(uint16_t);
- }
- }
-
- indic |= 1 << (32 - ((indic_bit % 32) + 1));
-
- if (best_len > 9) {
- if (nibble_index == 0) {
- nibble_index = compressed_pos + sizeof(uint16_t);
- } else {
- nibble_index = 0;
- }
- }
-
- compressed_pos += metadata_size;
- uncompressed_pos += best_len;
- byte_left -= best_len;
- } else {
- compressed[compressed_pos++] = uncompressed[uncompressed_pos++];
- byte_left--;
- }
- indic_bit++;
-
- if ((indic_bit - 1) % 32 > (indic_bit % 32)) {
- *(uint32_t *)indic_pos = indic;
- indic = 0;
- indic_pos = &compressed[compressed_pos];
- compressed_pos += sizeof(uint32_t);
- }
- } while (byte_left > 3);
-
- do {
- compressed[compressed_pos] = uncompressed[uncompressed_pos];
- indic_bit++;
-
- uncompressed_pos++;
- compressed_pos++;
- if (((indic_bit - 1) % 32) > (indic_bit % 32)){
- *(uint32_t *)indic_pos = indic;
- indic = 0;
- indic_pos = &compressed[compressed_pos];
- compressed_pos += sizeof(uint32_t);
- }
- } while (uncompressed_pos < uncompressed_size);
-
- if ((indic_bit % 32) > 0) {
- for (; (indic_bit % 32) != 0; indic_bit++)
- indic |= 0 << (32 - ((indic_bit % 32) + 1));
-
- *(uint32_t *)indic_pos = indic;
- compressed_pos += sizeof(uint32_t);
- }
-
- return compressed_pos;
-}
-
-ssize_t lzxpress_decompress(const uint8_t *input,
- uint32_t input_size,
- uint8_t *output,
- uint32_t max_output_size)
-{
- uint32_t output_index, input_index;
- uint32_t indicator, indicator_bit;
- uint32_t length;
- uint32_t offset;
- uint32_t nibble_index;
-
- output_index = 0;
- input_index = 0;
- indicator = 0;
- indicator_bit = 0;
- length = 0;
- offset = 0;
- nibble_index = 0;
-
- do {
- if (indicator_bit == 0) {
- indicator = PULL_LE_UINT32(input, input_index);
- input_index += sizeof(uint32_t);
- indicator_bit = 32;
- }
- indicator_bit--;
-
- /*
- * check whether the bit specified by indicator_bit is set or not
- * set in indicator. For example, if indicator_bit has value 4
- * check whether the 4th bit of the value in indicator is set
- */
- if (((indicator >> indicator_bit) & 1) == 0) {
- output[output_index] = input[input_index];
- input_index += sizeof(uint8_t);
- output_index += sizeof(uint8_t);
- } else {
- length = PULL_LE_UINT16(input, input_index);
- input_index += sizeof(uint16_t);
- offset = length / 8;
- length = length % 8;
-
- if (length == 7) {
- if (nibble_index == 0) {
- nibble_index = input_index;
- length = input[input_index] % 16;
- input_index += sizeof(uint8_t);
- } else {
- length = input[nibble_index] / 16;
- nibble_index = 0;
- }
-
- if (length == 15) {
- length = input[input_index];
- input_index += sizeof(uint8_t);
- if (length == 255) {
- length = PULL_LE_UINT16(input, input_index);
- input_index += sizeof(uint16_t);
- length -= (15 + 7);
- }
- length += 15;
- }
- length += 7;
- }
-
- length += 3;
-
- do {
- if ((output_index >= max_output_size) || ((offset + 1) > output_index)) break;
-
- output[output_index] = output[output_index - offset - 1];
-
- output_index += sizeof(uint8_t);
- length -= sizeof(uint8_t);
- } while (length != 0);
- }
- } while ((output_index < max_output_size) && (input_index < (input_size)));
-
- return output_index;
-}
diff --git a/source4/lib/compression/lzxpress.h b/source4/lib/compression/lzxpress.h
deleted file mode 100644
index df0ee59a0e..0000000000
--- a/source4/lib/compression/lzxpress.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) Matthieu Suiche 2008
- *
- * 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. Neither the name of the author nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- */
-
-#ifndef _LZXPRESS_H
-#define _LZXPRESS_H
-
-#define XPRESS_BLOCK_SIZE 0x10000
-
-ssize_t lzxpress_compress(const uint8_t *uncompressed,
- uint32_t uncompressed_size,
- uint8_t *compressed,
- uint32_t max_compressed_size);
-
-ssize_t lzxpress_decompress(const uint8_t *input,
- uint32_t input_size,
- uint8_t *output,
- uint32_t max_output_size);
-
-#endif /* _LZXPRESS_H */
diff --git a/source4/lib/compression/mszip.c b/source4/lib/compression/mszip.c
deleted file mode 100644
index 59961d6c06..0000000000
--- a/source4/lib/compression/mszip.c
+++ /dev/null
@@ -1,676 +0,0 @@
-/* mszip decompression - based on cabextract.c code from
- * Stuart Caie
- *
- * adapted for Samba by Andrew Tridgell and Stefan Metzmacher 2005
- *
- * (C) 2000-2001 Stuart Caie <kyzer@4u.net>
- * reaktivate-specifics by Malte Starostik <malte@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "includes.h"
-#include "lib/compression/mszip.h"
-
-/*--------------------------------------------------------------------------*/
-/* our archiver information / state */
-
-/* MSZIP stuff */
-#define ZIPWSIZE 0x8000 /* window size */
-#define ZIPLBITS 9 /* bits in base literal/length lookup table */
-#define ZIPDBITS 6 /* bits in base distance lookup table */
-#define ZIPBMAX 16 /* maximum bit length of any code */
-#define ZIPN_MAX 288 /* maximum number of codes in any set */
-
-struct Ziphuft {
- uint8_t e; /* number of extra bits or operation */
- uint8_t b; /* number of bits in this code or subcode */
- union {
- uint16_t n; /* literal, length base, or distance base */
- struct Ziphuft *t; /* pointer to next level of table */
- } v;
-};
-
-struct ZIPstate {
- uint32_t window_posn; /* current offset within the window */
- uint32_t bb; /* bit buffer */
- uint32_t bk; /* bits in bit buffer */
- uint32_t ll[288+32]; /* literal/length and distance code lengths */
- uint32_t c[ZIPBMAX+1]; /* bit length count table */
- int32_t lx[ZIPBMAX+1]; /* memory for l[-1..ZIPBMAX-1] */
- struct Ziphuft *u[ZIPBMAX]; /* table stack */
- uint32_t v[ZIPN_MAX]; /* values in order of bit length */
- uint32_t x[ZIPBMAX+1]; /* bit offsets, then code stack */
- uint8_t *inpos;
-};
-
-/* generic stuff */
-#define CAB(x) (decomp_state->x)
-#define ZIP(x) (decomp_state->methods.zip.x)
-
-/* CAB data blocks are <= 32768 bytes in uncompressed form. Uncompressed
- * blocks have zero growth. MSZIP guarantees that it won't grow above
- * uncompressed size by more than 12 bytes. LZX guarantees it won't grow
- * more than 6144 bytes.
- */
-#define CAB_BLOCKMAX (32768)
-#define CAB_INPUTMAX (CAB_BLOCKMAX+6144)
-
-struct decomp_state {
- struct folder *current; /* current folder we're extracting from */
- uint32_t offset; /* uncompressed offset within folder */
- uint8_t *outpos; /* (high level) start of data to use up */
- uint16_t outlen; /* (high level) amount of data to use up */
- uint16_t split; /* at which split in current folder? */
- int (*decompress)(int, int); /* the chosen compression func */
- uint8_t inbuf[CAB_INPUTMAX+2]; /* +2 for lzx bitbuffer overflows! */
- uint8_t outbuf[CAB_BLOCKMAX];
- union {
- struct ZIPstate zip;
- } methods;
-};
-
-
-/* MSZIP decruncher */
-
-/* Dirk Stoecker wrote the ZIP decoder, based on the InfoZip deflate code */
-
-/* Tables for deflate from PKZIP's appnote.txt. */
-static const uint8_t Zipborder[] = /* Order of the bit length code lengths */
-{ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-static const uint16_t Zipcplens[] = /* Copy lengths for literal codes 257..285 */
-{ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51,
- 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
-static const uint16_t Zipcplext[] = /* Extra bits for literal codes 257..285 */
-{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,
- 4, 5, 5, 5, 5, 0, 99, 99}; /* 99==invalid */
-static const uint16_t Zipcpdist[] = /* Copy offsets for distance codes 0..29 */
-{ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385,
-513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577};
-static const uint16_t Zipcpdext[] = /* Extra bits for distance codes */
-{ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10,
-10, 11, 11, 12, 12, 13, 13};
-
-/* And'ing with Zipmask[n] masks the lower n bits */
-static const uint16_t Zipmask[17] = {
- 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
- 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
-};
-
-#define ZIPNEEDBITS(n) {while(k<(n)){int32_t c=*(ZIP(inpos)++);\
- b|=((uint32_t)c)<<k;k+=8;}}
-#define ZIPDUMPBITS(n) {b>>=(n);k-=(n);}
-
-static void Ziphuft_free(struct Ziphuft *t)
-{
- register struct Ziphuft *p, *q;
-
- /* Go through linked list, freeing from the allocated (t[-1]) address. */
- p = t;
- while (p != (struct Ziphuft *)NULL)
- {
- q = (--p)->v.t;
- free(p);
- p = q;
- }
-}
-
-static int32_t Ziphuft_build(struct decomp_state *decomp_state,
- uint32_t *b, uint32_t n, uint32_t s, const uint16_t *d, const uint16_t *e,
- struct Ziphuft **t, int32_t *m)
-{
- uint32_t a; /* counter for codes of length k */
- uint32_t el; /* length of EOB code (value 256) */
- uint32_t f; /* i repeats in table every f entries */
- int32_t g; /* maximum code length */
- int32_t h; /* table level */
- register uint32_t i; /* counter, current code */
- register uint32_t j; /* counter */
- register int32_t k; /* number of bits in current code */
- int32_t *l; /* stack of bits per table */
- register uint32_t *p; /* pointer into ZIP(c)[],ZIP(b)[],ZIP(v)[] */
- register struct Ziphuft *q; /* points to current table */
- struct Ziphuft r; /* table entry for structure assignment */
- register int32_t w; /* bits before this table == (l * h) */
- uint32_t *xp; /* pointer into x */
- int32_t y; /* number of dummy codes added */
- uint32_t z; /* number of entries in current table */
-
- l = ZIP(lx)+1;
-
- /* Generate counts for each bit length */
- el = n > 256 ? b[256] : ZIPBMAX; /* set length of EOB code, if any */
-
- for(i = 0; i < ZIPBMAX+1; ++i)
- ZIP(c)[i] = 0;
- p = b; i = n;
- do
- {
- ZIP(c)[*p]++; p++; /* assume all entries <= ZIPBMAX */
- } while (--i);
- if (ZIP(c)[0] == n) /* null input--all zero length codes */
- {
- *t = (struct Ziphuft *)NULL;
- *m = 0;
- return 0;
- }
-
- /* Find minimum and maximum length, bound *m by those */
- for (j = 1; j <= ZIPBMAX; j++)
- if (ZIP(c)[j])
- break;
- k = j; /* minimum code length */
- if ((uint32_t)*m < j)
- *m = j;
- for (i = ZIPBMAX; i; i--)
- if (ZIP(c)[i])
- break;
- g = i; /* maximum code length */
- if ((uint32_t)*m > i)
- *m = i;
-
- /* Adjust last length count to fill out codes, if needed */
- for (y = 1 << j; j < i; j++, y <<= 1)
- if ((y -= ZIP(c)[j]) < 0)
- return 2; /* bad input: more codes than bits */
- if ((y -= ZIP(c)[i]) < 0)
- return 2;
- ZIP(c)[i] += y;
-
- /* Generate starting offsets int32_to the value table for each length */
- ZIP(x)[1] = j = 0;
- p = ZIP(c) + 1; xp = ZIP(x) + 2;
- while (--i)
- { /* note that i == g from above */
- *xp++ = (j += *p++);
- }
-
- /* Make a table of values in order of bit lengths */
- p = b; i = 0;
- do{
- if ((j = *p++) != 0)
- ZIP(v)[ZIP(x)[j]++] = i;
- } while (++i < n);
-
-
- /* Generate the Huffman codes and for each, make the table entries */
- ZIP(x)[0] = i = 0; /* first Huffman code is zero */
- p = ZIP(v); /* grab values in bit order */
- h = -1; /* no tables yet--level -1 */
- w = l[-1] = 0; /* no bits decoded yet */
- ZIP(u)[0] = (struct Ziphuft *)NULL; /* just to keep compilers happy */
- q = (struct Ziphuft *)NULL; /* ditto */
- z = 0; /* ditto */
-
- /* go through the bit lengths (k already is bits in shortest code) */
- for (; k <= g; k++)
- {
- a = ZIP(c)[k];
- while (a--)
- {
- /* here i is the Huffman code of length k bits for value *p */
- /* make tables up to required level */
- while (k > w + l[h])
- {
- w += l[h++]; /* add bits already decoded */
-
- /* compute minimum size table less than or equal to *m bits */
- z = (z = g - w) > (uint32_t)*m ? *m : z; /* upper limit */
- if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
- { /* too few codes for k-w bit table */
- f -= a + 1; /* deduct codes from patterns left */
- xp = ZIP(c) + k;
- while (++j < z) /* try smaller tables up to z bits */
- {
- if ((f <<= 1) <= *++xp)
- break; /* enough codes to use up j bits */
- f -= *xp; /* else deduct codes from patterns */
- }
- }
- if ((uint32_t)w + j > el && (uint32_t)w < el)
- j = el - w; /* make EOB code end at table */
- z = 1 << j; /* table entries for j-bit table */
- l[h] = j; /* set table size in stack */
-
- /* allocate and link in new table */
- if (!(q = (struct Ziphuft *) malloc((z + 1)*sizeof(struct Ziphuft))))
- {
- if(h)
- Ziphuft_free(ZIP(u)[0]);
- return 3; /* not enough memory */
- }
- *t = q + 1; /* link to list for Ziphuft_free() */
- *(t = &(q->v.t)) = (struct Ziphuft *)NULL;
- ZIP(u)[h] = ++q; /* table starts after link */
-
- /* connect to last table, if there is one */
- if (h)
- {
- ZIP(x)[h] = i; /* save pattern for backing up */
- r.b = (uint8_t)l[h-1]; /* bits to dump before this table */
- r.e = (uint8_t)(16 + j); /* bits in this table */
- r.v.t = q; /* pointer to this table */
- j = (i & ((1 << w) - 1)) >> (w - l[h-1]);
- ZIP(u)[h-1][j] = r; /* connect to last table */
- }
- }
-
- /* set up table entry in r */
- r.b = (uint8_t)(k - w);
- if (p >= ZIP(v) + n)
- r.e = 99; /* out of values--invalid code */
- else if (*p < s)
- {
- r.e = (uint8_t)(*p < 256 ? 16 : 15); /* 256 is end-of-block code */
- r.v.n = *p++; /* simple code is just the value */
- }
- else
- {
- r.e = (uint8_t)e[*p - s]; /* non-simple--look up in lists */
- r.v.n = d[*p++ - s];
- }
-
- /* fill code-like entries with r */
- f = 1 << (k - w);
- for (j = i >> w; j < z; j += f)
- q[j] = r;
-
- /* backwards increment the k-bit code i */
- for (j = 1 << (k - 1); i & j; j >>= 1)
- i ^= j;
- i ^= j;
-
- /* backup over finished tables */
- while ((i & ((1 << w) - 1)) != ZIP(x)[h])
- w -= l[--h]; /* don't need to update q */
- }
- }
-
- /* return actual size of base table */
- *m = l[0];
-
- /* Return true (1) if we were given an incomplete table */
- return y != 0 && g != 1;
-}
-
-static int32_t Zipinflate_codes(struct decomp_state *decomp_state,
- struct Ziphuft *tl, struct Ziphuft *td,
- int32_t bl, int32_t bd)
-{
- register uint32_t e; /* table entry flag/number of extra bits */
- uint32_t n, d; /* length and index for copy */
- uint32_t w; /* current window position */
- struct Ziphuft *t; /* pointer to table entry */
- uint32_t ml, md; /* masks for bl and bd bits */
- register uint32_t b; /* bit buffer */
- register uint32_t k; /* number of bits in bit buffer */
-
- DEBUG(10,("Zipinflate_codes\n"));
-
- /* make local copies of globals */
- b = ZIP(bb); /* initialize bit buffer */
- k = ZIP(bk);
- w = ZIP(window_posn); /* initialize window position */
-
- /* inflate the coded data */
- ml = Zipmask[bl]; /* precompute masks for speed */
- md = Zipmask[bd];
-
- for(;;)
- {
- ZIPNEEDBITS((uint32_t)bl)
- if((e = (t = tl + ((uint32_t)b & ml))->e) > 16)
- do
- {
- if (e == 99)
- return 1;
- ZIPDUMPBITS(t->b)
- e -= 16;
- ZIPNEEDBITS(e)
- } while ((e = (t = t->v.t + ((uint32_t)b & Zipmask[e]))->e) > 16);
- ZIPDUMPBITS(t->b)
- if (w >= CAB_BLOCKMAX) break;
- if (e == 16) /* then it's a literal */
- CAB(outbuf)[w++] = (uint8_t)t->v.n;
- else /* it's an EOB or a length */
- {
- /* exit if end of block */
- if(e == 15)
- break;
-
- /* get length of block to copy */
- ZIPNEEDBITS(e)
- n = t->v.n + ((uint32_t)b & Zipmask[e]);
- ZIPDUMPBITS(e);
-
- /* decode distance of block to copy */
- ZIPNEEDBITS((uint32_t)bd)
- if ((e = (t = td + ((uint32_t)b & md))->e) > 16)
- do {
- if (e == 99)
- return 1;
- ZIPDUMPBITS(t->b)
- e -= 16;
- ZIPNEEDBITS(e)
- } while ((e = (t = t->v.t + ((uint32_t)b & Zipmask[e]))->e) > 16);
- ZIPDUMPBITS(t->b)
- ZIPNEEDBITS(e)
- d = w - t->v.n - ((uint32_t)b & Zipmask[e]);
- ZIPDUMPBITS(e)
- do
- {
- n -= (e = (e = ZIPWSIZE - ((d &= ZIPWSIZE-1) > w ? d : w)) > n ?n:e);
- do
- {
- CAB(outbuf)[w++] = CAB(outbuf)[d++];
- } while (--e);
- } while (n);
- }
- }
-
- /* restore the globals from the locals */
- ZIP(window_posn) = w; /* restore global window pointer */
- ZIP(bb) = b; /* restore global bit buffer */
- ZIP(bk) = k;
-
- /* done */
- return 0;
-}
-
-/* "decompress" an inflated type 0 (stored) block. */
-static int32_t Zipinflate_stored(struct decomp_state *decomp_state)
-{
- uint32_t n; /* number of bytes in block */
- uint32_t w; /* current window position */
- register uint32_t b; /* bit buffer */
- register uint32_t k; /* number of bits in bit buffer */
-
- /* make local copies of globals */
- b = ZIP(bb); /* initialize bit buffer */
- k = ZIP(bk);
- w = ZIP(window_posn); /* initialize window position */
-
- /* go to byte boundary */
- n = k & 7;
- ZIPDUMPBITS(n);
-
- /* get the length and its complement */
- ZIPNEEDBITS(16)
- n = ((uint32_t)b & 0xffff);
- ZIPDUMPBITS(16)
- ZIPNEEDBITS(16)
- if (n != (uint32_t)((~b) & 0xffff))
- return 1; /* error in compressed data */
- ZIPDUMPBITS(16)
-
- /* read and output the compressed data */
- while(n--)
- {
- ZIPNEEDBITS(8)
- CAB(outbuf)[w++] = (uint8_t)b;
- ZIPDUMPBITS(8)
- }
-
- /* restore the globals from the locals */
- ZIP(window_posn) = w; /* restore global window pointer */
- ZIP(bb) = b; /* restore global bit buffer */
- ZIP(bk) = k;
- return 0;
-}
-
-static int32_t Zipinflate_fixed(struct decomp_state *decomp_state)
-{
- struct Ziphuft *fixed_tl;
- struct Ziphuft *fixed_td;
- int32_t fixed_bl, fixed_bd;
- int32_t i; /* temporary variable */
- uint32_t *l;
-
- l = ZIP(ll);
-
- /* literal table */
- for(i = 0; i < 144; i++)
- l[i] = 8;
- for(; i < 256; i++)
- l[i] = 9;
- for(; i < 280; i++)
- l[i] = 7;
- for(; i < 288; i++) /* make a complete, but wrong code set */
- l[i] = 8;
- fixed_bl = 7;
- if((i = Ziphuft_build(decomp_state, l, 288, 257, Zipcplens, Zipcplext, &fixed_tl, &fixed_bl)))
- return i;
-
- /* distance table */
- for(i = 0; i < 30; i++) /* make an incomplete code set */
- l[i] = 5;
- fixed_bd = 5;
- if((i = Ziphuft_build(decomp_state, l, 30, 0, Zipcpdist, Zipcpdext, &fixed_td, &fixed_bd)) > 1)
- {
- Ziphuft_free(fixed_tl);
- return i;
- }
-
- /* decompress until an end-of-block code */
- i = Zipinflate_codes(decomp_state, fixed_tl, fixed_td, fixed_bl, fixed_bd);
-
- Ziphuft_free(fixed_td);
- Ziphuft_free(fixed_tl);
- return i;
-}
-
-/* decompress an inflated type 2 (dynamic Huffman codes) block. */
-static int32_t Zipinflate_dynamic(struct decomp_state *decomp_state)
-{
- int32_t i; /* temporary variables */
- uint32_t j;
- uint32_t *ll;
- uint32_t l; /* last length */
- uint32_t m; /* mask for bit lengths table */
- uint32_t n; /* number of lengths to get */
- struct Ziphuft *tl; /* literal/length code table */
- struct Ziphuft *td; /* distance code table */
- int32_t bl; /* lookup bits for tl */
- int32_t bd; /* lookup bits for td */
- uint32_t nb; /* number of bit length codes */
- uint32_t nl; /* number of literal/length codes */
- uint32_t nd; /* number of distance codes */
- register uint32_t b; /* bit buffer */
- register uint32_t k; /* number of bits in bit buffer */
-
- /* make local bit buffer */
- b = ZIP(bb);
- k = ZIP(bk);
- ll = ZIP(ll);
-
- /* read in table lengths */
- ZIPNEEDBITS(5)
- nl = 257 + ((uint32_t)b & 0x1f); /* number of literal/length codes */
- ZIPDUMPBITS(5)
- ZIPNEEDBITS(5)
- nd = 1 + ((uint32_t)b & 0x1f); /* number of distance codes */
- ZIPDUMPBITS(5)
- ZIPNEEDBITS(4)
- nb = 4 + ((uint32_t)b & 0xf); /* number of bit length codes */
- ZIPDUMPBITS(4)
- if(nl > 288 || nd > 32)
- return 1; /* bad lengths */
-
- /* read in bit-length-code lengths */
- for(j = 0; j < nb; j++)
- {
- ZIPNEEDBITS(3)
- ll[Zipborder[j]] = (uint32_t)b & 7;
- ZIPDUMPBITS(3)
- }
- for(; j < 19; j++)
- ll[Zipborder[j]] = 0;
-
- /* build decoding table for trees--single level, 7 bit lookup */
- bl = 7;
- if((i = Ziphuft_build(decomp_state, ll, 19, 19, NULL, NULL, &tl, &bl)) != 0)
- {
- if(i == 1)
- Ziphuft_free(tl);
- return i; /* incomplete code set */
- }
-
- /* read in literal and distance code lengths */
- n = nl + nd;
- m = Zipmask[bl];
- i = l = 0;
- while((uint32_t)i < n)
- {
- ZIPNEEDBITS((uint32_t)bl)
- j = (td = tl + ((uint32_t)b & m))->b;
- ZIPDUMPBITS(j)
- j = td->v.n;
- if (j < 16) /* length of code in bits (0..15) */
- ll[i++] = l = j; /* save last length in l */
- else if (j == 16) /* repeat last length 3 to 6 times */
- {
- ZIPNEEDBITS(2)
- j = 3 + ((uint32_t)b & 3);
- ZIPDUMPBITS(2)
- if((uint32_t)i + j > n)
- return 1;
- while (j--)
- ll[i++] = l;
- }
- else if (j == 17) /* 3 to 10 zero length codes */
- {
- ZIPNEEDBITS(3)
- j = 3 + ((uint32_t)b & 7);
- ZIPDUMPBITS(3)
- if ((uint32_t)i + j > n)
- return 1;
- while (j--)
- ll[i++] = 0;
- l = 0;
- }
- else /* j == 18: 11 to 138 zero length codes */
- {
- ZIPNEEDBITS(7)
- j = 11 + ((uint32_t)b & 0x7f);
- ZIPDUMPBITS(7)
- if ((uint32_t)i + j > n)
- return 1;
- while (j--)
- ll[i++] = 0;
- l = 0;
- }
- }
-
- /* free decoding table for trees */
- Ziphuft_free(tl);
-
- /* restore the global bit buffer */
- ZIP(bb) = b;
- ZIP(bk) = k;
-
- /* build the decoding tables for literal/length and distance codes */
- bl = ZIPLBITS;
- if((i = Ziphuft_build(decomp_state, ll, nl, 257, Zipcplens, Zipcplext, &tl, &bl)) != 0)
- {
- if(i == 1)
- Ziphuft_free(tl);
- return i; /* incomplete code set */
- }
- bd = ZIPDBITS;
- Ziphuft_build(decomp_state, ll + nl, nd, 0, Zipcpdist, Zipcpdext, &td, &bd);
-
- /* decompress until an end-of-block code */
- if(Zipinflate_codes(decomp_state, tl, td, bl, bd))
- return 1;
-
- /* free the decoding tables, return */
- Ziphuft_free(tl);
- Ziphuft_free(td);
- return 0;
-}
-
-/* e == last block flag */
-static int32_t Zipinflate_block(struct decomp_state *decomp_state, int32_t *e)
-{ /* decompress an inflated block */
- uint32_t t; /* block type */
- register uint32_t b; /* bit buffer */
- register uint32_t k; /* number of bits in bit buffer */
-
- DEBUG(10,("Zipinflate_block\n"));
-
- /* make local bit buffer */
- b = ZIP(bb);
- k = ZIP(bk);
-
- /* read in last block bit */
- ZIPNEEDBITS(1)
- *e = (int32_t)b & 1;
- ZIPDUMPBITS(1)
-
- /* read in block type */
- ZIPNEEDBITS(2)
- t = (uint32_t)b & 3;
- ZIPDUMPBITS(2)
-
- /* restore the global bit buffer */
- ZIP(bb) = b;
- ZIP(bk) = k;
-
- DEBUG(10,("inflate type %d\n", t));
-
- /* inflate that block type */
- if(t == 2)
- return Zipinflate_dynamic(decomp_state);
- if(t == 0)
- return Zipinflate_stored(decomp_state);
- if(t == 1)
- return Zipinflate_fixed(decomp_state);
- /* bad block type */
- return 2;
-}
-
-_PUBLIC_ struct decomp_state *ZIPdecomp_state(TALLOC_CTX *mem_ctx)
-{
- return talloc_zero(mem_ctx, struct decomp_state);
-}
-
-int ZIPdecompress(struct decomp_state *decomp_state, DATA_BLOB *inbuf, DATA_BLOB *outbuf)
-{
- int32_t e = 0;/* last block flag */
-
- ZIP(inpos) = CAB(inbuf);
- ZIP(bb) = ZIP(bk) = ZIP(window_posn) = 0;
-
- if (inbuf->length > sizeof(decomp_state->inbuf)) return DECR_INPUT;
-
- if (outbuf->length > sizeof(decomp_state->outbuf)) return DECR_OUTPUT;
-
- if (outbuf->length > ZIPWSIZE) return DECR_DATAFORMAT;
-
- memcpy(decomp_state->inbuf, inbuf->data, inbuf->length);
-
- /* CK = Chris Kirmse, official Microsoft purloiner */
- if (ZIP(inpos)[0] != 'C' || ZIP(inpos)[1] != 'K') return DECR_ILLEGALDATA;
- ZIP(inpos) += 2;
-
- while (!e) {
- if (Zipinflate_block(decomp_state, &e)) {
- return DECR_ILLEGALDATA;
- }
- }
-
- memcpy(outbuf->data, decomp_state->outbuf, outbuf->length);
-
- return DECR_OK;
-}
diff --git a/source4/lib/compression/mszip.h b/source4/lib/compression/mszip.h
deleted file mode 100644
index bb835f2595..0000000000
--- a/source4/lib/compression/mszip.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* mszip decompression - based on cabextract.c code from
- * Stuart Caie
- *
- * adapted for Samba by Andrew Tridgell and Stefan Metzmacher 2005
- *
- * (C) 2000-2001 Stuart Caie <kyzer@4u.net>
- * reaktivate-specifics by Malte Starostik <malte@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-struct decomp_state;
-struct decomp_state *ZIPdecomp_state(TALLOC_CTX *mem_ctx);
-
-#define DECR_OK (0)
-#define DECR_DATAFORMAT (1)
-#define DECR_ILLEGALDATA (2)
-#define DECR_NOMEMORY (3)
-#define DECR_CHECKSUM (4)
-#define DECR_INPUT (5)
-#define DECR_OUTPUT (6)
-int ZIPdecompress(struct decomp_state *decomp_state, DATA_BLOB *inbuf, DATA_BLOB *outbuf);
diff --git a/source4/lib/compression/testsuite.c b/source4/lib/compression/testsuite.c
deleted file mode 100644
index f6e4d49afb..0000000000
--- a/source4/lib/compression/testsuite.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- test suite for the compression functions
-
- Copyright (C) Jelmer Vernooij 2007
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "torture/torture.h"
-#include "lib/compression/mszip.h"
-
-struct torture_suite *torture_local_compression(TALLOC_CTX *mem_ctx)
-{
- struct torture_suite *suite = torture_suite_create(mem_ctx, "COMPRESSION");
-
- return suite;
-}
diff --git a/source4/lib/dbwrap/dbwrap.c b/source4/lib/dbwrap/dbwrap.c
index be48e97b5a..69203773f0 100644
--- a/source4/lib/dbwrap/dbwrap.c
+++ b/source4/lib/dbwrap/dbwrap.c
@@ -21,7 +21,7 @@
*/
#include "includes.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/dbwrap/dbwrap.h"
#include "param/param.h"
diff --git a/source4/lib/dbwrap/dbwrap_ctdb.c b/source4/lib/dbwrap/dbwrap_ctdb.c
index f3daa7dfe5..b079658a00 100644
--- a/source4/lib/dbwrap/dbwrap_ctdb.c
+++ b/source4/lib/dbwrap/dbwrap_ctdb.c
@@ -20,7 +20,7 @@
*/
#include "includes.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/dbwrap/dbwrap.h"
#include "cluster/cluster.h"
#include "cluster/ctdb/include/ctdb.h"
diff --git a/source4/lib/dbwrap/dbwrap_tdb.c b/source4/lib/dbwrap/dbwrap_tdb.c
index fae73a1db8..3fd13dbd13 100644
--- a/source4/lib/dbwrap/dbwrap_tdb.c
+++ b/source4/lib/dbwrap/dbwrap_tdb.c
@@ -21,7 +21,7 @@
*/
#include "includes.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/dbwrap/dbwrap.h"
#include "system/filesys.h"
#include "tdb_wrap.h"
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index 4b90e8c4fd..2125ba1fe6 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -30,8 +30,7 @@
#include "tdb_wrap.h"
#include "lib/util/unix_privs.h"
#include "librpc/rpc/dcerpc.h"
-#include "lib/tdb/include/tdb.h"
-#include "lib/util/util_tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/util/util_tdb.h"
#include "cluster/cluster.h"
#include "param/param.h"
diff --git a/source4/lib/nss_wrapper/config.m4 b/source4/lib/nss_wrapper/config.m4
deleted file mode 100644
index 58e94f9830..0000000000
--- a/source4/lib/nss_wrapper/config.m4
+++ /dev/null
@@ -1,19 +0,0 @@
-AC_ARG_ENABLE(nss-wrapper,
-[ --enable-nss-wrapper Turn on nss wrapper library (default=no)])
-
-HAVE_NSS_WRAPPER=no
-
-if eval "test x$developer = xyes"; then
- enable_nss_wrapper=yes
-fi
-
-if eval "test x$enable_nss_wrapper = xyes"; then
- AC_DEFINE(NSS_WRAPPER,1,[Use nss wrapper library])
- HAVE_NSS_WRAPPER=yes
-
- # this is only used for samba3
- NSS_WRAPPER_OBJS="lib/nss_wrapper/nss_wrapper.o"
-fi
-
-AC_SUBST(HAVE_NSS_WRAPPER)
-AC_SUBST(NSS_WRAPPER_OBJS)
diff --git a/source4/lib/nss_wrapper/config.mk b/source4/lib/nss_wrapper/config.mk
deleted file mode 100644
index 015fbe511c..0000000000
--- a/source4/lib/nss_wrapper/config.mk
+++ /dev/null
@@ -1,7 +0,0 @@
-##############################
-# Start SUBSYSTEM NSS_WRAPPER
-[SUBSYSTEM::NSS_WRAPPER]
-# End SUBSYSTEM NSS_WRAPPER
-##############################
-
-NSS_WRAPPER_OBJ_FILES = $(nsswrappersrcdir)/nss_wrapper.o
diff --git a/source4/lib/nss_wrapper/nss_wrapper.c b/source4/lib/nss_wrapper/nss_wrapper.c
deleted file mode 100644
index 5bf7ebda4f..0000000000
--- a/source4/lib/nss_wrapper/nss_wrapper.c
+++ /dev/null
@@ -1,1130 +0,0 @@
-/*
- * Copyright (C) Stefan Metzmacher 2007 <metze@samba.org>
- *
- * 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. Neither the name of the author nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- */
-
-#ifdef _SAMBA_BUILD_
-
-#define NSS_WRAPPER_NOT_REPLACE
-#include "lib/replace/replace.h"
-#include "system/passwd.h"
-#include "system/filesys.h"
-
-#else /* _SAMBA_BUILD_ */
-
-#error nss_wrapper_only_supported_in_samba_yet
-
-#endif
-
-#ifndef _PUBLIC_
-#define _PUBLIC_
-#endif
-
-/* not all systems have _r functions... */
-#ifndef HAVE_GETPWNAM_R
-#define getpwnam_r(name, pwdst, buf, buflen, pwdstp) ENOSYS
-#endif
-#ifndef HAVE_GETPWUID_R
-#define getpwuid_r(uid, pwdst, buf, buflen, pwdstp) ENOSYS
-#endif
-#ifndef HAVE_GETPWENT_R
-#define getpwent_r(pwdst, buf, buflen, pwdstp) ENOSYS
-#endif
-#ifndef HAVE_GETGRNAM_R
-#define getgrnam_r(name, grdst, buf, buflen, grdstp) ENOSYS
-#endif
-#ifndef HAVE_GETGRUID_R
-#define getgrgid_r(uid, grdst, buf, buflen, grdstp) ENOSYS
-#endif
-#ifndef HAVE_GETGRENT_R
-#define getgrent_r(grdst, buf, buflen, grdstp) ENOSYS
-#endif
-
-/* LD_PRELOAD doesn't work yet, so REWRITE_CALLS is all we support
- * for now */
-#define REWRITE_CALLS
-
-#ifdef REWRITE_CALLS
-
-#define real_getpwnam getpwnam
-#define real_getpwnam_r getpwnam_r
-#define real_getpwuid getpwuid
-#define real_getpwuid_r getpwuid_r
-
-#define real_setpwent setpwent
-#define real_getpwent getpwent
-#define real_getpwent_r getpwent_r
-#define real_endpwent endpwent
-
-/*
-#define real_getgrlst getgrlst
-#define real_getgrlst_r getgrlst_r
-#define real_initgroups_dyn initgroups_dyn
-*/
-#define real_initgroups initgroups
-
-#define real_getgrnam getgrnam
-#define real_getgrnam_r getgrnam_r
-#define real_getgrgid getgrgid
-#define real_getgrgid_r getgrgid_r
-
-#define real_setgrent setgrent
-#define real_getgrent getgrent
-#define real_getgrent_r getgrent_r
-#define real_endgrent endgrent
-
-#endif
-
-#if 0
-# ifdef DEBUG
-# define NWRAP_ERROR(args) DEBUG(0, args)
-# else
-# define NWRAP_ERROR(args) printf args
-# endif
-#else
-#define NWRAP_ERROR(args)
-#endif
-
-#if 0
-# ifdef DEBUG
-# define NWRAP_DEBUG(args) DEBUG(0, args)
-# else
-# define NWRAP_DEBUG(args) printf args
-# endif
-#else
-#define NWRAP_DEBUG(args)
-#endif
-
-#if 0
-# ifdef DEBUG
-# define NWRAP_VERBOSE(args) DEBUG(0, args)
-# else
-# define NWRAP_VERBOSE(args) printf args
-# endif
-#else
-#define NWRAP_VERBOSE(args)
-#endif
-
-struct nwrap_cache {
- const char *path;
- int fd;
- struct stat st;
- uint8_t *buf;
- void *private_data;
- bool (*parse_line)(struct nwrap_cache *, char *line);
- void (*unload)(struct nwrap_cache *);
-};
-
-struct nwrap_pw {
- struct nwrap_cache *cache;
-
- struct passwd *list;
- int num;
- int idx;
-};
-
-struct nwrap_cache __nwrap_cache_pw;
-struct nwrap_pw nwrap_pw_global;
-
-static bool nwrap_pw_parse_line(struct nwrap_cache *nwrap, char *line);
-static void nwrap_pw_unload(struct nwrap_cache *nwrap);
-
-struct nwrap_gr {
- struct nwrap_cache *cache;
-
- struct group *list;
- int num;
- int idx;
-};
-
-struct nwrap_cache __nwrap_cache_gr;
-struct nwrap_gr nwrap_gr_global;
-
-static bool nwrap_gr_parse_line(struct nwrap_cache *nwrap, char *line);
-static void nwrap_gr_unload(struct nwrap_cache *nwrap);
-
-static void nwrap_init(void)
-{
- static bool initialized;
-
- if (initialized) return;
- initialized = true;
-
- nwrap_pw_global.cache = &__nwrap_cache_pw;
-
- nwrap_pw_global.cache->path = getenv("NSS_WRAPPER_PASSWD");
- nwrap_pw_global.cache->fd = -1;
- nwrap_pw_global.cache->private_data = &nwrap_pw_global;
- nwrap_pw_global.cache->parse_line = nwrap_pw_parse_line;
- nwrap_pw_global.cache->unload = nwrap_pw_unload;
-
- nwrap_gr_global.cache = &__nwrap_cache_gr;
-
- nwrap_gr_global.cache->path = getenv("NSS_WRAPPER_GROUP");
- nwrap_gr_global.cache->fd = -1;
- nwrap_gr_global.cache->private_data = &nwrap_gr_global;
- nwrap_gr_global.cache->parse_line = nwrap_gr_parse_line;
- nwrap_gr_global.cache->unload = nwrap_gr_unload;
-}
-
-static bool nwrap_enabled(void)
-{
- nwrap_init();
-
- if (!nwrap_pw_global.cache->path) {
- return false;
- }
- if (nwrap_pw_global.cache->path[0] == '\0') {
- return false;
- }
- if (!nwrap_gr_global.cache->path) {
- return false;
- }
- if (nwrap_gr_global.cache->path[0] == '\0') {
- return false;
- }
-
- return true;
-}
-
-static bool nwrap_parse_file(struct nwrap_cache *nwrap)
-{
- int ret;
- uint8_t *buf = NULL;
- char *nline;
-
- if (nwrap->st.st_size == 0) {
- NWRAP_DEBUG(("%s: size == 0\n",
- __location__));
- goto done;
- }
-
- if (nwrap->st.st_size > INT32_MAX) {
- NWRAP_ERROR(("%s: size[%u] larger than INT32_MAX\n",
- __location__, (unsigned)nwrap->st.st_size));
- goto failed;
- }
-
- ret = lseek(nwrap->fd, 0, SEEK_SET);
- if (ret != 0) {
- NWRAP_ERROR(("%s: lseek - %d\n",__location__,ret));
- goto failed;
- }
-
- buf = malloc(nwrap->st.st_size + 1);
- if (!buf) {
- NWRAP_ERROR(("%s: malloc failed\n",__location__));
- goto failed;
- }
-
- ret = read(nwrap->fd, buf, nwrap->st.st_size);
- if (ret != nwrap->st.st_size) {
- NWRAP_ERROR(("%s: read(%u) gave %d\n",
- __location__, (unsigned)nwrap->st.st_size, ret));
- goto failed;
- }
-
- buf[nwrap->st.st_size] = '\0';
-
- nline = (char *)buf;
- while (nline && nline[0]) {
- char *line;
- char *e;
- bool ok;
-
- line = nline;
- nline = NULL;
-
- e = strchr(line, '\n');
- if (e) {
- e[0] = '\0';
- e++;
- if (e[0] == '\r') {
- e[0] = '\0';
- e++;
- }
- nline = e;
- }
-
- NWRAP_VERBOSE(("%s:'%s'\n",__location__, line));
-
- if (strlen(line) == 0) {
- continue;
- }
-
- ok = nwrap->parse_line(nwrap, line);
- if (!ok) {
- goto failed;
- }
- }
-
-done:
- nwrap->buf = buf;
- return true;
-
-failed:
- if (buf) free(buf);
- return false;
-}
-
-static void nwrap_cache_unload(struct nwrap_cache *nwrap)
-{
- nwrap->unload(nwrap);
-
- if (nwrap->buf) free(nwrap->buf);
-
- nwrap->buf = NULL;
-}
-
-static void nwrap_cache_reload(struct nwrap_cache *nwrap)
-{
- struct stat st;
- int ret;
- bool ok;
- bool retried = false;
-
-reopen:
- if (nwrap->fd < 0) {
- nwrap->fd = open(nwrap->path, O_RDONLY);
- if (nwrap->fd < 0) {
- NWRAP_ERROR(("%s: unable to open '%s' readonly %d:%s\n",
- __location__,
- nwrap->path, nwrap->fd,
- strerror(errno)));
- return;
- }
- NWRAP_VERBOSE(("%s: open '%s'\n", __location__, nwrap->path));
- }
-
- ret = fstat(nwrap->fd, &st);
- if (ret != 0) {
- NWRAP_ERROR(("%s: fstat(%s) - %d:%s\n",
- __location__,
- nwrap->path,
- ret, strerror(errno)));
- return;
- }
-
- if (retried == false && st.st_nlink == 0) {
- /* maybe someone has replaced the file... */
- NWRAP_DEBUG(("%s: st_nlink == 0, reopen %s\n",
- __location__, nwrap->path));
- retried = true;
- memset(&nwrap->st, 0, sizeof(nwrap->st));
- close(nwrap->fd);
- nwrap->fd = -1;
- goto reopen;
- }
-
- if (st.st_mtime == nwrap->st.st_mtime) {
- NWRAP_VERBOSE(("%s: st_mtime[%u] hasn't changed, skip reload\n",
- __location__, (unsigned)st.st_mtime));
- return;
- }
- NWRAP_DEBUG(("%s: st_mtime has changed [%u] => [%u], start reload\n",
- __location__, (unsigned)st.st_mtime,
- (unsigned)nwrap->st.st_mtime));
-
- nwrap->st = st;
-
- nwrap_cache_unload(nwrap);
-
- ok = nwrap_parse_file(nwrap);
- if (!ok) {
- NWRAP_ERROR(("%s: failed to reload %s\n",
- __location__, nwrap->path));
- nwrap_cache_unload(nwrap);
- }
- NWRAP_DEBUG(("%s: reloaded %s\n",
- __location__, nwrap->path));
-}
-
-/*
- * the caller has to call nwrap_unload() on failure
- */
-static bool nwrap_pw_parse_line(struct nwrap_cache *nwrap, char *line)
-{
- struct nwrap_pw *nwrap_pw;
- char *c;
- char *p;
- char *e;
- struct passwd *pw;
- size_t list_size;
-
- nwrap_pw = (struct nwrap_pw *)nwrap->private_data;
-
- list_size = sizeof(*nwrap_pw->list) * (nwrap_pw->num+1);
- pw = (struct passwd *)realloc(nwrap_pw->list, list_size);
- if (!pw) {
- NWRAP_ERROR(("%s:realloc(%u) failed\n",
- __location__, list_size));
- return false;
- }
- nwrap_pw->list = pw;
-
- pw = &nwrap_pw->list[nwrap_pw->num];
-
- c = line;
-
- /* name */
- p = strchr(c, ':');
- if (!p) {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n",
- __location__, line, c));
- return false;
- }
- *p = '\0';
- p++;
- pw->pw_name = c;
- c = p;
-
- NWRAP_VERBOSE(("name[%s]\n", pw->pw_name));
-
- /* password */
- p = strchr(c, ':');
- if (!p) {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n",
- __location__, line, c));
- return false;
- }
- *p = '\0';
- p++;
- pw->pw_passwd = c;
- c = p;
-
- NWRAP_VERBOSE(("password[%s]\n", pw->pw_passwd));
-
- /* uid */
- p = strchr(c, ':');
- if (!p) {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n",
- __location__, line, c));
- return false;
- }
- *p = '\0';
- p++;
- e = NULL;
- pw->pw_uid = (uid_t)strtoul(c, &e, 10);
- if (c == e) {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n",
- __location__, line, c, strerror(errno)));
- return false;
- }
- if (e == NULL) {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n",
- __location__, line, c, strerror(errno)));
- return false;
- }
- if (e[0] != '\0') {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n",
- __location__, line, c, strerror(errno)));
- return false;
- }
- c = p;
-
- NWRAP_VERBOSE(("uid[%u]\n", pw->pw_uid));
-
- /* gid */
- p = strchr(c, ':');
- if (!p) {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n",
- __location__, line, c));
- return false;
- }
- *p = '\0';
- p++;
- e = NULL;
- pw->pw_gid = (gid_t)strtoul(c, &e, 10);
- if (c == e) {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n",
- __location__, line, c, strerror(errno)));
- return false;
- }
- if (e == NULL) {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n",
- __location__, line, c, strerror(errno)));
- return false;
- }
- if (e[0] != '\0') {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n",
- __location__, line, c, strerror(errno)));
- return false;
- }
- c = p;
-
- NWRAP_VERBOSE(("gid[%u]\n", pw->pw_gid));
-
- /* gecos */
- p = strchr(c, ':');
- if (!p) {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n",
- __location__, line, c));
- return false;
- }
- *p = '\0';
- p++;
- pw->pw_gecos = c;
- c = p;
-
- NWRAP_VERBOSE(("gecos[%s]\n", pw->pw_gecos));
-
- /* dir */
- p = strchr(c, ':');
- if (!p) {
- NWRAP_ERROR(("%s:'%s'\n",__location__,c));
- return false;
- }
- *p = '\0';
- p++;
- pw->pw_dir = c;
- c = p;
-
- NWRAP_VERBOSE(("dir[%s]\n", pw->pw_dir));
-
- /* shell */
- pw->pw_shell = c;
- NWRAP_VERBOSE(("shell[%s]\n", pw->pw_shell));
-
- NWRAP_DEBUG(("add user[%s:%s:%u:%u:%s:%s:%s]\n",
- pw->pw_name, pw->pw_passwd,
- pw->pw_uid, pw->pw_gid,
- pw->pw_gecos, pw->pw_dir, pw->pw_shell));
-
- nwrap_pw->num++;
- return true;
-}
-
-static void nwrap_pw_unload(struct nwrap_cache *nwrap)
-{
- struct nwrap_pw *nwrap_pw;
- nwrap_pw = (struct nwrap_pw *)nwrap->private_data;
-
- if (nwrap_pw->list) free(nwrap_pw->list);
-
- nwrap_pw->list = NULL;
- nwrap_pw->num = 0;
- nwrap_pw->idx = 0;
-}
-
-static int nwrap_pw_copy_r(const struct passwd *src, struct passwd *dst,
- char *buf, size_t buflen, struct passwd **dstp)
-{
- char *first;
- char *last;
- off_t ofs;
-
- first = src->pw_name;
-
- last = src->pw_shell;
- while (*last) last++;
-
- ofs = PTR_DIFF(last + 1, first);
-
- if (ofs > buflen) {
- return ERANGE;
- }
-
- memcpy(buf, first, ofs);
-
- ofs = PTR_DIFF(src->pw_name, first);
- dst->pw_name = buf + ofs;
- ofs = PTR_DIFF(src->pw_passwd, first);
- dst->pw_passwd = buf + ofs;
- dst->pw_uid = src->pw_uid;
- dst->pw_gid = src->pw_gid;
- ofs = PTR_DIFF(src->pw_gecos, first);
- dst->pw_gecos = buf + ofs;
- ofs = PTR_DIFF(src->pw_dir, first);
- dst->pw_dir = buf + ofs;
- ofs = PTR_DIFF(src->pw_shell, first);
- dst->pw_shell = buf + ofs;
-
- if (dstp) {
- *dstp = dst;
- }
-
- return 0;
-}
-
-/*
- * the caller has to call nwrap_unload() on failure
- */
-static bool nwrap_gr_parse_line(struct nwrap_cache *nwrap, char *line)
-{
- struct nwrap_gr *nwrap_gr;
- char *c;
- char *p;
- char *e;
- struct group *gr;
- size_t list_size;
- unsigned nummem;
-
- nwrap_gr = (struct nwrap_gr *)nwrap->private_data;
-
- list_size = sizeof(*nwrap_gr->list) * (nwrap_gr->num+1);
- gr = (struct group *)realloc(nwrap_gr->list, list_size);
- if (!gr) {
- NWRAP_ERROR(("%s:realloc failed\n",__location__));
- return false;
- }
- nwrap_gr->list = gr;
-
- gr = &nwrap_gr->list[nwrap_gr->num];
-
- c = line;
-
- /* name */
- p = strchr(c, ':');
- if (!p) {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n",
- __location__, line, c));
- return false;
- }
- *p = '\0';
- p++;
- gr->gr_name = c;
- c = p;
-
- NWRAP_VERBOSE(("name[%s]\n", gr->gr_name));
-
- /* password */
- p = strchr(c, ':');
- if (!p) {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n",
- __location__, line, c));
- return false;
- }
- *p = '\0';
- p++;
- gr->gr_passwd = c;
- c = p;
-
- NWRAP_VERBOSE(("password[%s]\n", gr->gr_passwd));
-
- /* gid */
- p = strchr(c, ':');
- if (!p) {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n",
- __location__, line, c));
- return false;
- }
- *p = '\0';
- p++;
- e = NULL;
- gr->gr_gid = (gid_t)strtoul(c, &e, 10);
- if (c == e) {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n",
- __location__, line, c, strerror(errno)));
- return false;
- }
- if (e == NULL) {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n",
- __location__, line, c, strerror(errno)));
- return false;
- }
- if (e[0] != '\0') {
- NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n",
- __location__, line, c, strerror(errno)));
- return false;
- }
- c = p;
-
- NWRAP_VERBOSE(("gid[%u]\n", gr->gr_gid));
-
- /* members */
- gr->gr_mem = (char **)malloc(sizeof(char *));
- if (!gr->gr_mem) {
- NWRAP_ERROR(("%s:calloc failed\n",__location__));
- return false;
- }
- gr->gr_mem[0] = NULL;
-
- for(nummem=0; p; nummem++) {
- char **m;
- size_t m_size;
- c = p;
- p = strchr(c, ',');
- if (p) {
- *p = '\0';
- p++;
- }
-
- if (strlen(c) == 0) {
- break;
- }
-
- m_size = sizeof(char *) * (nummem+2);
- m = (char **)realloc(gr->gr_mem, m_size);
- if (!m) {
- NWRAP_ERROR(("%s:realloc(%u) failed\n",
- __location__, m_size));
- return false;
- }
- gr->gr_mem = m;
- gr->gr_mem[nummem] = c;
- gr->gr_mem[nummem+1] = NULL;
-
- NWRAP_VERBOSE(("member[%u]: '%s'\n", nummem, gr->gr_mem[nummem]));
- }
-
- NWRAP_DEBUG(("add group[%s:%s:%u:] with %u members\n",
- gr->gr_name, gr->gr_passwd, gr->gr_gid, nummem));
-
- nwrap_gr->num++;
- return true;
-}
-
-static void nwrap_gr_unload(struct nwrap_cache *nwrap)
-{
- int i;
- struct nwrap_gr *nwrap_gr;
- nwrap_gr = (struct nwrap_gr *)nwrap->private_data;
-
- if (nwrap_gr->list) {
- for (i=0; i < nwrap_gr->num; i++) {
- if (nwrap_gr->list[i].gr_mem) {
- free(nwrap_gr->list[i].gr_mem);
- }
- }
- free(nwrap_gr->list);
- }
-
- nwrap_gr->list = NULL;
- nwrap_gr->num = 0;
- nwrap_gr->idx = 0;
-}
-
-static int nwrap_gr_copy_r(const struct group *src, struct group *dst,
- char *buf, size_t buflen, struct group **dstp)
-{
- char *first;
- char **lastm;
- char *last;
- off_t ofsb;
- off_t ofsm;
- off_t ofs;
- unsigned i;
-
- first = src->gr_name;
-
- lastm = src->gr_mem;
- while (*lastm) lastm++;
-
- last = *lastm;
- while (*last) last++;
-
- ofsb = PTR_DIFF(last + 1, first);
- ofsm = PTR_DIFF(lastm + 1, src->gr_mem);
-
- if ((ofsb + ofsm) > buflen) {
- return ERANGE;
- }
-
- memcpy(buf, first, ofsb);
- memcpy(buf + ofsb, src->gr_mem, ofsm);
-
- ofs = PTR_DIFF(src->gr_name, first);
- dst->gr_name = buf + ofs;
- ofs = PTR_DIFF(src->gr_passwd, first);
- dst->gr_passwd = buf + ofs;
- dst->gr_gid = src->gr_gid;
-
- dst->gr_mem = (char **)(buf + ofsb);
- for (i=0; src->gr_mem[i]; i++) {
- ofs = PTR_DIFF(src->gr_mem[i], first);
- dst->gr_mem[i] = buf + ofs;
- }
-
- if (dstp) {
- *dstp = dst;
- }
-
- return 0;
-}
-
-/* user functions */
-_PUBLIC_ struct passwd *nwrap_getpwnam(const char *name)
-{
- int i;
-
- if (!nwrap_enabled()) {
- return real_getpwnam(name);
- }
-
- nwrap_cache_reload(nwrap_pw_global.cache);
-
- for (i=0; i<nwrap_pw_global.num; i++) {
- if (strcmp(nwrap_pw_global.list[i].pw_name, name) == 0) {
- NWRAP_DEBUG(("%s: user[%s] found\n",
- __location__, name));
- return &nwrap_pw_global.list[i];
- }
- NWRAP_VERBOSE(("%s: user[%s] does not match [%s]\n",
- __location__, name,
- nwrap_pw_global.list[i].pw_name));
- }
-
- NWRAP_DEBUG(("%s: user[%s] not found\n", __location__, name));
-
- errno = ENOENT;
- return NULL;
-}
-
-_PUBLIC_ int nwrap_getpwnam_r(const char *name, struct passwd *pwdst,
- char *buf, size_t buflen, struct passwd **pwdstp)
-{
- struct passwd *pw;
-
- if (!nwrap_enabled()) {
- return real_getpwnam_r(name, pwdst, buf, buflen, pwdstp);
- }
-
- pw = nwrap_getpwnam(name);
- if (!pw) {
- if (errno == 0) {
- return ENOENT;
- }
- return errno;
- }
-
- return nwrap_pw_copy_r(pw, pwdst, buf, buflen, pwdstp);
-}
-
-_PUBLIC_ struct passwd *nwrap_getpwuid(uid_t uid)
-{
- int i;
-
- if (!nwrap_enabled()) {
- return real_getpwuid(uid);
- }
-
- nwrap_cache_reload(nwrap_pw_global.cache);
-
- for (i=0; i<nwrap_pw_global.num; i++) {
- if (nwrap_pw_global.list[i].pw_uid == uid) {
- NWRAP_DEBUG(("%s: uid[%u] found\n",
- __location__, uid));
- return &nwrap_pw_global.list[i];
- }
- NWRAP_VERBOSE(("%s: uid[%u] does not match [%u]\n",
- __location__, uid,
- nwrap_pw_global.list[i].pw_uid));
- }
-
- NWRAP_DEBUG(("%s: uid[%u] not found\n", __location__, uid));
-
- errno = ENOENT;
- return NULL;
-}
-
-_PUBLIC_ int nwrap_getpwuid_r(uid_t uid, struct passwd *pwdst,
- char *buf, size_t buflen, struct passwd **pwdstp)
-{
- struct passwd *pw;
-
- if (!nwrap_enabled()) {
- return real_getpwuid_r(uid, pwdst, buf, buflen, pwdstp);
- }
-
- pw = nwrap_getpwuid(uid);
- if (!pw) {
- if (errno == 0) {
- return ENOENT;
- }
- return errno;
- }
-
- return nwrap_pw_copy_r(pw, pwdst, buf, buflen, pwdstp);
-}
-
-/* user enum functions */
-_PUBLIC_ void nwrap_setpwent(void)
-{
- if (!nwrap_enabled()) {
- real_setpwent();
- }
-
- nwrap_pw_global.idx = 0;
-}
-
-_PUBLIC_ struct passwd *nwrap_getpwent(void)
-{
- struct passwd *pw;
-
- if (!nwrap_enabled()) {
- return real_getpwent();
- }
-
- if (nwrap_pw_global.idx == 0) {
- nwrap_cache_reload(nwrap_pw_global.cache);
- }
-
- if (nwrap_pw_global.idx >= nwrap_pw_global.num) {
- errno = ENOENT;
- return NULL;
- }
-
- pw = &nwrap_pw_global.list[nwrap_pw_global.idx++];
-
- NWRAP_VERBOSE(("%s: return user[%s] uid[%u]\n",
- __location__, pw->pw_name, pw->pw_uid));
-
- return pw;
-}
-
-_PUBLIC_ int nwrap_getpwent_r(struct passwd *pwdst, char *buf,
- size_t buflen, struct passwd **pwdstp)
-{
- struct passwd *pw;
-
- if (!nwrap_enabled()) {
-#ifdef SOLARIS_GETPWENT_R
- pw = real_getpwent_r(pwdst, buf, buflen);
- if (!pw) {
- if (errno == 0) {
- return ENOENT;
- }
- return errno;
- }
- if (pwdstp) {
- *pwdstp = pw;
- }
- return 0;
-#else
- return real_getpwent_r(pwdst, buf, buflen, pwdstp);
-#endif
- }
-
- pw = nwrap_getpwent();
- if (!pw) {
- if (errno == 0) {
- return ENOENT;
- }
- return errno;
- }
-
- return nwrap_pw_copy_r(pw, pwdst, buf, buflen, pwdstp);
-}
-
-_PUBLIC_ void nwrap_endpwent(void)
-{
- if (!nwrap_enabled()) {
- real_endpwent();
- }
-
- nwrap_pw_global.idx = 0;
-}
-
-/* misc functions */
-_PUBLIC_ int nwrap_initgroups(const char *user, gid_t group)
-{
- if (!nwrap_enabled()) {
- return real_initgroups(user, group);
- }
-
- /* TODO: maybe we should also fake this... */
- return EPERM;
-}
-
-/* group functions */
-_PUBLIC_ struct group *nwrap_getgrnam(const char *name)
-{
- int i;
-
- if (!nwrap_enabled()) {
- return real_getgrnam(name);
- }
-
- nwrap_cache_reload(nwrap_gr_global.cache);
-
- for (i=0; i<nwrap_gr_global.num; i++) {
- if (strcmp(nwrap_gr_global.list[i].gr_name, name) == 0) {
- NWRAP_DEBUG(("%s: group[%s] found\n",
- __location__, name));
- return &nwrap_gr_global.list[i];
- }
- NWRAP_VERBOSE(("%s: group[%s] does not match [%s]\n",
- __location__, name,
- nwrap_gr_global.list[i].gr_name));
- }
-
- NWRAP_DEBUG(("%s: group[%s] not found\n", __location__, name));
-
- errno = ENOENT;
- return NULL;
-}
-
-_PUBLIC_ int nwrap_getgrnam_r(const char *name, struct group *grdst,
- char *buf, size_t buflen, struct group **grdstp)
-{
- struct group *gr;
-
- if (!nwrap_enabled()) {
- return real_getgrnam_r(name, grdst, buf, buflen, grdstp);
- }
-
- gr = nwrap_getgrnam(name);
- if (!gr) {
- if (errno == 0) {
- return ENOENT;
- }
- return errno;
- }
-
- return nwrap_gr_copy_r(gr, grdst, buf, buflen, grdstp);
-}
-
-_PUBLIC_ struct group *nwrap_getgrgid(gid_t gid)
-{
- int i;
-
- if (!nwrap_enabled()) {
- return real_getgrgid(gid);
- }
-
- nwrap_cache_reload(nwrap_gr_global.cache);
-
- for (i=0; i<nwrap_gr_global.num; i++) {
- if (nwrap_gr_global.list[i].gr_gid == gid) {
- NWRAP_DEBUG(("%s: gid[%u] found\n",
- __location__, gid));
- return &nwrap_gr_global.list[i];
- }
- NWRAP_VERBOSE(("%s: gid[%u] does not match [%u]\n",
- __location__, gid,
- nwrap_gr_global.list[i].gr_gid));
- }
-
- NWRAP_DEBUG(("%s: gid[%u] not found\n", __location__, gid));
-
- errno = ENOENT;
- return NULL;
-}
-
-_PUBLIC_ int nwrap_getgrgid_r(gid_t gid, struct group *grdst,
- char *buf, size_t buflen, struct group **grdstp)
-{
- struct group *gr;
-
- if (!nwrap_enabled()) {
- return real_getgrgid_r(gid, grdst, buf, buflen, grdstp);
- }
-
- gr = nwrap_getgrgid(gid);
- if (!gr) {
- if (errno == 0) {
- return ENOENT;
- }
- return errno;
- }
-
- return nwrap_gr_copy_r(gr, grdst, buf, buflen, grdstp);
-
- return ENOENT;
-}
-
-/* group enum functions */
-_PUBLIC_ void nwrap_setgrent(void)
-{
- if (!nwrap_enabled()) {
- real_setgrent();
- }
-
- nwrap_gr_global.idx = 0;
-}
-
-_PUBLIC_ struct group *nwrap_getgrent(void)
-{
- struct group *gr;
-
- if (!nwrap_enabled()) {
- return real_getgrent();
- }
-
- if (nwrap_gr_global.idx == 0) {
- nwrap_cache_reload(nwrap_gr_global.cache);
- }
-
- if (nwrap_gr_global.idx >= nwrap_gr_global.num) {
- errno = ENOENT;
- return NULL;
- }
-
- gr = &nwrap_gr_global.list[nwrap_gr_global.idx++];
-
- NWRAP_VERBOSE(("%s: return group[%s] gid[%u]\n",
- __location__, gr->gr_name, gr->gr_gid));
-
- return gr;
-}
-
-_PUBLIC_ int nwrap_getgrent_r(struct group *grdst, char *buf,
- size_t buflen, struct group **grdstp)
-{
- struct group *gr;
-
- if (!nwrap_enabled()) {
-#ifdef SOLARIS_GETGRENT_R
- gr = real_getgrent_r(grdst, buf, buflen);
- if (!gr) {
- if (errno == 0) {
- return ENOENT;
- }
- return errno;
- }
- if (grdstp) {
- *grdstp = gr;
- }
- return 0;
-#else
- return real_getgrent_r(grdst, buf, buflen, grdstp);
-#endif
- }
-
- gr = nwrap_getgrent();
- if (!gr) {
- if (errno == 0) {
- return ENOENT;
- }
- return errno;
- }
-
- return nwrap_gr_copy_r(gr, grdst, buf, buflen, grdstp);
-}
-
-_PUBLIC_ void nwrap_endgrent(void)
-{
- if (!nwrap_enabled()) {
- real_endgrent();
- }
-
- nwrap_gr_global.idx = 0;
-}
diff --git a/source4/lib/nss_wrapper/nss_wrapper.h b/source4/lib/nss_wrapper/nss_wrapper.h
deleted file mode 100644
index 35a47348a8..0000000000
--- a/source4/lib/nss_wrapper/nss_wrapper.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) Stefan Metzmacher 2007 <metze@samba.org>
- *
- * 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. Neither the name of the author nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- */
-
-#ifndef __NSS_WRAPPER_H__
-#define __NSS_WRAPPER_H__
-
-struct passwd *nwrap_getpwnam(const char *name);
-int nwrap_getpwnam_r(const char *name, struct passwd *pwbuf,
- char *buf, size_t buflen, struct passwd **pwbufp);
-struct passwd *nwrap_getpwuid(uid_t uid);
-int nwrap_getpwuid_r(uid_t uid, struct passwd *pwbuf,
- char *buf, size_t buflen, struct passwd **pwbufp);
-void nwrap_setpwent(void);
-struct passwd *nwrap_getpwent(void);
-int nwrap_getpwent_r(struct passwd *pwbuf, char *buf,
- size_t buflen, struct passwd **pwbufp);
-void nwrap_endpwent(void);
-int nwrap_initgroups(const char *user, gid_t group);
-struct group *nwrap_getgrnam(const char *name);
-int nwrap_getgrnam_r(const char *name, struct group *gbuf,
- char *buf, size_t buflen, struct group **gbufp);
-struct group *nwrap_getgrgid(gid_t gid);
-int nwrap_getgrgid_r(gid_t gid, struct group *gbuf,
- char *buf, size_t buflen, struct group **gbufp);
-void nwrap_setgrent(void);
-struct group *nwrap_getgrent(void);
-int nwrap_getgrent_r(struct group *gbuf, char *buf,
- size_t buflen, struct group **gbufp);
-void nwrap_endgrent(void);
-
-#ifdef NSS_WRAPPER_REPLACE
-
-#ifdef getpwnam
-#undef getpwnam
-#endif
-#define getpwnam nwrap_getpwnam
-
-#ifdef getpwnam_r
-#undef getpwnam_r
-#endif
-#define getpwnam_r nwrap_getpwnam_r
-
-#ifdef getpwuid
-#undef getpwuid
-#endif
-#define getpwuid nwrap_getpwuid
-
-#ifdef getpwuid_r
-#undef getpwuid_r
-#endif
-#define getpwuid_r nwrap_getpwuid_r
-
-#ifdef setpwent
-#undef setpwent
-#endif
-#define setpwent nwrap_setpwent
-
-#ifdef getpwent
-#undef getpwent
-#endif
-#define getpwent nwrap_getpwent
-
-#ifdef getpwent_r
-#undef getpwent_r
-#endif
-#define getpwent_r nwrap_getpwent_r
-
-#ifdef endpwent
-#undef endpwent
-#endif
-#define endpwent nwrap_endpwent
-
-#ifdef getgrlst
-#undef getgrlst
-#endif
-#define getgrlst __none_nwrap_getgrlst
-
-#ifdef getgrlst_r
-#undef getgrlst_r
-#endif
-#define getgrlst_r __none_nwrap_getgrlst_r
-
-#ifdef initgroups_dyn
-#undef initgroups_dyn
-#endif
-#define initgroups_dyn __none_nwrap_initgroups_dyn
-
-#ifdef initgroups
-#undef initgroups
-#endif
-#define initgroups nwrap_initgroups
-
-#ifdef getgrnam
-#undef getgrnam
-#endif
-#define getgrnam nwrap_getgrnam
-
-#ifdef getgrnam_r
-#undef getgrnam_r
-#endif
-#define getgrnam_r nwrap_getgrnam_r
-
-#ifdef getgrgid
-#undef getgrgid
-#endif
-#define getgrgid nwrap_getgrgid
-
-#ifdef getgrgid_r
-#undef getgrgid_r
-#endif
-#define getgrgid_r nwrap_getgrgid_r
-
-#ifdef setgrent
-#undef setgrent
-#endif
-#define setgrent nwrap_setgrent
-
-#ifdef getgrent
-#undef getgrent
-#endif
-#define getgrent nwrap_getgrent
-
-#ifdef getgrent_r
-#undef getgrent_r
-#endif
-#define getgrent_r nwrap_getgrent_r
-
-#ifdef endgrent
-#undef endgrent
-#endif
-#define endgrent nwrap_endgrent
-
-#endif /* NSS_WRAPPER_REPLACE */
-
-#endif /* __NSS_WRAPPER_H__ */
diff --git a/source4/lib/nss_wrapper/nss_wrapper.pl b/source4/lib/nss_wrapper/nss_wrapper.pl
deleted file mode 100644
index b1c9be5365..0000000000
--- a/source4/lib/nss_wrapper/nss_wrapper.pl
+++ /dev/null
@@ -1,265 +0,0 @@
-#!/usr/bin/perl
-#
-
-use strict;
-
-use Getopt::Long;
-use Cwd qw(abs_path);
-
-my $opt_help = 0;
-my $opt_path = undef;
-my $opt_action = undef;
-my $opt_type = undef;
-my $opt_name = undef;
-
-my $passwdfn = undef;
-my $groupfn = undef;
-my $actionfn = undef;
-
-sub passwd_add($$);
-sub passwd_delete($$);
-sub group_add($$);
-sub group_delete($$);
-
-my $result = GetOptions(
- 'help|h|?' => \$opt_help,
- 'path=s' => \$opt_path,
- 'action=s' => \$opt_action,
- 'type=s' => \$opt_type,
- 'name=s' => \$opt_name
-);
-
-sub usage($;$)
-{
- my ($ret, $msg) = @_;
-
- print $msg."\n\n" if defined($msg);
-
- print "usage:
-
- --help|-h|-? Show this help.
-
- --path <path> Path of the 'passwd' or 'group' file.
-
- --type <type> Only 'passwd' is supported yet,
- but 'group' and maybe 'member' will be added
- in future.
-
- --action <action> 'add' or 'delete'.
-
- --name <name> The name of the object.
-";
- exit($ret);
-}
-
-usage(1) if (not $result);
-
-usage(0) if ($opt_help);
-
-if (not defined($opt_path)) {
- usage(1, "missing: --path <path>");
-}
-if ($opt_path eq "" or $opt_path eq "/") {
- usage(1, "invalid: --path <path>: '$opt_path'");
-}
-my $opt_fullpath = abs_path($opt_path);
-if (not defined($opt_fullpath)) {
- usage(1, "invalid: --path <path>: '$opt_path'");
-}
-
-
-if (not defined($opt_action)) {
- usage(1, "missing: --action [add|delete]");
-}
-if ($opt_action eq "add") {
- $passwdfn = \&passwd_add;
- $groupfn = \&group_add;
-} elsif ($opt_action eq "delete") {
- $passwdfn = \&passwd_delete;
- $groupfn = \&group_delete;
-} else {
- usage(1, "invalid: --action [add|delete]: '$opt_action'");
-}
-
-if (not defined($opt_type)) {
- usage(1, "missing: --type [passwd|group]");
-}
-if ($opt_type eq "passwd") {
- $actionfn = $passwdfn;
-} elsif ($opt_type eq "group") {
- $actionfn = $groupfn;
-} else {
- usage(1, "invalid: --type [passwd|group]: '$opt_type'")
-}
-
-if (not defined($opt_name)) {
- usage(1, "missing: --name <name>");
-}
-if ($opt_name eq "") {
- usage(1, "invalid: --name <name>");
-}
-
-exit $actionfn->($opt_fullpath, $opt_name);
-
-sub passwd_add_entry($$);
-
-sub passwd_load($)
-{
- my ($path) = @_;
- my @lines;
- my $passwd = undef;
-
- open(PWD, "<$path") or die("Unable to open '$path' for read");
- @lines = <PWD>;
- close(PWD);
-
- $passwd->{array} = ();
- $passwd->{name} = {};
- $passwd->{uid} = {};
- $passwd->{path} = $path;
-
- foreach my $line (@lines) {
- passwd_add_entry($passwd, $line);
- }
-
- return $passwd;
-}
-
-sub passwd_lookup_name($$)
-{
- my ($passwd, $name) = @_;
-
- return undef unless defined($passwd->{name}{$name});
-
- return $passwd->{name}{$name};
-}
-
-sub passwd_lookup_uid($$)
-{
- my ($passwd, $uid) = @_;
-
- return undef unless defined($passwd->{uid}{$uid});
-
- return $passwd->{uid}{$uid};
-}
-
-sub passwd_get_free_uid($)
-{
- my ($passwd) = @_;
- my $uid = 1000;
-
- while (passwd_lookup_uid($passwd, $uid)) {
- $uid++;
- }
-
- return $uid;
-}
-
-sub passwd_add_entry($$)
-{
- my ($passwd, $str) = @_;
-
- chomp $str;
- my @e = split(':', $str);
-
- push(@{$passwd->{array}}, \@e);
- $passwd->{name}{$e[0]} = \@e;
- $passwd->{uid}{$e[2]} = \@e;
-}
-
-sub passwd_remove_entry($$)
-{
- my ($passwd, $eref) = @_;
-
- for(my $i; defined($passwd->{array}[$i]); $i++) {
- if ($eref == $passwd->{array}[$i]) {
- $passwd->{array}[$i] = undef;
- }
- }
-
- delete $passwd->{name}{${$eref}[0]};
- delete $passwd->{uid}{${$eref}[2]};
-}
-
-sub passwd_save($)
-{
- my ($passwd) = @_;
- my @lines = ();
- my $path = $passwd->{path};
- my $tmppath = $path.$$;
-
- foreach my $eref (@{$passwd->{array}}) {
- next unless defined($eref);
-
- my $line = join(':', @{$eref});
- push(@lines, $line);
- }
-
- open(PWD, ">$tmppath") or die("Unable to open '$tmppath' for write");
- print PWD join("\n", @lines)."\n";
- close(PWD);
- rename($tmppath, $path) or die("Unable to rename $tmppath => $path");
-}
-
-sub passwd_add($$)
-{
- my ($path, $name) = @_;
-
- #print "passwd_add: '$name' in '$path'\n";
-
- my $passwd = passwd_load($path);
-
- my $e = passwd_lookup_name($passwd, $name);
- die("account[$name] already exists in '$path'") if defined($e);
-
- my $uid = passwd_get_free_uid($passwd);
- my $gid = 65534;# nogroup gid
-
- my $pwent = $name.":x:".$uid.":".$gid.":".$name." gecos:/nodir:/bin/false";
-
- passwd_add_entry($passwd, $pwent);
-
- passwd_save($passwd);
-
- return 0;
-}
-
-sub passwd_delete($$)
-{
- my ($path, $name) = @_;
-
- #print "passwd_delete: '$name' in '$path'\n";
-
- my $passwd = passwd_load($path);
-
- my $e = passwd_lookup_name($passwd, $name);
- die("account[$name] does not exists in '$path'") unless defined($e);
-
- passwd_remove_entry($passwd, $e);
-
- passwd_save($passwd);
-
- return 0;
-}
-
-sub group_add($$)
-{
- my ($path, $name) = @_;
-
- #print "group_add: '$name' in '$path'\n";
-
- die("group_add: not implemented yet!");
-
- return 0;
-}
-
-sub group_delete($$)
-{
- my ($path, $name) = @_;
-
- #print "group_delete: '$name' in '$path'\n";
-
- die("group_delete: not implemented yet!");
-
- return 0;
-}
diff --git a/source4/lib/popt/CHANGES b/source4/lib/popt/CHANGES
deleted file mode 100644
index db16a5fdd0..0000000000
--- a/source4/lib/popt/CHANGES
+++ /dev/null
@@ -1,46 +0,0 @@
-1.5 -> 1.6
- - add ability to perform callbacks for every, not just first, match.
-
-1.3 -> 1.5
- - heavy dose of const's
- - poptParseArgvString() now NULL terminates the list
-
-1.2.3 -> 1.3
- - added support for single -
- - misc bug fixes
- - portability improvements
-
-1.2.2 -> 1.2.3
- - fixed memset() in help message generation (Dale Hawkins)
- - added extern "C" stuff to popt.h for C++ compilers (Dale Hawkins)
- - const'ified poptParseArgvString (Jeff Garzik)
-
-1.2.1 -> 1.2.2
- - fixed bug in chaind alias happens which seems to have only
- affected --triggers in rpm
- - added POPT_ARG_VAL
- - popt.3 installed by default
-
-1.2 -> 1.2.1
- - added POPT_ARG_INTL_DOMAIN (Elliot Lee)
- - updated Makefile's to be more GNUish (Elliot Lee)
-
-1.1 -> 1.2
- - added popt.3 man page (Robert Lynch)
- - don't use mmap anymore (its lack of portability isn't worth the
- trouble)
- - added test script
- - added support for exec
- - removed support for *_POPT_ALIASES env variable -- it was a bad
- idea
- - reorganized into multiple source files
- - added automatic help generation, POPT_AUTOHELP
- - added table callbacks
- - added table inclusion
- - updated man page for new features
- - added test scripts
-
-1.0 -> 1.1
- - moved to autoconf (Fred Fish)
- - added STRERROR replacement (Norbert Warmuth)
- - added const keywords (Bruce Perens)
diff --git a/source4/lib/popt/COPYING b/source4/lib/popt/COPYING
deleted file mode 100644
index b4c7ca876c..0000000000
--- a/source4/lib/popt/COPYING
+++ /dev/null
@@ -1,22 +0,0 @@
-Copyright (c) 1998 Red Hat Software
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the X Consortium shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from the X Consortium.
diff --git a/source4/lib/popt/README b/source4/lib/popt/README
deleted file mode 100644
index 0b5205bfdd..0000000000
--- a/source4/lib/popt/README
+++ /dev/null
@@ -1,18 +0,0 @@
-This is the popt command line option parsing library. While it is similiar
-to getopt(3), it contains a number of enhancements, including:
-
- 1) popt is fully reentrant
- 2) popt can parse arbitrary argv[] style arrays while
- getopt(2) makes this quite difficult
- 3) popt allows users to alias command line arguments
- 4) popt provides convience functions for parsing strings
- into argv[] style arrays
-
-popt is used by rpm, the Red Hat install program, and many other Red Hat
-utilities, all of which provide excellent examples of how to use popt.
-Complete documentation on popt is available in popt.ps (included in this
-tarball), which is excerpted with permission from the book "Linux
-Application Development" by Michael K. Johnson and Erik Troan (availble
-from Addison Wesley in May, 1998).
-
-Comments on popt should be addressed to ewt@redhat.com.
diff --git a/source4/lib/popt/config.mk b/source4/lib/popt/config.mk
deleted file mode 100644
index e015577aea..0000000000
--- a/source4/lib/popt/config.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-[SUBSYSTEM::LIBPOPT]
-CFLAGS = -Ilib/popt
-
-LIBPOPT_OBJ_FILES = $(addprefix $(poptsrcdir)/, findme.o popt.o poptconfig.o popthelp.o poptparse.o)
-
diff --git a/source4/lib/popt/findme.c b/source4/lib/popt/findme.c
deleted file mode 100644
index a950e50018..0000000000
--- a/source4/lib/popt/findme.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/** \ingroup popt
- * \file popt/findme.c
- */
-
-/* (C) 1998-2002 Red Hat, Inc. -- Licensing details are in the COPYING
- file accompanying popt source distributions, available from
- ftp://ftp.rpm.org/pub/rpm/dist. */
-
-#include "system.h"
-#include "findme.h"
-
-const char * findProgramPath(const char * argv0) {
- char * path = getenv("PATH");
- char * pathbuf;
- char * start, * chptr;
- char * buf;
-
- if (argv0 == NULL) return NULL; /* XXX can't happen */
- /* If there is a / in the argv[0], it has to be an absolute path */
- if (strchr(argv0, '/'))
- return xstrdup(argv0);
-
- if (path == NULL) return NULL;
-
- start = pathbuf = alloca(strlen(path) + 1);
- buf = malloc(strlen(path) + strlen(argv0) + sizeof("/"));
- if (buf == NULL) return NULL; /* XXX can't happen */
- strcpy(pathbuf, path);
-
- chptr = NULL;
- /*@-branchstate@*/
- do {
- if ((chptr = strchr(start, ':')))
- *chptr = '\0';
- sprintf(buf, "%s/%s", start, argv0);
-
- if (!access(buf, X_OK))
- return buf;
-
- if (chptr)
- start = chptr + 1;
- else
- start = NULL;
- } while (start && *start);
- /*@=branchstate@*/
-
- free(buf);
-
- return NULL;
-}
diff --git a/source4/lib/popt/findme.h b/source4/lib/popt/findme.h
deleted file mode 100644
index a016b867ea..0000000000
--- a/source4/lib/popt/findme.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/** \ingroup popt
- * \file popt/findme.h
- */
-
-/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
- file accompanying popt source distributions, available from
- ftp://ftp.rpm.org/pub/rpm/dist. */
-
-#ifndef H_FINDME
-#define H_FINDME
-
-/**
- * Return absolute path to executable by searching PATH.
- * @param argv0 name of executable
- * @return (malloc'd) absolute path to executable (or NULL)
- */
-/*@null@*/ const char * findProgramPath(/*@null@*/ const char * argv0)
- /*@*/;
-
-#endif
diff --git a/source4/lib/popt/libpopt.m4 b/source4/lib/popt/libpopt.m4
deleted file mode 100644
index 79980d1d6b..0000000000
--- a/source4/lib/popt/libpopt.m4
+++ /dev/null
@@ -1,43 +0,0 @@
-dnl Check to see if we should use the included popt
-
-INCLUDED_POPT=auto
-AC_ARG_WITH(included-popt,
-[ --with-included-popt use bundled popt library, not from system],
-[ INCLUDED_POPT=$withval ])
-
-AC_SUBST(POPT_LIBS)
-AC_SUBST(POPT_CFLAGS)
-
-if test x"$INCLUDED_POPT" != x"yes"; then
- AC_CHECK_HEADERS(popt.h)
- AC_CHECK_LIB(popt, poptGetContext, [ POPT_LIBS="-lpopt" ])
- if test x"$ac_cv_header_popt_h" = x"no" -o x"$ac_cv_lib_popt_poptGetContext" = x"no"; then
- INCLUDED_POPT=yes
- POPT_CFLAGS=""
- else
- INCLUDED_POPT=no
- fi
-fi
-
-AC_MSG_CHECKING(whether to use included popt)
-AC_MSG_RESULT($INCLUDED_POPT)
-if test x"$INCLUDED_POPT" != x"no"; then
- dnl find the popt sources. This is meant to work both for
- dnl popt standalone builds, and builds of packages using popt
- poptdir=""
- poptpaths="$srcdir $srcdir/lib/popt $srcdir/popt $srcdir/../popt"
- for d in $poptpaths; do
- if test -f "$d/popt.c"; then
- poptdir="$d"
- POPT_CFLAGS="-I$d"
- AC_SUBST(poptdir)
- break
- fi
- done
- if test x"$poptdir" = "x"; then
- AC_MSG_ERROR([cannot find popt source in $poptpaths])
- fi
- POPT_OBJ="popt.o findme.o poptconfig.o popthelp.o poptparse.o"
- AC_SUBST(POPT_OBJ)
- AC_CHECK_HEADERS([float.h alloca.h])
-fi
diff --git a/source4/lib/popt/popt.c b/source4/lib/popt/popt.c
deleted file mode 100644
index 4f1de65e6f..0000000000
--- a/source4/lib/popt/popt.c
+++ /dev/null
@@ -1,1238 +0,0 @@
-/** \ingroup popt
- * \file popt/popt.c
- */
-
-/* (C) 1998-2002 Red Hat, Inc. -- Licensing details are in the COPYING
- file accompanying popt source distributions, available from
- ftp://ftp.rpm.org/pub/rpm/dist */
-
-#undef MYDEBUG
-
-#include "system.h"
-
-#if HAVE_MATH_H
-#include <math.h>
-#endif
-#if HAVE_FLOAT_H
-#include <float.h>
-#endif
-
-#include "findme.h"
-#include "poptint.h"
-
-#ifdef MYDEBUG
-/*@unchecked@*/
-int _popt_debug = 0;
-#endif
-
-#ifndef HAVE_STRERROR
-static char * strerror(int errno) {
- extern int sys_nerr;
- extern char * sys_errlist[];
-
- if ((0 <= errno) && (errno < sys_nerr))
- return sys_errlist[errno];
- else
- return POPT_("unknown errno");
-}
-#endif
-
-#ifdef MYDEBUG
-/*@unused@*/ static void prtcon(const char *msg, poptContext con)
-{
- if (msg) fprintf(stderr, "%s", msg);
- fprintf(stderr, "\tcon %p os %p nextCharArg \"%s\" nextArg \"%s\" argv[%d] \"%s\"\n",
- con, con->os,
- (con->os->nextCharArg ? con->os->nextCharArg : ""),
- (con->os->nextArg ? con->os->nextArg : ""),
- con->os->next,
- (con->os->argv && con->os->argv[con->os->next]
- ? con->os->argv[con->os->next] : ""));
-}
-#endif
-
-void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
-{
- con->execPath = _free(con->execPath);
- con->execPath = xstrdup(path);
- con->execAbsolute = allowAbsolute;
- /*@-nullstate@*/ /* LCL: con->execPath can be NULL? */
- return;
- /*@=nullstate@*/
-}
-
-static void invokeCallbacksPRE(poptContext con, const struct poptOption * opt)
- /*@globals internalState@*/
- /*@modifies internalState@*/
-{
- if (opt != NULL)
- for (; opt->longName || opt->shortName || opt->arg; opt++) {
- if (opt->arg == NULL) continue; /* XXX program error. */
- if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
- /* Recurse on included sub-tables. */
- invokeCallbacksPRE(con, opt->arg);
- } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK &&
- (opt->argInfo & POPT_CBFLAG_PRE))
- { /*@-castfcnptr@*/
- poptCallbackType cb = (poptCallbackType)opt->arg;
- /*@=castfcnptr@*/
- /* Perform callback. */
- /*@-moduncon -noeffectuncon @*/
- cb(con, POPT_CALLBACK_REASON_PRE, NULL, NULL, opt->descrip);
- /*@=moduncon =noeffectuncon @*/
- }
- }
-}
-
-static void invokeCallbacksPOST(poptContext con, const struct poptOption * opt)
- /*@globals internalState@*/
- /*@modifies internalState@*/
-{
- if (opt != NULL)
- for (; opt->longName || opt->shortName || opt->arg; opt++) {
- if (opt->arg == NULL) continue; /* XXX program error. */
- if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
- /* Recurse on included sub-tables. */
- invokeCallbacksPOST(con, opt->arg);
- } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK &&
- (opt->argInfo & POPT_CBFLAG_POST))
- { /*@-castfcnptr@*/
- poptCallbackType cb = (poptCallbackType)opt->arg;
- /*@=castfcnptr@*/
- /* Perform callback. */
- /*@-moduncon -noeffectuncon @*/
- cb(con, POPT_CALLBACK_REASON_POST, NULL, NULL, opt->descrip);
- /*@=moduncon =noeffectuncon @*/
- }
- }
-}
-
-static void invokeCallbacksOPTION(poptContext con,
- const struct poptOption * opt,
- const struct poptOption * myOpt,
- /*@null@*/ const void * myData, int shorty)
- /*@globals internalState@*/
- /*@modifies internalState@*/
-{
- const struct poptOption * cbopt = NULL;
-
- if (opt != NULL)
- for (; opt->longName || opt->shortName || opt->arg; opt++) {
- if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
- /* Recurse on included sub-tables. */
- if (opt->arg != NULL) /* XXX program error */
- invokeCallbacksOPTION(con, opt->arg, myOpt, myData, shorty);
- } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK &&
- !(opt->argInfo & POPT_CBFLAG_SKIPOPTION)) {
- /* Save callback info. */
- cbopt = opt;
- } else if (cbopt != NULL &&
- ((myOpt->shortName && opt->shortName && shorty &&
- myOpt->shortName == opt->shortName) ||
- (myOpt->longName && opt->longName &&
- /*@-nullpass@*/ /* LCL: opt->longName != NULL */
- !strcmp(myOpt->longName, opt->longName)))
- /*@=nullpass@*/
- )
- { /*@-castfcnptr@*/
- poptCallbackType cb = (poptCallbackType)cbopt->arg;
- /*@=castfcnptr@*/
- const void * cbData = (cbopt->descrip ? cbopt->descrip : myData);
- /* Perform callback. */
- if (cb != NULL) { /* XXX program error */
- /*@-moduncon -noeffectuncon @*/
- cb(con, POPT_CALLBACK_REASON_OPTION, myOpt,
- con->os->nextArg, cbData);
- /*@=moduncon =noeffectuncon @*/
- }
- /* Terminate (unless explcitly continuing). */
- if (!(cbopt->argInfo & POPT_CBFLAG_CONTINUE))
- return;
- }
- }
-}
-
-poptContext poptGetContext(const char * name, int argc, const char ** argv,
- const struct poptOption * options, int flags)
-{
- poptContext con = malloc(sizeof(*con));
-
- if (con == NULL) return NULL; /* XXX can't happen */
- memset(con, 0, sizeof(*con));
-
- con->os = con->optionStack;
- con->os->argc = argc;
- /*@-dependenttrans -assignexpose@*/ /* FIX: W2DO? */
- con->os->argv = argv;
- /*@=dependenttrans =assignexpose@*/
- con->os->argb = NULL;
-
- if (!(flags & POPT_CONTEXT_KEEP_FIRST))
- con->os->next = 1; /* skip argv[0] */
-
- con->leftovers = calloc( (argc + 1), sizeof(*con->leftovers) );
- /*@-dependenttrans -assignexpose@*/ /* FIX: W2DO? */
- con->options = options;
- /*@=dependenttrans =assignexpose@*/
- con->aliases = NULL;
- con->numAliases = 0;
- con->flags = flags;
- con->execs = NULL;
- con->numExecs = 0;
- con->finalArgvAlloced = argc * 2;
- con->finalArgv = calloc( con->finalArgvAlloced, sizeof(*con->finalArgv) );
- con->execAbsolute = 1;
- con->arg_strip = NULL;
-
- if (getenv("POSIXLY_CORRECT") || getenv("POSIX_ME_HARDER"))
- con->flags |= POPT_CONTEXT_POSIXMEHARDER;
-
- if (name) {
- char * t = malloc(strlen(name) + 1);
- if (t) con->appName = strcpy(t, name);
- }
-
- /*@-internalglobs@*/
- invokeCallbacksPRE(con, con->options);
- /*@=internalglobs@*/
-
- return con;
-}
-
-static void cleanOSE(/*@special@*/ struct optionStackEntry *os)
- /*@uses os @*/
- /*@releases os->nextArg, os->argv, os->argb @*/
- /*@modifies os @*/
-{
- os->nextArg = _free(os->nextArg);
- os->argv = _free(os->argv);
- os->argb = PBM_FREE(os->argb);
-}
-
-/*@-boundswrite@*/
-void poptResetContext(poptContext con)
-{
- int i;
-
- if (con == NULL) return;
- while (con->os > con->optionStack) {
- cleanOSE(con->os--);
- }
- con->os->argb = PBM_FREE(con->os->argb);
- con->os->currAlias = NULL;
- con->os->nextCharArg = NULL;
- con->os->nextArg = NULL;
- con->os->next = 1; /* skip argv[0] */
-
- con->numLeftovers = 0;
- con->nextLeftover = 0;
- con->restLeftover = 0;
- con->doExec = NULL;
-
- if (con->finalArgv != NULL)
- for (i = 0; i < con->finalArgvCount; i++) {
- /*@-unqualifiedtrans@*/ /* FIX: typedef double indirection. */
- con->finalArgv[i] = _free(con->finalArgv[i]);
- /*@=unqualifiedtrans@*/
- }
-
- con->finalArgvCount = 0;
- con->arg_strip = PBM_FREE(con->arg_strip);
- /*@-nullstate@*/ /* FIX: con->finalArgv != NULL */
- return;
- /*@=nullstate@*/
-}
-/*@=boundswrite@*/
-
-/* Only one of longName, shortName should be set, not both. */
-/*@-boundswrite@*/
-static int handleExec(/*@special@*/ poptContext con,
- /*@null@*/ const char * longName, char shortName)
- /*@uses con->execs, con->numExecs, con->flags, con->doExec,
- con->finalArgv, con->finalArgvAlloced, con->finalArgvCount @*/
- /*@modifies con @*/
-{
- poptItem item;
- int i;
-
- if (con->execs == NULL || con->numExecs <= 0) /* XXX can't happen */
- return 0;
-
- for (i = con->numExecs - 1; i >= 0; i--) {
- item = con->execs + i;
- if (longName && !(item->option.longName &&
- !strcmp(longName, item->option.longName)))
- continue;
- else if (shortName != item->option.shortName)
- continue;
- break;
- }
- if (i < 0) return 0;
-
-
- if (con->flags & POPT_CONTEXT_NO_EXEC)
- return 1;
-
- if (con->doExec == NULL) {
- con->doExec = con->execs + i;
- return 1;
- }
-
- /* We already have an exec to do; remember this option for next
- time 'round */
- if ((con->finalArgvCount + 1) >= (con->finalArgvAlloced)) {
- con->finalArgvAlloced += 10;
- con->finalArgv = realloc(con->finalArgv,
- sizeof(*con->finalArgv) * con->finalArgvAlloced);
- }
-
- i = con->finalArgvCount++;
- if (con->finalArgv != NULL) /* XXX can't happen */
- { char *s = malloc((longName ? strlen(longName) : 0) + 3);
- if (s != NULL) { /* XXX can't happen */
- if (longName)
- sprintf(s, "--%s", longName);
- else
- sprintf(s, "-%c", shortName);
- con->finalArgv[i] = s;
- } else
- con->finalArgv[i] = NULL;
- }
-
- /*@-nullstate@*/ /* FIX: con->finalArgv[] == NULL */
- return 1;
- /*@=nullstate@*/
-}
-/*@=boundswrite@*/
-
-/* Only one of longName, shortName may be set at a time */
-static int handleAlias(/*@special@*/ poptContext con,
- /*@null@*/ const char * longName, char shortName,
- /*@exposed@*/ /*@null@*/ const char * nextCharArg)
- /*@uses con->aliases, con->numAliases, con->optionStack, con->os,
- con->os->currAlias, con->os->currAlias->option.longName @*/
- /*@modifies con @*/
-{
- poptItem item = con->os->currAlias;
- int rc;
- int i;
-
- if (item) {
- if (longName && (item->option.longName &&
- !strcmp(longName, item->option.longName)))
- return 0;
- if (shortName && shortName == item->option.shortName)
- return 0;
- }
-
- if (con->aliases == NULL || con->numAliases <= 0) /* XXX can't happen */
- return 0;
-
- for (i = con->numAliases - 1; i >= 0; i--) {
- item = con->aliases + i;
- if (longName && !(item->option.longName &&
- !strcmp(longName, item->option.longName)))
- continue;
- else if (shortName != item->option.shortName)
- continue;
- break;
- }
- if (i < 0) return 0;
-
- if ((con->os - con->optionStack + 1) == POPT_OPTION_DEPTH)
- return POPT_ERROR_OPTSTOODEEP;
-
-/*@-boundsread@*/
- if (nextCharArg && *nextCharArg)
- con->os->nextCharArg = nextCharArg;
-/*@=boundsread@*/
-
- con->os++;
- con->os->next = 0;
- con->os->stuffed = 0;
- con->os->nextArg = NULL;
- con->os->nextCharArg = NULL;
- con->os->currAlias = con->aliases + i;
- rc = poptDupArgv(con->os->currAlias->argc, con->os->currAlias->argv,
- &con->os->argc, &con->os->argv);
- con->os->argb = NULL;
-
- return (rc ? rc : 1);
-}
-
-/*@-bounds -boundswrite @*/
-static int execCommand(poptContext con)
- /*@globals internalState @*/
- /*@modifies internalState @*/
-{
- poptItem item = con->doExec;
- const char ** argv;
- int argc = 0;
- int rc;
-
- if (item == NULL) /*XXX can't happen*/
- return POPT_ERROR_NOARG;
-
- if (item->argv == NULL || item->argc < 1 ||
- (!con->execAbsolute && strchr(item->argv[0], '/')))
- return POPT_ERROR_NOARG;
-
- argv = malloc(sizeof(*argv) *
- (6 + item->argc + con->numLeftovers + con->finalArgvCount));
- if (argv == NULL) return POPT_ERROR_MALLOC; /* XXX can't happen */
-
- if (!strchr(item->argv[0], '/') && con->execPath) {
- char *s = alloca(strlen(con->execPath) + strlen(item->argv[0]) + sizeof("/"));
- sprintf(s, "%s/%s", con->execPath, item->argv[0]);
- argv[argc] = s;
- } else {
- argv[argc] = findProgramPath(item->argv[0]);
- }
- if (argv[argc++] == NULL) return POPT_ERROR_NOARG;
-
- if (item->argc > 1) {
- memcpy(argv + argc, item->argv + 1, sizeof(*argv) * (item->argc - 1));
- argc += (item->argc - 1);
- }
-
- if (con->finalArgv != NULL && con->finalArgvCount > 0) {
- memcpy(argv + argc, con->finalArgv,
- sizeof(*argv) * con->finalArgvCount);
- argc += con->finalArgvCount;
- }
-
- if (con->leftovers != NULL && con->numLeftovers > 0) {
-#if 0
- argv[argc++] = "--";
-#endif
- memcpy(argv + argc, con->leftovers, sizeof(*argv) * con->numLeftovers);
- argc += con->numLeftovers;
- }
-
- argv[argc] = NULL;
-
-#ifdef __hpux
- rc = setresuid(getuid(), getuid(),-1);
- if (rc) return POPT_ERROR_ERRNO;
-#else
-/*
- * XXX " ... on BSD systems setuid() should be preferred over setreuid()"
- * XXX sez' Timur Bakeyev <mc@bat.ru>
- * XXX from Norbert Warmuth <nwarmuth@privat.circular.de>
- */
-#if defined(HAVE_SETUID)
- rc = setuid(getuid());
- if (rc) return POPT_ERROR_ERRNO;
-#elif defined (HAVE_SETREUID)
- rc = setreuid(getuid(), getuid()); /*hlauer: not portable to hpux9.01 */
- if (rc) return POPT_ERROR_ERRNO;
-#else
- ; /* Can't drop privileges */
-#endif
-#endif
-
- if (argv[0] == NULL)
- return POPT_ERROR_NOARG;
-
-#ifdef MYDEBUG
-if (_popt_debug)
- { const char ** avp;
- fprintf(stderr, "==> execvp(%s) argv[%d]:", argv[0], argc);
- for (avp = argv; *avp; avp++)
- fprintf(stderr, " '%s'", *avp);
- fprintf(stderr, "\n");
- }
-#endif
-
- rc = execvp(argv[0], (char *const *)argv);
-
- return POPT_ERROR_ERRNO;
-}
-/*@=bounds =boundswrite @*/
-
-/*@-boundswrite@*/
-/*@observer@*/ /*@null@*/ static const struct poptOption *
-findOption(const struct poptOption * opt, /*@null@*/ const char * longName,
- char shortName,
- /*@null@*/ /*@out@*/ poptCallbackType * callback,
- /*@null@*/ /*@out@*/ const void ** callbackData,
- int singleDash)
- /*@modifies *callback, *callbackData */
-{
- const struct poptOption * cb = NULL;
-
- /* This happens when a single - is given */
- if (singleDash && !shortName && (longName && *longName == '\0'))
- shortName = '-';
-
- for (; opt->longName || opt->shortName || opt->arg; opt++) {
-
- if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
- const struct poptOption * opt2;
-
- /* Recurse on included sub-tables. */
- if (opt->arg == NULL) continue; /* XXX program error */
- opt2 = findOption(opt->arg, longName, shortName, callback,
- callbackData, singleDash);
- if (opt2 == NULL) continue;
- /* Sub-table data will be inheirited if no data yet. */
- if (!(callback && *callback)) return opt2;
- if (!(callbackData && *callbackData == NULL)) return opt2;
- /*@-observertrans -dependenttrans @*/
- *callbackData = opt->descrip;
- /*@=observertrans =dependenttrans @*/
- return opt2;
- } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK) {
- cb = opt;
- } else if (longName && opt->longName &&
- (!singleDash || (opt->argInfo & POPT_ARGFLAG_ONEDASH)) &&
- /*@-nullpass@*/ /* LCL: opt->longName != NULL */
- !strcmp(longName, opt->longName))
- /*@=nullpass@*/
- {
- break;
- } else if (shortName && shortName == opt->shortName) {
- break;
- }
- }
-
- if (!opt->longName && !opt->shortName)
- return NULL;
- /*@-modobserver -mods @*/
- if (callback) *callback = NULL;
- if (callbackData) *callbackData = NULL;
- if (cb) {
- if (callback)
- /*@-castfcnptr@*/
- *callback = (poptCallbackType)cb->arg;
- /*@=castfcnptr@*/
- if (!(cb->argInfo & POPT_CBFLAG_INC_DATA)) {
- if (callbackData)
- /*@-observertrans@*/ /* FIX: typedef double indirection. */
- *callbackData = cb->descrip;
- /*@=observertrans@*/
- }
- }
- /*@=modobserver =mods @*/
-
- return opt;
-}
-/*@=boundswrite@*/
-
-static const char * findNextArg(/*@special@*/ poptContext con,
- unsigned argx, int delete_arg)
- /*@uses con->optionStack, con->os,
- con->os->next, con->os->argb, con->os->argc, con->os->argv @*/
- /*@modifies con @*/
-{
- struct optionStackEntry * os = con->os;
- const char * arg;
-
- do {
- int i;
- arg = NULL;
- while (os->next == os->argc && os > con->optionStack) os--;
- if (os->next == os->argc && os == con->optionStack) break;
- if (os->argv != NULL)
- for (i = os->next; i < os->argc; i++) {
- /*@-sizeoftype@*/
- if (os->argb && PBM_ISSET(i, os->argb))
- /*@innercontinue@*/ continue;
- if (*os->argv[i] == '-')
- /*@innercontinue@*/ continue;
- if (--argx > 0)
- /*@innercontinue@*/ continue;
- arg = os->argv[i];
- if (delete_arg) {
- if (os->argb == NULL) os->argb = PBM_ALLOC(os->argc);
- if (os->argb != NULL) /* XXX can't happen */
- PBM_SET(i, os->argb);
- }
- /*@innerbreak@*/ break;
- /*@=sizeoftype@*/
- }
- if (os > con->optionStack) os--;
- } while (arg == NULL);
- return arg;
-}
-
-/*@-boundswrite@*/
-static /*@only@*/ /*@null@*/ const char *
-expandNextArg(/*@special@*/ poptContext con, const char * s)
- /*@uses con->optionStack, con->os,
- con->os->next, con->os->argb, con->os->argc, con->os->argv @*/
- /*@modifies con @*/
-{
- const char * a = NULL;
- size_t alen;
- char *t, *te;
- size_t tn = strlen(s) + 1;
- char c;
-
- te = t = malloc(tn);;
- if (t == NULL) return NULL; /* XXX can't happen */
- while ((c = *s++) != '\0') {
- switch (c) {
-#if 0 /* XXX can't do this */
- case '\\': /* escape */
- c = *s++;
- /*@switchbreak@*/ break;
-#endif
- case '!':
- if (!(s[0] == '#' && s[1] == ':' && s[2] == '+'))
- /*@switchbreak@*/ break;
- /* XXX Make sure that findNextArg deletes only next arg. */
- if (a == NULL) {
- if ((a = findNextArg(con, 1, 1)) == NULL)
- /*@switchbreak@*/ break;
- }
- s += 3;
-
- alen = strlen(a);
- tn += alen;
- *te = '\0';
- t = realloc(t, tn);
- te = t + strlen(t);
- strncpy(te, a, alen); te += alen;
- continue;
- /*@notreached@*/ /*@switchbreak@*/ break;
- default:
- /*@switchbreak@*/ break;
- }
- *te++ = c;
- }
- *te = '\0';
- t = realloc(t, strlen(t) + 1); /* XXX memory leak, hard to plug */
- return t;
-}
-/*@=boundswrite@*/
-
-static void poptStripArg(/*@special@*/ poptContext con, int which)
- /*@uses con->arg_strip, con->optionStack @*/
- /*@defines con->arg_strip @*/
- /*@modifies con @*/
-{
- /*@-sizeoftype@*/
- if (con->arg_strip == NULL)
- con->arg_strip = PBM_ALLOC(con->optionStack[0].argc);
- if (con->arg_strip != NULL) /* XXX can't happen */
- PBM_SET(which, con->arg_strip);
- /*@=sizeoftype@*/
- /*@-compdef@*/ /* LCL: con->arg_strip udefined? */
- return;
- /*@=compdef@*/
-}
-
-int poptSaveLong(long * arg, int argInfo, long aLong)
-{
- /* XXX Check alignment, may fail on funky platforms. */
- if (arg == NULL || (((unsigned long)arg) & (sizeof(*arg)-1)))
- return POPT_ERROR_NULLARG;
-
- if (argInfo & POPT_ARGFLAG_NOT)
- aLong = ~aLong;
- switch (argInfo & POPT_ARGFLAG_LOGICALOPS) {
- case 0:
- *arg = aLong;
- break;
- case POPT_ARGFLAG_OR:
- *arg |= aLong;
- break;
- case POPT_ARGFLAG_AND:
- *arg &= aLong;
- break;
- case POPT_ARGFLAG_XOR:
- *arg ^= aLong;
- break;
- default:
- return POPT_ERROR_BADOPERATION;
- /*@notreached@*/ break;
- }
- return 0;
-}
-
-int poptSaveInt(/*@null@*/ int * arg, int argInfo, long aLong)
-{
- /* XXX Check alignment, may fail on funky platforms. */
- if (arg == NULL || (((unsigned long)arg) & (sizeof(*arg)-1)))
- return POPT_ERROR_NULLARG;
-
- if (argInfo & POPT_ARGFLAG_NOT)
- aLong = ~aLong;
- switch (argInfo & POPT_ARGFLAG_LOGICALOPS) {
- case 0:
- *arg = aLong;
- break;
- case POPT_ARGFLAG_OR:
- *arg |= aLong;
- break;
- case POPT_ARGFLAG_AND:
- *arg &= aLong;
- break;
- case POPT_ARGFLAG_XOR:
- *arg ^= aLong;
- break;
- default:
- return POPT_ERROR_BADOPERATION;
- /*@notreached@*/ break;
- }
- return 0;
-}
-
-/*@-boundswrite@*/
-/* returns 'val' element, -1 on last item, POPT_ERROR_* on error */
-int poptGetNextOpt(poptContext con)
-{
- const struct poptOption * opt = NULL;
- int done = 0;
-
- if (con == NULL)
- return -1;
- while (!done) {
- const char * origOptString = NULL;
- poptCallbackType cb = NULL;
- const void * cbData = NULL;
- const char * longArg = NULL;
- int canstrip = 0;
- int shorty = 0;
-
- while (!con->os->nextCharArg && con->os->next == con->os->argc
- && con->os > con->optionStack) {
- cleanOSE(con->os--);
- }
- if (!con->os->nextCharArg && con->os->next == con->os->argc) {
- /*@-internalglobs@*/
- invokeCallbacksPOST(con, con->options);
- /*@=internalglobs@*/
- if (con->doExec) return execCommand(con);
- return -1;
- }
-
- /* Process next long option */
- if (!con->os->nextCharArg) {
- char * localOptString, * optString;
- int thisopt;
-
- /*@-sizeoftype@*/
- if (con->os->argb && PBM_ISSET(con->os->next, con->os->argb)) {
- con->os->next++;
- continue;
- }
- /*@=sizeoftype@*/
- thisopt = con->os->next;
- if (con->os->argv != NULL) /* XXX can't happen */
- origOptString = con->os->argv[con->os->next++];
-
- if (origOptString == NULL) /* XXX can't happen */
- return POPT_ERROR_BADOPT;
-
- if (con->restLeftover || *origOptString != '-') {
- if (con->flags & POPT_CONTEXT_POSIXMEHARDER)
- con->restLeftover = 1;
- if (con->flags & POPT_CONTEXT_ARG_OPTS) {
- con->os->nextArg = xstrdup(origOptString);
- return 0;
- }
- if (con->leftovers != NULL) /* XXX can't happen */
- con->leftovers[con->numLeftovers++] = origOptString;
- continue;
- }
-
- /* Make a copy we can hack at */
- localOptString = optString =
- strcpy(alloca(strlen(origOptString) + 1), origOptString);
-
- if (optString[0] == '\0')
- return POPT_ERROR_BADOPT;
-
- if (optString[1] == '-' && !optString[2]) {
- con->restLeftover = 1;
- continue;
- } else {
- char *oe;
- int singleDash;
-
- optString++;
- if (*optString == '-')
- singleDash = 0, optString++;
- else
- singleDash = 1;
-
- /* XXX aliases with arg substitution need "--alias=arg" */
- if (handleAlias(con, optString, '\0', NULL))
- continue;
-
- if (handleExec(con, optString, '\0'))
- continue;
-
- /* Check for "--long=arg" option. */
- for (oe = optString; *oe && *oe != '='; oe++)
- {};
- if (*oe == '=') {
- *oe++ = '\0';
- /* XXX longArg is mapped back to persistent storage. */
- longArg = origOptString + (oe - localOptString);
- }
-
- opt = findOption(con->options, optString, '\0', &cb, &cbData,
- singleDash);
- if (!opt && !singleDash)
- return POPT_ERROR_BADOPT;
- }
-
- if (!opt) {
- con->os->nextCharArg = origOptString + 1;
- } else {
- if (con->os == con->optionStack &&
- opt->argInfo & POPT_ARGFLAG_STRIP)
- {
- canstrip = 1;
- poptStripArg(con, thisopt);
- }
- shorty = 0;
- }
- }
-
- /* Process next short option */
- /*@-branchstate@*/ /* FIX: W2DO? */
- if (con->os->nextCharArg) {
- origOptString = con->os->nextCharArg;
-
- con->os->nextCharArg = NULL;
-
- if (handleAlias(con, NULL, *origOptString, origOptString + 1))
- continue;
-
- if (handleExec(con, NULL, *origOptString)) {
- /* Restore rest of short options for further processing */
- origOptString++;
- if (*origOptString != '\0')
- con->os->nextCharArg = origOptString;
- continue;
- }
-
- opt = findOption(con->options, NULL, *origOptString, &cb,
- &cbData, 0);
- if (!opt)
- return POPT_ERROR_BADOPT;
- shorty = 1;
-
- origOptString++;
- if (*origOptString != '\0')
- con->os->nextCharArg = origOptString;
- }
- /*@=branchstate@*/
-
- if (opt == NULL) return POPT_ERROR_BADOPT; /* XXX can't happen */
- if (opt->arg && (opt->argInfo & POPT_ARG_MASK) == POPT_ARG_NONE) {
- if (poptSaveInt((int *)opt->arg, opt->argInfo, 1L))
- return POPT_ERROR_BADOPERATION;
- } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_VAL) {
- if (opt->arg) {
- if (poptSaveInt((int *)opt->arg, opt->argInfo, (long)opt->val))
- return POPT_ERROR_BADOPERATION;
- }
- } else if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE) {
- con->os->nextArg = _free(con->os->nextArg);
- /*@-usedef@*/ /* FIX: W2DO? */
- if (longArg) {
- /*@=usedef@*/
- longArg = expandNextArg(con, longArg);
- con->os->nextArg = longArg;
- } else if (con->os->nextCharArg) {
- longArg = expandNextArg(con, con->os->nextCharArg);
- con->os->nextArg = longArg;
- con->os->nextCharArg = NULL;
- } else {
- while (con->os->next == con->os->argc &&
- con->os > con->optionStack) {
- cleanOSE(con->os--);
- }
- if (con->os->next == con->os->argc) {
- if (!(opt->argInfo & POPT_ARGFLAG_OPTIONAL))
- /*@-compdef@*/ /* FIX: con->os->argv not defined */
- return POPT_ERROR_NOARG;
- /*@=compdef@*/
- con->os->nextArg = NULL;
- } else {
-
- /*
- * Make sure this isn't part of a short arg or the
- * result of an alias expansion.
- */
- if (con->os == con->optionStack &&
- (opt->argInfo & POPT_ARGFLAG_STRIP) &&
- canstrip) {
- poptStripArg(con, con->os->next);
- }
-
- if (con->os->argv != NULL) { /* XXX can't happen */
- /* XXX watchout: subtle side-effects live here. */
- longArg = con->os->argv[con->os->next++];
- longArg = expandNextArg(con, longArg);
- con->os->nextArg = longArg;
- }
- }
- }
- longArg = NULL;
-
- if (opt->arg) {
- switch (opt->argInfo & POPT_ARG_MASK) {
- case POPT_ARG_STRING:
- /* XXX memory leak, hard to plug */
- *((const char **) opt->arg) = (con->os->nextArg)
- ? xstrdup(con->os->nextArg) : NULL;
- /*@switchbreak@*/ break;
-
- case POPT_ARG_INT:
- case POPT_ARG_LONG:
- { long aLong = 0;
- char *end;
-
- if (con->os->nextArg) {
- aLong = strtol(con->os->nextArg, &end, 0);
- if (!(end && *end == '\0'))
- return POPT_ERROR_BADNUMBER;
- }
-
- if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_LONG) {
- if (aLong == LONG_MIN || aLong == LONG_MAX)
- return POPT_ERROR_OVERFLOW;
- if (poptSaveLong((long *)opt->arg, opt->argInfo, aLong))
- return POPT_ERROR_BADOPERATION;
- } else {
- if (aLong > INT_MAX || aLong < INT_MIN)
- return POPT_ERROR_OVERFLOW;
- if (poptSaveInt((int *)opt->arg, opt->argInfo, aLong))
- return POPT_ERROR_BADOPERATION;
- }
- } /*@switchbreak@*/ break;
-
- case POPT_ARG_FLOAT:
- case POPT_ARG_DOUBLE:
- { double aDouble = 0.0;
- char *end;
-
- if (con->os->nextArg) {
- /*@-mods@*/
- int saveerrno = errno;
- errno = 0;
- aDouble = strtod(con->os->nextArg, &end);
- if (errno == ERANGE)
- return POPT_ERROR_OVERFLOW;
- errno = saveerrno;
- /*@=mods@*/
- if (*end != '\0')
- return POPT_ERROR_BADNUMBER;
- }
-
- if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_DOUBLE) {
- *((double *) opt->arg) = aDouble;
- } else {
-#define _ABS(a) ((((a) - 0.0) < DBL_EPSILON) ? -(a) : (a))
- if ((_ABS(aDouble) - FLT_MAX) > DBL_EPSILON)
- return POPT_ERROR_OVERFLOW;
- if ((FLT_MIN - _ABS(aDouble)) > DBL_EPSILON)
- return POPT_ERROR_OVERFLOW;
- *((float *) opt->arg) = aDouble;
- }
- } /*@switchbreak@*/ break;
- default:
- fprintf(stdout,
- POPT_("option type (%d) not implemented in popt\n"),
- (opt->argInfo & POPT_ARG_MASK));
- exit(EXIT_FAILURE);
- /*@notreached@*/ /*@switchbreak@*/ break;
- }
- }
- }
-
- if (cb) {
- /*@-internalglobs@*/
- invokeCallbacksOPTION(con, con->options, opt, cbData, shorty);
- /*@=internalglobs@*/
- } else if (opt->val && ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_VAL))
- done = 1;
-
- if ((con->finalArgvCount + 2) >= (con->finalArgvAlloced)) {
- con->finalArgvAlloced += 10;
- con->finalArgv = realloc(con->finalArgv,
- sizeof(*con->finalArgv) * con->finalArgvAlloced);
- }
-
- if (con->finalArgv != NULL)
- { char *s = malloc((opt->longName ? strlen(opt->longName) : 0) + 3);
- if (s != NULL) { /* XXX can't happen */
- if (opt->longName)
- sprintf(s, "%s%s",
- ((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "-" : "--"),
- opt->longName);
- else
- sprintf(s, "-%c", opt->shortName);
- con->finalArgv[con->finalArgvCount++] = s;
- } else
- con->finalArgv[con->finalArgvCount++] = NULL;
- }
-
- if (opt->arg && (opt->argInfo & POPT_ARG_MASK) == POPT_ARG_NONE)
- /*@-ifempty@*/ ; /*@=ifempty@*/
- else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_VAL)
- /*@-ifempty@*/ ; /*@=ifempty@*/
- else if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE) {
- if (con->finalArgv != NULL && con->os->nextArg)
- con->finalArgv[con->finalArgvCount++] =
- /*@-nullpass@*/ /* LCL: con->os->nextArg != NULL */
- xstrdup(con->os->nextArg);
- /*@=nullpass@*/
- }
- }
-
- return (opt ? opt->val : -1); /* XXX can't happen */
-}
-/*@=boundswrite@*/
-
-const char * poptGetOptArg(poptContext con)
-{
- const char * ret = NULL;
- /*@-branchstate@*/
- if (con) {
- ret = con->os->nextArg;
- con->os->nextArg = NULL;
- }
- /*@=branchstate@*/
- return ret;
-}
-
-const char * poptGetArg(poptContext con)
-{
- const char * ret = NULL;
- if (con && con->leftovers != NULL && con->nextLeftover < con->numLeftovers)
- ret = con->leftovers[con->nextLeftover++];
- return ret;
-}
-
-const char * poptPeekArg(poptContext con)
-{
- const char * ret = NULL;
- if (con && con->leftovers != NULL && con->nextLeftover < con->numLeftovers)
- ret = con->leftovers[con->nextLeftover];
- return ret;
-}
-
-/*@-boundswrite@*/
-const char ** poptGetArgs(poptContext con)
-{
- if (con == NULL ||
- con->leftovers == NULL || con->numLeftovers == con->nextLeftover)
- return NULL;
-
- /* some apps like [like RPM ;-) ] need this NULL terminated */
- con->leftovers[con->numLeftovers] = NULL;
-
- /*@-nullret -nullstate @*/ /* FIX: typedef double indirection. */
- return (con->leftovers + con->nextLeftover);
- /*@=nullret =nullstate @*/
-}
-/*@=boundswrite@*/
-
-poptContext poptFreeContext(poptContext con)
-{
- poptItem item;
- int i;
-
- if (con == NULL) return con;
- poptResetContext(con);
- con->os->argb = _free(con->os->argb);
-
- if (con->aliases != NULL)
- for (i = 0; i < con->numAliases; i++) {
- item = con->aliases + i;
- /*@-modobserver -observertrans -dependenttrans@*/
- item->option.longName = _free(item->option.longName);
- item->option.descrip = _free(item->option.descrip);
- item->option.argDescrip = _free(item->option.argDescrip);
- /*@=modobserver =observertrans =dependenttrans@*/
- item->argv = _free(item->argv);
- }
- con->aliases = _free(con->aliases);
-
- if (con->execs != NULL)
- for (i = 0; i < con->numExecs; i++) {
- item = con->execs + i;
- /*@-modobserver -observertrans -dependenttrans@*/
- item->option.longName = _free(item->option.longName);
- item->option.descrip = _free(item->option.descrip);
- item->option.argDescrip = _free(item->option.argDescrip);
- /*@=modobserver =observertrans =dependenttrans@*/
- item->argv = _free(item->argv);
- }
- con->execs = _free(con->execs);
-
- con->leftovers = _free(con->leftovers);
- con->finalArgv = _free(con->finalArgv);
- con->appName = _free(con->appName);
- con->otherHelp = _free(con->otherHelp);
- con->execPath = _free(con->execPath);
- con->arg_strip = PBM_FREE(con->arg_strip);
-
- con = _free(con);
- return con;
-}
-
-int poptAddAlias(poptContext con, struct poptAlias alias,
- /*@unused@*/ int flags)
-{
- poptItem item = alloca(sizeof(*item));
- memset(item, 0, sizeof(*item));
- item->option.longName = alias.longName;
- item->option.shortName = alias.shortName;
- item->option.argInfo = POPT_ARGFLAG_DOC_HIDDEN;
- item->option.arg = 0;
- item->option.val = 0;
- item->option.descrip = NULL;
- item->option.argDescrip = NULL;
- item->argc = alias.argc;
- item->argv = alias.argv;
- return poptAddItem(con, item, 0);
-}
-
-/*@-boundswrite@*/
-/*@-mustmod@*/ /* LCL: con not modified? */
-int poptAddItem(poptContext con, poptItem newItem, int flags)
-{
- poptItem * items, item;
- int * nitems;
-
- switch (flags) {
- case 1:
- items = &con->execs;
- nitems = &con->numExecs;
- break;
- case 0:
- items = &con->aliases;
- nitems = &con->numAliases;
- break;
- default:
- return 1;
- /*@notreached@*/ break;
- }
-
- *items = realloc((*items), ((*nitems) + 1) * sizeof(**items));
- if ((*items) == NULL)
- return 1;
-
- item = (*items) + (*nitems);
-
- item->option.longName =
- (newItem->option.longName ? xstrdup(newItem->option.longName) : NULL);
- item->option.shortName = newItem->option.shortName;
- item->option.argInfo = newItem->option.argInfo;
- item->option.arg = newItem->option.arg;
- item->option.val = newItem->option.val;
- item->option.descrip =
- (newItem->option.descrip ? xstrdup(newItem->option.descrip) : NULL);
- item->option.argDescrip =
- (newItem->option.argDescrip ? xstrdup(newItem->option.argDescrip) : NULL);
- item->argc = newItem->argc;
- item->argv = newItem->argv;
-
- (*nitems)++;
-
- return 0;
-}
-/*@=mustmod@*/
-/*@=boundswrite@*/
-
-const char * poptBadOption(poptContext con, int flags)
-{
- struct optionStackEntry * os = NULL;
-
- if (con != NULL)
- os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os;
-
- /*@-nullderef@*/ /* LCL: os->argv != NULL */
- return (os && os->argv ? os->argv[os->next - 1] : NULL);
- /*@=nullderef@*/
-}
-
-const char *poptStrerror(const int error)
-{
- switch (error) {
- case POPT_ERROR_NOARG:
- return POPT_("missing argument");
- case POPT_ERROR_BADOPT:
- return POPT_("unknown option");
- case POPT_ERROR_BADOPERATION:
- return POPT_("mutually exclusive logical operations requested");
- case POPT_ERROR_NULLARG:
- return POPT_("opt->arg should not be NULL");
- case POPT_ERROR_OPTSTOODEEP:
- return POPT_("aliases nested too deeply");
- case POPT_ERROR_BADQUOTE:
- return POPT_("error in parameter quoting");
- case POPT_ERROR_BADNUMBER:
- return POPT_("invalid numeric value");
- case POPT_ERROR_OVERFLOW:
- return POPT_("number too large or too small");
- case POPT_ERROR_MALLOC:
- return POPT_("memory allocation failed");
- case POPT_ERROR_ERRNO:
- return strerror(errno);
- default:
- return POPT_("unknown error");
- }
-}
-
-int poptStuffArgs(poptContext con, const char ** argv)
-{
- int argc;
- int rc;
-
- if ((con->os - con->optionStack) == POPT_OPTION_DEPTH)
- return POPT_ERROR_OPTSTOODEEP;
-
- for (argc = 0; argv[argc]; argc++)
- {};
-
- con->os++;
- con->os->next = 0;
- con->os->nextArg = NULL;
- con->os->nextCharArg = NULL;
- con->os->currAlias = NULL;
- rc = poptDupArgv(argc, argv, &con->os->argc, &con->os->argv);
- con->os->argb = NULL;
- con->os->stuffed = 1;
-
- return rc;
-}
-
-const char * poptGetInvocationName(poptContext con)
-{
- return (con->os->argv ? con->os->argv[0] : "");
-}
-
-/*@-boundswrite@*/
-int poptStrippedArgv(poptContext con, int argc, char ** argv)
-{
- int numargs = argc;
- int j = 1;
- int i;
-
- /*@-sizeoftype@*/
- if (con->arg_strip)
- for (i = 1; i < argc; i++) {
- if (PBM_ISSET(i, con->arg_strip))
- numargs--;
- }
-
- for (i = 1; i < argc; i++) {
- if (con->arg_strip && PBM_ISSET(i, con->arg_strip))
- continue;
- argv[j] = (j < numargs) ? argv[i] : NULL;
- j++;
- }
- /*@=sizeoftype@*/
-
- return numargs;
-}
-/*@=boundswrite@*/
diff --git a/source4/lib/popt/popt.h b/source4/lib/popt/popt.h
deleted file mode 100644
index 04c9f655ab..0000000000
--- a/source4/lib/popt/popt.h
+++ /dev/null
@@ -1,541 +0,0 @@
-/** \file popt/popt.h
- * \ingroup popt
- */
-
-/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
- file accompanying popt source distributions, available from
- ftp://ftp.rpm.org/pub/rpm/dist. */
-
-#ifndef H_POPT
-#define H_POPT
-
-#include <stdio.h> /* for FILE * */
-
-#define POPT_OPTION_DEPTH 10
-
-/** \ingroup popt
- * \name Arg type identifiers
- */
-/*@{*/
-#define POPT_ARG_NONE 0 /*!< no arg */
-#define POPT_ARG_STRING 1 /*!< arg will be saved as string */
-#define POPT_ARG_INT 2 /*!< arg will be converted to int */
-#define POPT_ARG_LONG 3 /*!< arg will be converted to long */
-#define POPT_ARG_INCLUDE_TABLE 4 /*!< arg points to table */
-#define POPT_ARG_CALLBACK 5 /*!< table-wide callback... must be
- set first in table; arg points
- to callback, descrip points to
- callback data to pass */
-#define POPT_ARG_INTL_DOMAIN 6 /*!< set the translation domain
- for this table and any
- included tables; arg points
- to the domain string */
-#define POPT_ARG_VAL 7 /*!< arg should take value val */
-#define POPT_ARG_FLOAT 8 /*!< arg will be converted to float */
-#define POPT_ARG_DOUBLE 9 /*!< arg will be converted to double */
-
-#define POPT_ARG_MASK 0x0000FFFF
-/*@}*/
-
-/** \ingroup popt
- * \name Arg modifiers
- */
-/*@{*/
-#define POPT_ARGFLAG_ONEDASH 0x80000000 /*!< allow -longoption */
-#define POPT_ARGFLAG_DOC_HIDDEN 0x40000000 /*!< don't show in help/usage */
-#define POPT_ARGFLAG_STRIP 0x20000000 /*!< strip this arg from argv(only applies to long args) */
-#define POPT_ARGFLAG_OPTIONAL 0x10000000 /*!< arg may be missing */
-
-#define POPT_ARGFLAG_OR 0x08000000 /*!< arg will be or'ed */
-#define POPT_ARGFLAG_NOR 0x09000000 /*!< arg will be nor'ed */
-#define POPT_ARGFLAG_AND 0x04000000 /*!< arg will be and'ed */
-#define POPT_ARGFLAG_NAND 0x05000000 /*!< arg will be nand'ed */
-#define POPT_ARGFLAG_XOR 0x02000000 /*!< arg will be xor'ed */
-#define POPT_ARGFLAG_NOT 0x01000000 /*!< arg will be negated */
-#define POPT_ARGFLAG_LOGICALOPS \
- (POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR)
-
-#define POPT_BIT_SET (POPT_ARG_VAL|POPT_ARGFLAG_OR)
- /*!< set arg bit(s) */
-#define POPT_BIT_CLR (POPT_ARG_VAL|POPT_ARGFLAG_NAND)
- /*!< clear arg bit(s) */
-
-#define POPT_ARGFLAG_SHOW_DEFAULT 0x00800000 /*!< show default value in --help */
-
-/*@}*/
-
-/** \ingroup popt
- * \name Callback modifiers
- */
-/*@{*/
-#define POPT_CBFLAG_PRE 0x80000000 /*!< call the callback before parse */
-#define POPT_CBFLAG_POST 0x40000000 /*!< call the callback after parse */
-#define POPT_CBFLAG_INC_DATA 0x20000000 /*!< use data from the include line,
- not the subtable */
-#define POPT_CBFLAG_SKIPOPTION 0x10000000 /*!< don't callback with option */
-#define POPT_CBFLAG_CONTINUE 0x08000000 /*!< continue callbacks with option */
-/*@}*/
-
-/** \ingroup popt
- * \name Error return values
- */
-/*@{*/
-#define POPT_ERROR_NOARG -10 /*!< missing argument */
-#define POPT_ERROR_BADOPT -11 /*!< unknown option */
-#define POPT_ERROR_OPTSTOODEEP -13 /*!< aliases nested too deeply */
-#define POPT_ERROR_BADQUOTE -15 /*!< error in paramter quoting */
-#define POPT_ERROR_ERRNO -16 /*!< errno set, use strerror(errno) */
-#define POPT_ERROR_BADNUMBER -17 /*!< invalid numeric value */
-#define POPT_ERROR_OVERFLOW -18 /*!< number too large or too small */
-#define POPT_ERROR_BADOPERATION -19 /*!< mutually exclusive logical operations requested */
-#define POPT_ERROR_NULLARG -20 /*!< opt->arg should not be NULL */
-#define POPT_ERROR_MALLOC -21 /*!< memory allocation failed */
-/*@}*/
-
-/** \ingroup popt
- * \name poptBadOption() flags
- */
-/*@{*/
-#define POPT_BADOPTION_NOALIAS (1 << 0) /*!< don't go into an alias */
-/*@}*/
-
-/** \ingroup popt
- * \name poptGetContext() flags
- */
-/*@{*/
-#define POPT_CONTEXT_NO_EXEC (1 << 0) /*!< ignore exec expansions */
-#define POPT_CONTEXT_KEEP_FIRST (1 << 1) /*!< pay attention to argv[0] */
-#define POPT_CONTEXT_POSIXMEHARDER (1 << 2) /*!< options can't follow args */
-#define POPT_CONTEXT_ARG_OPTS (1 << 4) /*!< return args as options with value 0 */
-/*@}*/
-
-/** \ingroup popt
- */
-struct poptOption {
-/*@observer@*/ /*@null@*/ const char * longName; /*!< may be NULL */
- char shortName; /*!< may be '\0' */
- int argInfo;
-/*@shared@*/ /*@null@*/ void * arg; /*!< depends on argInfo */
- int val; /*!< 0 means don't return, just update flag */
-/*@observer@*/ /*@null@*/ const char * descrip; /*!< description for autohelp -- may be NULL */
-/*@observer@*/ /*@null@*/ const char * argDescrip; /*!< argument description for autohelp */
-};
-
-/** \ingroup popt
- * A popt alias argument for poptAddAlias().
- */
-struct poptAlias {
-/*@owned@*/ /*@null@*/ const char * longName; /*!< may be NULL */
- char shortName; /*!< may be '\0' */
- int argc;
-/*@owned@*/ const char ** argv; /*!< must be free()able */
-};
-
-/** \ingroup popt
- * A popt alias or exec argument for poptAddItem().
- */
-/*@-exporttype@*/
-typedef struct poptItem_s {
- struct poptOption option; /*!< alias/exec name(s) and description. */
- int argc; /*!< (alias) no. of args. */
-/*@owned@*/ const char ** argv; /*!< (alias) args, must be free()able. */
-} * poptItem;
-/*@=exporttype@*/
-
-/** \ingroup popt
- * \name Auto-generated help/usage
- */
-/*@{*/
-
-/**
- * Empty table marker to enable displaying popt alias/exec options.
- */
-/*@-exportvar@*/
-/*@unchecked@*/ /*@observer@*/
-extern struct poptOption poptAliasOptions[];
-/*@=exportvar@*/
-#define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
- 0, "Options implemented via popt alias/exec:", NULL },
-
-/**
- * Auto help table options.
- */
-/*@-exportvar@*/
-/*@unchecked@*/ /*@observer@*/
-extern struct poptOption poptHelpOptions[];
-/*@=exportvar@*/
-#define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
- 0, "Help options:", NULL },
-
-#define POPT_TABLEEND { NULL, '\0', 0, 0, 0, NULL, NULL }
-/*@}*/
-
-/** \ingroup popt
- */
-/*@-exporttype@*/
-typedef /*@abstract@*/ struct poptContext_s * poptContext;
-/*@=exporttype@*/
-
-/** \ingroup popt
- */
-#ifndef __cplusplus
-/*@-exporttype -typeuse@*/
-typedef struct poptOption * poptOption;
-/*@=exporttype =typeuse@*/
-#endif
-
-/*@-exportconst@*/
-enum poptCallbackReason {
- POPT_CALLBACK_REASON_PRE = 0,
- POPT_CALLBACK_REASON_POST = 1,
- POPT_CALLBACK_REASON_OPTION = 2
-};
-/*@=exportconst@*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*@-type@*/
-
-/** \ingroup popt
- * Table callback prototype.
- * @param con context
- * @param reason reason for callback
- * @param opt option that triggered callback
- * @param arg @todo Document.
- * @param data @todo Document.
- */
-typedef void (*poptCallbackType) (poptContext con,
- enum poptCallbackReason reason,
- /*@null@*/ const struct poptOption * opt,
- /*@null@*/ const char * arg,
- /*@null@*/ const void * data)
- /*@*/;
-
-/** \ingroup popt
- * Initialize popt context.
- * @param name
- * @param argc no. of arguments
- * @param argv argument array
- * @param options address of popt option table
- * @param flags or'd POPT_CONTEXT_* bits
- * @return initialized popt context
- */
-/*@only@*/ /*@null@*/ poptContext poptGetContext(
- /*@dependent@*/ /*@keep@*/ const char * name,
- int argc, /*@dependent@*/ /*@keep@*/ const char ** argv,
- /*@dependent@*/ /*@keep@*/ const struct poptOption * options,
- int flags)
- /*@*/;
-
-/** \ingroup popt
- * Reinitialize popt context.
- * @param con context
- */
-/*@-exportlocal@*/
-void poptResetContext(/*@null@*/poptContext con)
- /*@modifies con @*/;
-/*@=exportlocal@*/
-
-/** \ingroup popt
- * Return value of next option found.
- * @param con context
- * @return next option val, -1 on last item, POPT_ERROR_* on error
- */
-int poptGetNextOpt(/*@null@*/poptContext con)
- /*@globals fileSystem, internalState @*/
- /*@modifies con, fileSystem, internalState @*/;
-
-/*@-redecl@*/
-/** \ingroup popt
- * Return next option argument (if any).
- * @param con context
- * @return option argument, NULL if no more options are available
- */
-/*@observer@*/ /*@null@*/ const char * poptGetOptArg(/*@null@*/poptContext con)
- /*@modifies con @*/;
-
-/** \ingroup popt
- * Return current option's argument.
- * @param con context
- * @return option argument, NULL if no more options are available
- */
-/*@observer@*/ /*@null@*/ const char * poptGetArg(/*@null@*/poptContext con)
- /*@modifies con @*/;
-
-/** \ingroup popt
- * Peek at current option's argument.
- * @param con context
- * @return option argument
- */
-/*@observer@*/ /*@null@*/ const char * poptPeekArg(/*@null@*/poptContext con)
- /*@*/;
-
-/** \ingroup popt
- * Return remaining arguments.
- * @param con context
- * @return argument array, terminated with NULL
- */
-/*@observer@*/ /*@null@*/ const char ** poptGetArgs(/*@null@*/poptContext con)
- /*@modifies con @*/;
-
-/** \ingroup popt
- * Return the option which caused the most recent error.
- * @param con context
- * @param flags
- * @return offending option
- */
-/*@observer@*/ const char * poptBadOption(/*@null@*/poptContext con, int flags)
- /*@*/;
-/*@=redecl@*/
-
-/** \ingroup popt
- * Destroy context.
- * @param con context
- * @return NULL always
- */
-/*@null@*/ poptContext poptFreeContext( /*@only@*/ /*@null@*/ poptContext con)
- /*@modifies con @*/;
-
-/** \ingroup popt
- * Add arguments to context.
- * @param con context
- * @param argv argument array, NULL terminated
- * @return 0 on success, POPT_ERROR_OPTSTOODEEP on failure
- */
-int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv)
- /*@modifies con @*/;
-
-/** \ingroup popt
- * Add alias to context.
- * @todo Pass alias by reference, not value.
- * @deprecated Use poptAddItem instead.
- * @param con context
- * @param alias alias to add
- * @param flags (unused)
- * @return 0 on success
- */
-/*@unused@*/
-int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
- /*@modifies con @*/;
-
-/** \ingroup popt
- * Add alias/exec item to context.
- * @param con context
- * @param newItem alias/exec item to add
- * @param flags 0 for alias, 1 for exec
- * @return 0 on success
- */
-int poptAddItem(poptContext con, poptItem newItem, int flags)
- /*@modifies con @*/;
-
-/** \ingroup popt
- * Read configuration file.
- * @param con context
- * @param fn file name to read
- * @return 0 on success, POPT_ERROR_ERRNO on failure
- */
-int poptReadConfigFile(poptContext con, const char * fn)
- /*@globals fileSystem, internalState @*/
- /*@modifies con->execs, con->numExecs,
- fileSystem, internalState @*/;
-
-/** \ingroup popt
- * Read default configuration from /etc/popt and $HOME/.popt.
- * @param con context
- * @param useEnv (unused)
- * @return 0 on success, POPT_ERROR_ERRNO on failure
- */
-int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv)
- /*@globals fileSystem, internalState @*/
- /*@modifies con->execs, con->numExecs,
- fileSystem, internalState @*/;
-
-/** \ingroup popt
- * Duplicate an argument array.
- * @note: The argument array is malloc'd as a single area, so only argv must
- * be free'd.
- *
- * @param argc no. of arguments
- * @param argv argument array
- * @retval argcPtr address of returned no. of arguments
- * @retval argvPtr address of returned argument array
- * @return 0 on success, POPT_ERROR_NOARG on failure
- */
-int poptDupArgv(int argc, /*@null@*/ const char **argv,
- /*@null@*/ /*@out@*/ int * argcPtr,
- /*@null@*/ /*@out@*/ const char *** argvPtr)
- /*@modifies *argcPtr, *argvPtr @*/;
-
-/** \ingroup popt
- * Parse a string into an argument array.
- * The parse allows ', ", and \ quoting, but ' is treated the same as " and
- * both may include \ quotes.
- * @note: The argument array is malloc'd as a single area, so only argv must
- * be free'd.
- *
- * @param s string to parse
- * @retval argcPtr address of returned no. of arguments
- * @retval argvPtr address of returned argument array
- */
-int poptParseArgvString(const char * s,
- /*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr)
- /*@modifies *argcPtr, *argvPtr @*/;
-
-/** \ingroup popt
- * Parses an input configuration file and returns an string that is a
- * command line. For use with popt. You must free the return value when done.
- *
- * Given the file:
-\verbatim
-# this line is ignored
- # this one too
-aaa
- bbb
- ccc
-bla=bla
-
-this_is = fdsafdas
- bad_line=
- reall bad line
- reall bad line = again
-5555= 55555
- test = with lots of spaces
-\endverbatim
-*
-* The result is:
-\verbatim
---aaa --bbb --ccc --bla="bla" --this_is="fdsafdas" --5555="55555" --test="with lots of spaces"
-\endverbatim
-*
-* Passing this to poptParseArgvString() yields an argv of:
-\verbatim
-'--aaa'
-'--bbb'
-'--ccc'
-'--bla=bla'
-'--this_is=fdsafdas'
-'--5555=55555'
-'--test=with lots of spaces'
-\endverbatim
- *
- * @bug NULL is returned if file line is too long.
- * @bug Silently ignores invalid lines.
- *
- * @param fp file handle to read
- * @param *argstrp return string of options (malloc'd)
- * @param flags unused
- * @return 0 on success
- * @see poptParseArgvString
- */
-/*@-fcnuse@*/
-int poptConfigFileToString(FILE *fp, /*@out@*/ char ** argstrp, int flags)
- /*@globals fileSystem @*/
- /*@modifies *fp, *argstrp, fileSystem @*/;
-/*@=fcnuse@*/
-
-/** \ingroup popt
- * Return formatted error string for popt failure.
- * @param error popt error
- * @return error string
- */
-/*@-redecl@*/
-/*@observer@*/ const char *poptStrerror(const int error)
- /*@*/;
-/*@=redecl@*/
-
-/** \ingroup popt
- * Limit search for executables.
- * @param con context
- * @param path single path to search for executables
- * @param allowAbsolute absolute paths only?
- */
-void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
- /*@modifies con @*/;
-
-/** \ingroup popt
- * Print detailed description of options.
- * @param con context
- * @param fp ouput file handle
- * @param flags (unused)
- */
-void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ int flags)
- /*@globals fileSystem @*/
- /*@modifies *fp, fileSystem @*/;
-
-/** \ingroup popt
- * Print terse description of options.
- * @param con context
- * @param fp ouput file handle
- * @param flags (unused)
- */
-void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags)
- /*@globals fileSystem @*/
- /*@modifies *fp, fileSystem @*/;
-
-/** \ingroup popt
- * Provide text to replace default "[OPTION...]" in help/usage output.
- * @param con context
- * @param text replacement text
- */
-/*@-fcnuse@*/
-void poptSetOtherOptionHelp(poptContext con, const char * text)
- /*@modifies con @*/;
-/*@=fcnuse@*/
-
-/** \ingroup popt
- * Return argv[0] from context.
- * @param con context
- * @return argv[0]
- */
-/*@-redecl -fcnuse@*/
-/*@observer@*/ const char * poptGetInvocationName(poptContext con)
- /*@*/;
-/*@=redecl =fcnuse@*/
-
-/** \ingroup popt
- * Shuffle argv pointers to remove stripped args, returns new argc.
- * @param con context
- * @param argc no. of args
- * @param argv arg vector
- * @return new argc
- */
-/*@-fcnuse@*/
-int poptStrippedArgv(poptContext con, int argc, char ** argv)
- /*@modifies *argv @*/;
-/*@=fcnuse@*/
-
-/**
- * Save a long, performing logical operation with value.
- * @warning Alignment check may be too strict on certain platorms.
- * @param arg integer pointer, aligned on int boundary.
- * @param argInfo logical operation (see POPT_ARGFLAG_*)
- * @param aLong value to use
- * @return 0 on success, POPT_ERROR_NULLARG/POPT_ERROR_BADOPERATION
- */
-/*@-incondefs@*/
-int poptSaveLong(/*@null@*/ long * arg, int argInfo, long aLong)
- /*@modifies *arg @*/
- /*@requires maxSet(arg) >= 0 /\ maxRead(arg) == 0 @*/;
-/*@=incondefs@*/
-
-/**
- * Save an integer, performing logical operation with value.
- * @warning Alignment check may be too strict on certain platorms.
- * @param arg integer pointer, aligned on int boundary.
- * @param argInfo logical operation (see POPT_ARGFLAG_*)
- * @param aLong value to use
- * @return 0 on success, POPT_ERROR_NULLARG/POPT_ERROR_BADOPERATION
- */
-/*@-incondefs@*/
-int poptSaveInt(/*@null@*/ int * arg, int argInfo, long aLong)
- /*@modifies *arg @*/
- /*@requires maxSet(arg) >= 0 /\ maxRead(arg) == 0 @*/;
-/*@=incondefs@*/
-
-/*@=type@*/
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/source4/lib/popt/poptconfig.c b/source4/lib/popt/poptconfig.c
deleted file mode 100644
index a600a92905..0000000000
--- a/source4/lib/popt/poptconfig.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/** \ingroup popt
- * \file popt/poptconfig.c
- */
-
-/* (C) 1998-2002 Red Hat, Inc. -- Licensing details are in the COPYING
- file accompanying popt source distributions, available from
- ftp://ftp.rpm.org/pub/rpm/dist. */
-
-#include "system.h"
-#include "poptint.h"
-
-/*@-compmempass@*/ /* FIX: item->option.longName kept, not dependent. */
-static void configLine(poptContext con, char * line)
- /*@modifies con @*/
-{
- /*@-type@*/
- int nameLength = strlen(con->appName);
- /*@=type@*/
- const char * entryType;
- const char * opt;
- poptItem item = alloca(sizeof(*item));
- int i, j;
-
-/*@-boundswrite@*/
- memset(item, 0, sizeof(*item));
-
- /*@-type@*/
- if (strncmp(line, con->appName, nameLength)) return;
- /*@=type@*/
-
- line += nameLength;
- if (*line == '\0' || !isspace(*line)) return;
-
- while (*line != '\0' && isspace(*line)) line++;
- entryType = line;
- while (*line == '\0' || !isspace(*line)) line++;
- *line++ = '\0';
-
- while (*line != '\0' && isspace(*line)) line++;
- if (*line == '\0') return;
- opt = line;
- while (*line == '\0' || !isspace(*line)) line++;
- *line++ = '\0';
-
- while (*line != '\0' && isspace(*line)) line++;
- if (*line == '\0') return;
-
- /*@-temptrans@*/ /* FIX: line alias is saved */
- if (opt[0] == '-' && opt[1] == '-')
- item->option.longName = opt + 2;
- else if (opt[0] == '-' && opt[2] == '\0')
- item->option.shortName = opt[1];
- /*@=temptrans@*/
-
- if (poptParseArgvString(line, &item->argc, &item->argv)) return;
-
- /*@-modobserver@*/
- item->option.argInfo = POPT_ARGFLAG_DOC_HIDDEN;
- for (i = 0, j = 0; i < item->argc; i++, j++) {
- const char * f;
- if (!strncmp(item->argv[i], "--POPTdesc=", sizeof("--POPTdesc=")-1)) {
- f = item->argv[i] + sizeof("--POPTdesc=");
- if (f[0] == '$' && f[1] == '"') f++;
- item->option.descrip = f;
- item->option.argInfo &= ~POPT_ARGFLAG_DOC_HIDDEN;
- j--;
- } else
- if (!strncmp(item->argv[i], "--POPTargs=", sizeof("--POPTargs=")-1)) {
- f = item->argv[i] + sizeof("--POPTargs=");
- if (f[0] == '$' && f[1] == '"') f++;
- item->option.argDescrip = f;
- item->option.argInfo &= ~POPT_ARGFLAG_DOC_HIDDEN;
- item->option.argInfo |= POPT_ARG_STRING;
- j--;
- } else
- if (j != i)
- item->argv[j] = item->argv[i];
- }
- if (j != i) {
- item->argv[j] = NULL;
- item->argc = j;
- }
- /*@=modobserver@*/
-/*@=boundswrite@*/
-
- /*@-nullstate@*/ /* FIX: item->argv[] may be NULL */
- if (!strcmp(entryType, "alias"))
- (void) poptAddItem(con, item, 0);
- else if (!strcmp(entryType, "exec"))
- (void) poptAddItem(con, item, 1);
- /*@=nullstate@*/
-}
-/*@=compmempass@*/
-
-int poptReadConfigFile(poptContext con, const char * fn)
-{
- const char * file, * chptr, * end;
- char * buf;
-/*@dependent@*/ char * dst;
- int fd, rc;
- off_t fileLength;
-
- fd = open(fn, O_RDONLY);
- if (fd < 0)
- return (errno == ENOENT ? 0 : POPT_ERROR_ERRNO);
-
- fileLength = lseek(fd, 0, SEEK_END);
- if (fileLength == -1 || lseek(fd, 0, 0) == -1) {
- rc = errno;
- (void) close(fd);
- /*@-mods@*/
- errno = rc;
- /*@=mods@*/
- return POPT_ERROR_ERRNO;
- }
-
- file = alloca(fileLength + 1);
- if (read(fd, (char *)file, fileLength) != fileLength) {
- rc = errno;
- (void) close(fd);
- /*@-mods@*/
- errno = rc;
- /*@=mods@*/
- return POPT_ERROR_ERRNO;
- }
- if (close(fd) == -1)
- return POPT_ERROR_ERRNO;
-
-/*@-boundswrite@*/
- dst = buf = alloca(fileLength + 1);
-
- chptr = file;
- end = (file + fileLength);
- /*@-infloops@*/ /* LCL: can't detect chptr++ */
- while (chptr < end) {
- switch (*chptr) {
- case '\n':
- *dst = '\0';
- dst = buf;
- while (*dst && isspace(*dst)) dst++;
- if (*dst && *dst != '#')
- configLine(con, dst);
- chptr++;
- /*@switchbreak@*/ break;
- case '\\':
- *dst++ = *chptr++;
- if (chptr < end) {
- if (*chptr == '\n')
- dst--, chptr++;
- /* \ at the end of a line does not insert a \n */
- else
- *dst++ = *chptr++;
- }
- /*@switchbreak@*/ break;
- default:
- *dst++ = *chptr++;
- /*@switchbreak@*/ break;
- }
- }
- /*@=infloops@*/
-/*@=boundswrite@*/
-
- return 0;
-}
-
-int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv)
-{
- char * fn, * home;
- int rc;
-
- /*@-type@*/
- if (!con->appName) return 0;
- /*@=type@*/
-
- rc = poptReadConfigFile(con, "/etc/popt");
- if (rc) return rc;
-#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
- if (getuid() != geteuid()) return 0;
-#endif
-
- if ((home = getenv("HOME"))) {
- fn = alloca(strlen(home) + 20);
- strcpy(fn, home);
- strcat(fn, "/.popt");
- rc = poptReadConfigFile(con, fn);
- if (rc) return rc;
- }
-
- return 0;
-}
diff --git a/source4/lib/popt/popthelp.c b/source4/lib/popt/popthelp.c
deleted file mode 100644
index 7ae3de7fb5..0000000000
--- a/source4/lib/popt/popthelp.c
+++ /dev/null
@@ -1,742 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*@-type@*/
-/** \ingroup popt
- * \file popt/popthelp.c
- */
-
-/* (C) 1998-2002 Red Hat, Inc. -- Licensing details are in the COPYING
- file accompanying popt source distributions, available from
- ftp://ftp.rpm.org/pub/rpm/dist. */
-
-#include "system.h"
-#include "poptint.h"
-
-/**
- * Display arguments.
- * @param con context
- * @param foo (unused)
- * @param key option(s)
- * @param arg (unused)
- * @param data (unused)
- */
-static void displayArgs(poptContext con,
- /*@unused@*/ enum poptCallbackReason foo,
- struct poptOption * key,
- /*@unused@*/ const char * arg, /*@unused@*/ void * data)
- /*@globals fileSystem@*/
- /*@modifies fileSystem@*/
-{
- if (key->shortName == '?')
- poptPrintHelp(con, stdout, 0);
- else
- poptPrintUsage(con, stdout, 0);
- exit(0);
-}
-
-#ifdef NOTYET
-/*@unchecked@*/
-static int show_option_defaults = 0;
-#endif
-
-/**
- * Empty table marker to enable displaying popt alias/exec options.
- */
-/*@observer@*/ /*@unchecked@*/
-struct poptOption poptAliasOptions[] = {
- POPT_TABLEEND
-};
-
-/**
- * Auto help table options.
- */
-/*@-castfcnptr@*/
-/*@observer@*/ /*@unchecked@*/
-struct poptOption poptHelpOptions[] = {
- { NULL, '\0', POPT_ARG_CALLBACK, (void *)&displayArgs, '\0', NULL, NULL },
- { "help", '?', 0, NULL, '?', N_("Show this help message"), NULL },
- { "usage", '\0', 0, NULL, 'u', N_("Display brief usage message"), NULL },
-#ifdef NOTYET
- { "defaults", '\0', POPT_ARG_NONE, &show_option_defaults, 0,
- N_("Display option defaults in message"), NULL },
-#endif
- POPT_TABLEEND
-} ;
-/*@=castfcnptr@*/
-
-/**
- * @param table option(s)
- */
-/*@observer@*/ /*@null@*/ static const char *const
-getTableTranslationDomain(/*@null@*/ const struct poptOption *table)
- /*@*/
-{
- const struct poptOption *opt;
-
- if (table != NULL)
- for (opt = table; opt->longName || opt->shortName || opt->arg; opt++) {
- if (opt->argInfo == POPT_ARG_INTL_DOMAIN)
- return opt->arg;
- }
- return NULL;
-}
-
-/**
- * @param opt option(s)
- * @param translation_domain translation domain
- */
-/*@observer@*/ /*@null@*/ static const char *const
-getArgDescrip(const struct poptOption * opt,
- /*@-paramuse@*/ /* FIX: i18n macros disabled with lclint */
- /*@null@*/ const char * translation_domain)
- /*@=paramuse@*/
- /*@*/
-{
- if (!(opt->argInfo & POPT_ARG_MASK)) return NULL;
-
- if (opt == (poptHelpOptions + 1) || opt == (poptHelpOptions + 2))
- if (opt->argDescrip) return POPT_(opt->argDescrip);
-
- if (opt->argDescrip) return D_(translation_domain, opt->argDescrip);
-
- switch (opt->argInfo & POPT_ARG_MASK) {
- case POPT_ARG_NONE: return POPT_("NONE");
-#ifdef DYING
- case POPT_ARG_VAL: return POPT_("VAL");
-#else
- case POPT_ARG_VAL: return NULL;
-#endif
- case POPT_ARG_INT: return POPT_("INT");
- case POPT_ARG_LONG: return POPT_("LONG");
- case POPT_ARG_STRING: return POPT_("STRING");
- case POPT_ARG_FLOAT: return POPT_("FLOAT");
- case POPT_ARG_DOUBLE: return POPT_("DOUBLE");
- default: return POPT_("ARG");
- }
-}
-
-/**
- * Display default value for an option.
- * @param lineLength
- * @param opt option(s)
- * @param translation_domain translation domain
- * @return
- */
-static /*@only@*/ /*@null@*/ char *
-singleOptionDefaultValue(int lineLength,
- const struct poptOption * opt,
- /*@-paramuse@*/ /* FIX: i18n macros disabled with lclint */
- /*@null@*/ const char * translation_domain)
- /*@=paramuse@*/
- /*@*/
-{
- const char * defstr = D_(translation_domain, "default");
- char * le = malloc(4*lineLength + 1);
- char * l = le;
-
- if (le == NULL) return NULL; /* XXX can't happen */
-/*@-boundswrite@*/
- *le = '\0';
- *le++ = '(';
- strcpy(le, defstr); le += strlen(le);
- *le++ = ':';
- *le++ = ' ';
- if (opt->arg) /* XXX programmer error */
- switch (opt->argInfo & POPT_ARG_MASK) {
- case POPT_ARG_VAL:
- case POPT_ARG_INT:
- { long aLong = *((int *)opt->arg);
- le += sprintf(le, "%ld", aLong);
- } break;
- case POPT_ARG_LONG:
- { long aLong = *((long *)opt->arg);
- le += sprintf(le, "%ld", aLong);
- } break;
- case POPT_ARG_FLOAT:
- { double aDouble = *((float *)opt->arg);
- le += sprintf(le, "%g", aDouble);
- } break;
- case POPT_ARG_DOUBLE:
- { double aDouble = *((double *)opt->arg);
- le += sprintf(le, "%g", aDouble);
- } break;
- case POPT_ARG_STRING:
- { const char * s = *(const char **)opt->arg;
- if (s == NULL) {
- strcpy(le, "null"); le += strlen(le);
- } else {
- size_t slen = 4*lineLength - (le - l) - sizeof("\"...\")");
- *le++ = '"';
- strncpy(le, s, slen); le[slen] = '\0'; le += strlen(le);
- if (slen < strlen(s)) {
- strcpy(le, "..."); le += strlen(le);
- }
- *le++ = '"';
- }
- } break;
- case POPT_ARG_NONE:
- default:
- l = _free(l);
- return NULL;
- /*@notreached@*/ break;
- }
- *le++ = ')';
- *le = '\0';
-/*@=boundswrite@*/
-
- return l;
-}
-
-/**
- * Display help text for an option.
- * @param fp output file handle
- * @param maxLeftCol
- * @param opt option(s)
- * @param translation_domain translation domain
- */
-static void singleOptionHelp(FILE * fp, int maxLeftCol,
- const struct poptOption * opt,
- /*@null@*/ const char * translation_domain)
- /*@globals fileSystem @*/
- /*@modifies *fp, fileSystem @*/
-{
- int indentLength = maxLeftCol + 5;
- int lineLength = 79 - indentLength;
- const char * help = D_(translation_domain, opt->descrip);
- const char * argDescrip = getArgDescrip(opt, translation_domain);
- int helpLength;
- char * defs = NULL;
- char * left;
- int nb = maxLeftCol + 1;
-
- /* Make sure there's more than enough room in target buffer. */
- if (opt->longName) nb += strlen(opt->longName);
- if (argDescrip) nb += strlen(argDescrip);
-
-/*@-boundswrite@*/
- left = malloc(nb);
- if (left == NULL) return; /* XXX can't happen */
- left[0] = '\0';
- left[maxLeftCol] = '\0';
-
- if (opt->longName && opt->shortName)
- sprintf(left, "-%c, %s%s", opt->shortName,
- ((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "-" : "--"),
- opt->longName);
- else if (opt->shortName != '\0')
- sprintf(left, "-%c", opt->shortName);
- else if (opt->longName)
- sprintf(left, "%s%s",
- ((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "-" : "--"),
- opt->longName);
- if (!*left) goto out;
-
- if (argDescrip) {
- char * le = left + strlen(left);
-
- if (opt->argInfo & POPT_ARGFLAG_OPTIONAL)
- *le++ = '[';
-
- /* Choose type of output */
- /*@-branchstate@*/
- if (opt->argInfo & POPT_ARGFLAG_SHOW_DEFAULT) {
- defs = singleOptionDefaultValue(lineLength, opt, translation_domain);
- if (defs) {
- char * t = malloc((help ? strlen(help) : 0) +
- strlen(defs) + sizeof(" "));
- if (t) {
- char * te = t;
- *te = '\0';
- if (help) {
- strcpy(te, help); te += strlen(te);
- }
- *te++ = ' ';
- strcpy(te, defs);
- defs = _free(defs);
- }
- defs = t;
- }
- }
- /*@=branchstate@*/
-
- if (opt->argDescrip == NULL) {
- switch (opt->argInfo & POPT_ARG_MASK) {
- case POPT_ARG_NONE:
- break;
- case POPT_ARG_VAL:
-#ifdef NOTNOW /* XXX pug ugly nerdy output */
- { long aLong = opt->val;
- int ops = (opt->argInfo & POPT_ARGFLAG_LOGICALOPS);
- int negate = (opt->argInfo & POPT_ARGFLAG_NOT);
-
- /* Don't bother displaying typical values */
- if (!ops && (aLong == 0L || aLong == 1L || aLong == -1L))
- break;
- *le++ = '[';
- switch (ops) {
- case POPT_ARGFLAG_OR:
- *le++ = '|';
- /*@innerbreak@*/ break;
- case POPT_ARGFLAG_AND:
- *le++ = '&';
- /*@innerbreak@*/ break;
- case POPT_ARGFLAG_XOR:
- *le++ = '^';
- /*@innerbreak@*/ break;
- default:
- /*@innerbreak@*/ break;
- }
- *le++ = '=';
- if (negate) *le++ = '~';
- /*@-formatconst@*/
- le += sprintf(le, (ops ? "0x%lx" : "%ld"), aLong);
- /*@=formatconst@*/
- *le++ = ']';
- }
-#endif
- break;
- case POPT_ARG_INT:
- case POPT_ARG_LONG:
- case POPT_ARG_FLOAT:
- case POPT_ARG_DOUBLE:
- case POPT_ARG_STRING:
- *le++ = '=';
- strcpy(le, argDescrip); le += strlen(le);
- break;
- default:
- break;
- }
- } else {
- *le++ = '=';
- strcpy(le, argDescrip); le += strlen(le);
- }
- if (opt->argInfo & POPT_ARGFLAG_OPTIONAL)
- *le++ = ']';
- *le = '\0';
- }
-/*@=boundswrite@*/
-
- if (help)
- fprintf(fp," %-*s ", maxLeftCol, left);
- else {
- fprintf(fp," %s\n", left);
- goto out;
- }
-
- left = _free(left);
- if (defs) {
- help = defs; defs = NULL;
- }
-
- helpLength = strlen(help);
-/*@-boundsread@*/
- while (helpLength > lineLength) {
- const char * ch;
- char format[16];
-
- ch = help + lineLength - 1;
- while (ch > help && !isspace(*ch)) ch--;
- if (ch == help) break; /* give up */
- while (ch > (help + 1) && isspace(*ch)) ch--;
- ch++;
-
- sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength);
- /*@-formatconst@*/
- fprintf(fp, format, help, " ");
- /*@=formatconst@*/
- help = ch;
- while (isspace(*help) && *help) help++;
- helpLength = strlen(help);
- }
-/*@=boundsread@*/
-
- if (helpLength) fprintf(fp, "%s\n", help);
-
-out:
- /*@-dependenttrans@*/
- defs = _free(defs);
- /*@=dependenttrans@*/
- left = _free(left);
-}
-
-/**
- * @param opt option(s)
- * @param translation_domain translation domain
- */
-static int maxArgWidth(const struct poptOption * opt,
- /*@null@*/ const char * translation_domain)
- /*@*/
-{
- int max = 0;
- int len = 0;
- const char * s;
-
- if (opt != NULL)
- while (opt->longName || opt->shortName || opt->arg) {
- if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
- if (opt->arg) /* XXX program error */
- len = maxArgWidth(opt->arg, translation_domain);
- if (len > max) max = len;
- } else if (!(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) {
- len = sizeof(" ")-1;
- if (opt->shortName != '\0') len += sizeof("-X")-1;
- if (opt->shortName != '\0' && opt->longName) len += sizeof(", ")-1;
- if (opt->longName) {
- len += ((opt->argInfo & POPT_ARGFLAG_ONEDASH)
- ? sizeof("-")-1 : sizeof("--")-1);
- len += strlen(opt->longName);
- }
-
- s = getArgDescrip(opt, translation_domain);
- if (s)
- len += sizeof("=")-1 + strlen(s);
- if (opt->argInfo & POPT_ARGFLAG_OPTIONAL) len += sizeof("[]")-1;
- if (len > max) max = len;
- }
-
- opt++;
- }
-
- return max;
-}
-
-/**
- * Display popt alias and exec help.
- * @param fp output file handle
- * @param items alias/exec array
- * @param nitems no. of alias/exec entries
- * @param left
- * @param translation_domain translation domain
- */
-static void itemHelp(FILE * fp,
- /*@null@*/ poptItem items, int nitems, int left,
- /*@null@*/ const char * translation_domain)
- /*@globals fileSystem @*/
- /*@modifies *fp, fileSystem @*/
-{
- poptItem item;
- int i;
-
- if (items != NULL)
- for (i = 0, item = items; i < nitems; i++, item++) {
- const struct poptOption * opt;
- opt = &item->option;
- if ((opt->longName || opt->shortName) &&
- !(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN))
- singleOptionHelp(fp, left, opt, translation_domain);
- }
-}
-
-/**
- * Display help text for a table of options.
- * @param con context
- * @param fp output file handle
- * @param table option(s)
- * @param left
- * @param translation_domain translation domain
- */
-static void singleTableHelp(poptContext con, FILE * fp,
- /*@null@*/ const struct poptOption * table, int left,
- /*@null@*/ const char * translation_domain)
- /*@globals fileSystem @*/
- /*@modifies *fp, fileSystem @*/
-{
- const struct poptOption * opt;
- const char *sub_transdom;
-
- if (table == poptAliasOptions) {
- itemHelp(fp, con->aliases, con->numAliases, left, NULL);
- itemHelp(fp, con->execs, con->numExecs, left, NULL);
- return;
- }
-
- if (table != NULL)
- for (opt = table; (opt->longName || opt->shortName || opt->arg); opt++) {
- if ((opt->longName || opt->shortName) &&
- !(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN))
- singleOptionHelp(fp, left, opt, translation_domain);
- }
-
- if (table != NULL)
- for (opt = table; (opt->longName || opt->shortName || opt->arg); opt++) {
- if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_INCLUDE_TABLE)
- continue;
- sub_transdom = getTableTranslationDomain(opt->arg);
- if (sub_transdom == NULL)
- sub_transdom = translation_domain;
-
- if (opt->descrip)
- fprintf(fp, "\n%s\n", D_(sub_transdom, opt->descrip));
-
- singleTableHelp(con, fp, opt->arg, left, sub_transdom);
- }
-}
-
-/**
- * @param con context
- * @param fp output file handle
- */
-static int showHelpIntro(poptContext con, FILE * fp)
- /*@globals fileSystem @*/
- /*@modifies *fp, fileSystem @*/
-{
- int len = 6;
- const char * fn;
-
- fprintf(fp, POPT_("Usage:"));
- if (!(con->flags & POPT_CONTEXT_KEEP_FIRST)) {
-/*@-boundsread@*/
- /*@-nullderef@*/ /* LCL: wazzup? */
- fn = con->optionStack->argv[0];
- /*@=nullderef@*/
-/*@=boundsread@*/
- if (fn == NULL) return len;
- if (strchr(fn, '/')) fn = strrchr(fn, '/') + 1;
- fprintf(fp, " %s", fn);
- len += strlen(fn) + 1;
- }
-
- return len;
-}
-
-void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ int flags)
-{
- int leftColWidth;
-
- (void) showHelpIntro(con, fp);
- if (con->otherHelp)
- fprintf(fp, " %s\n", con->otherHelp);
- else
- fprintf(fp, " %s\n", POPT_("[OPTION...]"));
-
- leftColWidth = maxArgWidth(con->options, NULL);
- singleTableHelp(con, fp, con->options, leftColWidth, NULL);
-}
-
-/**
- * @param fp output file handle
- * @param cursor
- * @param opt option(s)
- * @param translation_domain translation domain
- */
-static int singleOptionUsage(FILE * fp, int cursor,
- const struct poptOption * opt,
- /*@null@*/ const char *translation_domain)
- /*@globals fileSystem @*/
- /*@modifies *fp, fileSystem @*/
-{
- int len = 4;
- char shortStr[2] = { '\0', '\0' };
- const char * item = shortStr;
- const char * argDescrip = getArgDescrip(opt, translation_domain);
-
- if (opt->shortName != '\0' && opt->longName != NULL) {
- len += 2;
- if (!(opt->argInfo & POPT_ARGFLAG_ONEDASH)) len++;
- len += strlen(opt->longName);
- } else if (opt->shortName != '\0') {
- len++;
- shortStr[0] = opt->shortName;
- shortStr[1] = '\0';
- } else if (opt->longName) {
- len += strlen(opt->longName);
- if (!(opt->argInfo & POPT_ARGFLAG_ONEDASH)) len++;
- item = opt->longName;
- }
-
- if (len == 4) return cursor;
-
- if (argDescrip)
- len += strlen(argDescrip) + 1;
-
- if ((cursor + len) > 79) {
- fprintf(fp, "\n ");
- cursor = 7;
- }
-
- if (opt->longName && opt->shortName) {
- fprintf(fp, " [-%c|-%s%s%s%s]",
- opt->shortName, ((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "" : "-"),
- opt->longName,
- (argDescrip ? " " : ""),
- (argDescrip ? argDescrip : ""));
- } else {
- fprintf(fp, " [-%s%s%s%s]",
- ((opt->shortName || (opt->argInfo & POPT_ARGFLAG_ONEDASH)) ? "" : "-"),
- item,
- (argDescrip ? (opt->shortName != '\0' ? " " : "=") : ""),
- (argDescrip ? argDescrip : ""));
- }
-
- return cursor + len + 1;
-}
-
-/**
- * Display popt alias and exec usage.
- * @param fp output file handle
- * @param cursor
- * @param item alias/exec array
- * @param nitems no. of ara/exec entries
- * @param translation_domain translation domain
- */
-static int itemUsage(FILE * fp, int cursor, poptItem item, int nitems,
- /*@null@*/ const char * translation_domain)
- /*@globals fileSystem @*/
- /*@modifies *fp, fileSystem @*/
-{
- int i;
-
- /*@-branchstate@*/ /* FIX: W2DO? */
- if (item != NULL)
- for (i = 0; i < nitems; i++, item++) {
- const struct poptOption * opt;
- opt = &item->option;
- if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INTL_DOMAIN) {
- translation_domain = (const char *)opt->arg;
- } else if ((opt->longName || opt->shortName) &&
- !(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) {
- cursor = singleOptionUsage(fp, cursor, opt, translation_domain);
- }
- }
- /*@=branchstate@*/
-
- return cursor;
-}
-
-/**
- * Keep track of option tables already processed.
- */
-typedef struct poptDone_s {
- int nopts;
- int maxopts;
- const void ** opts;
-} * poptDone;
-
-/**
- * Display usage text for a table of options.
- * @param con context
- * @param fp output file handle
- * @param cursor
- * @param opt option(s)
- * @param translation_domain translation domain
- * @param done tables already processed
- * @return
- */
-static int singleTableUsage(poptContext con, FILE * fp, int cursor,
- /*@null@*/ const struct poptOption * opt,
- /*@null@*/ const char * translation_domain,
- /*@null@*/ poptDone done)
- /*@globals fileSystem @*/
- /*@modifies *fp, done, fileSystem @*/
-{
- /*@-branchstate@*/ /* FIX: W2DO? */
- if (opt != NULL)
- for (; (opt->longName || opt->shortName || opt->arg) ; opt++) {
- if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INTL_DOMAIN) {
- translation_domain = (const char *)opt->arg;
- } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
- if (done) {
- int i = 0;
- for (i = 0; i < done->nopts; i++) {
-/*@-boundsread@*/
- const void * that = done->opts[i];
-/*@=boundsread@*/
- if (that == NULL || that != opt->arg)
- /*@innercontinue@*/ continue;
- /*@innerbreak@*/ break;
- }
- /* Skip if this table has already been processed. */
- if (opt->arg == NULL || i < done->nopts)
- continue;
-/*@-boundswrite@*/
- if (done->nopts < done->maxopts)
- done->opts[done->nopts++] = (const void *) opt->arg;
-/*@=boundswrite@*/
- }
- cursor = singleTableUsage(con, fp, cursor, opt->arg,
- translation_domain, done);
- } else if ((opt->longName || opt->shortName) &&
- !(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) {
- cursor = singleOptionUsage(fp, cursor, opt, translation_domain);
- }
- }
- /*@=branchstate@*/
-
- return cursor;
-}
-
-/**
- * Return concatenated short options for display.
- * @todo Sub-tables should be recursed.
- * @param opt option(s)
- * @param fp output file handle
- * @retval str concatenation of short options
- * @return length of display string
- */
-static int showShortOptions(const struct poptOption * opt, FILE * fp,
- /*@null@*/ char * str)
- /*@globals fileSystem @*/
- /*@modifies *str, *fp, fileSystem @*/
-{
- char * s = alloca(300); /* larger than the ascii set */
-
- s[0] = '\0';
- /*@-branchstate@*/ /* FIX: W2DO? */
- if (str == NULL) {
- memset(s, 0, sizeof(s));
- str = s;
- }
- /*@=branchstate@*/
-
-/*@-boundswrite@*/
- if (opt != NULL)
- for (; (opt->longName || opt->shortName || opt->arg); opt++) {
- if (opt->shortName && !(opt->argInfo & POPT_ARG_MASK))
- str[strlen(str)] = opt->shortName;
- else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE)
- if (opt->arg) /* XXX program error */
- (void) showShortOptions(opt->arg, fp, str);
- }
-/*@=boundswrite@*/
-
- if (s != str || *s != '\0')
- return 0;
-
- fprintf(fp, " [-%s]", s);
- return strlen(s) + 4;
-}
-
-void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags)
-{
- poptDone done = memset(alloca(sizeof(*done)), 0, sizeof(*done));
- int cursor;
-
- done->nopts = 0;
- done->maxopts = 64;
- cursor = done->maxopts * sizeof(*done->opts);
-/*@-boundswrite@*/
- done->opts = memset(alloca(cursor), 0, cursor);
- done->opts[done->nopts++] = (const void *) con->options;
-/*@=boundswrite@*/
-
- cursor = showHelpIntro(con, fp);
- cursor += showShortOptions(con->options, fp, NULL);
- cursor = singleTableUsage(con, fp, cursor, con->options, NULL, done);
- cursor = itemUsage(fp, cursor, con->aliases, con->numAliases, NULL);
- cursor = itemUsage(fp, cursor, con->execs, con->numExecs, NULL);
-
- if (con->otherHelp) {
- cursor += strlen(con->otherHelp) + 1;
- if (cursor > 79) fprintf(fp, "\n ");
- fprintf(fp, " %s", con->otherHelp);
- }
-
- fprintf(fp, "\n");
-}
-
-void poptSetOtherOptionHelp(poptContext con, const char * text)
-{
- con->otherHelp = _free(con->otherHelp);
- con->otherHelp = xstrdup(text);
-}
-/*@=type@*/
diff --git a/source4/lib/popt/poptint.h b/source4/lib/popt/poptint.h
deleted file mode 100644
index 5d308efe96..0000000000
--- a/source4/lib/popt/poptint.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/** \ingroup popt
- * \file popt/poptint.h
- */
-
-/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
- file accompanying popt source distributions, available from
- ftp://ftp.rpm.org/pub/rpm/dist. */
-
-#ifndef H_POPTINT
-#define H_POPTINT
-
-/**
- * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
- * @param p memory to free
- * @retval NULL always
- */
-/*@unused@*/ static inline /*@null@*/ void *
-_free(/*@only@*/ /*@null@*/ const void * p)
- /*@modifies p @*/
-{
- if (p != NULL) free((void *)p);
- return NULL;
-}
-
-/* Bit mask macros. */
-/*@-exporttype -redef @*/
-typedef unsigned int __pbm_bits;
-/*@=exporttype =redef @*/
-#define __PBM_NBITS (8 * sizeof (__pbm_bits))
-#define __PBM_IX(d) ((d) / __PBM_NBITS)
-#define __PBM_MASK(d) ((__pbm_bits) 1 << (((unsigned)(d)) % __PBM_NBITS))
-/*@-exporttype -redef @*/
-typedef struct {
- __pbm_bits bits[1];
-} pbm_set;
-/*@=exporttype =redef @*/
-#define __PBM_BITS(set) ((set)->bits)
-
-#define PBM_ALLOC(d) calloc(__PBM_IX (d) + 1, sizeof(__pbm_bits))
-#define PBM_FREE(s) _free(s);
-#define PBM_SET(d, s) (__PBM_BITS (s)[__PBM_IX (d)] |= __PBM_MASK (d))
-#define PBM_CLR(d, s) (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d))
-#define PBM_ISSET(d, s) ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0)
-
-struct optionStackEntry {
- int argc;
-/*@only@*/ /*@null@*/
- const char ** argv;
-/*@only@*/ /*@null@*/
- pbm_set * argb;
- int next;
-/*@only@*/ /*@null@*/
- const char * nextArg;
-/*@observer@*/ /*@null@*/
- const char * nextCharArg;
-/*@dependent@*/ /*@null@*/
- poptItem currAlias;
- int stuffed;
-};
-
-struct poptContext_s {
- struct optionStackEntry optionStack[POPT_OPTION_DEPTH];
-/*@dependent@*/
- struct optionStackEntry * os;
-/*@owned@*/ /*@null@*/
- const char ** leftovers;
- int numLeftovers;
- int nextLeftover;
-/*@keep@*/
- const struct poptOption * options;
- int restLeftover;
-/*@only@*/ /*@null@*/
- const char * appName;
-/*@only@*/ /*@null@*/
- poptItem aliases;
- int numAliases;
- int flags;
-/*@owned@*/ /*@null@*/
- poptItem execs;
- int numExecs;
-/*@only@*/ /*@null@*/
- const char ** finalArgv;
- int finalArgvCount;
- int finalArgvAlloced;
-/*@dependent@*/ /*@null@*/
- poptItem doExec;
-/*@only@*/
- const char * execPath;
- int execAbsolute;
-/*@only@*/
- const char * otherHelp;
-/*@null@*/
- pbm_set * arg_strip;
-};
-
-#ifdef HAVE_LIBINTL_H
-#include <libintl.h>
-#endif
-
-#if defined(HAVE_GETTEXT) && !defined(__LCLINT__)
-#define _(foo) gettext(foo)
-#else
-#define _(foo) foo
-#endif
-
-#if defined(HAVE_DCGETTEXT) && !defined(__LCLINT__)
-#define D_(dom, str) dgettext(dom, str)
-#define POPT_(foo) D_("popt", foo)
-#else
-#define D_(dom, str) str
-#define POPT_(foo) foo
-#endif
-
-#define N_(foo) foo
-
-#endif
diff --git a/source4/lib/popt/poptparse.c b/source4/lib/popt/poptparse.c
deleted file mode 100644
index a0dea80041..0000000000
--- a/source4/lib/popt/poptparse.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/** \ingroup popt
- * \file popt/poptparse.c
- */
-
-/* (C) 1998-2002 Red Hat, Inc. -- Licensing details are in the COPYING
- file accompanying popt source distributions, available from
- ftp://ftp.rpm.org/pub/rpm/dist. */
-
-#include "system.h"
-
-#define POPT_ARGV_ARRAY_GROW_DELTA 5
-
-/*@-boundswrite@*/
-int poptDupArgv(int argc, const char **argv,
- int * argcPtr, const char *** argvPtr)
-{
- size_t nb = (argc + 1) * sizeof(*argv);
- const char ** argv2;
- char * dst;
- int i;
-
- if (argc <= 0 || argv == NULL) /* XXX can't happen */
- return POPT_ERROR_NOARG;
- for (i = 0; i < argc; i++) {
- if (argv[i] == NULL)
- return POPT_ERROR_NOARG;
- nb += strlen(argv[i]) + 1;
- }
-
- dst = malloc(nb);
- if (dst == NULL) /* XXX can't happen */
- return POPT_ERROR_MALLOC;
- argv2 = (void *) dst;
- dst += (argc + 1) * sizeof(*argv);
-
- /*@-branchstate@*/
- for (i = 0; i < argc; i++) {
- argv2[i] = dst;
- dst += strlen(strcpy(dst, argv[i])) + 1;
- }
- /*@=branchstate@*/
- argv2[argc] = NULL;
-
- if (argvPtr) {
- *argvPtr = argv2;
- } else {
- free(argv2);
- argv2 = NULL;
- }
- if (argcPtr)
- *argcPtr = argc;
- return 0;
-}
-/*@=boundswrite@*/
-
-/*@-bounds@*/
-int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
-{
- const char * src;
- char quote = '\0';
- int argvAlloced = POPT_ARGV_ARRAY_GROW_DELTA;
- const char ** argv = malloc(sizeof(*argv) * argvAlloced);
- int argc = 0;
- int buflen = strlen(s) + 1;
- char * buf = memset(alloca(buflen), 0, buflen);
- int rc = POPT_ERROR_MALLOC;
-
- if (argv == NULL) return rc;
- argv[argc] = buf;
-
- for (src = s; *src != '\0'; src++) {
- if (quote == *src) {
- quote = '\0';
- } else if (quote != '\0') {
- if (*src == '\\') {
- src++;
- if (!*src) {
- rc = POPT_ERROR_BADQUOTE;
- goto exit;
- }
- if (*src != quote) *buf++ = '\\';
- }
- *buf++ = *src;
- } else if (isspace(*src)) {
- if (*argv[argc] != '\0') {
- buf++, argc++;
- if (argc == argvAlloced) {
- argvAlloced += POPT_ARGV_ARRAY_GROW_DELTA;
- argv = realloc(argv, sizeof(*argv) * argvAlloced);
- if (argv == NULL) goto exit;
- }
- argv[argc] = buf;
- }
- } else switch (*src) {
- case '"':
- case '\'':
- quote = *src;
- /*@switchbreak@*/ break;
- case '\\':
- src++;
- if (!*src) {
- rc = POPT_ERROR_BADQUOTE;
- goto exit;
- }
- /*@fallthrough@*/
- default:
- *buf++ = *src;
- /*@switchbreak@*/ break;
- }
- }
-
- if (strlen(argv[argc])) {
- argc++, buf++;
- }
-
- rc = poptDupArgv(argc, argv, argcPtr, argvPtr);
-
-exit:
- if (argv) free(argv);
- return rc;
-}
-/*@=bounds@*/
-
-/* still in the dev stage.
- * return values, perhaps 1== file erro
- * 2== line to long
- * 3== umm.... more?
- */
-int poptConfigFileToString(FILE *fp, char ** argstrp, /*@unused@*/ int flags)
-{
- char line[999];
- char * argstr;
- char * p;
- char * q;
- char * x;
- int t;
- int argvlen = 0;
- size_t maxlinelen = sizeof(line);
- size_t linelen;
- int maxargvlen = 480;
- int linenum = 0;
-
- *argstrp = NULL;
-
- /* | this_is = our_line
- * p q x
- */
-
- if (fp == NULL)
- return POPT_ERROR_NULLARG;
-
- argstr = calloc(maxargvlen, sizeof(*argstr));
- if (argstr == NULL) return POPT_ERROR_MALLOC;
-
- while (fgets(line, (int)maxlinelen, fp) != NULL) {
- linenum++;
- p = line;
-
- /* loop until first non-space char or EOL */
- while( *p != '\0' && isspace(*p) )
- p++;
-
- linelen = strlen(p);
- if (linelen >= maxlinelen-1)
- return POPT_ERROR_OVERFLOW; /* XXX line too long */
-
- if (*p == '\0' || *p == '\n') continue; /* line is empty */
- if (*p == '#') continue; /* comment line */
-
- q = p;
-
- while (*q != '\0' && (!isspace(*q)) && *q != '=')
- q++;
-
- if (isspace(*q)) {
- /* a space after the name, find next non space */
- *q++='\0';
- while( *q != '\0' && isspace((int)*q) ) q++;
- }
- if (*q == '\0') {
- /* single command line option (ie, no name=val, just name) */
- q[-1] = '\0'; /* kill off newline from fgets() call */
- argvlen += (t = q - p) + (sizeof(" --")-1);
- if (argvlen >= maxargvlen) {
- maxargvlen = (t > maxargvlen) ? t*2 : maxargvlen*2;
- argstr = realloc(argstr, maxargvlen);
- if (argstr == NULL) return POPT_ERROR_MALLOC;
- }
- strcat(argstr, " --");
- strcat(argstr, p);
- continue;
- }
- if (*q != '=')
- continue; /* XXX for now, silently ignore bogus line */
-
- /* *q is an equal sign. */
- *q++ = '\0';
-
- /* find next non-space letter of value */
- while (*q != '\0' && isspace(*q))
- q++;
- if (*q == '\0')
- continue; /* XXX silently ignore missing value */
-
- /* now, loop and strip all ending whitespace */
- x = p + linelen;
- while (isspace(*--x))
- *x = 0; /* null out last char if space (including fgets() NL) */
-
- /* rest of line accept */
- t = x - p;
- argvlen += t + (sizeof("' --='")-1);
- if (argvlen >= maxargvlen) {
- maxargvlen = (t > maxargvlen) ? t*2 : maxargvlen*2;
- argstr = realloc(argstr, maxargvlen);
- if (argstr == NULL) return POPT_ERROR_MALLOC;
- }
- strcat(argstr, " --");
- strcat(argstr, p);
- strcat(argstr, "=\"");
- strcat(argstr, q);
- strcat(argstr, "\"");
- }
-
- *argstrp = argstr;
- return 0;
-}
diff --git a/source4/lib/popt/samba.m4 b/source4/lib/popt/samba.m4
deleted file mode 100644
index 855fd6c402..0000000000
--- a/source4/lib/popt/samba.m4
+++ /dev/null
@@ -1,8 +0,0 @@
-m4_include(lib/popt/libpopt.m4)
-
-if test x"$POPT_OBJ" = "x"; then
- SMB_EXT_LIB(LIBPOPT, [${POPT_LIBS}])
-else
- SMB_INCLUDE_MK(lib/popt/config.mk)
-fi
-
diff --git a/source4/lib/popt/system.h b/source4/lib/popt/system.h
deleted file mode 100644
index 000e23d484..0000000000
--- a/source4/lib/popt/system.h
+++ /dev/null
@@ -1,74 +0,0 @@
-#include "config.h"
-
-#if defined (__GLIBC__) && defined(__LCLINT__)
-/*@-declundef@*/
-/*@unchecked@*/
-extern __const __int32_t *__ctype_tolower;
-/*@unchecked@*/
-extern __const __int32_t *__ctype_toupper;
-/*@=declundef@*/
-#endif
-
-#include <ctype.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-
-#if HAVE_MCHECK_H
-#include <mcheck.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef __NeXT
-/* access macros are not declared in non posix mode in unistd.h -
- don't try to use posix on NeXTstep 3.3 ! */
-#include <libc.h>
-#endif
-
-#if defined(__LCLINT__)
-/*@-declundef -incondefs -redecl@*/ /* LCL: missing annotation */
-/*@only@*/ void * alloca (size_t __size)
- /*@ensures MaxSet(result) == (__size - 1) @*/
- /*@*/;
-/*@=declundef =incondefs =redecl@*/
-#endif
-
-/* AIX requires this to be the first thing in the file. */
-#ifndef __GNUC__
-# if HAVE_ALLOCA_H
-# include <alloca.h>
-# else
-# ifdef _AIX
-#pragma alloca
-# else
-# ifndef alloca /* predefined by HP cc +Olibcalls */
-char *alloca ();
-# endif
-# endif
-# endif
-#elif defined(__GNUC__) && defined(__STRICT_ANSI__)
-#define alloca __builtin_alloca
-#endif
-
-/*@-redecl -redef@*/
-/*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str)
- /*@*/;
-/*@=redecl =redef@*/
-
-#if HAVE_MCHECK_H && defined(__GNUC__)
-#define vmefail() (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL)
-#define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str)))
-#else
-#define xstrdup(_str) strdup(_str)
-#endif /* HAVE_MCHECK_H && defined(__GNUC__) */
-
-
-#include "popt.h"
diff --git a/source4/lib/replace/.checker_innocent b/source4/lib/replace/.checker_innocent
deleted file mode 100644
index e619176540..0000000000
--- a/source4/lib/replace/.checker_innocent
+++ /dev/null
@@ -1,4 +0,0 @@
->>>MISTAKE21_create_files_6a9e68ada99a97cb
->>>MISTAKE21_os2_delete_9b2bfa7f38711d09
->>>MISTAKE21_os2_delete_2fcc29aaa99a97cb
->>>SECURITY2_os2_delete_9b2bfa7f1c9396ca
diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in
deleted file mode 100644
index c989835a8d..0000000000
--- a/source4/lib/replace/Makefile.in
+++ /dev/null
@@ -1,63 +0,0 @@
-#!gmake
-#
-CC = @CC@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-bindir = @bindir@
-includedir = @includedir@
-libdir = @libdir@
-VPATH = @libreplacedir@
-srcdir = @srcdir@
-builddir = @builddir@
-INSTALL = @INSTALL@
-LIBS = @LIBS@
-
-.PHONY: test all showflags install installcheck clean distclean realdistclean
-
-CFLAGS=-I. @CFLAGS@
-LDFLAGS=@LDFLAGS@
-
-OBJS = @LIBREPLACEOBJ@
-
-all: showflags libreplace.a testsuite
-
-showflags:
- @echo 'libreplace will be compiled with flags:'
- @echo ' CC = $(CC)'
- @echo ' CFLAGS = $(CFLAGS)'
- @echo ' LDFLAGS= $(LDFLAGS)'
- @echo ' LIBS = $(LIBS)'
-
-install: all
- mkdir -p $(libdir)
- $(INSTALL) libreplace.a $(libdir)
-
-libreplace.a: $(OBJS)
- ar -rcsv $@ $(OBJS)
-
-test: all
- ./testsuite
-
-installcheck: install test
-
-TEST_OBJS = test/testsuite.o test/os2_delete.o test/strptime.o test/getifaddrs.o
-
-testsuite: libreplace.a $(TEST_OBJS)
- $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) $(LIBS)
-
-.c.o:
- @echo Compiling $*.c
- @mkdir -p `dirname $@`
- @$(CC) $(CFLAGS) -c $< -o $@
-
-clean:
- rm -f *.o test/*.o *.a testsuite
- rm -f testfile.dat
-
-distclean: clean
- rm -f *~ */*~
- rm -f config.log config.status config.h config.cache
- rm -f Makefile
-
-realdistclean: distclean
- rm -f configure config.h.in
diff --git a/source4/lib/replace/README b/source4/lib/replace/README
deleted file mode 100644
index 4d94317c4b..0000000000
--- a/source4/lib/replace/README
+++ /dev/null
@@ -1,113 +0,0 @@
-This subsystem ensures that we can always use a certain core set of
-functions and types, that are either provided by the OS or by replacement
-functions / definitions in this subsystem. The aim is to try to stick
-to POSIX functions in here as much as possible. Convenience functions
-that are available on no platform at all belong in other subsystems
-(such as LIBUTIL).
-
-The following functions are guaranteed:
-
-ftruncate
-strlcpy
-strlcat
-mktime
-rename
-initgroups
-memmove
-strdup
-setlinebuf
-vsyslog
-timegm
-setenv
-unsetenv
-strndup
-strnlen
-waitpid
-seteuid
-setegid
-asprintf
-snprintf
-vasprintf
-vsnprintf
-opendir
-readdir
-telldir
-seekdir
-closedir
-dlopen
-dlclose
-dlsym
-dlerror
-chroot
-bzero
-strerror
-errno
-mkdtemp
-mkstemp (a secure one!)
-pread
-pwrite
-getpass
-readline (the library)
-inet_ntoa
-inet_ntop
-inet_pton
-inet_aton
-strtoll
-strtoull
-socketpair
-strptime
-getaddrinfo
-freeaddrinfo
-getnameinfo
-gai_strerror
-getifaddrs
-freeifaddrs
-utime
-utimes
-
-Types:
-bool
-socklen_t
-uint_t
-uint{8,16,32,64}_t
-int{8,16,32,64}_t
-intptr_t
-
-Constants:
-PATH_NAME_MAX
-UINT{16,32,64}_MAX
-INT32_MAX
-RTLD_LAZY
-HOST_NAME_MAX
-UINT16_MAX
-UINT32_MAX
-UINT64_MAX
-CHAR_BIT
-
-Macros:
-va_copy
-__FUNCTION__
-__FILE__
-__LINE__
-__LINESTR__
-__location__
-__STRING
-__STRINGSTRING
-MIN
-MAX
-QSORT_CAST
-ZERO_STRUCT
-ZERO_STRUCTP
-ZERO_STRUCTPN
-ZERO_ARRAY
-ARRAY_SIZE
-PTR_DIFF
-
-Headers:
-stdint.h
-stdbool.h
-
-Prerequisites:
-memset (for bzero)
-syslog (for vsyslog)
-mktemp (for mkstemp and mkdtemp)
diff --git a/source4/lib/replace/aclocal.m4 b/source4/lib/replace/aclocal.m4
deleted file mode 100644
index 5605e476ba..0000000000
--- a/source4/lib/replace/aclocal.m4
+++ /dev/null
@@ -1 +0,0 @@
-m4_include(libreplace.m4)
diff --git a/source4/lib/replace/autoconf-2.60.m4 b/source4/lib/replace/autoconf-2.60.m4
deleted file mode 100644
index acdcd38efe..0000000000
--- a/source4/lib/replace/autoconf-2.60.m4
+++ /dev/null
@@ -1,210 +0,0 @@
-# AC_GNU_SOURCE
-# --------------
-AC_DEFUN([AC_GNU_SOURCE],
-[AH_VERBATIM([_GNU_SOURCE],
-[/* Enable GNU extensions on systems that have them. */
-#ifndef _GNU_SOURCE
-# undef _GNU_SOURCE
-#endif])dnl
-AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
-AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
-AC_DEFINE([_GNU_SOURCE])
-])
-
-# _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
-# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
-# --------------------------------------------------------------
-# Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99')
-# by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails,
-# try again with each compiler option in the space-separated OPTION-LIST; if one
-# helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE,
-# else ACTION-IF-UNAVAILABLE.
-AC_DEFUN([_AC_C_STD_TRY],
-[AC_MSG_CHECKING([for $CC option to accept ISO ]m4_translit($1, [c], [C]))
-AC_CACHE_VAL(ac_cv_prog_cc_$1,
-[ac_cv_prog_cc_$1=no
-ac_save_CC=$CC
-AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
-for ac_arg in '' $4
-do
- CC="$ac_save_CC $ac_arg"
- _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg])
- test "x$ac_cv_prog_cc_$1" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
-])# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_$1" in
- x)
- AC_MSG_RESULT([none needed]) ;;
- xno)
- AC_MSG_RESULT([unsupported]) ;;
- *)
- CC="$CC $ac_cv_prog_cc_$1"
- AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;
-esac
-AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
-])# _AC_C_STD_TRY
-
-# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
-# ----------------------------------------------------------------
-# If the C compiler is not in ISO C99 mode by default, try to add an
-# option to output variable CC to make it so. This macro tries
-# various options that select ISO C99 on some system or another. It
-# considers the compiler to be in ISO C99 mode if it handles mixed
-# code and declarations, _Bool, inline and restrict.
-AC_DEFUN([_AC_PROG_CC_C99],
-[_AC_C_STD_TRY([c99],
-[[#include <stdarg.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <wchar.h>
-#include <stdio.h>
-
-struct incomplete_array
-{
- int datasize;
- double data[];
-};
-
-struct named_init {
- int number;
- const wchar_t *name;
- double average;
-};
-
-typedef const char *ccp;
-
-static inline int
-test_restrict(ccp restrict text)
-{
- // See if C++-style comments work.
- // Iterate through items via the restricted pointer.
- // Also check for declarations in for loops.
- for (unsigned int i = 0; *(text+i) != '\0'; ++i)
- continue;
- return 0;
-}
-
-// Check varargs and va_copy work.
-static void
-test_varargs(const char *format, ...)
-{
- va_list args;
- va_start(args, format);
- va_list args_copy;
- va_copy(args_copy, args);
-
- const char *str;
- int number;
- float fnumber;
-
- while (*format)
- {
- switch (*format++)
- {
- case 's': // string
- str = va_arg(args_copy, const char *);
- break;
- case 'd': // int
- number = va_arg(args_copy, int);
- break;
- case 'f': // float
- fnumber = (float) va_arg(args_copy, double);
- break;
- default:
- break;
- }
- }
- va_end(args_copy);
- va_end(args);
-}
-]],
-[[
- // Check bool and long long datatypes.
- _Bool success = false;
- long long int bignum = -1234567890LL;
- unsigned long long int ubignum = 1234567890uLL;
-
- // Check restrict.
- if (test_restrict("String literal") != 0)
- success = true;
- char *restrict newvar = "Another string";
-
- // Check varargs.
- test_varargs("s, d' f .", "string", 65, 34.234);
-
- // Check incomplete arrays work.
- struct incomplete_array *ia =
- malloc(sizeof(struct incomplete_array) + (sizeof(double) * 10));
- ia->datasize = 10;
- for (int i = 0; i < ia->datasize; ++i)
- ia->data[i] = (double) i * 1.234;
-
- // Check named initialisers.
- struct named_init ni = {
- .number = 34,
- .name = L"Test wide string",
- .average = 543.34343,
- };
-
- ni.number = 58;
-
- int dynamic_array[ni.number];
- dynamic_array[43] = 543;
-
- // work around unused variable warnings
- return bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x';
-]],
-dnl Try
-dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999)
-dnl AIX -qlanglvl=extc99 (unused restrictive mode: -qlanglvl=stdc99)
-dnl Intel ICC -c99
-dnl IRIX -c99
-dnl Solaris (unused because it causes the compiler to assume C99 semantics for
-dnl library functions, and this is invalid before Solaris 10: -xc99)
-dnl Tru64 -c99
-dnl with extended modes being tried first.
-[[-std=gnu99 -c99 -qlanglvl=extc99]], [$1], [$2])[]dnl
-])# _AC_PROG_CC_C99
-
-# AC_PROG_CC_C99
-# --------------
-AC_DEFUN([AC_PROG_CC_C99],
-[ AC_REQUIRE([AC_PROG_CC])dnl
- _AC_PROG_CC_C99
-])
-
-# AC_USE_SYSTEM_EXTENSIONS
-# ------------------------
-# Enable extensions on systems that normally disable them,
-# typically due to standards-conformance issues.
-AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS],
-[
- AC_BEFORE([$0], [AC_COMPILE_IFELSE])
- AC_BEFORE([$0], [AC_RUN_IFELSE])
-
- AC_REQUIRE([AC_GNU_SOURCE])
- AC_REQUIRE([AC_AIX])
- AC_REQUIRE([AC_MINIX])
-
- AH_VERBATIM([__EXTENSIONS__],
-[/* Enable extensions on Solaris. */
-#ifndef __EXTENSIONS__
-# undef __EXTENSIONS__
-#endif
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# undef _POSIX_PTHREAD_SEMANTICS
-#endif])
- AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
- [ac_cv_safe_to_define___extensions__],
- [AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([
-# define __EXTENSIONS__ 1
- AC_INCLUDES_DEFAULT])],
- [ac_cv_safe_to_define___extensions__=yes],
- [ac_cv_safe_to_define___extensions__=no])])
- test $ac_cv_safe_to_define___extensions__ = yes &&
- AC_DEFINE([__EXTENSIONS__])
- AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
-])
diff --git a/source4/lib/replace/autogen.sh b/source4/lib/replace/autogen.sh
deleted file mode 100755
index d46a4279f3..0000000000
--- a/source4/lib/replace/autogen.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-rm -rf autom4te.cache
-rm -f configure config.h.in
-
-autoheader || exit 1
-autoconf || exit 1
-
-rm -rf autom4te.cache
-
-echo "Now run ./configure and then make."
-exit 0
-
diff --git a/source4/lib/replace/config.guess b/source4/lib/replace/config.guess
deleted file mode 100755
index 354dbe175a..0000000000
--- a/source4/lib/replace/config.guess
+++ /dev/null
@@ -1,1464 +0,0 @@
-#! /bin/sh
-# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2005-08-03'
-
-# This file is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Originally written by Per Bothner <per@bothner.com>.
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# This script attempts to guess a canonical system name similar to
-# config.sub. If it succeeds, it prints the system name on stdout, and
-# exits with 0. Otherwise, it exits with 1.
-#
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit build system type.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION]
-
-Output the configuration name of the system \`$me' is run on.
-
-Operation modes:
- -h, --help print this help, then exit
- -t, --time-stamp print date of last modification, then exit
- -v, --version print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.guess ($timestamp)
-
-Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
- case $1 in
- --time-stamp | --time* | -t )
- echo "$timestamp" ; exit ;;
- --version | -v )
- echo "$version" ; exit ;;
- --help | --h* | -h )
- echo "$usage"; exit ;;
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- echo "$me: invalid option $1$help" >&2
- exit 1 ;;
- * )
- break ;;
- esac
-done
-
-if test $# != 0; then
- echo "$me: too many arguments$help" >&2
- exit 1
-fi
-
-trap 'exit 1' 1 2 15
-
-# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
-# compiler to aid in system detection is discouraged as it requires
-# temporary files to be created and, as you can see below, it is a
-# headache to deal with in a portable fashion.
-
-# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
-# use `HOST_CC' if defined, but it is deprecated.
-
-# Portable tmp directory creation inspired by the Autoconf team.
-
-set_cc_for_build='
-trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
-trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
-: ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
-dummy=$tmp/dummy ;
-tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
-case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,) echo "int x;" > $dummy.c ;
- for c in cc gcc c89 c99 ; do
- if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
- CC_FOR_BUILD="$c"; break ;
- fi ;
- done ;
- if test x"$CC_FOR_BUILD" = x ; then
- CC_FOR_BUILD=no_compiler_found ;
- fi
- ;;
- ,,*) CC_FOR_BUILD=$CC ;;
- ,*,*) CC_FOR_BUILD=$HOST_CC ;;
-esac ; set_cc_for_build= ;'
-
-# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-# (ghazi@noc.rutgers.edu 1994-08-24)
-if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
- PATH=$PATH:/.attbin ; export PATH
-fi
-
-UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
-UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
-UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-
-# Note: order is significant - the case branches are not exclusive.
-
-case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
- *:NetBSD:*:*)
- # NetBSD (nbsd) targets should (where applicable) match one or
- # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
- # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
- # switched to ELF, *-*-netbsd* would select the old
- # object file format. This provides both forward
- # compatibility and a consistent mechanism for selecting the
- # object file format.
- #
- # Note: NetBSD doesn't particularly care about the vendor
- # portion of the name. We always set it to "unknown".
- sysctl="sysctl -n hw.machine_arch"
- UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
- /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
- case "${UNAME_MACHINE_ARCH}" in
- armeb) machine=armeb-unknown ;;
- arm*) machine=arm-unknown ;;
- sh3el) machine=shl-unknown ;;
- sh3eb) machine=sh-unknown ;;
- *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
- esac
- # The Operating System including object format, if it has switched
- # to ELF recently, or will in the future.
- case "${UNAME_MACHINE_ARCH}" in
- arm*|i386|m68k|ns32k|sh3*|sparc|vax)
- eval $set_cc_for_build
- if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
- | grep __ELF__ >/dev/null
- then
- # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
- # Return netbsd for either. FIX?
- os=netbsd
- else
- os=netbsdelf
- fi
- ;;
- *)
- os=netbsd
- ;;
- esac
- # The OS release
- # Debian GNU/NetBSD machines have a different userland, and
- # thus, need a distinct triplet. However, they do not need
- # kernel version information, so it can be replaced with a
- # suitable tag, in the style of linux-gnu.
- case "${UNAME_VERSION}" in
- Debian*)
- release='-gnu'
- ;;
- *)
- release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
- ;;
- esac
- # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
- # contains redundant information, the shorter form:
- # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
- echo "${machine}-${os}${release}"
- exit ;;
- *:OpenBSD:*:*)
- UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
- echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
- exit ;;
- *:ekkoBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
- exit ;;
- macppc:MirBSD:*:*)
- echo powerppc-unknown-mirbsd${UNAME_RELEASE}
- exit ;;
- *:MirBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
- exit ;;
- alpha:OSF1:*:*)
- case $UNAME_RELEASE in
- *4.0)
- UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
- ;;
- *5.*)
- UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
- ;;
- esac
- # According to Compaq, /usr/sbin/psrinfo has been available on
- # OSF/1 and Tru64 systems produced since 1995. I hope that
- # covers most systems running today. This code pipes the CPU
- # types through head -n 1, so we only detect the type of CPU 0.
- ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
- case "$ALPHA_CPU_TYPE" in
- "EV4 (21064)")
- UNAME_MACHINE="alpha" ;;
- "EV4.5 (21064)")
- UNAME_MACHINE="alpha" ;;
- "LCA4 (21066/21068)")
- UNAME_MACHINE="alpha" ;;
- "EV5 (21164)")
- UNAME_MACHINE="alphaev5" ;;
- "EV5.6 (21164A)")
- UNAME_MACHINE="alphaev56" ;;
- "EV5.6 (21164PC)")
- UNAME_MACHINE="alphapca56" ;;
- "EV5.7 (21164PC)")
- UNAME_MACHINE="alphapca57" ;;
- "EV6 (21264)")
- UNAME_MACHINE="alphaev6" ;;
- "EV6.7 (21264A)")
- UNAME_MACHINE="alphaev67" ;;
- "EV6.8CB (21264C)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.8AL (21264B)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.8CX (21264D)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.9A (21264/EV69A)")
- UNAME_MACHINE="alphaev69" ;;
- "EV7 (21364)")
- UNAME_MACHINE="alphaev7" ;;
- "EV7.9 (21364A)")
- UNAME_MACHINE="alphaev79" ;;
- esac
- # A Pn.n version is a patched version.
- # A Vn.n version is a released version.
- # A Tn.n version is a released field test version.
- # A Xn.n version is an unreleased experimental baselevel.
- # 1.2 uses "1.2" for uname -r.
- echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- exit ;;
- Alpha\ *:Windows_NT*:*)
- # How do we know it's Interix rather than the generic POSIX subsystem?
- # Should we change UNAME_MACHINE based on the output of uname instead
- # of the specific Alpha model?
- echo alpha-pc-interix
- exit ;;
- 21064:Windows_NT:50:3)
- echo alpha-dec-winnt3.5
- exit ;;
- Amiga*:UNIX_System_V:4.0:*)
- echo m68k-unknown-sysv4
- exit ;;
- *:[Aa]miga[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-amigaos
- exit ;;
- *:[Mm]orph[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-morphos
- exit ;;
- *:OS/390:*:*)
- echo i370-ibm-openedition
- exit ;;
- *:z/VM:*:*)
- echo s390-ibm-zvmoe
- exit ;;
- *:OS400:*:*)
- echo powerpc-ibm-os400
- exit ;;
- arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
- echo arm-acorn-riscix${UNAME_RELEASE}
- exit ;;
- arm:riscos:*:*|arm:RISCOS:*:*)
- echo arm-unknown-riscos
- exit ;;
- SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
- echo hppa1.1-hitachi-hiuxmpp
- exit ;;
- Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
- # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
- if test "`(/bin/universe) 2>/dev/null`" = att ; then
- echo pyramid-pyramid-sysv3
- else
- echo pyramid-pyramid-bsd
- fi
- exit ;;
- NILE*:*:*:dcosx)
- echo pyramid-pyramid-svr4
- exit ;;
- DRS?6000:unix:4.0:6*)
- echo sparc-icl-nx6
- exit ;;
- DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
- case `/usr/bin/uname -p` in
- sparc) echo sparc-icl-nx7; exit ;;
- esac ;;
- sun4H:SunOS:5.*:*)
- echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
- echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- i86pc:SunOS:5.*:*)
- echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:6*:*)
- # According to config.sub, this is the proper way to canonicalize
- # SunOS6. Hard to guess exactly what SunOS6 will be like, but
- # it's likely to be more like Solaris than SunOS4.
- echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:*:*)
- case "`/usr/bin/arch -k`" in
- Series*|S4*)
- UNAME_RELEASE=`uname -v`
- ;;
- esac
- # Japanese Language versions have a version number like `4.1.3-JL'.
- echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
- exit ;;
- sun3*:SunOS:*:*)
- echo m68k-sun-sunos${UNAME_RELEASE}
- exit ;;
- sun*:*:4.2BSD:*)
- UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
- test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
- case "`/bin/arch`" in
- sun3)
- echo m68k-sun-sunos${UNAME_RELEASE}
- ;;
- sun4)
- echo sparc-sun-sunos${UNAME_RELEASE}
- ;;
- esac
- exit ;;
- aushp:SunOS:*:*)
- echo sparc-auspex-sunos${UNAME_RELEASE}
- exit ;;
- # The situation for MiNT is a little confusing. The machine name
- # can be virtually everything (everything which is not
- # "atarist" or "atariste" at least should have a processor
- # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
- # to the lowercase version "mint" (or "freemint"). Finally
- # the system name "TOS" denotes a system which is actually not
- # MiNT. But MiNT is downward compatible to TOS, so this should
- # be no problem.
- atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
- echo m68k-milan-mint${UNAME_RELEASE}
- exit ;;
- hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
- echo m68k-hades-mint${UNAME_RELEASE}
- exit ;;
- *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
- echo m68k-unknown-mint${UNAME_RELEASE}
- exit ;;
- m68k:machten:*:*)
- echo m68k-apple-machten${UNAME_RELEASE}
- exit ;;
- powerpc:machten:*:*)
- echo powerpc-apple-machten${UNAME_RELEASE}
- exit ;;
- RISC*:Mach:*:*)
- echo mips-dec-mach_bsd4.3
- exit ;;
- RISC*:ULTRIX:*:*)
- echo mips-dec-ultrix${UNAME_RELEASE}
- exit ;;
- VAX*:ULTRIX*:*:*)
- echo vax-dec-ultrix${UNAME_RELEASE}
- exit ;;
- 2020:CLIX:*:* | 2430:CLIX:*:*)
- echo clipper-intergraph-clix${UNAME_RELEASE}
- exit ;;
- mips:*:*:UMIPS | mips:*:*:RISCos)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
-#ifdef __cplusplus
-#include <stdio.h> /* for printf() prototype */
- int main (int argc, char *argv[]) {
-#else
- int main (argc, argv) int argc; char *argv[]; {
-#endif
- #if defined (host_mips) && defined (MIPSEB)
- #if defined (SYSTYPE_SYSV)
- printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
- #endif
- #if defined (SYSTYPE_SVR4)
- printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
- #endif
- #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
- printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
- #endif
- #endif
- exit (-1);
- }
-EOF
- $CC_FOR_BUILD -o $dummy $dummy.c &&
- dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
- SYSTEM_NAME=`$dummy $dummyarg` &&
- { echo "$SYSTEM_NAME"; exit; }
- echo mips-mips-riscos${UNAME_RELEASE}
- exit ;;
- Motorola:PowerMAX_OS:*:*)
- echo powerpc-motorola-powermax
- exit ;;
- Motorola:*:4.3:PL8-*)
- echo powerpc-harris-powermax
- exit ;;
- Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
- echo powerpc-harris-powermax
- exit ;;
- Night_Hawk:Power_UNIX:*:*)
- echo powerpc-harris-powerunix
- exit ;;
- m88k:CX/UX:7*:*)
- echo m88k-harris-cxux7
- exit ;;
- m88k:*:4*:R4*)
- echo m88k-motorola-sysv4
- exit ;;
- m88k:*:3*:R3*)
- echo m88k-motorola-sysv3
- exit ;;
- AViiON:dgux:*:*)
- # DG/UX returns AViiON for all architectures
- UNAME_PROCESSOR=`/usr/bin/uname -p`
- if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
- then
- if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
- [ ${TARGET_BINARY_INTERFACE}x = x ]
- then
- echo m88k-dg-dgux${UNAME_RELEASE}
- else
- echo m88k-dg-dguxbcs${UNAME_RELEASE}
- fi
- else
- echo i586-dg-dgux${UNAME_RELEASE}
- fi
- exit ;;
- M88*:DolphinOS:*:*) # DolphinOS (SVR3)
- echo m88k-dolphin-sysv3
- exit ;;
- M88*:*:R3*:*)
- # Delta 88k system running SVR3
- echo m88k-motorola-sysv3
- exit ;;
- XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
- echo m88k-tektronix-sysv3
- exit ;;
- Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
- echo m68k-tektronix-bsd
- exit ;;
- *:IRIX*:*:*)
- echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
- exit ;;
- ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
- echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
- exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
- i*86:AIX:*:*)
- echo i386-ibm-aix
- exit ;;
- ia64:AIX:*:*)
- if [ -x /usr/bin/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
- else
- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
- fi
- echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
- exit ;;
- *:AIX:2:3)
- if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <sys/systemcfg.h>
-
- main()
- {
- if (!__power_pc())
- exit(1);
- puts("powerpc-ibm-aix3.2.5");
- exit(0);
- }
-EOF
- if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
- then
- echo "$SYSTEM_NAME"
- else
- echo rs6000-ibm-aix3.2.5
- fi
- elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
- echo rs6000-ibm-aix3.2.4
- else
- echo rs6000-ibm-aix3.2
- fi
- exit ;;
- *:AIX:*:[45])
- IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
- if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
- IBM_ARCH=rs6000
- else
- IBM_ARCH=powerpc
- fi
- if [ -x /usr/bin/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
- else
- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
- fi
- echo ${IBM_ARCH}-ibm-aix${IBM_REV}
- exit ;;
- *:AIX:*:*)
- echo rs6000-ibm-aix
- exit ;;
- ibmrt:4.4BSD:*|romp-ibm:BSD:*)
- echo romp-ibm-bsd4.4
- exit ;;
- ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
- echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
- exit ;; # report: romp-ibm BSD 4.3
- *:BOSX:*:*)
- echo rs6000-bull-bosx
- exit ;;
- DPX/2?00:B.O.S.:*:*)
- echo m68k-bull-sysv3
- exit ;;
- 9000/[34]??:4.3bsd:1.*:*)
- echo m68k-hp-bsd
- exit ;;
- hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
- echo m68k-hp-bsd4.4
- exit ;;
- 9000/[34678]??:HP-UX:*:*)
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- case "${UNAME_MACHINE}" in
- 9000/31? ) HP_ARCH=m68000 ;;
- 9000/[34]?? ) HP_ARCH=m68k ;;
- 9000/[678][0-9][0-9])
- if [ -x /usr/bin/getconf ]; then
- sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
- sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
- case "${sc_cpu_version}" in
- 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
- 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
- 532) # CPU_PA_RISC2_0
- case "${sc_kernel_bits}" in
- 32) HP_ARCH="hppa2.0n" ;;
- 64) HP_ARCH="hppa2.0w" ;;
- '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
- esac ;;
- esac
- fi
- if [ "${HP_ARCH}" = "" ]; then
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
-
- #define _HPUX_SOURCE
- #include <stdlib.h>
- #include <unistd.h>
-
- int main ()
- {
- #if defined(_SC_KERNEL_BITS)
- long bits = sysconf(_SC_KERNEL_BITS);
- #endif
- long cpu = sysconf (_SC_CPU_VERSION);
-
- switch (cpu)
- {
- case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
- case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
- case CPU_PA_RISC2_0:
- #if defined(_SC_KERNEL_BITS)
- switch (bits)
- {
- case 64: puts ("hppa2.0w"); break;
- case 32: puts ("hppa2.0n"); break;
- default: puts ("hppa2.0"); break;
- } break;
- #else /* !defined(_SC_KERNEL_BITS) */
- puts ("hppa2.0"); break;
- #endif
- default: puts ("hppa1.0"); break;
- }
- exit (0);
- }
-EOF
- (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
- test -z "$HP_ARCH" && HP_ARCH=hppa
- fi ;;
- esac
- if [ ${HP_ARCH} = "hppa2.0w" ]
- then
- eval $set_cc_for_build
-
- # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
- # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
- # generating 64-bit code. GNU and HP use different nomenclature:
- #
- # $ CC_FOR_BUILD=cc ./config.guess
- # => hppa2.0w-hp-hpux11.23
- # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
- # => hppa64-hp-hpux11.23
-
- if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
- grep __LP64__ >/dev/null
- then
- HP_ARCH="hppa2.0w"
- else
- HP_ARCH="hppa64"
- fi
- fi
- echo ${HP_ARCH}-hp-hpux${HPUX_REV}
- exit ;;
- ia64:HP-UX:*:*)
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- echo ia64-hp-hpux${HPUX_REV}
- exit ;;
- 3050*:HI-UX:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <unistd.h>
- int
- main ()
- {
- long cpu = sysconf (_SC_CPU_VERSION);
- /* The order matters, because CPU_IS_HP_MC68K erroneously returns
- true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
- results, however. */
- if (CPU_IS_PA_RISC (cpu))
- {
- switch (cpu)
- {
- case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
- case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
- case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
- default: puts ("hppa-hitachi-hiuxwe2"); break;
- }
- }
- else if (CPU_IS_HP_MC68K (cpu))
- puts ("m68k-hitachi-hiuxwe2");
- else puts ("unknown-hitachi-hiuxwe2");
- exit (0);
- }
-EOF
- $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
- { echo "$SYSTEM_NAME"; exit; }
- echo unknown-hitachi-hiuxwe2
- exit ;;
- 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
- echo hppa1.1-hp-bsd
- exit ;;
- 9000/8??:4.3bsd:*:*)
- echo hppa1.0-hp-bsd
- exit ;;
- *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
- echo hppa1.0-hp-mpeix
- exit ;;
- hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
- echo hppa1.1-hp-osf
- exit ;;
- hp8??:OSF1:*:*)
- echo hppa1.0-hp-osf
- exit ;;
- i*86:OSF1:*:*)
- if [ -x /usr/sbin/sysversion ] ; then
- echo ${UNAME_MACHINE}-unknown-osf1mk
- else
- echo ${UNAME_MACHINE}-unknown-osf1
- fi
- exit ;;
- parisc*:Lites*:*:*)
- echo hppa1.1-hp-lites
- exit ;;
- C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
- echo c1-convex-bsd
- exit ;;
- C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit ;;
- C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
- echo c34-convex-bsd
- exit ;;
- C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
- echo c38-convex-bsd
- exit ;;
- C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
- echo c4-convex-bsd
- exit ;;
- CRAY*Y-MP:*:*:*)
- echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*[A-Z]90:*:*:*)
- echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
- | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
- -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
- -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*TS:*:*:*)
- echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*T3E:*:*:*)
- echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*SV1:*:*:*)
- echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- *:UNICOS/mp:*:*)
- echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
- FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
- echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
- 5000:UNIX_System_V:4.*:*)
- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
- echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
- i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
- echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
- exit ;;
- sparc*:BSD/OS:*:*)
- echo sparc-unknown-bsdi${UNAME_RELEASE}
- exit ;;
- *:BSD/OS:*:*)
- echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
- exit ;;
- *:FreeBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit ;;
- i*:CYGWIN*:*)
- echo ${UNAME_MACHINE}-pc-cygwin
- exit ;;
- i*:MINGW*:*)
- echo ${UNAME_MACHINE}-pc-mingw32
- exit ;;
- i*:windows32*:*)
- # uname -m includes "-pc" on this system.
- echo ${UNAME_MACHINE}-mingw32
- exit ;;
- i*:PW*:*)
- echo ${UNAME_MACHINE}-pc-pw32
- exit ;;
- x86:Interix*:[34]*)
- echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
- exit ;;
- [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
- echo i${UNAME_MACHINE}-pc-mks
- exit ;;
- i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
- # How do we know it's Interix rather than the generic POSIX subsystem?
- # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
- # UNAME_MACHINE based on the output of uname instead of i386?
- echo i586-pc-interix
- exit ;;
- i*:UWIN*:*)
- echo ${UNAME_MACHINE}-pc-uwin
- exit ;;
- amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
- echo x86_64-unknown-cygwin
- exit ;;
- p*:CYGWIN*:*)
- echo powerpcle-unknown-cygwin
- exit ;;
- prep*:SunOS:5.*:*)
- echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- *:GNU:*:*)
- # the GNU system
- echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
- exit ;;
- *:GNU/*:*:*)
- # other systems with GNU libc and userland
- echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
- exit ;;
- i*86:Minix:*:*)
- echo ${UNAME_MACHINE}-pc-minix
- exit ;;
- arm*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- cris:Linux:*:*)
- echo cris-axis-linux-gnu
- exit ;;
- crisv32:Linux:*:*)
- echo crisv32-axis-linux-gnu
- exit ;;
- frv:Linux:*:*)
- echo frv-unknown-linux-gnu
- exit ;;
- ia64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- m32r*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- m68*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- mips:Linux:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #undef CPU
- #undef mips
- #undef mipsel
- #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mipsel
- #else
- #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips
- #else
- CPU=
- #endif
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
- ;;
- mips64:Linux:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #undef CPU
- #undef mips64
- #undef mips64el
- #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mips64el
- #else
- #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips64
- #else
- CPU=
- #endif
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
- ;;
- or32:Linux:*:*)
- echo or32-unknown-linux-gnu
- exit ;;
- ppc:Linux:*:*)
- echo powerpc-unknown-linux-gnu
- exit ;;
- ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-gnu
- exit ;;
- alpha:Linux:*:*)
- case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
- EV5) UNAME_MACHINE=alphaev5 ;;
- EV56) UNAME_MACHINE=alphaev56 ;;
- PCA56) UNAME_MACHINE=alphapca56 ;;
- PCA57) UNAME_MACHINE=alphapca56 ;;
- EV6) UNAME_MACHINE=alphaev6 ;;
- EV67) UNAME_MACHINE=alphaev67 ;;
- EV68*) UNAME_MACHINE=alphaev68 ;;
- esac
- objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
- if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
- exit ;;
- parisc:Linux:*:* | hppa:Linux:*:*)
- # Look for CPU level
- case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
- PA7*) echo hppa1.1-unknown-linux-gnu ;;
- PA8*) echo hppa2.0-unknown-linux-gnu ;;
- *) echo hppa-unknown-linux-gnu ;;
- esac
- exit ;;
- parisc64:Linux:*:* | hppa64:Linux:*:*)
- echo hppa64-unknown-linux-gnu
- exit ;;
- s390:Linux:*:* | s390x:Linux:*:*)
- echo ${UNAME_MACHINE}-ibm-linux
- exit ;;
- sh64*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- sh*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- sparc:Linux:*:* | sparc64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- x86_64:Linux:*:*)
- echo x86_64-unknown-linux-gnu
- exit ;;
- i*86:Linux:*:*)
- # The BFD linker knows what the default object file format is, so
- # first see if it will tell us. cd to the root directory to prevent
- # problems with other programs or directories called `ld' in the path.
- # Set LC_ALL=C to ensure ld outputs messages in English.
- ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
- | sed -ne '/supported targets:/!d
- s/[ ][ ]*/ /g
- s/.*supported targets: *//
- s/ .*//
- p'`
- case "$ld_supported_targets" in
- elf32-i386)
- TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
- ;;
- a.out-i386-linux)
- echo "${UNAME_MACHINE}-pc-linux-gnuaout"
- exit ;;
- coff-i386)
- echo "${UNAME_MACHINE}-pc-linux-gnucoff"
- exit ;;
- "")
- # Either a pre-BFD a.out linker (linux-gnuoldld) or
- # one that does not give us useful --help.
- echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
- exit ;;
- esac
- # Determine whether the default compiler is a.out or elf
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <features.h>
- #ifdef __ELF__
- # ifdef __GLIBC__
- # if __GLIBC__ >= 2
- LIBC=gnu
- # else
- LIBC=gnulibc1
- # endif
- # else
- LIBC=gnulibc1
- # endif
- #else
- #ifdef __INTEL_COMPILER
- LIBC=gnu
- #else
- LIBC=gnuaout
- #endif
- #endif
- #ifdef __dietlibc__
- LIBC=dietlibc
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
- test x"${LIBC}" != x && {
- echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
- exit
- }
- test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
- ;;
- i*86:DYNIX/ptx:4*:*)
- # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
- # earlier versions are messed up and put the nodename in both
- # sysname and nodename.
- echo i386-sequent-sysv4
- exit ;;
- i*86:UNIX_SV:4.2MP:2.*)
- # Unixware is an offshoot of SVR4, but it has its own version
- # number series starting with 2...
- # I am not positive that other SVR4 systems won't match this,
- # I just have to hope. -- rms.
- # Use sysv4.2uw... so that sysv4* matches it.
- echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
- exit ;;
- i*86:OS/2:*:*)
- # If we were able to find `uname', then EMX Unix compatibility
- # is probably installed.
- echo ${UNAME_MACHINE}-pc-os2-emx
- exit ;;
- i*86:XTS-300:*:STOP)
- echo ${UNAME_MACHINE}-unknown-stop
- exit ;;
- i*86:atheos:*:*)
- echo ${UNAME_MACHINE}-unknown-atheos
- exit ;;
- i*86:syllable:*:*)
- echo ${UNAME_MACHINE}-pc-syllable
- exit ;;
- i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
- echo i386-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- i*86:*DOS:*:*)
- echo ${UNAME_MACHINE}-pc-msdosdjgpp
- exit ;;
- i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
- UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
- if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
- echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
- else
- echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
- fi
- exit ;;
- i*86:*:5:[678]*)
- # UnixWare 7.x, OpenUNIX and OpenServer 6.
- case `/bin/uname -X | grep "^Machine"` in
- *486*) UNAME_MACHINE=i486 ;;
- *Pentium) UNAME_MACHINE=i586 ;;
- *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
- esac
- echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
- exit ;;
- i*86:*:3.2:*)
- if test -f /usr/options/cb.name; then
- UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
- echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
- elif /bin/uname -X 2>/dev/null >/dev/null ; then
- UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
- (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
- (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
- && UNAME_MACHINE=i586
- (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
- && UNAME_MACHINE=i686
- (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
- && UNAME_MACHINE=i686
- echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
- else
- echo ${UNAME_MACHINE}-pc-sysv32
- fi
- exit ;;
- pc:*:*:*)
- # Left here for compatibility:
- # uname -m prints for DJGPP always 'pc', but it prints nothing about
- # the processor, so we play safe by assuming i386.
- echo i386-pc-msdosdjgpp
- exit ;;
- Intel:Mach:3*:*)
- echo i386-pc-mach3
- exit ;;
- paragon:*:*:*)
- echo i860-intel-osf1
- exit ;;
- i860:*:4.*:*) # i860-SVR4
- if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
- echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
- else # Add other i860-SVR4 vendors below as they are discovered.
- echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
- fi
- exit ;;
- mini*:CTIX:SYS*5:*)
- # "miniframe"
- echo m68010-convergent-sysv
- exit ;;
- mc68k:UNIX:SYSTEM5:3.51m)
- echo m68k-convergent-sysv
- exit ;;
- M680?0:D-NIX:5.3:*)
- echo m68k-diab-dnix
- exit ;;
- M68*:*:R3V[5678]*:*)
- test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
- 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
- OS_REL=''
- test -r /etc/.relid \
- && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
- /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
- /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
- && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
- 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
- /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && { echo i486-ncr-sysv4; exit; } ;;
- m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
- echo m68k-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- mc68030:UNIX_System_V:4.*:*)
- echo m68k-atari-sysv4
- exit ;;
- TSUNAMI:LynxOS:2.*:*)
- echo sparc-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- rs6000:LynxOS:2.*:*)
- echo rs6000-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
- echo powerpc-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- SM[BE]S:UNIX_SV:*:*)
- echo mips-dde-sysv${UNAME_RELEASE}
- exit ;;
- RM*:ReliantUNIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
- RM*:SINIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
- *:SINIX-*:*:*)
- if uname -p 2>/dev/null >/dev/null ; then
- UNAME_MACHINE=`(uname -p) 2>/dev/null`
- echo ${UNAME_MACHINE}-sni-sysv4
- else
- echo ns32k-sni-sysv
- fi
- exit ;;
- PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
- # says <Richard.M.Bartel@ccMail.Census.GOV>
- echo i586-unisys-sysv4
- exit ;;
- *:UNIX_System_V:4*:FTX*)
- # From Gerald Hewes <hewes@openmarket.com>.
- # How about differentiating between stratus architectures? -djm
- echo hppa1.1-stratus-sysv4
- exit ;;
- *:*:*:FTX*)
- # From seanf@swdc.stratus.com.
- echo i860-stratus-sysv4
- exit ;;
- i*86:VOS:*:*)
- # From Paul.Green@stratus.com.
- echo ${UNAME_MACHINE}-stratus-vos
- exit ;;
- *:VOS:*:*)
- # From Paul.Green@stratus.com.
- echo hppa1.1-stratus-vos
- exit ;;
- mc68*:A/UX:*:*)
- echo m68k-apple-aux${UNAME_RELEASE}
- exit ;;
- news*:NEWS-OS:6*:*)
- echo mips-sony-newsos6
- exit ;;
- R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
- if [ -d /usr/nec ]; then
- echo mips-nec-sysv${UNAME_RELEASE}
- else
- echo mips-unknown-sysv${UNAME_RELEASE}
- fi
- exit ;;
- BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
- echo powerpc-be-beos
- exit ;;
- BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
- echo powerpc-apple-beos
- exit ;;
- BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
- echo i586-pc-beos
- exit ;;
- SX-4:SUPER-UX:*:*)
- echo sx4-nec-superux${UNAME_RELEASE}
- exit ;;
- SX-5:SUPER-UX:*:*)
- echo sx5-nec-superux${UNAME_RELEASE}
- exit ;;
- SX-6:SUPER-UX:*:*)
- echo sx6-nec-superux${UNAME_RELEASE}
- exit ;;
- Power*:Rhapsody:*:*)
- echo powerpc-apple-rhapsody${UNAME_RELEASE}
- exit ;;
- *:Rhapsody:*:*)
- echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
- exit ;;
- *:Darwin:*:*)
- UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
- case $UNAME_PROCESSOR in
- *86) UNAME_PROCESSOR=i686 ;;
- unknown) UNAME_PROCESSOR=powerpc ;;
- esac
- echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
- exit ;;
- *:procnto*:*:* | *:QNX:[0123456789]*:*)
- UNAME_PROCESSOR=`uname -p`
- if test "$UNAME_PROCESSOR" = "x86"; then
- UNAME_PROCESSOR=i386
- UNAME_MACHINE=pc
- fi
- echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
- exit ;;
- *:QNX:*:4*)
- echo i386-pc-qnx
- exit ;;
- NSE-?:NONSTOP_KERNEL:*:*)
- echo nse-tandem-nsk${UNAME_RELEASE}
- exit ;;
- NSR-?:NONSTOP_KERNEL:*:*)
- echo nsr-tandem-nsk${UNAME_RELEASE}
- exit ;;
- *:NonStop-UX:*:*)
- echo mips-compaq-nonstopux
- exit ;;
- BS2000:POSIX*:*:*)
- echo bs2000-siemens-sysv
- exit ;;
- DS/*:UNIX_System_V:*:*)
- echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
- exit ;;
- *:Plan9:*:*)
- # "uname -m" is not consistent, so use $cputype instead. 386
- # is converted to i386 for consistency with other x86
- # operating systems.
- if test "$cputype" = "386"; then
- UNAME_MACHINE=i386
- else
- UNAME_MACHINE="$cputype"
- fi
- echo ${UNAME_MACHINE}-unknown-plan9
- exit ;;
- *:TOPS-10:*:*)
- echo pdp10-unknown-tops10
- exit ;;
- *:TENEX:*:*)
- echo pdp10-unknown-tenex
- exit ;;
- KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
- echo pdp10-dec-tops20
- exit ;;
- XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
- echo pdp10-xkl-tops20
- exit ;;
- *:TOPS-20:*:*)
- echo pdp10-unknown-tops20
- exit ;;
- *:ITS:*:*)
- echo pdp10-unknown-its
- exit ;;
- SEI:*:*:SEIUX)
- echo mips-sei-seiux${UNAME_RELEASE}
- exit ;;
- *:DragonFly:*:*)
- echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit ;;
- *:*VMS:*:*)
- UNAME_MACHINE=`(uname -p) 2>/dev/null`
- case "${UNAME_MACHINE}" in
- A*) echo alpha-dec-vms ; exit ;;
- I*) echo ia64-dec-vms ; exit ;;
- V*) echo vax-dec-vms ; exit ;;
- esac ;;
- *:XENIX:*:SysV)
- echo i386-pc-xenix
- exit ;;
- i*86:skyos:*:*)
- echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
- exit ;;
-esac
-
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
- /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
- I don't know.... */
- printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
- printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
- "4"
-#else
- ""
-#endif
- ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
- printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
- printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
- int version;
- version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
- if (version < 4)
- printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
- else
- printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
- exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
- printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
- printf ("ns32k-encore-mach\n"); exit (0);
-#else
- printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
- printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
- printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
- printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
- struct utsname un;
-
- uname(&un);
-
- if (strncmp(un.version, "V2", 2) == 0) {
- printf ("i386-sequent-ptx2\n"); exit (0);
- }
- if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
- printf ("i386-sequent-ptx1\n"); exit (0);
- }
- printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-# include <sys/param.h>
-# if defined (BSD)
-# if BSD == 43
- printf ("vax-dec-bsd4.3\n"); exit (0);
-# else
-# if BSD == 199006
- printf ("vax-dec-bsd4.3reno\n"); exit (0);
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# endif
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# else
- printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
- printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
- exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
- { echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
- case `getsysinfo -f cpu_type` in
- c1*)
- echo c1-convex-bsd
- exit ;;
- c2*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit ;;
- c34*)
- echo c34-convex-bsd
- exit ;;
- c38*)
- echo c38-convex-bsd
- exit ;;
- c4*)
- echo c4-convex-bsd
- exit ;;
- esac
-fi
-
-cat >&2 <<EOF
-$0: unable to guess system type
-
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
-
- http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
-and
- http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
-
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
-
-config.guess timestamp = $timestamp
-
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
-/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
-
-hostinfo = `(hostinfo) 2>/dev/null`
-/bin/universe = `(/bin/universe) 2>/dev/null`
-/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
-/bin/arch = `(/bin/arch) 2>/dev/null`
-/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
-
-UNAME_MACHINE = ${UNAME_MACHINE}
-UNAME_RELEASE = ${UNAME_RELEASE}
-UNAME_SYSTEM = ${UNAME_SYSTEM}
-UNAME_VERSION = ${UNAME_VERSION}
-EOF
-
-exit 1
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/source4/lib/replace/config.sub b/source4/lib/replace/config.sub
deleted file mode 100755
index 23cd6fd75c..0000000000
--- a/source4/lib/replace/config.sub
+++ /dev/null
@@ -1,1577 +0,0 @@
-#! /bin/sh
-# Configuration validation subroutine script.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2005-07-08'
-
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine. It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# Configuration subroutine to validate and canonicalize a configuration type.
-# Supply the specified configuration type as an argument.
-# If it is invalid, we print an error message on stderr and exit with code 1.
-# Otherwise, we print the canonical config type on stdout and succeed.
-
-# This file is supposed to be the same for all GNU packages
-# and recognize all the CPU types, system types and aliases
-# that are meaningful with *any* GNU software.
-# Each package is responsible for reporting which valid configurations
-# it does not support. The user should be able to distinguish
-# a failure to support a valid configuration from a meaningless
-# configuration.
-
-# The goal of this file is to map all the various variations of a given
-# machine specification into a single specification in the form:
-# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-# or in some cases, the newer four-part form:
-# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-# It is wrong to echo any other type of specification.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION] CPU-MFR-OPSYS
- $0 [OPTION] ALIAS
-
-Canonicalize a configuration name.
-
-Operation modes:
- -h, --help print this help, then exit
- -t, --time-stamp print date of last modification, then exit
- -v, --version print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.sub ($timestamp)
-
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
- case $1 in
- --time-stamp | --time* | -t )
- echo "$timestamp" ; exit ;;
- --version | -v )
- echo "$version" ; exit ;;
- --help | --h* | -h )
- echo "$usage"; exit ;;
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- echo "$me: invalid option $1$help"
- exit 1 ;;
-
- *local*)
- # First pass through any local machine types.
- echo $1
- exit ;;
-
- * )
- break ;;
- esac
-done
-
-case $# in
- 0) echo "$me: missing argument$help" >&2
- exit 1;;
- 1) ;;
- *) echo "$me: too many arguments$help" >&2
- exit 1;;
-esac
-
-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-case $maybe_os in
- nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
- kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
- os=-$maybe_os
- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
- ;;
- *)
- basic_machine=`echo $1 | sed 's/-[^-]*$//'`
- if [ $basic_machine != $1 ]
- then os=`echo $1 | sed 's/.*-/-/'`
- else os=; fi
- ;;
-esac
-
-### Let's recognize common machines as not being operating systems so
-### that things like config.sub decstation-3100 work. We also
-### recognize some manufacturers as not being operating systems, so we
-### can provide default operating systems below.
-case $os in
- -sun*os*)
- # Prevent following clause from handling this invalid input.
- ;;
- -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
- -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
- -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
- -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
- -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
- -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
- -apple | -axis | -knuth | -cray)
- os=
- basic_machine=$1
- ;;
- -sim | -cisco | -oki | -wec | -winbond)
- os=
- basic_machine=$1
- ;;
- -scout)
- ;;
- -wrs)
- os=-vxworks
- basic_machine=$1
- ;;
- -chorusos*)
- os=-chorusos
- basic_machine=$1
- ;;
- -chorusrdb)
- os=-chorusrdb
- basic_machine=$1
- ;;
- -hiux*)
- os=-hiuxwe2
- ;;
- -sco5)
- os=-sco3.2v5
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco4)
- os=-sco3.2v4
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2.[4-9]*)
- os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2v[4-9]*)
- # Don't forget version if it is 3.2v4 or newer.
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco*)
- os=-sco3.2v2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -udk*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -isc)
- os=-isc2.2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -clix*)
- basic_machine=clipper-intergraph
- ;;
- -isc*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -lynx*)
- os=-lynxos
- ;;
- -ptx*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
- ;;
- -windowsnt*)
- os=`echo $os | sed -e 's/windowsnt/winnt/'`
- ;;
- -psos*)
- os=-psos
- ;;
- -mint | -mint[0-9]*)
- basic_machine=m68k-atari
- os=-mint
- ;;
-esac
-
-# Decode aliases for certain CPU-COMPANY combinations.
-case $basic_machine in
- # Recognize the basic CPU types without company name.
- # Some are omitted here because they have special meanings below.
- 1750a | 580 \
- | a29k \
- | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
- | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
- | am33_2.0 \
- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
- | bfin \
- | c4x | clipper \
- | d10v | d30v | dlx | dsp16xx \
- | fr30 | frv \
- | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
- | i370 | i860 | i960 | ia64 \
- | ip2k | iq2000 \
- | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
- | mips | mipsbe | mipseb | mipsel | mipsle \
- | mips16 \
- | mips64 | mips64el \
- | mips64vr | mips64vrel \
- | mips64orion | mips64orionel \
- | mips64vr4100 | mips64vr4100el \
- | mips64vr4300 | mips64vr4300el \
- | mips64vr5000 | mips64vr5000el \
- | mips64vr5900 | mips64vr5900el \
- | mipsisa32 | mipsisa32el \
- | mipsisa32r2 | mipsisa32r2el \
- | mipsisa64 | mipsisa64el \
- | mipsisa64r2 | mipsisa64r2el \
- | mipsisa64sb1 | mipsisa64sb1el \
- | mipsisa64sr71k | mipsisa64sr71kel \
- | mipstx39 | mipstx39el \
- | mn10200 | mn10300 \
- | ms1 \
- | msp430 \
- | ns16k | ns32k \
- | or32 \
- | pdp10 | pdp11 | pj | pjl \
- | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
- | pyramid \
- | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
- | sh64 | sh64le \
- | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
- | sparcv8 | sparcv9 | sparcv9b \
- | strongarm \
- | tahoe | thumb | tic4x | tic80 | tron \
- | v850 | v850e \
- | we32k \
- | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
- | z8k)
- basic_machine=$basic_machine-unknown
- ;;
- m32c)
- basic_machine=$basic_machine-unknown
- ;;
- m6811 | m68hc11 | m6812 | m68hc12)
- # Motorola 68HC11/12.
- basic_machine=$basic_machine-unknown
- os=-none
- ;;
- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
- ;;
-
- # We use `pc' rather than `unknown'
- # because (1) that's what they normally are, and
- # (2) the word "unknown" tends to confuse beginning users.
- i*86 | x86_64)
- basic_machine=$basic_machine-pc
- ;;
- # Object if more than one company name word.
- *-*-*)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
- # Recognize the basic CPU types with company name.
- 580-* \
- | a29k-* \
- | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
- | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
- | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
- | avr-* \
- | bfin-* | bs2000-* \
- | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
- | clipper-* | craynv-* | cydra-* \
- | d10v-* | d30v-* | dlx-* \
- | elxsi-* \
- | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
- | h8300-* | h8500-* \
- | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
- | i*86-* | i860-* | i960-* | ia64-* \
- | ip2k-* | iq2000-* \
- | m32r-* | m32rle-* \
- | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
- | m88110-* | m88k-* | maxq-* | mcore-* \
- | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
- | mips16-* \
- | mips64-* | mips64el-* \
- | mips64vr-* | mips64vrel-* \
- | mips64orion-* | mips64orionel-* \
- | mips64vr4100-* | mips64vr4100el-* \
- | mips64vr4300-* | mips64vr4300el-* \
- | mips64vr5000-* | mips64vr5000el-* \
- | mips64vr5900-* | mips64vr5900el-* \
- | mipsisa32-* | mipsisa32el-* \
- | mipsisa32r2-* | mipsisa32r2el-* \
- | mipsisa64-* | mipsisa64el-* \
- | mipsisa64r2-* | mipsisa64r2el-* \
- | mipsisa64sb1-* | mipsisa64sb1el-* \
- | mipsisa64sr71k-* | mipsisa64sr71kel-* \
- | mipstx39-* | mipstx39el-* \
- | mmix-* \
- | ms1-* \
- | msp430-* \
- | none-* | np1-* | ns16k-* | ns32k-* \
- | orion-* \
- | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
- | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
- | pyramid-* \
- | romp-* | rs6000-* \
- | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
- | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
- | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
- | sparclite-* \
- | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
- | tahoe-* | thumb-* \
- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
- | tron-* \
- | v850-* | v850e-* | vax-* \
- | we32k-* \
- | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
- | xstormy16-* | xtensa-* \
- | ymp-* \
- | z8k-*)
- ;;
- m32c-*)
- ;;
- # Recognize the various machine names and aliases which stand
- # for a CPU type and a company and sometimes even an OS.
- 386bsd)
- basic_machine=i386-unknown
- os=-bsd
- ;;
- 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
- basic_machine=m68000-att
- ;;
- 3b*)
- basic_machine=we32k-att
- ;;
- a29khif)
- basic_machine=a29k-amd
- os=-udi
- ;;
- abacus)
- basic_machine=abacus-unknown
- ;;
- adobe68k)
- basic_machine=m68010-adobe
- os=-scout
- ;;
- alliant | fx80)
- basic_machine=fx80-alliant
- ;;
- altos | altos3068)
- basic_machine=m68k-altos
- ;;
- am29k)
- basic_machine=a29k-none
- os=-bsd
- ;;
- amd64)
- basic_machine=x86_64-pc
- ;;
- amd64-*)
- basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- amdahl)
- basic_machine=580-amdahl
- os=-sysv
- ;;
- amiga | amiga-*)
- basic_machine=m68k-unknown
- ;;
- amigaos | amigados)
- basic_machine=m68k-unknown
- os=-amigaos
- ;;
- amigaunix | amix)
- basic_machine=m68k-unknown
- os=-sysv4
- ;;
- apollo68)
- basic_machine=m68k-apollo
- os=-sysv
- ;;
- apollo68bsd)
- basic_machine=m68k-apollo
- os=-bsd
- ;;
- aux)
- basic_machine=m68k-apple
- os=-aux
- ;;
- balance)
- basic_machine=ns32k-sequent
- os=-dynix
- ;;
- c90)
- basic_machine=c90-cray
- os=-unicos
- ;;
- convex-c1)
- basic_machine=c1-convex
- os=-bsd
- ;;
- convex-c2)
- basic_machine=c2-convex
- os=-bsd
- ;;
- convex-c32)
- basic_machine=c32-convex
- os=-bsd
- ;;
- convex-c34)
- basic_machine=c34-convex
- os=-bsd
- ;;
- convex-c38)
- basic_machine=c38-convex
- os=-bsd
- ;;
- cray | j90)
- basic_machine=j90-cray
- os=-unicos
- ;;
- craynv)
- basic_machine=craynv-cray
- os=-unicosmp
- ;;
- cr16c)
- basic_machine=cr16c-unknown
- os=-elf
- ;;
- crds | unos)
- basic_machine=m68k-crds
- ;;
- crisv32 | crisv32-* | etraxfs*)
- basic_machine=crisv32-axis
- ;;
- cris | cris-* | etrax*)
- basic_machine=cris-axis
- ;;
- crx)
- basic_machine=crx-unknown
- os=-elf
- ;;
- da30 | da30-*)
- basic_machine=m68k-da30
- ;;
- decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
- basic_machine=mips-dec
- ;;
- decsystem10* | dec10*)
- basic_machine=pdp10-dec
- os=-tops10
- ;;
- decsystem20* | dec20*)
- basic_machine=pdp10-dec
- os=-tops20
- ;;
- delta | 3300 | motorola-3300 | motorola-delta \
- | 3300-motorola | delta-motorola)
- basic_machine=m68k-motorola
- ;;
- delta88)
- basic_machine=m88k-motorola
- os=-sysv3
- ;;
- djgpp)
- basic_machine=i586-pc
- os=-msdosdjgpp
- ;;
- dpx20 | dpx20-*)
- basic_machine=rs6000-bull
- os=-bosx
- ;;
- dpx2* | dpx2*-bull)
- basic_machine=m68k-bull
- os=-sysv3
- ;;
- ebmon29k)
- basic_machine=a29k-amd
- os=-ebmon
- ;;
- elxsi)
- basic_machine=elxsi-elxsi
- os=-bsd
- ;;
- encore | umax | mmax)
- basic_machine=ns32k-encore
- ;;
- es1800 | OSE68k | ose68k | ose | OSE)
- basic_machine=m68k-ericsson
- os=-ose
- ;;
- fx2800)
- basic_machine=i860-alliant
- ;;
- genix)
- basic_machine=ns32k-ns
- ;;
- gmicro)
- basic_machine=tron-gmicro
- os=-sysv
- ;;
- go32)
- basic_machine=i386-pc
- os=-go32
- ;;
- h3050r* | hiux*)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- h8300hms)
- basic_machine=h8300-hitachi
- os=-hms
- ;;
- h8300xray)
- basic_machine=h8300-hitachi
- os=-xray
- ;;
- h8500hms)
- basic_machine=h8500-hitachi
- os=-hms
- ;;
- harris)
- basic_machine=m88k-harris
- os=-sysv3
- ;;
- hp300-*)
- basic_machine=m68k-hp
- ;;
- hp300bsd)
- basic_machine=m68k-hp
- os=-bsd
- ;;
- hp300hpux)
- basic_machine=m68k-hp
- os=-hpux
- ;;
- hp3k9[0-9][0-9] | hp9[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hp9k2[0-9][0-9] | hp9k31[0-9])
- basic_machine=m68000-hp
- ;;
- hp9k3[2-9][0-9])
- basic_machine=m68k-hp
- ;;
- hp9k6[0-9][0-9] | hp6[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hp9k7[0-79][0-9] | hp7[0-79][0-9])
- basic_machine=hppa1.1-hp
- ;;
- hp9k78[0-9] | hp78[0-9])
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][13679] | hp8[0-9][13679])
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][0-9] | hp8[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hppa-next)
- os=-nextstep3
- ;;
- hppaosf)
- basic_machine=hppa1.1-hp
- os=-osf
- ;;
- hppro)
- basic_machine=hppa1.1-hp
- os=-proelf
- ;;
- i370-ibm* | ibm*)
- basic_machine=i370-ibm
- ;;
-# I'm not sure what "Sysv32" means. Should this be sysv3.2?
- i*86v32)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv32
- ;;
- i*86v4*)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv4
- ;;
- i*86v)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv
- ;;
- i*86sol2)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-solaris2
- ;;
- i386mach)
- basic_machine=i386-mach
- os=-mach
- ;;
- i386-vsta | vsta)
- basic_machine=i386-unknown
- os=-vsta
- ;;
- iris | iris4d)
- basic_machine=mips-sgi
- case $os in
- -irix*)
- ;;
- *)
- os=-irix4
- ;;
- esac
- ;;
- isi68 | isi)
- basic_machine=m68k-isi
- os=-sysv
- ;;
- m88k-omron*)
- basic_machine=m88k-omron
- ;;
- magnum | m3230)
- basic_machine=mips-mips
- os=-sysv
- ;;
- merlin)
- basic_machine=ns32k-utek
- os=-sysv
- ;;
- mingw32)
- basic_machine=i386-pc
- os=-mingw32
- ;;
- miniframe)
- basic_machine=m68000-convergent
- ;;
- *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
- basic_machine=m68k-atari
- os=-mint
- ;;
- mips3*-*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
- ;;
- mips3*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
- ;;
- monitor)
- basic_machine=m68k-rom68k
- os=-coff
- ;;
- morphos)
- basic_machine=powerpc-unknown
- os=-morphos
- ;;
- msdos)
- basic_machine=i386-pc
- os=-msdos
- ;;
- mvs)
- basic_machine=i370-ibm
- os=-mvs
- ;;
- ncr3000)
- basic_machine=i486-ncr
- os=-sysv4
- ;;
- netbsd386)
- basic_machine=i386-unknown
- os=-netbsd
- ;;
- netwinder)
- basic_machine=armv4l-rebel
- os=-linux
- ;;
- news | news700 | news800 | news900)
- basic_machine=m68k-sony
- os=-newsos
- ;;
- news1000)
- basic_machine=m68030-sony
- os=-newsos
- ;;
- news-3600 | risc-news)
- basic_machine=mips-sony
- os=-newsos
- ;;
- necv70)
- basic_machine=v70-nec
- os=-sysv
- ;;
- next | m*-next )
- basic_machine=m68k-next
- case $os in
- -nextstep* )
- ;;
- -ns2*)
- os=-nextstep2
- ;;
- *)
- os=-nextstep3
- ;;
- esac
- ;;
- nh3000)
- basic_machine=m68k-harris
- os=-cxux
- ;;
- nh[45]000)
- basic_machine=m88k-harris
- os=-cxux
- ;;
- nindy960)
- basic_machine=i960-intel
- os=-nindy
- ;;
- mon960)
- basic_machine=i960-intel
- os=-mon960
- ;;
- nonstopux)
- basic_machine=mips-compaq
- os=-nonstopux
- ;;
- np1)
- basic_machine=np1-gould
- ;;
- nsr-tandem)
- basic_machine=nsr-tandem
- ;;
- op50n-* | op60c-*)
- basic_machine=hppa1.1-oki
- os=-proelf
- ;;
- openrisc | openrisc-*)
- basic_machine=or32-unknown
- ;;
- os400)
- basic_machine=powerpc-ibm
- os=-os400
- ;;
- OSE68000 | ose68000)
- basic_machine=m68000-ericsson
- os=-ose
- ;;
- os68k)
- basic_machine=m68k-none
- os=-os68k
- ;;
- pa-hitachi)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- paragon)
- basic_machine=i860-intel
- os=-osf
- ;;
- pbd)
- basic_machine=sparc-tti
- ;;
- pbb)
- basic_machine=m68k-tti
- ;;
- pc532 | pc532-*)
- basic_machine=ns32k-pc532
- ;;
- pentium | p5 | k5 | k6 | nexgen | viac3)
- basic_machine=i586-pc
- ;;
- pentiumpro | p6 | 6x86 | athlon | athlon_*)
- basic_machine=i686-pc
- ;;
- pentiumii | pentium2 | pentiumiii | pentium3)
- basic_machine=i686-pc
- ;;
- pentium4)
- basic_machine=i786-pc
- ;;
- pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
- basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentiumpro-* | p6-* | 6x86-* | athlon-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentium4-*)
- basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pn)
- basic_machine=pn-gould
- ;;
- power) basic_machine=power-ibm
- ;;
- ppc) basic_machine=powerpc-unknown
- ;;
- ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppcle | powerpclittle | ppc-le | powerpc-little)
- basic_machine=powerpcle-unknown
- ;;
- ppcle-* | powerpclittle-*)
- basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppc64) basic_machine=powerpc64-unknown
- ;;
- ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppc64le | powerpc64little | ppc64-le | powerpc64-little)
- basic_machine=powerpc64le-unknown
- ;;
- ppc64le-* | powerpc64little-*)
- basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ps2)
- basic_machine=i386-ibm
- ;;
- pw32)
- basic_machine=i586-unknown
- os=-pw32
- ;;
- rom68k)
- basic_machine=m68k-rom68k
- os=-coff
- ;;
- rm[46]00)
- basic_machine=mips-siemens
- ;;
- rtpc | rtpc-*)
- basic_machine=romp-ibm
- ;;
- s390 | s390-*)
- basic_machine=s390-ibm
- ;;
- s390x | s390x-*)
- basic_machine=s390x-ibm
- ;;
- sa29200)
- basic_machine=a29k-amd
- os=-udi
- ;;
- sb1)
- basic_machine=mipsisa64sb1-unknown
- ;;
- sb1el)
- basic_machine=mipsisa64sb1el-unknown
- ;;
- sei)
- basic_machine=mips-sei
- os=-seiux
- ;;
- sequent)
- basic_machine=i386-sequent
- ;;
- sh)
- basic_machine=sh-hitachi
- os=-hms
- ;;
- sh64)
- basic_machine=sh64-unknown
- ;;
- sparclite-wrs | simso-wrs)
- basic_machine=sparclite-wrs
- os=-vxworks
- ;;
- sps7)
- basic_machine=m68k-bull
- os=-sysv2
- ;;
- spur)
- basic_machine=spur-unknown
- ;;
- st2000)
- basic_machine=m68k-tandem
- ;;
- stratus)
- basic_machine=i860-stratus
- os=-sysv4
- ;;
- sun2)
- basic_machine=m68000-sun
- ;;
- sun2os3)
- basic_machine=m68000-sun
- os=-sunos3
- ;;
- sun2os4)
- basic_machine=m68000-sun
- os=-sunos4
- ;;
- sun3os3)
- basic_machine=m68k-sun
- os=-sunos3
- ;;
- sun3os4)
- basic_machine=m68k-sun
- os=-sunos4
- ;;
- sun4os3)
- basic_machine=sparc-sun
- os=-sunos3
- ;;
- sun4os4)
- basic_machine=sparc-sun
- os=-sunos4
- ;;
- sun4sol2)
- basic_machine=sparc-sun
- os=-solaris2
- ;;
- sun3 | sun3-*)
- basic_machine=m68k-sun
- ;;
- sun4)
- basic_machine=sparc-sun
- ;;
- sun386 | sun386i | roadrunner)
- basic_machine=i386-sun
- ;;
- sv1)
- basic_machine=sv1-cray
- os=-unicos
- ;;
- symmetry)
- basic_machine=i386-sequent
- os=-dynix
- ;;
- t3e)
- basic_machine=alphaev5-cray
- os=-unicos
- ;;
- t90)
- basic_machine=t90-cray
- os=-unicos
- ;;
- tic54x | c54x*)
- basic_machine=tic54x-unknown
- os=-coff
- ;;
- tic55x | c55x*)
- basic_machine=tic55x-unknown
- os=-coff
- ;;
- tic6x | c6x*)
- basic_machine=tic6x-unknown
- os=-coff
- ;;
- tx39)
- basic_machine=mipstx39-unknown
- ;;
- tx39el)
- basic_machine=mipstx39el-unknown
- ;;
- toad1)
- basic_machine=pdp10-xkl
- os=-tops20
- ;;
- tower | tower-32)
- basic_machine=m68k-ncr
- ;;
- tpf)
- basic_machine=s390x-ibm
- os=-tpf
- ;;
- udi29k)
- basic_machine=a29k-amd
- os=-udi
- ;;
- ultra3)
- basic_machine=a29k-nyu
- os=-sym1
- ;;
- v810 | necv810)
- basic_machine=v810-nec
- os=-none
- ;;
- vaxv)
- basic_machine=vax-dec
- os=-sysv
- ;;
- vms)
- basic_machine=vax-dec
- os=-vms
- ;;
- vpp*|vx|vx-*)
- basic_machine=f301-fujitsu
- ;;
- vxworks960)
- basic_machine=i960-wrs
- os=-vxworks
- ;;
- vxworks68)
- basic_machine=m68k-wrs
- os=-vxworks
- ;;
- vxworks29k)
- basic_machine=a29k-wrs
- os=-vxworks
- ;;
- w65*)
- basic_machine=w65-wdc
- os=-none
- ;;
- w89k-*)
- basic_machine=hppa1.1-winbond
- os=-proelf
- ;;
- xbox)
- basic_machine=i686-pc
- os=-mingw32
- ;;
- xps | xps100)
- basic_machine=xps100-honeywell
- ;;
- ymp)
- basic_machine=ymp-cray
- os=-unicos
- ;;
- z8k-*-coff)
- basic_machine=z8k-unknown
- os=-sim
- ;;
- none)
- basic_machine=none-none
- os=-none
- ;;
-
-# Here we handle the default manufacturer of certain CPU types. It is in
-# some cases the only manufacturer, in others, it is the most popular.
- w89k)
- basic_machine=hppa1.1-winbond
- ;;
- op50n)
- basic_machine=hppa1.1-oki
- ;;
- op60c)
- basic_machine=hppa1.1-oki
- ;;
- romp)
- basic_machine=romp-ibm
- ;;
- mmix)
- basic_machine=mmix-knuth
- ;;
- rs6000)
- basic_machine=rs6000-ibm
- ;;
- vax)
- basic_machine=vax-dec
- ;;
- pdp10)
- # there are many clones, so DEC is not a safe bet
- basic_machine=pdp10-unknown
- ;;
- pdp11)
- basic_machine=pdp11-dec
- ;;
- we32k)
- basic_machine=we32k-att
- ;;
- sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
- basic_machine=sh-unknown
- ;;
- sparc | sparcv8 | sparcv9 | sparcv9b)
- basic_machine=sparc-sun
- ;;
- cydra)
- basic_machine=cydra-cydrome
- ;;
- orion)
- basic_machine=orion-highlevel
- ;;
- orion105)
- basic_machine=clipper-highlevel
- ;;
- mac | mpw | mac-mpw)
- basic_machine=m68k-apple
- ;;
- pmac | pmac-mpw)
- basic_machine=powerpc-apple
- ;;
- *-unknown)
- # Make sure to match an already-canonicalized machine name.
- ;;
- *)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
-esac
-
-# Here we canonicalize certain aliases for manufacturers.
-case $basic_machine in
- *-digital*)
- basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
- ;;
- *-commodore*)
- basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
- ;;
- *)
- ;;
-esac
-
-# Decode manufacturer-specific aliases for certain operating systems.
-
-if [ x"$os" != x"" ]
-then
-case $os in
- # First match some system type aliases
- # that might get confused with valid system types.
- # -solaris* is a basic system type, with this one exception.
- -solaris1 | -solaris1.*)
- os=`echo $os | sed -e 's|solaris1|sunos4|'`
- ;;
- -solaris)
- os=-solaris2
- ;;
- -svr4*)
- os=-sysv4
- ;;
- -unixware*)
- os=-sysv4.2uw
- ;;
- -gnu/linux*)
- os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
- ;;
- # First accept the basic system types.
- # The portable systems comes first.
- # Each alternative MUST END IN A *, to match a version number.
- # -sysv* is not here because it comes later, after sysvr4.
- -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
- | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
- | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
- | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
- | -aos* \
- | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
- | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
- | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
- | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
- | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
- | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
- | -chorusos* | -chorusrdb* \
- | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
- | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
- | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
- | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
- | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
- | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
- | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
- | -skyos* | -haiku*)
- # Remember, each alternative MUST END IN *, to match a version number.
- ;;
- -qnx*)
- case $basic_machine in
- x86-* | i*86-*)
- ;;
- *)
- os=-nto$os
- ;;
- esac
- ;;
- -nto-qnx*)
- ;;
- -nto*)
- os=`echo $os | sed -e 's|nto|nto-qnx|'`
- ;;
- -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
- | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
- | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
- ;;
- -mac*)
- os=`echo $os | sed -e 's|mac|macos|'`
- ;;
- -linux-dietlibc)
- os=-linux-dietlibc
- ;;
- -linux*)
- os=`echo $os | sed -e 's|linux|linux-gnu|'`
- ;;
- -sunos5*)
- os=`echo $os | sed -e 's|sunos5|solaris2|'`
- ;;
- -sunos6*)
- os=`echo $os | sed -e 's|sunos6|solaris3|'`
- ;;
- -opened*)
- os=-openedition
- ;;
- -os400*)
- os=-os400
- ;;
- -wince*)
- os=-wince
- ;;
- -osfrose*)
- os=-osfrose
- ;;
- -osf*)
- os=-osf
- ;;
- -utek*)
- os=-bsd
- ;;
- -dynix*)
- os=-bsd
- ;;
- -acis*)
- os=-aos
- ;;
- -atheos*)
- os=-atheos
- ;;
- -syllable*)
- os=-syllable
- ;;
- -386bsd)
- os=-bsd
- ;;
- -ctix* | -uts*)
- os=-sysv
- ;;
- -nova*)
- os=-rtmk-nova
- ;;
- -ns2 )
- os=-nextstep2
- ;;
- -nsk*)
- os=-nsk
- ;;
- # Preserve the version number of sinix5.
- -sinix5.*)
- os=`echo $os | sed -e 's|sinix|sysv|'`
- ;;
- -sinix*)
- os=-sysv4
- ;;
- -tpf*)
- os=-tpf
- ;;
- -triton*)
- os=-sysv3
- ;;
- -oss*)
- os=-sysv3
- ;;
- -svr4)
- os=-sysv4
- ;;
- -svr3)
- os=-sysv3
- ;;
- -sysvr4)
- os=-sysv4
- ;;
- # This must come after -sysvr4.
- -sysv*)
- ;;
- -ose*)
- os=-ose
- ;;
- -es1800*)
- os=-ose
- ;;
- -xenix)
- os=-xenix
- ;;
- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
- os=-mint
- ;;
- -aros*)
- os=-aros
- ;;
- -kaos*)
- os=-kaos
- ;;
- -zvmoe)
- os=-zvmoe
- ;;
- -none)
- ;;
- *)
- # Get rid of the `-' at the beginning of $os.
- os=`echo $os | sed 's/[^-]*-//'`
- echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
- exit 1
- ;;
-esac
-else
-
-# Here we handle the default operating systems that come with various machines.
-# The value should be what the vendor currently ships out the door with their
-# machine or put another way, the most popular os provided with the machine.
-
-# Note that if you're going to try to match "-MANUFACTURER" here (say,
-# "-sun"), then you have to tell the case statement up towards the top
-# that MANUFACTURER isn't an operating system. Otherwise, code above
-# will signal an error saying that MANUFACTURER isn't an operating
-# system, and we'll never get to this point.
-
-case $basic_machine in
- *-acorn)
- os=-riscix1.2
- ;;
- arm*-rebel)
- os=-linux
- ;;
- arm*-semi)
- os=-aout
- ;;
- c4x-* | tic4x-*)
- os=-coff
- ;;
- # This must come before the *-dec entry.
- pdp10-*)
- os=-tops20
- ;;
- pdp11-*)
- os=-none
- ;;
- *-dec | vax-*)
- os=-ultrix4.2
- ;;
- m68*-apollo)
- os=-domain
- ;;
- i386-sun)
- os=-sunos4.0.2
- ;;
- m68000-sun)
- os=-sunos3
- # This also exists in the configure program, but was not the
- # default.
- # os=-sunos4
- ;;
- m68*-cisco)
- os=-aout
- ;;
- mips*-cisco)
- os=-elf
- ;;
- mips*-*)
- os=-elf
- ;;
- or32-*)
- os=-coff
- ;;
- *-tti) # must be before sparc entry or we get the wrong os.
- os=-sysv3
- ;;
- sparc-* | *-sun)
- os=-sunos4.1.1
- ;;
- *-be)
- os=-beos
- ;;
- *-haiku)
- os=-haiku
- ;;
- *-ibm)
- os=-aix
- ;;
- *-knuth)
- os=-mmixware
- ;;
- *-wec)
- os=-proelf
- ;;
- *-winbond)
- os=-proelf
- ;;
- *-oki)
- os=-proelf
- ;;
- *-hp)
- os=-hpux
- ;;
- *-hitachi)
- os=-hiux
- ;;
- i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
- os=-sysv
- ;;
- *-cbm)
- os=-amigaos
- ;;
- *-dg)
- os=-dgux
- ;;
- *-dolphin)
- os=-sysv3
- ;;
- m68k-ccur)
- os=-rtu
- ;;
- m88k-omron*)
- os=-luna
- ;;
- *-next )
- os=-nextstep
- ;;
- *-sequent)
- os=-ptx
- ;;
- *-crds)
- os=-unos
- ;;
- *-ns)
- os=-genix
- ;;
- i370-*)
- os=-mvs
- ;;
- *-next)
- os=-nextstep3
- ;;
- *-gould)
- os=-sysv
- ;;
- *-highlevel)
- os=-bsd
- ;;
- *-encore)
- os=-bsd
- ;;
- *-sgi)
- os=-irix
- ;;
- *-siemens)
- os=-sysv4
- ;;
- *-masscomp)
- os=-rtu
- ;;
- f30[01]-fujitsu | f700-fujitsu)
- os=-uxpv
- ;;
- *-rom68k)
- os=-coff
- ;;
- *-*bug)
- os=-coff
- ;;
- *-apple)
- os=-macos
- ;;
- *-atari*)
- os=-mint
- ;;
- *)
- os=-none
- ;;
-esac
-fi
-
-# Here we handle the case where we know the os, and the CPU type, but not the
-# manufacturer. We pick the logical manufacturer.
-vendor=unknown
-case $basic_machine in
- *-unknown)
- case $os in
- -riscix*)
- vendor=acorn
- ;;
- -sunos*)
- vendor=sun
- ;;
- -aix*)
- vendor=ibm
- ;;
- -beos*)
- vendor=be
- ;;
- -hpux*)
- vendor=hp
- ;;
- -mpeix*)
- vendor=hp
- ;;
- -hiux*)
- vendor=hitachi
- ;;
- -unos*)
- vendor=crds
- ;;
- -dgux*)
- vendor=dg
- ;;
- -luna*)
- vendor=omron
- ;;
- -genix*)
- vendor=ns
- ;;
- -mvs* | -opened*)
- vendor=ibm
- ;;
- -os400*)
- vendor=ibm
- ;;
- -ptx*)
- vendor=sequent
- ;;
- -tpf*)
- vendor=ibm
- ;;
- -vxsim* | -vxworks* | -windiss*)
- vendor=wrs
- ;;
- -aux*)
- vendor=apple
- ;;
- -hms*)
- vendor=hitachi
- ;;
- -mpw* | -macos*)
- vendor=apple
- ;;
- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
- vendor=atari
- ;;
- -vos*)
- vendor=stratus
- ;;
- esac
- basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
- ;;
-esac
-
-echo $basic_machine$os
-exit
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac
deleted file mode 100644
index 81997e09b7..0000000000
--- a/source4/lib/replace/configure.ac
+++ /dev/null
@@ -1,30 +0,0 @@
-AC_PREREQ(2.50)
-AC_INIT(replace.c)
-AC_CONFIG_SRCDIR([replace.c])
-AC_CONFIG_HEADER(config.h)
-
-CFLAGS="$CFLAGS -I$srcdir"
-
-AC_LIBREPLACE_ALL_CHECKS
-AC_LIBREPLACE_NETWORK_CHECKS
-
-if test "$ac_cv_prog_gcc" = yes; then
- CFLAGS="$CFLAGS -Wall"
- CFLAGS="$CFLAGS -W"
- CFLAGS="$CFLAGS -Wshadow"
- CFLAGS="$CFLAGS -Wstrict-prototypes"
- CFLAGS="$CFLAGS -Wpointer-arith"
- CFLAGS="$CFLAGS -Wcast-qual"
- CFLAGS="$CFLAGS -Wcast-align"
- CFLAGS="$CFLAGS -Wwrite-strings"
- CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
- CFLAGS="$CFLAGS -Wformat=2"
- CFLAGS="$CFLAGS -Wno-format-y2k"
-fi
-
-LIBS="${LIBREPLACE_NETWORK_LIBS}"
-AC_SUBST(LIBS)
-
-AC_SUBST(LDFLAGS)
-
-AC_OUTPUT(Makefile)
diff --git a/source4/lib/replace/dlfcn.c b/source4/lib/replace/dlfcn.c
deleted file mode 100644
index 3b109d7e40..0000000000
--- a/source4/lib/replace/dlfcn.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba system utilities
- Copyright (C) Andrew Tridgell 1992-1998
- Copyright (C) Jeremy Allison 1998-2002
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "replace.h"
-#ifdef HAVE_DL_H
-#include <dl.h>
-#endif
-
-#ifndef HAVE_DLOPEN
-#ifdef DLOPEN_TAKES_UNSIGNED_FLAGS
-void *rep_dlopen(const char *name, unsigned int flags)
-#else
-void *rep_dlopen(const char *name, int flags)
-#endif
-{
-#ifdef HAVE_SHL_LOAD
- if (name == NULL)
- return PROG_HANDLE;
- return (void *)shl_load(name, flags, 0);
-#else
- return NULL;
-#endif
-}
-#endif
-
-#ifndef HAVE_DLSYM
-void *rep_dlsym(void *handle, const char *symbol)
-{
-#ifdef HAVE_SHL_FINDSYM
- void *sym_addr;
- if (!shl_findsym((shl_t *)&handle, symbol, TYPE_UNDEFINED, &sym_addr))
- return sym_addr;
-#endif
- return NULL;
-}
-#endif
-
-#ifndef HAVE_DLERROR
-char *rep_dlerror(void)
-{
- return "dynamic loading of objects not supported on this platform";
-}
-#endif
-
-#ifndef HAVE_DLCLOSE
-int rep_dlclose(void *handle)
-{
-#ifdef HAVE_SHL_CLOSE
- return shl_unload((shl_t)handle);
-#else
- return 0;
-#endif
-}
-#endif
diff --git a/source4/lib/replace/dlfcn.m4 b/source4/lib/replace/dlfcn.m4
deleted file mode 100644
index 42f56f26be..0000000000
--- a/source4/lib/replace/dlfcn.m4
+++ /dev/null
@@ -1,31 +0,0 @@
-dnl dummies provided by dlfcn.c if not available
-save_LIBS="$LIBS"
-LIBS=""
-
-libreplace_cv_dlfcn=no
-AC_SEARCH_LIBS(dlopen, dl)
-
-AC_CHECK_HEADERS(dlfcn.h)
-AC_CHECK_FUNCS([dlopen dlsym dlerror dlclose],[],[libreplace_cv_dlfcn=yes])
-
-libreplace_cv_shl=no
-AC_SEARCH_LIBS(shl_load, sl)
-AC_CHECK_HEADERS(dl.h)
-AC_CHECK_FUNCS([shl_load shl_unload shl_findsym],[],[libreplace_cv_shl=yes])
-
-AC_VERIFY_C_PROTOTYPE([void *dlopen(const char* filename, unsigned int flags)],
- [
- return 0;
- ],[
- AC_DEFINE(DLOPEN_TAKES_UNSIGNED_FLAGS, 1, [Whether dlopen takes unsigned int flags])
- ],[],[
- #include <dlfcn.h>
- ])
-
-if test x"${libreplace_cv_dlfcn}" = x"yes";then
- LIBREPLACEOBJ="${LIBREPLACEOBJ} dlfcn.o"
-fi
-
-LIBDL="$LIBS"
-AC_SUBST(LIBDL)
-LIBS="$save_LIBS"
diff --git a/source4/lib/replace/getaddrinfo.c b/source4/lib/replace/getaddrinfo.c
deleted file mode 100644
index c5cd52be93..0000000000
--- a/source4/lib/replace/getaddrinfo.c
+++ /dev/null
@@ -1,497 +0,0 @@
-/*
-PostgreSQL Database Management System
-(formerly known as Postgres, then as Postgres95)
-
-Portions Copyright (c) 1996-2005, The PostgreSQL Global Development Group
-
-Portions Copyright (c) 1994, The Regents of the University of California
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose, without fee, and without a written agreement
-is hereby granted, provided that the above copyright notice and this paragraph
-and the following two paragraphs appear in all copies.
-
-IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
-DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
-LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
-EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
-THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
-INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
-AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
-ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS
-TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
-*/
-
-/*-------------------------------------------------------------------------
- *
- * getaddrinfo.c
- * Support getaddrinfo() on platforms that don't have it.
- *
- * We also supply getnameinfo() here, assuming that the platform will have
- * it if and only if it has getaddrinfo(). If this proves false on some
- * platform, we'll need to split this file and provide a separate configure
- * test for getnameinfo().
- *
- * Copyright (c) 2003-2007, PostgreSQL Global Development Group
- *
- * Copyright (C) 2007 Jeremy Allison.
- * Modified to return multiple IPv4 addresses for Samba.
- *
- *-------------------------------------------------------------------------
- */
-
-#include "replace.h"
-#include "system/network.h"
-
-#ifndef SMB_MALLOC
-#define SMB_MALLOC(s) malloc(s)
-#endif
-
-#ifndef SMB_STRDUP
-#define SMB_STRDUP(s) strdup(s)
-#endif
-
-static int check_hostent_err(struct hostent *hp)
-{
- if (!hp) {
- switch (h_errno) {
- case HOST_NOT_FOUND:
- case NO_DATA:
- return EAI_NONAME;
- case TRY_AGAIN:
- return EAI_AGAIN;
- case NO_RECOVERY:
- default:
- return EAI_FAIL;
- }
- }
- if (!hp->h_name || hp->h_addrtype != AF_INET) {
- return EAI_FAIL;
- }
- return 0;
-}
-
-static char *canon_name_from_hostent(struct hostent *hp,
- int *perr)
-{
- char *ret = NULL;
-
- *perr = check_hostent_err(hp);
- if (*perr) {
- return NULL;
- }
- ret = SMB_STRDUP(hp->h_name);
- if (!ret) {
- *perr = EAI_MEMORY;
- }
- return ret;
-}
-
-static char *get_my_canon_name(int *perr)
-{
- char name[HOST_NAME_MAX+1];
-
- if (gethostname(name, HOST_NAME_MAX) == -1) {
- *perr = EAI_FAIL;
- return NULL;
- }
- /* Ensure null termination. */
- name[HOST_NAME_MAX] = '\0';
- return canon_name_from_hostent(gethostbyname(name), perr);
-}
-
-static char *get_canon_name_from_addr(struct in_addr ip,
- int *perr)
-{
- return canon_name_from_hostent(
- gethostbyaddr(&ip, sizeof(ip), AF_INET),
- perr);
-}
-
-static struct addrinfo *alloc_entry(const struct addrinfo *hints,
- struct in_addr ip,
- unsigned short port)
-{
- struct sockaddr_in *psin = NULL;
- struct addrinfo *ai = SMB_MALLOC(sizeof(*ai));
-
- if (!ai) {
- return NULL;
- }
- memset(ai, '\0', sizeof(*ai));
-
- psin = SMB_MALLOC(sizeof(*psin));
- if (!psin) {
- free(ai);
- return NULL;
- }
-
- memset(psin, '\0', sizeof(*psin));
-
- psin->sin_family = AF_INET;
- psin->sin_port = htons(port);
- psin->sin_addr = ip;
-
- ai->ai_flags = 0;
- ai->ai_family = AF_INET;
- ai->ai_socktype = hints->ai_socktype;
- ai->ai_protocol = hints->ai_protocol;
- ai->ai_addrlen = sizeof(*psin);
- ai->ai_addr = (struct sockaddr *) psin;
- ai->ai_canonname = NULL;
- ai->ai_next = NULL;
-
- return ai;
-}
-
-/*
- * get address info for a single ipv4 address.
- *
- * Bugs: - servname can only be a number, not text.
- */
-
-static int getaddr_info_single_addr(const char *service,
- uint32_t addr,
- const struct addrinfo *hints,
- struct addrinfo **res)
-{
-
- struct addrinfo *ai = NULL;
- struct in_addr ip;
- unsigned short port = 0;
-
- if (service) {
- port = (unsigned short)atoi(service);
- }
- ip.s_addr = htonl(addr);
-
- ai = alloc_entry(hints, ip, port);
- if (!ai) {
- return EAI_MEMORY;
- }
-
- /* If we're asked for the canonical name,
- * make sure it returns correctly. */
- if (!(hints->ai_flags & AI_NUMERICSERV) &&
- hints->ai_flags & AI_CANONNAME) {
- int err;
- if (addr == INADDR_LOOPBACK || addr == INADDR_ANY) {
- ai->ai_canonname = get_my_canon_name(&err);
- } else {
- ai->ai_canonname =
- get_canon_name_from_addr(ip,&err);
- }
- if (ai->ai_canonname == NULL) {
- freeaddrinfo(ai);
- return err;
- }
- }
-
- *res = ai;
- return 0;
-}
-
-/*
- * get address info for multiple ipv4 addresses.
- *
- * Bugs: - servname can only be a number, not text.
- */
-
-static int getaddr_info_name(const char *node,
- const char *service,
- const struct addrinfo *hints,
- struct addrinfo **res)
-{
- struct addrinfo *listp = NULL, *prevp = NULL;
- char **pptr = NULL;
- int err;
- struct hostent *hp = NULL;
- unsigned short port = 0;
-
- if (service) {
- port = (unsigned short)atoi(service);
- }
-
- hp = gethostbyname(node);
- err = check_hostent_err(hp);
- if (err) {
- return err;
- }
-
- for(pptr = hp->h_addr_list; *pptr; pptr++) {
- struct in_addr ip = *(struct in_addr *)*pptr;
- struct addrinfo *ai = alloc_entry(hints, ip, port);
-
- if (!ai) {
- freeaddrinfo(listp);
- return EAI_MEMORY;
- }
-
- if (!listp) {
- listp = ai;
- prevp = ai;
- ai->ai_canonname = SMB_STRDUP(hp->h_name);
- if (!ai->ai_canonname) {
- freeaddrinfo(listp);
- return EAI_MEMORY;
- }
- } else {
- prevp->ai_next = ai;
- prevp = ai;
- }
- }
- *res = listp;
- return 0;
-}
-
-/*
- * get address info for ipv4 sockets.
- *
- * Bugs: - servname can only be a number, not text.
- */
-
-int rep_getaddrinfo(const char *node,
- const char *service,
- const struct addrinfo * hintp,
- struct addrinfo ** res)
-{
- struct addrinfo hints;
-
- /* Setup the hints struct. */
- if (hintp == NULL) {
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_INET;
- hints.ai_socktype = SOCK_STREAM;
- } else {
- memcpy(&hints, hintp, sizeof(hints));
- }
-
- if (hints.ai_family != AF_INET && hints.ai_family != AF_UNSPEC) {
- return EAI_FAMILY;
- }
-
- if (hints.ai_socktype == 0) {
- hints.ai_socktype = SOCK_STREAM;
- }
-
- if (!node && !service) {
- return EAI_NONAME;
- }
-
- if (node) {
- if (node[0] == '\0') {
- return getaddr_info_single_addr(service,
- INADDR_ANY,
- &hints,
- res);
- } else if (hints.ai_flags & AI_NUMERICHOST) {
- struct in_addr ip;
- if (!inet_aton(node, &ip)) {
- return EAI_FAIL;
- }
- return getaddr_info_single_addr(service,
- ntohl(ip.s_addr),
- &hints,
- res);
- } else {
- return getaddr_info_name(node,
- service,
- &hints,
- res);
- }
- } else if (hints.ai_flags & AI_PASSIVE) {
- return getaddr_info_single_addr(service,
- INADDR_ANY,
- &hints,
- res);
- }
- return getaddr_info_single_addr(service,
- INADDR_LOOPBACK,
- &hints,
- res);
-}
-
-
-void rep_freeaddrinfo(struct addrinfo *res)
-{
- struct addrinfo *next = NULL;
-
- for (;res; res = next) {
- next = res->ai_next;
- if (res->ai_canonname) {
- free(res->ai_canonname);
- }
- if (res->ai_addr) {
- free(res->ai_addr);
- }
- free(res);
- }
-}
-
-
-const char *rep_gai_strerror(int errcode)
-{
-#ifdef HAVE_HSTRERROR
- int hcode;
-
- switch (errcode)
- {
- case EAI_NONAME:
- hcode = HOST_NOT_FOUND;
- break;
- case EAI_AGAIN:
- hcode = TRY_AGAIN;
- break;
- case EAI_FAIL:
- default:
- hcode = NO_RECOVERY;
- break;
- }
-
- return hstrerror(hcode);
-#else /* !HAVE_HSTRERROR */
-
- switch (errcode)
- {
- case EAI_NONAME:
- return "Unknown host";
- case EAI_AGAIN:
- return "Host name lookup failure";
-#ifdef EAI_BADFLAGS
- case EAI_BADFLAGS:
- return "Invalid argument";
-#endif
-#ifdef EAI_FAMILY
- case EAI_FAMILY:
- return "Address family not supported";
-#endif
-#ifdef EAI_MEMORY
- case EAI_MEMORY:
- return "Not enough memory";
-#endif
-#ifdef EAI_NODATA
- case EAI_NODATA:
- return "No host data of that type was found";
-#endif
-#ifdef EAI_SERVICE
- case EAI_SERVICE:
- return "Class type not found";
-#endif
-#ifdef EAI_SOCKTYPE
- case EAI_SOCKTYPE:
- return "Socket type not supported";
-#endif
- default:
- return "Unknown server error";
- }
-#endif /* HAVE_HSTRERROR */
-}
-
-static int gethostnameinfo(const struct sockaddr *sa,
- char *node,
- size_t nodelen,
- int flags)
-{
- int ret = -1;
- char *p = NULL;
-
- if (!(flags & NI_NUMERICHOST)) {
- struct hostent *hp = gethostbyaddr(
- &((struct sockaddr_in *)sa)->sin_addr,
- sizeof(struct in_addr),
- sa->sa_family);
- ret = check_hostent_err(hp);
- if (ret == 0) {
- /* Name looked up successfully. */
- ret = snprintf(node, nodelen, "%s", hp->h_name);
- if (ret < 0 || (size_t)ret >= nodelen) {
- return EAI_MEMORY;
- }
- if (flags & NI_NOFQDN) {
- p = strchr(node,'.');
- if (p) {
- *p = '\0';
- }
- }
- return 0;
- }
-
- if (flags & NI_NAMEREQD) {
- /* If we require a name and didn't get one,
- * automatically fail. */
- return ret;
- }
- /* Otherwise just fall into the numeric host code... */
- }
- p = inet_ntoa(((struct sockaddr_in *)sa)->sin_addr);
- ret = snprintf(node, nodelen, "%s", p);
- if (ret < 0 || (size_t)ret >= nodelen) {
- return EAI_MEMORY;
- }
- return 0;
-}
-
-static int getservicenameinfo(const struct sockaddr *sa,
- char *service,
- size_t servicelen,
- int flags)
-{
- int ret = -1;
- int port = ntohs(((struct sockaddr_in *)sa)->sin_port);
-
- if (!(flags & NI_NUMERICSERV)) {
- struct servent *se = getservbyport(
- port,
- (flags & NI_DGRAM) ? "udp" : "tcp");
- if (se && se->s_name) {
- /* Service name looked up successfully. */
- ret = snprintf(service, servicelen, "%s", se->s_name);
- if (ret < 0 || (size_t)ret >= servicelen) {
- return EAI_MEMORY;
- }
- return 0;
- }
- /* Otherwise just fall into the numeric service code... */
- }
- ret = snprintf(service, servicelen, "%d", port);
- if (ret < 0 || (size_t)ret >= servicelen) {
- return EAI_MEMORY;
- }
- return 0;
-}
-
-/*
- * Convert an ipv4 address to a hostname.
- *
- * Bugs: - No IPv6 support.
- */
-int rep_getnameinfo(const struct sockaddr *sa, socklen_t salen,
- char *node, size_t nodelen,
- char *service, size_t servicelen, int flags)
-{
-
- /* Invalid arguments. */
- if (sa == NULL || (node == NULL && service == NULL)) {
- return EAI_FAIL;
- }
-
- if (sa->sa_family != AF_INET) {
- return EAI_FAIL;
- }
-
- if (salen < sizeof(struct sockaddr_in)) {
- return EAI_FAIL;
- }
-
- if (node) {
- return gethostnameinfo(sa, node, nodelen, flags);
- }
-
- if (service) {
- return getservicenameinfo(sa, service, servicelen, flags);
- }
- return 0;
-}
diff --git a/source4/lib/replace/getaddrinfo.h b/source4/lib/replace/getaddrinfo.h
deleted file mode 100644
index dddd699b62..0000000000
--- a/source4/lib/replace/getaddrinfo.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-PostgreSQL Database Management System
-(formerly known as Postgres, then as Postgres95)
-
-Portions Copyright (c) 1996-2005, The PostgreSQL Global Development Group
-
-Portions Copyright (c) 1994, The Regents of the University of California
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose, without fee, and without a written agreement
-is hereby granted, provided that the above copyright notice and this paragraph
-and the following two paragraphs appear in all copies.
-
-IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
-DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
-LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
-EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
-THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
-INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
-AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
-ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS
-TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
-*/
-
-/*-------------------------------------------------------------------------
- *
- * getaddrinfo.h
- * Support getaddrinfo() on platforms that don't have it.
- *
- * Note: we use our own routines on platforms that don't HAVE_STRUCT_ADDRINFO,
- * whether or not the library routine getaddrinfo() can be found. This
- * policy is needed because on some platforms a manually installed libbind.a
- * may provide getaddrinfo(), yet the system headers may not provide the
- * struct definitions needed to call it. To avoid conflict with the libbind
- * definition in such cases, we rename our routines to pg_xxx() via macros.
- *
-
-in lib/replace we use rep_xxx()
-
- * This code will also work on platforms where struct addrinfo is defined
- * in the system headers but no getaddrinfo() can be located.
- *
- * Copyright (c) 2003-2007, PostgreSQL Global Development Group
- *
- *-------------------------------------------------------------------------
- */
-#ifndef GETADDRINFO_H
-#define GETADDRINFO_H
-
-#ifndef HAVE_GETADDRINFO
-
-/* Rename private copies per comments above */
-#ifdef getaddrinfo
-#undef getaddrinfo
-#endif
-#define getaddrinfo rep_getaddrinfo
-#define HAVE_GETADDRINFO
-
-#ifdef freeaddrinfo
-#undef freeaddrinfo
-#endif
-#define freeaddrinfo rep_freeaddrinfo
-#define HAVE_FREEADDRINFO
-
-#ifdef gai_strerror
-#undef gai_strerror
-#endif
-#define gai_strerror rep_gai_strerror
-#define HAVE_GAI_STRERROR
-
-#ifdef getnameinfo
-#undef getnameinfo
-#endif
-#define getnameinfo rep_getnameinfo
-#define HAVE_GETNAMEINFO
-
-extern int rep_getaddrinfo(const char *node, const char *service,
- const struct addrinfo * hints, struct addrinfo ** res);
-extern void rep_freeaddrinfo(struct addrinfo * res);
-extern const char *rep_gai_strerror(int errcode);
-extern int rep_getnameinfo(const struct sockaddr * sa, socklen_t salen,
- char *node, size_t nodelen,
- char *service, size_t servicelen, int flags);
-#endif /* HAVE_GETADDRINFO */
-
-#endif /* GETADDRINFO_H */
diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c
deleted file mode 100644
index f6f0ec080c..0000000000
--- a/source4/lib/replace/getifaddrs.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba utility functions
- Copyright (C) Andrew Tridgell 1998
- Copyright (C) Jeremy Allison 2007
- Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#define SOCKET_WRAPPER_NOT_REPLACE
-
-#include "replace.h"
-#include "system/network.h"
-
-#include <unistd.h>
-#include <stdio.h>
-#include <sys/types.h>
-
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-
-#ifndef SIOCGIFCONF
-#ifdef HAVE_SYS_SOCKIO_H
-#include <sys/sockio.h>
-#endif
-#endif
-
-#ifdef HAVE_IFACE_GETIFADDRS
-#define _FOUND_IFACE_ANY
-#else
-
-void rep_freeifaddrs(struct ifaddrs *ifp)
-{
- if (ifp != NULL) {
- free(ifp->ifa_name);
- free(ifp->ifa_addr);
- free(ifp->ifa_netmask);
- free(ifp->ifa_dstaddr);
- freeifaddrs(ifp->ifa_next);
- free(ifp);
- }
-}
-
-static struct sockaddr *sockaddr_dup(struct sockaddr *sa)
-{
- struct sockaddr *ret;
- socklen_t socklen;
-#ifdef HAVE_SOCKADDR_SA_LEN
- socklen = sa->sa_len;
-#else
- socklen = sizeof(struct sockaddr_storage);
-#endif
- ret = calloc(1, socklen);
- if (ret == NULL)
- return NULL;
- memcpy(ret, sa, socklen);
- return ret;
-}
-#endif
-
-#if HAVE_IFACE_IFCONF
-
-/* this works for Linux 2.2, Solaris 2.5, SunOS4, HPUX 10.20, OSF1
- V4.0, Ultrix 4.4, SCO Unix 3.2, IRIX 6.4 and FreeBSD 3.2.
-
- It probably also works on any BSD style system. */
-
-int rep_getifaddrs(struct ifaddrs **ifap)
-{
- struct ifconf ifc;
- char buff[8192];
- int fd, i, n;
- struct ifreq *ifr=NULL;
- struct in_addr ipaddr;
- struct in_addr nmask;
- char *iname;
- struct ifaddrs *curif;
- struct ifaddrs *lastif = NULL;
-
- *ifap = NULL;
-
- if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
- return -1;
- }
-
- ifc.ifc_len = sizeof(buff);
- ifc.ifc_buf = buff;
-
- if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) {
- close(fd);
- return -1;
- }
-
- ifr = ifc.ifc_req;
-
- n = ifc.ifc_len / sizeof(struct ifreq);
-
- /* Loop through interfaces, looking for given IP address */
- for (i=n-1; i>=0; i--) {
- if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) == -1) {
- freeifaddrs(*ifap);
- return -1;
- }
-
- curif = calloc(1, sizeof(struct ifaddrs));
- curif->ifa_name = strdup(ifr[i].ifr_name);
- curif->ifa_flags = ifr[i].ifr_flags;
- curif->ifa_dstaddr = NULL;
- curif->ifa_data = NULL;
- curif->ifa_next = NULL;
-
- curif->ifa_addr = NULL;
- if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != -1) {
- curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr);
- }
-
- curif->ifa_netmask = NULL;
- if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != -1) {
- curif->ifa_netmask = sockaddr_dup(&ifr[i].ifr_addr);
- }
-
- if (lastif == NULL) {
- *ifap = curif;
- } else {
- lastif->ifa_next = curif;
- }
- lastif = curif;
- }
-
- close(fd);
-
- return 0;
-}
-
-#define _FOUND_IFACE_ANY
-#endif /* HAVE_IFACE_IFCONF */
-#ifdef HAVE_IFACE_IFREQ
-
-#ifndef I_STR
-#include <sys/stropts.h>
-#endif
-
-/****************************************************************************
-this should cover most of the streams based systems
-Thanks to Andrej.Borsenkow@mow.siemens.ru for several ideas in this code
-****************************************************************************/
-int rep_getifaddrs(struct ifaddrs **ifap)
-{
- struct ifreq ifreq;
- struct strioctl strioctl;
- char buff[8192];
- int fd, i, n;
- struct ifreq *ifr=NULL;
- struct in_addr ipaddr;
- struct in_addr nmask;
- char *iname;
- struct ifaddrs *curif;
- struct ifaddrs *lastif = NULL;
-
- *ifap = NULL;
-
- if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
- return -1;
- }
-
- strioctl.ic_cmd = SIOCGIFCONF;
- strioctl.ic_dp = buff;
- strioctl.ic_len = sizeof(buff);
- if (ioctl(fd, I_STR, &strioctl) < 0) {
- close(fd);
- return -1;
- }
-
- /* we can ignore the possible sizeof(int) here as the resulting
- number of interface structures won't change */
- n = strioctl.ic_len / sizeof(struct ifreq);
-
- /* we will assume that the kernel returns the length as an int
- at the start of the buffer if the offered size is a
- multiple of the structure size plus an int */
- if (n*sizeof(struct ifreq) + sizeof(int) == strioctl.ic_len) {
- ifr = (struct ifreq *)(buff + sizeof(int));
- } else {
- ifr = (struct ifreq *)buff;
- }
-
- /* Loop through interfaces */
-
- for (i = 0; i<n; i++) {
- ifreq = ifr[i];
-
- curif = calloc(1, sizeof(struct ifaddrs));
- if (lastif == NULL) {
- *ifap = curif;
- } else {
- lastif->ifa_next = curif;
- }
-
- strioctl.ic_cmd = SIOCGIFFLAGS;
- strioctl.ic_dp = (char *)&ifreq;
- strioctl.ic_len = sizeof(struct ifreq);
- if (ioctl(fd, I_STR, &strioctl) != 0) {
- freeifaddrs(*ifap);
- return -1;
- }
-
- curif->ifa_flags = ifreq.ifr_flags;
-
- strioctl.ic_cmd = SIOCGIFADDR;
- strioctl.ic_dp = (char *)&ifreq;
- strioctl.ic_len = sizeof(struct ifreq);
- if (ioctl(fd, I_STR, &strioctl) != 0) {
- freeifaddrs(*ifap);
- return -1;
- }
-
- curif->ifa_name = strdup(ifreq.ifr_name);
- curif->ifa_addr = sockaddr_dup(&ifreq.ifr_addr);
- curif->ifa_dstaddr = NULL;
- curif->ifa_data = NULL;
- curif->ifa_next = NULL;
- curif->ifa_netmask = NULL;
-
- strioctl.ic_cmd = SIOCGIFNETMASK;
- strioctl.ic_dp = (char *)&ifreq;
- strioctl.ic_len = sizeof(struct ifreq);
- if (ioctl(fd, I_STR, &strioctl) != 0) {
- freeifaddrs(*ifap);
- return -1;
- }
-
- curif->ifa_netmask = sockaddr_dup(&ifreq.ifr_addr);
-
- lastif = curif;
- }
-
- close(fd);
-
- return 0;
-}
-
-#define _FOUND_IFACE_ANY
-#endif /* HAVE_IFACE_IFREQ */
-#ifdef HAVE_IFACE_AIX
-
-/****************************************************************************
-this one is for AIX (tested on 4.2)
-****************************************************************************/
-int rep_getifaddrs(struct ifaddrs **ifap)
-{
- char buff[8192];
- int fd, i;
- struct ifconf ifc;
- struct ifreq *ifr=NULL;
- struct in_addr ipaddr;
- struct in_addr nmask;
- char *iname;
- struct ifaddrs *curif;
- struct ifaddrs *lastif = NULL;
-
- *ifap = NULL;
-
- if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
- return -1;
- }
-
- ifc.ifc_len = sizeof(buff);
- ifc.ifc_buf = buff;
-
- if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) {
- close(fd);
- return -1;
- }
-
- ifr = ifc.ifc_req;
-
- /* Loop through interfaces */
- i = ifc.ifc_len;
-
- while (i > 0) {
- uint_t inc;
-
- inc = ifr->ifr_addr.sa_len;
-
- if (ioctl(fd, SIOCGIFADDR, ifr) != 0) {
- freeaddrinfo(*ifap);
- return -1;
- }
-
- curif = calloc(1, sizeof(struct ifaddrs));
- if (lastif == NULL) {
- *ifap = curif;
- } else {
- lastif->ifa_next = curif;
- }
-
- curif->ifa_name = strdup(ifr->ifr_name);
- curif->ifa_addr = sockaddr_dup(&ifr->ifr_addr);
- curif->ifa_dstaddr = NULL;
- curif->ifa_data = NULL;
- curif->ifa_netmask = NULL;
- curif->ifa_next = NULL;
-
- if (ioctl(fd, SIOCGIFFLAGS, ifr) != 0) {
- freeaddrinfo(*ifap);
- return -1;
- }
-
- curif->ifa_flags = ifr->ifr_flags;
-
- if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) {
- freeaddrinfo(*ifap);
- return -1;
- }
-
- curif->ifa_netmask = sockaddr_dup(&ifr->ifr_addr);
-
- lastif = curif;
-
- next:
- /*
- * Patch from Archie Cobbs (archie@whistle.com). The
- * addresses in the SIOCGIFCONF interface list have a
- * minimum size. Usually this doesn't matter, but if
- * your machine has tunnel interfaces, etc. that have
- * a zero length "link address", this does matter. */
-
- if (inc < sizeof(ifr->ifr_addr))
- inc = sizeof(ifr->ifr_addr);
- inc += IFNAMSIZ;
-
- ifr = (struct ifreq*) (((char*) ifr) + inc);
- i -= inc;
- }
-
- close(fd);
- return 0;
-}
-
-#define _FOUND_IFACE_ANY
-#endif /* HAVE_IFACE_AIX */
-#ifndef _FOUND_IFACE_ANY
-int rep_getifaddrs(struct ifaddrs **ifap)
-{
- errno = ENOSYS;
- return -1;
-}
-#endif
diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c
deleted file mode 100644
index 0be618fc91..0000000000
--- a/source4/lib/replace/getpass.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/* Copyright (C) 1992-1998 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public License as
-published by the Free Software Foundation; either version 3 of the
-License, or (at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, see <http://www.gnu.org/licenses/>. */
-
-/* Modified to use with samba by Jeremy Allison, 8th July 1995. */
-
-#include "replace.h"
-#include "system/filesys.h"
-#include "system/wait.h"
-#include "system/terminal.h"
-#include "system/passwd.h"
-
-/*
- * Define additional missing types
- */
-#ifndef HAVE_SIG_ATOMIC_T_TYPE
-typedef int sig_atomic_t;
-#endif
-
-#ifndef SIGCLD
-#define SIGCLD SIGCHLD
-#endif
-
-#ifndef SIGNAL_CAST
-#define SIGNAL_CAST (RETSIGTYPE (*)(int))
-#endif
-
-#ifdef SYSV_TERMIO
-
-/* SYSTEM V TERMIO HANDLING */
-
-static struct termio t;
-
-#define ECHO_IS_ON(t) ((t).c_lflag & ECHO)
-#define TURN_ECHO_OFF(t) ((t).c_lflag &= ~ECHO)
-#define TURN_ECHO_ON(t) ((t).c_lflag |= ECHO)
-
-#ifndef TCSAFLUSH
-#define TCSAFLUSH 1
-#endif
-
-#ifndef TCSANOW
-#define TCSANOW 0
-#endif
-
-static int tcgetattr(int fd, struct termio *_t)
-{
- return ioctl(fd, TCGETA, _t);
-}
-
-static int tcsetattr(int fd, int flags, struct termio *_t)
-{
- if(flags & TCSAFLUSH)
- ioctl(fd, TCFLSH, TCIOFLUSH);
- return ioctl(fd, TCSETS, _t);
-}
-
-#elif !defined(TCSAFLUSH)
-
-/* BSD TERMIO HANDLING */
-
-static struct sgttyb t;
-
-#define ECHO_IS_ON(t) ((t).sg_flags & ECHO)
-#define TURN_ECHO_OFF(t) ((t).sg_flags &= ~ECHO)
-#define TURN_ECHO_ON(t) ((t).sg_flags |= ECHO)
-
-#define TCSAFLUSH 1
-#define TCSANOW 0
-
-static int tcgetattr(int fd, struct sgttyb *_t)
-{
- return ioctl(fd, TIOCGETP, (char *)_t);
-}
-
-static int tcsetattr(int fd, int flags, struct sgttyb *_t)
-{
- return ioctl(fd, TIOCSETP, (char *)_t);
-}
-
-#else /* POSIX TERMIO HANDLING */
-#define ECHO_IS_ON(t) ((t).c_lflag & ECHO)
-#define TURN_ECHO_OFF(t) ((t).c_lflag &= ~ECHO)
-#define TURN_ECHO_ON(t) ((t).c_lflag |= ECHO)
-
-static struct termios t;
-#endif /* SYSV_TERMIO */
-
-static void catch_signal(int signum,void (*handler)(int ))
-{
-#ifdef HAVE_SIGACTION
- struct sigaction act;
- struct sigaction oldact;
-
- memset(&act, 0, sizeof(act));
-
- act.sa_handler = handler;
-#ifdef SA_RESTART
- /*
- * We *want* SIGALRM to interrupt a system call.
- */
- if(signum != SIGALRM)
- act.sa_flags = SA_RESTART;
-#endif
- sigemptyset(&act.sa_mask);
- sigaddset(&act.sa_mask,signum);
- sigaction(signum,&act,&oldact);
-#else /* !HAVE_SIGACTION */
- /* FIXME: need to handle sigvec and systems with broken signal() */
- signal(signum, handler);
-#endif
-}
-
-static sig_atomic_t gotintr;
-static int in_fd = -1;
-
-/***************************************************************
- Signal function to tell us were ^C'ed.
-****************************************************************/
-
-static void gotintr_sig(void)
-{
- gotintr = 1;
- if (in_fd != -1)
- close(in_fd); /* Safe way to force a return. */
- in_fd = -1;
-}
-
-char *rep_getpass(const char *prompt)
-{
- FILE *in, *out;
- int echo_off;
- static char buf[256];
- static size_t bufsize = sizeof(buf);
- size_t nread;
-
- /* Catch problematic signals */
- catch_signal(SIGINT, SIGNAL_CAST gotintr_sig);
-
- /* Try to write to and read from the terminal if we can.
- If we can't open the terminal, use stderr and stdin. */
-
- in = fopen ("/dev/tty", "w+");
- if (in == NULL) {
- in = stdin;
- out = stderr;
- } else {
- out = in;
- }
-
- setvbuf(in, NULL, _IONBF, 0);
-
- /* Turn echoing off if it is on now. */
-
- if (tcgetattr (fileno (in), &t) == 0) {
- if (ECHO_IS_ON(t)) {
- TURN_ECHO_OFF(t);
- echo_off = tcsetattr (fileno (in), TCSAFLUSH, &t) == 0;
- TURN_ECHO_ON(t);
- } else {
- echo_off = 0;
- }
- } else {
- echo_off = 0;
- }
-
- /* Write the prompt. */
- fputs(prompt, out);
- fflush(out);
-
- /* Read the password. */
- buf[0] = 0;
- if (!gotintr) {
- in_fd = fileno(in);
- if (fgets(buf, bufsize, in) == NULL) {
- buf[0] = 0;
- }
- }
- nread = strlen(buf);
- if (nread) {
- if (buf[nread - 1] == '\n')
- buf[nread - 1] = '\0';
- }
-
- /* Restore echoing. */
- if (echo_off) {
- if (gotintr && in_fd == -1) {
- in = fopen ("/dev/tty", "w+");
- }
- if (in != NULL)
- tcsetattr (fileno (in), TCSANOW, &t);
- }
-
- fprintf(out, "\n");
- fflush(out);
-
- if (in && in != stdin) /* We opened the terminal; now close it. */
- fclose(in);
-
- /* Catch problematic signals */
- catch_signal(SIGINT, SIGNAL_CAST SIG_DFL);
-
- if (gotintr) {
- printf("Interupted by signal.\n");
- fflush(stdout);
- exit(1);
- }
- return buf;
-}
diff --git a/source4/lib/replace/getpass.m4 b/source4/lib/replace/getpass.m4
deleted file mode 100644
index b93817f9d3..0000000000
--- a/source4/lib/replace/getpass.m4
+++ /dev/null
@@ -1,24 +0,0 @@
-AC_CHECK_FUNC(getpass, libreplace_cv_HAVE_GETPASS=yes)
-AC_CHECK_FUNC(getpassphrase, libreplace_cv_HAVE_GETPASSPHRASE=yes)
-if test x"$libreplace_cv_HAVE_GETPASS" = x"yes" -a x"$libreplace_cv_HAVE_GETPASSPHRASE" = x"yes"; then
- AC_DEFINE(REPLACE_GETPASS_BY_GETPASSPHRASE, 1, [getpass returns <9 chars where getpassphrase returns <265 chars])
- AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
- LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o"
-else
-
-AC_CACHE_CHECK([whether getpass should be replaced],libreplace_cv_REPLACE_GETPASS,[
-SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I$libreplacedir/"
-AC_TRY_COMPILE([
-#include "confdefs.h"
-#define NO_CONFIG_H
-#include "$libreplacedir/getpass.c"
-],[],libreplace_cv_REPLACE_GETPASS=yes,libreplace_cv_REPLACE_GETPASS=no)
-CPPFLAGS="$SAVE_CPPFLAGS"
-])
-if test x"$libreplace_cv_REPLACE_GETPASS" = x"yes"; then
- AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
- LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o"
-fi
-
-fi
diff --git a/source4/lib/replace/inet_aton.c b/source4/lib/replace/inet_aton.c
deleted file mode 100644
index c6b3bb11a7..0000000000
--- a/source4/lib/replace/inet_aton.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * replacement functions
- * Copyright (C) Michael Adam <obnox@samba.org> 2008
- *
- * ** NOTE! The following LGPL license applies to the replace
- * ** library. This does NOT imply that all of Samba is released
- * ** under the LGPL
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "replace.h"
-#include "system/network.h"
-
-/**
- * We know that we have inet_pton from earlier libreplace checks.
- */
-int rep_inet_aton(const char *src, struct in_addr *dst)
-{
- return (inet_pton(AF_INET, src, dst) > 0) ? 1 : 0;
-}
diff --git a/source4/lib/replace/inet_ntoa.c b/source4/lib/replace/inet_ntoa.c
deleted file mode 100644
index e3b80ebef8..0000000000
--- a/source4/lib/replace/inet_ntoa.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * replacement routines for broken systems
- * Copyright (C) Andrew Tridgell 2003
- * Copyright (C) Michael Adam 2008
- *
- * ** NOTE! The following LGPL license applies to the replace
- * ** library. This does NOT imply that all of Samba is released
- * ** under the LGPL
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "replace.h"
-#include "system/network.h"
-
-/**
- * NOTE: this is not thread safe, but it can't be, either
- * since it returns a pointer to static memory.
- */
-char *rep_inet_ntoa(struct in_addr ip)
-{
- uint8_t *p = (uint8_t *)&ip.s_addr;
- static char buf[18];
- slprintf(buf, 17, "%d.%d.%d.%d",
- (int)p[0], (int)p[1], (int)p[2], (int)p[3]);
- return buf;
-}
diff --git a/source4/lib/replace/inet_ntop.c b/source4/lib/replace/inet_ntop.c
deleted file mode 100644
index fb3d8e90c8..0000000000
--- a/source4/lib/replace/inet_ntop.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (C) 1996-2001 Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
- * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
- * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
- * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-
-#include "replace.h"
-#include "system/network.h"
-
-#define NS_INT16SZ 2
-#define NS_IN6ADDRSZ 16
-
-/*
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-
-static const char *inet_ntop4(const unsigned char *src, char *dst,
- socklen_t size);
-
-#ifdef AF_INET6
-static const char *inet_ntop6(const unsigned char *src, char *dst,
- socklen_t size);
-#endif
-
-/* char *
- * isc_net_ntop(af, src, dst, size)
- * convert a network format address to presentation format.
- * return:
- * pointer to presentation format address (`dst'), or NULL (see errno).
- * author:
- * Paul Vixie, 1996.
- */
-const char *
-rep_inet_ntop(int af, const void *src, char *dst, socklen_t size)
-{
- switch (af) {
- case AF_INET:
- return (inet_ntop4(src, dst, size));
-#ifdef AF_INET6
- case AF_INET6:
- return (inet_ntop6(src, dst, size));
-#endif
- default:
- errno = EAFNOSUPPORT;
- return (NULL);
- }
- /* NOTREACHED */
-}
-
-/* const char *
- * inet_ntop4(src, dst, size)
- * format an IPv4 address
- * return:
- * `dst' (as a const)
- * notes:
- * (1) uses no statics
- * (2) takes a unsigned char* not an in_addr as input
- * author:
- * Paul Vixie, 1996.
- */
-static const char *
-inet_ntop4(const unsigned char *src, char *dst, socklen_t size)
-{
- static const char *fmt = "%u.%u.%u.%u";
- char tmp[sizeof "255.255.255.255"];
- size_t len;
-
- len = snprintf(tmp, sizeof tmp, fmt, src[0], src[1], src[2], src[3]);
- if (len >= size) {
- errno = ENOSPC;
- return (NULL);
- }
- memcpy(dst, tmp, len + 1);
-
- return (dst);
-}
-
-/* const char *
- * isc_inet_ntop6(src, dst, size)
- * convert IPv6 binary address into presentation (printable) format
- * author:
- * Paul Vixie, 1996.
- */
-#ifdef AF_INET6
-static const char *
-inet_ntop6(const unsigned char *src, char *dst, socklen_t size)
-{
- /*
- * Note that int32_t and int16_t need only be "at least" large enough
- * to contain a value of the specified size. On some systems, like
- * Crays, there is no such thing as an integer variable with 16 bits.
- * Keep this in mind if you think this function should have been coded
- * to use pointer overlays. All the world's not a VAX.
- */
- char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
- struct { int base, len; } best, cur;
- unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
- int i, inc;
-
- /*
- * Preprocess:
- * Copy the input (bytewise) array into a wordwise array.
- * Find the longest run of 0x00's in src[] for :: shorthanding.
- */
- memset(words, '\0', sizeof words);
- for (i = 0; i < NS_IN6ADDRSZ; i++)
- words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
- best.base = -1;
- best.len = 0;
- cur.base = -1;
- cur.len = 0;
- for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
- if (words[i] == 0) {
- if (cur.base == -1)
- cur.base = i, cur.len = 1;
- else
- cur.len++;
- } else {
- if (cur.base != -1) {
- if (best.base == -1 || cur.len > best.len)
- best = cur;
- cur.base = -1;
- }
- }
- }
- if (cur.base != -1) {
- if (best.base == -1 || cur.len > best.len)
- best = cur;
- }
- if (best.base != -1 && best.len < 2)
- best.base = -1;
-
- /*
- * Format the result.
- */
- tp = tmp;
- for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
- /* Are we inside the best run of 0x00's? */
- if (best.base != -1 && i >= best.base &&
- i < (best.base + best.len)) {
- if (i == best.base)
- *tp++ = ':';
- continue;
- }
- /* Are we following an initial run of 0x00s or any real hex? */
- if (i != 0)
- *tp++ = ':';
- /* Is this address an encapsulated IPv4? */
- if (i == 6 && best.base == 0 &&
- (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
- if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
- return (NULL);
- tp += strlen(tp);
- break;
- }
- inc = snprintf(tp, 5, "%x", words[i]);
- if (inc >= 5) {
- abort();
- }
- tp += inc;
- }
- /* Was it a trailing run of 0x00's? */
- if (best.base != -1 && (best.base + best.len) ==
- (NS_IN6ADDRSZ / NS_INT16SZ))
- *tp++ = ':';
- *tp++ = '\0';
-
- /*
- * Check for overflow, copy, and we're done.
- */
- if ((size_t)(tp - tmp) > size) {
- errno = ENOSPC;
- return (NULL);
- }
- memcpy(dst, tmp, tp - tmp);
- return (dst);
-}
-#endif /* AF_INET6 */
diff --git a/source4/lib/replace/inet_pton.c b/source4/lib/replace/inet_pton.c
deleted file mode 100644
index 80e4865ef4..0000000000
--- a/source4/lib/replace/inet_pton.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (C) 1996-2001 Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
- * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
- * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
- * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "replace.h"
-#include "system/network.h"
-
-#define NS_INT16SZ 2
-#define NS_INADDRSZ 4
-#define NS_IN6ADDRSZ 16
-
-/*
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-
-static int inet_pton4(const char *src, unsigned char *dst);
-#ifdef AF_INET6
-static int inet_pton6(const char *src, unsigned char *dst);
-#endif
-
-/* int
- * inet_pton(af, src, dst)
- * convert from presentation format (which usually means ASCII printable)
- * to network format (which is usually some kind of binary format).
- * return:
- * 1 if the address was valid for the specified address family
- * 0 if the address wasn't valid (`dst' is untouched in this case)
- * -1 if some other error occurred (`dst' is untouched in this case, too)
- * author:
- * Paul Vixie, 1996.
- */
-int
-rep_inet_pton(int af,
- const char *src,
- void *dst)
-{
- switch (af) {
- case AF_INET:
- return (inet_pton4(src, dst));
-#ifdef AF_INET6
- case AF_INET6:
- return (inet_pton6(src, dst));
-#endif
- default:
- errno = EAFNOSUPPORT;
- return (-1);
- }
- /* NOTREACHED */
-}
-
-/* int
- * inet_pton4(src, dst)
- * like inet_aton() but without all the hexadecimal and shorthand.
- * return:
- * 1 if `src' is a valid dotted quad, else 0.
- * notice:
- * does not touch `dst' unless it's returning 1.
- * author:
- * Paul Vixie, 1996.
- */
-static int
-inet_pton4(src, dst)
- const char *src;
- unsigned char *dst;
-{
- static const char digits[] = "0123456789";
- int saw_digit, octets, ch;
- unsigned char tmp[NS_INADDRSZ], *tp;
-
- saw_digit = 0;
- octets = 0;
- *(tp = tmp) = 0;
- while ((ch = *src++) != '\0') {
- const char *pch;
-
- if ((pch = strchr(digits, ch)) != NULL) {
- unsigned int new = *tp * 10 + (pch - digits);
-
- if (new > 255)
- return (0);
- *tp = new;
- if (! saw_digit) {
- if (++octets > 4)
- return (0);
- saw_digit = 1;
- }
- } else if (ch == '.' && saw_digit) {
- if (octets == 4)
- return (0);
- *++tp = 0;
- saw_digit = 0;
- } else
- return (0);
- }
- if (octets < 4)
- return (0);
- memcpy(dst, tmp, NS_INADDRSZ);
- return (1);
-}
-
-/* int
- * inet_pton6(src, dst)
- * convert presentation level address to network order binary form.
- * return:
- * 1 if `src' is a valid [RFC1884 2.2] address, else 0.
- * notice:
- * (1) does not touch `dst' unless it's returning 1.
- * (2) :: in a full address is silently ignored.
- * credit:
- * inspired by Mark Andrews.
- * author:
- * Paul Vixie, 1996.
- */
-#ifdef AF_INET6
-static int
-inet_pton6(src, dst)
- const char *src;
- unsigned char *dst;
-{
- static const char xdigits_l[] = "0123456789abcdef",
- xdigits_u[] = "0123456789ABCDEF";
- unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
- const char *xdigits, *curtok;
- int ch, saw_xdigit;
- unsigned int val;
-
- memset((tp = tmp), '\0', NS_IN6ADDRSZ);
- endp = tp + NS_IN6ADDRSZ;
- colonp = NULL;
- /* Leading :: requires some special handling. */
- if (*src == ':')
- if (*++src != ':')
- return (0);
- curtok = src;
- saw_xdigit = 0;
- val = 0;
- while ((ch = *src++) != '\0') {
- const char *pch;
-
- if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
- pch = strchr((xdigits = xdigits_u), ch);
- if (pch != NULL) {
- val <<= 4;
- val |= (pch - xdigits);
- if (val > 0xffff)
- return (0);
- saw_xdigit = 1;
- continue;
- }
- if (ch == ':') {
- curtok = src;
- if (!saw_xdigit) {
- if (colonp)
- return (0);
- colonp = tp;
- continue;
- }
- if (tp + NS_INT16SZ > endp)
- return (0);
- *tp++ = (unsigned char) (val >> 8) & 0xff;
- *tp++ = (unsigned char) val & 0xff;
- saw_xdigit = 0;
- val = 0;
- continue;
- }
- if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
- inet_pton4(curtok, tp) > 0) {
- tp += NS_INADDRSZ;
- saw_xdigit = 0;
- break; /* '\0' was seen by inet_pton4(). */
- }
- return (0);
- }
- if (saw_xdigit) {
- if (tp + NS_INT16SZ > endp)
- return (0);
- *tp++ = (unsigned char) (val >> 8) & 0xff;
- *tp++ = (unsigned char) val & 0xff;
- }
- if (colonp != NULL) {
- /*
- * Since some memmove()'s erroneously fail to handle
- * overlapping regions, we'll do the shift by hand.
- */
- const int n = tp - colonp;
- int i;
-
- for (i = 1; i <= n; i++) {
- endp[- i] = colonp[n - i];
- colonp[n - i] = 0;
- }
- tp = endp;
- }
- if (tp != endp)
- return (0);
- memcpy(dst, tmp, NS_IN6ADDRSZ);
- return (1);
-}
-#endif
diff --git a/source4/lib/replace/install-sh b/source4/lib/replace/install-sh
deleted file mode 100755
index 58719246f0..0000000000
--- a/source4/lib/replace/install-sh
+++ /dev/null
@@ -1,238 +0,0 @@
-#! /bin/sh
-#
-# install - install a program, script, or datafile
-# This comes from X11R5.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-#
-
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-transformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd="$stripprog"
- shift
- continue;;
-
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
-
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
-done
-
-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
-else
- true
-fi
-
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- else
- instcmd=mkdir
- fi
-else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
-
- if [ -f $src -o -d $src ]
- then
- true
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- true
- fi
-
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- true
- fi
-fi
-
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
-
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-'
-IFS="${IFS-${defaultIFS}}"
-
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
-
-pathcomp=''
-
-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
-
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- true
- fi
-
- pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
-
-# If we're going to rename the final executable, determine the name now.
-
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
-
-# don't allow the sed command to completely eliminate the filename
-
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- true
- fi
-
-# Make a temp file name in the proper directory.
-
- dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-
- $doit $instcmd $src $dsttmp &&
-
- trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
-
-# Now rename the file to the real destination.
-
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
-
-fi &&
-
-
-exit 0
diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4
deleted file mode 100644
index 71fa041672..0000000000
--- a/source4/lib/replace/libreplace.m4
+++ /dev/null
@@ -1,303 +0,0 @@
-AC_DEFUN_ONCE(AC_LIBREPLACE_LOCATION_CHECKS,
-[
-echo "LIBREPLACE_LOCATION_CHECKS: START"
-
-dnl find the libreplace sources. This is meant to work both for
-dnl libreplace standalone builds, and builds of packages using libreplace
-libreplacedir=""
-libreplacepaths="$srcdir $srcdir/lib/replace $srcdir/libreplace $srcdir/../libreplace $srcdir/../replace"
-for d in $libreplacepaths; do
- if test -f "$d/replace.c"; then
- libreplacedir="$d"
- AC_SUBST(libreplacedir)
- break;
- fi
-done
-if test x"$libreplacedir" = "x"; then
- AC_MSG_ERROR([cannot find libreplace in $libreplacepaths])
-fi
-LIBREPLACEOBJ="replace.o"
-AC_SUBST(LIBREPLACEOBJ)
-
-AC_CANONICAL_BUILD
-AC_CANONICAL_HOST
-AC_CANONICAL_TARGET
-
-echo "LIBREPLACE_LOCATION_CHECKS: END"
-]) dnl end AC_LIBREPLACE_LOCATION_CHECKS
-
-
-AC_DEFUN_ONCE(AC_LIBREPLACE_BROKEN_CHECKS,
-[
-echo "LIBREPLACE_BROKEN_CHECKS: START"
-
-dnl find the libreplace sources. This is meant to work both for
-dnl libreplace standalone builds, and builds of packages using libreplace
-libreplacedir=""
-for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace" "$srcdir/../replace"; do
- if test -f "$d/replace.c"; then
- libreplacedir="$d"
- AC_SUBST(libreplacedir)
- break;
- fi
-done
-LIBREPLACEOBJ="replace.o"
-AC_SUBST(LIBREPLACEOBJ)
-
-LIBREPLACEOBJ="${LIBREPLACEOBJ} snprintf.o"
-
-AC_TYPE_SIGNAL
-AC_TYPE_UID_T
-AC_TYPE_MODE_T
-AC_TYPE_OFF_T
-AC_TYPE_SIZE_T
-AC_TYPE_PID_T
-AC_STRUCT_ST_RDEV
-AC_CHECK_TYPE(ino_t,unsigned)
-AC_CHECK_TYPE(loff_t,off_t)
-AC_CHECK_TYPE(offset_t,loff_t)
-
-AC_FUNC_MEMCMP
-
-AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer lstat getpgrp)
-
-AC_CHECK_HEADERS(stdbool.h stdint.h sys/select.h)
-AC_CHECK_HEADERS(setjmp.h)
-
-LIBREPLACE_PROVIDE_HEADER([stdint.h])
-LIBREPLACE_PROVIDE_HEADER([stdbool.h])
-
-AC_CHECK_TYPE(bool,
-[AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],,
-[
-AC_INCLUDES_DEFAULT
-#ifdef HAVE_STDBOOL_H
-#include <stdbool.h>
-#endif]
-)
-
-AC_CHECK_TYPE(_Bool,
-[AC_DEFINE(HAVE__Bool, 1, [Whether the _Bool type is available])],,
-[
-AC_INCLUDES_DEFAULT
-#ifdef HAVE_STDBOOL_H
-#include <stdbool.h>
-#endif]
-)
-
-AC_CACHE_CHECK([for working mmap],libreplace_cv_HAVE_MMAP,[
-AC_TRY_RUN([#include "$libreplacedir/test/shared_mmap.c"],
- libreplace_cv_HAVE_MMAP=yes,libreplace_cv_HAVE_MMAP=no,libreplace_cv_HAVE_MMAP=cross)])
-if test x"$libreplace_cv_HAVE_MMAP" = x"yes"; then
- AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
-fi
-
-
-AC_CHECK_HEADERS(sys/syslog.h syslog.h)
-AC_CHECK_HEADERS(sys/time.h time.h)
-AC_CHECK_HEADERS(stdarg.h vararg.h)
-AC_CHECK_HEADERS(sys/mount.h mntent.h)
-AC_CHECK_HEADERS(stropts.h)
-
-AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
-AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
-AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup)
-AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp)
-AC_CHECK_FUNCS(isatty)
-AC_HAVE_DECL(setresuid, [#include <unistd.h>])
-AC_HAVE_DECL(setresgid, [#include <unistd.h>])
-AC_HAVE_DECL(errno, [#include <errno.h>])
-
-AC_CACHE_CHECK([for secure mkstemp],libreplace_cv_HAVE_SECURE_MKSTEMP,[
-AC_TRY_RUN([#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-main() {
- struct stat st;
- char tpl[20]="/tmp/test.XXXXXX";
- int fd = mkstemp(tpl);
- if (fd == -1) exit(1);
- unlink(tpl);
- if (fstat(fd, &st) != 0) exit(1);
- if ((st.st_mode & 0777) != 0600) exit(1);
- exit(0);
-}],
-libreplace_cv_HAVE_SECURE_MKSTEMP=yes,
-libreplace_cv_HAVE_SECURE_MKSTEMP=no,
-libreplace_cv_HAVE_SECURE_MKSTEMP=cross)])
-if test x"$libreplace_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
- AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
-fi
-
-dnl Provided by snprintf.c:
-AC_CHECK_HEADERS(stdio.h strings.h)
-AC_CHECK_DECLS([snprintf, vsnprintf, asprintf, vasprintf])
-AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
-
-AC_CACHE_CHECK([for C99 vsnprintf],libreplace_cv_HAVE_C99_VSNPRINTF,[
-AC_TRY_RUN([
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-void foo(const char *format, ...) {
- va_list ap;
- int len;
- char buf[20];
- long long l = 1234567890;
- l *= 100;
-
- va_start(ap, format);
- len = vsnprintf(buf, 0, format, ap);
- va_end(ap);
- if (len != 5) exit(1);
-
- va_start(ap, format);
- len = vsnprintf(0, 0, format, ap);
- va_end(ap);
- if (len != 5) exit(2);
-
- if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3);
-
- if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4);
- if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5);
- if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6);
- if (snprintf(buf, 20, "%s", 0) < 3) exit(7);
-
- exit(0);
-}
-main() { foo("hello"); }
-],
-libreplace_cv_HAVE_C99_VSNPRINTF=yes,libreplace_cv_HAVE_C99_VSNPRINTF=no,libreplace_cv_HAVE_C99_VSNPRINTF=cross)])
-if test x"$libreplace_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
- AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
-fi
-
-
-dnl VA_COPY
-AC_CACHE_CHECK([for va_copy],libreplace_cv_HAVE_VA_COPY,[
-AC_TRY_LINK([#include <stdarg.h>
-va_list ap1,ap2;], [va_copy(ap1,ap2);],
-libreplace_cv_HAVE_VA_COPY=yes,libreplace_cv_HAVE_VA_COPY=no)])
-if test x"$libreplace_cv_HAVE_VA_COPY" = x"yes"; then
- AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
-fi
-
-if test x"$libreplace_cv_HAVE_VA_COPY" != x"yes"; then
-AC_CACHE_CHECK([for __va_copy],libreplace_cv_HAVE___VA_COPY,[
-AC_TRY_LINK([#include <stdarg.h>
-va_list ap1,ap2;], [__va_copy(ap1,ap2);],
-libreplace_cv_HAVE___VA_COPY=yes,libreplace_cv_HAVE___VA_COPY=no)])
-if test x"$libreplace_cv_HAVE___VA_COPY" = x"yes"; then
- AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
-fi
-fi
-
-dnl __FUNCTION__ macro
-AC_CACHE_CHECK([for __FUNCTION__ macro],libreplace_cv_HAVE_FUNCTION_MACRO,[
-AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
-libreplace_cv_HAVE_FUNCTION_MACRO=yes,libreplace_cv_HAVE_FUNCTION_MACRO=no)])
-if test x"$libreplace_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
- AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
-else
- dnl __func__ macro
- AC_CACHE_CHECK([for __func__ macro],libreplace_cv_HAVE_func_MACRO,[
- AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __func__);],
- libreplace_cv_HAVE_func_MACRO=yes,libreplace_cv_HAVE_func_MACRO=no)])
- if test x"$libreplace_cv_HAVE_func_MACRO" = x"yes"; then
- AC_DEFINE(HAVE_func_MACRO,1,[Whether there is a __func__ macro])
- fi
-fi
-
-AC_CHECK_HEADERS([sys/param.h limits.h])
-
-AC_CHECK_TYPE(comparison_fn_t,
-[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
-
-AC_HAVE_DECL(setenv, [#include <stdlib.h>])
-AC_CHECK_FUNCS(setenv unsetenv)
-
-AC_CHECK_FUNCS(strnlen)
-AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
-
-# this test disabled as we don't actually need __VA_ARGS__ yet
-AC_TRY_CPP([
-#define eprintf(...) fprintf(stderr, __VA_ARGS__)
-eprintf("bla", "bar");
-], AC_DEFINE(HAVE__VA_ARGS__MACRO, 1, [Whether the __VA_ARGS__ macro is available]))
-
-
-AC_CACHE_CHECK([for sig_atomic_t type],libreplace_cv_sig_atomic_t, [
- AC_TRY_COMPILE([
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
-#include <signal.h>],[sig_atomic_t i = 0],
- libreplace_cv_sig_atomic_t=yes,libreplace_cv_sig_atomic_t=no)])
-if test x"$libreplace_cv_sig_atomic_t" = x"yes"; then
- AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
-fi
-
-
-AC_CACHE_CHECK([for O_DIRECT flag to open(2)],libreplace_cv_HAVE_OPEN_O_DIRECT,[
-AC_TRY_COMPILE([
-#include <unistd.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif],
-[int fd = open("/dev/null", O_DIRECT);],
-libreplace_cv_HAVE_OPEN_O_DIRECT=yes,libreplace_cv_HAVE_OPEN_O_DIRECT=no)])
-if test x"$libreplace_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then
- AC_DEFINE(HAVE_OPEN_O_DIRECT,1,[Whether the open(2) accepts O_DIRECT])
-fi
-
-
-dnl Check if the C compiler understands volatile (it should, being ANSI).
-AC_CACHE_CHECK([that the C compiler understands volatile],libreplace_cv_volatile, [
- AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
- libreplace_cv_volatile=yes,libreplace_cv_volatile=no)])
-if test x"$libreplace_cv_volatile" = x"yes"; then
- AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
-fi
-
-m4_include(system/config.m4)
-
-m4_include(dlfcn.m4)
-m4_include(getpass.m4)
-m4_include(strptime.m4)
-m4_include(win32.m4)
-m4_include(timegm.m4)
-m4_include(repdir.m4)
-
-AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])])
-
-echo "LIBREPLACE_BROKEN_CHECKS: END"
-]) dnl end AC_LIBREPLACE_BROKEN_CHECKS
-
-AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_START,
-[
-#LIBREPLACE_ALL_CHECKS: START"
-])
-AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_END,
-[
-#LIBREPLACE_ALL_CHECKS: END"
-])
-m4_define(AC_LIBREPLACE_ALL_CHECKS,
-[
-AC__LIBREPLACE_ALL_CHECKS_START
-AC_LIBREPLACE_LOCATION_CHECKS
-AC_LIBREPLACE_CC_CHECKS
-AC_LIBREPLACE_BROKEN_CHECKS
-AC__LIBREPLACE_ALL_CHECKS_END
-CFLAGS="$CFLAGS -I$libreplacedir"
-])
-
-m4_include(libreplace_cc.m4)
-m4_include(libreplace_ld.m4)
-m4_include(libreplace_network.m4)
-m4_include(libreplace_macros.m4)
-
-m4_ifndef([AC_USE_SYSTEM_EXTENSIONS],[m4_include(autoconf-2.60.m4)])
diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4
deleted file mode 100644
index 30c63f2f05..0000000000
--- a/source4/lib/replace/libreplace_cc.m4
+++ /dev/null
@@ -1,182 +0,0 @@
-
-AC_DEFUN_ONCE(AC__LIBREPLACE_ONLY_CC_CHECKS_START,
-[
-echo "LIBREPLACE_CC_CHECKS: START"
-])
-
-AC_DEFUN_ONCE(AC__LIBREPLACE_ONLY_CC_CHECKS_END,
-[
-echo "LIBREPLACE_CC_CHECKS: END"
-])
-
-dnl
-dnl
-dnl AC_LIBREPLACE_CC_CHECKS
-dnl
-dnl Note: we need to use m4_define instead of AC_DEFUN because
-dnl of the ordering of tests
-dnl
-dnl
-m4_define(AC_LIBREPLACE_CC_CHECKS,
-[
-AC__LIBREPLACE_ONLY_CC_CHECKS_START
-
-dnl stop the C89 attempt by autoconf - if autoconf detects -Ae it will enable it
-dnl which conflicts with C99 on HPUX
-ac_cv_prog_cc_Ae=no
-
-savedCFLAGS=$CFLAGS
-AC_PROG_CC
-CFLAGS=$savedCFLAGS
-
-dnl don't try for C99 if we are using gcc, as otherwise we
-dnl lose immediate structure constants
-if test x"$GCC" != x"yes" ; then
-AC_PROG_CC_C99
-fi
-
-if test x"$GCC" = x"yes" ; then
- AC_MSG_CHECKING([for version of gcc])
- GCC_VERSION=`$CC -dumpversion`
- AC_MSG_RESULT(${GCC_VERSION})
-fi
-AC_USE_SYSTEM_EXTENSIONS
-AC_C_BIGENDIAN
-AC_C_INLINE
-LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_WARN([c99 structure initializer are not supported])])
-
-AC_PROG_INSTALL
-
-AC_ISC_POSIX
-AC_N_DEFINE(_XOPEN_SOURCE_EXTENDED)
-
-AC_SYS_LARGEFILE
-
-dnl Add #include for broken IRIX header files
-case "$host_os" in
- *irix6*) AC_ADD_INCLUDE(<standards.h>)
- ;;
- *hpux*)
- # mmap on HPUX is completely broken...
- AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
- if test "`uname -r`" = "B.11.00" -o "`uname -r`" = "B.11.11"; then
- AC_MSG_WARN([Enabling HPUX 11.00/11.11 header bug workaround])
- CFLAGS="$CFLAGS -Dpread=pread64 -Dpwrite=pwrite64"
- fi
- if test "`uname -r`" = "B.11.23"; then
- AC_MSG_WARN([Enabling HPUX 11.23 machine/sys/getppdp.h bug workaround])
- CFLAGS="$CFLAGS -D_MACHINE_SYS_GETPPDP_INCLUDED"
- fi
- ;;
- *aix*)
- AC_DEFINE(BROKEN_STRNDUP, 1, [Whether strndup is broken])
- AC_DEFINE(BROKEN_STRNLEN, 1, [Whether strnlen is broken])
- if test "${GCC}" != "yes"; then
- ## for funky AIX compiler using strncpy()
- CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
- fi
- ;;
- *osf*)
- # this brings in socklen_t
- AC_N_DEFINE(_XOPEN_SOURCE,600)
- AC_N_DEFINE(_OSF_SOURCE)
- ;;
- #
- # VOS may need to have POSIX support and System V compatibility enabled.
- #
- *vos*)
- case "$CFLAGS" in
- *-D_POSIX_C_SOURCE*);;
- *)
- CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L"
- AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
- ;;
- esac
- case "$CFLAGS" in
- *-D_SYSV*|*-D_SVID_SOURCE*);;
- *)
- CFLAGS="$CFLAGS -D_SYSV"
- AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
- ;;
- esac
- ;;
-esac
-
-
-
-AC_CHECK_HEADERS([standards.h])
-
-# Solaris needs HAVE_LONG_LONG defined
-AC_CHECK_TYPES(long long)
-
-AC_CHECK_SIZEOF(int)
-AC_CHECK_SIZEOF(char)
-AC_CHECK_SIZEOF(short)
-AC_CHECK_SIZEOF(long)
-AC_CHECK_SIZEOF(long long)
-
-AC_CHECK_TYPE(uint_t, unsigned int)
-AC_CHECK_TYPE(int8_t, char)
-AC_CHECK_TYPE(uint8_t, unsigned char)
-AC_CHECK_TYPE(int16_t, short)
-AC_CHECK_TYPE(uint16_t, unsigned short)
-
-if test $ac_cv_sizeof_int -eq 4 ; then
-AC_CHECK_TYPE(int32_t, int)
-AC_CHECK_TYPE(uint32_t, unsigned int)
-elif test $ac_cv_size_long -eq 4 ; then
-AC_CHECK_TYPE(int32_t, long)
-AC_CHECK_TYPE(uint32_t, unsigned long)
-else
-AC_MSG_ERROR([LIBREPLACE no 32-bit type found])
-fi
-
-AC_CHECK_TYPE(int64_t, long long)
-AC_CHECK_TYPE(uint64_t, unsigned long long)
-
-AC_CHECK_TYPE(size_t, unsigned int)
-AC_CHECK_TYPE(ssize_t, int)
-
-AC_CHECK_SIZEOF(off_t)
-AC_CHECK_SIZEOF(size_t)
-AC_CHECK_SIZEOF(ssize_t)
-
-AC_CHECK_TYPE(intptr_t, long long)
-AC_CHECK_TYPE(uintptr_t, unsigned long long)
-AC_CHECK_TYPE(ptrdiff_t, unsigned long long)
-
-if test x"$ac_cv_type_long_long" != x"yes";then
- AC_MSG_ERROR([LIBREPLACE needs type 'long long'])
-fi
-if test $ac_cv_sizeof_long_long -lt 8;then
- AC_MSG_ERROR([LIBREPLACE needs sizeof(long long) >= 8])
-fi
-
-############################################
-# check if the compiler can do immediate structures
-AC_SUBST(libreplace_cv_immediate_structures)
-AC_CACHE_CHECK([for immediate structures],libreplace_cv_immediate_structures,[
- AC_TRY_COMPILE([
- #include <stdio.h>
- ],[
- typedef struct {unsigned x;} FOOBAR;
- #define X_FOOBAR(x) ((FOOBAR) { x })
- #define FOO_ONE X_FOOBAR(1)
- FOOBAR f = FOO_ONE;
- static const struct {
- FOOBAR y;
- } f2[] = {
- {FOO_ONE}
- };
- static const FOOBAR f3[] = {FOO_ONE};
- ],
- libreplace_cv_immediate_structures=yes,
- libreplace_cv_immediate_structures=no,
- libreplace_cv_immediate_structures=cross)
-])
-if test x"$libreplace_cv_immediate_structures" = x"yes"; then
- AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
-fi
-
-AC__LIBREPLACE_ONLY_CC_CHECKS_END
-]) dnl end AC_LIBREPLACE_CC_CHECKS
diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4
deleted file mode 100644
index 81bde46219..0000000000
--- a/source4/lib/replace/libreplace_ld.m4
+++ /dev/null
@@ -1,319 +0,0 @@
-#
-# This offers a nice overview how to build shared libraries on all platforms
-# http://www.fortran-2000.com/ArnaudRecipes/sharedlib.html
-#
-
-AC_DEFUN([AC_LIBREPLACE_STLD],
-[
- AC_PATH_PROG(PROG_AR, ar)
-
- STLD=${PROG_AR}
-
- AC_SUBST(STLD)
-])
-
-AC_DEFUN([AC_LIBREPLACE_STLD_FLAGS],
-[
- STLD_FLAGS="-rcs"
- AC_SUBST(STLD_FLAGS)
-])
-
-AC_DEFUN([AC_LD_EXPORT_DYNAMIC],
-[
-saved_LDFLAGS="$LDFLAGS"
-if AC_TRY_COMMAND([${CC-cc} $CFLAGS -Wl,--version 2>&1 | grep "GNU ld" >/dev/null]); then
- LD_EXPORT_DYNAMIC="-Wl,-export-dynamic"
-else
- case "$host_os" in
- hpux* )
- LD_EXPORT_DYNAMIC="-Wl,-E"
- ;;
- *)
- LD_EXPORT_DYNAMIC=""
- ;;
- esac
-fi
-AC_SUBST(LD_EXPORT_DYNAMIC)
-LDFLAGS="$saved_LDFLAGS"
-])
-
-AC_DEFUN([AC_LD_PICFLAG],
-[
-case "$host_os" in
- *linux*)
- PICFLAG="-fPIC"
- ;;
- *solaris*)
- if test "${GCC}" = "yes"; then
- PICFLAG="-fPIC"
- else
- PICFLAG="-KPIC"
- fi
- ;;
- *sunos*)
- PICFLAG="-KPIC" # Is this correct for SunOS
- ;;
- *netbsd* | *freebsd* | *dragonfly* )
- PICFLAG="-fPIC -DPIC"
- ;;
- *openbsd*)
- PICFLAG="-fPIC"
- ;;
- *irix*)
- if test "${GCC}" = "yes"; then
- PICFLAG="-fPIC"
- else
- PICFLAG="-KPIC"
- fi
- ;;
- *aix*)
- # as AIX code is always position independent...
- PICFLAG="-O2"
- ;;
- *hpux*)
- if test $ac_cv_prog_cc_Ae = yes; then
- PICFLAG="+z +ESnolit"
- elif test "${GCC}" = "yes"; then
- PICFLAG="-fPIC"
- fi
- if test "$host_cpu" = "ia64"; then
- PICFLAG="+z"
- fi
- ;;
- *osf*)
- PICFLAG="-fPIC"
- ;;
- *unixware*)
- PICFLAG="-KPIC"
- ;;
- *darwin*)
- PICFLAG="-fno-common"
- ;;
-esac
-AC_SUBST(PICFLAG)
-])
-
-AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_LINKER],
-[
- LD_SHLIB_LINKER="${CC}"
-
- case "$host_os" in
- *irix*)
- LD_SHLIB_LINKER="${PROG_LD}"
- ;;
- esac
-
- AC_SUBST(LD_SHLIB_LINKER)
-])
-
-AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_FLAGS],
-[
- LD_SHLIB_FLAGS="-shared"
-
- case "$host_os" in
- *linux*)
- LD_SHLIB_FLAGS="-shared -Wl,-Bsymbolic"
- ;;
- *solaris*)
- LD_SHLIB_FLAGS="-G"
- if test "${GCC}" = "no"; then
- ## ${CFLAGS} added for building 64-bit shared
- ## libs using Sun's Compiler
- LD_SHLIB_FLAGS="-G \${CFLAGS}"
- fi
- ;;
- *sunos*)
- LD_SHLIB_FLAGS="-G"
- ;;
- *irix*)
- LD_SHLIB_FLAGS="-shared"
- ;;
- *aix*)
- LD_SHLIB_FLAGS="-Wl,-G,-bexpall,-bbigtoc"
- ;;
- *hpux*)
- if test "${GCC}" = "yes"; then
- LD_SHLIB_FLAGS="-shared"
- else
- LD_SHLIB_FLAGS="-b"
- fi
- ;;
- *osf*)
- LD_SHLIB_FLAGS="-shared"
- ;;
- *darwin*)
- LD_SHLIB_FLAGS="-dynamiclib -Wl,-search_paths_first"
- ;;
- esac
-
- AC_SUBST(LD_SHLIB_FLAGS)
-])
-
-AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_DISALLOW_UNDEF_FLAG],
-[
- LD_SHLIB_DISALLOW_UNDEF_FLAG=""
-
- #
- # TODO: enforce error not only warnings
- #
- # NOTE: -Wl,--no-allow-shlib-undefined isn't what we want...
- # as it bails out on broken system libraries
- #
- case "$host_os" in
- *osf*)
- LD_SHLIB_DISALLOW_UNDEF_FLAG="-warning_unresolved"
- ;;
- *darwin*)
- LD_SHLIB_DISALLOW_UNDEF_FLAG="-undefined error"
- ;;
- esac
-
- AC_SUBST(LD_SHLIB_DISALLOW_UNDEF_FLAG)
-])
-
-AC_DEFUN([AC_LIBREPLACE_SHLD],
-[
- AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_LINKER])
- SHLD="$LD_SHLIB_LINKER"
- AC_SUBST(SHLD)
-])
-
-AC_DEFUN([AC_LIBREPLACE_SHLD_FLAGS],
-[
- AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_FLAGS])
- AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_DISALLOW_UNDEF_FLAG])
- SHLD_FLAGS="$LD_SHLIB_FLAGS $LD_SHLIB_DISALLOW_UNDEF_FLAG"
- AC_SUBST(SHLD_FLAGS)
-])
-
-AC_DEFUN([AC_LD_SHLIBEXT],
-[
- SHLIBEXT="so"
- case "$host_os" in
- *hpux*)
- if test "$host_cpu" = "ia64"; then
- SHLIBEXT="so"
- else
- SHLIBEXT="sl"
- fi
- ;;
- *darwin*)
- SHLIBEXT="dylib"
- ;;
- esac
- AC_SUBST(SHLIBEXT)
-])
-
-AC_DEFUN([AC_LD_SONAMEFLAG],
-[
- AC_SUBST(SONAMEFLAG)
- SONAMEFLAG=""
- case "$host_os" in
- *linux*)
- SONAMEFLAG="-Wl,-soname="
- ;;
- *solaris*)
- SONAMEFLAG="-h "
- if test "${GCC}" = "yes"; then
- SONAMEFLAG="-Wl,-soname="
- fi
- ;;
- *sunos*)
- SONAMEFLAG="-Wl,-h,"
- ;;
- *netbsd* | *freebsd* | *dragonfly* )
- SONAMEFLAG="-Wl,-soname,"
- ;;
- *openbsd*)
- SONAMEFLAG="-Wl,-soname,"
- ;;
- *irix*)
- SONAMEFLAG="-Wl,-soname,"
- ;;
- *hpux*)
- SONAMEFLAG="-Wl,+h,"
- ;;
- *osf*)
- SONAMEFLAG="-Wl,-soname,"
- ;;
- *unixware*)
- SONAMEFLAG="-Wl,-soname,"
- ;;
- *darwin*)
- SONAMEFLAG="#"
- ;;
- *aix*)
- # Not supported
- SONAMEFLAG="#"
- ;;
- esac
-])
-
-AC_DEFUN([AC_LIBREPLACE_MDLD],
-[
- AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_LINKER])
- MDLD="$LD_SHLIB_LINKER"
- AC_SUBST(MDLD)
-])
-
-AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG],
-[
- LD_ALLOW_SHLIB_UNDEF_FLAG=""
-
- case "$host_os" in
- *linux*)
- LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,--allow-shlib-undefined"
- ;;
- *osf*)
- LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-expect_unresolved,\"*\""
- ;;
- *darwin*)
- LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined dynamic_lookup"
- ;;
- *aix*)
- LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-bnoentry"
- ;;
- esac
-
- AC_SUBST(LD_SHLIB_ALLOW_UNDEF_FLAG)
-])
-
-AC_DEFUN([AC_LIBREPLACE_MDLD_FLAGS],
-[
- AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_FLAGS])
- AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG])
- MDLD_FLAGS="$LD_SHLIB_FLAGS $LD_SHLIB_ALLOW_UNDEF_FLAG"
- AC_SUBST(MDLD_FLAGS)
-])
-
-AC_DEFUN([AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR],
-[
- case "$host_os" in
- *linux*)
- LIB_PATH_VAR=LD_LIBRARY_PATH
- ;;
- *netbsd*)
- LIB_PATH_VAR=LD_LIBRARY_PATH
- ;;
- *solaris*)
- LIB_PATH_VAR=LD_LIBRARY_PATH
- ;;
- *hpux*)
- LIB_PATH_VAR=SHLIB_PATH
- ;;
- *osf*)
- LIB_PATH_VAR=LD_LIBRARY_PATH
- ;;
- *aix*)
- LIB_PATH_VAR=LIB_PATH
- ;;
- *irix*)
- LIB_PATH_VAR=LD_LIBRARY_PATH
- ;;
- *darwin*)
- LIB_PATH_VAR=DYLD_LIBRARY_PATH
- ;;
- esac
-
- AC_SUBST(LIB_PATH_VAR)
-])
diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4
deleted file mode 100644
index 1856eacf66..0000000000
--- a/source4/lib/replace/libreplace_macros.m4
+++ /dev/null
@@ -1,332 +0,0 @@
-#
-# This is a collection of useful autoconf macros
-#
-
-############################################
-# Check if the compiler handles c99 struct initialization, and if not try -AC99 and -c99 flags
-# Usage: LIBREPLACE_C99_STRUCT_INIT(success-action,failure-action)
-# changes CFLAGS to add -AC99 or -c99 if needed
-AC_DEFUN([LIBREPLACE_C99_STRUCT_INIT],
-[
-saved_CFLAGS="$CFLAGS";
-c99_init=no
-if test x"$c99_init" = x"no"; then
- AC_MSG_CHECKING(for C99 designated initializers)
- CFLAGS="$saved_CFLAGS";
- AC_TRY_COMPILE([#include <stdio.h>],
- [ struct foo {int x;char y;};
- struct foo bar = { .y = 'X', .x = 1 };
- ],
- [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
-fi
-if test x"$c99_init" = x"no"; then
- AC_MSG_CHECKING(for C99 designated initializers with -AC99)
- CFLAGS="$saved_CFLAGS -AC99";
- AC_TRY_COMPILE([#include <stdio.h>],
- [ struct foo {int x;char y;};
- struct foo bar = { .y = 'X', .x = 1 };
- ],
- [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
-fi
-if test x"$c99_init" = x"no"; then
- AC_MSG_CHECKING(for C99 designated initializers with -qlanglvl=extc99)
- CFLAGS="$saved_CFLAGS -qlanglvl=extc99";
- AC_TRY_COMPILE([#include <stdio.h>],
- [ struct foo {int x;char y;};
- struct foo bar = { .y = 'X', .x = 1 };
- ],
- [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
-fi
-if test x"$c99_init" = x"no"; then
- AC_MSG_CHECKING(for C99 designated initializers with -qlanglvl=stdc99)
- CFLAGS="$saved_CFLAGS -qlanglvl=stdc99";
- AC_TRY_COMPILE([#include <stdio.h>],
- [ struct foo {int x;char y;};
- struct foo bar = { .y = 'X', .x = 1 };
- ],
- [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
-fi
-if test x"$c99_init" = x"no"; then
- AC_MSG_CHECKING(for C99 designated initializers with -c99)
- CFLAGS="$saved_CFLAGS -c99"
- AC_TRY_COMPILE([#include <stdio.h>],
- [ struct foo {int x;char y;};
- struct foo bar = { .y = 'X', .x = 1 };
- ],
- [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
-fi
-
-if test "`uname`" = "HP-UX"; then
- if test "$ac_cv_c_compiler_gnu" = no; then
- # special override for broken HP-UX compiler - I can't find a way to test
- # this properly (its a compiler bug)
- CFLAGS="$CFLAGS -AC99";
- c99_init=yes;
- fi
-fi
-
-if test x"$c99_init" = x"yes"; then
- saved_CFLAGS=""
- $1
-else
- CFLAGS="$saved_CFLAGS"
- saved_CFLAGS=""
- $2
-fi
-])
-
-dnl AC_PROG_CC_FLAG(flag)
-AC_DEFUN(AC_PROG_CC_FLAG,
-[AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
-[echo 'void f(){}' > conftest.c
-if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
- ac_cv_prog_cc_$1=yes
-else
- ac_cv_prog_cc_$1=no
-fi
-rm -f conftest*
-])])
-
-dnl see if a declaration exists for a function or variable
-dnl defines HAVE_function_DECL if it exists
-dnl AC_HAVE_DECL(var, includes)
-AC_DEFUN(AC_HAVE_DECL,
-[
- AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
- AC_TRY_COMPILE([$2],[int i = (int)$1],
- ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
- if test x"$ac_cv_have_$1_decl" = x"yes"; then
- AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
- fi
-])
-
-
-# AC_CHECK_LIB_EXT(LIBRARY, [EXT_LIBS], [FUNCTION],
-# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
-# [ADD-ACTION-IF-FOUND],[OTHER-LIBRARIES])
-# ------------------------------------------------------
-#
-# Use a cache variable name containing both the library and function name,
-# because the test really is for library $1 defining function $3, not
-# just for library $1. Separate tests with the same $1 and different $3s
-# may have different results.
-#
-# Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$3])
-# is asking for trouble, since AC_CHECK_LIB($lib, fun) would give
-# ac_cv_lib_$lib_fun, which is definitely not what was meant. Hence
-# the AS_LITERAL_IF indirection.
-#
-# FIXME: This macro is extremely suspicious. It DEFINEs unconditionally,
-# whatever the FUNCTION, in addition to not being a *S macro. Note
-# that the cache does depend upon the function we are looking for.
-#
-# It is on purpose we used `ac_check_lib_ext_save_LIBS' and not just
-# `ac_save_LIBS': there are many macros which don't want to see `LIBS'
-# changed but still want to use AC_CHECK_LIB_EXT, so they save `LIBS'.
-# And ``ac_save_LIBS' is too tempting a name, so let's leave them some
-# freedom.
-AC_DEFUN([AC_CHECK_LIB_EXT],
-[
-AH_CHECK_LIB_EXT([$1])
-ac_check_lib_ext_save_LIBS=$LIBS
-LIBS="-l$1 $$2 $7 $LIBS"
-AS_LITERAL_IF([$1],
- [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1])],
- [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1''])])dnl
-
-m4_ifval([$3],
- [
- AH_CHECK_FUNC_EXT([$3])
- AS_LITERAL_IF([$1],
- [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1_$3])],
- [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1''_$3])])dnl
- AC_CACHE_CHECK([for $3 in -l$1], ac_Lib_func,
- [AC_TRY_LINK_FUNC($3,
- [AS_VAR_SET(ac_Lib_func, yes);
- AS_VAR_SET(ac_Lib_ext, yes)],
- [AS_VAR_SET(ac_Lib_func, no);
- AS_VAR_SET(ac_Lib_ext, no)])
- ])
- AS_IF([test AS_VAR_GET(ac_Lib_func) = yes],
- [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$3))])dnl
- AS_VAR_POPDEF([ac_Lib_func])dnl
- ],[
- AC_CACHE_CHECK([for -l$1], ac_Lib_ext,
- [AC_TRY_LINK_FUNC([main],
- [AS_VAR_SET(ac_Lib_ext, yes)],
- [AS_VAR_SET(ac_Lib_ext, no)])
- ])
- ])
-LIBS=$ac_check_lib_ext_save_LIBS
-
-AS_IF([test AS_VAR_GET(ac_Lib_ext) = yes],
- [m4_default([$4],
- [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
- case "$$2" in
- *-l$1*)
- ;;
- *)
- $2="-l$1 $$2"
- ;;
- esac])
- [$6]
- ],
- [$5])dnl
-AS_VAR_POPDEF([ac_Lib_ext])dnl
-])# AC_CHECK_LIB_EXT
-
-# AH_CHECK_LIB_EXT(LIBNAME)
-# ---------------------
-m4_define([AH_CHECK_LIB_EXT],
-[AH_TEMPLATE(AS_TR_CPP(HAVE_LIB$1),
- [Define to 1 if you have the `]$1[' library (-l]$1[).])])
-
-dnl AC_SEARCH_LIBS_EXT(FUNCTION, SEARCH-LIBS, EXT_LIBS,
-dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
-dnl [OTHER-LIBRARIES])
-dnl --------------------------------------------------------
-dnl Search for a library defining FUNC, if it's not already available.
-AC_DEFUN([AC_SEARCH_LIBS_EXT],
-[AC_CACHE_CHECK([for library containing $1], [ac_cv_search_ext_$1],
-[
-ac_func_search_ext_save_LIBS=$LIBS
-ac_cv_search_ext_$1=no
-AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
- [ac_cv_search_ext_$1="none required"])
-if test "$ac_cv_search_ext_$1" = no; then
- for ac_lib in $2; do
- LIBS="-l$ac_lib $$3 $6 $ac_func_search_save_ext_LIBS"
- AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
- [ac_cv_search_ext_$1="-l$ac_lib"
-break])
- done
-fi
-LIBS=$ac_func_search_ext_save_LIBS])
-AS_IF([test "$ac_cv_search_ext_$1" != no],
- [test "$ac_cv_search_ext_$1" = "none required" || $3="$ac_cv_search_ext_$1 $$3"
- $4],
- [$5])dnl
-])
-
-dnl check for a function in a $LIBS and $OTHER_LIBS libraries variable.
-dnl AC_CHECK_FUNC_EXT(func,OTHER_LIBS,IF-TRUE,IF-FALSE)
-AC_DEFUN([AC_CHECK_FUNC_EXT],
-[
- AH_CHECK_FUNC_EXT($1)
- ac_check_func_ext_save_LIBS=$LIBS
- LIBS="$2 $LIBS"
- AS_VAR_PUSHDEF([ac_var], [ac_cv_func_ext_$1])dnl
- AC_CACHE_CHECK([for $1], ac_var,
- [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
- [AS_VAR_SET(ac_var, yes)],
- [AS_VAR_SET(ac_var, no)])])
- LIBS=$ac_check_func_ext_save_LIBS
- AS_IF([test AS_VAR_GET(ac_var) = yes],
- [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1])) $3],
- [$4])dnl
-AS_VAR_POPDEF([ac_var])dnl
-])# AC_CHECK_FUNC
-
-# AH_CHECK_FUNC_EXT(FUNCNAME)
-# ---------------------
-m4_define([AH_CHECK_FUNC_EXT],
-[AH_TEMPLATE(AS_TR_CPP(HAVE_$1),
- [Define to 1 if you have the `]$1[' function.])])
-
-dnl Define an AC_DEFINE with ifndef guard.
-dnl AC_N_DEFINE(VARIABLE [, VALUE])
-AC_DEFUN([AC_N_DEFINE],
-[
-AH_VERBATIM([$1], [
-#ifndef $1
-# undef $1
-#endif
-])
-
- cat >>confdefs.h <<\EOF
-#ifndef $1
-[#define] $1 m4_if($#, 1, 1, [$2])
-#endif
-EOF
-])
-
-dnl Add an #include
-dnl AC_ADD_INCLUDE(VARIABLE)
-define(AC_ADD_INCLUDE,
-[cat >> confdefs.h <<\EOF
-[#include] $1
-EOF
-])
-
-dnl remove an #include
-dnl AC_REMOVE_INCLUDE(VARIABLE)
-define(AC_REMOVE_INCLUDE,
-[
-grep -v '[#include] $1' confdefs.h >confdefs.h.tmp
-cat confdefs.h.tmp > confdefs.h
-rm confdefs.h.tmp
-])
-
-dnl remove an #define
-dnl AC_REMOVE_DEFINE(VARIABLE)
-define(AC_REMOVE_DEFINE,
-[
-grep -v '[#define] $1 ' confdefs.h |grep -v '[#define] $1[$]'>confdefs.h.tmp
-cat confdefs.h.tmp > confdefs.h
-rm confdefs.h.tmp
-])
-
-dnl AS_HELP_STRING is not available in autoconf 2.57, and AC_HELP_STRING is deprecated
-dnl in autoconf 2.59, so define AS_HELP_STRING to be AC_HELP_STRING unless it is already
-dnl defined.
-m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))])
-
-dnl check if the prototype in the header matches the given one
-dnl AC_VERIFY_C_PROTOTYPE(prototype,functionbody,[IF-TRUE].[IF-FALSE],[extraheaders])
-AC_DEFUN(AC_VERIFY_C_PROTOTYPE,
-[AC_CACHE_CHECK([for prototype $1], AS_TR_SH([ac_cv_c_prototype_$1]),
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([
- AC_INCLUDES_DEFAULT
- $5
- $1
- {
- $2
- }
- ])],[
- AS_TR_SH([ac_cv_c_prototype_$1])=yes
- ],[
- AS_TR_SH([ac_cv_c_prototype_$1])=no
- ])
-)
-AS_IF([test $AS_TR_SH([ac_cv_c_prototype_$1]) = yes],[$3],[$4])
-])
-
-AC_DEFUN(LIBREPLACE_PROVIDE_HEADER,
-[AC_CHECK_HEADER([$1],
- [ AC_CONFIG_COMMANDS(rm-$1, [rm -f $libreplacedir/$1], [libreplacedir=$libreplacedir]) ],
- [ AC_CONFIG_COMMANDS(mk-$1, [echo "#include \"replace.h\"" > $libreplacedir/$1], [libreplacedir=$libreplacedir]) ]
- )
-])
-
-dnl AC_HAVE_TYPE(TYPE,INCLUDES)
-AC_DEFUN([AC_HAVE_TYPE], [
-AC_REQUIRE([AC_HEADER_STDC])
-cv=`echo "$1" | sed 'y%./+- %__p__%'`
-AC_MSG_CHECKING(for $1)
-AC_CACHE_VAL([ac_cv_type_$cv],
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-AC_INCLUDES_DEFAULT
-$2]],
-[[$1 foo;]])],
-[eval "ac_cv_type_$cv=yes"],
-[eval "ac_cv_type_$cv=no"]))dnl
-ac_foo=`eval echo \\$ac_cv_type_$cv`
-AC_MSG_RESULT($ac_foo)
-if test "$ac_foo" = yes; then
- ac_tr_hdr=HAVE_`echo $1 | sed 'y%abcdefghijklmnopqrstuvwxyz./- %ABCDEFGHIJKLMNOPQRSTUVWXYZ____%'`
-if false; then
- AC_CHECK_TYPES($1)
-fi
- AC_DEFINE_UNQUOTED($ac_tr_hdr, 1, [Define if you have type `$1'])
-fi
-])
diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4
deleted file mode 100644
index 4edb55c03a..0000000000
--- a/source4/lib/replace/libreplace_network.m4
+++ /dev/null
@@ -1,377 +0,0 @@
-AC_DEFUN_ONCE(AC_LIBREPLACE_NETWORK_CHECKS,
-[
-echo "LIBREPLACE_NETWORK_CHECKS: START"
-
-AC_DEFINE(LIBREPLACE_NETWORK_CHECKS, 1, [LIBREPLACE_NETWORK_CHECKS were used])
-LIBREPLACE_NETWORK_OBJS=""
-LIBREPLACE_NETWORK_LIBS=""
-
-AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h)
-AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
-AC_CHECK_HEADERS(sys/sockio.h sys/un.h)
-
-dnl we need to check that net/if.h really can be used, to cope with hpux
-dnl where including it always fails
-AC_CACHE_CHECK([for usable net/if.h],libreplace_cv_USABLE_NET_IF_H,[
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([
- AC_INCLUDES_DEFAULT
- #if HAVE_SYS_SOCKET_H
- # include <sys/socket.h>
- #endif
- #include <net/if.h>
- int main(void) {return 0;}])],
- [libreplace_cv_USABLE_NET_IF_H=yes],
- [libreplace_cv_USABLE_NET_IF_H=no]
- )
-])
-if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then
- AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h)
-fi
-
-AC_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])
-AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])
-AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
-AC_HAVE_TYPE([struct sockaddr], [#include <sys/socket.h>])
-AC_HAVE_TYPE([struct sockaddr_storage], [
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-])
-AC_HAVE_TYPE([struct sockaddr_in6], [
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-])
-
-if test x"$ac_cv_type_struct_sockaddr_storage" = x"yes"; then
-AC_CHECK_MEMBER(struct sockaddr_storage.ss_family,
- AC_DEFINE(HAVE_SS_FAMILY, 1, [Defined if struct sockaddr_storage has ss_family field]),,
- [
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
- ])
-
-if test x"$ac_cv_member_struct_sockaddr_storage_ss_family" != x"yes"; then
-AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family,
- AC_DEFINE(HAVE___SS_FAMILY, 1, [Defined if struct sockaddr_storage has __ss_family field]),,
- [
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
- ])
-fi
-fi
-
-AC_CACHE_CHECK([for sin_len in sock],libreplace_cv_HAVE_SOCK_SIN_LEN,[
- AC_TRY_COMPILE(
- [
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
- ],[
-struct sockaddr_in sock; sock.sin_len = sizeof(sock);
- ],[
- libreplace_cv_HAVE_SOCK_SIN_LEN=yes
- ],[
- libreplace_cv_HAVE_SOCK_SIN_LEN=no
- ])
-])
-if test x"$libreplace_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
- AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
-fi
-
-############################################
-# check for unix domain sockets
-AC_CACHE_CHECK([for unix domain sockets],libreplace_cv_HAVE_UNIXSOCKET,[
- AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <sys/socket.h>
-#include <sys/un.h>
- ],[
-struct sockaddr_un sunaddr;
-sunaddr.sun_family = AF_UNIX;
- ],[
- libreplace_cv_HAVE_UNIXSOCKET=yes
- ],[
- libreplace_cv_HAVE_UNIXSOCKET=no
- ])
-])
-if test x"$libreplace_cv_HAVE_UNIXSOCKET" = x"yes"; then
- AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
-fi
-
-dnl The following test is roughl taken from the cvs sources.
-dnl
-dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
-dnl The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
-dnl libsocket.so which has a bad implementation of gethostbyname (it
-dnl only looks in /etc/hosts), so we only look for -lsocket if we need
-dnl it.
-AC_CHECK_FUNCS(connect)
-if test x"$ac_cv_func_connect" = x"no"; then
- AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, connect)
- AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, connect)
- AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, connect)
- AC_CHECK_LIB_EXT(inet, LIBREPLACE_NETWORK_LIBS, connect)
- dnl We can't just call AC_CHECK_FUNCS(connect) here,
- dnl because the value has been cached.
- if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" ||
- test x"$ac_cv_lib_ext_nsl_connect" = x"yes" ||
- test x"$ac_cv_lib_ext_socket_connect" = x"yes" ||
- test x"$ac_cv_lib_ext_inet_connect" = x"yes"
- then
- AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
- fi
-fi
-
-AC_CHECK_FUNCS(gethostbyname)
-if test x"$ac_cv_func_gethostbyname" = x"no"; then
- AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, gethostbyname)
- AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, gethostbyname)
- AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, gethostbyname)
- dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here,
- dnl because the value has been cached.
- if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" ||
- test x"$ac_cv_lib_ext_nsl_gethostbyname" = x"yes" ||
- test x"$ac_cv_lib_ext_socket_gethostbyname" = x"yes"
- then
- AC_DEFINE(HAVE_GETHOSTBYNAME,1,
- [Whether the system has gethostbyname()])
- fi
-fi
-
-dnl HP-UX has if_nametoindex in -lipv6
-AC_CHECK_FUNCS(if_nametoindex)
-if test x"$ac_cv_func_if_nametoindex" = x"no"; then
- AC_CHECK_LIB_EXT(ipv6, LIBREPLACE_NETWORK_LIBS, if_nametoindex)
- dnl We can't just call AC_CHECK_FUNCS(if_nametoindex) here,
- dnl because the value has been cached.
- if test x"$ac_cv_lib_ext_ipv6_if_nametoindex" = x"yes"
- then
- AC_DEFINE(HAVE_IF_NAMETOINDEX, 1,
- [Whether the system has if_nametoindex()])
- fi
-fi
-
-# The following tests need LIBS="${LIBREPLACE_NETWORK_LIBS}"
-old_LIBS=$LIBS
-LIBS="${LIBREPLACE_NETWORK_LIBS}"
-SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I$libreplacedir"
-
-AC_CHECK_FUNCS(socketpair,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} socketpair.o"])
-
-AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[
-AC_TRY_RUN([
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-main() { struct in_addr ip; ip.s_addr = 0x12345678;
-if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
- strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); }
-exit(1);}],
- libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)])
-
-AC_CHECK_FUNCS(inet_ntoa,[],[libreplace_cv_REPLACE_INET_NTOA=yes])
-if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then
- AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
- LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_ntoa.o"
-fi
-
-AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_aton.o"])
-
-AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_ntop.o"])
-
-AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_pton.o"])
-
-dnl test for getaddrinfo/getnameinfo
-AC_CACHE_CHECK([for getaddrinfo],libreplace_cv_HAVE_GETADDRINFO,[
-AC_TRY_LINK([
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
-#include <sys/socket.h>
-#include <netdb.h>],
-[
-struct sockaddr sa;
-struct addrinfo *ai = NULL;
-int ret = getaddrinfo(NULL, NULL, NULL, &ai);
-if (ret != 0) {
- const char *es = gai_strerror(ret);
-}
-freeaddrinfo(ai);
-ret = getnameinfo(&sa, sizeof(sa),
- NULL, 0,
- NULL, 0, 0);
-
-],
-libreplace_cv_HAVE_GETADDRINFO=yes,libreplace_cv_HAVE_GETADDRINFO=no)])
-if test x"$libreplace_cv_HAVE_GETADDRINFO" = x"yes"; then
- AC_DEFINE(HAVE_GETADDRINFO,1,[Whether the system has getaddrinfo])
- AC_DEFINE(HAVE_GETNAMEINFO,1,[Whether the system has getnameinfo])
- AC_DEFINE(HAVE_FREEADDRINFO,1,[Whether the system has freeaddrinfo])
- AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror])
-else
- LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} getaddrinfo.o"
-fi
-
-AC_CHECK_HEADERS([ifaddrs.h])
-
-dnl Used when getifaddrs is not available
-AC_CHECK_MEMBERS([struct sockaddr.sa_len],
- [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has a sa_len member])],
- [],
- [#include <sys/socket.h>])
-
-dnl test for getifaddrs and freeifaddrs
-AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[
-AC_TRY_COMPILE([
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <ifaddrs.h>
-#include <netdb.h>],
-[
-struct ifaddrs *ifp = NULL;
-int ret = getifaddrs (&ifp);
-freeifaddrs(ifp);
-],
-libreplace_cv_HAVE_GETIFADDRS=yes,libreplace_cv_HAVE_GETIFADDRS=no)])
-if test x"$libreplace_cv_HAVE_GETIFADDRS" = x"yes"; then
- AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs])
- AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs])
- AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available])
-fi
-
-##################
-# look for a method of finding the list of network interfaces
-iface=no;
-AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[
-AC_TRY_RUN([
-#define HAVE_IFACE_GETIFADDRS 1
-#define NO_CONFIG_H 1
-#define AUTOCONF_TEST 1
-#define SOCKET_WRAPPER_NOT_REPLACE
-#include "$libreplacedir/replace.c"
-#include "$libreplacedir/inet_ntop.c"
-#include "$libreplacedir/snprintf.c"
-#include "$libreplacedir/getifaddrs.c"
-#define getifaddrs_test main
-#include "$libreplacedir/test/getifaddrs.c"],
- libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)])
-if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then
- iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available])
-else
- LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} getifaddrs.o"
-fi
-
-
-if test $iface = no; then
-AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[
-AC_TRY_RUN([
-#define HAVE_IFACE_AIX 1
-#define NO_CONFIG_H 1
-#define AUTOCONF_TEST 1
-#undef _XOPEN_SOURCE_EXTENDED
-#define SOCKET_WRAPPER_NOT_REPLACE
-#include "$libreplacedir/replace.c"
-#include "$libreplacedir/inet_ntop.c"
-#include "$libreplacedir/snprintf.c"
-#include "$libreplacedir/getifaddrs.c"
-#define getifaddrs_test main
-#include "$libreplacedir/test/getifaddrs.c"],
- libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)])
-if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then
- iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
-fi
-fi
-
-
-if test $iface = no; then
-AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[
-AC_TRY_RUN([
-#define HAVE_IFACE_IFCONF 1
-#define NO_CONFIG_H 1
-#define AUTOCONF_TEST 1
-#define SOCKET_WRAPPER_NOT_REPLACE
-#include "$libreplacedir/replace.c"
-#include "$libreplacedir/inet_ntop.c"
-#include "$libreplacedir/snprintf.c"
-#include "$libreplacedir/getifaddrs.c"
-#define getifaddrs_test main
-#include "$libreplacedir/test/getifaddrs.c"],
- libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)])
-if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then
- iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
-fi
-fi
-
-if test $iface = no; then
-AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[
-AC_TRY_RUN([
-#define HAVE_IFACE_IFREQ 1
-#define NO_CONFIG_H 1
-#define AUTOCONF_TEST 1
-#define SOCKET_WRAPPER_NOT_REPLACE
-#include "$libreplacedir/replace.c"
-#include "$libreplacedir/inet_ntop.c"
-#include "$libreplacedir/snprintf.c"
-#include "$libreplacedir/getifaddrs.c"
-#define getifaddrs_test main
-#include "$libreplacedir/test/getifaddrs.c"],
- libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)])
-if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then
- iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
-fi
-fi
-
-dnl test for ipv6
-AC_CACHE_CHECK([for ipv6 support],libreplace_cv_HAVE_IPV6,[
- AC_TRY_LINK([
-#include <stdlib.h> /* for NULL */
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netdb.h>
- ],
- [
-struct sockaddr_storage sa_store;
-struct addrinfo *ai = NULL;
-struct in6_addr in6addr;
-int idx = if_nametoindex("iface1");
-int s = socket(AF_INET6, SOCK_STREAM, 0);
-int ret = getaddrinfo(NULL, NULL, NULL, &ai);
-if (ret != 0) {
- const char *es = gai_strerror(ret);
-}
-freeaddrinfo(ai);
- ],[
- libreplace_cv_HAVE_IPV6=yes
- ],[
- libreplace_cv_HAVE_IPV6=no
- ])
-])
-if test x"$libreplace_cv_HAVE_IPV6" = x"yes"; then
- AC_DEFINE(HAVE_IPV6,1,[Whether the system has IPv6 support])
-fi
-
-LIBS=$old_LIBS
-CPPFLAGS="$SAVE_CPPFLAGS"
-
-LIBREPLACEOBJ="${LIBREPLACEOBJ} ${LIBREPLACE_NETWORK_OBJS}"
-
-echo "LIBREPLACE_NETWORK_CHECKS: END"
-]) dnl end AC_LIBREPLACE_NETWORK_CHECKS
diff --git a/source4/lib/replace/repdir.m4 b/source4/lib/replace/repdir.m4
deleted file mode 100644
index f53a4c2974..0000000000
--- a/source4/lib/replace/repdir.m4
+++ /dev/null
@@ -1,78 +0,0 @@
-AC_CACHE_CHECK([for broken readdir],libreplace_cv_READDIR_NEEDED,[
- AC_TRY_RUN([
-#define test_readdir_os2_delete main
-#include "$libreplacedir/test/os2_delete.c"],
- [libreplace_cv_READDIR_NEEDED=no],
- [libreplace_cv_READDIR_NEEDED=yes],
- [libreplace_cv_READDIR_NEEDED="assuming not"])
-])
-
-#
-# try to replace with getdirentries() if needed
-#
-if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then
-AC_CHECK_FUNCS(getdirentries)
-AC_VERIFY_C_PROTOTYPE([long telldir(const DIR *dir)],
- [
- return 0;
- ],[
- AC_DEFINE(TELLDIR_TAKES_CONST_DIR, 1, [Whether telldir takes a const pointer])
- ],[],[
- #include <dirent.h>
- ])
-
-AC_VERIFY_C_PROTOTYPE([int seekdir(DIR *dir, long ofs)],
- [
- return 0;
- ],[
- AC_DEFINE(SEEKDIR_RETURNS_INT, 1, [Whether seekdir returns an int])
- ],[],[
- #include <dirent.h>
- ])
-AC_CACHE_CHECK([for replacing readdir using getdirentries()],libreplace_cv_READDIR_GETDIRENTRIES,[
- AC_TRY_RUN([
-#define _LIBREPLACE_REPLACE_H
-#include "$libreplacedir/repdir_getdirentries.c"
-#define test_readdir_os2_delete main
-#include "$libreplacedir/test/os2_delete.c"],
- [libreplace_cv_READDIR_GETDIRENTRIES=yes],
- [libreplace_cv_READDIR_GETDIRENTRIES=no])
-])
-fi
-if test x"$libreplace_cv_READDIR_GETDIRENTRIES" = x"yes"; then
- AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
- AC_DEFINE(REPLACE_READDIR_GETDIRENTRIES,1,[replace readdir using getdirentries()])
- LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdirentries.o"
- libreplace_cv_READDIR_NEEDED=no
-fi
-
-#
-# try to replace with getdents() if needed
-#
-if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then
-AC_CHECK_FUNCS(getdents)
-AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_cv_READDIR_GETDENTS,[
- AC_TRY_RUN([
-#define _LIBREPLACE_REPLACE_H
-#error _donot_use_getdents_replacement_anymore
-#include "$libreplacedir/repdir_getdents.c"
-#define test_readdir_os2_delete main
-#include "$libreplacedir/test/os2_delete.c"],
- [libreplace_cv_READDIR_GETDENTS=yes],
- [libreplace_cv_READDIR_GETDENTS=no])
-])
-fi
-if test x"$libreplace_cv_READDIR_GETDENTS" = x"yes"; then
- AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
- AC_DEFINE(REPLACE_READDIR_GETDENTS,1,[replace readdir using getdents()])
- LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdents.o"
- libreplace_cv_READDIR_NEEDED=no
-fi
-
-AC_MSG_CHECKING([a usable readdir()])
-if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then
- AC_MSG_RESULT(no)
- AC_MSG_WARN([the provided readdir() is broken])
-else
- AC_MSG_RESULT(yes)
-fi
diff --git a/source4/lib/replace/repdir_getdents.c b/source4/lib/replace/repdir_getdents.c
deleted file mode 100644
index afc634a796..0000000000
--- a/source4/lib/replace/repdir_getdents.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Copyright (C) Andrew Tridgell 2005
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-/*
- a replacement for opendir/readdir/telldir/seekdir/closedir for BSD systems
-
- This is needed because the existing directory handling in FreeBSD
- and OpenBSD (and possibly NetBSD) doesn't correctly handle unlink()
- on files in a directory where telldir() has been used. On a block
- boundary it will occasionally miss a file when seekdir() is used to
- return to a position previously recorded with telldir().
-
- This also fixes a severe performance and memory usage problem with
- telldir() on BSD systems. Each call to telldir() in BSD adds an
- entry to a linked list, and those entries are cleaned up on
- closedir(). This means with a large directory closedir() can take an
- arbitrary amount of time, causing network timeouts as millions of
- telldir() entries are freed
-
- Note! This replacement code is not portable. It relies on getdents()
- always leaving the file descriptor at a seek offset that is a
- multiple of DIR_BUF_SIZE. If the code detects that this doesn't
- happen then it will abort(). It also does not handle directories
- with offsets larger than can be stored in a long,
-
- This code is available under other free software licenses as
- well. Contact the author.
-*/
-
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <dirent.h>
-
-#define DIR_BUF_BITS 9
-#define DIR_BUF_SIZE (1<<DIR_BUF_BITS)
-
-struct dir_buf {
- int fd;
- int nbytes, ofs;
- off_t seekpos;
- char buf[DIR_BUF_SIZE];
-};
-
-DIR *opendir(const char *dname)
-{
- struct dir_buf *d;
- struct stat sb;
- d = malloc(sizeof(*d));
- if (d == NULL) {
- errno = ENOMEM;
- return NULL;
- }
- d->fd = open(dname, O_RDONLY);
- if (d->fd == -1) {
- free(d);
- return NULL;
- }
- if (fstat(d->fd, &sb) < 0) {
- close(d->fd);
- free(d);
- return NULL;
- }
- if (!S_ISDIR(sb.st_mode)) {
- close(d->fd);
- free(d);
- errno = ENOTDIR;
- return NULL;
- }
- d->ofs = 0;
- d->seekpos = 0;
- d->nbytes = 0;
- return (DIR *)d;
-}
-
-struct dirent *readdir(DIR *dir)
-{
- struct dir_buf *d = (struct dir_buf *)dir;
- struct dirent *de;
-
- if (d->ofs >= d->nbytes) {
- d->seekpos = lseek(d->fd, 0, SEEK_CUR);
- d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE);
- d->ofs = 0;
- }
- if (d->ofs >= d->nbytes) {
- return NULL;
- }
- de = (struct dirent *)&d->buf[d->ofs];
- d->ofs += de->d_reclen;
- return de;
-}
-
-long telldir(DIR *dir)
-{
- struct dir_buf *d = (struct dir_buf *)dir;
- if (d->ofs >= d->nbytes) {
- d->seekpos = lseek(d->fd, 0, SEEK_CUR);
- d->ofs = 0;
- d->nbytes = 0;
- }
- /* this relies on seekpos always being a multiple of
- DIR_BUF_SIZE. Is that always true on BSD systems? */
- if (d->seekpos & (DIR_BUF_SIZE-1)) {
- abort();
- }
- return d->seekpos + d->ofs;
-}
-
-void seekdir(DIR *dir, long ofs)
-{
- struct dir_buf *d = (struct dir_buf *)dir;
- d->seekpos = lseek(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET);
- d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE);
- d->ofs = 0;
- while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) {
- if (readdir(dir) == NULL) break;
- }
-}
-
-void rewinddir(DIR *dir)
-{
- seekdir(dir, 0);
-}
-
-int closedir(DIR *dir)
-{
- struct dir_buf *d = (struct dir_buf *)dir;
- int r = close(d->fd);
- if (r != 0) {
- return r;
- }
- free(d);
- return 0;
-}
-
-#ifndef dirfd
-/* darn, this is a macro on some systems. */
-int dirfd(DIR *dir)
-{
- struct dir_buf *d = (struct dir_buf *)dir;
- return d->fd;
-}
-#endif
diff --git a/source4/lib/replace/repdir_getdirentries.c b/source4/lib/replace/repdir_getdirentries.c
deleted file mode 100644
index 197e5931fc..0000000000
--- a/source4/lib/replace/repdir_getdirentries.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Copyright (C) Andrew Tridgell 2005
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-/*
- a replacement for opendir/readdir/telldir/seekdir/closedir for BSD
- systems using getdirentries
-
- This is needed because the existing directory handling in FreeBSD
- and OpenBSD (and possibly NetBSD) doesn't correctly handle unlink()
- on files in a directory where telldir() has been used. On a block
- boundary it will occasionally miss a file when seekdir() is used to
- return to a position previously recorded with telldir().
-
- This also fixes a severe performance and memory usage problem with
- telldir() on BSD systems. Each call to telldir() in BSD adds an
- entry to a linked list, and those entries are cleaned up on
- closedir(). This means with a large directory closedir() can take an
- arbitrary amount of time, causing network timeouts as millions of
- telldir() entries are freed
-
- Note! This replacement code is not portable. It relies on
- getdirentries() always leaving the file descriptor at a seek offset
- that is a multiple of DIR_BUF_SIZE. If the code detects that this
- doesn't happen then it will abort(). It also does not handle
- directories with offsets larger than can be stored in a long,
-
- This code is available under other free software licenses as
- well. Contact the author.
-*/
-
-#include "replace.h"
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <dirent.h>
-
-#define DIR_BUF_BITS 9
-#define DIR_BUF_SIZE (1<<DIR_BUF_BITS)
-
-struct dir_buf {
- int fd;
- int nbytes, ofs;
- off_t seekpos;
- char buf[DIR_BUF_SIZE];
-};
-
-DIR *opendir(const char *dname)
-{
- struct dir_buf *d;
- struct stat sb;
- d = malloc(sizeof(*d));
- if (d == NULL) {
- errno = ENOMEM;
- return NULL;
- }
- d->fd = open(dname, O_RDONLY);
- if (d->fd == -1) {
- free(d);
- return NULL;
- }
- if (fstat(d->fd, &sb) < 0) {
- close(d->fd);
- free(d);
- return NULL;
- }
- if (!S_ISDIR(sb.st_mode)) {
- close(d->fd);
- free(d);
- errno = ENOTDIR;
- return NULL;
- }
- d->ofs = 0;
- d->seekpos = 0;
- d->nbytes = 0;
- return (DIR *)d;
-}
-
-struct dirent *readdir(DIR *dir)
-{
- struct dir_buf *d = (struct dir_buf *)dir;
- struct dirent *de;
-
- if (d->ofs >= d->nbytes) {
- long pos;
- d->nbytes = getdirentries(d->fd, d->buf, DIR_BUF_SIZE, &pos);
- d->seekpos = pos;
- d->ofs = 0;
- }
- if (d->ofs >= d->nbytes) {
- return NULL;
- }
- de = (struct dirent *)&d->buf[d->ofs];
- d->ofs += de->d_reclen;
- return de;
-}
-
-#ifdef TELLDIR_TAKES_CONST_DIR
-long telldir(const DIR *dir)
-#else
-long telldir(DIR *dir)
-#endif
-{
- struct dir_buf *d = (struct dir_buf *)dir;
- if (d->ofs >= d->nbytes) {
- d->seekpos = lseek(d->fd, 0, SEEK_CUR);
- d->ofs = 0;
- d->nbytes = 0;
- }
- /* this relies on seekpos always being a multiple of
- DIR_BUF_SIZE. Is that always true on BSD systems? */
- if (d->seekpos & (DIR_BUF_SIZE-1)) {
- abort();
- }
- return d->seekpos + d->ofs;
-}
-
-#ifdef SEEKDIR_RETURNS_INT
-int seekdir(DIR *dir, long ofs)
-#else
-void seekdir(DIR *dir, long ofs)
-#endif
-{
- struct dir_buf *d = (struct dir_buf *)dir;
- long pos;
- d->seekpos = lseek(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET);
- d->nbytes = getdirentries(d->fd, d->buf, DIR_BUF_SIZE, &pos);
- d->ofs = 0;
- while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) {
- if (readdir(dir) == NULL) break;
- }
-#ifdef SEEKDIR_RETURNS_INT
- return -1;
-#endif
-}
-
-void rewinddir(DIR *dir)
-{
- seekdir(dir, 0);
-}
-
-int closedir(DIR *dir)
-{
- struct dir_buf *d = (struct dir_buf *)dir;
- int r = close(d->fd);
- if (r != 0) {
- return r;
- }
- free(d);
- return 0;
-}
-
-#ifndef dirfd
-/* darn, this is a macro on some systems. */
-int dirfd(DIR *dir)
-{
- struct dir_buf *d = (struct dir_buf *)dir;
- return d->fd;
-}
-#endif
-
-
diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c
deleted file mode 100644
index 98d799b07e..0000000000
--- a/source4/lib/replace/replace.c
+++ /dev/null
@@ -1,616 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- replacement routines for broken systems
- Copyright (C) Andrew Tridgell 1992-1998
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "replace.h"
-
-#include "system/filesys.h"
-#include "system/time.h"
-#include "system/passwd.h"
-#include "system/syslog.h"
-#include "system/locale.h"
-#include "system/wait.h"
-
-void replace_dummy(void);
-void replace_dummy(void) {}
-
-#ifndef HAVE_FTRUNCATE
- /*******************************************************************
-ftruncate for operating systems that don't have it
-********************************************************************/
-int rep_ftruncate(int f, off_t l)
-{
-#ifdef HAVE_CHSIZE
- return chsize(f,l);
-#elif defined(F_FREESP)
- struct flock fl;
-
- fl.l_whence = 0;
- fl.l_len = 0;
- fl.l_start = l;
- fl.l_type = F_WRLCK;
- return fcntl(f, F_FREESP, &fl);
-#else
-#error "you must have a ftruncate function"
-#endif
-}
-#endif /* HAVE_FTRUNCATE */
-
-
-#ifndef HAVE_STRLCPY
-/* like strncpy but does not 0 fill the buffer and always null
- terminates. bufsize is the size of the destination buffer */
-size_t rep_strlcpy(char *d, const char *s, size_t bufsize)
-{
- size_t len = strlen(s);
- size_t ret = len;
- if (bufsize <= 0) return 0;
- if (len >= bufsize) len = bufsize-1;
- memcpy(d, s, len);
- d[len] = 0;
- return ret;
-}
-#endif
-
-#ifndef HAVE_STRLCAT
-/* like strncat but does not 0 fill the buffer and always null
- terminates. bufsize is the length of the buffer, which should
- be one more than the maximum resulting string length */
-size_t rep_strlcat(char *d, const char *s, size_t bufsize)
-{
- size_t len1 = strlen(d);
- size_t len2 = strlen(s);
- size_t ret = len1 + len2;
-
- if (len1+len2 >= bufsize) {
- if (bufsize < (len1+1)) {
- return ret;
- }
- len2 = bufsize - (len1+1);
- }
- if (len2 > 0) {
- memcpy(d+len1, s, len2);
- d[len1+len2] = 0;
- }
- return ret;
-}
-#endif
-
-#ifndef HAVE_MKTIME
-/*******************************************************************
-a mktime() replacement for those who don't have it - contributed by
-C.A. Lademann <cal@zls.com>
-Corrections by richard.kettlewell@kewill.com
-********************************************************************/
-
-#define MINUTE 60
-#define HOUR 60*MINUTE
-#define DAY 24*HOUR
-#define YEAR 365*DAY
-time_t rep_mktime(struct tm *t)
-{
- struct tm *u;
- time_t epoch = 0;
- int n;
- int mon [] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
- y, m, i;
-
- if(t->tm_year < 70)
- return((time_t)-1);
-
- n = t->tm_year + 1900 - 1;
- epoch = (t->tm_year - 70) * YEAR +
- ((n / 4 - n / 100 + n / 400) - (1969 / 4 - 1969 / 100 + 1969 / 400)) * DAY;
-
- y = t->tm_year + 1900;
- m = 0;
-
- for(i = 0; i < t->tm_mon; i++) {
- epoch += mon [m] * DAY;
- if(m == 1 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0))
- epoch += DAY;
-
- if(++m > 11) {
- m = 0;
- y++;
- }
- }
-
- epoch += (t->tm_mday - 1) * DAY;
- epoch += t->tm_hour * HOUR + t->tm_min * MINUTE + t->tm_sec;
-
- if((u = localtime(&epoch)) != NULL) {
- t->tm_sec = u->tm_sec;
- t->tm_min = u->tm_min;
- t->tm_hour = u->tm_hour;
- t->tm_mday = u->tm_mday;
- t->tm_mon = u->tm_mon;
- t->tm_year = u->tm_year;
- t->tm_wday = u->tm_wday;
- t->tm_yday = u->tm_yday;
- t->tm_isdst = u->tm_isdst;
- }
-
- return(epoch);
-}
-#endif /* !HAVE_MKTIME */
-
-
-#ifndef HAVE_INITGROUPS
-/****************************************************************************
- some systems don't have an initgroups call
-****************************************************************************/
-int rep_initgroups(char *name, gid_t id)
-{
-#ifndef HAVE_SETGROUPS
- /* yikes! no SETGROUPS or INITGROUPS? how can this work? */
- errno = ENOSYS;
- return -1;
-#else /* HAVE_SETGROUPS */
-
-#include <grp.h>
-
- gid_t *grouplst = NULL;
- int max_gr = NGROUPS_MAX;
- int ret;
- int i,j;
- struct group *g;
- char *gr;
-
- if((grouplst = malloc(sizeof(gid_t) * max_gr)) == NULL) {
- errno = ENOMEM;
- return -1;
- }
-
- grouplst[0] = id;
- i = 1;
- while (i < max_gr && ((g = (struct group *)getgrent()) != (struct group *)NULL)) {
- if (g->gr_gid == id)
- continue;
- j = 0;
- gr = g->gr_mem[0];
- while (gr && (*gr != (char)NULL)) {
- if (strcmp(name,gr) == 0) {
- grouplst[i] = g->gr_gid;
- i++;
- gr = (char *)NULL;
- break;
- }
- gr = g->gr_mem[++j];
- }
- }
- endgrent();
- ret = setgroups(i, grouplst);
- free(grouplst);
- return ret;
-#endif /* HAVE_SETGROUPS */
-}
-#endif /* HAVE_INITGROUPS */
-
-
-#if (defined(SecureWare) && defined(SCO))
-/* This is needed due to needing the nap() function but we don't want
- to include the Xenix libraries since that will break other things...
- BTW: system call # 0x0c28 is the same as calling nap() */
-long nap(long milliseconds) {
- return syscall(0x0c28, milliseconds);
- }
-#endif
-
-
-#ifndef HAVE_MEMMOVE
-/*******************************************************************
-safely copies memory, ensuring no overlap problems.
-this is only used if the machine does not have its own memmove().
-this is not the fastest algorithm in town, but it will do for our
-needs.
-********************************************************************/
-void *rep_memmove(void *dest,const void *src,int size)
-{
- unsigned long d,s;
- int i;
- if (dest==src || !size) return(dest);
-
- d = (unsigned long)dest;
- s = (unsigned long)src;
-
- if ((d >= (s+size)) || (s >= (d+size))) {
- /* no overlap */
- memcpy(dest,src,size);
- return(dest);
- }
-
- if (d < s) {
- /* we can forward copy */
- if (s-d >= sizeof(int) &&
- !(s%sizeof(int)) &&
- !(d%sizeof(int)) &&
- !(size%sizeof(int))) {
- /* do it all as words */
- int *idest = (int *)dest;
- int *isrc = (int *)src;
- size /= sizeof(int);
- for (i=0;i<size;i++) idest[i] = isrc[i];
- } else {
- /* simplest */
- char *cdest = (char *)dest;
- char *csrc = (char *)src;
- for (i=0;i<size;i++) cdest[i] = csrc[i];
- }
- } else {
- /* must backward copy */
- if (d-s >= sizeof(int) &&
- !(s%sizeof(int)) &&
- !(d%sizeof(int)) &&
- !(size%sizeof(int))) {
- /* do it all as words */
- int *idest = (int *)dest;
- int *isrc = (int *)src;
- size /= sizeof(int);
- for (i=size-1;i>=0;i--) idest[i] = isrc[i];
- } else {
- /* simplest */
- char *cdest = (char *)dest;
- char *csrc = (char *)src;
- for (i=size-1;i>=0;i--) cdest[i] = csrc[i];
- }
- }
- return(dest);
-}
-#endif /* HAVE_MEMMOVE */
-
-#ifndef HAVE_STRDUP
-/****************************************************************************
-duplicate a string
-****************************************************************************/
-char *rep_strdup(const char *s)
-{
- size_t len;
- char *ret;
-
- if (!s) return(NULL);
-
- len = strlen(s)+1;
- ret = (char *)malloc(len);
- if (!ret) return(NULL);
- memcpy(ret,s,len);
- return(ret);
-}
-#endif /* HAVE_STRDUP */
-
-#ifndef HAVE_SETLINEBUF
-void rep_setlinebuf(FILE *stream)
-{
- setvbuf(stream, (char *)NULL, _IOLBF, 0);
-}
-#endif /* HAVE_SETLINEBUF */
-
-#ifndef HAVE_VSYSLOG
-#ifdef HAVE_SYSLOG
-void rep_vsyslog (int facility_priority, const char *format, va_list arglist)
-{
- char *msg = NULL;
- vasprintf(&msg, format, arglist);
- if (!msg)
- return;
- syslog(facility_priority, "%s", msg);
- free(msg);
-}
-#endif /* HAVE_SYSLOG */
-#endif /* HAVE_VSYSLOG */
-
-#ifndef HAVE_STRNLEN
-/**
- Some platforms don't have strnlen
-**/
- size_t rep_strnlen(const char *s, size_t max)
-{
- size_t len;
-
- for (len = 0; len < max; len++) {
- if (s[len] == '\0') {
- break;
- }
- }
- return len;
-}
-#endif
-
-#ifndef HAVE_STRNDUP
-/**
- Some platforms don't have strndup.
-**/
-char *rep_strndup(const char *s, size_t n)
-{
- char *ret;
-
- n = strnlen(s, n);
- ret = malloc(n+1);
- if (!ret)
- return NULL;
- memcpy(ret, s, n);
- ret[n] = 0;
-
- return ret;
-}
-#endif
-
-#ifndef HAVE_WAITPID
-int rep_waitpid(pid_t pid,int *status,int options)
-{
- return wait4(pid, status, options, NULL);
-}
-#endif
-
-#ifndef HAVE_SETEUID
-int rep_seteuid(uid_t euid)
-{
-#ifdef HAVE_SETRESUID
- return setresuid(-1, euid, -1);
-#else
-# error "You need a seteuid function"
-#endif
-}
-#endif
-
-#ifndef HAVE_SETEGID
-int rep_setegid(gid_t egid)
-{
-#ifdef HAVE_SETRESGID
- return setresgid(-1, egid, -1);
-#else
-# error "You need a setegid function"
-#endif
-}
-#endif
-
-/*******************************************************************
-os/2 also doesn't have chroot
-********************************************************************/
-#ifndef HAVE_CHROOT
-int rep_chroot(const char *dname)
-{
- errno = ENOSYS;
- return -1;
-}
-#endif
-
-/*****************************************************************
- Possibly replace mkstemp if it is broken.
-*****************************************************************/
-
-#ifndef HAVE_SECURE_MKSTEMP
-int rep_mkstemp(char *template)
-{
- /* have a reasonable go at emulating it. Hope that
- the system mktemp() isn't completly hopeless */
- char *p = mktemp(template);
- if (!p)
- return -1;
- return open(p, O_CREAT|O_EXCL|O_RDWR, 0600);
-}
-#endif
-
-#ifndef HAVE_MKDTEMP
-char *rep_mkdtemp(char *template)
-{
- char *dname;
-
- if ((dname = mktemp(template))) {
- if (mkdir(dname, 0700) >= 0) {
- return dname;
- }
- }
-
- return NULL;
-}
-#endif
-
-/*****************************************************************
- Watch out: this is not thread safe.
-*****************************************************************/
-
-#ifndef HAVE_PREAD
-ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset)
-{
- if (lseek(__fd, __offset, SEEK_SET) != __offset) {
- return -1;
- }
- return read(__fd, __buf, __nbytes);
-}
-#endif
-
-/*****************************************************************
- Watch out: this is not thread safe.
-*****************************************************************/
-
-#ifndef HAVE_PWRITE
-ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset)
-{
- if (lseek(__fd, __offset, SEEK_SET) != __offset) {
- return -1;
- }
- return write(__fd, __buf, __nbytes);
-}
-#endif
-
-#ifndef HAVE_STRCASESTR
-char *rep_strcasestr(const char *haystack, const char *needle)
-{
- const char *s;
- size_t nlen = strlen(needle);
- for (s=haystack;*s;s++) {
- if (toupper(*needle) == toupper(*s) &&
- strncasecmp(s, needle, nlen) == 0) {
- return (char *)((uintptr_t)s);
- }
- }
- return NULL;
-}
-#endif
-
-#ifndef HAVE_STRTOK_R
-/* based on GLIBC version, copyright Free Software Foundation */
-char *rep_strtok_r(char *s, const char *delim, char **save_ptr)
-{
- char *token;
-
- if (s == NULL) s = *save_ptr;
-
- s += strspn(s, delim);
- if (*s == '\0') {
- *save_ptr = s;
- return NULL;
- }
-
- token = s;
- s = strpbrk(token, delim);
- if (s == NULL) {
- *save_ptr = token + strlen(token);
- } else {
- *s = '\0';
- *save_ptr = s + 1;
- }
-
- return token;
-}
-#endif
-
-#ifndef HAVE_STRTOLL
-long long int rep_strtoll(const char *str, char **endptr, int base)
-{
-#ifdef HAVE_STRTOQ
- return strtoq(str, endptr, base);
-#elif defined(HAVE___STRTOLL)
- return __strtoll(str, endptr, base);
-#elif SIZEOF_LONG == SIZEOF_LONG_LONG
- return (long long int) strtol(str, endptr, base);
-#else
-# error "You need a strtoll function"
-#endif
-}
-#endif
-
-
-#ifndef HAVE_STRTOULL
-unsigned long long int rep_strtoull(const char *str, char **endptr, int base)
-{
-#ifdef HAVE_STRTOUQ
- return strtouq(str, endptr, base);
-#elif defined(HAVE___STRTOULL)
- return __strtoull(str, endptr, base);
-#elif SIZEOF_LONG == SIZEOF_LONG_LONG
- return (unsigned long long int) strtoul(str, endptr, base);
-#else
-# error "You need a strtoull function"
-#endif
-}
-#endif
-
-#ifndef HAVE_SETENV
-int rep_setenv(const char *name, const char *value, int overwrite)
-{
- char *p;
- size_t l1, l2;
- int ret;
-
- if (!overwrite && getenv(name)) {
- return 0;
- }
-
- l1 = strlen(name);
- l2 = strlen(value);
-
- p = malloc(l1+l2+2);
- if (p == NULL) {
- return -1;
- }
- memcpy(p, name, l1);
- p[l1] = '=';
- memcpy(p+l1+1, value, l2);
- p[l1+l2+1] = 0;
-
- ret = putenv(p);
- if (ret != 0) {
- free(p);
- }
-
- return ret;
-}
-#endif
-
-#ifndef HAVE_UNSETENV
-int rep_unsetenv(const char *name)
-{
- extern char **environ;
- size_t len = strlen(name);
- size_t i, count;
-
- if (environ == NULL || getenv(name) == NULL) {
- return 0;
- }
-
- for (i=0;environ[i];i++) /* noop */ ;
-
- count=i;
-
- for (i=0;i<count;) {
- if (strncmp(environ[i], name, len) == 0 && environ[i][len] == '=') {
- /* note: we do _not_ free the old variable here. It is unsafe to
- do so, as the pointer may not have come from malloc */
- memmove(&environ[i], &environ[i+1], (count-i)*sizeof(char *));
- count--;
- } else {
- i++;
- }
- }
-
- return 0;
-}
-#endif
-
-#ifndef HAVE_UTIME
-int rep_utime(const char *filename, const struct utimbuf *buf)
-{
- errno = ENOSYS;
- return -1;
-}
-#endif
-
-#ifndef HAVE_UTIMES
-int rep_utimes(const char *filename, const struct timeval tv[2])
-{
- struct utimbuf u;
-
- u.actime = tv[0].tv_sec;
- if (tv[0].tv_usec > 500000) {
- u.actime += 1;
- }
-
- u.modtime = tv[1].tv_sec;
- if (tv[1].tv_usec > 500000) {
- u.modtime += 1;
- }
-
- return utime(filename, &u);
-}
-#endif
diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h
deleted file mode 100644
index c69ea6cdac..0000000000
--- a/source4/lib/replace/replace.h
+++ /dev/null
@@ -1,582 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- macros to go along with the lib/replace/ portability layer code
-
- Copyright (C) Andrew Tridgell 2005
- Copyright (C) Jelmer Vernooij 2006
- Copyright (C) Jeremy Allison 2007.
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _LIBREPLACE_REPLACE_H
-#define _LIBREPLACE_REPLACE_H
-
-#ifndef NO_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef HAVE_STANDARDS_H
-#include <standards.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <errno.h>
-
-#if defined(_MSC_VER) || defined(__MINGW32__)
-#include "win32_replace.h"
-#endif
-
-
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-/* force off HAVE_INTTYPES_H so that roken doesn't try to include both,
- which causes a warning storm on irix */
-#undef HAVE_INTTYPES_H
-#elif HAVE_INTTYPES_H
-#include <inttypes.h>
-#endif
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
-
-#ifndef HAVE_STRERROR
-extern char *sys_errlist[];
-#define strerror(i) sys_errlist[i]
-#endif
-
-#ifndef HAVE_ERRNO_DECL
-extern int errno;
-#endif
-
-#ifndef HAVE_STRDUP
-#define strdup rep_strdup
-char *rep_strdup(const char *s);
-#endif
-
-#ifndef HAVE_MEMMOVE
-#define memmove rep_memmove
-void *rep_memmove(void *dest,const void *src,int size);
-#endif
-
-#ifndef HAVE_MKTIME
-#define mktime rep_mktime
-/* prototype is in "system/time.h" */
-#endif
-
-#ifndef HAVE_TIMEGM
-#define timegm rep_timegm
-/* prototype is in "system/time.h" */
-#endif
-
-#ifndef HAVE_UTIME
-#define utime rep_utime
-/* prototype is in "system/time.h" */
-#endif
-
-#ifndef HAVE_UTIMES
-#define utimes rep_utimes
-/* prototype is in "system/time.h" */
-#endif
-
-#ifndef HAVE_STRLCPY
-#define strlcpy rep_strlcpy
-size_t rep_strlcpy(char *d, const char *s, size_t bufsize);
-#endif
-
-#ifndef HAVE_STRLCAT
-#define strlcat rep_strlcat
-size_t rep_strlcat(char *d, const char *s, size_t bufsize);
-#endif
-
-#if (defined(BROKEN_STRNDUP) || !defined(HAVE_STRNDUP))
-#undef HAVE_STRNDUP
-#define strndup rep_strndup
-char *rep_strndup(const char *s, size_t n);
-#endif
-
-#if (defined(BROKEN_STRNLEN) || !defined(HAVE_STRNLEN))
-#undef HAVE_STRNLEN
-#define strnlen rep_strnlen
-size_t rep_strnlen(const char *s, size_t n);
-#endif
-
-#ifndef HAVE_SETENV
-#define setenv rep_setenv
-int rep_setenv(const char *name, const char *value, int overwrite);
-#else
-#ifndef HAVE_SETENV_DECL
-int setenv(const char *name, const char *value, int overwrite);
-#endif
-#endif
-
-#ifndef HAVE_UNSETENV
-#define unsetenv rep_unsetenv
-int rep_unsetenv(const char *name);
-#endif
-
-#ifndef HAVE_SETEUID
-#define seteuid rep_seteuid
-int rep_seteuid(uid_t);
-#endif
-
-#ifndef HAVE_SETEGID
-#define setegid rep_setegid
-int rep_setegid(gid_t);
-#endif
-
-#ifndef HAVE_SETLINEBUF
-#define setlinebuf rep_setlinebuf
-void rep_setlinebuf(FILE *);
-#endif
-
-#ifndef HAVE_STRCASESTR
-#define strcasestr rep_strcasestr
-char *rep_strcasestr(const char *haystack, const char *needle);
-#endif
-
-#ifndef HAVE_STRTOK_R
-#define strtok_r rep_strtok_r
-char *rep_strtok_r(char *s, const char *delim, char **save_ptr);
-#endif
-
-#ifndef HAVE_STRTOLL
-#define strtoll rep_strtoll
-long long int rep_strtoll(const char *str, char **endptr, int base);
-#endif
-
-#ifndef HAVE_STRTOULL
-#define strtoull rep_strtoull
-unsigned long long int rep_strtoull(const char *str, char **endptr, int base);
-#endif
-
-#ifndef HAVE_FTRUNCATE
-#define ftruncate rep_ftruncate
-int rep_ftruncate(int,off_t);
-#endif
-
-#ifndef HAVE_INITGROUPS
-#define initgroups rep_initgroups
-int rep_initgroups(char *name, gid_t id);
-#endif
-
-#if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
-#define bzero(a,b) memset((a),'\0',(b))
-#endif
-
-#ifndef HAVE_DLERROR
-#define dlerror rep_dlerror
-char *rep_dlerror(void);
-#endif
-
-#ifndef HAVE_DLOPEN
-#define dlopen rep_dlopen
-#ifdef DLOPEN_TAKES_UNSIGNED_FLAGS
-void *rep_dlopen(const char *name, unsigned int flags);
-#else
-void *rep_dlopen(const char *name, int flags);
-#endif
-#endif
-
-#ifndef HAVE_DLSYM
-#define dlsym rep_dlsym
-void *rep_dlsym(void *handle, const char *symbol);
-#endif
-
-#ifndef HAVE_DLCLOSE
-#define dlclose rep_dlclose
-int rep_dlclose(void *handle);
-#endif
-
-#ifndef HAVE_SOCKETPAIR
-#define socketpair rep_socketpair
-/* prototype is in system/network.h */
-#endif
-
-#ifndef PRINTF_ATTRIBUTE
-#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
-/** Use gcc attribute to check printf fns. a1 is the 1-based index of
- * the parameter containing the format, and a2 the index of the first
- * argument. Note that some gcc 2.x versions don't handle this
- * properly **/
-#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
-#else
-#define PRINTF_ATTRIBUTE(a1, a2)
-#endif
-#endif
-
-#ifndef _DEPRECATED_
-#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
-#define _DEPRECATED_ __attribute__ ((deprecated))
-#else
-#define _DEPRECATED_
-#endif
-#endif
-
-#ifndef HAVE_VASPRINTF
-#define vasprintf rep_vasprintf
-int rep_vasprintf(char **ptr, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
-#endif
-
-#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
-#define snprintf rep_snprintf
-int rep_snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4);
-#endif
-
-#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
-#define vsnprintf rep_vsnprintf
-int rep_vsnprintf(char *,size_t ,const char *, va_list ap) PRINTF_ATTRIBUTE(3,0);
-#endif
-
-#ifndef HAVE_ASPRINTF
-#define asprintf rep_asprintf
-int rep_asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3);
-#endif
-
-#ifndef HAVE_VSYSLOG
-#ifdef HAVE_SYSLOG
-#define vsyslog rep_vsyslog
-void rep_vsyslog (int facility_priority, const char *format, va_list arglist) PRINTF_ATTRIBUTE(2,0);
-#endif
-#endif
-
-/* we used to use these fns, but now we have good replacements
- for snprintf and vsnprintf */
-#define slprintf snprintf
-
-
-#ifndef HAVE_VA_COPY
-#undef va_copy
-#ifdef HAVE___VA_COPY
-#define va_copy(dest, src) __va_copy(dest, src)
-#else
-#define va_copy(dest, src) (dest) = (src)
-#endif
-#endif
-
-#ifndef HAVE_VOLATILE
-#define volatile
-#endif
-
-#ifndef HAVE_COMPARISON_FN_T
-typedef int (*comparison_fn_t)(const void *, const void *);
-#endif
-
-#ifdef REPLACE_STRPTIME
-#define strptime rep_strptime
-struct tm;
-char *rep_strptime(const char *buf, const char *format, struct tm *tm);
-#endif
-
-/* Load header file for dynamic linking stuff */
-#ifdef HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#ifndef RTLD_LAZY
-#define RTLD_LAZY 0
-#endif
-#ifndef RTLD_NOW
-#define RTLD_NOW 0
-#endif
-#ifndef RTLD_GLOBAL
-#define RTLD_GLOBAL 0
-#endif
-
-#ifndef HAVE_SECURE_MKSTEMP
-#define mkstemp(path) rep_mkstemp(path)
-int rep_mkstemp(char *temp);
-#endif
-
-#ifndef HAVE_MKDTEMP
-#define mkdtemp rep_mkdtemp
-char *rep_mkdtemp(char *template);
-#endif
-
-#ifndef HAVE_PREAD
-#define pread rep_pread
-ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset);
-#endif
-
-#ifndef HAVE_PWRITE
-#define pwrite rep_pwrite
-ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset);
-#endif
-
-#if !defined(HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA)
-#define inet_ntoa rep_inet_ntoa
-/* prototype is in "system/network.h" */
-#endif
-
-#ifndef HAVE_INET_PTON
-#define inet_pton rep_inet_pton
-/* prototype is in "system/network.h" */
-#endif
-
-#ifndef HAVE_INET_NTOP
-#define inet_ntop rep_inet_ntop
-/* prototype is in "system/network.h" */
-#endif
-
-#ifndef HAVE_INET_ATON
-#define inet_aton rep_inet_aton
-/* prototype is in "system/network.h" */
-#endif
-
-#ifndef HAVE_CONNECT
-#define connect rep_connect
-/* prototype is in "system/network.h" */
-#endif
-
-#ifndef HAVE_GETHOSTBYNAME
-#define gethostbyname rep_gethostbyname
-/* prototype is in "system/network.h" */
-#endif
-
-#ifndef HAVE_GETIFADDRS
-#define getifaddrs rep_getifaddrs
-/* prototype is in "system/network.h" */
-#endif
-
-#ifndef HAVE_FREEIFADDRS
-#define freeifaddrs rep_freeifaddrs
-/* prototype is in "system/network.h" */
-#endif
-
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-/* The extra casts work around common compiler bugs. */
-#define _TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
- It is necessary at least when t == time_t. */
-#define _TYPE_MINIMUM(t) ((t) (_TYPE_SIGNED (t) \
- ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
-#define _TYPE_MAXIMUM(t) ((t) (~ (t) 0 - _TYPE_MINIMUM (t)))
-
-#ifndef HOST_NAME_MAX
-#define HOST_NAME_MAX 255
-#endif
-
-/*
- * Some older systems seem not to have MAXHOSTNAMELEN
- * defined.
- */
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN HOST_NAME_MAX
-#endif
-
-#ifndef UINT16_MAX
-#define UINT16_MAX 65535
-#endif
-
-#ifndef UINT32_MAX
-#define UINT32_MAX (4294967295U)
-#endif
-
-#ifndef UINT64_MAX
-#define UINT64_MAX ((uint64_t)-1)
-#endif
-
-#ifndef CHAR_BIT
-#define CHAR_BIT 8
-#endif
-
-#ifndef INT32_MAX
-#define INT32_MAX _TYPE_MAXIMUM(int32_t)
-#endif
-
-#ifdef HAVE_STDBOOL_H
-#include <stdbool.h>
-#endif
-
-#if !defined(HAVE_BOOL)
-#ifdef HAVE__Bool
-#define bool _Bool
-#else
-typedef int bool;
-#endif
-#endif
-
-/*
- * to prevent <rpcsvc/yp_prot.h> from doing a redefine of 'bool'
- *
- * IRIX, HPUX, MacOS 10 and Solaris need BOOL_DEFINED
- * Tru64 needs _BOOL_EXISTS
- * AIX needs _BOOL,_TRUE,_FALSE
- */
-#ifndef BOOL_DEFINED
-#define BOOL_DEFINED
-#endif
-#ifndef _BOOL_EXISTS
-#define _BOOL_EXISTS
-#endif
-#ifndef _BOOL
-#define _BOOL
-#endif
-
-#ifndef __bool_true_false_are_defined
-#define __bool_true_false_are_defined
-#endif
-
-#ifndef true
-#define true (1)
-#endif
-#ifndef false
-#define false (0)
-#endif
-
-#ifndef _TRUE
-#define _TRUE true
-#endif
-#ifndef _FALSE
-#define _FALSE false
-#endif
-
-#ifndef HAVE_FUNCTION_MACRO
-#ifdef HAVE_func_MACRO
-#define __FUNCTION__ __func__
-#else
-#define __FUNCTION__ ("")
-#endif
-#endif
-
-
-#ifndef MIN
-#define MIN(a,b) ((a)<(b)?(a):(b))
-#endif
-
-#ifndef MAX
-#define MAX(a,b) ((a)>(b)?(a):(b))
-#endif
-
-#if !defined(HAVE_VOLATILE)
-#define volatile
-#endif
-
-/**
- this is a warning hack. The idea is to use this everywhere that we
- get the "discarding const" warning from gcc. That doesn't actually
- fix the problem of course, but it means that when we do get to
- cleaning them up we can do it by searching the code for
- discard_const.
-
- It also means that other error types aren't as swamped by the noise
- of hundreds of const warnings, so we are more likely to notice when
- we get new errors.
-
- Please only add more uses of this macro when you find it
- _really_ hard to fix const warnings. Our aim is to eventually use
- this function in only a very few places.
-
- Also, please call this via the discard_const_p() macro interface, as that
- makes the return type safe.
-*/
-#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
-
-/** Type-safe version of discard_const */
-#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
-
-#ifndef __STRING
-#define __STRING(x) #x
-#endif
-
-#ifndef __STRINGSTRING
-#define __STRINGSTRING(x) __STRING(x)
-#endif
-
-#ifndef __LINESTR__
-#define __LINESTR__ __STRINGSTRING(__LINE__)
-#endif
-
-#ifndef __location__
-#define __location__ __FILE__ ":" __LINESTR__
-#endif
-
-/**
- * zero a structure
- */
-#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
-
-/**
- * zero a structure given a pointer to the structure
- */
-#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
-
-/**
- * zero a structure given a pointer to the structure - no zero check
- */
-#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x)))
-
-/* zero an array - note that sizeof(array) must work - ie. it must not be a
- pointer */
-#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x))
-
-/**
- * work out how many elements there are in a static array
- */
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
-
-/**
- * pointer difference macro
- */
-#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2)))
-
-#if MMAP_BLACKLIST
-#undef HAVE_MMAP
-#endif
-
-#ifdef __COMPAR_FN_T
-#define QSORT_CAST (__compar_fn_t)
-#endif
-
-#ifndef QSORT_CAST
-#define QSORT_CAST (int (*)(const void *, const void *))
-#endif
-
-#ifndef PATH_MAX
-#define PATH_MAX 1024
-#endif
-
-#ifndef MAX_DNS_NAME_LENGTH
-#define MAX_DNS_NAME_LENGTH 256 /* Actually 255 but +1 for terminating null. */
-#endif
-
-#endif /* _LIBREPLACE_REPLACE_H */
diff --git a/source4/lib/replace/samba.m4 b/source4/lib/replace/samba.m4
deleted file mode 100644
index 07c4d38887..0000000000
--- a/source4/lib/replace/samba.m4
+++ /dev/null
@@ -1,35 +0,0 @@
-AC_LIBREPLACE_BROKEN_CHECKS
-AC_LIBREPLACE_NETWORK_CHECKS
-
-SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL}])
-SMB_ENABLE(LIBREPLACE_EXT)
-
-SMB_EXT_LIB(LIBREPLACE_NETWORK, [${LIBREPLACE_NETWORK_LIBS}])
-SMB_ENABLE(LIBREPLACE_NETWORK)
-
-# remove leading ./
-LIBREPLACE_DIR=`echo ${libreplacedir} |sed -e 's/^\.\///g'`
-
-# remove leading srcdir .. we are looking for the relative
-# path within the samba source tree or wherever libreplace is.
-# We need to make sure the object is not forced to end up in
-# the source directory because we might be using a separate
-# build directory.
-LIBREPLACE_DIR=`echo ${LIBREPLACE_DIR} | sed -e "s|^$srcdir/||g"`
-
-LIBREPLACE_OBJS=""
-for obj in ${LIBREPLACEOBJ}; do
- LIBREPLACE_OBJS="${LIBREPLACE_OBJS} ${LIBREPLACE_DIR}/${obj}"
-done
-
-SMB_SUBSYSTEM(LIBREPLACE,
- [${LIBREPLACE_OBJS}],
- [LIBREPLACE_EXT LIBREPLACE_NETWORK],
- [-Ilib/replace])
-
-LIBREPLACE_HOSTCC_OBJS=`echo ${LIBREPLACE_OBJS} |sed -e 's/\.o/\.ho/g'`
-
-SMB_SUBSYSTEM(LIBREPLACE_HOSTCC,
- [${LIBREPLACE_HOSTCC_OBJS}],
- [],
- [-Ilib/replace])
diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c
deleted file mode 100644
index c54d721ce5..0000000000
--- a/source4/lib/replace/snprintf.c
+++ /dev/null
@@ -1,1530 +0,0 @@
-/*
- * NOTE: If you change this file, please merge it into rsync, samba, etc.
- */
-
-/*
- * Copyright Patrick Powell 1995
- * This code is based on code written by Patrick Powell (papowell@astart.com)
- * It may be used for any purpose as long as this notice remains intact
- * on all source code distributions
- */
-
-/**************************************************************
- * Original:
- * Patrick Powell Tue Apr 11 09:48:21 PDT 1995
- * A bombproof version of doprnt (dopr) included.
- * Sigh. This sort of thing is always nasty do deal with. Note that
- * the version here does not include floating point...
- *
- * snprintf() is used instead of sprintf() as it does limit checks
- * for string length. This covers a nasty loophole.
- *
- * The other functions are there to prevent NULL pointers from
- * causing nast effects.
- *
- * More Recently:
- * Brandon Long <blong@fiction.net> 9/15/96 for mutt 0.43
- * This was ugly. It is still ugly. I opted out of floating point
- * numbers, but the formatter understands just about everything
- * from the normal C string format, at least as far as I can tell from
- * the Solaris 2.5 printf(3S) man page.
- *
- * Brandon Long <blong@fiction.net> 10/22/97 for mutt 0.87.1
- * Ok, added some minimal floating point support, which means this
- * probably requires libm on most operating systems. Don't yet
- * support the exponent (e,E) and sigfig (g,G). Also, fmtint()
- * was pretty badly broken, it just wasn't being exercised in ways
- * which showed it, so that's been fixed. Also, formated the code
- * to mutt conventions, and removed dead code left over from the
- * original. Also, there is now a builtin-test, just compile with:
- * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
- * and run snprintf for results.
- *
- * Thomas Roessler <roessler@guug.de> 01/27/98 for mutt 0.89i
- * The PGP code was using unsigned hexadecimal formats.
- * Unfortunately, unsigned formats simply didn't work.
- *
- * Michael Elkins <me@cs.hmc.edu> 03/05/98 for mutt 0.90.8
- * The original code assumed that both snprintf() and vsnprintf() were
- * missing. Some systems only have snprintf() but not vsnprintf(), so
- * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF.
- *
- * Andrew Tridgell (tridge@samba.org) Oct 1998
- * fixed handling of %.0f
- * added test for HAVE_LONG_DOUBLE
- *
- * tridge@samba.org, idra@samba.org, April 2001
- * got rid of fcvt code (twas buggy and made testing harder)
- * added C99 semantics
- *
- * date: 2002/12/19 19:56:31; author: herb; state: Exp; lines: +2 -0
- * actually print args for %g and %e
- *
- * date: 2002/06/03 13:37:52; author: jmcd; state: Exp; lines: +8 -0
- * Since includes.h isn't included here, VA_COPY has to be defined here. I don't
- * see any include file that is guaranteed to be here, so I'm defining it
- * locally. Fixes AIX and Solaris builds.
- *
- * date: 2002/06/03 03:07:24; author: tridge; state: Exp; lines: +5 -13
- * put the ifdef for HAVE_VA_COPY in one place rather than in lots of
- * functions
- *
- * date: 2002/05/17 14:51:22; author: jmcd; state: Exp; lines: +21 -4
- * Fix usage of va_list passed as an arg. Use __va_copy before using it
- * when it exists.
- *
- * date: 2002/04/16 22:38:04; author: idra; state: Exp; lines: +20 -14
- * Fix incorrect zpadlen handling in fmtfp.
- * Thanks to Ollie Oldham <ollie.oldham@metro-optix.com> for spotting it.
- * few mods to make it easier to compile the tests.
- * addedd the "Ollie" test to the floating point ones.
- *
- * Martin Pool (mbp@samba.org) April 2003
- * Remove NO_CONFIG_H so that the test case can be built within a source
- * tree with less trouble.
- * Remove unnecessary SAFE_FREE() definition.
- *
- * Martin Pool (mbp@samba.org) May 2003
- * Put in a prototype for dummy_snprintf() to quiet compiler warnings.
- *
- * Move #endif to make sure VA_COPY, LDOUBLE, etc are defined even
- * if the C library has some snprintf functions already.
- *
- * Darren Tucker (dtucker@zip.com.au) 2005
- * Fix bug allowing read overruns of the source string with "%.*s"
- * Usually harmless unless the read runs outside the process' allocation
- * (eg if your malloc does guard pages) in which case it will segfault.
- * From OpenSSH. Also added test for same.
- *
- * Simo Sorce (idra@samba.org) Jan 2006
- *
- * Add support for position independent parameters
- * fix fmtstr now it conforms to sprintf wrt min.max
- *
- **************************************************************/
-
-#include "replace.h"
-#include "system/locale.h"
-
-#ifdef TEST_SNPRINTF /* need math library headers for testing */
-
-/* In test mode, we pretend that this system doesn't have any snprintf
- * functions, regardless of what config.h says. */
-# undef HAVE_SNPRINTF
-# undef HAVE_VSNPRINTF
-# undef HAVE_C99_VSNPRINTF
-# undef HAVE_ASPRINTF
-# undef HAVE_VASPRINTF
-# include <math.h>
-#endif /* TEST_SNPRINTF */
-
-#if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF)
-/* only include stdio.h if we are not re-defining snprintf or vsnprintf */
-#include <stdio.h>
- /* make the compiler happy with an empty file */
- void dummy_snprintf(void);
- void dummy_snprintf(void) {}
-#endif /* HAVE_SNPRINTF, etc */
-
-/* yes this really must be a ||. Don't muck with this (tridge) */
-#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
-
-#ifdef HAVE_LONG_DOUBLE
-#define LDOUBLE long double
-#else
-#define LDOUBLE double
-#endif
-
-#ifdef HAVE_LONG_LONG
-#define LLONG long long
-#else
-#define LLONG long
-#endif
-
-#ifndef VA_COPY
-#ifdef HAVE_VA_COPY
-#define VA_COPY(dest, src) va_copy(dest, src)
-#else
-#ifdef HAVE___VA_COPY
-#define VA_COPY(dest, src) __va_copy(dest, src)
-#else
-#define VA_COPY(dest, src) (dest) = (src)
-#endif
-#endif
-
-/*
- * dopr(): poor man's version of doprintf
- */
-
-/* format read states */
-#define DP_S_DEFAULT 0
-#define DP_S_FLAGS 1
-#define DP_S_MIN 2
-#define DP_S_DOT 3
-#define DP_S_MAX 4
-#define DP_S_MOD 5
-#define DP_S_CONV 6
-#define DP_S_DONE 7
-
-/* format flags - Bits */
-#define DP_F_MINUS (1 << 0)
-#define DP_F_PLUS (1 << 1)
-#define DP_F_SPACE (1 << 2)
-#define DP_F_NUM (1 << 3)
-#define DP_F_ZERO (1 << 4)
-#define DP_F_UP (1 << 5)
-#define DP_F_UNSIGNED (1 << 6)
-
-/* Conversion Flags */
-#define DP_C_CHAR 1
-#define DP_C_SHORT 2
-#define DP_C_LONG 3
-#define DP_C_LDOUBLE 4
-#define DP_C_LLONG 5
-#define DP_C_SIZET 6
-
-/* Chunk types */
-#define CNK_FMT_STR 0
-#define CNK_INT 1
-#define CNK_OCTAL 2
-#define CNK_UINT 3
-#define CNK_HEX 4
-#define CNK_FLOAT 5
-#define CNK_CHAR 6
-#define CNK_STRING 7
-#define CNK_PTR 8
-#define CNK_NUM 9
-#define CNK_PRCNT 10
-
-#define char_to_int(p) ((p)- '0')
-#ifndef MAX
-#define MAX(p,q) (((p) >= (q)) ? (p) : (q))
-#endif
-
-struct pr_chunk {
- int type; /* chunk type */
- int num; /* parameter number */
- int min;
- int max;
- int flags;
- int cflags;
- int start;
- int len;
- LLONG value;
- LDOUBLE fvalue;
- char *strvalue;
- void *pnum;
- struct pr_chunk *min_star;
- struct pr_chunk *max_star;
- struct pr_chunk *next;
-};
-
-struct pr_chunk_x {
- struct pr_chunk **chunks;
- int num;
-};
-
-static int dopr(char *buffer, size_t maxlen, const char *format,
- va_list args_in);
-static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
- char *value, int flags, int min, int max);
-static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
- LLONG value, int base, int min, int max, int flags);
-static void fmtfp(char *buffer, size_t *currlen, size_t maxlen,
- LDOUBLE fvalue, int min, int max, int flags);
-static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c);
-static struct pr_chunk *new_chunk(void);
-static int add_cnk_list_entry(struct pr_chunk_x **list,
- int max_num, struct pr_chunk *chunk);
-
-static int dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
-{
- char ch;
- int state;
- int pflag;
- int pnum;
- int pfirst;
- size_t currlen;
- va_list args;
- const char *base;
- struct pr_chunk *chunks = NULL;
- struct pr_chunk *cnk = NULL;
- struct pr_chunk_x *clist = NULL;
- int max_pos;
- int ret = -1;
-
- VA_COPY(args, args_in);
-
- state = DP_S_DEFAULT;
- pfirst = 1;
- pflag = 0;
- pnum = 0;
-
- max_pos = 0;
- base = format;
- ch = *format++;
-
- /* retrieve the string structure as chunks */
- while (state != DP_S_DONE) {
- if (ch == '\0')
- state = DP_S_DONE;
-
- switch(state) {
- case DP_S_DEFAULT:
-
- if (cnk) {
- cnk->next = new_chunk();
- cnk = cnk->next;
- } else {
- cnk = new_chunk();
- }
- if (!cnk) goto done;
- if (!chunks) chunks = cnk;
-
- if (ch == '%') {
- state = DP_S_FLAGS;
- ch = *format++;
- } else {
- cnk->type = CNK_FMT_STR;
- cnk->start = format - base -1;
- while ((ch != '\0') && (ch != '%')) ch = *format++;
- cnk->len = format - base - cnk->start -1;
- }
- break;
- case DP_S_FLAGS:
- switch (ch) {
- case '-':
- cnk->flags |= DP_F_MINUS;
- ch = *format++;
- break;
- case '+':
- cnk->flags |= DP_F_PLUS;
- ch = *format++;
- break;
- case ' ':
- cnk->flags |= DP_F_SPACE;
- ch = *format++;
- break;
- case '#':
- cnk->flags |= DP_F_NUM;
- ch = *format++;
- break;
- case '0':
- cnk->flags |= DP_F_ZERO;
- ch = *format++;
- break;
- case 'I':
- /* internationalization not supported yet */
- ch = *format++;
- break;
- default:
- state = DP_S_MIN;
- break;
- }
- break;
- case DP_S_MIN:
- if (isdigit((unsigned char)ch)) {
- cnk->min = 10 * cnk->min + char_to_int (ch);
- ch = *format++;
- } else if (ch == '$') {
- if (!pfirst && !pflag) {
- /* parameters must be all positioned or none */
- goto done;
- }
- if (pfirst) {
- pfirst = 0;
- pflag = 1;
- }
- if (cnk->min == 0) /* what ?? */
- goto done;
- cnk->num = cnk->min;
- cnk->min = 0;
- ch = *format++;
- } else if (ch == '*') {
- if (pfirst) pfirst = 0;
- cnk->min_star = new_chunk();
- if (!cnk->min_star) /* out of memory :-( */
- goto done;
- cnk->min_star->type = CNK_INT;
- if (pflag) {
- int num;
- ch = *format++;
- if (!isdigit((unsigned char)ch)) {
- /* parameters must be all positioned or none */
- goto done;
- }
- for (num = 0; isdigit((unsigned char)ch); ch = *format++) {
- num = 10 * num + char_to_int(ch);
- }
- cnk->min_star->num = num;
- if (ch != '$') /* what ?? */
- goto done;
- } else {
- cnk->min_star->num = ++pnum;
- }
- max_pos = add_cnk_list_entry(&clist, max_pos, cnk->min_star);
- if (max_pos == 0) /* out of memory :-( */
- goto done;
- ch = *format++;
- state = DP_S_DOT;
- } else {
- if (pfirst) pfirst = 0;
- state = DP_S_DOT;
- }
- break;
- case DP_S_DOT:
- if (ch == '.') {
- state = DP_S_MAX;
- ch = *format++;
- } else {
- state = DP_S_MOD;
- }
- break;
- case DP_S_MAX:
- if (isdigit((unsigned char)ch)) {
- if (cnk->max < 0)
- cnk->max = 0;
- cnk->max = 10 * cnk->max + char_to_int (ch);
- ch = *format++;
- } else if (ch == '$') {
- if (!pfirst && !pflag) {
- /* parameters must be all positioned or none */
- goto done;
- }
- if (cnk->max <= 0) /* what ?? */
- goto done;
- cnk->num = cnk->max;
- cnk->max = -1;
- ch = *format++;
- } else if (ch == '*') {
- cnk->max_star = new_chunk();
- if (!cnk->max_star) /* out of memory :-( */
- goto done;
- cnk->max_star->type = CNK_INT;
- if (pflag) {
- int num;
- ch = *format++;
- if (!isdigit((unsigned char)ch)) {
- /* parameters must be all positioned or none */
- goto done;
- }
- for (num = 0; isdigit((unsigned char)ch); ch = *format++) {
- num = 10 * num + char_to_int(ch);
- }
- cnk->max_star->num = num;
- if (ch != '$') /* what ?? */
- goto done;
- } else {
- cnk->max_star->num = ++pnum;
- }
- max_pos = add_cnk_list_entry(&clist, max_pos, cnk->max_star);
- if (max_pos == 0) /* out of memory :-( */
- goto done;
-
- ch = *format++;
- state = DP_S_MOD;
- } else {
- state = DP_S_MOD;
- }
- break;
- case DP_S_MOD:
- switch (ch) {
- case 'h':
- cnk->cflags = DP_C_SHORT;
- ch = *format++;
- if (ch == 'h') {
- cnk->cflags = DP_C_CHAR;
- ch = *format++;
- }
- break;
- case 'l':
- cnk->cflags = DP_C_LONG;
- ch = *format++;
- if (ch == 'l') { /* It's a long long */
- cnk->cflags = DP_C_LLONG;
- ch = *format++;
- }
- break;
- case 'L':
- cnk->cflags = DP_C_LDOUBLE;
- ch = *format++;
- break;
- case 'z':
- cnk->cflags = DP_C_SIZET;
- ch = *format++;
- break;
- default:
- break;
- }
- state = DP_S_CONV;
- break;
- case DP_S_CONV:
- if (cnk->num == 0) cnk->num = ++pnum;
- max_pos = add_cnk_list_entry(&clist, max_pos, cnk);
- if (max_pos == 0) /* out of memory :-( */
- goto done;
-
- switch (ch) {
- case 'd':
- case 'i':
- cnk->type = CNK_INT;
- break;
- case 'o':
- cnk->type = CNK_OCTAL;
- cnk->flags |= DP_F_UNSIGNED;
- break;
- case 'u':
- cnk->type = CNK_UINT;
- cnk->flags |= DP_F_UNSIGNED;
- break;
- case 'X':
- cnk->flags |= DP_F_UP;
- case 'x':
- cnk->type = CNK_HEX;
- cnk->flags |= DP_F_UNSIGNED;
- break;
- case 'A':
- /* hex float not supported yet */
- case 'E':
- case 'G':
- case 'F':
- cnk->flags |= DP_F_UP;
- case 'a':
- /* hex float not supported yet */
- case 'e':
- case 'f':
- case 'g':
- cnk->type = CNK_FLOAT;
- break;
- case 'c':
- cnk->type = CNK_CHAR;
- break;
- case 's':
- cnk->type = CNK_STRING;
- break;
- case 'p':
- cnk->type = CNK_PTR;
- break;
- case 'n':
- cnk->type = CNK_NUM;
- break;
- case '%':
- cnk->type = CNK_PRCNT;
- break;
- default:
- /* Unknown, bail out*/
- goto done;
- }
- ch = *format++;
- state = DP_S_DEFAULT;
- break;
- case DP_S_DONE:
- break;
- default:
- /* hmm? */
- break; /* some picky compilers need this */
- }
- }
-
- /* retrieve the format arguments */
- for (pnum = 0; pnum < max_pos; pnum++) {
- int i;
-
- if (clist[pnum].num == 0) {
- /* ignoring a parameter should not be permitted
- * all parameters must be matched at least once
- * BUT seem some system ignore this rule ...
- * at least my glibc based system does --SSS
- */
-#ifdef DEBUG_SNPRINTF
- printf("parameter at position %d not used\n", pnum+1);
-#endif
- /* eat the parameter */
- va_arg (args, int);
- continue;
- }
- for (i = 1; i < clist[pnum].num; i++) {
- if (clist[pnum].chunks[0]->type != clist[pnum].chunks[i]->type) {
- /* nooo noo no!
- * all the references to a parameter
- * must be of the same type
- */
- goto done;
- }
- }
- cnk = clist[pnum].chunks[0];
- switch (cnk->type) {
- case CNK_INT:
- if (cnk->cflags == DP_C_SHORT)
- cnk->value = va_arg (args, int);
- else if (cnk->cflags == DP_C_LONG)
- cnk->value = va_arg (args, long int);
- else if (cnk->cflags == DP_C_LLONG)
- cnk->value = va_arg (args, LLONG);
- else if (cnk->cflags == DP_C_SIZET)
- cnk->value = va_arg (args, ssize_t);
- else
- cnk->value = va_arg (args, int);
-
- for (i = 1; i < clist[pnum].num; i++) {
- clist[pnum].chunks[i]->value = cnk->value;
- }
- break;
-
- case CNK_OCTAL:
- case CNK_UINT:
- case CNK_HEX:
- if (cnk->cflags == DP_C_SHORT)
- cnk->value = va_arg (args, unsigned int);
- else if (cnk->cflags == DP_C_LONG)
- cnk->value = (unsigned long int)va_arg (args, unsigned long int);
- else if (cnk->cflags == DP_C_LLONG)
- cnk->value = (LLONG)va_arg (args, unsigned LLONG);
- else if (cnk->cflags == DP_C_SIZET)
- cnk->value = (size_t)va_arg (args, size_t);
- else
- cnk->value = (unsigned int)va_arg (args, unsigned int);
-
- for (i = 1; i < clist[pnum].num; i++) {
- clist[pnum].chunks[i]->value = cnk->value;
- }
- break;
-
- case CNK_FLOAT:
- if (cnk->cflags == DP_C_LDOUBLE)
- cnk->fvalue = va_arg (args, LDOUBLE);
- else
- cnk->fvalue = va_arg (args, double);
-
- for (i = 1; i < clist[pnum].num; i++) {
- clist[pnum].chunks[i]->fvalue = cnk->fvalue;
- }
- break;
-
- case CNK_CHAR:
- cnk->value = va_arg (args, int);
-
- for (i = 1; i < clist[pnum].num; i++) {
- clist[pnum].chunks[i]->value = cnk->value;
- }
- break;
-
- case CNK_STRING:
- cnk->strvalue = va_arg (args, char *);
- if (!cnk->strvalue) cnk->strvalue = "(NULL)";
-
- for (i = 1; i < clist[pnum].num; i++) {
- clist[pnum].chunks[i]->strvalue = cnk->strvalue;
- }
- break;
-
- case CNK_PTR:
- cnk->strvalue = va_arg (args, void *);
- for (i = 1; i < clist[pnum].num; i++) {
- clist[pnum].chunks[i]->strvalue = cnk->strvalue;
- }
- break;
-
- case CNK_NUM:
- if (cnk->cflags == DP_C_CHAR)
- cnk->pnum = va_arg (args, char *);
- else if (cnk->cflags == DP_C_SHORT)
- cnk->pnum = va_arg (args, short int *);
- else if (cnk->cflags == DP_C_LONG)
- cnk->pnum = va_arg (args, long int *);
- else if (cnk->cflags == DP_C_LLONG)
- cnk->pnum = va_arg (args, LLONG *);
- else if (cnk->cflags == DP_C_SIZET)
- cnk->pnum = va_arg (args, ssize_t *);
- else
- cnk->pnum = va_arg (args, int *);
-
- for (i = 1; i < clist[pnum].num; i++) {
- clist[pnum].chunks[i]->pnum = cnk->pnum;
- }
- break;
-
- case CNK_PRCNT:
- break;
-
- default:
- /* what ?? */
- goto done;
- }
- }
- /* print out the actual string from chunks */
- currlen = 0;
- cnk = chunks;
- while (cnk) {
- int len, min, max;
-
- if (cnk->min_star) min = cnk->min_star->value;
- else min = cnk->min;
- if (cnk->max_star) max = cnk->max_star->value;
- else max = cnk->max;
-
- switch (cnk->type) {
-
- case CNK_FMT_STR:
- if (maxlen != 0 && maxlen > currlen) {
- if (maxlen > (currlen + cnk->len)) len = cnk->len;
- else len = maxlen - currlen;
-
- memcpy(&(buffer[currlen]), &(base[cnk->start]), len);
- }
- currlen += cnk->len;
-
- break;
-
- case CNK_INT:
- case CNK_UINT:
- fmtint (buffer, &currlen, maxlen, cnk->value, 10, min, max, cnk->flags);
- break;
-
- case CNK_OCTAL:
- fmtint (buffer, &currlen, maxlen, cnk->value, 8, min, max, cnk->flags);
- break;
-
- case CNK_HEX:
- fmtint (buffer, &currlen, maxlen, cnk->value, 16, min, max, cnk->flags);
- break;
-
- case CNK_FLOAT:
- fmtfp (buffer, &currlen, maxlen, cnk->fvalue, min, max, cnk->flags);
- break;
-
- case CNK_CHAR:
- dopr_outch (buffer, &currlen, maxlen, cnk->value);
- break;
-
- case CNK_STRING:
- if (max == -1) {
- max = strlen(cnk->strvalue);
- }
- fmtstr (buffer, &currlen, maxlen, cnk->strvalue, cnk->flags, min, max);
- break;
-
- case CNK_PTR:
- fmtint (buffer, &currlen, maxlen, (long)(cnk->strvalue), 16, min, max, cnk->flags);
- break;
-
- case CNK_NUM:
- if (cnk->cflags == DP_C_CHAR)
- *((char *)(cnk->pnum)) = (char)currlen;
- else if (cnk->cflags == DP_C_SHORT)
- *((short int *)(cnk->pnum)) = (short int)currlen;
- else if (cnk->cflags == DP_C_LONG)
- *((long int *)(cnk->pnum)) = (long int)currlen;
- else if (cnk->cflags == DP_C_LLONG)
- *((LLONG *)(cnk->pnum)) = (LLONG)currlen;
- else if (cnk->cflags == DP_C_SIZET)
- *((ssize_t *)(cnk->pnum)) = (ssize_t)currlen;
- else
- *((int *)(cnk->pnum)) = (int)currlen;
- break;
-
- case CNK_PRCNT:
- dopr_outch (buffer, &currlen, maxlen, '%');
- break;
-
- default:
- /* what ?? */
- goto done;
- }
- cnk = cnk->next;
- }
- if (maxlen != 0) {
- if (currlen < maxlen - 1)
- buffer[currlen] = '\0';
- else if (maxlen > 0)
- buffer[maxlen - 1] = '\0';
- }
- ret = currlen;
-
-done:
- va_end(args);
-
- while (chunks) {
- cnk = chunks->next;
- free(chunks);
- chunks = cnk;
- }
- if (clist) {
- for (pnum = 0; pnum < max_pos; pnum++) {
- if (clist[pnum].chunks) free(clist[pnum].chunks);
- }
- free(clist);
- }
- return ret;
-}
-
-static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
- char *value, int flags, int min, int max)
-{
- int padlen, strln; /* amount to pad */
- int cnt = 0;
-
-#ifdef DEBUG_SNPRINTF
- printf("fmtstr min=%d max=%d s=[%s]\n", min, max, value);
-#endif
- if (value == 0) {
- value = "<NULL>";
- }
-
- for (strln = 0; strln < max && value[strln]; ++strln); /* strlen */
- padlen = min - strln;
- if (padlen < 0)
- padlen = 0;
- if (flags & DP_F_MINUS)
- padlen = -padlen; /* Left Justify */
-
- while (padlen > 0) {
- dopr_outch (buffer, currlen, maxlen, ' ');
- --padlen;
- }
- while (*value && (cnt < max)) {
- dopr_outch (buffer, currlen, maxlen, *value++);
- ++cnt;
- }
- while (padlen < 0) {
- dopr_outch (buffer, currlen, maxlen, ' ');
- ++padlen;
- }
-}
-
-/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
-
-static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
- LLONG value, int base, int min, int max, int flags)
-{
- int signvalue = 0;
- unsigned LLONG uvalue;
- char convert[20];
- int place = 0;
- int spadlen = 0; /* amount to space pad */
- int zpadlen = 0; /* amount to zero pad */
- int caps = 0;
-
- if (max < 0)
- max = 0;
-
- uvalue = value;
-
- if(!(flags & DP_F_UNSIGNED)) {
- if( value < 0 ) {
- signvalue = '-';
- uvalue = -value;
- } else {
- if (flags & DP_F_PLUS) /* Do a sign (+/i) */
- signvalue = '+';
- else if (flags & DP_F_SPACE)
- signvalue = ' ';
- }
- }
-
- if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
-
- do {
- convert[place++] =
- (caps? "0123456789ABCDEF":"0123456789abcdef")
- [uvalue % (unsigned)base ];
- uvalue = (uvalue / (unsigned)base );
- } while(uvalue && (place < 20));
- if (place == 20) place--;
- convert[place] = 0;
-
- zpadlen = max - place;
- spadlen = min - MAX (max, place) - (signvalue ? 1 : 0);
- if (zpadlen < 0) zpadlen = 0;
- if (spadlen < 0) spadlen = 0;
- if (flags & DP_F_ZERO) {
- zpadlen = MAX(zpadlen, spadlen);
- spadlen = 0;
- }
- if (flags & DP_F_MINUS)
- spadlen = -spadlen; /* Left Justifty */
-
-#ifdef DEBUG_SNPRINTF
- printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
- zpadlen, spadlen, min, max, place);
-#endif
-
- /* Spaces */
- while (spadlen > 0) {
- dopr_outch (buffer, currlen, maxlen, ' ');
- --spadlen;
- }
-
- /* Sign */
- if (signvalue)
- dopr_outch (buffer, currlen, maxlen, signvalue);
-
- /* Zeros */
- if (zpadlen > 0) {
- while (zpadlen > 0) {
- dopr_outch (buffer, currlen, maxlen, '0');
- --zpadlen;
- }
- }
-
- /* Digits */
- while (place > 0)
- dopr_outch (buffer, currlen, maxlen, convert[--place]);
-
- /* Left Justified spaces */
- while (spadlen < 0) {
- dopr_outch (buffer, currlen, maxlen, ' ');
- ++spadlen;
- }
-}
-
-static LDOUBLE abs_val(LDOUBLE value)
-{
- LDOUBLE result = value;
-
- if (value < 0)
- result = -value;
-
- return result;
-}
-
-static LDOUBLE POW10(int exp)
-{
- LDOUBLE result = 1;
-
- while (exp) {
- result *= 10;
- exp--;
- }
-
- return result;
-}
-
-static LLONG ROUND(LDOUBLE value)
-{
- LLONG intpart;
-
- intpart = (LLONG)value;
- value = value - intpart;
- if (value >= 0.5) intpart++;
-
- return intpart;
-}
-
-/* a replacement for modf that doesn't need the math library. Should
- be portable, but slow */
-static double my_modf(double x0, double *iptr)
-{
- int i;
- LLONG l=0;
- double x = x0;
- double f = 1.0;
-
- for (i=0;i<100;i++) {
- l = (long)x;
- if (l <= (x+1) && l >= (x-1)) break;
- x *= 0.1;
- f *= 10.0;
- }
-
- if (i == 100) {
- /* yikes! the number is beyond what we can handle. What do we do? */
- (*iptr) = 0;
- return 0;
- }
-
- if (i != 0) {
- double i2;
- double ret;
-
- ret = my_modf(x0-l*f, &i2);
- (*iptr) = l*f + i2;
- return ret;
- }
-
- (*iptr) = l;
- return x - (*iptr);
-}
-
-
-static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
- LDOUBLE fvalue, int min, int max, int flags)
-{
- int signvalue = 0;
- double ufvalue;
- char iconvert[311];
- char fconvert[311];
- int iplace = 0;
- int fplace = 0;
- int padlen = 0; /* amount to pad */
- int zpadlen = 0;
- int caps = 0;
- int idx;
- double intpart;
- double fracpart;
- double temp;
-
- /*
- * AIX manpage says the default is 0, but Solaris says the default
- * is 6, and sprintf on AIX defaults to 6
- */
- if (max < 0)
- max = 6;
-
- ufvalue = abs_val (fvalue);
-
- if (fvalue < 0) {
- signvalue = '-';
- } else {
- if (flags & DP_F_PLUS) { /* Do a sign (+/i) */
- signvalue = '+';
- } else {
- if (flags & DP_F_SPACE)
- signvalue = ' ';
- }
- }
-
-#if 0
- if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
-#endif
-
-#if 0
- if (max == 0) ufvalue += 0.5; /* if max = 0 we must round */
-#endif
-
- /*
- * Sorry, we only support 9 digits past the decimal because of our
- * conversion method
- */
- if (max > 9)
- max = 9;
-
- /* We "cheat" by converting the fractional part to integer by
- * multiplying by a factor of 10
- */
-
- temp = ufvalue;
- my_modf(temp, &intpart);
-
- fracpart = ROUND((POW10(max)) * (ufvalue - intpart));
-
- if (fracpart >= POW10(max)) {
- intpart++;
- fracpart -= POW10(max);
- }
-
-
- /* Convert integer part */
- do {
- temp = intpart*0.1;
- my_modf(temp, &intpart);
- idx = (int) ((temp -intpart +0.05)* 10.0);
- /* idx = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */
- /* printf ("%llf, %f, %x\n", temp, intpart, idx); */
- iconvert[iplace++] =
- (caps? "0123456789ABCDEF":"0123456789abcdef")[idx];
- } while (intpart && (iplace < 311));
- if (iplace == 311) iplace--;
- iconvert[iplace] = 0;
-
- /* Convert fractional part */
- if (fracpart)
- {
- do {
- temp = fracpart*0.1;
- my_modf(temp, &fracpart);
- idx = (int) ((temp -fracpart +0.05)* 10.0);
- /* idx = (int) ((((temp/10) -fracpart) +0.05) *10); */
- /* printf ("%lf, %lf, %ld\n", temp, fracpart, idx ); */
- fconvert[fplace++] =
- (caps? "0123456789ABCDEF":"0123456789abcdef")[idx];
- } while(fracpart && (fplace < 311));
- if (fplace == 311) fplace--;
- }
- fconvert[fplace] = 0;
-
- /* -1 for decimal point, another -1 if we are printing a sign */
- padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
- zpadlen = max - fplace;
- if (zpadlen < 0) zpadlen = 0;
- if (padlen < 0)
- padlen = 0;
- if (flags & DP_F_MINUS)
- padlen = -padlen; /* Left Justifty */
-
- if ((flags & DP_F_ZERO) && (padlen > 0)) {
- if (signvalue) {
- dopr_outch (buffer, currlen, maxlen, signvalue);
- --padlen;
- signvalue = 0;
- }
- while (padlen > 0) {
- dopr_outch (buffer, currlen, maxlen, '0');
- --padlen;
- }
- }
- while (padlen > 0) {
- dopr_outch (buffer, currlen, maxlen, ' ');
- --padlen;
- }
- if (signvalue)
- dopr_outch (buffer, currlen, maxlen, signvalue);
-
- while (iplace > 0)
- dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
-
-#ifdef DEBUG_SNPRINTF
- printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen);
-#endif
-
- /*
- * Decimal point. This should probably use locale to find the correct
- * char to print out.
- */
- if (max > 0) {
- dopr_outch (buffer, currlen, maxlen, '.');
-
- while (zpadlen > 0) {
- dopr_outch (buffer, currlen, maxlen, '0');
- --zpadlen;
- }
-
- while (fplace > 0)
- dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
- }
-
- while (padlen < 0) {
- dopr_outch (buffer, currlen, maxlen, ' ');
- ++padlen;
- }
-}
-
-static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
-{
- if (*currlen < maxlen) {
- buffer[(*currlen)] = c;
- }
- (*currlen)++;
-}
-
-static struct pr_chunk *new_chunk(void) {
- struct pr_chunk *new_c = (struct pr_chunk *)malloc(sizeof(struct pr_chunk));
-
- if (!new_c)
- return NULL;
-
- new_c->type = 0;
- new_c->num = 0;
- new_c->min = 0;
- new_c->min_star = NULL;
- new_c->max = -1;
- new_c->max_star = NULL;
- new_c->flags = 0;
- new_c->cflags = 0;
- new_c->start = 0;
- new_c->len = 0;
- new_c->value = 0;
- new_c->fvalue = 0;
- new_c->strvalue = NULL;
- new_c->pnum = NULL;
- new_c->next = NULL;
-
- return new_c;
-}
-
-static int add_cnk_list_entry(struct pr_chunk_x **list,
- int max_num, struct pr_chunk *chunk) {
- struct pr_chunk_x *l;
- struct pr_chunk **c;
- int max;
- int cnum;
- int i, pos;
-
- if (chunk->num > max_num) {
- max = chunk->num;
-
- if (*list == NULL) {
- l = (struct pr_chunk_x *)malloc(sizeof(struct pr_chunk_x) * max);
- pos = 0;
- } else {
- l = (struct pr_chunk_x *)realloc(*list, sizeof(struct pr_chunk_x) * max);
- pos = max_num;
- }
- if (l == NULL) {
- for (i = 0; i < max; i++) {
- if ((*list)[i].chunks) free((*list)[i].chunks);
- }
- return 0;
- }
- for (i = pos; i < max; i++) {
- l[i].chunks = NULL;
- l[i].num = 0;
- }
- } else {
- l = *list;
- max = max_num;
- }
-
- i = chunk->num - 1;
- cnum = l[i].num + 1;
- if (l[i].chunks == NULL) {
- c = (struct pr_chunk **)malloc(sizeof(struct pr_chunk *) * cnum);
- } else {
- c = (struct pr_chunk **)realloc(l[i].chunks, sizeof(struct pr_chunk *) * cnum);
- }
- if (c == NULL) {
- for (i = 0; i < max; i++) {
- if (l[i].chunks) free(l[i].chunks);
- }
- return 0;
- }
- c[l[i].num] = chunk;
- l[i].chunks = c;
- l[i].num = cnum;
-
- *list = l;
- return max;
-}
-
- int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
-{
- return dopr(str, count, fmt, args);
-}
-#endif
-
-/* yes this really must be a ||. Don't muck with this (tridge)
- *
- * The logic for these two is that we need our own definition if the
- * OS *either* has no definition of *sprintf, or if it does have one
- * that doesn't work properly according to the autoconf test.
- */
-#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
- int snprintf(char *str,size_t count,const char *fmt,...)
-{
- size_t ret;
- va_list ap;
-
- va_start(ap, fmt);
- ret = vsnprintf(str, count, fmt, ap);
- va_end(ap);
- return ret;
-}
-#endif
-
-#ifndef HAVE_C99_VSNPRINTF
- int printf(const char *fmt, ...)
-{
- va_list ap;
- int ret;
- char *s;
-
- s = NULL;
- va_start(ap, fmt);
- ret = vasprintf(&s, fmt, ap);
- va_end(ap);
-
- if (s) {
- fwrite(s, 1, strlen(s), stdout);
- }
- free(s);
-
- return ret;
-}
-#endif
-
-#ifndef HAVE_C99_VSNPRINTF
- int fprintf(FILE *stream, const char *fmt, ...)
-{
- va_list ap;
- int ret;
- char *s;
-
- s = NULL;
- va_start(ap, fmt);
- ret = vasprintf(&s, fmt, ap);
- va_end(ap);
-
- if (s) {
- fwrite(s, 1, strlen(s), stream);
- }
- free(s);
-
- return ret;
-}
-#endif
-
-#endif
-
-#ifndef HAVE_VASPRINTF
- int vasprintf(char **ptr, const char *format, va_list ap)
-{
- int ret;
- va_list ap2;
-
- VA_COPY(ap2, ap);
- ret = vsnprintf(NULL, 0, format, ap2);
- va_end(ap2);
- if (ret < 0) return ret;
-
- (*ptr) = (char *)malloc(ret+1);
- if (!*ptr) return -1;
-
- VA_COPY(ap2, ap);
- ret = vsnprintf(*ptr, ret+1, format, ap2);
- va_end(ap2);
-
- return ret;
-}
-#endif
-
-
-#ifndef HAVE_ASPRINTF
- int asprintf(char **ptr, const char *format, ...)
-{
- va_list ap;
- int ret;
-
- *ptr = NULL;
- va_start(ap, format);
- ret = vasprintf(ptr, format, ap);
- va_end(ap);
-
- return ret;
-}
-#endif
-
-#ifdef TEST_SNPRINTF
-
- int sprintf(char *str,const char *fmt,...);
- int printf(const char *fmt,...);
-
- int main (void)
-{
- char buf1[1024];
- char buf2[1024];
- char *buf3;
- char *fp_fmt[] = {
- "%1.1f",
- "%-1.5f",
- "%1.5f",
- "%123.9f",
- "%10.5f",
- "% 10.5f",
- "%+22.9f",
- "%+4.9f",
- "%01.3f",
- "%4f",
- "%3.1f",
- "%3.2f",
- "%.0f",
- "%f",
- "%-8.8f",
- "%-9.9f",
- NULL
- };
- double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 203.9, 0.96, 0.996,
- 0.9996, 1.996, 4.136, 5.030201, 0.00205,
- /* END LIST */ 0};
- char *int_fmt[] = {
- "%-1.5d",
- "%1.5d",
- "%123.9d",
- "%5.5d",
- "%10.5d",
- "% 10.5d",
- "%+22.33d",
- "%01.3d",
- "%4d",
- "%d",
- NULL
- };
- long int_nums[] = { -1, 134, 91340, 341, 0203, 1234567890, 0};
- char *str_fmt[] = {
- "%10.5s",
- "%-10.5s",
- "%5.10s",
- "%-5.10s",
- "%10.1s",
- "%0.10s",
- "%10.0s",
- "%1.10s",
- "%s",
- "%.1s",
- "%.10s",
- "%10s",
- NULL
- };
- char *str_vals[] = {"hello", "a", "", "a longer string", NULL};
-#ifdef HAVE_LONG_LONG
- char *ll_fmt[] = {
- "%llu",
- NULL
- };
- LLONG ll_nums[] = { 134, 91340, 341, 0203, 1234567890, 128006186140000000LL, 0};
-#endif
- int x, y;
- int fail = 0;
- int num = 0;
- int l1, l2;
- char *ss_fmt[] = {
- "%zd",
- "%zu",
- NULL
- };
- size_t ss_nums[] = {134, 91340, 123456789, 0203, 1234567890, 0};
-
- printf ("Testing snprintf format codes against system sprintf...\n");
-
- for (x = 0; fp_fmt[x] ; x++) {
- for (y = 0; fp_nums[y] != 0 ; y++) {
- buf1[0] = buf2[0] = '\0';
- l1 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]);
- l2 = sprintf (buf2, fp_fmt[x], fp_nums[y]);
- buf1[1023] = buf2[1023] = '\0';
- if (strcmp (buf1, buf2) || (l1 != l2)) {
- printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
- fp_fmt[x], l1, buf1, l2, buf2);
- fail++;
- }
- num++;
- }
- }
-
- for (x = 0; int_fmt[x] ; x++) {
- for (y = 0; int_nums[y] != 0 ; y++) {
- buf1[0] = buf2[0] = '\0';
- l1 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]);
- l2 = sprintf (buf2, int_fmt[x], int_nums[y]);
- buf1[1023] = buf2[1023] = '\0';
- if (strcmp (buf1, buf2) || (l1 != l2)) {
- printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
- int_fmt[x], l1, buf1, l2, buf2);
- fail++;
- }
- num++;
- }
- }
-
- for (x = 0; str_fmt[x] ; x++) {
- for (y = 0; str_vals[y] != 0 ; y++) {
- buf1[0] = buf2[0] = '\0';
- l1 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]);
- l2 = sprintf (buf2, str_fmt[x], str_vals[y]);
- buf1[1023] = buf2[1023] = '\0';
- if (strcmp (buf1, buf2) || (l1 != l2)) {
- printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
- str_fmt[x], l1, buf1, l2, buf2);
- fail++;
- }
- num++;
- }
- }
-
-#ifdef HAVE_LONG_LONG
- for (x = 0; ll_fmt[x] ; x++) {
- for (y = 0; ll_nums[y] != 0 ; y++) {
- buf1[0] = buf2[0] = '\0';
- l1 = snprintf(buf1, sizeof(buf1), ll_fmt[x], ll_nums[y]);
- l2 = sprintf (buf2, ll_fmt[x], ll_nums[y]);
- buf1[1023] = buf2[1023] = '\0';
- if (strcmp (buf1, buf2) || (l1 != l2)) {
- printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
- ll_fmt[x], l1, buf1, l2, buf2);
- fail++;
- }
- num++;
- }
- }
-#endif
-
-#define BUFSZ 2048
-
- buf1[0] = buf2[0] = '\0';
- if ((buf3 = malloc(BUFSZ)) == NULL) {
- fail++;
- } else {
- num++;
- memset(buf3, 'a', BUFSZ);
- snprintf(buf1, sizeof(buf1), "%.*s", 1, buf3);
- buf1[1023] = '\0';
- if (strcmp(buf1, "a") != 0) {
- printf("length limit buf1 '%s' expected 'a'\n", buf1);
- fail++;
- }
- }
-
- buf1[0] = buf2[0] = '\0';
- l1 = snprintf(buf1, sizeof(buf1), "%4$*1$d %2$s %3$*1$.*1$f", 3, "pos test", 12.3456, 9);
- l2 = sprintf(buf2, "%4$*1$d %2$s %3$*1$.*1$f", 3, "pos test", 12.3456, 9);
- buf1[1023] = buf2[1023] = '\0';
- if (strcmp(buf1, buf2) || (l1 != l2)) {
- printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
- "%4$*1$d %2$s %3$*1$.*1$f", l1, buf1, l2, buf2);
- fail++;
- }
-
- buf1[0] = buf2[0] = '\0';
- l1 = snprintf(buf1, sizeof(buf1), "%4$*4$d %2$s %3$*4$.*4$f", 3, "pos test", 12.3456, 9);
- l2 = sprintf(buf2, "%4$*4$d %2$s %3$*4$.*4$f", 3, "pos test", 12.3456, 9);
- buf1[1023] = buf2[1023] = '\0';
- if (strcmp(buf1, buf2)) {
- printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
- "%4$*1$d %2$s %3$*1$.*1$f", l1, buf1, l2, buf2);
- fail++;
- }
-
- for (x = 0; ss_fmt[x] ; x++) {
- for (y = 0; ss_nums[y] != 0 ; y++) {
- buf1[0] = buf2[0] = '\0';
- l1 = snprintf(buf1, sizeof(buf1), ss_fmt[x], ss_nums[y]);
- l2 = sprintf (buf2, ss_fmt[x], ss_nums[y]);
- buf1[1023] = buf2[1023] = '\0';
- if (strcmp (buf1, buf2) || (l1 != l2)) {
- printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
- ss_fmt[x], l1, buf1, l2, buf2);
- fail++;
- }
- num++;
- }
- }
-#if 0
- buf1[0] = buf2[0] = '\0';
- l1 = snprintf(buf1, sizeof(buf1), "%lld", (LLONG)1234567890);
- l2 = sprintf(buf2, "%lld", (LLONG)1234567890);
- buf1[1023] = buf2[1023] = '\0';
- if (strcmp(buf1, buf2)) {
- printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
- "%lld", l1, buf1, l2, buf2);
- fail++;
- }
-
- buf1[0] = buf2[0] = '\0';
- l1 = snprintf(buf1, sizeof(buf1), "%Lf", (LDOUBLE)890.1234567890123);
- l2 = sprintf(buf2, "%Lf", (LDOUBLE)890.1234567890123);
- buf1[1023] = buf2[1023] = '\0';
- if (strcmp(buf1, buf2)) {
- printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
- "%Lf", l1, buf1, l2, buf2);
- fail++;
- }
-#endif
- printf ("%d tests failed out of %d.\n", fail, num);
-
- printf("seeing how many digits we support\n");
- {
- double v0 = 0.12345678901234567890123456789012345678901;
- for (x=0; x<100; x++) {
- double p = pow(10, x);
- double r = v0*p;
- snprintf(buf1, sizeof(buf1), "%1.1f", r);
- sprintf(buf2, "%1.1f", r);
- if (strcmp(buf1, buf2)) {
- printf("we seem to support %d digits\n", x-1);
- break;
- }
- }
- }
-
- return 0;
-}
-#endif /* TEST_SNPRINTF */
diff --git a/source4/lib/replace/socket.c b/source4/lib/replace/socket.c
deleted file mode 100644
index 35e975fce7..0000000000
--- a/source4/lib/replace/socket.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- *
- * Dummy replacements for socket functions.
- *
- * Copyright (C) Michael Adam <obnox@samba.org> 2008
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "replace.h"
-#include "system/network.h"
-
-int rep_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen)
-{
- errno = ENOSYS;
- return -1;
-}
-
-struct hostent *rep_gethostbyname(const char *name)
-{
- errno = ENOSYS;
- return NULL;
-}
diff --git a/source4/lib/replace/socketpair.c b/source4/lib/replace/socketpair.c
deleted file mode 100644
index c775730952..0000000000
--- a/source4/lib/replace/socketpair.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * replacement routines for broken systems
- * Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2006
- * Copyright (C) Michael Adam <obnox@samba.org> 2008
- *
- * ** NOTE! The following LGPL license applies to the replace
- * ** library. This does NOT imply that all of Samba is released
- * ** under the LGPL
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "replace.h"
-#include "system/network.h"
-
-int rep_socketpair(int d, int type, int protocol, int sv[2])
-{
- if (d != AF_UNIX) {
- errno = EAFNOSUPPORT;
- return -1;
- }
-
- if (protocol != 0) {
- errno = EPROTONOSUPPORT;
- return -1;
- }
-
- if (type != SOCK_STREAM) {
- errno = EOPNOTSUPP;
- return -1;
- }
-
- return pipe(sv);
-}
diff --git a/source4/lib/replace/strptime.c b/source4/lib/replace/strptime.c
deleted file mode 100644
index 0e40f7561a..0000000000
--- a/source4/lib/replace/strptime.c
+++ /dev/null
@@ -1,990 +0,0 @@
-/* Convert a string representation of time to a time value.
- Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- see <http://www.gnu.org/licenses/>. */
-
-/* XXX This version of the implementation is not really complete.
- Some of the fields cannot add information alone. But if seeing
- some of them in the same format (such as year, week and weekday)
- this is enough information for determining the date. */
-
-#include "replace.h"
-#include "system/locale.h"
-#include "system/time.h"
-
-#ifndef __P
-# if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
-# define __P(args) args
-# else
-# define __P(args) ()
-# endif /* GCC. */
-#endif /* Not __P. */
-
-#if ! HAVE_LOCALTIME_R && ! defined localtime_r
-# ifdef _LIBC
-# define localtime_r __localtime_r
-# else
-/* Approximate localtime_r as best we can in its absence. */
-# define localtime_r my_localtime_r
-static struct tm *localtime_r __P ((const time_t *, struct tm *));
-static struct tm *
-localtime_r (t, tp)
- const time_t *t;
- struct tm *tp;
-{
- struct tm *l = localtime (t);
- if (! l)
- return 0;
- *tp = *l;
- return tp;
-}
-# endif /* ! _LIBC */
-#endif /* ! HAVE_LOCALTIME_R && ! defined (localtime_r) */
-
-
-#define match_char(ch1, ch2) if (ch1 != ch2) return NULL
-#if defined __GNUC__ && __GNUC__ >= 2
-# define match_string(cs1, s2) \
- ({ size_t len = strlen (cs1); \
- int result = strncasecmp ((cs1), (s2), len) == 0; \
- if (result) (s2) += len; \
- result; })
-#else
-/* Oh come on. Get a reasonable compiler. */
-# define match_string(cs1, s2) \
- (strncasecmp ((cs1), (s2), strlen (cs1)) ? 0 : ((s2) += strlen (cs1), 1))
-#endif
-/* We intentionally do not use isdigit() for testing because this will
- lead to problems with the wide character version. */
-#define get_number(from, to, n) \
- do { \
- int __n = n; \
- val = 0; \
- while (*rp == ' ') \
- ++rp; \
- if (*rp < '0' || *rp > '9') \
- return NULL; \
- do { \
- val *= 10; \
- val += *rp++ - '0'; \
- } while (--__n > 0 && val * 10 <= to && *rp >= '0' && *rp <= '9'); \
- if (val < from || val > to) \
- return NULL; \
- } while (0)
-#ifdef _NL_CURRENT
-# define get_alt_number(from, to, n) \
- ({ \
- __label__ do_normal; \
- if (*decided != raw) \
- { \
- const char *alts = _NL_CURRENT (LC_TIME, ALT_DIGITS); \
- int __n = n; \
- int any = 0; \
- while (*rp == ' ') \
- ++rp; \
- val = 0; \
- do { \
- val *= 10; \
- while (*alts != '\0') \
- { \
- size_t len = strlen (alts); \
- if (strncasecmp (alts, rp, len) == 0) \
- break; \
- alts += len + 1; \
- ++val; \
- } \
- if (*alts == '\0') \
- { \
- if (*decided == not && ! any) \
- goto do_normal; \
- /* If we haven't read anything it's an error. */ \
- if (! any) \
- return NULL; \
- /* Correct the premature multiplication. */ \
- val /= 10; \
- break; \
- } \
- else \
- *decided = loc; \
- } while (--__n > 0 && val * 10 <= to); \
- if (val < from || val > to) \
- return NULL; \
- } \
- else \
- { \
- do_normal: \
- get_number (from, to, n); \
- } \
- 0; \
- })
-#else
-# define get_alt_number(from, to, n) \
- /* We don't have the alternate representation. */ \
- get_number(from, to, n)
-#endif
-#define recursive(new_fmt) \
- (*(new_fmt) != '\0' \
- && (rp = strptime_internal (rp, (new_fmt), tm, decided, era_cnt)) != NULL)
-
-
-#ifdef _LIBC
-/* This is defined in locale/C-time.c in the GNU libc. */
-extern const struct locale_data _nl_C_LC_TIME;
-extern const unsigned short int __mon_yday[2][13];
-
-# define weekday_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (DAY_1)].string)
-# define ab_weekday_name \
- (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABDAY_1)].string)
-# define month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (MON_1)].string)
-# define ab_month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABMON_1)].string)
-# define HERE_D_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_T_FMT)].string)
-# define HERE_D_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_FMT)].string)
-# define HERE_AM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (AM_STR)].string)
-# define HERE_PM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (PM_STR)].string)
-# define HERE_T_FMT_AMPM \
- (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (T_FMT_AMPM)].string)
-# define HERE_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (T_FMT)].string)
-
-# define strncasecmp(s1, s2, n) __strncasecmp (s1, s2, n)
-#else
-static char const weekday_name[][10] =
- {
- "Sunday", "Monday", "Tuesday", "Wednesday",
- "Thursday", "Friday", "Saturday"
- };
-static char const ab_weekday_name[][4] =
- {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
- };
-static char const month_name[][10] =
- {
- "January", "February", "March", "April", "May", "June",
- "July", "August", "September", "October", "November", "December"
- };
-static char const ab_month_name[][4] =
- {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
- };
-# define HERE_D_T_FMT "%a %b %e %H:%M:%S %Y"
-# define HERE_D_FMT "%m/%d/%y"
-# define HERE_AM_STR "AM"
-# define HERE_PM_STR "PM"
-# define HERE_T_FMT_AMPM "%I:%M:%S %p"
-# define HERE_T_FMT "%H:%M:%S"
-
-static const unsigned short int __mon_yday[2][13] =
- {
- /* Normal years. */
- { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
- /* Leap years. */
- { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
- };
-#endif
-
-/* Status of lookup: do we use the locale data or the raw data? */
-enum locale_status { not, loc, raw };
-
-
-#ifndef __isleap
-/* Nonzero if YEAR is a leap year (every 4 years,
- except every 100th isn't, and every 400th is). */
-# define __isleap(year) \
- ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
-#endif
-
-/* Compute the day of the week. */
-static void
-day_of_the_week (struct tm *tm)
-{
- /* We know that January 1st 1970 was a Thursday (= 4). Compute the
- the difference between this data in the one on TM and so determine
- the weekday. */
- int corr_year = 1900 + tm->tm_year - (tm->tm_mon < 2);
- int wday = (-473
- + (365 * (tm->tm_year - 70))
- + (corr_year / 4)
- - ((corr_year / 4) / 25) + ((corr_year / 4) % 25 < 0)
- + (((corr_year / 4) / 25) / 4)
- + __mon_yday[0][tm->tm_mon]
- + tm->tm_mday - 1);
- tm->tm_wday = ((wday % 7) + 7) % 7;
-}
-
-/* Compute the day of the year. */
-static void
-day_of_the_year (struct tm *tm)
-{
- tm->tm_yday = (__mon_yday[__isleap (1900 + tm->tm_year)][tm->tm_mon]
- + (tm->tm_mday - 1));
-}
-
-static char *
-#ifdef _LIBC
-internal_function
-#endif
-strptime_internal __P ((const char *rp, const char *fmt, struct tm *tm,
- enum locale_status *decided, int era_cnt));
-
-static char *
-#ifdef _LIBC
-internal_function
-#endif
-strptime_internal (rp, fmt, tm, decided, era_cnt)
- const char *rp;
- const char *fmt;
- struct tm *tm;
- enum locale_status *decided;
- int era_cnt;
-{
- const char *rp_backup;
- int cnt;
- size_t val;
- int have_I, is_pm;
- int century, want_century;
- int want_era;
- int have_wday, want_xday;
- int have_yday;
- int have_mon, have_mday;
-#ifdef _NL_CURRENT
- size_t num_eras;
-#endif
- struct era_entry *era;
-
- have_I = is_pm = 0;
- century = -1;
- want_century = 0;
- want_era = 0;
- era = NULL;
-
- have_wday = want_xday = have_yday = have_mon = have_mday = 0;
-
- while (*fmt != '\0')
- {
- /* A white space in the format string matches 0 more or white
- space in the input string. */
- if (isspace (*fmt))
- {
- while (isspace (*rp))
- ++rp;
- ++fmt;
- continue;
- }
-
- /* Any character but `%' must be matched by the same character
- in the iput string. */
- if (*fmt != '%')
- {
- match_char (*fmt++, *rp++);
- continue;
- }
-
- ++fmt;
-#ifndef _NL_CURRENT
- /* We need this for handling the `E' modifier. */
- start_over:
-#endif
-
- /* Make back up of current processing pointer. */
- rp_backup = rp;
-
- switch (*fmt++)
- {
- case '%':
- /* Match the `%' character itself. */
- match_char ('%', *rp++);
- break;
- case 'a':
- case 'A':
- /* Match day of week. */
- for (cnt = 0; cnt < 7; ++cnt)
- {
-#ifdef _NL_CURRENT
- if (*decided !=raw)
- {
- if (match_string (_NL_CURRENT (LC_TIME, DAY_1 + cnt), rp))
- {
- if (*decided == not
- && strcmp (_NL_CURRENT (LC_TIME, DAY_1 + cnt),
- weekday_name[cnt]))
- *decided = loc;
- break;
- }
- if (match_string (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt), rp))
- {
- if (*decided == not
- && strcmp (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt),
- ab_weekday_name[cnt]))
- *decided = loc;
- break;
- }
- }
-#endif
- if (*decided != loc
- && (match_string (weekday_name[cnt], rp)
- || match_string (ab_weekday_name[cnt], rp)))
- {
- *decided = raw;
- break;
- }
- }
- if (cnt == 7)
- /* Does not match a weekday name. */
- return NULL;
- tm->tm_wday = cnt;
- have_wday = 1;
- break;
- case 'b':
- case 'B':
- case 'h':
- /* Match month name. */
- for (cnt = 0; cnt < 12; ++cnt)
- {
-#ifdef _NL_CURRENT
- if (*decided !=raw)
- {
- if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), rp))
- {
- if (*decided == not
- && strcmp (_NL_CURRENT (LC_TIME, MON_1 + cnt),
- month_name[cnt]))
- *decided = loc;
- break;
- }
- if (match_string (_NL_CURRENT (LC_TIME, ABMON_1 + cnt), rp))
- {
- if (*decided == not
- && strcmp (_NL_CURRENT (LC_TIME, ABMON_1 + cnt),
- ab_month_name[cnt]))
- *decided = loc;
- break;
- }
- }
-#endif
- if (match_string (month_name[cnt], rp)
- || match_string (ab_month_name[cnt], rp))
- {
- *decided = raw;
- break;
- }
- }
- if (cnt == 12)
- /* Does not match a month name. */
- return NULL;
- tm->tm_mon = cnt;
- want_xday = 1;
- break;
- case 'c':
- /* Match locale's date and time format. */
-#ifdef _NL_CURRENT
- if (*decided != raw)
- {
- if (!recursive (_NL_CURRENT (LC_TIME, D_T_FMT)))
- {
- if (*decided == loc)
- return NULL;
- else
- rp = rp_backup;
- }
- else
- {
- if (*decided == not &&
- strcmp (_NL_CURRENT (LC_TIME, D_T_FMT), HERE_D_T_FMT))
- *decided = loc;
- want_xday = 1;
- break;
- }
- *decided = raw;
- }
-#endif
- if (!recursive (HERE_D_T_FMT))
- return NULL;
- want_xday = 1;
- break;
- case 'C':
- /* Match century number. */
-#ifdef _NL_CURRENT
- match_century:
-#endif
- get_number (0, 99, 2);
- century = val;
- want_xday = 1;
- break;
- case 'd':
- case 'e':
- /* Match day of month. */
- get_number (1, 31, 2);
- tm->tm_mday = val;
- have_mday = 1;
- want_xday = 1;
- break;
- case 'F':
- if (!recursive ("%Y-%m-%d"))
- return NULL;
- want_xday = 1;
- break;
- case 'x':
-#ifdef _NL_CURRENT
- if (*decided != raw)
- {
- if (!recursive (_NL_CURRENT (LC_TIME, D_FMT)))
- {
- if (*decided == loc)
- return NULL;
- else
- rp = rp_backup;
- }
- else
- {
- if (*decided == not
- && strcmp (_NL_CURRENT (LC_TIME, D_FMT), HERE_D_FMT))
- *decided = loc;
- want_xday = 1;
- break;
- }
- *decided = raw;
- }
-#endif
- /* Fall through. */
- case 'D':
- /* Match standard day format. */
- if (!recursive (HERE_D_FMT))
- return NULL;
- want_xday = 1;
- break;
- case 'k':
- case 'H':
- /* Match hour in 24-hour clock. */
- get_number (0, 23, 2);
- tm->tm_hour = val;
- have_I = 0;
- break;
- case 'I':
- /* Match hour in 12-hour clock. */
- get_number (1, 12, 2);
- tm->tm_hour = val % 12;
- have_I = 1;
- break;
- case 'j':
- /* Match day number of year. */
- get_number (1, 366, 3);
- tm->tm_yday = val - 1;
- have_yday = 1;
- break;
- case 'm':
- /* Match number of month. */
- get_number (1, 12, 2);
- tm->tm_mon = val - 1;
- have_mon = 1;
- want_xday = 1;
- break;
- case 'M':
- /* Match minute. */
- get_number (0, 59, 2);
- tm->tm_min = val;
- break;
- case 'n':
- case 't':
- /* Match any white space. */
- while (isspace (*rp))
- ++rp;
- break;
- case 'p':
- /* Match locale's equivalent of AM/PM. */
-#ifdef _NL_CURRENT
- if (*decided != raw)
- {
- if (match_string (_NL_CURRENT (LC_TIME, AM_STR), rp))
- {
- if (strcmp (_NL_CURRENT (LC_TIME, AM_STR), HERE_AM_STR))
- *decided = loc;
- break;
- }
- if (match_string (_NL_CURRENT (LC_TIME, PM_STR), rp))
- {
- if (strcmp (_NL_CURRENT (LC_TIME, PM_STR), HERE_PM_STR))
- *decided = loc;
- is_pm = 1;
- break;
- }
- *decided = raw;
- }
-#endif
- if (!match_string (HERE_AM_STR, rp)) {
- if (match_string (HERE_PM_STR, rp)) {
- is_pm = 1;
- } else {
- return NULL;
- }
- }
- break;
- case 'r':
-#ifdef _NL_CURRENT
- if (*decided != raw)
- {
- if (!recursive (_NL_CURRENT (LC_TIME, T_FMT_AMPM)))
- {
- if (*decided == loc)
- return NULL;
- else
- rp = rp_backup;
- }
- else
- {
- if (*decided == not &&
- strcmp (_NL_CURRENT (LC_TIME, T_FMT_AMPM),
- HERE_T_FMT_AMPM))
- *decided = loc;
- break;
- }
- *decided = raw;
- }
-#endif
- if (!recursive (HERE_T_FMT_AMPM))
- return NULL;
- break;
- case 'R':
- if (!recursive ("%H:%M"))
- return NULL;
- break;
- case 's':
- {
- /* The number of seconds may be very high so we cannot use
- the `get_number' macro. Instead read the number
- character for character and construct the result while
- doing this. */
- time_t secs = 0;
- if (*rp < '0' || *rp > '9')
- /* We need at least one digit. */
- return NULL;
-
- do
- {
- secs *= 10;
- secs += *rp++ - '0';
- }
- while (*rp >= '0' && *rp <= '9');
-
- if (localtime_r (&secs, tm) == NULL)
- /* Error in function. */
- return NULL;
- }
- break;
- case 'S':
- get_number (0, 61, 2);
- tm->tm_sec = val;
- break;
- case 'X':
-#ifdef _NL_CURRENT
- if (*decided != raw)
- {
- if (!recursive (_NL_CURRENT (LC_TIME, T_FMT)))
- {
- if (*decided == loc)
- return NULL;
- else
- rp = rp_backup;
- }
- else
- {
- if (strcmp (_NL_CURRENT (LC_TIME, T_FMT), HERE_T_FMT))
- *decided = loc;
- break;
- }
- *decided = raw;
- }
-#endif
- /* Fall through. */
- case 'T':
- if (!recursive (HERE_T_FMT))
- return NULL;
- break;
- case 'u':
- get_number (1, 7, 1);
- tm->tm_wday = val % 7;
- have_wday = 1;
- break;
- case 'g':
- get_number (0, 99, 2);
- /* XXX This cannot determine any field in TM. */
- break;
- case 'G':
- if (*rp < '0' || *rp > '9')
- return NULL;
- /* XXX Ignore the number since we would need some more
- information to compute a real date. */
- do
- ++rp;
- while (*rp >= '0' && *rp <= '9');
- break;
- case 'U':
- case 'V':
- case 'W':
- get_number (0, 53, 2);
- /* XXX This cannot determine any field in TM without some
- information. */
- break;
- case 'w':
- /* Match number of weekday. */
- get_number (0, 6, 1);
- tm->tm_wday = val;
- have_wday = 1;
- break;
- case 'y':
-#ifdef _NL_CURRENT
- match_year_in_century:
-#endif
- /* Match year within century. */
- get_number (0, 99, 2);
- /* The "Year 2000: The Millennium Rollover" paper suggests that
- values in the range 69-99 refer to the twentieth century. */
- tm->tm_year = val >= 69 ? val : val + 100;
- /* Indicate that we want to use the century, if specified. */
- want_century = 1;
- want_xday = 1;
- break;
- case 'Y':
- /* Match year including century number. */
- get_number (0, 9999, 4);
- tm->tm_year = val - 1900;
- want_century = 0;
- want_xday = 1;
- break;
- case 'Z':
- /* XXX How to handle this? */
- break;
- case 'E':
-#ifdef _NL_CURRENT
- switch (*fmt++)
- {
- case 'c':
- /* Match locale's alternate date and time format. */
- if (*decided != raw)
- {
- const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_T_FMT);
-
- if (*fmt == '\0')
- fmt = _NL_CURRENT (LC_TIME, D_T_FMT);
-
- if (!recursive (fmt))
- {
- if (*decided == loc)
- return NULL;
- else
- rp = rp_backup;
- }
- else
- {
- if (strcmp (fmt, HERE_D_T_FMT))
- *decided = loc;
- want_xday = 1;
- break;
- }
- *decided = raw;
- }
- /* The C locale has no era information, so use the
- normal representation. */
- if (!recursive (HERE_D_T_FMT))
- return NULL;
- want_xday = 1;
- break;
- case 'C':
- if (*decided != raw)
- {
- if (era_cnt >= 0)
- {
- era = _nl_select_era_entry (era_cnt);
- if (match_string (era->era_name, rp))
- {
- *decided = loc;
- break;
- }
- else
- return NULL;
- }
- else
- {
- num_eras = _NL_CURRENT_WORD (LC_TIME,
- _NL_TIME_ERA_NUM_ENTRIES);
- for (era_cnt = 0; era_cnt < (int) num_eras;
- ++era_cnt, rp = rp_backup)
- {
- era = _nl_select_era_entry (era_cnt);
- if (match_string (era->era_name, rp))
- {
- *decided = loc;
- break;
- }
- }
- if (era_cnt == (int) num_eras)
- {
- era_cnt = -1;
- if (*decided == loc)
- return NULL;
- }
- else
- break;
- }
-
- *decided = raw;
- }
- /* The C locale has no era information, so use the
- normal representation. */
- goto match_century;
- case 'y':
- if (*decided == raw)
- goto match_year_in_century;
-
- get_number(0, 9999, 4);
- tm->tm_year = val;
- want_era = 1;
- want_xday = 1;
- break;
- case 'Y':
- if (*decided != raw)
- {
- num_eras = _NL_CURRENT_WORD (LC_TIME,
- _NL_TIME_ERA_NUM_ENTRIES);
- for (era_cnt = 0; era_cnt < (int) num_eras;
- ++era_cnt, rp = rp_backup)
- {
- era = _nl_select_era_entry (era_cnt);
- if (recursive (era->era_format))
- break;
- }
- if (era_cnt == (int) num_eras)
- {
- era_cnt = -1;
- if (*decided == loc)
- return NULL;
- else
- rp = rp_backup;
- }
- else
- {
- *decided = loc;
- era_cnt = -1;
- break;
- }
-
- *decided = raw;
- }
- get_number (0, 9999, 4);
- tm->tm_year = val - 1900;
- want_century = 0;
- want_xday = 1;
- break;
- case 'x':
- if (*decided != raw)
- {
- const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_FMT);
-
- if (*fmt == '\0')
- fmt = _NL_CURRENT (LC_TIME, D_FMT);
-
- if (!recursive (fmt))
- {
- if (*decided == loc)
- return NULL;
- else
- rp = rp_backup;
- }
- else
- {
- if (strcmp (fmt, HERE_D_FMT))
- *decided = loc;
- break;
- }
- *decided = raw;
- }
- if (!recursive (HERE_D_FMT))
- return NULL;
- break;
- case 'X':
- if (*decided != raw)
- {
- const char *fmt = _NL_CURRENT (LC_TIME, ERA_T_FMT);
-
- if (*fmt == '\0')
- fmt = _NL_CURRENT (LC_TIME, T_FMT);
-
- if (!recursive (fmt))
- {
- if (*decided == loc)
- return NULL;
- else
- rp = rp_backup;
- }
- else
- {
- if (strcmp (fmt, HERE_T_FMT))
- *decided = loc;
- break;
- }
- *decided = raw;
- }
- if (!recursive (HERE_T_FMT))
- return NULL;
- break;
- default:
- return NULL;
- }
- break;
-#else
- /* We have no information about the era format. Just use
- the normal format. */
- if (*fmt != 'c' && *fmt != 'C' && *fmt != 'y' && *fmt != 'Y'
- && *fmt != 'x' && *fmt != 'X')
- /* This is an illegal format. */
- return NULL;
-
- goto start_over;
-#endif
- case 'O':
- switch (*fmt++)
- {
- case 'd':
- case 'e':
- /* Match day of month using alternate numeric symbols. */
- get_alt_number (1, 31, 2);
- tm->tm_mday = val;
- have_mday = 1;
- want_xday = 1;
- break;
- case 'H':
- /* Match hour in 24-hour clock using alternate numeric
- symbols. */
- get_alt_number (0, 23, 2);
- tm->tm_hour = val;
- have_I = 0;
- break;
- case 'I':
- /* Match hour in 12-hour clock using alternate numeric
- symbols. */
- get_alt_number (1, 12, 2);
- tm->tm_hour = val - 1;
- have_I = 1;
- break;
- case 'm':
- /* Match month using alternate numeric symbols. */
- get_alt_number (1, 12, 2);
- tm->tm_mon = val - 1;
- have_mon = 1;
- want_xday = 1;
- break;
- case 'M':
- /* Match minutes using alternate numeric symbols. */
- get_alt_number (0, 59, 2);
- tm->tm_min = val;
- break;
- case 'S':
- /* Match seconds using alternate numeric symbols. */
- get_alt_number (0, 61, 2);
- tm->tm_sec = val;
- break;
- case 'U':
- case 'V':
- case 'W':
- get_alt_number (0, 53, 2);
- /* XXX This cannot determine any field in TM without
- further information. */
- break;
- case 'w':
- /* Match number of weekday using alternate numeric symbols. */
- get_alt_number (0, 6, 1);
- tm->tm_wday = val;
- have_wday = 1;
- break;
- case 'y':
- /* Match year within century using alternate numeric symbols. */
- get_alt_number (0, 99, 2);
- tm->tm_year = val >= 69 ? val : val + 100;
- want_xday = 1;
- break;
- default:
- return NULL;
- }
- break;
- default:
- return NULL;
- }
- }
-
- if (have_I && is_pm)
- tm->tm_hour += 12;
-
- if (century != -1)
- {
- if (want_century)
- tm->tm_year = tm->tm_year % 100 + (century - 19) * 100;
- else
- /* Only the century, but not the year. Strange, but so be it. */
- tm->tm_year = (century - 19) * 100;
- }
-
-#ifdef _NL_CURRENT
- if (era_cnt != -1)
- {
- era = _nl_select_era_entry(era_cnt);
- if (want_era)
- tm->tm_year = (era->start_date[0]
- + ((tm->tm_year - era->offset)
- * era->absolute_direction));
- else
- /* Era start year assumed. */
- tm->tm_year = era->start_date[0];
- }
- else
-#endif
- if (want_era)
- return NULL;
-
- if (want_xday && !have_wday)
- {
- if ( !(have_mon && have_mday) && have_yday)
- {
- /* We don't have tm_mon and/or tm_mday, compute them. */
- int t_mon = 0;
- while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon] <= tm->tm_yday)
- t_mon++;
- if (!have_mon)
- tm->tm_mon = t_mon - 1;
- if (!have_mday)
- tm->tm_mday =
- (tm->tm_yday
- - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1);
- }
- day_of_the_week (tm);
- }
- if (want_xday && !have_yday)
- day_of_the_year (tm);
-
- return discard_const_p(char, rp);
-}
-
-
-char *rep_strptime(const char *buf, const char *format, struct tm *tm)
-{
- enum locale_status decided;
-
-#ifdef _NL_CURRENT
- decided = not;
-#else
- decided = raw;
-#endif
- return strptime_internal (buf, format, tm, &decided, -1);
-}
diff --git a/source4/lib/replace/strptime.m4 b/source4/lib/replace/strptime.m4
deleted file mode 100644
index da22fc5a97..0000000000
--- a/source4/lib/replace/strptime.m4
+++ /dev/null
@@ -1,13 +0,0 @@
-AC_CACHE_CHECK([whether strptime is available and works],libreplace_cv_STRPTIME_OK,[
- AC_TRY_RUN([
- #define LIBREPLACE_CONFIGURE_TEST_STRPTIME
- #include "$libreplacedir/test/strptime.c"
- ],
- [libreplace_cv_STRPTIME_OK=yes],
- [libreplace_cv_STRPTIME_OK=no],
- [libreplace_cv_STRPTIME_OK="assuming not"])
-])
-if test x"$libreplace_cv_STRPTIME_OK" != x"yes"; then
- AC_DEFINE(REPLACE_STRPTIME,1,[Whether strptime should be replaced])
- LIBREPLACEOBJ="${LIBREPLACEOBJ} strptime.o"
-fi
diff --git a/source4/lib/replace/system/README b/source4/lib/replace/system/README
deleted file mode 100644
index 69a2b80b56..0000000000
--- a/source4/lib/replace/system/README
+++ /dev/null
@@ -1,4 +0,0 @@
-This directory contains wrappers around logical groups of system
-include files. The idea is to avoid #ifdef blocks in the main code,
-and instead put all the necessary conditional includes in subsystem
-specific header files in this directory.
diff --git a/source4/lib/replace/system/aio.h b/source4/lib/replace/system/aio.h
deleted file mode 100644
index 784d77fa28..0000000000
--- a/source4/lib/replace/system/aio.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef _system_aio_h
-#define _system_aio_h
-/*
- Unix SMB/CIFS implementation.
-
- AIO system include wrappers
-
- Copyright (C) Andrew Tridgell 2006
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_LIBAIO_H
-#include <libaio.h>
-#endif
-
-#endif
diff --git a/source4/lib/replace/system/capability.h b/source4/lib/replace/system/capability.h
deleted file mode 100644
index a7b78f0275..0000000000
--- a/source4/lib/replace/system/capability.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef _system_capability_h
-#define _system_capability_h
-/*
- Unix SMB/CIFS implementation.
-
- capability system include wrappers
-
- Copyright (C) Andrew Tridgell 2004
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_SYS_CAPABILITY_H
-
-#if defined(BROKEN_REDHAT_7_SYSTEM_HEADERS) && !defined(_I386_STATFS_H) && !defined(_PPC_STATFS_H)
-#define _I386_STATFS_H
-#define _PPC_STATFS_H
-#define BROKEN_REDHAT_7_STATFS_WORKAROUND
-#endif
-
-#if defined(BROKEN_RHEL5_SYS_CAP_HEADER) && !defined(_LINUX_TYPES_H)
-#define BROKEN_RHEL5_SYS_CAP_HEADER_WORKAROUND
-#endif
-
-#include <sys/capability.h>
-
-#ifdef BROKEN_RHEL5_SYS_CAP_HEADER_WORKAROUND
-#undef _LINUX_TYPES_H
-#undef BROKEN_RHEL5_SYS_CAP_HEADER_WORKAROUND
-#endif
-
-#ifdef BROKEN_REDHAT_7_STATFS_WORKAROUND
-#undef _PPC_STATFS_H
-#undef _I386_STATFS_H
-#undef BROKEN_REDHAT_7_STATFS_WORKAROUND
-#endif
-
-#endif
-
-#endif
diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4
deleted file mode 100644
index 5c9b53d5c5..0000000000
--- a/source4/lib/replace/system/config.m4
+++ /dev/null
@@ -1,130 +0,0 @@
-# filesys
-AC_HEADER_DIRENT
-AC_CHECK_HEADERS(fcntl.h sys/fcntl.h sys/resource.h sys/ioctl.h sys/mode.h sys/filio.h sys/fs/s5param.h sys/filsys.h)
-AC_CHECK_HEADERS(sys/acl.h acl/libacl.h)
-
-# select
-AC_CHECK_HEADERS(sys/select.h)
-
-# time
-AC_CHECK_HEADERS(sys/time.h utime.h)
-AC_HEADER_TIME
-AC_CHECK_FUNCS(utime utimes)
-
-# wait
-AC_HEADER_SYS_WAIT
-
-# capability
-AC_CHECK_HEADERS(sys/capability.h)
-
-case "$host_os" in
-*linux*)
-AC_CACHE_CHECK([for broken RedHat 7.2 system header files],libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
-AC_TRY_COMPILE([
- #ifdef HAVE_SYS_VFS_H
- #include <sys/vfs.h>
- #endif
- #ifdef HAVE_SYS_CAPABILITY_H
- #include <sys/capability.h>
- #endif
- ],[
- int i;
- ],
- libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,
- libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes
-)])
-if test x"$libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
- AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
-fi
-
-AC_CACHE_CHECK([for broken RHEL5 sys/capability.h],libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER,[
-AC_TRY_COMPILE([
- #ifdef HAVE_SYS_CAPABILITY_H
- #include <sys/capability.h>
- #endif
- #include <linux/types.h>
- ],[
- __s8 i;
- ],
- libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER=no,
- libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER=yes
-)])
-if test x"$libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER" = x"yes"; then
- AC_DEFINE(BROKEN_RHEL5_SYS_CAP_HEADER,1,[Broken RHEL5 sys/capability.h])
-fi
-;;
-esac
-
-# passwd
-AC_CHECK_HEADERS(grp.h sys/id.h compat.h shadow.h sys/priv.h pwd.h sys/security.h)
-AC_CHECK_FUNCS(getpwnam_r getpwuid_r getpwent_r)
-AC_HAVE_DECL(getpwent_r, [
- #include <unistd.h>
- #include <pwd.h>
- ])
-AC_VERIFY_C_PROTOTYPE([struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)],
- [
- #ifndef HAVE_GETPWENT_R_DECL
- #error missing getpwent_r prototype
- #endif
- return NULL;
- ],[
- AC_DEFINE(SOLARIS_GETPWENT_R, 1, [getpwent_r solaris function prototype])
- ],[],[
- #include <unistd.h>
- #include <pwd.h>
- ])
-AC_VERIFY_C_PROTOTYPE([struct passwd *getpwent_r(struct passwd *src, char *buf, size_t buflen)],
- [
- #ifndef HAVE_GETPWENT_R_DECL
- #error missing getpwent_r prototype
- #endif
- return NULL;
- ],[
- AC_DEFINE(SOLARIS_GETPWENT_R, 1, [getpwent_r irix (similar to solaris) function prototype])
- ],[],[
- #include <unistd.h>
- #include <pwd.h>
- ])
-AC_CHECK_FUNCS(getgrnam_r getgrgid_r getgrent_r)
-AC_HAVE_DECL(getgrent_r, [
- #include <unistd.h>
- #include <grp.h>
- ])
-AC_VERIFY_C_PROTOTYPE([struct group *getgrent_r(struct group *src, char *buf, int buflen)],
- [
- #ifndef HAVE_GETGRENT_R_DECL
- #error missing getgrent_r prototype
- #endif
- return NULL;
- ],[
- AC_DEFINE(SOLARIS_GETGRENT_R, 1, [getgrent_r solaris function prototype])
- ],[],[
- #include <unistd.h>
- #include <grp.h>
- ])
-
-AC_VERIFY_C_PROTOTYPE([struct group *getgrent_r(struct group *src, char *buf, size_t buflen)],
- [
- #ifndef HAVE_GETGRENT_R_DECL
- #error missing getgrent_r prototype
- #endif
- return NULL;
- ],[
- AC_DEFINE(SOLARIS_GETGRENT_R, 1, [getgrent_r irix (similar to solaris) function prototype])
- ],[],[
- #include <unistd.h>
- #include <grp.h>
- ])
-
-# locale
-AC_CHECK_HEADERS(ctype.h locale.h)
-
-# glob
-AC_CHECK_HEADERS(fnmatch.h)
-
-# shmem
-AC_CHECK_HEADERS(sys/ipc.h sys/mman.h sys/shm.h )
-
-# terminal
-AC_CHECK_HEADERS(termios.h termio.h sys/termio.h )
diff --git a/source4/lib/replace/system/dir.h b/source4/lib/replace/system/dir.h
deleted file mode 100644
index dec2d54649..0000000000
--- a/source4/lib/replace/system/dir.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef _system_dir_h
-#define _system_dir_h
-/*
- Unix SMB/CIFS implementation.
-
- directory system include wrappers
-
- Copyright (C) Andrew Tridgell 2004
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#if HAVE_DIRENT_H
-# include <dirent.h>
-# define NAMLEN(dirent) strlen((dirent)->d_name)
-#else
-# define dirent direct
-# define NAMLEN(dirent) (dirent)->d_namlen
-# if HAVE_SYS_NDIR_H
-# include <sys/ndir.h>
-# endif
-# if HAVE_SYS_DIR_H
-# include <sys/dir.h>
-# endif
-# if HAVE_NDIR_H
-# include <ndir.h>
-# endif
-#endif
-
-#ifndef HAVE_MKDIR_MODE
-#define mkdir(dir, mode) mkdir(dir)
-#endif
-
-/* Test whether a file name is the "." or ".." directory entries.
- * These really should be inline functions.
- */
-#ifndef ISDOT
-#define ISDOT(path) ( \
- *((const char *)(path)) == '.' && \
- *(((const char *)(path)) + 1) == '\0' \
- )
-#endif
-
-#ifndef ISDOTDOT
-#define ISDOTDOT(path) ( \
- *((const char *)(path)) == '.' && \
- *(((const char *)(path)) + 1) == '.' && \
- *(((const char *)(path)) + 2) == '\0' \
- )
-#endif
-
-#endif
diff --git a/source4/lib/replace/system/filesys.h b/source4/lib/replace/system/filesys.h
deleted file mode 100644
index 4bf1f64865..0000000000
--- a/source4/lib/replace/system/filesys.h
+++ /dev/null
@@ -1,182 +0,0 @@
-#ifndef _system_filesys_h
-#define _system_filesys_h
-/*
- Unix SMB/CIFS implementation.
-
- filesystem system include wrappers
-
- Copyright (C) Andrew Tridgell 2004
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include <unistd.h>
-#include <sys/stat.h>
-
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#ifdef HAVE_SYS_MOUNT_H
-#include <sys/mount.h>
-#endif
-
-#ifdef HAVE_MNTENT_H
-#include <mntent.h>
-#endif
-
-#ifdef HAVE_SYS_VFS_H
-#include <sys/vfs.h>
-#endif
-
-#ifdef HAVE_SYS_ACL_H
-#include <sys/acl.h>
-#endif
-
-#ifdef HAVE_ACL_LIBACL_H
-#include <acl/libacl.h>
-#endif
-
-#ifdef HAVE_SYS_FS_S5PARAM_H
-#include <sys/fs/s5param.h>
-#endif
-
-#if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
-#include <sys/filsys.h>
-#endif
-
-#ifdef HAVE_SYS_STATFS_H
-# include <sys/statfs.h>
-#endif
-
-#ifdef HAVE_DUSTAT_H
-#include <sys/dustat.h>
-#endif
-
-#ifdef HAVE_SYS_STATVFS_H
-#include <sys/statvfs.h>
-#endif
-
-#ifdef HAVE_SYS_FILIO_H
-#include <sys/filio.h>
-#endif
-
-#include <sys/file.h>
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#ifdef HAVE_SYS_FCNTL_H
-#include <sys/fcntl.h>
-#endif
-#endif
-
-#ifdef HAVE_SYS_MODE_H
-/* apparently AIX needs this for S_ISLNK */
-#ifndef S_ISLNK
-#include <sys/mode.h>
-#endif
-#endif
-
-#ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-
-/*
- * Veritas File System. Often in addition to native.
- * Quotas different.
- */
-#if defined(HAVE_SYS_FS_VX_QUOTA_H)
-#define VXFS_QUOTA
-#endif
-
-#if HAVE_SYS_ATTRIBUTES_H
-#include <sys/attributes.h>
-#endif
-
-/* mutually exclusive (SuSE 8.2) */
-#if HAVE_ATTR_XATTR_H
-#include <attr/xattr.h>
-#elif HAVE_SYS_XATTR_H
-#include <sys/xattr.h>
-#endif
-
-
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>
-#endif
-
-/* Some POSIX definitions for those without */
-
-#ifndef S_IFDIR
-#define S_IFDIR 0x4000
-#endif
-#ifndef S_ISDIR
-#define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)
-#endif
-#ifndef S_IRWXU
-#define S_IRWXU 00700 /* read, write, execute: owner */
-#endif
-#ifndef S_IRUSR
-#define S_IRUSR 00400 /* read permission: owner */
-#endif
-#ifndef S_IWUSR
-#define S_IWUSR 00200 /* write permission: owner */
-#endif
-#ifndef S_IXUSR
-#define S_IXUSR 00100 /* execute permission: owner */
-#endif
-#ifndef S_IRWXG
-#define S_IRWXG 00070 /* read, write, execute: group */
-#endif
-#ifndef S_IRGRP
-#define S_IRGRP 00040 /* read permission: group */
-#endif
-#ifndef S_IWGRP
-#define S_IWGRP 00020 /* write permission: group */
-#endif
-#ifndef S_IXGRP
-#define S_IXGRP 00010 /* execute permission: group */
-#endif
-#ifndef S_IRWXO
-#define S_IRWXO 00007 /* read, write, execute: other */
-#endif
-#ifndef S_IROTH
-#define S_IROTH 00004 /* read permission: other */
-#endif
-#ifndef S_IWOTH
-#define S_IWOTH 00002 /* write permission: other */
-#endif
-#ifndef S_IXOTH
-#define S_IXOTH 00001 /* execute permission: other */
-#endif
-
-#ifndef O_ACCMODE
-#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
-#endif
-
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 256
-#endif
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-
-#endif
diff --git a/source4/lib/replace/system/glob.h b/source4/lib/replace/system/glob.h
deleted file mode 100644
index 3e23db6828..0000000000
--- a/source4/lib/replace/system/glob.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _system_glob_h
-#define _system_glob_h
-/*
- Unix SMB/CIFS implementation.
-
- glob system include wrappers
-
- Copyright (C) Andrew Tridgell 2004
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifdef HAVE_GLOB_H
-#include <glob.h>
-#endif
-
-#ifdef HAVE_FNMATCH_H
-#include <fnmatch.h>
-#endif
-
-#endif
diff --git a/source4/lib/replace/system/iconv.h b/source4/lib/replace/system/iconv.h
deleted file mode 100644
index 3c8a71f2f7..0000000000
--- a/source4/lib/replace/system/iconv.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef _system_iconv_h
-#define _system_iconv_h
-/*
- Unix SMB/CIFS implementation.
-
- iconv memory system include wrappers
-
- Copyright (C) Andrew Tridgell 2004
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#if !defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
-#define HAVE_ICONV
-#endif
-
-#if !defined(HAVE_GICONV) && defined(HAVE_GICONV_H)
-#define HAVE_GICONV
-#endif
-
-#if !defined(HAVE_BICONV) && defined(HAVE_BICONV_H)
-#define HAVE_BICONV
-#endif
-
-#ifdef HAVE_NATIVE_ICONV
-#if defined(HAVE_ICONV)
-#include <iconv.h>
-#elif defined(HAVE_GICONV)
-#include <giconv.h>
-#elif defined(HAVE_BICONV)
-#include <biconv.h>
-#endif
-#endif /* HAVE_NATIVE_ICONV */
-
-/* needed for some systems without iconv. Doesn't really matter
- what error code we use */
-#ifndef EILSEQ
-#define EILSEQ EIO
-#endif
-
-#endif
diff --git a/source4/lib/replace/system/kerberos.h b/source4/lib/replace/system/kerberos.h
deleted file mode 100644
index 2981024bee..0000000000
--- a/source4/lib/replace/system/kerberos.h
+++ /dev/null
@@ -1,137 +0,0 @@
-#ifndef _system_kerberos_h
-#define _system_kerberos_h
-
-/*
- Unix SMB/CIFS implementation.
-
- kerberos system include wrappers
-
- Copyright (C) Andrew Tridgell 2004
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifdef HAVE_KRB5
-/* Whether the krb5_address struct has a addrtype property */
-/* #undef HAVE_ADDRTYPE_IN_KRB5_ADDRESS */
-/* Whether the krb5_address struct has a addr_type property */
-#define HAVE_ADDR_TYPE_IN_KRB5_ADDRESS 1
-/* Define to 1 if you have the `gsskrb5_extract_authz_data_from_sec_context' */
-#define HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT 1
-/* Define to 1 if you have the `gsskrb5_get_initiator_subkey' function. */
-#define HAVE_GSSKRB5_GET_INITIATOR_SUBKEY 1
-/* Define to 1 if you have the `gsskrb5_register_acceptor_identity' function. */
-#define HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY 1
-/* Define to 1 if you have the `gss_krb5_ccache_name' function. */
-#define HAVE_GSS_KRB5_CCACHE_NAME 1
-/* Define to 1 if you have the `krb5_addlog_func' function. */
-#define HAVE_KRB5_ADDLOG_FUNC 1
-/* Define to 1 if you have the `krb5_auth_con_setkey' function. */
-#define HAVE_KRB5_AUTH_CON_SETKEY 1
-/* Define to 1 if you have the `krb5_auth_con_setuseruserkey' function. */
-/* #undef HAVE_KRB5_AUTH_CON_SETUSERUSERKEY */
-/* Define to 1 if you have the `krb5_c_enctype_compare' function. */
-#define HAVE_KRB5_C_ENCTYPE_COMPARE 1
-/* Define to 1 if you have the `krb5_c_verify_checksum' function. */
-#define HAVE_KRB5_C_VERIFY_CHECKSUM 1
-/* Whether the type krb5_encrypt_block exists */
-/* #undef HAVE_KRB5_ENCRYPT_BLOCK */
-/* Define to 1 if you have the `krb5_encrypt_data' function. */
-/* #undef HAVE_KRB5_ENCRYPT_DATA */
-/* Define to 1 if you have the `krb5_enctypes_compatible_keys' function. */
-#define HAVE_KRB5_ENCTYPES_COMPATIBLE_KEYS 1
-/* Define to 1 if you have the `krb5_free_data_contents' function. */
-#define HAVE_KRB5_FREE_DATA_CONTENTS 1
-/* Define to 1 if you have the `krb5_free_error_string' function. */
-#define HAVE_KRB5_FREE_ERROR_STRING 1
-/* Define to 1 if you have the `krb5_free_keytab_entry_contents' function. */
-/* #undef HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS */
-/* Define to 1 if you have the `krb5_free_ktypes' function. */
-/* #undef HAVE_KRB5_FREE_KTYPES */
-/* Define to 1 if you have the `krb5_free_unparsed_name' function. */
-/* #undef HAVE_KRB5_FREE_UNPARSED_NAME */
-/* Define to 1 if you have the `krb5_get_default_in_tkt_etypes' function. */
-#define HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES 1
-/* Define to 1 if you have the `krb5_get_error_string' function. */
-#define HAVE_KRB5_GET_ERROR_STRING 1
-/* Define to 1 if you have the `krb5_get_permitted_enctypes' function. */
-/* #undef HAVE_KRB5_GET_PERMITTED_ENCTYPES */
-/* Define to 1 if you have the `krb5_get_pw_salt' function. */
-#define HAVE_KRB5_GET_PW_SALT 1
-/* Define to 1 if you have the <krb5.h> header file. */
-#define HAVE_KRB5_H 1
-/* Define to 1 if you have the `krb5_initlog' function. */
-#define HAVE_KRB5_INITLOG 1
-/* Define to 1 if you have the `krb5_kdc_default_config' function. */
-#define HAVE_KRB5_KDC_DEFAULT_CONFIG 1
-/* Whether the krb5_creds struct has a keyblock property */
-/* #undef HAVE_KRB5_KEYBLOCK_IN_CREDS */
-/* Whether the krb5_keyblock struct has a keyvalue property */
-#define HAVE_KRB5_KEYBLOCK_KEYVALUE 1
-/* Whether krb5_keytab_entry has key member */
-/* #undef HAVE_KRB5_KEYTAB_ENTRY_KEY */
-/* Whether krb5_keytab_entry has keyblock member */
-#define HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK 1
-/* Define to 1 if you have the `krb5_krbhst_get_addrinfo' function. */
-#define HAVE_KRB5_KRBHST_GET_ADDRINFO 1
-/* Define to 1 if you have the `krb5_kt_compare' function. */
-#define HAVE_KRB5_KT_COMPARE 1
-/* Define to 1 if you have the `krb5_kt_free_entry' function. */
-#define HAVE_KRB5_KT_FREE_ENTRY 1
-/* Whether the type krb5_log_facility exists */
-#define HAVE_KRB5_LOG_FACILITY 1
-/* Define to 1 if you have the `krb5_mk_req_extended' function. */
-#define HAVE_KRB5_MK_REQ_EXTENDED 1
-/* Define to 1 if you have the `krb5_principal2salt' function. */
-/* #undef HAVE_KRB5_PRINCIPAL2SALT */
-/* Define to 1 if you have the `krb5_principal_get_comp_string' function. */
-#define HAVE_KRB5_PRINCIPAL_GET_COMP_STRING 1
-/* Whether krb5_princ_component is available */
-/* #undef HAVE_KRB5_PRINC_COMPONENT */
-/* Whether the krb5_creds struct has a session property */
-#define HAVE_KRB5_SESSION_IN_CREDS 1
-/* Define to 1 if you have the `krb5_set_default_in_tkt_etypes' function. */
-#define HAVE_KRB5_SET_DEFAULT_IN_TKT_ETYPES 1
-/* Define to 1 if you have the `krb5_set_default_tgs_ktypes' function. */
-/* #undef HAVE_KRB5_SET_DEFAULT_TGS_KTYPES */
-/* Define to 1 if you have the `krb5_set_real_time' function. */
-#define HAVE_KRB5_SET_REAL_TIME 1
-/* Define to 1 if you have the `krb5_set_warn_dest' function. */
-#define HAVE_KRB5_SET_WARN_DEST 1
-/* Define to 1 if you have the `krb5_string_to_key' function. */
-#define HAVE_KRB5_STRING_TO_KEY 1
-/* Define to 1 if you have the `krb5_string_to_key_salt' function. */
-#define HAVE_KRB5_STRING_TO_KEY_SALT 1
-/* Define to 1 if you have the `krb5_ticket_get_authorization_data_type' */
-#define HAVE_KRB5_TICKET_GET_AUTHORIZATION_DATA_TYPE 1
-/* Whether the krb5_ticket struct has a enc_part2 property */
-/* #undef HAVE_KRB5_TKT_ENC_PART2 */
-/* Define to 1 if you have the `krb5_use_enctype' function. */
-/* #undef HAVE_KRB5_USE_ENCTYPE */
-/* Define to 1 if you have the `krb5_verify_checksum' function. */
-#define HAVE_KRB5_VERIFY_CHECKSUM 1
-/* Whether krb5_princ_realm returns krb5_realm or krb5_data */
-#define KRB5_PRINC_REALM_RETURNS_REALM 1
-
-#include <krb5.h>
-#include <com_err.h>
-
-#endif
-
-#endif
diff --git a/source4/lib/replace/system/locale.h b/source4/lib/replace/system/locale.h
deleted file mode 100644
index e73a9bb274..0000000000
--- a/source4/lib/replace/system/locale.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef _system_locale_h
-#define _system_locale_h
-
-/*
- Unix SMB/CIFS implementation.
-
- locale include wrappers
-
- Copyright (C) Andrew Tridgell 2004
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifdef HAVE_CTYPE_H
-#include <ctype.h>
-#endif
-
-#ifdef HAVE_LOCALE_H
-#include <locale.h>
-#endif
-
-#endif
diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h
deleted file mode 100644
index 077892a54e..0000000000
--- a/source4/lib/replace/system/network.h
+++ /dev/null
@@ -1,332 +0,0 @@
-#ifndef _system_network_h
-#define _system_network_h
-/*
- Unix SMB/CIFS implementation.
-
- networking system include wrappers
-
- Copyright (C) Andrew Tridgell 2004
- Copyright (C) Jelmer Vernooij 2007
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef LIBREPLACE_NETWORK_CHECKS
-#error "AC_LIBREPLACE_NETWORK_CHECKS missing in configure"
-#endif
-
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#ifdef HAVE_UNIXSOCKET
-#include <sys/un.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-
-#ifdef HAVE_NETINET_TCP_H
-#include <netinet/tcp.h>
-#endif
-
-/*
- * The next three defines are needed to access the IPTOS_* options
- * on some systems.
- */
-
-#ifdef HAVE_NETINET_IN_SYSTM_H
-#include <netinet/in_systm.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_IP_H
-#include <netinet/in_ip.h>
-#endif
-
-#ifdef HAVE_NETINET_IP_H
-#include <netinet/ip.h>
-#endif
-
-#ifdef HAVE_NET_IF_H
-#include <net/if.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-
-#ifdef HAVE_STROPTS_H
-#include <stropts.h>
-#endif
-
-#ifndef HAVE_SOCKLEN_T
-#define HAVE_SOCKLEN_T
-typedef int socklen_t;
-#endif
-
-#if !defined (HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA)
-/* define is in "replace.h" */
-char *rep_inet_ntoa(struct in_addr ip);
-#endif
-
-#ifndef HAVE_INET_PTON
-/* define is in "replace.h" */
-int rep_inet_pton(int af, const char *src, void *dst);
-#endif
-
-#ifndef HAVE_INET_NTOP
-/* define is in "replace.h" */
-const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size);
-#endif
-
-#ifndef HAVE_INET_ATON
-/* define is in "replace.h" */
-int rep_inet_aton(const char *src, struct in_addr *dst);
-#endif
-
-#ifndef HAVE_CONNECT
-/* define is in "replace.h" */
-int rep_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
-#endif
-
-#ifndef HAVE_GETHOSTBYNAME
-/* define is in "replace.h" */
-struct hostent *rep_gethostbyname(const char *name);
-#endif
-
-#ifdef HAVE_IFADDRS_H
-#include <ifaddrs.h>
-#endif
-
-#ifndef HAVE_STRUCT_IFADDRS
-struct ifaddrs {
- struct ifaddrs *ifa_next; /* Pointer to next struct */
- char *ifa_name; /* Interface name */
- unsigned int ifa_flags; /* Interface flags */
- struct sockaddr *ifa_addr; /* Interface address */
- struct sockaddr *ifa_netmask; /* Interface netmask */
-#undef ifa_dstaddr
- struct sockaddr *ifa_dstaddr; /* P2P interface destination */
- void *ifa_data; /* Address specific data */
-};
-#endif
-
-#ifndef HAVE_GETIFADDRS
-int rep_getifaddrs(struct ifaddrs **);
-#endif
-
-#ifndef HAVE_FREEIFADDRS
-void rep_freeifaddrs(struct ifaddrs *);
-#endif
-
-#ifndef HAVE_SOCKETPAIR
-/* define is in "replace.h" */
-int rep_socketpair(int d, int type, int protocol, int sv[2]);
-#endif
-
-/*
- * Some systems have getaddrinfo but not the
- * defines needed to use it.
- */
-
-/* Various macros that ought to be in <netdb.h>, but might not be */
-
-#ifndef EAI_FAIL
-#define EAI_BADFLAGS (-1)
-#define EAI_NONAME (-2)
-#define EAI_AGAIN (-3)
-#define EAI_FAIL (-4)
-#define EAI_FAMILY (-6)
-#define EAI_SOCKTYPE (-7)
-#define EAI_SERVICE (-8)
-#define EAI_MEMORY (-10)
-#define EAI_SYSTEM (-11)
-#endif /* !EAI_FAIL */
-
-#ifndef AI_PASSIVE
-#define AI_PASSIVE 0x0001
-#endif
-
-#ifndef AI_CANONNAME
-#define AI_CANONNAME 0x0002
-#endif
-
-#ifndef AI_NUMERICHOST
-/*
- * some platforms don't support AI_NUMERICHOST; define as zero if using
- * the system version of getaddrinfo...
- */
-#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
-#define AI_NUMERICHOST 0
-#else
-#define AI_NUMERICHOST 0x0004
-#endif
-#endif
-
-#ifndef AI_ADDRCONFIG
-/*
- * logic copied from AI_NUMERICHOST
- */
-#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
-#define AI_ADDRCONFIG 0
-#else
-#define AI_ADDRCONFIG 0x0020
-#endif
-#endif
-
-#ifndef AI_NUMERICSERV
-/*
- * logic copied from AI_NUMERICHOST
- */
-#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
-#define AI_NUMERICSERV 0
-#else
-#define AI_NUMERICSERV 0x0400
-#endif
-#endif
-
-#ifndef NI_NUMERICHOST
-#define NI_NUMERICHOST 1
-#endif
-
-#ifndef NI_NUMERICSERV
-#define NI_NUMERICSERV 2
-#endif
-
-#ifndef NI_NOFQDN
-#define NI_NOFQDN 4
-#endif
-
-#ifndef NI_NAMEREQD
-#define NI_NAMEREQD 8
-#endif
-
-#ifndef NI_DGRAM
-#define NI_DGRAM 16
-#endif
-
-
-#ifndef NI_MAXHOST
-#define NI_MAXHOST 1025
-#endif
-
-#ifndef NI_MAXSERV
-#define NI_MAXSERV 32
-#endif
-
-/*
- * glibc on linux doesn't seem to have MSG_WAITALL
- * defined. I think the kernel has it though..
- */
-#ifndef MSG_WAITALL
-#define MSG_WAITALL 0
-#endif
-
-#ifndef INADDR_LOOPBACK
-#define INADDR_LOOPBACK 0x7f000001
-#endif
-
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff
-#endif
-
-#ifndef EAFNOSUPPORT
-#define EAFNOSUPPORT EINVAL
-#endif
-
-#ifndef INET_ADDRSTRLEN
-#define INET_ADDRSTRLEN 16
-#endif
-
-#ifndef INET6_ADDRSTRLEN
-#define INET6_ADDRSTRLEN 46
-#endif
-
-#ifndef HOST_NAME_MAX
-#define HOST_NAME_MAX 256
-#endif
-
-#ifndef HAVE_SA_FAMILY_T
-#define HAVE_SA_FAMILY_T
-typedef unsigned short int sa_family_t;
-#endif
-
-#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
-#define HAVE_STRUCT_SOCKADDR_STORAGE
-#ifdef HAVE_STRUCT_SOCKADDR_IN6
-#define sockaddr_storage sockaddr_in6
-#define ss_family sin6_family
-#define HAVE_SS_FAMILY 1
-#else
-#define sockaddr_storage sockaddr_in
-#define ss_family sin_family
-#define HAVE_SS_FAMILY 1
-#endif
-#endif
-
-#ifndef HAVE_SS_FAMILY
-#ifdef HAVE___SS_FAMILY
-#define ss_family __ss_family
-#define HAVE_SS_FAMILY 1
-#endif
-#endif
-
-#ifndef HAVE_STRUCT_ADDRINFO
-#define HAVE_STRUCT_ADDRINFO
-struct addrinfo {
- int ai_flags;
- int ai_family;
- int ai_socktype;
- int ai_protocol;
- socklen_t ai_addrlen;
- struct sockaddr *ai_addr;
- char *ai_canonname;
- struct addrinfo *ai_next;
-};
-#endif /* HAVE_STRUCT_ADDRINFO */
-
-#if !defined(HAVE_GETADDRINFO)
-#include "getaddrinfo.h"
-#endif
-
-/* Needed for some systems that don't define it (Solaris). */
-#ifndef ifr_netmask
-#define ifr_netmask ifr_addr
-#endif
-
-#ifdef SOCKET_WRAPPER
-#ifndef SOCKET_WRAPPER_NOT_REPLACE
-#define SOCKET_WRAPPER_REPLACE
-#endif
-#include "lib/socket_wrapper/socket_wrapper.h"
-#endif
-
-#endif
diff --git a/source4/lib/replace/system/passwd.h b/source4/lib/replace/system/passwd.h
deleted file mode 100644
index cad3197ccb..0000000000
--- a/source4/lib/replace/system/passwd.h
+++ /dev/null
@@ -1,110 +0,0 @@
-#ifndef _system_passwd_h
-#define _system_passwd_h
-
-/*
- Unix SMB/CIFS implementation.
-
- passwd system include wrappers
-
- Copyright (C) Andrew Tridgell 2004
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-/* this needs to be included before nss_wrapper.h on some systems */
-#include <unistd.h>
-
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif
-#ifdef HAVE_GRP_H
-#include <grp.h>
-#endif
-#ifdef HAVE_SYS_PRIV_H
-#include <sys/priv.h>
-#endif
-#ifdef HAVE_SYS_ID_H
-#include <sys/id.h>
-#endif
-
-#ifdef HAVE_CRYPT_H
-#include <crypt.h>
-#endif
-
-#ifdef HAVE_SHADOW_H
-#include <shadow.h>
-#endif
-
-#ifdef HAVE_SYS_SECURITY_H
-#include <sys/security.h>
-#include <prot.h>
-#define PASSWORD_LENGTH 16
-#endif /* HAVE_SYS_SECURITY_H */
-
-#ifdef HAVE_GETPWANAM
-#include <sys/label.h>
-#include <sys/audit.h>
-#include <pwdadj.h>
-#endif
-
-#ifdef HAVE_COMPAT_H
-#include <compat.h>
-#endif
-
-#ifdef REPLACE_GETPASS
-#if defined(REPLACE_GETPASS_BY_GETPASSPHRASE)
-#define getpass(prompt) getpassphrase(prompt)
-#else
-#define getpass(prompt) rep_getpass(prompt)
-char *rep_getpass(const char *prompt);
-#endif
-#endif
-
-#ifndef NGROUPS_MAX
-#define NGROUPS_MAX 32 /* Guess... */
-#endif
-
-/* what is the longest significant password available on your system?
- Knowing this speeds up password searches a lot */
-#ifndef PASSWORD_LENGTH
-#define PASSWORD_LENGTH 8
-#endif
-
-#if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
-#define OSF1_ENH_SEC 1
-#endif
-
-#ifndef ALLOW_CHANGE_PASSWORD
-#if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
-#define ALLOW_CHANGE_PASSWORD 1
-#endif
-#endif
-
-#if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
-#define ULTRIX_AUTH 1
-#endif
-
-#ifdef NSS_WRAPPER
-#ifndef NSS_WRAPPER_NOT_REPLACE
-#define NSS_WRAPPER_REPLACE
-#endif
-#include "lib/nss_wrapper/nss_wrapper.h"
-#endif
-
-#endif
diff --git a/source4/lib/replace/system/readline.h b/source4/lib/replace/system/readline.h
deleted file mode 100644
index ba34dc6a61..0000000000
--- a/source4/lib/replace/system/readline.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef _system_readline_h
-#define _system_readline_h
-/*
- Unix SMB/CIFS implementation.
-
- Readline wrappers
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifdef HAVE_LIBREADLINE
-# ifdef HAVE_READLINE_READLINE_H
-# include <readline/readline.h>
-# ifdef HAVE_READLINE_HISTORY_H
-# include <readline/history.h>
-# endif
-# else
-# ifdef HAVE_READLINE_H
-# include <readline.h>
-# ifdef HAVE_HISTORY_H
-# include <history.h>
-# endif
-# else
-# undef HAVE_LIBREADLINE
-# endif
-# endif
-#endif
-
-#ifdef HAVE_NEW_LIBREADLINE
-# define RL_COMPLETION_CAST (rl_completion_func_t *)
-#else
-/* This type is missing from libreadline<4.0 (approximately) */
-# define RL_COMPLETION_CAST
-#endif /* HAVE_NEW_LIBREADLINE */
-
-#endif
diff --git a/source4/lib/replace/system/select.h b/source4/lib/replace/system/select.h
deleted file mode 100644
index da18de0cfc..0000000000
--- a/source4/lib/replace/system/select.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef _system_select_h
-#define _system_select_h
-/*
- Unix SMB/CIFS implementation.
-
- select system include wrappers
-
- Copyright (C) Andrew Tridgell 2004
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-
-#ifdef HAVE_SYS_EPOLL_H
-#include <sys/epoll.h>
-#endif
-
-#ifndef SELECT_CAST
-#define SELECT_CAST
-#endif
-
-#endif
diff --git a/source4/lib/replace/system/shmem.h b/source4/lib/replace/system/shmem.h
deleted file mode 100644
index 64fe39b6cb..0000000000
--- a/source4/lib/replace/system/shmem.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef _system_shmem_h
-#define _system_shmem_h
-/*
- Unix SMB/CIFS implementation.
-
- shared memory system include wrappers
-
- Copyright (C) Andrew Tridgell 2004
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#if defined(HAVE_SYS_IPC_H)
-#include <sys/ipc.h>
-#endif /* HAVE_SYS_IPC_H */
-
-#if defined(HAVE_SYS_SHM_H)
-#include <sys/shm.h>
-#endif /* HAVE_SYS_SHM_H */
-
-#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-#endif
-
-/* NetBSD doesn't have these */
-#ifndef SHM_R
-#define SHM_R 0400
-#endif
-
-#ifndef SHM_W
-#define SHM_W 0200
-#endif
-
-
-#ifndef MAP_FILE
-#define MAP_FILE 0
-#endif
-
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *)-1)
-#endif
-
-#endif
diff --git a/source4/lib/replace/system/syslog.h b/source4/lib/replace/system/syslog.h
deleted file mode 100644
index 104be1df84..0000000000
--- a/source4/lib/replace/system/syslog.h
+++ /dev/null
@@ -1,70 +0,0 @@
-#ifndef _system_syslog_h
-#define _system_syslog_h
-/*
- Unix SMB/CIFS implementation.
-
- syslog system include wrappers
-
- Copyright (C) Andrew Tridgell 2004
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifdef HAVE_SYSLOG_H
-#include <syslog.h>
-#else
-#ifdef HAVE_SYS_SYSLOG_H
-#include <sys/syslog.h>
-#endif
-#endif
-
-/* For sys_adminlog(). */
-#ifndef LOG_EMERG
-#define LOG_EMERG 0 /* system is unusable */
-#endif
-
-#ifndef LOG_ALERT
-#define LOG_ALERT 1 /* action must be taken immediately */
-#endif
-
-#ifndef LOG_CRIT
-#define LOG_CRIT 2 /* critical conditions */
-#endif
-
-#ifndef LOG_ERR
-#define LOG_ERR 3 /* error conditions */
-#endif
-
-#ifndef LOG_WARNING
-#define LOG_WARNING 4 /* warning conditions */
-#endif
-
-#ifndef LOG_NOTICE
-#define LOG_NOTICE 5 /* normal but significant condition */
-#endif
-
-#ifndef LOG_INFO
-#define LOG_INFO 6 /* informational */
-#endif
-
-#ifndef LOG_DEBUG
-#define LOG_DEBUG 7 /* debug-level messages */
-#endif
-
-#endif
diff --git a/source4/lib/replace/system/terminal.h b/source4/lib/replace/system/terminal.h
deleted file mode 100644
index 9ad601ace0..0000000000
--- a/source4/lib/replace/system/terminal.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef _system_terminal_h
-#define _system_terminal_h
-/*
- Unix SMB/CIFS implementation.
-
- terminal system include wrappers
-
- Copyright (C) Andrew Tridgell 2004
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifdef SUNOS4
-/* on SUNOS4 termios.h conflicts with sys/ioctl.h */
-#undef HAVE_TERMIOS_H
-#endif
-
-
-#if defined(HAVE_TERMIOS_H)
-/* POSIX terminal handling. */
-#include <termios.h>
-#elif defined(HAVE_TERMIO_H)
-/* Older SYSV terminal handling - don't use if we can avoid it. */
-#include <termio.h>
-#elif defined(HAVE_SYS_TERMIO_H)
-/* Older SYSV terminal handling - don't use if we can avoid it. */
-#include <sys/termio.h>
-#endif
-
-#endif
diff --git a/source4/lib/replace/system/time.h b/source4/lib/replace/system/time.h
deleted file mode 100644
index 4abf295d1a..0000000000
--- a/source4/lib/replace/system/time.h
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef _system_time_h
-#define _system_time_h
-/*
- Unix SMB/CIFS implementation.
-
- time system include wrappers
-
- Copyright (C) Andrew Tridgell 2004
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifdef TIME_WITH_SYS_TIME
-#include <sys/time.h>
-#include <time.h>
-#else
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-#endif
-
-#ifdef HAVE_UTIME_H
-#include <utime.h>
-#else
-struct utimbuf {
- time_t actime; /* access time */
- time_t modtime; /* modification time */
-};
-#endif
-
-#ifndef HAVE_MKTIME
-/* define is in "replace.h" */
-time_t rep_mktime(struct tm *t);
-#endif
-
-#ifndef HAVE_TIMEGM
-/* define is in "replace.h" */
-time_t rep_timegm(struct tm *tm);
-#endif
-
-#ifndef HAVE_UTIME
-/* define is in "replace.h" */
-int rep_utime(const char *filename, const struct utimbuf *buf);
-#endif
-
-#ifndef HAVE_UTIMES
-/* define is in "replace.h" */
-int rep_utimes(const char *filename, const struct timeval tv[2]);
-#endif
-
-#endif
diff --git a/source4/lib/replace/system/wait.h b/source4/lib/replace/system/wait.h
deleted file mode 100644
index 5784b1ae92..0000000000
--- a/source4/lib/replace/system/wait.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef _system_wait_h
-#define _system_wait_h
-/*
- Unix SMB/CIFS implementation.
-
- waitpid system include wrappers
-
- Copyright (C) Andrew Tridgell 2004
-
- ** NOTE! The following LGPL license applies to the replace
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#include <signal.h>
-
-#ifndef SIGCLD
-#define SIGCLD SIGCHLD
-#endif
-
-#ifndef SIGNAL_CAST
-#define SIGNAL_CAST (RETSIGTYPE (*)(int))
-#endif
-
-#ifdef HAVE_SETJMP_H
-#include <setjmp.h>
-#endif
-
-#ifndef SA_RESETHAND
-#define SA_RESETHAND SA_ONESHOT
-#endif
-
-#if !defined(HAVE_SIG_ATOMIC_T_TYPE)
-typedef int sig_atomic_t;
-#endif
-
-#endif
diff --git a/source4/lib/replace/test/getifaddrs.c b/source4/lib/replace/test/getifaddrs.c
deleted file mode 100644
index 8b00ac2f40..0000000000
--- a/source4/lib/replace/test/getifaddrs.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- *
- * libreplace getifaddrs test
- *
- * Copyright (C) Michael Adam <obnox@samba.org> 2008
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef AUTOCONF_TEST
-#include "replace.h"
-#include "system/network.h"
-#endif
-
-#ifdef HAVE_INET_NTOP
-#define rep_inet_ntop inet_ntop
-#endif
-
-static const char *format_sockaddr(struct sockaddr *addr,
- char *addrstring,
- socklen_t addrlen)
-{
- const char *result = NULL;
-
- if (addr->sa_family == AF_INET) {
- result = rep_inet_ntop(AF_INET,
- &((struct sockaddr_in *)addr)->sin_addr,
- addrstring,
- addrlen);
-#ifdef HAVE_STRUCT_SOCKADDR_IN6
- } else if (addr->sa_family == AF_INET6) {
- result = rep_inet_ntop(AF_INET6,
- &((struct sockaddr_in6 *)addr)->sin6_addr,
- addrstring,
- addrlen);
-#endif
- }
- return result;
-}
-
-int getifaddrs_test(void)
-{
- struct ifaddrs *ifs = NULL;
- struct ifaddrs *ifs_head = NULL;
- int ret;
-
- ret = getifaddrs(&ifs);
- ifs_head = ifs;
- if (ret != 0) {
- fprintf(stderr, "getifaddrs() failed: %s\n", strerror(errno));
- return 1;
- }
-
- while (ifs) {
- printf("%-10s ", ifs->ifa_name);
- if (ifs->ifa_addr != NULL) {
- char addrstring[INET6_ADDRSTRLEN];
- const char *result;
-
- result = format_sockaddr(ifs->ifa_addr,
- addrstring,
- sizeof(addrstring));
- if (result != NULL) {
- printf("IP=%s ", addrstring);
- }
-
- if (ifs->ifa_netmask != NULL) {
- result = format_sockaddr(ifs->ifa_netmask,
- addrstring,
- sizeof(addrstring));
- if (result != NULL) {
- printf("NETMASK=%s", addrstring);
- }
- } else {
- printf("AF=%d ", ifs->ifa_addr->sa_family);
- }
- } else {
- printf("<no address>");
- }
-
- printf("\n");
- ifs = ifs->ifa_next;
- }
-
- freeifaddrs(ifs_head);
-
- return 0;
-}
diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c
deleted file mode 100644
index b45c135355..0000000000
--- a/source4/lib/replace/test/os2_delete.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- test readdir/unlink pattern that OS/2 uses
- tridge@samba.org July 2005
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <errno.h>
-#include <string.h>
-#include <fcntl.h>
-
-#define NUM_FILES 700
-#define READDIR_SIZE 100
-#define DELETE_SIZE 4
-
-#define TESTDIR "test.dir"
-
-static int test_readdir_os2_delete_ret;
-
-#define FAILED(d) (printf("failure: readdir [\nFailed for %s - %d = %s\n]\n", d, errno, strerror(errno)), test_readdir_os2_delete_ret = 1, 1)
-
-#ifndef MIN
-#define MIN(a,b) ((a)<(b)?(a):(b))
-#endif
-
-static void cleanup(void)
-{
- /* I'm a lazy bastard */
- system("rm -rf " TESTDIR);
- mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir");
-}
-
-static void create_files(void)
-{
- int i;
- for (i=0;i<NUM_FILES;i++) {
- char fname[40];
- int fd;
- sprintf(fname, TESTDIR "/test%u.txt", i);
- fd = open(fname, O_CREAT|O_RDWR, 0600);
- if (fd < 0) {
- FAILED("open");
- }
- if (close(fd) != 0) {
- FAILED("close");
- }
- }
-}
-
-static int os2_delete(DIR *d)
-{
- off_t offsets[READDIR_SIZE];
- int i, j;
- struct dirent *de;
- char names[READDIR_SIZE][30];
-
- /* scan, remembering offsets */
- for (i=0, de=readdir(d);
- de && i < READDIR_SIZE;
- de=readdir(d), i++) {
- offsets[i] = telldir(d);
- strcpy(names[i], de->d_name);
- }
-
- if (i == 0) {
- return 0;
- }
-
- /* delete the first few */
- for (j=0; j<MIN(i, DELETE_SIZE); j++) {
- char fname[40];
- sprintf(fname, TESTDIR "/%s", names[j]);
- unlink(fname) == 0 || FAILED("unlink");
- }
-
- /* seek to just after the deletion */
- seekdir(d, offsets[j-1]);
-
- /* return number deleted */
- return j;
-}
-
-int test_readdir_os2_delete(void)
-{
- int total_deleted = 0;
- DIR *d;
- struct dirent *de;
-
- test_readdir_os2_delete_ret = 0;
-
- cleanup();
- create_files();
-
- d = opendir(TESTDIR "/test0.txt");
- if (d != NULL) FAILED("opendir() on file succeed");
- if (errno != ENOTDIR) FAILED("opendir() on file didn't give ENOTDIR");
-
- d = opendir(TESTDIR);
-
- /* skip past . and .. */
- de = readdir(d);
- strcmp(de->d_name, ".") == 0 || FAILED("match .");
- de = readdir(d);
- strcmp(de->d_name, "..") == 0 || FAILED("match ..");
-
- while (1) {
- int n = os2_delete(d);
- if (n == 0) break;
- total_deleted += n;
- }
- closedir(d);
-
- fprintf(stderr, "Deleted %d files of %d\n", total_deleted, NUM_FILES);
-
- rmdir(TESTDIR) == 0 || FAILED("rmdir");
-
- system("rm -rf " TESTDIR);
-
- return test_readdir_os2_delete_ret;
-}
diff --git a/source4/lib/replace/test/shared_mmap.c b/source4/lib/replace/test/shared_mmap.c
deleted file mode 100644
index 50dad8d696..0000000000
--- a/source4/lib/replace/test/shared_mmap.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* this tests whether we can use a shared writeable mmap on a file -
- as needed for the mmap variant of FAST_SHARE_MODES */
-
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#define DATA "conftest.mmap"
-
-#ifndef MAP_FILE
-#define MAP_FILE 0
-#endif
-
-main()
-{
- int *buf;
- int i;
- int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666);
- int count=7;
-
- if (fd == -1) exit(1);
-
- for (i=0;i<10000;i++) {
- write(fd,&i,sizeof(i));
- }
-
- close(fd);
-
- if (fork() == 0) {
- fd = open(DATA,O_RDWR);
- if (fd == -1) exit(1);
-
- buf = (int *)mmap(NULL, 10000*sizeof(int),
- (PROT_READ | PROT_WRITE),
- MAP_FILE | MAP_SHARED,
- fd, 0);
-
- while (count-- && buf[9124] != 55732) sleep(1);
-
- if (count <= 0) exit(1);
-
- buf[1763] = 7268;
- exit(0);
- }
-
- fd = open(DATA,O_RDWR);
- if (fd == -1) exit(1);
-
- buf = (int *)mmap(NULL, 10000*sizeof(int),
- (PROT_READ | PROT_WRITE),
- MAP_FILE | MAP_SHARED,
- fd, 0);
-
- if (buf == (int *)-1) exit(1);
-
- buf[9124] = 55732;
-
- while (count-- && buf[1763] != 7268) sleep(1);
-
- unlink(DATA);
-
- if (count > 0) exit(0);
- exit(1);
-}
diff --git a/source4/lib/replace/test/strptime.c b/source4/lib/replace/test/strptime.c
deleted file mode 100644
index fade3ecc57..0000000000
--- a/source4/lib/replace/test/strptime.c
+++ /dev/null
@@ -1,172 +0,0 @@
-
-#ifdef LIBREPLACE_CONFIGURE_TEST_STRPTIME
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-
-#define true 1
-#define false 0
-
-#ifndef __STRING
-#define __STRING(x) #x
-#endif
-
-/* make printf a no-op */
-#define printf if(0) printf
-
-#else /* LIBREPLACE_CONFIGURE_TEST_STRPTIME */
-
-#include "replace.h"
-#include "system/time.h"
-
-#endif /* LIBREPLACE_CONFIGURE_TEST_STRPTIME */
-
-int libreplace_test_strptime(void)
-{
- const char *s = "20070414101546Z";
- char *ret;
- struct tm t, t2;
-
- memset(&t, 0, sizeof(t));
- memset(&t2, 0, sizeof(t2));
-
- printf("test: strptime\n");
-
- ret = strptime(s, "%Y%m%d%H%M%S", &t);
- if ( ret == NULL ) {
- printf("failure: strptime [\n"
- "returned NULL\n"
- "]\n");
- return false;
- }
-
- if ( *ret != 'Z' ) {
- printf("failure: strptime [\n"
- "ret doesn't point to 'Z'\n"
- "]\n");
- return false;
- }
-
- ret = strptime(s, "%Y%m%d%H%M%SZ", &t2);
- if ( ret == NULL ) {
- printf("failure: strptime [\n"
- "returned NULL with Z\n"
- "]\n");
- return false;
- }
-
- if ( *ret != '\0' ) {
- printf("failure: strptime [\n"
- "ret doesn't point to '\\0'\n"
- "]\n");
- return false;
- }
-
-#define CMP_TM_ELEMENT(t1,t2,elem) \
- if (t1.elem != t2.elem) { \
- printf("failure: strptime [\n" \
- "result differs if the format string has a 'Z' at the end\n" \
- "element: %s %d != %d\n" \
- "]\n", \
- __STRING(elen), t1.elem, t2.elem); \
- return false; \
- }
-
- CMP_TM_ELEMENT(t,t2,tm_sec);
- CMP_TM_ELEMENT(t,t2,tm_min);
- CMP_TM_ELEMENT(t,t2,tm_hour);
- CMP_TM_ELEMENT(t,t2,tm_mday);
- CMP_TM_ELEMENT(t,t2,tm_mon);
- CMP_TM_ELEMENT(t,t2,tm_year);
- CMP_TM_ELEMENT(t,t2,tm_wday);
- CMP_TM_ELEMENT(t,t2,tm_yday);
- CMP_TM_ELEMENT(t,t2,tm_isdst);
-
- if (t.tm_sec != 46) {
- printf("failure: strptime [\n"
- "tm_sec: expected: 46, got: %d\n"
- "]\n",
- t.tm_sec);
- return false;
- }
-
- if (t.tm_min != 15) {
- printf("failure: strptime [\n"
- "tm_min: expected: 15, got: %d\n"
- "]\n",
- t.tm_min);
- return false;
- }
-
- if (t.tm_hour != 10) {
- printf("failure: strptime [\n"
- "tm_hour: expected: 10, got: %d\n"
- "]\n",
- t.tm_hour);
- return false;
- }
-
- if (t.tm_mday != 14) {
- printf("failure: strptime [\n"
- "tm_mday: expected: 14, got: %d\n"
- "]\n",
- t.tm_mday);
- return false;
- }
-
- if (t.tm_mon != 3) {
- printf("failure: strptime [\n"
- "tm_mon: expected: 3, got: %d\n"
- "]\n",
- t.tm_mon);
- return false;
- }
-
- if (t.tm_year != 107) {
- printf("failure: strptime [\n"
- "tm_year: expected: 107, got: %d\n"
- "]\n",
- t.tm_year);
- return false;
- }
-
- if (t.tm_wday != 6) { /* saturday */
- printf("failure: strptime [\n"
- "tm_wday: expected: 6, got: %d\n"
- "]\n",
- t.tm_wday);
- return false;
- }
-
- if (t.tm_yday != 103) {
- printf("failure: strptime [\n"
- "tm_yday: expected: 103, got: %d\n"
- "]\n",
- t.tm_yday);
- return false;
- }
-
- /* we don't test this as it depends on the host configuration
- if (t.tm_isdst != 0) {
- printf("failure: strptime [\n"
- "tm_isdst: expected: 0, got: %d\n"
- "]\n",
- t.tm_isdst);
- return false;
- }*/
-
- printf("success: strptime\n");
-
- return true;
-}
-
-#ifdef LIBREPLACE_CONFIGURE_TEST_STRPTIME
-int main (void)
-{
- int ret;
- ret = libreplace_test_strptime();
- if (ret == false) return 1;
- return 0;
-}
-#endif
diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c
deleted file mode 100644
index 1e8290906e..0000000000
--- a/source4/lib/replace/test/testsuite.c
+++ /dev/null
@@ -1,1080 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- libreplace tests
-
- Copyright (C) Jelmer Vernooij 2006
-
- ** NOTE! The following LGPL license applies to the talloc
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "replace.h"
-
-/*
- we include all the system/ include files here so that libreplace tests
- them in the build farm
-*/
-#include "system/capability.h"
-#include "system/dir.h"
-#include "system/filesys.h"
-#include "system/glob.h"
-#include "system/iconv.h"
-#include "system/locale.h"
-#include "system/network.h"
-#include "system/passwd.h"
-#include "system/readline.h"
-#include "system/select.h"
-#include "system/shmem.h"
-#include "system/syslog.h"
-#include "system/terminal.h"
-#include "system/time.h"
-#include "system/wait.h"
-#include "system/aio.h"
-
-#define TESTFILE "testfile.dat"
-
-/*
- test ftruncate() function
- */
-static int test_ftruncate(void)
-{
- struct stat st;
- int fd;
- const int size = 1234;
- printf("test: ftruncate\n");
- unlink(TESTFILE);
- fd = open(TESTFILE, O_RDWR|O_CREAT, 0600);
- if (fd == -1) {
- printf("failure: ftruncate [\n"
- "creating '%s' failed - %s\n]\n", TESTFILE, strerror(errno));
- return false;
- }
- if (ftruncate(fd, size) != 0) {
- printf("failure: ftruncate [\n%s\n]\n", strerror(errno));
- return false;
- }
- if (fstat(fd, &st) != 0) {
- printf("failure: ftruncate [\nfstat failed - %s\n]\n", strerror(errno));
- return false;
- }
- if (st.st_size != size) {
- printf("failure: ftruncate [\ngave wrong size %d - expected %d\n]\n",
- (int)st.st_size, size);
- return false;
- }
- unlink(TESTFILE);
- printf("success: ftruncate\n");
- return true;
-}
-
-/*
- test strlcpy() function.
- see http://www.gratisoft.us/todd/papers/strlcpy.html
- */
-static int test_strlcpy(void)
-{
- char buf[4];
- const struct {
- const char *src;
- size_t result;
- } tests[] = {
- { "abc", 3 },
- { "abcdef", 6 },
- { "abcd", 4 },
- { "", 0 },
- { NULL, 0 }
- };
- int i;
- printf("test: strlcpy\n");
- for (i=0;tests[i].src;i++) {
- if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) {
- printf("failure: strlcpy [\ntest %d failed\n]\n", i);
- return false;
- }
- }
- printf("success: strlcpy\n");
- return true;
-}
-
-static int test_strlcat(void)
-{
- char tmp[10];
- printf("test: strlcat\n");
- strlcpy(tmp, "", sizeof(tmp));
- if (strlcat(tmp, "bla", 3) != 3) {
- printf("failure: strlcat [\ninvalid return code\n]\n");
- return false;
- }
- if (strcmp(tmp, "bl") != 0) {
- printf("failure: strlcat [\nexpected \"bl\", got \"%s\"\n]\n",
- tmp);
- return false;
- }
-
- strlcpy(tmp, "da", sizeof(tmp));
- if (strlcat(tmp, "me", 4) != 4) {
- printf("failure: strlcat [\nexpected \"dam\", got \"%s\"\n]\n",
- tmp);
- return false;
- }
-
- printf("success: strlcat\n");
- return true;
-}
-
-static int test_mktime(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_initgroups(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_memmove(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_strdup(void)
-{
- char *x;
- printf("test: strdup\n");
- x = strdup("bla");
- if (strcmp("bla", x) != 0) {
- printf("failure: strdup [\nfailed: expected \"bla\", got \"%s\"\n]\n",
- x);
- return false;
- }
- free(x);
- printf("success: strdup\n");
- return true;
-}
-
-static int test_setlinebuf(void)
-{
- printf("test: setlinebuf\n");
- setlinebuf(stdout);
- printf("success: setlinebuf\n");
- return true;
-}
-
-static int test_vsyslog(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_timegm(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_setenv(void)
-{
-#define TEST_SETENV(key, value, overwrite, result) do { \
- int _ret; \
- char *_v; \
- _ret = setenv(key, value, overwrite); \
- if (_ret != 0) { \
- printf("failure: setenv [\n" \
- "setenv(%s, %s, %d) failed\n" \
- "]\n", \
- key, value, overwrite); \
- return false; \
- } \
- _v=getenv(key); \
- if (!_v) { \
- printf("failure: setenv [\n" \
- "getenv(%s) returned NULL\n" \
- "]\n", \
- key); \
- return false; \
- } \
- if (strcmp(result, _v) != 0) { \
- printf("failure: setenv [\n" \
- "getenv(%s): '%s' != '%s'\n" \
- "]\n", \
- key, result, _v); \
- return false; \
- } \
-} while(0)
-
-#define TEST_UNSETENV(key) do { \
- char *_v; \
- unsetenv(key); \
- _v=getenv(key); \
- if (_v) { \
- printf("failure: setenv [\n" \
- "getenv(%s): NULL != '%s'\n" \
- "]\n", \
- SETENVTEST_KEY, _v); \
- return false; \
- } \
-} while (0)
-
-#define SETENVTEST_KEY "SETENVTESTKEY"
-#define SETENVTEST_VAL "SETENVTESTVAL"
-
- printf("test: setenv\n");
- TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"1", 0, SETENVTEST_VAL"1");
- TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"2", 0, SETENVTEST_VAL"1");
- TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"3", 1, SETENVTEST_VAL"3");
- TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"4", 1, SETENVTEST_VAL"4");
- TEST_UNSETENV(SETENVTEST_KEY);
- TEST_UNSETENV(SETENVTEST_KEY);
- TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"5", 0, SETENVTEST_VAL"5");
- TEST_UNSETENV(SETENVTEST_KEY);
- TEST_UNSETENV(SETENVTEST_KEY);
- printf("success: setenv\n");
- return true;
-}
-
-static int test_strndup(void)
-{
- char *x;
- printf("test: strndup\n");
- x = strndup("bla", 0);
- if (strcmp(x, "") != 0) {
- printf("failure: strndup [\ninvalid\n]\n");
- return false;
- }
- free(x);
- x = strndup("bla", 2);
- if (strcmp(x, "bl") != 0) {
- printf("failure: strndup [\ninvalid\n]\n");
- return false;
- }
- free(x);
- x = strndup("bla", 10);
- if (strcmp(x, "bla") != 0) {
- printf("failure: strndup [\ninvalid\n]\n");
- return false;
- }
- free(x);
- printf("success: strndup\n");
- return true;
-}
-
-static int test_strnlen(void)
-{
- printf("test: strnlen\n");
- if (strnlen("bla", 2) != 2) {
- printf("failure: strnlen [\nunexpected length\n]\n");
- return false;
- }
-
- if (strnlen("some text\n", 0) != 0) {
- printf("failure: strnlen [\nunexpected length\n]\n");
- return false;
- }
-
- if (strnlen("some text", 20) != 9) {
- printf("failure: strnlen [\nunexpected length\n]\n");
- return false;
- }
-
- printf("success: strnlen\n");
- return true;
-}
-
-static int test_waitpid(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_seteuid(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_setegid(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_asprintf(void)
-{
- char *x;
- printf("test: asprintf\n");
- if (asprintf(&x, "%d", 9) != 1) {
- printf("failure: asprintf [\ngenerate asprintf\n]\n");
- return false;
- }
- if (strcmp(x, "9") != 0) {
- printf("failure: asprintf [\ngenerate asprintf\n]\n");
- return false;
- }
- if (asprintf(&x, "dat%s", "a") != 4) {
- printf("failure: asprintf [\ngenerate asprintf\n]\n");
- return false;
- }
- if (strcmp(x, "data") != 0) {
- printf("failure: asprintf [\ngenerate asprintf\n]\n");
- return false;
- }
- printf("success: asprintf\n");
- return true;
-}
-
-static int test_snprintf(void)
-{
- char tmp[10];
- printf("test: snprintf\n");
- if (snprintf(tmp, 3, "foo%d", 9) != 4) {
- printf("failure: snprintf [\nsnprintf return code failed\n]\n");
- return false;
- }
-
- if (strcmp(tmp, "fo") != 0) {
- printf("failure: snprintf [\nsnprintf failed\n]\n");
- return false;
- }
-
- printf("success: snprintf\n");
- return true;
-}
-
-static int test_vasprintf(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_vsnprintf(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_opendir(void)
-{
- /* FIXME */
- return true;
-}
-
-extern int test_readdir_os2_delete(void);
-
-static int test_readdir(void)
-{
- printf("test: readdir\n");
- if (test_readdir_os2_delete() != 0) {
- return false;
- }
- printf("success: readdir\n");
- return true;
-}
-
-static int test_telldir(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_seekdir(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_dlopen(void)
-{
- /* FIXME: test dlopen, dlsym, dlclose, dlerror */
- return true;
-}
-
-
-static int test_chroot(void)
-{
- /* FIXME: chroot() */
- return true;
-}
-
-static int test_bzero(void)
-{
- /* FIXME: bzero */
- return true;
-}
-
-static int test_strerror(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_errno(void)
-{
- printf("test: errno\n");
- errno = 3;
- if (errno != 3) {
- printf("failure: errno [\nerrno failed\n]\n");
- return false;
- }
-
- printf("success: errno\n");
- return true;
-}
-
-static int test_mkdtemp(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_mkstemp(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_pread(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_pwrite(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_getpass(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_inet_ntoa(void)
-{
- /* FIXME */
- return true;
-}
-
-#define TEST_STRTO_X(type,fmt,func,str,base,res,diff,rrnoo) do {\
- type _v; \
- char _s[64]; \
- char *_p = NULL;\
- char *_ep = NULL; \
- strlcpy(_s, str, sizeof(_s));\
- if (diff >= 0) { \
- _ep = &_s[diff]; \
- } \
- errno = 0; \
- _v = func(_s, &_p, base); \
- if (errno != rrnoo) { \
- printf("failure: %s [\n" \
- "\t%s\n" \
- "\t%s(\"%s\",%d,%d): " fmt " (=/!)= " fmt "\n" \
- "\terrno: %d != %d\n" \
- "]\n", \
- __STRING(func), __location__, __STRING(func), \
- str, diff, base, res, _v, rrnoo, errno); \
- return false; \
- } else if (_v != res) { \
- printf("failure: %s [\n" \
- "\t%s\n" \
- "\t%s(\"%s\",%d,%d): " fmt " != " fmt "\n" \
- "]\n", \
- __STRING(func), __location__, __STRING(func), \
- str, diff, base, res, _v); \
- return false; \
- } else if (_p != _ep) { \
- printf("failure: %s [\n" \
- "\t%s\n" \
- "\t%s(\"%s\",%d,%d): " fmt " (=/!)= " fmt "\n" \
- "\tptr: %p - %p = %d != %d\n" \
- "]\n", \
- __STRING(func), __location__, __STRING(func), \
- str, diff, base, res, _v, _ep, _p, (int)(diff - (_ep - _p)), diff); \
- return false; \
- } \
-} while (0)
-
-static int test_strtoll(void)
-{
- printf("test: strtoll\n");
-
-#define TEST_STRTOLL(str,base,res,diff,errnoo) TEST_STRTO_X(long long int, "%lld", strtoll,str,base,res,diff,errnoo)
-
- TEST_STRTOLL("15", 10, 15LL, 2, 0);
- TEST_STRTOLL(" 15", 10, 15LL, 4, 0);
- TEST_STRTOLL("15", 0, 15LL, 2, 0);
- TEST_STRTOLL(" 15 ", 0, 15LL, 3, 0);
- TEST_STRTOLL("+15", 10, 15LL, 3, 0);
- TEST_STRTOLL(" +15", 10, 15LL, 5, 0);
- TEST_STRTOLL("+15", 0, 15LL, 3, 0);
- TEST_STRTOLL(" +15 ", 0, 15LL, 4, 0);
- TEST_STRTOLL("-15", 10, -15LL, 3, 0);
- TEST_STRTOLL(" -15", 10, -15LL, 5, 0);
- TEST_STRTOLL("-15", 0, -15LL, 3, 0);
- TEST_STRTOLL(" -15 ", 0, -15LL, 4, 0);
- TEST_STRTOLL("015", 10, 15LL, 3, 0);
- TEST_STRTOLL(" 015", 10, 15LL, 5, 0);
- TEST_STRTOLL("015", 0, 13LL, 3, 0);
- TEST_STRTOLL(" 015", 0, 13LL, 5, 0);
- TEST_STRTOLL("0x15", 10, 0LL, 1, 0);
- TEST_STRTOLL(" 0x15", 10, 0LL, 3, 0);
- TEST_STRTOLL("0x15", 0, 21LL, 4, 0);
- TEST_STRTOLL(" 0x15", 0, 21LL, 6, 0);
-
- TEST_STRTOLL("10", 16, 16LL, 2, 0);
- TEST_STRTOLL(" 10 ", 16, 16LL, 4, 0);
- TEST_STRTOLL("0x10", 16, 16LL, 4, 0);
- TEST_STRTOLL("0x10", 0, 16LL, 4, 0);
- TEST_STRTOLL(" 0x10 ", 0, 16LL, 5, 0);
- TEST_STRTOLL("+10", 16, 16LL, 3, 0);
- TEST_STRTOLL(" +10 ", 16, 16LL, 5, 0);
- TEST_STRTOLL("+0x10", 16, 16LL, 5, 0);
- TEST_STRTOLL("+0x10", 0, 16LL, 5, 0);
- TEST_STRTOLL(" +0x10 ", 0, 16LL, 6, 0);
- TEST_STRTOLL("-10", 16, -16LL, 3, 0);
- TEST_STRTOLL(" -10 ", 16, -16LL, 5, 0);
- TEST_STRTOLL("-0x10", 16, -16LL, 5, 0);
- TEST_STRTOLL("-0x10", 0, -16LL, 5, 0);
- TEST_STRTOLL(" -0x10 ", 0, -16LL, 6, 0);
- TEST_STRTOLL("010", 16, 16LL, 3, 0);
- TEST_STRTOLL(" 010 ", 16, 16LL, 5, 0);
- TEST_STRTOLL("-010", 16, -16LL, 4, 0);
-
- TEST_STRTOLL("11", 8, 9LL, 2, 0);
- TEST_STRTOLL("011", 8, 9LL, 3, 0);
- TEST_STRTOLL("011", 0, 9LL, 3, 0);
- TEST_STRTOLL("-11", 8, -9LL, 3, 0);
- TEST_STRTOLL("-011", 8, -9LL, 4, 0);
- TEST_STRTOLL("-011", 0, -9LL, 4, 0);
-
- TEST_STRTOLL("011", 8, 9LL, 3, 0);
- TEST_STRTOLL("011", 0, 9LL, 3, 0);
- TEST_STRTOLL("-11", 8, -9LL, 3, 0);
- TEST_STRTOLL("-011", 8, -9LL, 4, 0);
- TEST_STRTOLL("-011", 0, -9LL, 4, 0);
-
- TEST_STRTOLL("Text", 0, 0LL, 0, 0);
-
- TEST_STRTOLL("9223372036854775807", 10, 9223372036854775807LL, 19, 0);
- TEST_STRTOLL("9223372036854775807", 0, 9223372036854775807LL, 19, 0);
- TEST_STRTOLL("9223372036854775808", 0, 9223372036854775807LL, 19, ERANGE);
- TEST_STRTOLL("9223372036854775808", 10, 9223372036854775807LL, 19, ERANGE);
- TEST_STRTOLL("0x7FFFFFFFFFFFFFFF", 0, 9223372036854775807LL, 18, 0);
- TEST_STRTOLL("0x7FFFFFFFFFFFFFFF", 16, 9223372036854775807LL, 18, 0);
- TEST_STRTOLL("7FFFFFFFFFFFFFFF", 16, 9223372036854775807LL, 16, 0);
- TEST_STRTOLL("0x8000000000000000", 0, 9223372036854775807LL, 18, ERANGE);
- TEST_STRTOLL("0x8000000000000000", 16, 9223372036854775807LL, 18, ERANGE);
- TEST_STRTOLL("80000000000000000", 16, 9223372036854775807LL, 17, ERANGE);
- TEST_STRTOLL("0777777777777777777777", 0, 9223372036854775807LL, 22, 0);
- TEST_STRTOLL("0777777777777777777777", 8, 9223372036854775807LL, 22, 0);
- TEST_STRTOLL("777777777777777777777", 8, 9223372036854775807LL, 21, 0);
- TEST_STRTOLL("01000000000000000000000", 0, 9223372036854775807LL, 23, ERANGE);
- TEST_STRTOLL("01000000000000000000000", 8, 9223372036854775807LL, 23, ERANGE);
- TEST_STRTOLL("1000000000000000000000", 8, 9223372036854775807LL, 22, ERANGE);
-
- TEST_STRTOLL("-9223372036854775808", 10, -9223372036854775807LL -1, 20, 0);
- TEST_STRTOLL("-9223372036854775808", 0, -9223372036854775807LL -1, 20, 0);
- TEST_STRTOLL("-9223372036854775809", 0, -9223372036854775807LL -1, 20, ERANGE);
- TEST_STRTOLL("-9223372036854775809", 10, -9223372036854775807LL -1, 20, ERANGE);
- TEST_STRTOLL("-0x8000000000000000", 0, -9223372036854775807LL -1, 19, 0);
- TEST_STRTOLL("-0x8000000000000000", 16, -9223372036854775807LL -1, 19, 0);
- TEST_STRTOLL("-8000000000000000", 16, -9223372036854775807LL -1, 17, 0);
- TEST_STRTOLL("-0x8000000000000001", 0, -9223372036854775807LL -1, 19, ERANGE);
- TEST_STRTOLL("-0x8000000000000001", 16, -9223372036854775807LL -1, 19, ERANGE);
- TEST_STRTOLL("-80000000000000001", 16, -9223372036854775807LL -1, 18, ERANGE);
- TEST_STRTOLL("-01000000000000000000000",0, -9223372036854775807LL -1, 24, 0);
- TEST_STRTOLL("-01000000000000000000000",8, -9223372036854775807LL -1, 24, 0);
- TEST_STRTOLL("-1000000000000000000000", 8, -9223372036854775807LL -1, 23, 0);
- TEST_STRTOLL("-01000000000000000000001",0, -9223372036854775807LL -1, 24, ERANGE);
- TEST_STRTOLL("-01000000000000000000001",8, -9223372036854775807LL -1, 24, ERANGE);
- TEST_STRTOLL("-1000000000000000000001", 8, -9223372036854775807LL -1, 23, ERANGE);
-
- printf("success: strtoll\n");
- return true;
-}
-
-static int test_strtoull(void)
-{
- printf("test: strtoull\n");
-
-#define TEST_STRTOULL(str,base,res,diff,errnoo) TEST_STRTO_X(long long unsigned int,"%llu",strtoull,str,base,res,diff,errnoo)
-
- TEST_STRTOULL("15", 10, 15LLU, 2, 0);
- TEST_STRTOULL(" 15", 10, 15LLU, 4, 0);
- TEST_STRTOULL("15", 0, 15LLU, 2, 0);
- TEST_STRTOULL(" 15 ", 0, 15LLU, 3, 0);
- TEST_STRTOULL("+15", 10, 15LLU, 3, 0);
- TEST_STRTOULL(" +15", 10, 15LLU, 5, 0);
- TEST_STRTOULL("+15", 0, 15LLU, 3, 0);
- TEST_STRTOULL(" +15 ", 0, 15LLU, 4, 0);
- TEST_STRTOULL("-15", 10, 18446744073709551601LLU, 3, 0);
- TEST_STRTOULL(" -15", 10, 18446744073709551601LLU, 5, 0);
- TEST_STRTOULL("-15", 0, 18446744073709551601LLU, 3, 0);
- TEST_STRTOULL(" -15 ", 0, 18446744073709551601LLU, 4, 0);
- TEST_STRTOULL("015", 10, 15LLU, 3, 0);
- TEST_STRTOULL(" 015", 10, 15LLU, 5, 0);
- TEST_STRTOULL("015", 0, 13LLU, 3, 0);
- TEST_STRTOULL(" 015", 0, 13LLU, 5, 0);
- TEST_STRTOULL("0x15", 10, 0LLU, 1, 0);
- TEST_STRTOULL(" 0x15", 10, 0LLU, 3, 0);
- TEST_STRTOULL("0x15", 0, 21LLU, 4, 0);
- TEST_STRTOULL(" 0x15", 0, 21LLU, 6, 0);
-
- TEST_STRTOULL("10", 16, 16LLU, 2, 0);
- TEST_STRTOULL(" 10 ", 16, 16LLU, 4, 0);
- TEST_STRTOULL("0x10", 16, 16LLU, 4, 0);
- TEST_STRTOULL("0x10", 0, 16LLU, 4, 0);
- TEST_STRTOULL(" 0x10 ", 0, 16LLU, 5, 0);
- TEST_STRTOULL("+10", 16, 16LLU, 3, 0);
- TEST_STRTOULL(" +10 ", 16, 16LLU, 5, 0);
- TEST_STRTOULL("+0x10", 16, 16LLU, 5, 0);
- TEST_STRTOULL("+0x10", 0, 16LLU, 5, 0);
- TEST_STRTOULL(" +0x10 ", 0, 16LLU, 6, 0);
- TEST_STRTOULL("-10", 16, -16LLU, 3, 0);
- TEST_STRTOULL(" -10 ", 16, -16LLU, 5, 0);
- TEST_STRTOULL("-0x10", 16, -16LLU, 5, 0);
- TEST_STRTOULL("-0x10", 0, -16LLU, 5, 0);
- TEST_STRTOULL(" -0x10 ", 0, -16LLU, 6, 0);
- TEST_STRTOULL("010", 16, 16LLU, 3, 0);
- TEST_STRTOULL(" 010 ", 16, 16LLU, 5, 0);
- TEST_STRTOULL("-010", 16, -16LLU, 4, 0);
-
- TEST_STRTOULL("11", 8, 9LLU, 2, 0);
- TEST_STRTOULL("011", 8, 9LLU, 3, 0);
- TEST_STRTOULL("011", 0, 9LLU, 3, 0);
- TEST_STRTOULL("-11", 8, -9LLU, 3, 0);
- TEST_STRTOULL("-011", 8, -9LLU, 4, 0);
- TEST_STRTOULL("-011", 0, -9LLU, 4, 0);
-
- TEST_STRTOULL("011", 8, 9LLU, 3, 0);
- TEST_STRTOULL("011", 0, 9LLU, 3, 0);
- TEST_STRTOULL("-11", 8, -9LLU, 3, 0);
- TEST_STRTOULL("-011", 8, -9LLU, 4, 0);
- TEST_STRTOULL("-011", 0, -9LLU, 4, 0);
-
- TEST_STRTOULL("Text", 0, 0LLU, 0, 0);
-
- TEST_STRTOULL("9223372036854775807", 10, 9223372036854775807LLU, 19, 0);
- TEST_STRTOULL("9223372036854775807", 0, 9223372036854775807LLU, 19, 0);
- TEST_STRTOULL("9223372036854775808", 0, 9223372036854775808LLU, 19, 0);
- TEST_STRTOULL("9223372036854775808", 10, 9223372036854775808LLU, 19, 0);
- TEST_STRTOULL("0x7FFFFFFFFFFFFFFF", 0, 9223372036854775807LLU, 18, 0);
- TEST_STRTOULL("0x7FFFFFFFFFFFFFFF", 16, 9223372036854775807LLU, 18, 0);
- TEST_STRTOULL("7FFFFFFFFFFFFFFF", 16, 9223372036854775807LLU, 16, 0);
- TEST_STRTOULL("0x8000000000000000", 0, 9223372036854775808LLU, 18, 0);
- TEST_STRTOULL("0x8000000000000000", 16, 9223372036854775808LLU, 18, 0);
- TEST_STRTOULL("8000000000000000", 16, 9223372036854775808LLU, 16, 0);
- TEST_STRTOULL("0777777777777777777777", 0, 9223372036854775807LLU, 22, 0);
- TEST_STRTOULL("0777777777777777777777", 8, 9223372036854775807LLU, 22, 0);
- TEST_STRTOULL("777777777777777777777", 8, 9223372036854775807LLU, 21, 0);
- TEST_STRTOULL("01000000000000000000000",0, 9223372036854775808LLU, 23, 0);
- TEST_STRTOULL("01000000000000000000000",8, 9223372036854775808LLU, 23, 0);
- TEST_STRTOULL("1000000000000000000000", 8, 9223372036854775808LLU, 22, 0);
-
- TEST_STRTOULL("-9223372036854775808", 10, 9223372036854775808LLU, 20, 0);
- TEST_STRTOULL("-9223372036854775808", 0, 9223372036854775808LLU, 20, 0);
- TEST_STRTOULL("-9223372036854775809", 0, 9223372036854775807LLU, 20, 0);
- TEST_STRTOULL("-9223372036854775809", 10, 9223372036854775807LLU, 20, 0);
- TEST_STRTOULL("-0x8000000000000000", 0, 9223372036854775808LLU, 19, 0);
- TEST_STRTOULL("-0x8000000000000000", 16, 9223372036854775808LLU, 19, 0);
- TEST_STRTOULL("-8000000000000000", 16, 9223372036854775808LLU, 17, 0);
- TEST_STRTOULL("-0x8000000000000001", 0, 9223372036854775807LLU, 19, 0);
- TEST_STRTOULL("-0x8000000000000001", 16, 9223372036854775807LLU, 19, 0);
- TEST_STRTOULL("-8000000000000001", 16, 9223372036854775807LLU, 17, 0);
- TEST_STRTOULL("-01000000000000000000000",0, 9223372036854775808LLU, 24, 0);
- TEST_STRTOULL("-01000000000000000000000",8, 9223372036854775808LLU, 24, 0);
- TEST_STRTOULL("-1000000000000000000000",8, 9223372036854775808LLU, 23, 0);
- TEST_STRTOULL("-01000000000000000000001",0, 9223372036854775807LLU, 24, 0);
- TEST_STRTOULL("-01000000000000000000001",8, 9223372036854775807LLU, 24, 0);
- TEST_STRTOULL("-1000000000000000000001",8, 9223372036854775807LLU, 23, 0);
-
- TEST_STRTOULL("18446744073709551615", 0, 18446744073709551615LLU, 20, 0);
- TEST_STRTOULL("18446744073709551615", 10, 18446744073709551615LLU, 20, 0);
- TEST_STRTOULL("18446744073709551616", 0, 18446744073709551615LLU, 20, ERANGE);
- TEST_STRTOULL("18446744073709551616", 10, 18446744073709551615LLU, 20, ERANGE);
- TEST_STRTOULL("0xFFFFFFFFFFFFFFFF", 0, 18446744073709551615LLU, 18, 0);
- TEST_STRTOULL("0xFFFFFFFFFFFFFFFF", 16, 18446744073709551615LLU, 18, 0);
- TEST_STRTOULL("FFFFFFFFFFFFFFFF", 16, 18446744073709551615LLU, 16, 0);
- TEST_STRTOULL("0x10000000000000000", 0, 18446744073709551615LLU, 19, ERANGE);
- TEST_STRTOULL("0x10000000000000000", 16, 18446744073709551615LLU, 19, ERANGE);
- TEST_STRTOULL("10000000000000000", 16, 18446744073709551615LLU, 17, ERANGE);
- TEST_STRTOULL("01777777777777777777777",0, 18446744073709551615LLU, 23, 0);
- TEST_STRTOULL("01777777777777777777777",8, 18446744073709551615LLU, 23, 0);
- TEST_STRTOULL("1777777777777777777777", 8, 18446744073709551615LLU, 22, 0);
- TEST_STRTOULL("02000000000000000000000",0, 18446744073709551615LLU, 23, ERANGE);
- TEST_STRTOULL("02000000000000000000000",8, 18446744073709551615LLU, 23, ERANGE);
- TEST_STRTOULL("2000000000000000000000", 8, 18446744073709551615LLU, 22, ERANGE);
-
- TEST_STRTOULL("-18446744073709551615", 0, 1LLU, 21, 0);
- TEST_STRTOULL("-18446744073709551615", 10, 1LLU, 21, 0);
- TEST_STRTOULL("-18446744073709551616", 0, 18446744073709551615LLU, 21, ERANGE);
- TEST_STRTOULL("-18446744073709551616", 10, 18446744073709551615LLU, 21, ERANGE);
- TEST_STRTOULL("-0xFFFFFFFFFFFFFFFF", 0, 1LLU, 19, 0);
- TEST_STRTOULL("-0xFFFFFFFFFFFFFFFF", 16, 1LLU, 19, 0);
- TEST_STRTOULL("-FFFFFFFFFFFFFFFF", 16, 1LLU, 17, 0);
- TEST_STRTOULL("-0x10000000000000000", 0, 18446744073709551615LLU, 20, ERANGE);
- TEST_STRTOULL("-0x10000000000000000", 16, 18446744073709551615LLU, 20, ERANGE);
- TEST_STRTOULL("-10000000000000000", 16, 18446744073709551615LLU, 18, ERANGE);
- TEST_STRTOULL("-01777777777777777777777",0, 1LLU, 24, 0);
- TEST_STRTOULL("-01777777777777777777777",8, 1LLU, 24, 0);
- TEST_STRTOULL("-1777777777777777777777",8, 1LLU, 23, 0);
- TEST_STRTOULL("-02000000000000000000000",0, 18446744073709551615LLU, 24, ERANGE);
- TEST_STRTOULL("-02000000000000000000000",8, 18446744073709551615LLU, 24, ERANGE);
- TEST_STRTOULL("-2000000000000000000000",8, 18446744073709551615LLU, 23, ERANGE);
-
- printf("success: strtoull\n");
- return true;
-}
-
-/*
-FIXME:
-Types:
-bool
-socklen_t
-uint_t
-uint{8,16,32,64}_t
-int{8,16,32,64}_t
-intptr_t
-
-Constants:
-PATH_NAME_MAX
-UINT{16,32,64}_MAX
-INT32_MAX
-*/
-
-static int test_va_copy(void)
-{
- /* FIXME */
- return true;
-}
-
-static int test_FUNCTION(void)
-{
- printf("test: FUNCTION\n");
- if (strcmp(__FUNCTION__, "test_FUNCTION") != 0) {
- printf("failure: FAILURE [\nFAILURE invalid\n]\n");
- return false;
- }
- printf("success: FUNCTION\n");
- return true;
-}
-
-static int test_MIN(void)
-{
- printf("test: MIN\n");
- if (MIN(20, 1) != 1) {
- printf("failure: MIN [\nMIN invalid\n]\n");
- return false;
- }
- if (MIN(1, 20) != 1) {
- printf("failure: MIN [\nMIN invalid\n]\n");
- return false;
- }
- printf("success: MIN\n");
- return true;
-}
-
-static int test_MAX(void)
-{
- printf("test: MAX\n");
- if (MAX(20, 1) != 20) {
- printf("failure: MAX [\nMAX invalid\n]\n");
- return false;
- }
- if (MAX(1, 20) != 20) {
- printf("failure: MAX [\nMAX invalid\n]\n");
- return false;
- }
- printf("success: MAX\n");
- return true;
-}
-
-static int test_socketpair(void)
-{
- int sock[2];
- char buf[20];
-
- printf("test: socketpair\n");
-
- if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock) == -1) {
- printf("failure: socketpair [\n"
- "socketpair() failed\n"
- "]\n");
- return false;
- }
-
- if (write(sock[1], "automatisch", 12) == -1) {
- printf("failure: socketpair [\n"
- "write() failed: %s\n"
- "]\n", strerror(errno));
- return false;
- }
-
- if (read(sock[0], buf, 12) == -1) {
- printf("failure: socketpair [\n"
- "read() failed: %s\n"
- "]\n", strerror(errno));
- return false;
- }
-
- if (strcmp(buf, "automatisch") != 0) {
- printf("failure: socketpair [\n"
- "expected: automatisch, got: %s\n"
- "]\n", buf);
- return false;
- }
-
- printf("success: socketpair\n");
-
- return true;
-}
-
-extern int libreplace_test_strptime(void);
-
-static int test_strptime(void)
-{
- return libreplace_test_strptime();
-}
-
-extern int getifaddrs_test(void);
-
-static int test_getifaddrs(void)
-{
-
- printf("test: getifaddrs\n");
-
- if (getifaddrs_test() != 0) {
- printf("failure: getifaddrs\n");
- return false;
- }
-
- printf("success: getifaddrs\n");
- return true;
-}
-
-static int test_utime(void)
-{
- struct utimbuf u;
- struct stat st1, st2, st3;
- int fd;
-
- printf("test: utime\n");
- unlink(TESTFILE);
-
- fd = open(TESTFILE, O_RDWR|O_CREAT, 0600);
- if (fd == -1) {
- printf("failure: utime [\n"
- "creating '%s' failed - %s\n]\n",
- TESTFILE, strerror(errno));
- return false;
- }
-
- if (fstat(fd, &st1) != 0) {
- printf("failure: utime [\n"
- "fstat (1) failed - %s\n]\n",
- strerror(errno));
- return false;
- }
-
- u.actime = st1.st_atime + 300;
- u.modtime = st1.st_mtime - 300;
- if (utime(TESTFILE, &u) != 0) {
- printf("failure: utime [\n"
- "utime(&u) failed - %s\n]\n",
- strerror(errno));
- return false;
- }
-
- if (fstat(fd, &st2) != 0) {
- printf("failure: utime [\n"
- "fstat (2) failed - %s\n]\n",
- strerror(errno));
- return false;
- }
-
- if (utime(TESTFILE, NULL) != 0) {
- printf("failure: utime [\n"
- "utime(NULL) failed - %s\n]\n",
- strerror(errno));
- return false;
- }
-
- if (fstat(fd, &st3) != 0) {
- printf("failure: utime [\n"
- "fstat (3) failed - %s\n]\n",
- strerror(errno));
- return false;
- }
-
-#define CMP_VAL(a,c,b) do { \
- if (a c b) { \
- printf("failure: utime [\n" \
- "%s: %s(%d) %s %s(%d)\n]\n", \
- __location__, \
- #a, (int)a, #c, #b, (int)b); \
- return false; \
- } \
-} while(0)
-#define EQUAL_VAL(a,b) CMP_VAL(a,!=,b)
-#define GREATER_VAL(a,b) CMP_VAL(a,<=,b)
-#define LESSER_VAL(a,b) CMP_VAL(a,>=,b)
-
- EQUAL_VAL(st2.st_atime, st1.st_atime + 300);
- EQUAL_VAL(st2.st_mtime, st1.st_mtime - 300);
- LESSER_VAL(st3.st_atime, st2.st_atime);
- GREATER_VAL(st3.st_mtime, st2.st_mtime);
-
-#undef CMP_VAL
-#undef EQUAL_VAL
-#undef GREATER_VAL
-#undef LESSER_VAL
-
- unlink(TESTFILE);
- printf("success: utime\n");
- return true;
-}
-
-static int test_utimes(void)
-{
- struct timeval tv[2];
- struct stat st1, st2;
- int fd;
-
- printf("test: utimes\n");
- unlink(TESTFILE);
-
- fd = open(TESTFILE, O_RDWR|O_CREAT, 0600);
- if (fd == -1) {
- printf("failure: utimes [\n"
- "creating '%s' failed - %s\n]\n",
- TESTFILE, strerror(errno));
- return false;
- }
-
- if (fstat(fd, &st1) != 0) {
- printf("failure: utimes [\n"
- "fstat (1) failed - %s\n]\n",
- strerror(errno));
- return false;
- }
-
- ZERO_STRUCT(tv);
- tv[0].tv_sec = st1.st_atime + 300;
- tv[1].tv_sec = st1.st_mtime - 300;
- if (utimes(TESTFILE, tv) != 0) {
- printf("failure: utimes [\n"
- "utimes(tv) failed - %s\n]\n",
- strerror(errno));
- return false;
- }
-
- if (fstat(fd, &st2) != 0) {
- printf("failure: utimes [\n"
- "fstat (2) failed - %s\n]\n",
- strerror(errno));
- return false;
- }
-
-#define EQUAL_VAL(a,b) do { \
- if (a != b) { \
- printf("failure: utimes [\n" \
- "%s: %s(%d) != %s(%d)\n]\n", \
- __location__, \
- #a, (int)a, #b, (int)b); \
- return false; \
- } \
-} while(0)
-
- EQUAL_VAL(st2.st_atime, st1.st_atime + 300);
- EQUAL_VAL(st2.st_mtime, st1.st_mtime - 300);
-
-#undef EQUAL_VAL
-
- unlink(TESTFILE);
- printf("success: utimes\n");
- return true;
-}
-
-struct torture_context;
-bool torture_local_replace(struct torture_context *ctx)
-{
- bool ret = true;
- ret &= test_ftruncate();
- ret &= test_strlcpy();
- ret &= test_strlcat();
- ret &= test_mktime();
- ret &= test_initgroups();
- ret &= test_memmove();
- ret &= test_strdup();
- ret &= test_setlinebuf();
- ret &= test_vsyslog();
- ret &= test_timegm();
- ret &= test_setenv();
- ret &= test_strndup();
- ret &= test_strnlen();
- ret &= test_waitpid();
- ret &= test_seteuid();
- ret &= test_setegid();
- ret &= test_asprintf();
- ret &= test_snprintf();
- ret &= test_vasprintf();
- ret &= test_vsnprintf();
- ret &= test_opendir();
- ret &= test_readdir();
- ret &= test_telldir();
- ret &= test_seekdir();
- ret &= test_dlopen();
- ret &= test_chroot();
- ret &= test_bzero();
- ret &= test_strerror();
- ret &= test_errno();
- ret &= test_mkdtemp();
- ret &= test_mkstemp();
- ret &= test_pread();
- ret &= test_pwrite();
- ret &= test_getpass();
- ret &= test_inet_ntoa();
- ret &= test_strtoll();
- ret &= test_strtoull();
- ret &= test_va_copy();
- ret &= test_FUNCTION();
- ret &= test_MIN();
- ret &= test_MAX();
- ret &= test_socketpair();
- ret &= test_strptime();
- ret &= test_getifaddrs();
- ret &= test_utime();
- ret &= test_utimes();
-
- return ret;
-}
-
-#if _SAMBA_BUILD_<4
-int main(void)
-{
- bool ret = torture_local_replace(NULL);
- if (ret)
- return 0;
- return -1;
-}
-#endif
diff --git a/source4/lib/replace/timegm.c b/source4/lib/replace/timegm.c
deleted file mode 100644
index 395c684e11..0000000000
--- a/source4/lib/replace/timegm.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 1997 Kungliga Tekniska Högskolan
- * (Royal Institute of Technology, Stockholm, Sweden).
- * 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. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``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 INSTITUTE OR CONTRIBUTORS 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.
- */
-
-/*
- adapted for Samba4 by Andrew Tridgell
-*/
-
-#include "replace.h"
-#include "system/time.h"
-
-static int is_leap(unsigned y)
-{
- y += 1900;
- return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0);
-}
-
-time_t rep_timegm(struct tm *tm)
-{
- static const unsigned ndays[2][12] ={
- {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
- {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
- time_t res = 0;
- unsigned i;
-
- if (tm->tm_mon > 12 ||
- tm->tm_mon < 0 ||
- tm->tm_mday > 31 ||
- tm->tm_min > 60 ||
- tm->tm_sec > 60 ||
- tm->tm_hour > 24) {
- /* invalid tm structure */
- return 0;
- }
-
- for (i = 70; i < tm->tm_year; ++i)
- res += is_leap(i) ? 366 : 365;
-
- for (i = 0; i < tm->tm_mon; ++i)
- res += ndays[is_leap(tm->tm_year)][i];
- res += tm->tm_mday - 1;
- res *= 24;
- res += tm->tm_hour;
- res *= 60;
- res += tm->tm_min;
- res *= 60;
- res += tm->tm_sec;
- return res;
-}
diff --git a/source4/lib/replace/timegm.m4 b/source4/lib/replace/timegm.m4
deleted file mode 100644
index 59f3ae0521..0000000000
--- a/source4/lib/replace/timegm.m4
+++ /dev/null
@@ -1 +0,0 @@
-AC_CHECK_FUNCS(timegm,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} timegm.o"])
diff --git a/source4/lib/replace/win32.m4 b/source4/lib/replace/win32.m4
deleted file mode 100644
index eb364e2cb9..0000000000
--- a/source4/lib/replace/win32.m4
+++ /dev/null
@@ -1,20 +0,0 @@
-AC_CHECK_HEADERS(direct.h windows.h winsock2.h ws2tcpip.h)
-
-#######################################
-# Check for mkdir mode
-AC_CACHE_CHECK( [whether mkdir supports mode], libreplace_cv_mkdir_has_mode,
- AC_TRY_COMPILE([
- #include <stdio.h>
- #ifdef HAVE_DIRECT_H
- #include <direct.h>
- #endif],[
- mkdir("foo",0777);
- return 0;
- ],
- libreplace_cv_mkdir_has_mode="yes",
- libreplace_cv_mkdir_has_mode="no") )
-
-if test "$libreplace_cv_mkdir_has_mode" = "yes"
-then
- AC_DEFINE(HAVE_MKDIR_MODE, 1, [Define if target mkdir supports mode option])
-fi
diff --git a/source4/lib/replace/win32_replace.h b/source4/lib/replace/win32_replace.h
deleted file mode 100644
index 9901e72f6e..0000000000
--- a/source4/lib/replace/win32_replace.h
+++ /dev/null
@@ -1,159 +0,0 @@
-#ifndef _WIN32_REPLACE_H
-#define _WIN32_REPLACE_H
-
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
-
-#ifdef HAVE_WS2TCPIP_H
-#include <ws2tcpip.h>
-#endif
-
-#ifdef HAVE_WINDOWS_H
-#include <windows.h>
-#endif
-
-/* Map BSD Socket errorcodes to the WSA errorcodes (if possible) */
-
-#define EAFNOSUPPORT WSAEAFNOSUPPORT
-#define ECONNREFUSED WSAECONNREFUSED
-#define EINPROGRESS WSAEINPROGRESS
-#define EMSGSIZE WSAEMSGSIZE
-#define ENOBUFS WSAENOBUFS
-#define ENOTSOCK WSAENOTSOCK
-#define ENETUNREACH WSAENETUNREACH
-#define ENOPROTOOPT WSAENOPROTOOPT
-#define ENOTCONN WSAENOTCONN
-#define ENOTSUP 134
-
-/* We undefine the following constants due to conflicts with the w32api headers
- * and the Windows Platform SDK/DDK.
- */
-
-#undef interface
-
-#undef ERROR_INVALID_PARAMETER
-#undef ERROR_INSUFFICIENT_BUFFER
-#undef ERROR_INVALID_DATATYPE
-
-#undef FILE_GENERIC_READ
-#undef FILE_GENERIC_WRITE
-#undef FILE_GENERIC_EXECUTE
-#undef FILE_ATTRIBUTE_READONLY
-#undef FILE_ATTRIBUTE_HIDDEN
-#undef FILE_ATTRIBUTE_SYSTEM
-#undef FILE_ATTRIBUTE_DIRECTORY
-#undef FILE_ATTRIBUTE_ARCHIVE
-#undef FILE_ATTRIBUTE_DEVICE
-#undef FILE_ATTRIBUTE_NORMAL
-#undef FILE_ATTRIBUTE_TEMPORARY
-#undef FILE_ATTRIBUTE_REPARSE_POINT
-#undef FILE_ATTRIBUTE_COMPRESSED
-#undef FILE_ATTRIBUTE_OFFLINE
-#undef FILE_ATTRIBUTE_ENCRYPTED
-#undef FILE_FLAG_WRITE_THROUGH
-#undef FILE_FLAG_NO_BUFFERING
-#undef FILE_FLAG_RANDOM_ACCESS
-#undef FILE_FLAG_SEQUENTIAL_SCAN
-#undef FILE_FLAG_DELETE_ON_CLOSE
-#undef FILE_FLAG_BACKUP_SEMANTICS
-#undef FILE_FLAG_POSIX_SEMANTICS
-#undef FILE_TYPE_DISK
-#undef FILE_TYPE_UNKNOWN
-#undef FILE_CASE_SENSITIVE_SEARCH
-#undef FILE_CASE_PRESERVED_NAMES
-#undef FILE_UNICODE_ON_DISK
-#undef FILE_PERSISTENT_ACLS
-#undef FILE_FILE_COMPRESSION
-#undef FILE_VOLUME_QUOTAS
-#undef FILE_VOLUME_IS_COMPRESSED
-#undef FILE_NOTIFY_CHANGE_FILE_NAME
-#undef FILE_NOTIFY_CHANGE_DIR_NAME
-#undef FILE_NOTIFY_CHANGE_ATTRIBUTES
-#undef FILE_NOTIFY_CHANGE_SIZE
-#undef FILE_NOTIFY_CHANGE_LAST_WRITE
-#undef FILE_NOTIFY_CHANGE_LAST_ACCESS
-#undef FILE_NOTIFY_CHANGE_CREATION
-#undef FILE_NOTIFY_CHANGE_EA
-#undef FILE_NOTIFY_CHANGE_SECURITY
-#undef FILE_NOTIFY_CHANGE_STREAM_NAME
-#undef FILE_NOTIFY_CHANGE_STREAM_SIZE
-#undef FILE_NOTIFY_CHANGE_STREAM_WRITE
-#undef FILE_NOTIFY_CHANGE_NAME
-
-#undef PRINTER_ATTRIBUTE_QUEUED
-#undef PRINTER_ATTRIBUTE_DIRECT
-#undef PRINTER_ATTRIBUTE_DEFAULT
-#undef PRINTER_ATTRIBUTE_SHARED
-#undef PRINTER_ATTRIBUTE_NETWORK
-#undef PRINTER_ATTRIBUTE_HIDDEN
-#undef PRINTER_ATTRIBUTE_LOCAL
-#undef PRINTER_ATTRIBUTE_ENABLE_DEVQ
-#undef PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS
-#undef PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST
-#undef PRINTER_ATTRIBUTE_WORK_OFFLINE
-#undef PRINTER_ATTRIBUTE_ENABLE_BIDI
-#undef PRINTER_ATTRIBUTE_RAW_ONLY
-#undef PRINTER_ATTRIBUTE_PUBLISHED
-#undef PRINTER_ENUM_DEFAULT
-#undef PRINTER_ENUM_LOCAL
-#undef PRINTER_ENUM_CONNECTIONS
-#undef PRINTER_ENUM_FAVORITE
-#undef PRINTER_ENUM_NAME
-#undef PRINTER_ENUM_REMOTE
-#undef PRINTER_ENUM_SHARED
-#undef PRINTER_ENUM_NETWORK
-#undef PRINTER_ENUM_EXPAND
-#undef PRINTER_ENUM_CONTAINER
-#undef PRINTER_ENUM_ICON1
-#undef PRINTER_ENUM_ICON2
-#undef PRINTER_ENUM_ICON3
-#undef PRINTER_ENUM_ICON4
-#undef PRINTER_ENUM_ICON5
-#undef PRINTER_ENUM_ICON6
-#undef PRINTER_ENUM_ICON7
-#undef PRINTER_ENUM_ICON8
-#undef PRINTER_STATUS_PAUSED
-#undef PRINTER_STATUS_ERROR
-#undef PRINTER_STATUS_PENDING_DELETION
-#undef PRINTER_STATUS_PAPER_JAM
-#undef PRINTER_STATUS_PAPER_OUT
-#undef PRINTER_STATUS_MANUAL_FEED
-#undef PRINTER_STATUS_PAPER_PROBLEM
-#undef PRINTER_STATUS_OFFLINE
-#undef PRINTER_STATUS_IO_ACTIVE
-#undef PRINTER_STATUS_BUSY
-#undef PRINTER_STATUS_PRINTING
-#undef PRINTER_STATUS_OUTPUT_BIN_FULL
-#undef PRINTER_STATUS_NOT_AVAILABLE
-#undef PRINTER_STATUS_WAITING
-#undef PRINTER_STATUS_PROCESSING
-#undef PRINTER_STATUS_INITIALIZING
-#undef PRINTER_STATUS_WARMING_UP
-#undef PRINTER_STATUS_TONER_LOW
-#undef PRINTER_STATUS_NO_TONER
-#undef PRINTER_STATUS_PAGE_PUNT
-#undef PRINTER_STATUS_USER_INTERVENTION
-#undef PRINTER_STATUS_OUT_OF_MEMORY
-#undef PRINTER_STATUS_DOOR_OPEN
-#undef PRINTER_STATUS_SERVER_UNKNOWN
-#undef PRINTER_STATUS_POWER_SAVE
-
-#undef DWORD
-#undef HKEY_CLASSES_ROOT
-#undef HKEY_CURRENT_USER
-#undef HKEY_LOCAL_MACHINE
-#undef HKEY_USERS
-#undef HKEY_PERFORMANCE_DATA
-#undef HKEY_CURRENT_CONFIG
-#undef HKEY_DYN_DATA
-#undef REG_DWORD
-#undef REG_QWORD
-
-#undef SERVICE_STATE_ALL
-
-#undef SE_GROUP_MANDATORY
-#undef SE_GROUP_ENABLED_BY_DEFAULT
-#undef SE_GROUP_ENABLED
-
-#endif /* _WIN32_REPLACE_H */
diff --git a/source4/lib/socket_wrapper/config.m4 b/source4/lib/socket_wrapper/config.m4
deleted file mode 100644
index f3ffb895a9..0000000000
--- a/source4/lib/socket_wrapper/config.m4
+++ /dev/null
@@ -1,22 +0,0 @@
-AC_ARG_ENABLE(socket-wrapper,
-[ --enable-socket-wrapper Turn on socket wrapper library (default=no)])
-
-DEFAULT_TEST_OPTIONS=
-HAVE_SOCKET_WRAPPER=no
-
-if eval "test x$developer = xyes"; then
- enable_socket_wrapper=yes
-fi
-
-if eval "test x$enable_socket_wrapper = xyes"; then
- AC_DEFINE(SOCKET_WRAPPER,1,[Use socket wrapper library])
- DEFAULT_TEST_OPTIONS=--socket-wrapper
- HAVE_SOCKET_WRAPPER=yes
-
- # this is only used for samba3
- SOCKET_WRAPPER_OBJS="lib/socket_wrapper/socket_wrapper.o"
-fi
-
-AC_SUBST(DEFAULT_TEST_OPTIONS)
-AC_SUBST(HAVE_SOCKET_WRAPPER)
-AC_SUBST(SOCKET_WRAPPER_OBJS)
diff --git a/source4/lib/socket_wrapper/config.mk b/source4/lib/socket_wrapper/config.mk
deleted file mode 100644
index 60cfb3209a..0000000000
--- a/source4/lib/socket_wrapper/config.mk
+++ /dev/null
@@ -1,8 +0,0 @@
-##############################
-# Start SUBSYSTEM SOCKET_WRAPPER
-[SUBSYSTEM::SOCKET_WRAPPER]
-PRIVATE_DEPENDENCIES = LIBREPLACE_NETWORK
-# End SUBSYSTEM SOCKET_WRAPPER
-##############################
-
-SOCKET_WRAPPER_OBJ_FILES = $(socketwrappersrcdir)/socket_wrapper.o
diff --git a/source4/lib/socket_wrapper/socket_wrapper.c b/source4/lib/socket_wrapper/socket_wrapper.c
deleted file mode 100644
index 336179d837..0000000000
--- a/source4/lib/socket_wrapper/socket_wrapper.c
+++ /dev/null
@@ -1,1841 +0,0 @@
-/*
- * Copyright (C) Jelmer Vernooij 2005,2008 <jelmer@samba.org>
- * Copyright (C) Stefan Metzmacher 2006 <metze@samba.org>
- *
- * 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. Neither the name of the author nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- */
-
-/*
- Socket wrapper library. Passes all socket communication over
- unix domain sockets if the environment variable SOCKET_WRAPPER_DIR
- is set.
-*/
-
-#ifdef _SAMBA_BUILD_
-
-#define SOCKET_WRAPPER_NOT_REPLACE
-#include "lib/replace/replace.h"
-#include "system/network.h"
-#include "system/filesys.h"
-#include "system/time.h"
-
-#else /* _SAMBA_BUILD_ */
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/filio.h>
-#include <errno.h>
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdint.h>
-
-#endif
-
-#ifndef _PUBLIC_
-#define _PUBLIC_
-#endif
-
-#define SWRAP_DLIST_ADD(list,item) do { \
- if (!(list)) { \
- (item)->prev = NULL; \
- (item)->next = NULL; \
- (list) = (item); \
- } else { \
- (item)->prev = NULL; \
- (item)->next = (list); \
- (list)->prev = (item); \
- (list) = (item); \
- } \
-} while (0)
-
-#define SWRAP_DLIST_REMOVE(list,item) do { \
- if ((list) == (item)) { \
- (list) = (item)->next; \
- if (list) { \
- (list)->prev = NULL; \
- } \
- } else { \
- if ((item)->prev) { \
- (item)->prev->next = (item)->next; \
- } \
- if ((item)->next) { \
- (item)->next->prev = (item)->prev; \
- } \
- } \
- (item)->prev = NULL; \
- (item)->next = NULL; \
-} while (0)
-
-/* LD_PRELOAD doesn't work yet, so REWRITE_CALLS is all we support
- * for now */
-#define REWRITE_CALLS
-
-#ifdef REWRITE_CALLS
-#define real_accept accept
-#define real_connect connect
-#define real_bind bind
-#define real_listen listen
-#define real_getpeername getpeername
-#define real_getsockname getsockname
-#define real_getsockopt getsockopt
-#define real_setsockopt setsockopt
-#define real_recvfrom recvfrom
-#define real_sendto sendto
-#define real_ioctl ioctl
-#define real_recv recv
-#define real_send send
-#define real_socket socket
-#define real_close close
-#endif
-
-#ifdef HAVE_GETTIMEOFDAY_TZ
-#define swrapGetTimeOfDay(tval) gettimeofday(tval,NULL)
-#else
-#define swrapGetTimeOfDay(tval) gettimeofday(tval)
-#endif
-
-/* we need to use a very terse format here as IRIX 6.4 silently
- truncates names to 16 chars, so if we use a longer name then we
- can't tell which port a packet came from with recvfrom()
-
- with this format we have 8 chars left for the directory name
-*/
-#define SOCKET_FORMAT "%c%02X%04X"
-#define SOCKET_TYPE_CHAR_TCP 'T'
-#define SOCKET_TYPE_CHAR_UDP 'U'
-#define SOCKET_TYPE_CHAR_TCP_V6 'X'
-#define SOCKET_TYPE_CHAR_UDP_V6 'Y'
-
-#define MAX_WRAPPED_INTERFACES 16
-
-#define SW_IPV6_ADDRESS 1
-
-static struct sockaddr *sockaddr_dup(const void *data, socklen_t len)
-{
- struct sockaddr *ret = (struct sockaddr *)malloc(len);
- memcpy(ret, data, len);
- return ret;
-}
-
-static void set_port(int family, int prt, struct sockaddr *addr)
-{
- switch (family) {
- case AF_INET:
- ((struct sockaddr_in *)addr)->sin_port = htons(prt);
- break;
-#ifdef HAVE_IPV6
- case AF_INET6:
- ((struct sockaddr_in6 *)addr)->sin6_port = htons(prt);
- break;
-#endif
- }
-}
-
-static size_t socket_length(int family)
-{
- switch (family) {
- case AF_INET:
- return sizeof(struct sockaddr_in);
-#ifdef HAVE_IPV6
- case AF_INET6:
- return sizeof(struct sockaddr_in6);
-#endif
- }
- return 0;
-}
-
-
-
-struct socket_info
-{
- int fd;
-
- int family;
- int type;
- int protocol;
- int bound;
- int bcast;
- int is_server;
-
- char *path;
- char *tmp_path;
-
- struct sockaddr *myname;
- socklen_t myname_len;
-
- struct sockaddr *peername;
- socklen_t peername_len;
-
- struct {
- unsigned long pck_snd;
- unsigned long pck_rcv;
- } io;
-
- struct socket_info *prev, *next;
-};
-
-static struct socket_info *sockets;
-
-const char *socket_wrapper_dir(void)
-{
- const char *s = getenv("SOCKET_WRAPPER_DIR");
- if (s == NULL) {
- return NULL;
- }
- if (strncmp(s, "./", 2) == 0) {
- s += 2;
- }
- return s;
-}
-
-unsigned int socket_wrapper_default_iface(void)
-{
- const char *s = getenv("SOCKET_WRAPPER_DEFAULT_IFACE");
- if (s) {
- unsigned int iface;
- if (sscanf(s, "%u", &iface) == 1) {
- if (iface >= 1 && iface <= MAX_WRAPPED_INTERFACES) {
- return iface;
- }
- }
- }
-
- return 1;/* 127.0.0.1 */
-}
-
-static int convert_un_in(const struct sockaddr_un *un, struct sockaddr *in, socklen_t *len)
-{
- unsigned int iface;
- unsigned int prt;
- const char *p;
- char type;
-
- p = strrchr(un->sun_path, '/');
- if (p) p++; else p = un->sun_path;
-
- if (sscanf(p, SOCKET_FORMAT, &type, &iface, &prt) != 3) {
- errno = EINVAL;
- return -1;
- }
-
- if (iface == 0 || iface > MAX_WRAPPED_INTERFACES) {
- errno = EINVAL;
- return -1;
- }
-
- if (prt > 0xFFFF) {
- errno = EINVAL;
- return -1;
- }
-
- switch(type) {
- case SOCKET_TYPE_CHAR_TCP:
- case SOCKET_TYPE_CHAR_UDP: {
- struct sockaddr_in *in2 = (struct sockaddr_in *)in;
-
- if ((*len) < sizeof(*in2)) {
- errno = EINVAL;
- return -1;
- }
-
- memset(in2, 0, sizeof(*in2));
- in2->sin_family = AF_INET;
- in2->sin_addr.s_addr = htonl((127<<24) | iface);
- in2->sin_port = htons(prt);
-
- *len = sizeof(*in2);
- break;
- }
-#ifdef HAVE_IPV6
- case SOCKET_TYPE_CHAR_TCP_V6:
- case SOCKET_TYPE_CHAR_UDP_V6: {
- struct sockaddr_in6 *in2 = (struct sockaddr_in6 *)in;
-
- if ((*len) < sizeof(*in2)) {
- errno = EINVAL;
- return -1;
- }
-
- memset(in2, 0, sizeof(*in2));
- in2->sin6_family = AF_INET6;
- in2->sin6_addr.s6_addr[0] = SW_IPV6_ADDRESS;
- in2->sin6_port = htons(prt);
-
- *len = sizeof(*in2);
- break;
- }
-#endif
- default:
- errno = EINVAL;
- return -1;
- }
-
- return 0;
-}
-
-static int convert_in_un_remote(struct socket_info *si, const struct sockaddr *inaddr, struct sockaddr_un *un,
- int *bcast)
-{
- char type = '\0';
- unsigned int prt;
- unsigned int iface;
- int is_bcast = 0;
-
- if (bcast) *bcast = 0;
-
- switch (si->family) {
- case AF_INET: {
- const struct sockaddr_in *in =
- (const struct sockaddr_in *)inaddr;
- unsigned int addr = ntohl(in->sin_addr.s_addr);
- char u_type = '\0';
- char b_type = '\0';
- char a_type = '\0';
-
- switch (si->type) {
- case SOCK_STREAM:
- u_type = SOCKET_TYPE_CHAR_TCP;
- break;
- case SOCK_DGRAM:
- u_type = SOCKET_TYPE_CHAR_UDP;
- a_type = SOCKET_TYPE_CHAR_UDP;
- b_type = SOCKET_TYPE_CHAR_UDP;
- break;
- }
-
- prt = ntohs(in->sin_port);
- if (a_type && addr == 0xFFFFFFFF) {
- /* 255.255.255.255 only udp */
- is_bcast = 2;
- type = a_type;
- iface = socket_wrapper_default_iface();
- } else if (b_type && addr == 0x7FFFFFFF) {
- /* 127.255.255.255 only udp */
- is_bcast = 1;
- type = b_type;
- iface = socket_wrapper_default_iface();
- } else if ((addr & 0xFFFFFF00) == 0x7F000000) {
- /* 127.0.0.X */
- is_bcast = 0;
- type = u_type;
- iface = (addr & 0x000000FF);
- } else {
- errno = ENETUNREACH;
- return -1;
- }
- if (bcast) *bcast = is_bcast;
- break;
- }
-#ifdef HAVE_IPV6
- case AF_INET6: {
- const struct sockaddr_in6 *in =
- (const struct sockaddr_in6 *)inaddr;
-
- switch (si->type) {
- case SOCK_STREAM:
- type = SOCKET_TYPE_CHAR_TCP_V6;
- break;
- case SOCK_DGRAM:
- type = SOCKET_TYPE_CHAR_UDP_V6;
- break;
- }
-
- /* XXX no multicast/broadcast */
-
- prt = ntohs(in->sin6_port);
- iface = SW_IPV6_ADDRESS;
-
- break;
- }
-#endif
- default:
- errno = ENETUNREACH;
- return -1;
- }
-
- if (prt == 0) {
- errno = EINVAL;
- return -1;
- }
-
- if (is_bcast) {
- snprintf(un->sun_path, sizeof(un->sun_path), "%s/EINVAL",
- socket_wrapper_dir());
- /* the caller need to do more processing */
- return 0;
- }
-
- snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT,
- socket_wrapper_dir(), type, iface, prt);
-
- return 0;
-}
-
-static int convert_in_un_alloc(struct socket_info *si, const struct sockaddr *inaddr, struct sockaddr_un *un,
- int *bcast)
-{
- char type = '\0';
- unsigned int prt;
- unsigned int iface;
- struct stat st;
- int is_bcast = 0;
-
- if (bcast) *bcast = 0;
-
- switch (si->family) {
- case AF_INET: {
- const struct sockaddr_in *in =
- (const struct sockaddr_in *)inaddr;
- unsigned int addr = ntohl(in->sin_addr.s_addr);
- char u_type = '\0';
- char d_type = '\0';
- char b_type = '\0';
- char a_type = '\0';
-
- prt = ntohs(in->sin_port);
-
- switch (si->type) {
- case SOCK_STREAM:
- u_type = SOCKET_TYPE_CHAR_TCP;
- d_type = SOCKET_TYPE_CHAR_TCP;
- break;
- case SOCK_DGRAM:
- u_type = SOCKET_TYPE_CHAR_UDP;
- d_type = SOCKET_TYPE_CHAR_UDP;
- a_type = SOCKET_TYPE_CHAR_UDP;
- b_type = SOCKET_TYPE_CHAR_UDP;
- break;
- }
-
- if (addr == 0) {
- /* 0.0.0.0 */
- is_bcast = 0;
- type = d_type;
- iface = socket_wrapper_default_iface();
- } else if (a_type && addr == 0xFFFFFFFF) {
- /* 255.255.255.255 only udp */
- is_bcast = 2;
- type = a_type;
- iface = socket_wrapper_default_iface();
- } else if (b_type && addr == 0x7FFFFFFF) {
- /* 127.255.255.255 only udp */
- is_bcast = 1;
- type = b_type;
- iface = socket_wrapper_default_iface();
- } else if ((addr & 0xFFFFFF00) == 0x7F000000) {
- /* 127.0.0.X */
- is_bcast = 0;
- type = u_type;
- iface = (addr & 0x000000FF);
- } else {
- errno = EADDRNOTAVAIL;
- return -1;
- }
- break;
- }
-#ifdef HAVE_IPV6
- case AF_INET6: {
- const struct sockaddr_in6 *in =
- (const struct sockaddr_in6 *)inaddr;
-
- switch (si->type) {
- case SOCK_STREAM:
- type = SOCKET_TYPE_CHAR_TCP_V6;
- break;
- case SOCK_DGRAM:
- type = SOCKET_TYPE_CHAR_UDP_V6;
- break;
- }
-
- /* XXX no multicast/broadcast */
-
- prt = ntohs(in->sin6_port);
- iface = SW_IPV6_ADDRESS;
-
- break;
- }
-#endif
- default:
- errno = ENETUNREACH;
- return -1;
- }
-
-
- if (bcast) *bcast = is_bcast;
-
- if (prt == 0) {
- /* handle auto-allocation of ephemeral ports */
- for (prt = 5001; prt < 10000; prt++) {
- snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT,
- socket_wrapper_dir(), type, iface, prt);
- if (stat(un->sun_path, &st) == 0) continue;
-
- set_port(si->family, prt, si->myname);
- break;
- }
- if (prt == 10000) {
- errno = ENFILE;
- return -1;
- }
- }
-
- snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT,
- socket_wrapper_dir(), type, iface, prt);
- return 0;
-}
-
-static struct socket_info *find_socket_info(int fd)
-{
- struct socket_info *i;
- for (i = sockets; i; i = i->next) {
- if (i->fd == fd)
- return i;
- }
-
- return NULL;
-}
-
-static int sockaddr_convert_to_un(struct socket_info *si, const struct sockaddr *in_addr, socklen_t in_len,
- struct sockaddr_un *out_addr, int alloc_sock, int *bcast)
-{
- if (!out_addr)
- return 0;
-
- out_addr->sun_family = AF_UNIX;
-
- switch (in_addr->sa_family) {
- case AF_INET:
-#ifdef HAVE_IPV6
- case AF_INET6:
-#endif
- switch (si->type) {
- case SOCK_STREAM:
- case SOCK_DGRAM:
- break;
- default:
- errno = ESOCKTNOSUPPORT;
- return -1;
- }
- if (alloc_sock) {
- return convert_in_un_alloc(si, in_addr, out_addr, bcast);
- } else {
- return convert_in_un_remote(si, in_addr, out_addr, bcast);
- }
- default:
- break;
- }
-
- errno = EAFNOSUPPORT;
- return -1;
-}
-
-static int sockaddr_convert_from_un(const struct socket_info *si,
- const struct sockaddr_un *in_addr,
- socklen_t un_addrlen,
- int family,
- struct sockaddr *out_addr,
- socklen_t *out_addrlen)
-{
- if (out_addr == NULL || out_addrlen == NULL)
- return 0;
-
- if (un_addrlen == 0) {
- *out_addrlen = 0;
- return 0;
- }
-
- switch (family) {
- case AF_INET:
-#ifdef HAVE_IPV6
- case AF_INET6:
-#endif
- switch (si->type) {
- case SOCK_STREAM:
- case SOCK_DGRAM:
- break;
- default:
- errno = ESOCKTNOSUPPORT;
- return -1;
- }
- return convert_un_in(in_addr, out_addr, out_addrlen);
- default:
- break;
- }
-
- errno = EAFNOSUPPORT;
- return -1;
-}
-
-enum swrap_packet_type {
- SWRAP_CONNECT_SEND,
- SWRAP_CONNECT_UNREACH,
- SWRAP_CONNECT_RECV,
- SWRAP_CONNECT_ACK,
- SWRAP_ACCEPT_SEND,
- SWRAP_ACCEPT_RECV,
- SWRAP_ACCEPT_ACK,
- SWRAP_RECVFROM,
- SWRAP_SENDTO,
- SWRAP_SENDTO_UNREACH,
- SWRAP_PENDING_RST,
- SWRAP_RECV,
- SWRAP_RECV_RST,
- SWRAP_SEND,
- SWRAP_SEND_RST,
- SWRAP_CLOSE_SEND,
- SWRAP_CLOSE_RECV,
- SWRAP_CLOSE_ACK
-};
-
-struct swrap_file_hdr {
- uint32_t magic;
- uint16_t version_major;
- uint16_t version_minor;
- int32_t timezone;
- uint32_t sigfigs;
- uint32_t frame_max_len;
-#define SWRAP_FRAME_LENGTH_MAX 0xFFFF
- uint32_t link_type;
-};
-#define SWRAP_FILE_HDR_SIZE 24
-
-struct swrap_packet {
- struct {
- uint32_t seconds;
- uint32_t micro_seconds;
- uint32_t recorded_length;
- uint32_t full_length;
- } frame;
-#define SWRAP_PACKET__FRAME_SIZE 16
-
- struct {
- struct {
- uint8_t ver_hdrlen;
- uint8_t tos;
- uint16_t packet_length;
- uint16_t identification;
- uint8_t flags;
- uint8_t fragment;
- uint8_t ttl;
- uint8_t protocol;
- uint16_t hdr_checksum;
- uint32_t src_addr;
- uint32_t dest_addr;
- } hdr;
-#define SWRAP_PACKET__IP_HDR_SIZE 20
-
- union {
- struct {
- uint16_t source_port;
- uint16_t dest_port;
- uint32_t seq_num;
- uint32_t ack_num;
- uint8_t hdr_length;
- uint8_t control;
- uint16_t window;
- uint16_t checksum;
- uint16_t urg;
- } tcp;
-#define SWRAP_PACKET__IP_P_TCP_SIZE 20
- struct {
- uint16_t source_port;
- uint16_t dest_port;
- uint16_t length;
- uint16_t checksum;
- } udp;
-#define SWRAP_PACKET__IP_P_UDP_SIZE 8
- struct {
- uint8_t type;
- uint8_t code;
- uint16_t checksum;
- uint32_t unused;
- } icmp;
-#define SWRAP_PACKET__IP_P_ICMP_SIZE 8
- } p;
- } ip;
-};
-#define SWRAP_PACKET_SIZE 56
-
-static const char *socket_wrapper_pcap_file(void)
-{
- static int initialized = 0;
- static const char *s = NULL;
- static const struct swrap_file_hdr h = { 0, };
- static const struct swrap_packet p = { { 0, }, { { 0, }, { { 0, } } } };
-
- if (initialized == 1) {
- return s;
- }
- initialized = 1;
-
- /*
- * TODO: don't use the structs use plain buffer offsets
- * and PUSH_U8(), PUSH_U16() and PUSH_U32()
- *
- * for now make sure we disable PCAP support
- * if the struct has alignment!
- */
- if (sizeof(h) != SWRAP_FILE_HDR_SIZE) {
- return NULL;
- }
- if (sizeof(p) != SWRAP_PACKET_SIZE) {
- return NULL;
- }
- if (sizeof(p.frame) != SWRAP_PACKET__FRAME_SIZE) {
- return NULL;
- }
- if (sizeof(p.ip.hdr) != SWRAP_PACKET__IP_HDR_SIZE) {
- return NULL;
- }
- if (sizeof(p.ip.p.tcp) != SWRAP_PACKET__IP_P_TCP_SIZE) {
- return NULL;
- }
- if (sizeof(p.ip.p.udp) != SWRAP_PACKET__IP_P_UDP_SIZE) {
- return NULL;
- }
- if (sizeof(p.ip.p.icmp) != SWRAP_PACKET__IP_P_ICMP_SIZE) {
- return NULL;
- }
-
- s = getenv("SOCKET_WRAPPER_PCAP_FILE");
- if (s == NULL) {
- return NULL;
- }
- if (strncmp(s, "./", 2) == 0) {
- s += 2;
- }
- return s;
-}
-
-static struct swrap_packet *swrap_packet_init(struct timeval *tval,
- const struct sockaddr_in *src_addr,
- const struct sockaddr_in *dest_addr,
- int socket_type,
- const unsigned char *payload,
- size_t payload_len,
- unsigned long tcp_seq,
- unsigned long tcp_ack,
- unsigned char tcp_ctl,
- int unreachable,
- size_t *_packet_len)
-{
- struct swrap_packet *ret;
- struct swrap_packet *packet;
- size_t packet_len;
- size_t alloc_len;
- size_t nonwire_len = sizeof(packet->frame);
- size_t wire_hdr_len = 0;
- size_t wire_len = 0;
- size_t icmp_hdr_len = 0;
- size_t icmp_truncate_len = 0;
- unsigned char protocol = 0, icmp_protocol = 0;
- unsigned short src_port = src_addr->sin_port;
- unsigned short dest_port = dest_addr->sin_port;
-
- switch (socket_type) {
- case SOCK_STREAM:
- protocol = 0x06; /* TCP */
- wire_hdr_len = sizeof(packet->ip.hdr) + sizeof(packet->ip.p.tcp);
- wire_len = wire_hdr_len + payload_len;
- break;
-
- case SOCK_DGRAM:
- protocol = 0x11; /* UDP */
- wire_hdr_len = sizeof(packet->ip.hdr) + sizeof(packet->ip.p.udp);
- wire_len = wire_hdr_len + payload_len;
- break;
-
- default:
- return NULL;
- }
-
- if (unreachable) {
- icmp_protocol = protocol;
- protocol = 0x01; /* ICMP */
- if (wire_len > 64 ) {
- icmp_truncate_len = wire_len - 64;
- }
- icmp_hdr_len = sizeof(packet->ip.hdr) + sizeof(packet->ip.p.icmp);
- wire_hdr_len += icmp_hdr_len;
- wire_len += icmp_hdr_len;
- }
-
- packet_len = nonwire_len + wire_len;
- alloc_len = packet_len;
- if (alloc_len < sizeof(struct swrap_packet)) {
- alloc_len = sizeof(struct swrap_packet);
- }
- ret = (struct swrap_packet *)malloc(alloc_len);
- if (!ret) return NULL;
-
- packet = ret;
-
- packet->frame.seconds = tval->tv_sec;
- packet->frame.micro_seconds = tval->tv_usec;
- packet->frame.recorded_length = wire_len - icmp_truncate_len;
- packet->frame.full_length = wire_len - icmp_truncate_len;
-
- packet->ip.hdr.ver_hdrlen = 0x45; /* version 4 and 5 * 32 bit words */
- packet->ip.hdr.tos = 0x00;
- packet->ip.hdr.packet_length = htons(wire_len - icmp_truncate_len);
- packet->ip.hdr.identification = htons(0xFFFF);
- packet->ip.hdr.flags = 0x40; /* BIT 1 set - means don't fraqment */
- packet->ip.hdr.fragment = htons(0x0000);
- packet->ip.hdr.ttl = 0xFF;
- packet->ip.hdr.protocol = protocol;
- packet->ip.hdr.hdr_checksum = htons(0x0000);
- packet->ip.hdr.src_addr = src_addr->sin_addr.s_addr;
- packet->ip.hdr.dest_addr = dest_addr->sin_addr.s_addr;
-
- if (unreachable) {
- packet->ip.p.icmp.type = 0x03; /* destination unreachable */
- packet->ip.p.icmp.code = 0x01; /* host unreachable */
- packet->ip.p.icmp.checksum = htons(0x0000);
- packet->ip.p.icmp.unused = htonl(0x00000000);
-
- /* set the ip header in the ICMP payload */
- packet = (struct swrap_packet *)(((unsigned char *)ret) + icmp_hdr_len);
- packet->ip.hdr.ver_hdrlen = 0x45; /* version 4 and 5 * 32 bit words */
- packet->ip.hdr.tos = 0x00;
- packet->ip.hdr.packet_length = htons(wire_len - icmp_hdr_len);
- packet->ip.hdr.identification = htons(0xFFFF);
- packet->ip.hdr.flags = 0x40; /* BIT 1 set - means don't fraqment */
- packet->ip.hdr.fragment = htons(0x0000);
- packet->ip.hdr.ttl = 0xFF;
- packet->ip.hdr.protocol = icmp_protocol;
- packet->ip.hdr.hdr_checksum = htons(0x0000);
- packet->ip.hdr.src_addr = dest_addr->sin_addr.s_addr;
- packet->ip.hdr.dest_addr = src_addr->sin_addr.s_addr;
-
- src_port = dest_addr->sin_port;
- dest_port = src_addr->sin_port;
- }
-
- switch (socket_type) {
- case SOCK_STREAM:
- packet->ip.p.tcp.source_port = src_port;
- packet->ip.p.tcp.dest_port = dest_port;
- packet->ip.p.tcp.seq_num = htonl(tcp_seq);
- packet->ip.p.tcp.ack_num = htonl(tcp_ack);
- packet->ip.p.tcp.hdr_length = 0x50; /* 5 * 32 bit words */
- packet->ip.p.tcp.control = tcp_ctl;
- packet->ip.p.tcp.window = htons(0x7FFF);
- packet->ip.p.tcp.checksum = htons(0x0000);
- packet->ip.p.tcp.urg = htons(0x0000);
-
- break;
-
- case SOCK_DGRAM:
- packet->ip.p.udp.source_port = src_addr->sin_port;
- packet->ip.p.udp.dest_port = dest_addr->sin_port;
- packet->ip.p.udp.length = htons(8 + payload_len);
- packet->ip.p.udp.checksum = htons(0x0000);
-
- break;
- }
-
- if (payload && payload_len > 0) {
- unsigned char *p = (unsigned char *)ret;
- p += nonwire_len;
- p += wire_hdr_len;
- memcpy(p, payload, payload_len);
- }
-
- *_packet_len = packet_len - icmp_truncate_len;
- return ret;
-}
-
-static int swrap_get_pcap_fd(const char *fname)
-{
- static int fd = -1;
-
- if (fd != -1) return fd;
-
- fd = open(fname, O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0644);
- if (fd != -1) {
- struct swrap_file_hdr file_hdr;
- file_hdr.magic = 0xA1B2C3D4;
- file_hdr.version_major = 0x0002;
- file_hdr.version_minor = 0x0004;
- file_hdr.timezone = 0x00000000;
- file_hdr.sigfigs = 0x00000000;
- file_hdr.frame_max_len = SWRAP_FRAME_LENGTH_MAX;
- file_hdr.link_type = 0x0065; /* 101 RAW IP */
-
- write(fd, &file_hdr, sizeof(file_hdr));
- return fd;
- }
-
- fd = open(fname, O_WRONLY|O_APPEND, 0644);
-
- return fd;
-}
-
-static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
- const struct sockaddr *addr,
- enum swrap_packet_type type,
- const void *buf, size_t len,
- size_t *packet_len)
-{
- const struct sockaddr_in *src_addr;
- const struct sockaddr_in *dest_addr;
- unsigned long tcp_seq = 0;
- unsigned long tcp_ack = 0;
- unsigned char tcp_ctl = 0;
- int unreachable = 0;
-
- struct timeval tv;
-
- switch (si->family) {
- case AF_INET:
- break;
- default:
- return NULL;
- }
-
- switch (type) {
- case SWRAP_CONNECT_SEND:
- if (si->type != SOCK_STREAM) return NULL;
-
- src_addr = (const struct sockaddr_in *)si->myname;
- dest_addr = (const struct sockaddr_in *)addr;
-
- tcp_seq = si->io.pck_snd;
- tcp_ack = si->io.pck_rcv;
- tcp_ctl = 0x02; /* SYN */
-
- si->io.pck_snd += 1;
-
- break;
-
- case SWRAP_CONNECT_RECV:
- if (si->type != SOCK_STREAM) return NULL;
-
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)addr;
-
- tcp_seq = si->io.pck_rcv;
- tcp_ack = si->io.pck_snd;
- tcp_ctl = 0x12; /** SYN,ACK */
-
- si->io.pck_rcv += 1;
-
- break;
-
- case SWRAP_CONNECT_UNREACH:
- if (si->type != SOCK_STREAM) return NULL;
-
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)addr;
-
- /* Unreachable: resend the data of SWRAP_CONNECT_SEND */
- tcp_seq = si->io.pck_snd - 1;
- tcp_ack = si->io.pck_rcv;
- tcp_ctl = 0x02; /* SYN */
- unreachable = 1;
-
- break;
-
- case SWRAP_CONNECT_ACK:
- if (si->type != SOCK_STREAM) return NULL;
-
- src_addr = (const struct sockaddr_in *)si->myname;
- dest_addr = (const struct sockaddr_in *)addr;
-
- tcp_seq = si->io.pck_snd;
- tcp_ack = si->io.pck_rcv;
- tcp_ctl = 0x10; /* ACK */
-
- break;
-
- case SWRAP_ACCEPT_SEND:
- if (si->type != SOCK_STREAM) return NULL;
-
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)addr;
-
- tcp_seq = si->io.pck_rcv;
- tcp_ack = si->io.pck_snd;
- tcp_ctl = 0x02; /* SYN */
-
- si->io.pck_rcv += 1;
-
- break;
-
- case SWRAP_ACCEPT_RECV:
- if (si->type != SOCK_STREAM) return NULL;
-
- src_addr = (const struct sockaddr_in *)si->myname;
- dest_addr = (const struct sockaddr_in *)addr;
-
- tcp_seq = si->io.pck_snd;
- tcp_ack = si->io.pck_rcv;
- tcp_ctl = 0x12; /* SYN,ACK */
-
- si->io.pck_snd += 1;
-
- break;
-
- case SWRAP_ACCEPT_ACK:
- if (si->type != SOCK_STREAM) return NULL;
-
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)addr;
-
- tcp_seq = si->io.pck_rcv;
- tcp_ack = si->io.pck_snd;
- tcp_ctl = 0x10; /* ACK */
-
- break;
-
- case SWRAP_SEND:
- src_addr = (const struct sockaddr_in *)si->myname;
- dest_addr = (const struct sockaddr_in *)si->peername;
-
- tcp_seq = si->io.pck_snd;
- tcp_ack = si->io.pck_rcv;
- tcp_ctl = 0x18; /* PSH,ACK */
-
- si->io.pck_snd += len;
-
- break;
-
- case SWRAP_SEND_RST:
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)si->peername;
-
- if (si->type == SOCK_DGRAM) {
- return swrap_marshall_packet(si, si->peername,
- SWRAP_SENDTO_UNREACH,
- buf, len, packet_len);
- }
-
- tcp_seq = si->io.pck_rcv;
- tcp_ack = si->io.pck_snd;
- tcp_ctl = 0x14; /** RST,ACK */
-
- break;
-
- case SWRAP_PENDING_RST:
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)si->peername;
-
- if (si->type == SOCK_DGRAM) {
- return NULL;
- }
-
- tcp_seq = si->io.pck_rcv;
- tcp_ack = si->io.pck_snd;
- tcp_ctl = 0x14; /* RST,ACK */
-
- break;
-
- case SWRAP_RECV:
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)si->peername;
-
- tcp_seq = si->io.pck_rcv;
- tcp_ack = si->io.pck_snd;
- tcp_ctl = 0x18; /* PSH,ACK */
-
- si->io.pck_rcv += len;
-
- break;
-
- case SWRAP_RECV_RST:
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)si->peername;
-
- if (si->type == SOCK_DGRAM) {
- return NULL;
- }
-
- tcp_seq = si->io.pck_rcv;
- tcp_ack = si->io.pck_snd;
- tcp_ctl = 0x14; /* RST,ACK */
-
- break;
-
- case SWRAP_SENDTO:
- src_addr = (const struct sockaddr_in *)si->myname;
- dest_addr = (const struct sockaddr_in *)addr;
-
- si->io.pck_snd += len;
-
- break;
-
- case SWRAP_SENDTO_UNREACH:
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)addr;
-
- unreachable = 1;
-
- break;
-
- case SWRAP_RECVFROM:
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)addr;
-
- si->io.pck_rcv += len;
-
- break;
-
- case SWRAP_CLOSE_SEND:
- if (si->type != SOCK_STREAM) return NULL;
-
- src_addr = (const struct sockaddr_in *)si->myname;
- dest_addr = (const struct sockaddr_in *)si->peername;
-
- tcp_seq = si->io.pck_snd;
- tcp_ack = si->io.pck_rcv;
- tcp_ctl = 0x11; /* FIN, ACK */
-
- si->io.pck_snd += 1;
-
- break;
-
- case SWRAP_CLOSE_RECV:
- if (si->type != SOCK_STREAM) return NULL;
-
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)si->peername;
-
- tcp_seq = si->io.pck_rcv;
- tcp_ack = si->io.pck_snd;
- tcp_ctl = 0x11; /* FIN,ACK */
-
- si->io.pck_rcv += 1;
-
- break;
-
- case SWRAP_CLOSE_ACK:
- if (si->type != SOCK_STREAM) return NULL;
-
- src_addr = (const struct sockaddr_in *)si->myname;
- dest_addr = (const struct sockaddr_in *)si->peername;
-
- tcp_seq = si->io.pck_snd;
- tcp_ack = si->io.pck_rcv;
- tcp_ctl = 0x10; /* ACK */
-
- break;
- default:
- return NULL;
- }
-
- swrapGetTimeOfDay(&tv);
-
- return swrap_packet_init(&tv, src_addr, dest_addr, si->type,
- (const unsigned char *)buf, len,
- tcp_seq, tcp_ack, tcp_ctl, unreachable,
- packet_len);
-}
-
-static void swrap_dump_packet(struct socket_info *si,
- const struct sockaddr *addr,
- enum swrap_packet_type type,
- const void *buf, size_t len)
-{
- const char *file_name;
- struct swrap_packet *packet;
- size_t packet_len = 0;
- int fd;
-
- file_name = socket_wrapper_pcap_file();
- if (!file_name) {
- return;
- }
-
- packet = swrap_marshall_packet(si, addr, type, buf, len, &packet_len);
- if (!packet) {
- return;
- }
-
- fd = swrap_get_pcap_fd(file_name);
- if (fd != -1) {
- write(fd, packet, packet_len);
- }
-
- free(packet);
-}
-
-_PUBLIC_ int swrap_socket(int family, int type, int protocol)
-{
- struct socket_info *si;
- int fd;
-
- if (!socket_wrapper_dir()) {
- return real_socket(family, type, protocol);
- }
-
- switch (family) {
- case AF_INET:
-#ifdef HAVE_IPV6
- case AF_INET6:
-#endif
- break;
- case AF_UNIX:
- return real_socket(family, type, protocol);
- default:
- errno = EAFNOSUPPORT;
- return -1;
- }
-
- switch (type) {
- case SOCK_STREAM:
- break;
- case SOCK_DGRAM:
- break;
- default:
- errno = EPROTONOSUPPORT;
- return -1;
- }
-
- switch (protocol) {
- case 0:
- break;
- case 6:
- if (type == SOCK_STREAM) {
- break;
- }
- /*fall through*/
- case 17:
- if (type == SOCK_DGRAM) {
- break;
- }
- /*fall through*/
- default:
- errno = EPROTONOSUPPORT;
- return -1;
- }
-
- fd = real_socket(AF_UNIX, type, 0);
-
- if (fd == -1) return -1;
-
- si = (struct socket_info *)calloc(1, sizeof(struct socket_info));
-
- si->family = family;
- si->type = type;
- si->protocol = protocol;
- si->fd = fd;
-
- SWRAP_DLIST_ADD(sockets, si);
-
- return si->fd;
-}
-
-_PUBLIC_ int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
-{
- struct socket_info *parent_si, *child_si;
- int fd;
- struct sockaddr_un un_addr;
- socklen_t un_addrlen = sizeof(un_addr);
- struct sockaddr_un un_my_addr;
- socklen_t un_my_addrlen = sizeof(un_my_addr);
- struct sockaddr *my_addr;
- socklen_t my_addrlen, len;
- int ret;
-
- parent_si = find_socket_info(s);
- if (!parent_si) {
- return real_accept(s, addr, addrlen);
- }
-
- /*
- * assume out sockaddr have the same size as the in parent
- * socket family
- */
- my_addrlen = socket_length(parent_si->family);
- if (my_addrlen <= 0) {
- errno = EINVAL;
- return -1;
- }
-
- my_addr = (struct sockaddr *)malloc(my_addrlen);
- if (my_addr == NULL) {
- return -1;
- }
-
- memset(&un_addr, 0, sizeof(un_addr));
- memset(&un_my_addr, 0, sizeof(un_my_addr));
-
- ret = real_accept(s, (struct sockaddr *)&un_addr, &un_addrlen);
- if (ret == -1) {
- free(my_addr);
- return ret;
- }
-
- fd = ret;
-
- len = my_addrlen;
- ret = sockaddr_convert_from_un(parent_si, &un_addr, un_addrlen,
- parent_si->family, my_addr, &len);
- if (ret == -1) {
- free(my_addr);
- close(fd);
- return ret;
- }
-
- child_si = (struct socket_info *)malloc(sizeof(struct socket_info));
- memset(child_si, 0, sizeof(*child_si));
-
- child_si->fd = fd;
- child_si->family = parent_si->family;
- child_si->type = parent_si->type;
- child_si->protocol = parent_si->protocol;
- child_si->bound = 1;
- child_si->is_server = 1;
-
- child_si->peername_len = len;
- child_si->peername = sockaddr_dup(my_addr, len);
-
- if (addr != NULL && addrlen != NULL) {
- *addrlen = len;
- if (*addrlen >= len)
- memcpy(addr, my_addr, len);
- *addrlen = 0;
- }
-
- ret = real_getsockname(fd, (struct sockaddr *)&un_my_addr, &un_my_addrlen);
- if (ret == -1) {
- free(child_si);
- close(fd);
- return ret;
- }
-
- len = my_addrlen;
- ret = sockaddr_convert_from_un(child_si, &un_my_addr, un_my_addrlen,
- child_si->family, my_addr, &len);
- if (ret == -1) {
- free(child_si);
- free(my_addr);
- close(fd);
- return ret;
- }
-
- child_si->myname_len = len;
- child_si->myname = sockaddr_dup(my_addr, len);
- free(my_addr);
-
- SWRAP_DLIST_ADD(sockets, child_si);
-
- swrap_dump_packet(child_si, addr, SWRAP_ACCEPT_SEND, NULL, 0);
- swrap_dump_packet(child_si, addr, SWRAP_ACCEPT_RECV, NULL, 0);
- swrap_dump_packet(child_si, addr, SWRAP_ACCEPT_ACK, NULL, 0);
-
- return fd;
-}
-
-static int autobind_start_init;
-static int autobind_start;
-
-/* using sendto() or connect() on an unbound socket would give the
- recipient no way to reply, as unlike UDP and TCP, a unix domain
- socket can't auto-assign emphemeral port numbers, so we need to
- assign it here */
-static int swrap_auto_bind(struct socket_info *si)
-{
- struct sockaddr_un un_addr;
- int i;
- char type;
- int ret;
- int port;
- struct stat st;
-
- if (autobind_start_init != 1) {
- autobind_start_init = 1;
- autobind_start = getpid();
- autobind_start %= 50000;
- autobind_start += 10000;
- }
-
- un_addr.sun_family = AF_UNIX;
-
- switch (si->family) {
- case AF_INET: {
- struct sockaddr_in in;
-
- switch (si->type) {
- case SOCK_STREAM:
- type = SOCKET_TYPE_CHAR_TCP;
- break;
- case SOCK_DGRAM:
- type = SOCKET_TYPE_CHAR_UDP;
- break;
- default:
- errno = ESOCKTNOSUPPORT;
- return -1;
- }
-
- memset(&in, 0, sizeof(in));
- in.sin_family = AF_INET;
- in.sin_addr.s_addr = htonl(127<<24 |
- socket_wrapper_default_iface());
-
- si->myname_len = sizeof(in);
- si->myname = sockaddr_dup(&in, si->myname_len);
- break;
- }
-#ifdef HAVE_IPV6
- case AF_INET6: {
- struct sockaddr_in6 in6;
-
- switch (si->type) {
- case SOCK_STREAM:
- type = SOCKET_TYPE_CHAR_TCP_V6;
- break;
- case SOCK_DGRAM:
- type = SOCKET_TYPE_CHAR_UDP_V6;
- break;
- default:
- errno = ESOCKTNOSUPPORT;
- return -1;
- }
-
- memset(&in6, 0, sizeof(in6));
- in6.sin6_family = AF_INET6;
- in6.sin6_addr.s6_addr[0] = SW_IPV6_ADDRESS;
- si->myname_len = sizeof(in6);
- si->myname = sockaddr_dup(&in6, si->myname_len);
- break;
- }
-#endif
- default:
- errno = ESOCKTNOSUPPORT;
- return -1;
- }
-
- if (autobind_start > 60000) {
- autobind_start = 10000;
- }
-
- for (i=0;i<1000;i++) {
- port = autobind_start + i;
- snprintf(un_addr.sun_path, sizeof(un_addr.sun_path),
- "%s/"SOCKET_FORMAT, socket_wrapper_dir(),
- type, socket_wrapper_default_iface(), port);
- if (stat(un_addr.sun_path, &st) == 0) continue;
-
- ret = real_bind(si->fd, (struct sockaddr *)&un_addr, sizeof(un_addr));
- if (ret == -1) return ret;
-
- si->tmp_path = strdup(un_addr.sun_path);
- si->bound = 1;
- autobind_start = port + 1;
- break;
- }
- if (i == 1000) {
- errno = ENFILE;
- return -1;
- }
-
- set_port(si->family, port, si->myname);
-
- return 0;
-}
-
-
-_PUBLIC_ int swrap_connect(int s, const struct sockaddr *serv_addr, socklen_t addrlen)
-{
- int ret;
- struct sockaddr_un un_addr;
- struct socket_info *si = find_socket_info(s);
-
- if (!si) {
- return real_connect(s, serv_addr, addrlen);
- }
-
- if (si->bound == 0) {
- ret = swrap_auto_bind(si);
- if (ret == -1) return -1;
- }
-
- if (si->family != serv_addr->sa_family) {
- errno = EINVAL;
- return -1;
- }
-
- ret = sockaddr_convert_to_un(si, (const struct sockaddr *)serv_addr, addrlen, &un_addr, 0, NULL);
- if (ret == -1) return -1;
-
- swrap_dump_packet(si, serv_addr, SWRAP_CONNECT_SEND, NULL, 0);
-
- ret = real_connect(s, (struct sockaddr *)&un_addr,
- sizeof(struct sockaddr_un));
-
- /* to give better errors */
- if (ret == -1 && errno == ENOENT) {
- errno = EHOSTUNREACH;
- }
-
- if (ret == 0) {
- si->peername_len = addrlen;
- si->peername = sockaddr_dup(serv_addr, addrlen);
-
- swrap_dump_packet(si, serv_addr, SWRAP_CONNECT_RECV, NULL, 0);
- swrap_dump_packet(si, serv_addr, SWRAP_CONNECT_ACK, NULL, 0);
- } else {
- swrap_dump_packet(si, serv_addr, SWRAP_CONNECT_UNREACH, NULL, 0);
- }
-
- return ret;
-}
-
-_PUBLIC_ int swrap_bind(int s, const struct sockaddr *myaddr, socklen_t addrlen)
-{
- int ret;
- struct sockaddr_un un_addr;
- struct socket_info *si = find_socket_info(s);
-
- if (!si) {
- return real_bind(s, myaddr, addrlen);
- }
-
- si->myname_len = addrlen;
- si->myname = sockaddr_dup(myaddr, addrlen);
-
- ret = sockaddr_convert_to_un(si, (const struct sockaddr *)myaddr, addrlen, &un_addr, 1, &si->bcast);
- if (ret == -1) return -1;
-
- unlink(un_addr.sun_path);
-
- ret = real_bind(s, (struct sockaddr *)&un_addr,
- sizeof(struct sockaddr_un));
-
- if (ret == 0) {
- si->bound = 1;
- }
-
- return ret;
-}
-
-_PUBLIC_ int swrap_listen(int s, int backlog)
-{
- int ret;
- struct socket_info *si = find_socket_info(s);
-
- if (!si) {
- return real_listen(s, backlog);
- }
-
- ret = real_listen(s, backlog);
-
- return ret;
-}
-
-_PUBLIC_ int swrap_getpeername(int s, struct sockaddr *name, socklen_t *addrlen)
-{
- struct socket_info *si = find_socket_info(s);
-
- if (!si) {
- return real_getpeername(s, name, addrlen);
- }
-
- if (!si->peername)
- {
- errno = ENOTCONN;
- return -1;
- }
-
- memcpy(name, si->peername, si->peername_len);
- *addrlen = si->peername_len;
-
- return 0;
-}
-
-_PUBLIC_ int swrap_getsockname(int s, struct sockaddr *name, socklen_t *addrlen)
-{
- struct socket_info *si = find_socket_info(s);
-
- if (!si) {
- return real_getsockname(s, name, addrlen);
- }
-
- memcpy(name, si->myname, si->myname_len);
- *addrlen = si->myname_len;
-
- return 0;
-}
-
-_PUBLIC_ int swrap_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
-{
- struct socket_info *si = find_socket_info(s);
-
- if (!si) {
- return real_getsockopt(s, level, optname, optval, optlen);
- }
-
- if (level == SOL_SOCKET) {
- return real_getsockopt(s, level, optname, optval, optlen);
- }
-
- errno = ENOPROTOOPT;
- return -1;
-}
-
-_PUBLIC_ int swrap_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen)
-{
- struct socket_info *si = find_socket_info(s);
-
- if (!si) {
- return real_setsockopt(s, level, optname, optval, optlen);
- }
-
- if (level == SOL_SOCKET) {
- return real_setsockopt(s, level, optname, optval, optlen);
- }
-
- switch (si->family) {
- case AF_INET:
- return 0;
- default:
- errno = ENOPROTOOPT;
- return -1;
- }
-}
-
-_PUBLIC_ ssize_t swrap_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen)
-{
- struct sockaddr_un un_addr;
- socklen_t un_addrlen = sizeof(un_addr);
- int ret;
- struct socket_info *si = find_socket_info(s);
-
- if (!si) {
- return real_recvfrom(s, buf, len, flags, from, fromlen);
- }
-
- len = MIN(len, 1500);
-
- /* irix 6.4 forgets to null terminate the sun_path string :-( */
- memset(&un_addr, 0, sizeof(un_addr));
- ret = real_recvfrom(s, buf, len, flags, (struct sockaddr *)&un_addr, &un_addrlen);
- if (ret == -1)
- return ret;
-
- if (sockaddr_convert_from_un(si, &un_addr, un_addrlen,
- si->family, from, fromlen) == -1) {
- return -1;
- }
-
- swrap_dump_packet(si, from, SWRAP_RECVFROM, buf, ret);
-
- return ret;
-}
-
-
-_PUBLIC_ ssize_t swrap_sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen)
-{
- struct sockaddr_un un_addr;
- int ret;
- struct socket_info *si = find_socket_info(s);
- int bcast = 0;
-
- if (!si) {
- return real_sendto(s, buf, len, flags, to, tolen);
- }
-
- len = MIN(len, 1500);
-
- switch (si->type) {
- case SOCK_STREAM:
- ret = real_send(s, buf, len, flags);
- break;
- case SOCK_DGRAM:
- if (si->bound == 0) {
- ret = swrap_auto_bind(si);
- if (ret == -1) return -1;
- }
-
- ret = sockaddr_convert_to_un(si, to, tolen, &un_addr, 0, &bcast);
- if (ret == -1) return -1;
-
- if (bcast) {
- struct stat st;
- unsigned int iface;
- unsigned int prt = ntohs(((const struct sockaddr_in *)to)->sin_port);
- char type;
-
- type = SOCKET_TYPE_CHAR_UDP;
-
- for(iface=0; iface <= MAX_WRAPPED_INTERFACES; iface++) {
- snprintf(un_addr.sun_path, sizeof(un_addr.sun_path), "%s/"SOCKET_FORMAT,
- socket_wrapper_dir(), type, iface, prt);
- if (stat(un_addr.sun_path, &st) != 0) continue;
-
- /* ignore the any errors in broadcast sends */
- real_sendto(s, buf, len, flags, (struct sockaddr *)&un_addr, sizeof(un_addr));
- }
-
- swrap_dump_packet(si, to, SWRAP_SENDTO, buf, len);
-
- return len;
- }
-
- ret = real_sendto(s, buf, len, flags, (struct sockaddr *)&un_addr, sizeof(un_addr));
- break;
- default:
- ret = -1;
- errno = EHOSTUNREACH;
- break;
- }
-
- /* to give better errors */
- if (ret == -1 && errno == ENOENT) {
- errno = EHOSTUNREACH;
- }
-
- if (ret == -1) {
- swrap_dump_packet(si, to, SWRAP_SENDTO, buf, len);
- swrap_dump_packet(si, to, SWRAP_SENDTO_UNREACH, buf, len);
- } else {
- swrap_dump_packet(si, to, SWRAP_SENDTO, buf, ret);
- }
-
- return ret;
-}
-
-_PUBLIC_ int swrap_ioctl(int s, int r, void *p)
-{
- int ret;
- struct socket_info *si = find_socket_info(s);
- int value;
-
- if (!si) {
- return real_ioctl(s, r, p);
- }
-
- ret = real_ioctl(s, r, p);
-
- switch (r) {
- case FIONREAD:
- value = *((int *)p);
- if (ret == -1 && errno != EAGAIN && errno != ENOBUFS) {
- swrap_dump_packet(si, NULL, SWRAP_PENDING_RST, NULL, 0);
- } else if (value == 0) { /* END OF FILE */
- swrap_dump_packet(si, NULL, SWRAP_PENDING_RST, NULL, 0);
- }
- break;
- }
-
- return ret;
-}
-
-_PUBLIC_ ssize_t swrap_recv(int s, void *buf, size_t len, int flags)
-{
- int ret;
- struct socket_info *si = find_socket_info(s);
-
- if (!si) {
- return real_recv(s, buf, len, flags);
- }
-
- len = MIN(len, 1500);
-
- ret = real_recv(s, buf, len, flags);
- if (ret == -1 && errno != EAGAIN && errno != ENOBUFS) {
- swrap_dump_packet(si, NULL, SWRAP_RECV_RST, NULL, 0);
- } else if (ret == 0) { /* END OF FILE */
- swrap_dump_packet(si, NULL, SWRAP_RECV_RST, NULL, 0);
- } else {
- swrap_dump_packet(si, NULL, SWRAP_RECV, buf, ret);
- }
-
- return ret;
-}
-
-
-_PUBLIC_ ssize_t swrap_send(int s, const void *buf, size_t len, int flags)
-{
- int ret;
- struct socket_info *si = find_socket_info(s);
-
- if (!si) {
- return real_send(s, buf, len, flags);
- }
-
- len = MIN(len, 1500);
-
- ret = real_send(s, buf, len, flags);
-
- if (ret == -1) {
- swrap_dump_packet(si, NULL, SWRAP_SEND, buf, len);
- swrap_dump_packet(si, NULL, SWRAP_SEND_RST, NULL, 0);
- } else {
- swrap_dump_packet(si, NULL, SWRAP_SEND, buf, ret);
- }
-
- return ret;
-}
-
-_PUBLIC_ int swrap_close(int fd)
-{
- struct socket_info *si = find_socket_info(fd);
- int ret;
-
- if (!si) {
- return real_close(fd);
- }
-
- SWRAP_DLIST_REMOVE(sockets, si);
-
- if (si->myname && si->peername) {
- swrap_dump_packet(si, NULL, SWRAP_CLOSE_SEND, NULL, 0);
- }
-
- ret = real_close(fd);
-
- if (si->myname && si->peername) {
- swrap_dump_packet(si, NULL, SWRAP_CLOSE_RECV, NULL, 0);
- swrap_dump_packet(si, NULL, SWRAP_CLOSE_ACK, NULL, 0);
- }
-
- if (si->path) free(si->path);
- if (si->myname) free(si->myname);
- if (si->peername) free(si->peername);
- if (si->tmp_path) {
- unlink(si->tmp_path);
- free(si->tmp_path);
- }
- free(si);
-
- return ret;
-}
diff --git a/source4/lib/socket_wrapper/socket_wrapper.h b/source4/lib/socket_wrapper/socket_wrapper.h
deleted file mode 100644
index cc8b937608..0000000000
--- a/source4/lib/socket_wrapper/socket_wrapper.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) Jelmer Vernooij 2005 <jelmer@samba.org>
- * Copyright (C) Stefan Metzmacher 2006 <metze@samba.org>
- *
- * 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. Neither the name of the author nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- */
-
-#ifndef __SOCKET_WRAPPER_H__
-#define __SOCKET_WRAPPER_H__
-
-const char *socket_wrapper_dir(void);
-unsigned int socket_wrapper_default_iface(void);
-int swrap_socket(int family, int type, int protocol);
-int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
-int swrap_connect(int s, const struct sockaddr *serv_addr, socklen_t addrlen);
-int swrap_bind(int s, const struct sockaddr *myaddr, socklen_t addrlen);
-int swrap_listen(int s, int backlog);
-int swrap_getpeername(int s, struct sockaddr *name, socklen_t *addrlen);
-int swrap_getsockname(int s, struct sockaddr *name, socklen_t *addrlen);
-int swrap_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen);
-int swrap_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen);
-ssize_t swrap_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
-ssize_t swrap_sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen);
-int swrap_ioctl(int s, int req, void *ptr);
-ssize_t swrap_recv(int s, void *buf, size_t len, int flags);
-ssize_t swrap_send(int s, const void *buf, size_t len, int flags);
-int swrap_close(int);
-
-#ifdef SOCKET_WRAPPER_REPLACE
-
-#ifdef accept
-#undef accept
-#endif
-#define accept(s,addr,addrlen) swrap_accept(s,addr,addrlen)
-
-#ifdef connect
-#undef connect
-#endif
-#define connect(s,serv_addr,addrlen) swrap_connect(s,serv_addr,addrlen)
-
-#ifdef bind
-#undef bind
-#endif
-#define bind(s,myaddr,addrlen) swrap_bind(s,myaddr,addrlen)
-
-#ifdef listen
-#undef listen
-#endif
-#define listen(s,blog) swrap_listen(s,blog)
-
-#ifdef getpeername
-#undef getpeername
-#endif
-#define getpeername(s,name,addrlen) swrap_getpeername(s,name,addrlen)
-
-#ifdef getsockname
-#undef getsockname
-#endif
-#define getsockname(s,name,addrlen) swrap_getsockname(s,name,addrlen)
-
-#ifdef getsockopt
-#undef getsockopt
-#endif
-#define getsockopt(s,level,optname,optval,optlen) swrap_getsockopt(s,level,optname,optval,optlen)
-
-#ifdef setsockopt
-#undef setsockopt
-#endif
-#define setsockopt(s,level,optname,optval,optlen) swrap_setsockopt(s,level,optname,optval,optlen)
-
-#ifdef recvfrom
-#undef recvfrom
-#endif
-#define recvfrom(s,buf,len,flags,from,fromlen) swrap_recvfrom(s,buf,len,flags,from,fromlen)
-
-#ifdef sendto
-#undef sendto
-#endif
-#define sendto(s,buf,len,flags,to,tolen) swrap_sendto(s,buf,len,flags,to,tolen)
-
-#ifdef ioctl
-#undef ioctl
-#endif
-#define ioctl(s,req,ptr) swrap_ioctl(s,req,ptr)
-
-#ifdef recv
-#undef recv
-#endif
-#define recv(s,buf,len,flags) swrap_recv(s,buf,len,flags)
-
-#ifdef send
-#undef send
-#endif
-#define send(s,buf,len,flags) swrap_send(s,buf,len,flags)
-
-#ifdef socket
-#undef socket
-#endif
-#define socket(domain,type,protocol) swrap_socket(domain,type,protocol)
-
-#ifdef close
-#undef close
-#endif
-#define close(s) swrap_close(s)
-#endif
-
-
-#endif /* __SOCKET_WRAPPER_H__ */
diff --git a/source4/lib/socket_wrapper/testsuite.c b/source4/lib/socket_wrapper/testsuite.c
deleted file mode 100644
index 8877418e4c..0000000000
--- a/source4/lib/socket_wrapper/testsuite.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- local testing of the socket wrapper
-
- Copyright (C) Jelmer Vernooij 2007
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "system/network.h"
-#include "lib/socket_wrapper/socket_wrapper.h"
-#include "torture/torture.h"
-
-static char *old_dir = NULL;
-static char *old_iface = NULL;
-
-static void backup_env(void)
-{
- old_dir = getenv("SOCKET_WRAPPER_DIR");
- old_iface = getenv("SOCKET_WRAPPER_DEFAULT_IFACE");
-}
-
-static void restore_env(void)
-{
- if (old_dir == NULL)
- unsetenv("SOCKET_WRAPPER_DIR");
- else
- setenv("SOCKET_WRAPPER_DIR", old_dir, 1);
- if (old_iface == NULL)
- unsetenv("SOCKET_WRAPPER_DEFAULT_IFACE");
- else
- setenv("SOCKET_WRAPPER_DEFAULT_IFACE", old_iface, 1);
-}
-
-static bool test_socket_wrapper_dir(struct torture_context *tctx)
-{
- backup_env();
-
- setenv("SOCKET_WRAPPER_DIR", "foo", 1);
- torture_assert_str_equal(tctx, socket_wrapper_dir(), "foo", "setting failed");
- setenv("SOCKET_WRAPPER_DIR", "./foo", 1);
- torture_assert_str_equal(tctx, socket_wrapper_dir(), "foo", "setting failed");
- unsetenv("SOCKET_WRAPPER_DIR");
- torture_assert_str_equal(tctx, socket_wrapper_dir(), NULL, "resetting failed");
-
- restore_env();
-
- return true;
-}
-
-static bool test_swrap_socket(struct torture_context *tctx)
-{
- backup_env();
- setenv("SOCKET_WRAPPER_DIR", "foo", 1);
-
- torture_assert_int_equal(tctx, swrap_socket(1337, 1337, 0), -1, "unknown address family fails");
- torture_assert_int_equal(tctx, errno, EAFNOSUPPORT, "correct errno set");
- torture_assert_int_equal(tctx, swrap_socket(AF_INET, 1337, 0), -1, "unknown type fails");
- torture_assert_int_equal(tctx, errno, EPROTONOSUPPORT, "correct errno set");
- torture_assert_int_equal(tctx, swrap_socket(AF_INET, SOCK_DGRAM, 10), -1, "unknown protocol fails");
- torture_assert_int_equal(tctx, errno, EPROTONOSUPPORT, "correct errno set");
-
- restore_env();
-
- return true;
-}
-
-unsigned int socket_wrapper_default_iface(void);
-static bool test_socket_wrapper_default_iface(struct torture_context *tctx)
-{
- backup_env();
- unsetenv("SOCKET_WRAPPER_DEFAULT_IFACE");
- torture_assert_int_equal(tctx, socket_wrapper_default_iface(), 1, "unset");
- setenv("SOCKET_WRAPPER_DEFAULT_IFACE", "2", 1);
- torture_assert_int_equal(tctx, socket_wrapper_default_iface(), 2, "unset");
- setenv("SOCKET_WRAPPER_DEFAULT_IFACE", "bla", 1);
- torture_assert_int_equal(tctx, socket_wrapper_default_iface(), 1, "unset");
- restore_env();
- return true;
-}
-
-struct torture_suite *torture_local_socket_wrapper(TALLOC_CTX *mem_ctx)
-{
- struct torture_suite *suite = torture_suite_create(mem_ctx,
- "SOCKET-WRAPPER");
-
- torture_suite_add_simple_test(suite, "socket_wrapper_dir", test_socket_wrapper_dir);
- torture_suite_add_simple_test(suite, "socket", test_swrap_socket);
- torture_suite_add_simple_test(suite, "socket_wrapper_default_iface", test_socket_wrapper_default_iface);
-
- return suite;
-}
diff --git a/source4/lib/talloc/Makefile.in b/source4/lib/talloc/Makefile.in
deleted file mode 100644
index 07b8fd4ff0..0000000000
--- a/source4/lib/talloc/Makefile.in
+++ /dev/null
@@ -1,43 +0,0 @@
-#!gmake
-#
-prefix = @prefix@
-datarootdir = @datarootdir@
-exec_prefix = @exec_prefix@
-includedir = @includedir@
-libdir = @libdir@
-mandir = @mandir@
-VPATH = @srcdir@:@libreplacedir@
-srcdir = @srcdir@
-builddir = @builddir@
-XSLTPROC = @XSLTPROC@
-INSTALLCMD = @INSTALL@
-CC = @CC@
-CFLAGS = @CFLAGS@ -DHAVE_CONFIG_H= -I. -I@srcdir@
-EXTRA_TARGETS = @DOC_TARGET@
-PICFLAG = @PICFLAG@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-SHLIBEXT = @SHLIBEXT@
-SHLD = @SHLD@
-SHLD_FLAGS = @SHLD_FLAGS@
-tallocdir = @tallocdir@
-
-LIBOBJ = $(TALLOC_OBJ) @LIBREPLACEOBJ@
-
-all:: showflags $(EXTRA_TARGETS)
-
-include $(tallocdir)/rules.mk
-include $(tallocdir)/talloc.mk
-
-$(TALLOC_SOLIB): $(LIBOBJ)
- $(SHLD) $(SHLD_FLAGS) -o $@ $(LIBOBJ) @SONAMEFLAG@$(TALLOC_SONAME)
-
-check: test
-
-installcheck:: test install
-
-distclean:: clean
- rm -f Makefile
- rm -f config.log config.status config.h config.cache
-
-realdistclean:: distclean
- rm -f configure config.h.in
diff --git a/source4/lib/talloc/NEWS b/source4/lib/talloc/NEWS
deleted file mode 100644
index e5b3aa0731..0000000000
--- a/source4/lib/talloc/NEWS
+++ /dev/null
@@ -1,13 +0,0 @@
-1.0.1 26 May 2007
-
- BUGS
-
- * Set name of correctly when using talloc_append_string() (metze)
-
- LICENSE
-
- * Change license of files in lib/replace to LGPL (was GPL). (jelmer)
-
-1.0.0 30 April 2007
-
- Initial release.
diff --git a/source4/lib/talloc/aclocal.m4 b/source4/lib/talloc/aclocal.m4
deleted file mode 100644
index 5605e476ba..0000000000
--- a/source4/lib/talloc/aclocal.m4
+++ /dev/null
@@ -1 +0,0 @@
-m4_include(libreplace.m4)
diff --git a/source4/lib/talloc/autogen.sh b/source4/lib/talloc/autogen.sh
deleted file mode 100755
index bf84eeee19..0000000000
--- a/source4/lib/talloc/autogen.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-rm -rf autom4te.cache
-rm -f configure config.h.in
-
-IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace"
-autoconf $IPATHS || exit 1
-autoheader $IPATHS || exit 1
-
-rm -rf autom4te.cache
-
-echo "Now run ./configure and then make."
-exit 0
-
diff --git a/source4/lib/talloc/config.guess b/source4/lib/talloc/config.guess
deleted file mode 100755
index 354dbe175a..0000000000
--- a/source4/lib/talloc/config.guess
+++ /dev/null
@@ -1,1464 +0,0 @@
-#! /bin/sh
-# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2005-08-03'
-
-# This file is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Originally written by Per Bothner <per@bothner.com>.
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# This script attempts to guess a canonical system name similar to
-# config.sub. If it succeeds, it prints the system name on stdout, and
-# exits with 0. Otherwise, it exits with 1.
-#
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit build system type.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION]
-
-Output the configuration name of the system \`$me' is run on.
-
-Operation modes:
- -h, --help print this help, then exit
- -t, --time-stamp print date of last modification, then exit
- -v, --version print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.guess ($timestamp)
-
-Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
- case $1 in
- --time-stamp | --time* | -t )
- echo "$timestamp" ; exit ;;
- --version | -v )
- echo "$version" ; exit ;;
- --help | --h* | -h )
- echo "$usage"; exit ;;
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- echo "$me: invalid option $1$help" >&2
- exit 1 ;;
- * )
- break ;;
- esac
-done
-
-if test $# != 0; then
- echo "$me: too many arguments$help" >&2
- exit 1
-fi
-
-trap 'exit 1' 1 2 15
-
-# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
-# compiler to aid in system detection is discouraged as it requires
-# temporary files to be created and, as you can see below, it is a
-# headache to deal with in a portable fashion.
-
-# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
-# use `HOST_CC' if defined, but it is deprecated.
-
-# Portable tmp directory creation inspired by the Autoconf team.
-
-set_cc_for_build='
-trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
-trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
-: ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
-dummy=$tmp/dummy ;
-tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
-case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,) echo "int x;" > $dummy.c ;
- for c in cc gcc c89 c99 ; do
- if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
- CC_FOR_BUILD="$c"; break ;
- fi ;
- done ;
- if test x"$CC_FOR_BUILD" = x ; then
- CC_FOR_BUILD=no_compiler_found ;
- fi
- ;;
- ,,*) CC_FOR_BUILD=$CC ;;
- ,*,*) CC_FOR_BUILD=$HOST_CC ;;
-esac ; set_cc_for_build= ;'
-
-# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-# (ghazi@noc.rutgers.edu 1994-08-24)
-if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
- PATH=$PATH:/.attbin ; export PATH
-fi
-
-UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
-UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
-UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-
-# Note: order is significant - the case branches are not exclusive.
-
-case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
- *:NetBSD:*:*)
- # NetBSD (nbsd) targets should (where applicable) match one or
- # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
- # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
- # switched to ELF, *-*-netbsd* would select the old
- # object file format. This provides both forward
- # compatibility and a consistent mechanism for selecting the
- # object file format.
- #
- # Note: NetBSD doesn't particularly care about the vendor
- # portion of the name. We always set it to "unknown".
- sysctl="sysctl -n hw.machine_arch"
- UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
- /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
- case "${UNAME_MACHINE_ARCH}" in
- armeb) machine=armeb-unknown ;;
- arm*) machine=arm-unknown ;;
- sh3el) machine=shl-unknown ;;
- sh3eb) machine=sh-unknown ;;
- *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
- esac
- # The Operating System including object format, if it has switched
- # to ELF recently, or will in the future.
- case "${UNAME_MACHINE_ARCH}" in
- arm*|i386|m68k|ns32k|sh3*|sparc|vax)
- eval $set_cc_for_build
- if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
- | grep __ELF__ >/dev/null
- then
- # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
- # Return netbsd for either. FIX?
- os=netbsd
- else
- os=netbsdelf
- fi
- ;;
- *)
- os=netbsd
- ;;
- esac
- # The OS release
- # Debian GNU/NetBSD machines have a different userland, and
- # thus, need a distinct triplet. However, they do not need
- # kernel version information, so it can be replaced with a
- # suitable tag, in the style of linux-gnu.
- case "${UNAME_VERSION}" in
- Debian*)
- release='-gnu'
- ;;
- *)
- release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
- ;;
- esac
- # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
- # contains redundant information, the shorter form:
- # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
- echo "${machine}-${os}${release}"
- exit ;;
- *:OpenBSD:*:*)
- UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
- echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
- exit ;;
- *:ekkoBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
- exit ;;
- macppc:MirBSD:*:*)
- echo powerppc-unknown-mirbsd${UNAME_RELEASE}
- exit ;;
- *:MirBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
- exit ;;
- alpha:OSF1:*:*)
- case $UNAME_RELEASE in
- *4.0)
- UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
- ;;
- *5.*)
- UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
- ;;
- esac
- # According to Compaq, /usr/sbin/psrinfo has been available on
- # OSF/1 and Tru64 systems produced since 1995. I hope that
- # covers most systems running today. This code pipes the CPU
- # types through head -n 1, so we only detect the type of CPU 0.
- ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
- case "$ALPHA_CPU_TYPE" in
- "EV4 (21064)")
- UNAME_MACHINE="alpha" ;;
- "EV4.5 (21064)")
- UNAME_MACHINE="alpha" ;;
- "LCA4 (21066/21068)")
- UNAME_MACHINE="alpha" ;;
- "EV5 (21164)")
- UNAME_MACHINE="alphaev5" ;;
- "EV5.6 (21164A)")
- UNAME_MACHINE="alphaev56" ;;
- "EV5.6 (21164PC)")
- UNAME_MACHINE="alphapca56" ;;
- "EV5.7 (21164PC)")
- UNAME_MACHINE="alphapca57" ;;
- "EV6 (21264)")
- UNAME_MACHINE="alphaev6" ;;
- "EV6.7 (21264A)")
- UNAME_MACHINE="alphaev67" ;;
- "EV6.8CB (21264C)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.8AL (21264B)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.8CX (21264D)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.9A (21264/EV69A)")
- UNAME_MACHINE="alphaev69" ;;
- "EV7 (21364)")
- UNAME_MACHINE="alphaev7" ;;
- "EV7.9 (21364A)")
- UNAME_MACHINE="alphaev79" ;;
- esac
- # A Pn.n version is a patched version.
- # A Vn.n version is a released version.
- # A Tn.n version is a released field test version.
- # A Xn.n version is an unreleased experimental baselevel.
- # 1.2 uses "1.2" for uname -r.
- echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- exit ;;
- Alpha\ *:Windows_NT*:*)
- # How do we know it's Interix rather than the generic POSIX subsystem?
- # Should we change UNAME_MACHINE based on the output of uname instead
- # of the specific Alpha model?
- echo alpha-pc-interix
- exit ;;
- 21064:Windows_NT:50:3)
- echo alpha-dec-winnt3.5
- exit ;;
- Amiga*:UNIX_System_V:4.0:*)
- echo m68k-unknown-sysv4
- exit ;;
- *:[Aa]miga[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-amigaos
- exit ;;
- *:[Mm]orph[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-morphos
- exit ;;
- *:OS/390:*:*)
- echo i370-ibm-openedition
- exit ;;
- *:z/VM:*:*)
- echo s390-ibm-zvmoe
- exit ;;
- *:OS400:*:*)
- echo powerpc-ibm-os400
- exit ;;
- arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
- echo arm-acorn-riscix${UNAME_RELEASE}
- exit ;;
- arm:riscos:*:*|arm:RISCOS:*:*)
- echo arm-unknown-riscos
- exit ;;
- SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
- echo hppa1.1-hitachi-hiuxmpp
- exit ;;
- Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
- # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
- if test "`(/bin/universe) 2>/dev/null`" = att ; then
- echo pyramid-pyramid-sysv3
- else
- echo pyramid-pyramid-bsd
- fi
- exit ;;
- NILE*:*:*:dcosx)
- echo pyramid-pyramid-svr4
- exit ;;
- DRS?6000:unix:4.0:6*)
- echo sparc-icl-nx6
- exit ;;
- DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
- case `/usr/bin/uname -p` in
- sparc) echo sparc-icl-nx7; exit ;;
- esac ;;
- sun4H:SunOS:5.*:*)
- echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
- echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- i86pc:SunOS:5.*:*)
- echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:6*:*)
- # According to config.sub, this is the proper way to canonicalize
- # SunOS6. Hard to guess exactly what SunOS6 will be like, but
- # it's likely to be more like Solaris than SunOS4.
- echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:*:*)
- case "`/usr/bin/arch -k`" in
- Series*|S4*)
- UNAME_RELEASE=`uname -v`
- ;;
- esac
- # Japanese Language versions have a version number like `4.1.3-JL'.
- echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
- exit ;;
- sun3*:SunOS:*:*)
- echo m68k-sun-sunos${UNAME_RELEASE}
- exit ;;
- sun*:*:4.2BSD:*)
- UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
- test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
- case "`/bin/arch`" in
- sun3)
- echo m68k-sun-sunos${UNAME_RELEASE}
- ;;
- sun4)
- echo sparc-sun-sunos${UNAME_RELEASE}
- ;;
- esac
- exit ;;
- aushp:SunOS:*:*)
- echo sparc-auspex-sunos${UNAME_RELEASE}
- exit ;;
- # The situation for MiNT is a little confusing. The machine name
- # can be virtually everything (everything which is not
- # "atarist" or "atariste" at least should have a processor
- # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
- # to the lowercase version "mint" (or "freemint"). Finally
- # the system name "TOS" denotes a system which is actually not
- # MiNT. But MiNT is downward compatible to TOS, so this should
- # be no problem.
- atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
- echo m68k-milan-mint${UNAME_RELEASE}
- exit ;;
- hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
- echo m68k-hades-mint${UNAME_RELEASE}
- exit ;;
- *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
- echo m68k-unknown-mint${UNAME_RELEASE}
- exit ;;
- m68k:machten:*:*)
- echo m68k-apple-machten${UNAME_RELEASE}
- exit ;;
- powerpc:machten:*:*)
- echo powerpc-apple-machten${UNAME_RELEASE}
- exit ;;
- RISC*:Mach:*:*)
- echo mips-dec-mach_bsd4.3
- exit ;;
- RISC*:ULTRIX:*:*)
- echo mips-dec-ultrix${UNAME_RELEASE}
- exit ;;
- VAX*:ULTRIX*:*:*)
- echo vax-dec-ultrix${UNAME_RELEASE}
- exit ;;
- 2020:CLIX:*:* | 2430:CLIX:*:*)
- echo clipper-intergraph-clix${UNAME_RELEASE}
- exit ;;
- mips:*:*:UMIPS | mips:*:*:RISCos)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
-#ifdef __cplusplus
-#include <stdio.h> /* for printf() prototype */
- int main (int argc, char *argv[]) {
-#else
- int main (argc, argv) int argc; char *argv[]; {
-#endif
- #if defined (host_mips) && defined (MIPSEB)
- #if defined (SYSTYPE_SYSV)
- printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
- #endif
- #if defined (SYSTYPE_SVR4)
- printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
- #endif
- #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
- printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
- #endif
- #endif
- exit (-1);
- }
-EOF
- $CC_FOR_BUILD -o $dummy $dummy.c &&
- dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
- SYSTEM_NAME=`$dummy $dummyarg` &&
- { echo "$SYSTEM_NAME"; exit; }
- echo mips-mips-riscos${UNAME_RELEASE}
- exit ;;
- Motorola:PowerMAX_OS:*:*)
- echo powerpc-motorola-powermax
- exit ;;
- Motorola:*:4.3:PL8-*)
- echo powerpc-harris-powermax
- exit ;;
- Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
- echo powerpc-harris-powermax
- exit ;;
- Night_Hawk:Power_UNIX:*:*)
- echo powerpc-harris-powerunix
- exit ;;
- m88k:CX/UX:7*:*)
- echo m88k-harris-cxux7
- exit ;;
- m88k:*:4*:R4*)
- echo m88k-motorola-sysv4
- exit ;;
- m88k:*:3*:R3*)
- echo m88k-motorola-sysv3
- exit ;;
- AViiON:dgux:*:*)
- # DG/UX returns AViiON for all architectures
- UNAME_PROCESSOR=`/usr/bin/uname -p`
- if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
- then
- if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
- [ ${TARGET_BINARY_INTERFACE}x = x ]
- then
- echo m88k-dg-dgux${UNAME_RELEASE}
- else
- echo m88k-dg-dguxbcs${UNAME_RELEASE}
- fi
- else
- echo i586-dg-dgux${UNAME_RELEASE}
- fi
- exit ;;
- M88*:DolphinOS:*:*) # DolphinOS (SVR3)
- echo m88k-dolphin-sysv3
- exit ;;
- M88*:*:R3*:*)
- # Delta 88k system running SVR3
- echo m88k-motorola-sysv3
- exit ;;
- XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
- echo m88k-tektronix-sysv3
- exit ;;
- Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
- echo m68k-tektronix-bsd
- exit ;;
- *:IRIX*:*:*)
- echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
- exit ;;
- ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
- echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
- exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
- i*86:AIX:*:*)
- echo i386-ibm-aix
- exit ;;
- ia64:AIX:*:*)
- if [ -x /usr/bin/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
- else
- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
- fi
- echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
- exit ;;
- *:AIX:2:3)
- if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <sys/systemcfg.h>
-
- main()
- {
- if (!__power_pc())
- exit(1);
- puts("powerpc-ibm-aix3.2.5");
- exit(0);
- }
-EOF
- if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
- then
- echo "$SYSTEM_NAME"
- else
- echo rs6000-ibm-aix3.2.5
- fi
- elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
- echo rs6000-ibm-aix3.2.4
- else
- echo rs6000-ibm-aix3.2
- fi
- exit ;;
- *:AIX:*:[45])
- IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
- if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
- IBM_ARCH=rs6000
- else
- IBM_ARCH=powerpc
- fi
- if [ -x /usr/bin/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
- else
- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
- fi
- echo ${IBM_ARCH}-ibm-aix${IBM_REV}
- exit ;;
- *:AIX:*:*)
- echo rs6000-ibm-aix
- exit ;;
- ibmrt:4.4BSD:*|romp-ibm:BSD:*)
- echo romp-ibm-bsd4.4
- exit ;;
- ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
- echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
- exit ;; # report: romp-ibm BSD 4.3
- *:BOSX:*:*)
- echo rs6000-bull-bosx
- exit ;;
- DPX/2?00:B.O.S.:*:*)
- echo m68k-bull-sysv3
- exit ;;
- 9000/[34]??:4.3bsd:1.*:*)
- echo m68k-hp-bsd
- exit ;;
- hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
- echo m68k-hp-bsd4.4
- exit ;;
- 9000/[34678]??:HP-UX:*:*)
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- case "${UNAME_MACHINE}" in
- 9000/31? ) HP_ARCH=m68000 ;;
- 9000/[34]?? ) HP_ARCH=m68k ;;
- 9000/[678][0-9][0-9])
- if [ -x /usr/bin/getconf ]; then
- sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
- sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
- case "${sc_cpu_version}" in
- 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
- 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
- 532) # CPU_PA_RISC2_0
- case "${sc_kernel_bits}" in
- 32) HP_ARCH="hppa2.0n" ;;
- 64) HP_ARCH="hppa2.0w" ;;
- '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
- esac ;;
- esac
- fi
- if [ "${HP_ARCH}" = "" ]; then
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
-
- #define _HPUX_SOURCE
- #include <stdlib.h>
- #include <unistd.h>
-
- int main ()
- {
- #if defined(_SC_KERNEL_BITS)
- long bits = sysconf(_SC_KERNEL_BITS);
- #endif
- long cpu = sysconf (_SC_CPU_VERSION);
-
- switch (cpu)
- {
- case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
- case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
- case CPU_PA_RISC2_0:
- #if defined(_SC_KERNEL_BITS)
- switch (bits)
- {
- case 64: puts ("hppa2.0w"); break;
- case 32: puts ("hppa2.0n"); break;
- default: puts ("hppa2.0"); break;
- } break;
- #else /* !defined(_SC_KERNEL_BITS) */
- puts ("hppa2.0"); break;
- #endif
- default: puts ("hppa1.0"); break;
- }
- exit (0);
- }
-EOF
- (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
- test -z "$HP_ARCH" && HP_ARCH=hppa
- fi ;;
- esac
- if [ ${HP_ARCH} = "hppa2.0w" ]
- then
- eval $set_cc_for_build
-
- # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
- # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
- # generating 64-bit code. GNU and HP use different nomenclature:
- #
- # $ CC_FOR_BUILD=cc ./config.guess
- # => hppa2.0w-hp-hpux11.23
- # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
- # => hppa64-hp-hpux11.23
-
- if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
- grep __LP64__ >/dev/null
- then
- HP_ARCH="hppa2.0w"
- else
- HP_ARCH="hppa64"
- fi
- fi
- echo ${HP_ARCH}-hp-hpux${HPUX_REV}
- exit ;;
- ia64:HP-UX:*:*)
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- echo ia64-hp-hpux${HPUX_REV}
- exit ;;
- 3050*:HI-UX:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <unistd.h>
- int
- main ()
- {
- long cpu = sysconf (_SC_CPU_VERSION);
- /* The order matters, because CPU_IS_HP_MC68K erroneously returns
- true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
- results, however. */
- if (CPU_IS_PA_RISC (cpu))
- {
- switch (cpu)
- {
- case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
- case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
- case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
- default: puts ("hppa-hitachi-hiuxwe2"); break;
- }
- }
- else if (CPU_IS_HP_MC68K (cpu))
- puts ("m68k-hitachi-hiuxwe2");
- else puts ("unknown-hitachi-hiuxwe2");
- exit (0);
- }
-EOF
- $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
- { echo "$SYSTEM_NAME"; exit; }
- echo unknown-hitachi-hiuxwe2
- exit ;;
- 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
- echo hppa1.1-hp-bsd
- exit ;;
- 9000/8??:4.3bsd:*:*)
- echo hppa1.0-hp-bsd
- exit ;;
- *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
- echo hppa1.0-hp-mpeix
- exit ;;
- hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
- echo hppa1.1-hp-osf
- exit ;;
- hp8??:OSF1:*:*)
- echo hppa1.0-hp-osf
- exit ;;
- i*86:OSF1:*:*)
- if [ -x /usr/sbin/sysversion ] ; then
- echo ${UNAME_MACHINE}-unknown-osf1mk
- else
- echo ${UNAME_MACHINE}-unknown-osf1
- fi
- exit ;;
- parisc*:Lites*:*:*)
- echo hppa1.1-hp-lites
- exit ;;
- C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
- echo c1-convex-bsd
- exit ;;
- C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit ;;
- C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
- echo c34-convex-bsd
- exit ;;
- C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
- echo c38-convex-bsd
- exit ;;
- C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
- echo c4-convex-bsd
- exit ;;
- CRAY*Y-MP:*:*:*)
- echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*[A-Z]90:*:*:*)
- echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
- | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
- -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
- -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*TS:*:*:*)
- echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*T3E:*:*:*)
- echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*SV1:*:*:*)
- echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- *:UNICOS/mp:*:*)
- echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
- FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
- echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
- 5000:UNIX_System_V:4.*:*)
- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
- echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
- i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
- echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
- exit ;;
- sparc*:BSD/OS:*:*)
- echo sparc-unknown-bsdi${UNAME_RELEASE}
- exit ;;
- *:BSD/OS:*:*)
- echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
- exit ;;
- *:FreeBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit ;;
- i*:CYGWIN*:*)
- echo ${UNAME_MACHINE}-pc-cygwin
- exit ;;
- i*:MINGW*:*)
- echo ${UNAME_MACHINE}-pc-mingw32
- exit ;;
- i*:windows32*:*)
- # uname -m includes "-pc" on this system.
- echo ${UNAME_MACHINE}-mingw32
- exit ;;
- i*:PW*:*)
- echo ${UNAME_MACHINE}-pc-pw32
- exit ;;
- x86:Interix*:[34]*)
- echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
- exit ;;
- [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
- echo i${UNAME_MACHINE}-pc-mks
- exit ;;
- i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
- # How do we know it's Interix rather than the generic POSIX subsystem?
- # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
- # UNAME_MACHINE based on the output of uname instead of i386?
- echo i586-pc-interix
- exit ;;
- i*:UWIN*:*)
- echo ${UNAME_MACHINE}-pc-uwin
- exit ;;
- amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
- echo x86_64-unknown-cygwin
- exit ;;
- p*:CYGWIN*:*)
- echo powerpcle-unknown-cygwin
- exit ;;
- prep*:SunOS:5.*:*)
- echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- *:GNU:*:*)
- # the GNU system
- echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
- exit ;;
- *:GNU/*:*:*)
- # other systems with GNU libc and userland
- echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
- exit ;;
- i*86:Minix:*:*)
- echo ${UNAME_MACHINE}-pc-minix
- exit ;;
- arm*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- cris:Linux:*:*)
- echo cris-axis-linux-gnu
- exit ;;
- crisv32:Linux:*:*)
- echo crisv32-axis-linux-gnu
- exit ;;
- frv:Linux:*:*)
- echo frv-unknown-linux-gnu
- exit ;;
- ia64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- m32r*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- m68*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- mips:Linux:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #undef CPU
- #undef mips
- #undef mipsel
- #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mipsel
- #else
- #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips
- #else
- CPU=
- #endif
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
- ;;
- mips64:Linux:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #undef CPU
- #undef mips64
- #undef mips64el
- #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mips64el
- #else
- #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips64
- #else
- CPU=
- #endif
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
- ;;
- or32:Linux:*:*)
- echo or32-unknown-linux-gnu
- exit ;;
- ppc:Linux:*:*)
- echo powerpc-unknown-linux-gnu
- exit ;;
- ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-gnu
- exit ;;
- alpha:Linux:*:*)
- case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
- EV5) UNAME_MACHINE=alphaev5 ;;
- EV56) UNAME_MACHINE=alphaev56 ;;
- PCA56) UNAME_MACHINE=alphapca56 ;;
- PCA57) UNAME_MACHINE=alphapca56 ;;
- EV6) UNAME_MACHINE=alphaev6 ;;
- EV67) UNAME_MACHINE=alphaev67 ;;
- EV68*) UNAME_MACHINE=alphaev68 ;;
- esac
- objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
- if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
- exit ;;
- parisc:Linux:*:* | hppa:Linux:*:*)
- # Look for CPU level
- case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
- PA7*) echo hppa1.1-unknown-linux-gnu ;;
- PA8*) echo hppa2.0-unknown-linux-gnu ;;
- *) echo hppa-unknown-linux-gnu ;;
- esac
- exit ;;
- parisc64:Linux:*:* | hppa64:Linux:*:*)
- echo hppa64-unknown-linux-gnu
- exit ;;
- s390:Linux:*:* | s390x:Linux:*:*)
- echo ${UNAME_MACHINE}-ibm-linux
- exit ;;
- sh64*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- sh*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- sparc:Linux:*:* | sparc64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- x86_64:Linux:*:*)
- echo x86_64-unknown-linux-gnu
- exit ;;
- i*86:Linux:*:*)
- # The BFD linker knows what the default object file format is, so
- # first see if it will tell us. cd to the root directory to prevent
- # problems with other programs or directories called `ld' in the path.
- # Set LC_ALL=C to ensure ld outputs messages in English.
- ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
- | sed -ne '/supported targets:/!d
- s/[ ][ ]*/ /g
- s/.*supported targets: *//
- s/ .*//
- p'`
- case "$ld_supported_targets" in
- elf32-i386)
- TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
- ;;
- a.out-i386-linux)
- echo "${UNAME_MACHINE}-pc-linux-gnuaout"
- exit ;;
- coff-i386)
- echo "${UNAME_MACHINE}-pc-linux-gnucoff"
- exit ;;
- "")
- # Either a pre-BFD a.out linker (linux-gnuoldld) or
- # one that does not give us useful --help.
- echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
- exit ;;
- esac
- # Determine whether the default compiler is a.out or elf
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <features.h>
- #ifdef __ELF__
- # ifdef __GLIBC__
- # if __GLIBC__ >= 2
- LIBC=gnu
- # else
- LIBC=gnulibc1
- # endif
- # else
- LIBC=gnulibc1
- # endif
- #else
- #ifdef __INTEL_COMPILER
- LIBC=gnu
- #else
- LIBC=gnuaout
- #endif
- #endif
- #ifdef __dietlibc__
- LIBC=dietlibc
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
- test x"${LIBC}" != x && {
- echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
- exit
- }
- test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
- ;;
- i*86:DYNIX/ptx:4*:*)
- # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
- # earlier versions are messed up and put the nodename in both
- # sysname and nodename.
- echo i386-sequent-sysv4
- exit ;;
- i*86:UNIX_SV:4.2MP:2.*)
- # Unixware is an offshoot of SVR4, but it has its own version
- # number series starting with 2...
- # I am not positive that other SVR4 systems won't match this,
- # I just have to hope. -- rms.
- # Use sysv4.2uw... so that sysv4* matches it.
- echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
- exit ;;
- i*86:OS/2:*:*)
- # If we were able to find `uname', then EMX Unix compatibility
- # is probably installed.
- echo ${UNAME_MACHINE}-pc-os2-emx
- exit ;;
- i*86:XTS-300:*:STOP)
- echo ${UNAME_MACHINE}-unknown-stop
- exit ;;
- i*86:atheos:*:*)
- echo ${UNAME_MACHINE}-unknown-atheos
- exit ;;
- i*86:syllable:*:*)
- echo ${UNAME_MACHINE}-pc-syllable
- exit ;;
- i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
- echo i386-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- i*86:*DOS:*:*)
- echo ${UNAME_MACHINE}-pc-msdosdjgpp
- exit ;;
- i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
- UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
- if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
- echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
- else
- echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
- fi
- exit ;;
- i*86:*:5:[678]*)
- # UnixWare 7.x, OpenUNIX and OpenServer 6.
- case `/bin/uname -X | grep "^Machine"` in
- *486*) UNAME_MACHINE=i486 ;;
- *Pentium) UNAME_MACHINE=i586 ;;
- *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
- esac
- echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
- exit ;;
- i*86:*:3.2:*)
- if test -f /usr/options/cb.name; then
- UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
- echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
- elif /bin/uname -X 2>/dev/null >/dev/null ; then
- UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
- (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
- (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
- && UNAME_MACHINE=i586
- (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
- && UNAME_MACHINE=i686
- (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
- && UNAME_MACHINE=i686
- echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
- else
- echo ${UNAME_MACHINE}-pc-sysv32
- fi
- exit ;;
- pc:*:*:*)
- # Left here for compatibility:
- # uname -m prints for DJGPP always 'pc', but it prints nothing about
- # the processor, so we play safe by assuming i386.
- echo i386-pc-msdosdjgpp
- exit ;;
- Intel:Mach:3*:*)
- echo i386-pc-mach3
- exit ;;
- paragon:*:*:*)
- echo i860-intel-osf1
- exit ;;
- i860:*:4.*:*) # i860-SVR4
- if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
- echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
- else # Add other i860-SVR4 vendors below as they are discovered.
- echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
- fi
- exit ;;
- mini*:CTIX:SYS*5:*)
- # "miniframe"
- echo m68010-convergent-sysv
- exit ;;
- mc68k:UNIX:SYSTEM5:3.51m)
- echo m68k-convergent-sysv
- exit ;;
- M680?0:D-NIX:5.3:*)
- echo m68k-diab-dnix
- exit ;;
- M68*:*:R3V[5678]*:*)
- test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
- 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
- OS_REL=''
- test -r /etc/.relid \
- && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
- /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
- /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
- && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
- 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
- /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && { echo i486-ncr-sysv4; exit; } ;;
- m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
- echo m68k-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- mc68030:UNIX_System_V:4.*:*)
- echo m68k-atari-sysv4
- exit ;;
- TSUNAMI:LynxOS:2.*:*)
- echo sparc-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- rs6000:LynxOS:2.*:*)
- echo rs6000-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
- echo powerpc-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- SM[BE]S:UNIX_SV:*:*)
- echo mips-dde-sysv${UNAME_RELEASE}
- exit ;;
- RM*:ReliantUNIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
- RM*:SINIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
- *:SINIX-*:*:*)
- if uname -p 2>/dev/null >/dev/null ; then
- UNAME_MACHINE=`(uname -p) 2>/dev/null`
- echo ${UNAME_MACHINE}-sni-sysv4
- else
- echo ns32k-sni-sysv
- fi
- exit ;;
- PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
- # says <Richard.M.Bartel@ccMail.Census.GOV>
- echo i586-unisys-sysv4
- exit ;;
- *:UNIX_System_V:4*:FTX*)
- # From Gerald Hewes <hewes@openmarket.com>.
- # How about differentiating between stratus architectures? -djm
- echo hppa1.1-stratus-sysv4
- exit ;;
- *:*:*:FTX*)
- # From seanf@swdc.stratus.com.
- echo i860-stratus-sysv4
- exit ;;
- i*86:VOS:*:*)
- # From Paul.Green@stratus.com.
- echo ${UNAME_MACHINE}-stratus-vos
- exit ;;
- *:VOS:*:*)
- # From Paul.Green@stratus.com.
- echo hppa1.1-stratus-vos
- exit ;;
- mc68*:A/UX:*:*)
- echo m68k-apple-aux${UNAME_RELEASE}
- exit ;;
- news*:NEWS-OS:6*:*)
- echo mips-sony-newsos6
- exit ;;
- R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
- if [ -d /usr/nec ]; then
- echo mips-nec-sysv${UNAME_RELEASE}
- else
- echo mips-unknown-sysv${UNAME_RELEASE}
- fi
- exit ;;
- BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
- echo powerpc-be-beos
- exit ;;
- BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
- echo powerpc-apple-beos
- exit ;;
- BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
- echo i586-pc-beos
- exit ;;
- SX-4:SUPER-UX:*:*)
- echo sx4-nec-superux${UNAME_RELEASE}
- exit ;;
- SX-5:SUPER-UX:*:*)
- echo sx5-nec-superux${UNAME_RELEASE}
- exit ;;
- SX-6:SUPER-UX:*:*)
- echo sx6-nec-superux${UNAME_RELEASE}
- exit ;;
- Power*:Rhapsody:*:*)
- echo powerpc-apple-rhapsody${UNAME_RELEASE}
- exit ;;
- *:Rhapsody:*:*)
- echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
- exit ;;
- *:Darwin:*:*)
- UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
- case $UNAME_PROCESSOR in
- *86) UNAME_PROCESSOR=i686 ;;
- unknown) UNAME_PROCESSOR=powerpc ;;
- esac
- echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
- exit ;;
- *:procnto*:*:* | *:QNX:[0123456789]*:*)
- UNAME_PROCESSOR=`uname -p`
- if test "$UNAME_PROCESSOR" = "x86"; then
- UNAME_PROCESSOR=i386
- UNAME_MACHINE=pc
- fi
- echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
- exit ;;
- *:QNX:*:4*)
- echo i386-pc-qnx
- exit ;;
- NSE-?:NONSTOP_KERNEL:*:*)
- echo nse-tandem-nsk${UNAME_RELEASE}
- exit ;;
- NSR-?:NONSTOP_KERNEL:*:*)
- echo nsr-tandem-nsk${UNAME_RELEASE}
- exit ;;
- *:NonStop-UX:*:*)
- echo mips-compaq-nonstopux
- exit ;;
- BS2000:POSIX*:*:*)
- echo bs2000-siemens-sysv
- exit ;;
- DS/*:UNIX_System_V:*:*)
- echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
- exit ;;
- *:Plan9:*:*)
- # "uname -m" is not consistent, so use $cputype instead. 386
- # is converted to i386 for consistency with other x86
- # operating systems.
- if test "$cputype" = "386"; then
- UNAME_MACHINE=i386
- else
- UNAME_MACHINE="$cputype"
- fi
- echo ${UNAME_MACHINE}-unknown-plan9
- exit ;;
- *:TOPS-10:*:*)
- echo pdp10-unknown-tops10
- exit ;;
- *:TENEX:*:*)
- echo pdp10-unknown-tenex
- exit ;;
- KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
- echo pdp10-dec-tops20
- exit ;;
- XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
- echo pdp10-xkl-tops20
- exit ;;
- *:TOPS-20:*:*)
- echo pdp10-unknown-tops20
- exit ;;
- *:ITS:*:*)
- echo pdp10-unknown-its
- exit ;;
- SEI:*:*:SEIUX)
- echo mips-sei-seiux${UNAME_RELEASE}
- exit ;;
- *:DragonFly:*:*)
- echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit ;;
- *:*VMS:*:*)
- UNAME_MACHINE=`(uname -p) 2>/dev/null`
- case "${UNAME_MACHINE}" in
- A*) echo alpha-dec-vms ; exit ;;
- I*) echo ia64-dec-vms ; exit ;;
- V*) echo vax-dec-vms ; exit ;;
- esac ;;
- *:XENIX:*:SysV)
- echo i386-pc-xenix
- exit ;;
- i*86:skyos:*:*)
- echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
- exit ;;
-esac
-
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
- /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
- I don't know.... */
- printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
- printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
- "4"
-#else
- ""
-#endif
- ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
- printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
- printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
- int version;
- version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
- if (version < 4)
- printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
- else
- printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
- exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
- printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
- printf ("ns32k-encore-mach\n"); exit (0);
-#else
- printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
- printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
- printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
- printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
- struct utsname un;
-
- uname(&un);
-
- if (strncmp(un.version, "V2", 2) == 0) {
- printf ("i386-sequent-ptx2\n"); exit (0);
- }
- if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
- printf ("i386-sequent-ptx1\n"); exit (0);
- }
- printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-# include <sys/param.h>
-# if defined (BSD)
-# if BSD == 43
- printf ("vax-dec-bsd4.3\n"); exit (0);
-# else
-# if BSD == 199006
- printf ("vax-dec-bsd4.3reno\n"); exit (0);
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# endif
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# else
- printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
- printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
- exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
- { echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
- case `getsysinfo -f cpu_type` in
- c1*)
- echo c1-convex-bsd
- exit ;;
- c2*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit ;;
- c34*)
- echo c34-convex-bsd
- exit ;;
- c38*)
- echo c38-convex-bsd
- exit ;;
- c4*)
- echo c4-convex-bsd
- exit ;;
- esac
-fi
-
-cat >&2 <<EOF
-$0: unable to guess system type
-
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
-
- http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
-and
- http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
-
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
-
-config.guess timestamp = $timestamp
-
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
-/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
-
-hostinfo = `(hostinfo) 2>/dev/null`
-/bin/universe = `(/bin/universe) 2>/dev/null`
-/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
-/bin/arch = `(/bin/arch) 2>/dev/null`
-/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
-
-UNAME_MACHINE = ${UNAME_MACHINE}
-UNAME_RELEASE = ${UNAME_RELEASE}
-UNAME_SYSTEM = ${UNAME_SYSTEM}
-UNAME_VERSION = ${UNAME_VERSION}
-EOF
-
-exit 1
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/source4/lib/talloc/config.mk b/source4/lib/talloc/config.mk
deleted file mode 100644
index c13e1b79ab..0000000000
--- a/source4/lib/talloc/config.mk
+++ /dev/null
@@ -1,7 +0,0 @@
-[LIBRARY::LIBTALLOC]
-OUTPUT_TYPE = MERGED_OBJ
-CFLAGS = -Ilib/talloc
-
-LIBTALLOC_OBJ_FILES = lib/talloc/talloc.o
-
-MANPAGES += $(tallocdir)/talloc.3
diff --git a/source4/lib/talloc/config.sub b/source4/lib/talloc/config.sub
deleted file mode 100755
index 23cd6fd75c..0000000000
--- a/source4/lib/talloc/config.sub
+++ /dev/null
@@ -1,1577 +0,0 @@
-#! /bin/sh
-# Configuration validation subroutine script.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2005-07-08'
-
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine. It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# Configuration subroutine to validate and canonicalize a configuration type.
-# Supply the specified configuration type as an argument.
-# If it is invalid, we print an error message on stderr and exit with code 1.
-# Otherwise, we print the canonical config type on stdout and succeed.
-
-# This file is supposed to be the same for all GNU packages
-# and recognize all the CPU types, system types and aliases
-# that are meaningful with *any* GNU software.
-# Each package is responsible for reporting which valid configurations
-# it does not support. The user should be able to distinguish
-# a failure to support a valid configuration from a meaningless
-# configuration.
-
-# The goal of this file is to map all the various variations of a given
-# machine specification into a single specification in the form:
-# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-# or in some cases, the newer four-part form:
-# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-# It is wrong to echo any other type of specification.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION] CPU-MFR-OPSYS
- $0 [OPTION] ALIAS
-
-Canonicalize a configuration name.
-
-Operation modes:
- -h, --help print this help, then exit
- -t, --time-stamp print date of last modification, then exit
- -v, --version print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.sub ($timestamp)
-
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
- case $1 in
- --time-stamp | --time* | -t )
- echo "$timestamp" ; exit ;;
- --version | -v )
- echo "$version" ; exit ;;
- --help | --h* | -h )
- echo "$usage"; exit ;;
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- echo "$me: invalid option $1$help"
- exit 1 ;;
-
- *local*)
- # First pass through any local machine types.
- echo $1
- exit ;;
-
- * )
- break ;;
- esac
-done
-
-case $# in
- 0) echo "$me: missing argument$help" >&2
- exit 1;;
- 1) ;;
- *) echo "$me: too many arguments$help" >&2
- exit 1;;
-esac
-
-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-case $maybe_os in
- nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
- kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
- os=-$maybe_os
- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
- ;;
- *)
- basic_machine=`echo $1 | sed 's/-[^-]*$//'`
- if [ $basic_machine != $1 ]
- then os=`echo $1 | sed 's/.*-/-/'`
- else os=; fi
- ;;
-esac
-
-### Let's recognize common machines as not being operating systems so
-### that things like config.sub decstation-3100 work. We also
-### recognize some manufacturers as not being operating systems, so we
-### can provide default operating systems below.
-case $os in
- -sun*os*)
- # Prevent following clause from handling this invalid input.
- ;;
- -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
- -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
- -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
- -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
- -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
- -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
- -apple | -axis | -knuth | -cray)
- os=
- basic_machine=$1
- ;;
- -sim | -cisco | -oki | -wec | -winbond)
- os=
- basic_machine=$1
- ;;
- -scout)
- ;;
- -wrs)
- os=-vxworks
- basic_machine=$1
- ;;
- -chorusos*)
- os=-chorusos
- basic_machine=$1
- ;;
- -chorusrdb)
- os=-chorusrdb
- basic_machine=$1
- ;;
- -hiux*)
- os=-hiuxwe2
- ;;
- -sco5)
- os=-sco3.2v5
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco4)
- os=-sco3.2v4
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2.[4-9]*)
- os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2v[4-9]*)
- # Don't forget version if it is 3.2v4 or newer.
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco*)
- os=-sco3.2v2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -udk*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -isc)
- os=-isc2.2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -clix*)
- basic_machine=clipper-intergraph
- ;;
- -isc*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -lynx*)
- os=-lynxos
- ;;
- -ptx*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
- ;;
- -windowsnt*)
- os=`echo $os | sed -e 's/windowsnt/winnt/'`
- ;;
- -psos*)
- os=-psos
- ;;
- -mint | -mint[0-9]*)
- basic_machine=m68k-atari
- os=-mint
- ;;
-esac
-
-# Decode aliases for certain CPU-COMPANY combinations.
-case $basic_machine in
- # Recognize the basic CPU types without company name.
- # Some are omitted here because they have special meanings below.
- 1750a | 580 \
- | a29k \
- | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
- | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
- | am33_2.0 \
- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
- | bfin \
- | c4x | clipper \
- | d10v | d30v | dlx | dsp16xx \
- | fr30 | frv \
- | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
- | i370 | i860 | i960 | ia64 \
- | ip2k | iq2000 \
- | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
- | mips | mipsbe | mipseb | mipsel | mipsle \
- | mips16 \
- | mips64 | mips64el \
- | mips64vr | mips64vrel \
- | mips64orion | mips64orionel \
- | mips64vr4100 | mips64vr4100el \
- | mips64vr4300 | mips64vr4300el \
- | mips64vr5000 | mips64vr5000el \
- | mips64vr5900 | mips64vr5900el \
- | mipsisa32 | mipsisa32el \
- | mipsisa32r2 | mipsisa32r2el \
- | mipsisa64 | mipsisa64el \
- | mipsisa64r2 | mipsisa64r2el \
- | mipsisa64sb1 | mipsisa64sb1el \
- | mipsisa64sr71k | mipsisa64sr71kel \
- | mipstx39 | mipstx39el \
- | mn10200 | mn10300 \
- | ms1 \
- | msp430 \
- | ns16k | ns32k \
- | or32 \
- | pdp10 | pdp11 | pj | pjl \
- | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
- | pyramid \
- | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
- | sh64 | sh64le \
- | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
- | sparcv8 | sparcv9 | sparcv9b \
- | strongarm \
- | tahoe | thumb | tic4x | tic80 | tron \
- | v850 | v850e \
- | we32k \
- | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
- | z8k)
- basic_machine=$basic_machine-unknown
- ;;
- m32c)
- basic_machine=$basic_machine-unknown
- ;;
- m6811 | m68hc11 | m6812 | m68hc12)
- # Motorola 68HC11/12.
- basic_machine=$basic_machine-unknown
- os=-none
- ;;
- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
- ;;
-
- # We use `pc' rather than `unknown'
- # because (1) that's what they normally are, and
- # (2) the word "unknown" tends to confuse beginning users.
- i*86 | x86_64)
- basic_machine=$basic_machine-pc
- ;;
- # Object if more than one company name word.
- *-*-*)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
- # Recognize the basic CPU types with company name.
- 580-* \
- | a29k-* \
- | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
- | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
- | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
- | avr-* \
- | bfin-* | bs2000-* \
- | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
- | clipper-* | craynv-* | cydra-* \
- | d10v-* | d30v-* | dlx-* \
- | elxsi-* \
- | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
- | h8300-* | h8500-* \
- | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
- | i*86-* | i860-* | i960-* | ia64-* \
- | ip2k-* | iq2000-* \
- | m32r-* | m32rle-* \
- | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
- | m88110-* | m88k-* | maxq-* | mcore-* \
- | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
- | mips16-* \
- | mips64-* | mips64el-* \
- | mips64vr-* | mips64vrel-* \
- | mips64orion-* | mips64orionel-* \
- | mips64vr4100-* | mips64vr4100el-* \
- | mips64vr4300-* | mips64vr4300el-* \
- | mips64vr5000-* | mips64vr5000el-* \
- | mips64vr5900-* | mips64vr5900el-* \
- | mipsisa32-* | mipsisa32el-* \
- | mipsisa32r2-* | mipsisa32r2el-* \
- | mipsisa64-* | mipsisa64el-* \
- | mipsisa64r2-* | mipsisa64r2el-* \
- | mipsisa64sb1-* | mipsisa64sb1el-* \
- | mipsisa64sr71k-* | mipsisa64sr71kel-* \
- | mipstx39-* | mipstx39el-* \
- | mmix-* \
- | ms1-* \
- | msp430-* \
- | none-* | np1-* | ns16k-* | ns32k-* \
- | orion-* \
- | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
- | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
- | pyramid-* \
- | romp-* | rs6000-* \
- | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
- | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
- | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
- | sparclite-* \
- | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
- | tahoe-* | thumb-* \
- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
- | tron-* \
- | v850-* | v850e-* | vax-* \
- | we32k-* \
- | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
- | xstormy16-* | xtensa-* \
- | ymp-* \
- | z8k-*)
- ;;
- m32c-*)
- ;;
- # Recognize the various machine names and aliases which stand
- # for a CPU type and a company and sometimes even an OS.
- 386bsd)
- basic_machine=i386-unknown
- os=-bsd
- ;;
- 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
- basic_machine=m68000-att
- ;;
- 3b*)
- basic_machine=we32k-att
- ;;
- a29khif)
- basic_machine=a29k-amd
- os=-udi
- ;;
- abacus)
- basic_machine=abacus-unknown
- ;;
- adobe68k)
- basic_machine=m68010-adobe
- os=-scout
- ;;
- alliant | fx80)
- basic_machine=fx80-alliant
- ;;
- altos | altos3068)
- basic_machine=m68k-altos
- ;;
- am29k)
- basic_machine=a29k-none
- os=-bsd
- ;;
- amd64)
- basic_machine=x86_64-pc
- ;;
- amd64-*)
- basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- amdahl)
- basic_machine=580-amdahl
- os=-sysv
- ;;
- amiga | amiga-*)
- basic_machine=m68k-unknown
- ;;
- amigaos | amigados)
- basic_machine=m68k-unknown
- os=-amigaos
- ;;
- amigaunix | amix)
- basic_machine=m68k-unknown
- os=-sysv4
- ;;
- apollo68)
- basic_machine=m68k-apollo
- os=-sysv
- ;;
- apollo68bsd)
- basic_machine=m68k-apollo
- os=-bsd
- ;;
- aux)
- basic_machine=m68k-apple
- os=-aux
- ;;
- balance)
- basic_machine=ns32k-sequent
- os=-dynix
- ;;
- c90)
- basic_machine=c90-cray
- os=-unicos
- ;;
- convex-c1)
- basic_machine=c1-convex
- os=-bsd
- ;;
- convex-c2)
- basic_machine=c2-convex
- os=-bsd
- ;;
- convex-c32)
- basic_machine=c32-convex
- os=-bsd
- ;;
- convex-c34)
- basic_machine=c34-convex
- os=-bsd
- ;;
- convex-c38)
- basic_machine=c38-convex
- os=-bsd
- ;;
- cray | j90)
- basic_machine=j90-cray
- os=-unicos
- ;;
- craynv)
- basic_machine=craynv-cray
- os=-unicosmp
- ;;
- cr16c)
- basic_machine=cr16c-unknown
- os=-elf
- ;;
- crds | unos)
- basic_machine=m68k-crds
- ;;
- crisv32 | crisv32-* | etraxfs*)
- basic_machine=crisv32-axis
- ;;
- cris | cris-* | etrax*)
- basic_machine=cris-axis
- ;;
- crx)
- basic_machine=crx-unknown
- os=-elf
- ;;
- da30 | da30-*)
- basic_machine=m68k-da30
- ;;
- decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
- basic_machine=mips-dec
- ;;
- decsystem10* | dec10*)
- basic_machine=pdp10-dec
- os=-tops10
- ;;
- decsystem20* | dec20*)
- basic_machine=pdp10-dec
- os=-tops20
- ;;
- delta | 3300 | motorola-3300 | motorola-delta \
- | 3300-motorola | delta-motorola)
- basic_machine=m68k-motorola
- ;;
- delta88)
- basic_machine=m88k-motorola
- os=-sysv3
- ;;
- djgpp)
- basic_machine=i586-pc
- os=-msdosdjgpp
- ;;
- dpx20 | dpx20-*)
- basic_machine=rs6000-bull
- os=-bosx
- ;;
- dpx2* | dpx2*-bull)
- basic_machine=m68k-bull
- os=-sysv3
- ;;
- ebmon29k)
- basic_machine=a29k-amd
- os=-ebmon
- ;;
- elxsi)
- basic_machine=elxsi-elxsi
- os=-bsd
- ;;
- encore | umax | mmax)
- basic_machine=ns32k-encore
- ;;
- es1800 | OSE68k | ose68k | ose | OSE)
- basic_machine=m68k-ericsson
- os=-ose
- ;;
- fx2800)
- basic_machine=i860-alliant
- ;;
- genix)
- basic_machine=ns32k-ns
- ;;
- gmicro)
- basic_machine=tron-gmicro
- os=-sysv
- ;;
- go32)
- basic_machine=i386-pc
- os=-go32
- ;;
- h3050r* | hiux*)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- h8300hms)
- basic_machine=h8300-hitachi
- os=-hms
- ;;
- h8300xray)
- basic_machine=h8300-hitachi
- os=-xray
- ;;
- h8500hms)
- basic_machine=h8500-hitachi
- os=-hms
- ;;
- harris)
- basic_machine=m88k-harris
- os=-sysv3
- ;;
- hp300-*)
- basic_machine=m68k-hp
- ;;
- hp300bsd)
- basic_machine=m68k-hp
- os=-bsd
- ;;
- hp300hpux)
- basic_machine=m68k-hp
- os=-hpux
- ;;
- hp3k9[0-9][0-9] | hp9[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hp9k2[0-9][0-9] | hp9k31[0-9])
- basic_machine=m68000-hp
- ;;
- hp9k3[2-9][0-9])
- basic_machine=m68k-hp
- ;;
- hp9k6[0-9][0-9] | hp6[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hp9k7[0-79][0-9] | hp7[0-79][0-9])
- basic_machine=hppa1.1-hp
- ;;
- hp9k78[0-9] | hp78[0-9])
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][13679] | hp8[0-9][13679])
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][0-9] | hp8[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hppa-next)
- os=-nextstep3
- ;;
- hppaosf)
- basic_machine=hppa1.1-hp
- os=-osf
- ;;
- hppro)
- basic_machine=hppa1.1-hp
- os=-proelf
- ;;
- i370-ibm* | ibm*)
- basic_machine=i370-ibm
- ;;
-# I'm not sure what "Sysv32" means. Should this be sysv3.2?
- i*86v32)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv32
- ;;
- i*86v4*)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv4
- ;;
- i*86v)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv
- ;;
- i*86sol2)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-solaris2
- ;;
- i386mach)
- basic_machine=i386-mach
- os=-mach
- ;;
- i386-vsta | vsta)
- basic_machine=i386-unknown
- os=-vsta
- ;;
- iris | iris4d)
- basic_machine=mips-sgi
- case $os in
- -irix*)
- ;;
- *)
- os=-irix4
- ;;
- esac
- ;;
- isi68 | isi)
- basic_machine=m68k-isi
- os=-sysv
- ;;
- m88k-omron*)
- basic_machine=m88k-omron
- ;;
- magnum | m3230)
- basic_machine=mips-mips
- os=-sysv
- ;;
- merlin)
- basic_machine=ns32k-utek
- os=-sysv
- ;;
- mingw32)
- basic_machine=i386-pc
- os=-mingw32
- ;;
- miniframe)
- basic_machine=m68000-convergent
- ;;
- *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
- basic_machine=m68k-atari
- os=-mint
- ;;
- mips3*-*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
- ;;
- mips3*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
- ;;
- monitor)
- basic_machine=m68k-rom68k
- os=-coff
- ;;
- morphos)
- basic_machine=powerpc-unknown
- os=-morphos
- ;;
- msdos)
- basic_machine=i386-pc
- os=-msdos
- ;;
- mvs)
- basic_machine=i370-ibm
- os=-mvs
- ;;
- ncr3000)
- basic_machine=i486-ncr
- os=-sysv4
- ;;
- netbsd386)
- basic_machine=i386-unknown
- os=-netbsd
- ;;
- netwinder)
- basic_machine=armv4l-rebel
- os=-linux
- ;;
- news | news700 | news800 | news900)
- basic_machine=m68k-sony
- os=-newsos
- ;;
- news1000)
- basic_machine=m68030-sony
- os=-newsos
- ;;
- news-3600 | risc-news)
- basic_machine=mips-sony
- os=-newsos
- ;;
- necv70)
- basic_machine=v70-nec
- os=-sysv
- ;;
- next | m*-next )
- basic_machine=m68k-next
- case $os in
- -nextstep* )
- ;;
- -ns2*)
- os=-nextstep2
- ;;
- *)
- os=-nextstep3
- ;;
- esac
- ;;
- nh3000)
- basic_machine=m68k-harris
- os=-cxux
- ;;
- nh[45]000)
- basic_machine=m88k-harris
- os=-cxux
- ;;
- nindy960)
- basic_machine=i960-intel
- os=-nindy
- ;;
- mon960)
- basic_machine=i960-intel
- os=-mon960
- ;;
- nonstopux)
- basic_machine=mips-compaq
- os=-nonstopux
- ;;
- np1)
- basic_machine=np1-gould
- ;;
- nsr-tandem)
- basic_machine=nsr-tandem
- ;;
- op50n-* | op60c-*)
- basic_machine=hppa1.1-oki
- os=-proelf
- ;;
- openrisc | openrisc-*)
- basic_machine=or32-unknown
- ;;
- os400)
- basic_machine=powerpc-ibm
- os=-os400
- ;;
- OSE68000 | ose68000)
- basic_machine=m68000-ericsson
- os=-ose
- ;;
- os68k)
- basic_machine=m68k-none
- os=-os68k
- ;;
- pa-hitachi)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- paragon)
- basic_machine=i860-intel
- os=-osf
- ;;
- pbd)
- basic_machine=sparc-tti
- ;;
- pbb)
- basic_machine=m68k-tti
- ;;
- pc532 | pc532-*)
- basic_machine=ns32k-pc532
- ;;
- pentium | p5 | k5 | k6 | nexgen | viac3)
- basic_machine=i586-pc
- ;;
- pentiumpro | p6 | 6x86 | athlon | athlon_*)
- basic_machine=i686-pc
- ;;
- pentiumii | pentium2 | pentiumiii | pentium3)
- basic_machine=i686-pc
- ;;
- pentium4)
- basic_machine=i786-pc
- ;;
- pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
- basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentiumpro-* | p6-* | 6x86-* | athlon-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentium4-*)
- basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pn)
- basic_machine=pn-gould
- ;;
- power) basic_machine=power-ibm
- ;;
- ppc) basic_machine=powerpc-unknown
- ;;
- ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppcle | powerpclittle | ppc-le | powerpc-little)
- basic_machine=powerpcle-unknown
- ;;
- ppcle-* | powerpclittle-*)
- basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppc64) basic_machine=powerpc64-unknown
- ;;
- ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppc64le | powerpc64little | ppc64-le | powerpc64-little)
- basic_machine=powerpc64le-unknown
- ;;
- ppc64le-* | powerpc64little-*)
- basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ps2)
- basic_machine=i386-ibm
- ;;
- pw32)
- basic_machine=i586-unknown
- os=-pw32
- ;;
- rom68k)
- basic_machine=m68k-rom68k
- os=-coff
- ;;
- rm[46]00)
- basic_machine=mips-siemens
- ;;
- rtpc | rtpc-*)
- basic_machine=romp-ibm
- ;;
- s390 | s390-*)
- basic_machine=s390-ibm
- ;;
- s390x | s390x-*)
- basic_machine=s390x-ibm
- ;;
- sa29200)
- basic_machine=a29k-amd
- os=-udi
- ;;
- sb1)
- basic_machine=mipsisa64sb1-unknown
- ;;
- sb1el)
- basic_machine=mipsisa64sb1el-unknown
- ;;
- sei)
- basic_machine=mips-sei
- os=-seiux
- ;;
- sequent)
- basic_machine=i386-sequent
- ;;
- sh)
- basic_machine=sh-hitachi
- os=-hms
- ;;
- sh64)
- basic_machine=sh64-unknown
- ;;
- sparclite-wrs | simso-wrs)
- basic_machine=sparclite-wrs
- os=-vxworks
- ;;
- sps7)
- basic_machine=m68k-bull
- os=-sysv2
- ;;
- spur)
- basic_machine=spur-unknown
- ;;
- st2000)
- basic_machine=m68k-tandem
- ;;
- stratus)
- basic_machine=i860-stratus
- os=-sysv4
- ;;
- sun2)
- basic_machine=m68000-sun
- ;;
- sun2os3)
- basic_machine=m68000-sun
- os=-sunos3
- ;;
- sun2os4)
- basic_machine=m68000-sun
- os=-sunos4
- ;;
- sun3os3)
- basic_machine=m68k-sun
- os=-sunos3
- ;;
- sun3os4)
- basic_machine=m68k-sun
- os=-sunos4
- ;;
- sun4os3)
- basic_machine=sparc-sun
- os=-sunos3
- ;;
- sun4os4)
- basic_machine=sparc-sun
- os=-sunos4
- ;;
- sun4sol2)
- basic_machine=sparc-sun
- os=-solaris2
- ;;
- sun3 | sun3-*)
- basic_machine=m68k-sun
- ;;
- sun4)
- basic_machine=sparc-sun
- ;;
- sun386 | sun386i | roadrunner)
- basic_machine=i386-sun
- ;;
- sv1)
- basic_machine=sv1-cray
- os=-unicos
- ;;
- symmetry)
- basic_machine=i386-sequent
- os=-dynix
- ;;
- t3e)
- basic_machine=alphaev5-cray
- os=-unicos
- ;;
- t90)
- basic_machine=t90-cray
- os=-unicos
- ;;
- tic54x | c54x*)
- basic_machine=tic54x-unknown
- os=-coff
- ;;
- tic55x | c55x*)
- basic_machine=tic55x-unknown
- os=-coff
- ;;
- tic6x | c6x*)
- basic_machine=tic6x-unknown
- os=-coff
- ;;
- tx39)
- basic_machine=mipstx39-unknown
- ;;
- tx39el)
- basic_machine=mipstx39el-unknown
- ;;
- toad1)
- basic_machine=pdp10-xkl
- os=-tops20
- ;;
- tower | tower-32)
- basic_machine=m68k-ncr
- ;;
- tpf)
- basic_machine=s390x-ibm
- os=-tpf
- ;;
- udi29k)
- basic_machine=a29k-amd
- os=-udi
- ;;
- ultra3)
- basic_machine=a29k-nyu
- os=-sym1
- ;;
- v810 | necv810)
- basic_machine=v810-nec
- os=-none
- ;;
- vaxv)
- basic_machine=vax-dec
- os=-sysv
- ;;
- vms)
- basic_machine=vax-dec
- os=-vms
- ;;
- vpp*|vx|vx-*)
- basic_machine=f301-fujitsu
- ;;
- vxworks960)
- basic_machine=i960-wrs
- os=-vxworks
- ;;
- vxworks68)
- basic_machine=m68k-wrs
- os=-vxworks
- ;;
- vxworks29k)
- basic_machine=a29k-wrs
- os=-vxworks
- ;;
- w65*)
- basic_machine=w65-wdc
- os=-none
- ;;
- w89k-*)
- basic_machine=hppa1.1-winbond
- os=-proelf
- ;;
- xbox)
- basic_machine=i686-pc
- os=-mingw32
- ;;
- xps | xps100)
- basic_machine=xps100-honeywell
- ;;
- ymp)
- basic_machine=ymp-cray
- os=-unicos
- ;;
- z8k-*-coff)
- basic_machine=z8k-unknown
- os=-sim
- ;;
- none)
- basic_machine=none-none
- os=-none
- ;;
-
-# Here we handle the default manufacturer of certain CPU types. It is in
-# some cases the only manufacturer, in others, it is the most popular.
- w89k)
- basic_machine=hppa1.1-winbond
- ;;
- op50n)
- basic_machine=hppa1.1-oki
- ;;
- op60c)
- basic_machine=hppa1.1-oki
- ;;
- romp)
- basic_machine=romp-ibm
- ;;
- mmix)
- basic_machine=mmix-knuth
- ;;
- rs6000)
- basic_machine=rs6000-ibm
- ;;
- vax)
- basic_machine=vax-dec
- ;;
- pdp10)
- # there are many clones, so DEC is not a safe bet
- basic_machine=pdp10-unknown
- ;;
- pdp11)
- basic_machine=pdp11-dec
- ;;
- we32k)
- basic_machine=we32k-att
- ;;
- sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
- basic_machine=sh-unknown
- ;;
- sparc | sparcv8 | sparcv9 | sparcv9b)
- basic_machine=sparc-sun
- ;;
- cydra)
- basic_machine=cydra-cydrome
- ;;
- orion)
- basic_machine=orion-highlevel
- ;;
- orion105)
- basic_machine=clipper-highlevel
- ;;
- mac | mpw | mac-mpw)
- basic_machine=m68k-apple
- ;;
- pmac | pmac-mpw)
- basic_machine=powerpc-apple
- ;;
- *-unknown)
- # Make sure to match an already-canonicalized machine name.
- ;;
- *)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
-esac
-
-# Here we canonicalize certain aliases for manufacturers.
-case $basic_machine in
- *-digital*)
- basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
- ;;
- *-commodore*)
- basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
- ;;
- *)
- ;;
-esac
-
-# Decode manufacturer-specific aliases for certain operating systems.
-
-if [ x"$os" != x"" ]
-then
-case $os in
- # First match some system type aliases
- # that might get confused with valid system types.
- # -solaris* is a basic system type, with this one exception.
- -solaris1 | -solaris1.*)
- os=`echo $os | sed -e 's|solaris1|sunos4|'`
- ;;
- -solaris)
- os=-solaris2
- ;;
- -svr4*)
- os=-sysv4
- ;;
- -unixware*)
- os=-sysv4.2uw
- ;;
- -gnu/linux*)
- os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
- ;;
- # First accept the basic system types.
- # The portable systems comes first.
- # Each alternative MUST END IN A *, to match a version number.
- # -sysv* is not here because it comes later, after sysvr4.
- -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
- | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
- | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
- | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
- | -aos* \
- | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
- | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
- | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
- | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
- | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
- | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
- | -chorusos* | -chorusrdb* \
- | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
- | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
- | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
- | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
- | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
- | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
- | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
- | -skyos* | -haiku*)
- # Remember, each alternative MUST END IN *, to match a version number.
- ;;
- -qnx*)
- case $basic_machine in
- x86-* | i*86-*)
- ;;
- *)
- os=-nto$os
- ;;
- esac
- ;;
- -nto-qnx*)
- ;;
- -nto*)
- os=`echo $os | sed -e 's|nto|nto-qnx|'`
- ;;
- -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
- | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
- | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
- ;;
- -mac*)
- os=`echo $os | sed -e 's|mac|macos|'`
- ;;
- -linux-dietlibc)
- os=-linux-dietlibc
- ;;
- -linux*)
- os=`echo $os | sed -e 's|linux|linux-gnu|'`
- ;;
- -sunos5*)
- os=`echo $os | sed -e 's|sunos5|solaris2|'`
- ;;
- -sunos6*)
- os=`echo $os | sed -e 's|sunos6|solaris3|'`
- ;;
- -opened*)
- os=-openedition
- ;;
- -os400*)
- os=-os400
- ;;
- -wince*)
- os=-wince
- ;;
- -osfrose*)
- os=-osfrose
- ;;
- -osf*)
- os=-osf
- ;;
- -utek*)
- os=-bsd
- ;;
- -dynix*)
- os=-bsd
- ;;
- -acis*)
- os=-aos
- ;;
- -atheos*)
- os=-atheos
- ;;
- -syllable*)
- os=-syllable
- ;;
- -386bsd)
- os=-bsd
- ;;
- -ctix* | -uts*)
- os=-sysv
- ;;
- -nova*)
- os=-rtmk-nova
- ;;
- -ns2 )
- os=-nextstep2
- ;;
- -nsk*)
- os=-nsk
- ;;
- # Preserve the version number of sinix5.
- -sinix5.*)
- os=`echo $os | sed -e 's|sinix|sysv|'`
- ;;
- -sinix*)
- os=-sysv4
- ;;
- -tpf*)
- os=-tpf
- ;;
- -triton*)
- os=-sysv3
- ;;
- -oss*)
- os=-sysv3
- ;;
- -svr4)
- os=-sysv4
- ;;
- -svr3)
- os=-sysv3
- ;;
- -sysvr4)
- os=-sysv4
- ;;
- # This must come after -sysvr4.
- -sysv*)
- ;;
- -ose*)
- os=-ose
- ;;
- -es1800*)
- os=-ose
- ;;
- -xenix)
- os=-xenix
- ;;
- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
- os=-mint
- ;;
- -aros*)
- os=-aros
- ;;
- -kaos*)
- os=-kaos
- ;;
- -zvmoe)
- os=-zvmoe
- ;;
- -none)
- ;;
- *)
- # Get rid of the `-' at the beginning of $os.
- os=`echo $os | sed 's/[^-]*-//'`
- echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
- exit 1
- ;;
-esac
-else
-
-# Here we handle the default operating systems that come with various machines.
-# The value should be what the vendor currently ships out the door with their
-# machine or put another way, the most popular os provided with the machine.
-
-# Note that if you're going to try to match "-MANUFACTURER" here (say,
-# "-sun"), then you have to tell the case statement up towards the top
-# that MANUFACTURER isn't an operating system. Otherwise, code above
-# will signal an error saying that MANUFACTURER isn't an operating
-# system, and we'll never get to this point.
-
-case $basic_machine in
- *-acorn)
- os=-riscix1.2
- ;;
- arm*-rebel)
- os=-linux
- ;;
- arm*-semi)
- os=-aout
- ;;
- c4x-* | tic4x-*)
- os=-coff
- ;;
- # This must come before the *-dec entry.
- pdp10-*)
- os=-tops20
- ;;
- pdp11-*)
- os=-none
- ;;
- *-dec | vax-*)
- os=-ultrix4.2
- ;;
- m68*-apollo)
- os=-domain
- ;;
- i386-sun)
- os=-sunos4.0.2
- ;;
- m68000-sun)
- os=-sunos3
- # This also exists in the configure program, but was not the
- # default.
- # os=-sunos4
- ;;
- m68*-cisco)
- os=-aout
- ;;
- mips*-cisco)
- os=-elf
- ;;
- mips*-*)
- os=-elf
- ;;
- or32-*)
- os=-coff
- ;;
- *-tti) # must be before sparc entry or we get the wrong os.
- os=-sysv3
- ;;
- sparc-* | *-sun)
- os=-sunos4.1.1
- ;;
- *-be)
- os=-beos
- ;;
- *-haiku)
- os=-haiku
- ;;
- *-ibm)
- os=-aix
- ;;
- *-knuth)
- os=-mmixware
- ;;
- *-wec)
- os=-proelf
- ;;
- *-winbond)
- os=-proelf
- ;;
- *-oki)
- os=-proelf
- ;;
- *-hp)
- os=-hpux
- ;;
- *-hitachi)
- os=-hiux
- ;;
- i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
- os=-sysv
- ;;
- *-cbm)
- os=-amigaos
- ;;
- *-dg)
- os=-dgux
- ;;
- *-dolphin)
- os=-sysv3
- ;;
- m68k-ccur)
- os=-rtu
- ;;
- m88k-omron*)
- os=-luna
- ;;
- *-next )
- os=-nextstep
- ;;
- *-sequent)
- os=-ptx
- ;;
- *-crds)
- os=-unos
- ;;
- *-ns)
- os=-genix
- ;;
- i370-*)
- os=-mvs
- ;;
- *-next)
- os=-nextstep3
- ;;
- *-gould)
- os=-sysv
- ;;
- *-highlevel)
- os=-bsd
- ;;
- *-encore)
- os=-bsd
- ;;
- *-sgi)
- os=-irix
- ;;
- *-siemens)
- os=-sysv4
- ;;
- *-masscomp)
- os=-rtu
- ;;
- f30[01]-fujitsu | f700-fujitsu)
- os=-uxpv
- ;;
- *-rom68k)
- os=-coff
- ;;
- *-*bug)
- os=-coff
- ;;
- *-apple)
- os=-macos
- ;;
- *-atari*)
- os=-mint
- ;;
- *)
- os=-none
- ;;
-esac
-fi
-
-# Here we handle the case where we know the os, and the CPU type, but not the
-# manufacturer. We pick the logical manufacturer.
-vendor=unknown
-case $basic_machine in
- *-unknown)
- case $os in
- -riscix*)
- vendor=acorn
- ;;
- -sunos*)
- vendor=sun
- ;;
- -aix*)
- vendor=ibm
- ;;
- -beos*)
- vendor=be
- ;;
- -hpux*)
- vendor=hp
- ;;
- -mpeix*)
- vendor=hp
- ;;
- -hiux*)
- vendor=hitachi
- ;;
- -unos*)
- vendor=crds
- ;;
- -dgux*)
- vendor=dg
- ;;
- -luna*)
- vendor=omron
- ;;
- -genix*)
- vendor=ns
- ;;
- -mvs* | -opened*)
- vendor=ibm
- ;;
- -os400*)
- vendor=ibm
- ;;
- -ptx*)
- vendor=sequent
- ;;
- -tpf*)
- vendor=ibm
- ;;
- -vxsim* | -vxworks* | -windiss*)
- vendor=wrs
- ;;
- -aux*)
- vendor=apple
- ;;
- -hms*)
- vendor=hitachi
- ;;
- -mpw* | -macos*)
- vendor=apple
- ;;
- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
- vendor=atari
- ;;
- -vos*)
- vendor=stratus
- ;;
- esac
- basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
- ;;
-esac
-
-echo $basic_machine$os
-exit
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/source4/lib/talloc/configure.ac b/source4/lib/talloc/configure.ac
deleted file mode 100644
index 4719aa04b5..0000000000
--- a/source4/lib/talloc/configure.ac
+++ /dev/null
@@ -1,24 +0,0 @@
-AC_PREREQ(2.50)
-AC_INIT(talloc, 1.2.0)
-AC_CONFIG_SRCDIR([talloc.c])
-AC_SUBST(datarootdir)
-AC_CONFIG_HEADER(config.h)
-
-AC_LIBREPLACE_ALL_CHECKS
-
-m4_include(libtalloc.m4)
-
-AC_PATH_PROG(XSLTPROC,xsltproc)
-DOC_TARGET=""
-if test -n "$XSLTPROC"; then
- DOC_TARGET=doc
-fi
-AC_SUBST(DOC_TARGET)
-
-AC_LD_PICFLAG
-AC_LD_SHLIBEXT
-AC_LD_SONAMEFLAG
-AC_LIBREPLACE_SHLD
-AC_LIBREPLACE_SHLD_FLAGS
-
-AC_OUTPUT(Makefile talloc.pc)
diff --git a/source4/lib/talloc/install-sh b/source4/lib/talloc/install-sh
deleted file mode 100755
index 58719246f0..0000000000
--- a/source4/lib/talloc/install-sh
+++ /dev/null
@@ -1,238 +0,0 @@
-#! /bin/sh
-#
-# install - install a program, script, or datafile
-# This comes from X11R5.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-#
-
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-transformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd="$stripprog"
- shift
- continue;;
-
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
-
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
-done
-
-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
-else
- true
-fi
-
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- else
- instcmd=mkdir
- fi
-else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
-
- if [ -f $src -o -d $src ]
- then
- true
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- true
- fi
-
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- true
- fi
-fi
-
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
-
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-'
-IFS="${IFS-${defaultIFS}}"
-
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
-
-pathcomp=''
-
-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
-
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- true
- fi
-
- pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
-
-# If we're going to rename the final executable, determine the name now.
-
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
-
-# don't allow the sed command to completely eliminate the filename
-
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- true
- fi
-
-# Make a temp file name in the proper directory.
-
- dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-
- $doit $instcmd $src $dsttmp &&
-
- trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
-
-# Now rename the file to the real destination.
-
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
-
-fi &&
-
-
-exit 0
diff --git a/source4/lib/talloc/libtalloc.m4 b/source4/lib/talloc/libtalloc.m4
deleted file mode 100644
index fd2b4b22cd..0000000000
--- a/source4/lib/talloc/libtalloc.m4
+++ /dev/null
@@ -1,33 +0,0 @@
-dnl find the talloc sources. This is meant to work both for
-dnl talloc standalone builds, and builds of packages using talloc
-tallocdir=""
-tallocpaths=". lib/talloc talloc ../talloc"
-for d in $tallocpaths; do
- if test -f "$srcdir/$d/talloc.c"; then
- tallocdir="$d"
- AC_SUBST(tallocdir)
- break;
- fi
-done
-if test x"$tallocdir" = "x"; then
- AC_MSG_ERROR([cannot find talloc source in $tallocpaths])
-fi
-TALLOC_OBJ="talloc.o"
-AC_SUBST(TALLOC_OBJ)
-
-TALLOC_CFLAGS="-I$srcdir/$tallocdir"
-AC_SUBST(TALLOC_CFLAGS)
-
-TALLOC_LIBS=""
-AC_SUBST(TALLOC_LIBS)
-
-AC_CHECK_SIZEOF(size_t,cross)
-AC_CHECK_SIZEOF(void *,cross)
-
-if test $ac_cv_sizeof_size_t -lt $ac_cv_sizeof_void_p; then
- AC_WARN([size_t cannot represent the amount of used memory of a process])
- AC_WARN([please report this to <samba-technical@samba.org>])
- AC_WARN([sizeof(size_t) = $ac_cv_sizeof_size_t])
- AC_WARN([sizeof(void *) = $ac_cv_sizeof_void_p])
- AC_ERROR([sizeof(size_t) < sizeof(void *)])
-fi
diff --git a/source4/lib/talloc/rules.mk b/source4/lib/talloc/rules.mk
deleted file mode 100644
index 6cee126529..0000000000
--- a/source4/lib/talloc/rules.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-.SUFFIXES: .c .o .3 .3.xml .xml .html
-
-showflags::
- @echo 'talloc will be compiled with flags:'
- @echo ' CFLAGS = $(CFLAGS)'
- @echo ' LIBS = $(LIBS)'
-
-.c.o:
- $(CC) $(PICFLAG) -o $@ -c $< $(CFLAGS)
-
-.3.xml.3:
- -test -z "$(XSLTPROC)" || $(XSLTPROC) --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
-
-.xml.html:
- -test -z "$(XSLTPROC)" || $(XSLTPROC) --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl $<
-
-distclean::
- rm -f *~ */*~
diff --git a/source4/lib/talloc/talloc.3.xml b/source4/lib/talloc/talloc.3.xml
deleted file mode 100644
index 67de15bfc8..0000000000
--- a/source4/lib/talloc/talloc.3.xml
+++ /dev/null
@@ -1,738 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
-<refentry>
- <refmeta>
- <refentrytitle>talloc</refentrytitle>
- <manvolnum>3</manvolnum>
- </refmeta>
- <refnamediv>
- <refname>talloc</refname>
-<refpurpose>hierarchical reference counted memory pool system with destructors</refpurpose>
- </refnamediv>
- <refsynopsisdiv>
-<synopsis>#include &lt;talloc/talloc.h&gt;</synopsis>
- </refsynopsisdiv>
- <refsect1><title>DESCRIPTION</title>
- <para>
- If you are used to talloc from Samba3 then please read this
- carefully, as talloc has changed a lot.
- </para>
- <para>
- The new talloc is a hierarchical, reference counted memory pool
- system with destructors. Quite a mouthful really, but not too bad
- once you get used to it.
- </para>
- <para>
- Perhaps the biggest change from Samba3 is that there is no
- distinction between a "talloc context" and a "talloc pointer". Any
- pointer returned from talloc() is itself a valid talloc context.
- This means you can do this:
- </para>
- <programlisting>
- struct foo *X = talloc(mem_ctx, struct foo);
- X->name = talloc_strdup(X, "foo");
- </programlisting>
- <para>
- and the pointer <literal role="code">X-&gt;name</literal>
- would be a "child" of the talloc context <literal
- role="code">X</literal> which is itself a child of
- <literal role="code">mem_ctx</literal>. So if you do
- <literal role="code">talloc_free(mem_ctx)</literal> then
- it is all destroyed, whereas if you do <literal
- role="code">talloc_free(X)</literal> then just <literal
- role="code">X</literal> and <literal
- role="code">X-&gt;name</literal> are destroyed, and if
- you do <literal
- role="code">talloc_free(X-&gt;name)</literal> then just
- the name element of <literal role="code">X</literal> is
- destroyed.
- </para>
- <para>
- If you think about this, then what this effectively gives you is an
- n-ary tree, where you can free any part of the tree with
- talloc_free().
- </para>
- <para>
- If you find this confusing, then I suggest you run the <literal
- role="code">testsuite</literal> program to watch talloc
- in action. You may also like to add your own tests to <literal
- role="code">testsuite.c</literal> to clarify how some
- particular situation is handled.
- </para>
- </refsect1>
- <refsect1><title>TALLOC API</title>
- <para>
- The following is a complete guide to the talloc API. Read it all at
- least twice.
- </para>
- <refsect2><title>(type *)talloc(const void *ctx, type);</title>
- <para>
- The talloc() macro is the core of the talloc library. It takes a
- memory <emphasis role="italic">ctx</emphasis> and a <emphasis
- role="italic">type</emphasis>, and returns a pointer to a new
- area of memory of the given <emphasis
- role="italic">type</emphasis>.
- </para>
- <para>
- The returned pointer is itself a talloc context, so you can use
- it as the <emphasis role="italic">ctx</emphasis> argument to more
- calls to talloc() if you wish.
- </para>
- <para>
- The returned pointer is a "child" of the supplied context. This
- means that if you talloc_free() the <emphasis
- role="italic">ctx</emphasis> then the new child disappears as
- well. Alternatively you can free just the child.
- </para>
- <para>
- The <emphasis role="italic">ctx</emphasis> argument to talloc()
- can be NULL, in which case a new top level context is created.
- </para>
- </refsect2>
- <refsect2><title>void *talloc_size(const void *ctx, size_t size);</title>
- <para>
- The function talloc_size() should be used when you don't have a
- convenient type to pass to talloc(). Unlike talloc(), it is not
- type safe (as it returns a void *), so you are on your own for
- type checking.
- </para>
- </refsect2>
- <refsect2><title>(typeof(ptr)) talloc_ptrtype(const void *ctx, ptr);</title>
- <para>
- The talloc_ptrtype() macro should be used when you have a pointer and
- want to allocate memory to point at with this pointer. When compiling
- with gcc >= 3 it is typesafe. Note this is a wrapper of talloc_size()
- and talloc_get_name() will return the current location in the source file.
- and not the type.
- </para>
- </refsect2>
- <refsect2><title>int talloc_free(void *ptr);</title>
- <para>
- The talloc_free() function frees a piece of talloc memory, and
- all its children. You can call talloc_free() on any pointer
- returned by talloc().
- </para>
- <para>
- The return value of talloc_free() indicates success or failure,
- with 0 returned for success and -1 for failure. The only
- possible failure condition is if <emphasis
- role="italic">ptr</emphasis> had a destructor attached to it and
- the destructor returned -1. See <link
- linkend="talloc_set_destructor"><quote>talloc_set_destructor()</quote></link>
- for details on destructors.
- </para>
- <para>
- If this pointer has an additional parent when talloc_free() is
- called then the memory is not actually released, but instead the
- most recently established parent is destroyed. See <link
- linkend="talloc_reference"><quote>talloc_reference()</quote></link>
- for details on establishing additional parents.
- </para>
- <para>
- For more control on which parent is removed, see <link
- linkend="talloc_unlink"><quote>talloc_unlink()</quote></link>.
- </para>
- <para>
- talloc_free() operates recursively on its children.
- </para>
- </refsect2>
- <refsect2 id="talloc_reference"><title>void *talloc_reference(const void *ctx, const void *ptr);</title>
- <para>
- The talloc_reference() function makes <emphasis
- role="italic">ctx</emphasis> an additional parent of <emphasis
- role="italic">ptr</emphasis>.
- </para>
- <para>
- The return value of talloc_reference() is always the original
- pointer <emphasis role="italic">ptr</emphasis>, unless talloc ran
- out of memory in creating the reference in which case it will
- return NULL (each additional reference consumes around 48 bytes
- of memory on intel x86 platforms).
- </para>
- <para>
- If <emphasis role="italic">ptr</emphasis> is NULL, then the
- function is a no-op, and simply returns NULL.
- </para>
- <para>
- After creating a reference you can free it in one of the
- following ways:
- </para>
- <para>
- <itemizedlist>
- <listitem>
- <para>
- you can talloc_free() any parent of the original pointer.
- That will reduce the number of parents of this pointer by 1,
- and will cause this pointer to be freed if it runs out of
- parents.
- </para>
- </listitem>
- <listitem>
- <para>
- you can talloc_free() the pointer itself. That will destroy
- the most recently established parent to the pointer and leave
- the pointer as a child of its current parent.
- </para>
- </listitem>
- </itemizedlist>
- </para>
- <para>
- For more control on which parent to remove, see <link
- linkend="talloc_unlink"><quote>talloc_unlink()</quote></link>.
- </para>
- </refsect2>
- <refsect2 id="talloc_unlink"><title>int talloc_unlink(const void *ctx, const void *ptr);</title>
- <para>
- The talloc_unlink() function removes a specific parent from
- <emphasis role="italic">ptr</emphasis>. The <emphasis
- role="italic">ctx</emphasis> passed must either be a context used
- in talloc_reference() with this pointer, or must be a direct
- parent of ptr.
- </para>
- <para>
- Note that if the parent has already been removed using
- talloc_free() then this function will fail and will return -1.
- Likewise, if <emphasis role="italic">ptr</emphasis> is NULL, then
- the function will make no modifications and return -1.
- </para>
- <para>
- Usually you can just use talloc_free() instead of
- talloc_unlink(), but sometimes it is useful to have the
- additional control on which parent is removed.
- </para>
- </refsect2>
- <refsect2 id="talloc_set_destructor"><title>void talloc_set_destructor(const void *ptr, int (*destructor)(void *));</title>
- <para>
- The function talloc_set_destructor() sets the <emphasis
- role="italic">destructor</emphasis> for the pointer <emphasis
- role="italic">ptr</emphasis>. A <emphasis
- role="italic">destructor</emphasis> is a function that is called
- when the memory used by a pointer is about to be released. The
- destructor receives <emphasis role="italic">ptr</emphasis> as an
- argument, and should return 0 for success and -1 for failure.
- </para>
- <para>
- The <emphasis role="italic">destructor</emphasis> can do anything
- it wants to, including freeing other pieces of memory. A common
- use for destructors is to clean up operating system resources
- (such as open file descriptors) contained in the structure the
- destructor is placed on.
- </para>
- <para>
- You can only place one destructor on a pointer. If you need more
- than one destructor then you can create a zero-length child of
- the pointer and place an additional destructor on that.
- </para>
- <para>
- To remove a destructor call talloc_set_destructor() with NULL for
- the destructor.
- </para>
- <para>
- If your destructor attempts to talloc_free() the pointer that it
- is the destructor for then talloc_free() will return -1 and the
- free will be ignored. This would be a pointless operation
- anyway, as the destructor is only called when the memory is just
- about to go away.
- </para>
- </refsect2>
- <refsect2><title>int talloc_increase_ref_count(const void *<emphasis role="italic">ptr</emphasis>);</title>
- <para>
- The talloc_increase_ref_count(<emphasis
- role="italic">ptr</emphasis>) function is exactly equivalent to:
- </para>
- <programlisting>talloc_reference(NULL, ptr);</programlisting>
- <para>
- You can use either syntax, depending on which you think is
- clearer in your code.
- </para>
- <para>
- It returns 0 on success and -1 on failure.
- </para>
- </refsect2>
- <refsect2><title>size_t talloc_reference_count(const void *<emphasis role="italic">ptr</emphasis>);</title>
- <para>
- Return the number of references to the pointer.
- </para>
- </refsect2>
- <refsect2 id="talloc_set_name"><title>void talloc_set_name(const void *ptr, const char *fmt, ...);</title>
- <para>
- Each talloc pointer has a "name". The name is used principally
- for debugging purposes, although it is also possible to set and
- get the name on a pointer in as a way of "marking" pointers in
- your code.
- </para>
- <para>
- The main use for names on pointer is for "talloc reports". See
- <link
- linkend="talloc_report"><quote>talloc_report_depth_cb()</quote></link>,
- <link
- linkend="talloc_report"><quote>talloc_report_depth_file()</quote></link>,
- <link
- linkend="talloc_report"><quote>talloc_report()</quote></link>
- <link
- linkend="talloc_report"><quote>talloc_report()</quote></link>
- and <link
- linkend="talloc_report_full"><quote>talloc_report_full()</quote></link>
- for details. Also see <link
- linkend="talloc_enable_leak_report"><quote>talloc_enable_leak_report()</quote></link>
- and <link
- linkend="talloc_enable_leak_report_full"><quote>talloc_enable_leak_report_full()</quote></link>.
- </para>
- <para>
- The talloc_set_name() function allocates memory as a child of the
- pointer. It is logically equivalent to:
- </para>
- <programlisting>talloc_set_name_const(ptr, talloc_asprintf(ptr, fmt, ...));</programlisting>
- <para>
- Note that multiple calls to talloc_set_name() will allocate more
- memory without releasing the name. All of the memory is released
- when the ptr is freed using talloc_free().
- </para>
- </refsect2>
- <refsect2><title>void talloc_set_name_const(const void *<emphasis role="italic">ptr</emphasis>, const char *<emphasis role="italic">name</emphasis>);</title>
- <para>
- The function talloc_set_name_const() is just like
- talloc_set_name(), but it takes a string constant, and is much
- faster. It is extensively used by the "auto naming" macros, such
- as talloc_p().
- </para>
- <para>
- This function does not allocate any memory. It just copies the
- supplied pointer into the internal representation of the talloc
- ptr. This means you must not pass a <emphasis
- role="italic">name</emphasis> pointer to memory that will
- disappear before <emphasis role="italic">ptr</emphasis> is freed
- with talloc_free().
- </para>
- </refsect2>
- <refsect2><title>void *talloc_named(const void *<emphasis role="italic">ctx</emphasis>, size_t <emphasis role="italic">size</emphasis>, const char *<emphasis role="italic">fmt</emphasis>, ...);</title>
- <para>
- The talloc_named() function creates a named talloc pointer. It
- is equivalent to:
- </para>
- <programlisting>ptr = talloc_size(ctx, size);
-talloc_set_name(ptr, fmt, ....);</programlisting>
- </refsect2>
- <refsect2><title>void *talloc_named_const(const void *<emphasis role="italic">ctx</emphasis>, size_t <emphasis role="italic">size</emphasis>, const char *<emphasis role="italic">name</emphasis>);</title>
- <para>
- This is equivalent to:
- </para>
- <programlisting>ptr = talloc_size(ctx, size);
-talloc_set_name_const(ptr, name);</programlisting>
- </refsect2>
- <refsect2><title>const char *talloc_get_name(const void *<emphasis role="italic">ptr</emphasis>);</title>
- <para>
- This returns the current name for the given talloc pointer,
- <emphasis role="italic">ptr</emphasis>. See <link
- linkend="talloc_set_name"><quote>talloc_set_name()</quote></link>
- for details.
- </para>
- </refsect2>
- <refsect2><title>void *talloc_init(const char *<emphasis role="italic">fmt</emphasis>, ...);</title>
- <para>
- This function creates a zero length named talloc context as a top
- level context. It is equivalent to:
- </para>
- <programlisting>talloc_named(NULL, 0, fmt, ...);</programlisting>
- </refsect2>
- <refsect2><title>void *talloc_new(void *<emphasis role="italic">ctx</emphasis>);</title>
- <para>
- This is a utility macro that creates a new memory context hanging
- off an exiting context, automatically naming it "talloc_new:
- __location__" where __location__ is the source line it is called
- from. It is particularly useful for creating a new temporary
- working context.
- </para>
- </refsect2>
- <refsect2><title>(<emphasis role="italic">type</emphasis> *)talloc_realloc(const void *<emphasis role="italic">ctx</emphasis>, void *<emphasis role="italic">ptr</emphasis>, <emphasis role="italic">type</emphasis>, <emphasis role="italic">count</emphasis>);</title>
- <para>
- The talloc_realloc() macro changes the size of a talloc pointer.
- It has the following equivalences:
- </para>
- <programlisting>talloc_realloc(ctx, NULL, type, 1) ==> talloc(ctx, type);
-talloc_realloc(ctx, ptr, type, 0) ==> talloc_free(ptr);</programlisting>
- <para>
- The <emphasis role="italic">ctx</emphasis> argument is only used
- if <emphasis role="italic">ptr</emphasis> is not NULL, otherwise
- it is ignored.
- </para>
- <para>
- talloc_realloc() returns the new pointer, or NULL on failure.
- The call will fail either due to a lack of memory, or because the
- pointer has more than one parent (see <link
- linkend="talloc_reference"><quote>talloc_reference()</quote></link>).
- </para>
- </refsect2>
- <refsect2><title>void *talloc_realloc_size(const void *ctx, void *ptr, size_t size);</title>
- <para>
- the talloc_realloc_size() function is useful when the type is not
- known so the type-safe talloc_realloc() cannot be used.
- </para>
- </refsect2>
- <refsect2><title>TYPE *talloc_steal(const void *<emphasis role="italic">new_ctx</emphasis>, const TYPE *<emphasis role="italic">ptr</emphasis>);</title>
- <para>
- The talloc_steal() function changes the parent context of a
- talloc pointer. It is typically used when the context that the
- pointer is currently a child of is going to be freed and you wish
- to keep the memory for a longer time.
- </para>
- <para>
- The talloc_steal() function returns the pointer that you pass it.
- It does not have any failure modes.
- </para>
- <para>
- NOTE: It is possible to produce loops in the parent/child
- relationship if you are not careful with talloc_steal(). No
- guarantees are provided as to your sanity or the safety of your
- data if you do this.
- </para>
- </refsect2>
- <refsect2><title>TYPE *talloc_move(const void *<emphasis role="italic">new_ctx</emphasis>, TYPE **<emphasis role="italic">ptr</emphasis>);</title>
- <para>
- The talloc_move() function is a wrapper around
- talloc_steal() which zeros the source pointer after the
- move. This avoids a potential source of bugs where a
- programmer leaves a pointer in two structures, and uses the
- pointer from the old structure after it has been moved to a
- new one.
- </para>
- </refsect2>
- <refsect2><title>size_t talloc_total_size(const void *<emphasis role="italic">ptr</emphasis>);</title>
- <para>
- The talloc_total_size() function returns the total size in bytes
- used by this pointer and all child pointers. Mostly useful for
- debugging.
- </para>
- <para>
- Passing NULL is allowed, but it will only give a meaningful
- result if talloc_enable_leak_report() or
- talloc_enable_leak_report_full() has been called.
- </para>
- </refsect2>
- <refsect2><title>size_t talloc_total_blocks(const void *<emphasis role="italic">ptr</emphasis>);</title>
- <para>
- The talloc_total_blocks() function returns the total memory block
- count used by this pointer and all child pointers. Mostly useful
- for debugging.
- </para>
- <para>
- Passing NULL is allowed, but it will only give a meaningful
- result if talloc_enable_leak_report() or
- talloc_enable_leak_report_full() has been called.
- </para>
- </refsect2>
- <refsect2 id="talloc_report"><title>void talloc_report(const void *ptr, FILE *f);</title>
- <para>
- The talloc_report() function prints a summary report of all
- memory used by <emphasis role="italic">ptr</emphasis>. One line
- of report is printed for each immediate child of ptr, showing the
- total memory and number of blocks used by that child.
- </para>
- <para>
- You can pass NULL for the pointer, in which case a report is
- printed for the top level memory context, but only if
- talloc_enable_leak_report() or talloc_enable_leak_report_full()
- has been called.
- </para>
- </refsect2>
- <refsect2 id="talloc_report_full"><title>void talloc_report_full(const void *<emphasis role="italic">ptr</emphasis>, FILE *<emphasis role="italic">f</emphasis>);</title>
- <para>
- This provides a more detailed report than talloc_report(). It
- will recursively print the entire tree of memory referenced by
- the pointer. References in the tree are shown by giving the name
- of the pointer that is referenced.
- </para>
- <para>
- You can pass NULL for the pointer, in which case a report is
- printed for the top level memory context, but only if
- talloc_enable_leak_report() or talloc_enable_leak_report_full()
- has been called.
- </para>
- </refsect2>
- <refsect2 id="talloc_report_depth_cb">
- <funcsynopsis><funcprototype>
- <funcdef>void <function>talloc_report_depth_cb</function></funcdef>
- <paramdef><parameter>const void *ptr</parameter></paramdef>
- <paramdef><parameter>int depth</parameter></paramdef>
- <paramdef><parameter>int max_depth</parameter></paramdef>
- <paramdef><parameter>void (*callback)(const void *ptr, int depth, int max_depth, int is_ref, void *priv)</parameter></paramdef>
- <paramdef><parameter>void *priv</parameter></paramdef>
- </funcprototype></funcsynopsis>
- <para>
- This provides a more flexible reports than talloc_report(). It
- will recursively call the callback for the entire tree of memory
- referenced by the pointer. References in the tree are passed with
- <emphasis role="italic">is_ref = 1</emphasis> and the pointer that is referenced.
- </para>
- <para>
- You can pass NULL for the pointer, in which case a report is
- printed for the top level memory context, but only if
- talloc_enable_leak_report() or talloc_enable_leak_report_full()
- has been called.
- </para>
- <para>
- The recursion is stopped when depth >= max_depth.
- max_depth = -1 means only stop at leaf nodes.
- </para>
- </refsect2>
- <refsect2 id="talloc_report_depth_file">
- <funcsynopsis><funcprototype>
- <funcdef>void <function>talloc_report_depth_file</function></funcdef>
- <paramdef><parameter>const void *ptr</parameter></paramdef>
- <paramdef><parameter>int depth</parameter></paramdef>
- <paramdef><parameter>int max_depth</parameter></paramdef>
- <paramdef><parameter>FILE *f</parameter></paramdef>
- </funcprototype></funcsynopsis>
- <para>
- This provides a more flexible reports than talloc_report(). It
- will let you specify the depth and max_depth.
- </para>
- </refsect2>
- <refsect2 id="talloc_enable_leak_report"><title>void talloc_enable_leak_report(void);</title>
- <para>
- This enables calling of talloc_report(NULL, stderr) when the
- program exits. In Samba4 this is enabled by using the
- --leak-report command line option.
- </para>
- <para>
- For it to be useful, this function must be called before any
- other talloc function as it establishes a "null context" that
- acts as the top of the tree. If you don't call this function
- first then passing NULL to talloc_report() or
- talloc_report_full() won't give you the full tree printout.
- </para>
- <para>
- Here is a typical talloc report:
- </para>
- <screen format="linespecific">talloc report on 'null_context' (total 267 bytes in 15 blocks)
-libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks
-libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks
-iconv(UTF8,CP850) contains 42 bytes in 2 blocks
-libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks
-iconv(CP850,UTF8) contains 42 bytes in 2 blocks
-iconv(UTF8,UTF-16LE) contains 45 bytes in 2 blocks
-iconv(UTF-16LE,UTF8) contains 45 bytes in 2 blocks
- </screen>
- </refsect2>
- <refsect2 id="talloc_enable_leak_report_full"><title>void talloc_enable_leak_report_full(void);</title>
- <para>
- This enables calling of talloc_report_full(NULL, stderr) when the
- program exits. In Samba4 this is enabled by using the
- --leak-report-full command line option.
- </para>
- <para>
- For it to be useful, this function must be called before any
- other talloc function as it establishes a "null context" that
- acts as the top of the tree. If you don't call this function
- first then passing NULL to talloc_report() or
- talloc_report_full() won't give you the full tree printout.
- </para>
- <para>
- Here is a typical full report:
- </para>
- <screen format="linespecific">full talloc report on 'root' (total 18 bytes in 8 blocks)
-p1 contains 18 bytes in 7 blocks (ref 0)
- r1 contains 13 bytes in 2 blocks (ref 0)
- reference to: p2
- p2 contains 1 bytes in 1 blocks (ref 1)
- x3 contains 1 bytes in 1 blocks (ref 0)
- x2 contains 1 bytes in 1 blocks (ref 0)
- x1 contains 1 bytes in 1 blocks (ref 0)
- </screen>
- </refsect2>
- <refsect2><title>(<emphasis role="italic">type</emphasis> *)talloc_zero(const void *<emphasis role="italic">ctx</emphasis>, <emphasis role="italic">type</emphasis>);</title>
- <para>
- The talloc_zero() macro is equivalent to:
- </para>
- <programlisting>ptr = talloc(ctx, type);
-if (ptr) memset(ptr, 0, sizeof(type));</programlisting>
- </refsect2>
- <refsect2><title>void *talloc_zero_size(const void *<emphasis role="italic">ctx</emphasis>, size_t <emphasis role="italic">size</emphasis>)</title>
- <para>
- The talloc_zero_size() function is useful when you don't have a
- known type.
- </para>
- </refsect2>
- <refsect2><title>void *talloc_memdup(const void *<emphasis role="italic">ctx</emphasis>, const void *<emphasis role="italic">p</emphasis>, size_t size);</title>
- <para>
- The talloc_memdup() function is equivalent to:
- </para>
- <programlisting>ptr = talloc_size(ctx, size);
-if (ptr) memcpy(ptr, p, size);</programlisting>
- </refsect2>
- <refsect2><title>char *talloc_strdup(const void *<emphasis role="italic">ctx</emphasis>, const char *<emphasis role="italic">p</emphasis>);</title>
- <para>
- The talloc_strdup() function is equivalent to:
- </para>
- <programlisting>ptr = talloc_size(ctx, strlen(p)+1);
-if (ptr) memcpy(ptr, p, strlen(p)+1);</programlisting>
- <para>
- This function sets the name of the new pointer to the passed
- string. This is equivalent to:
- </para>
- <programlisting>talloc_set_name_const(ptr, ptr)</programlisting>
- </refsect2>
- <refsect2><title>char *talloc_strndup(const void *<emphasis role="italic">t</emphasis>, const char *<emphasis role="italic">p</emphasis>, size_t <emphasis role="italic">n</emphasis>);</title>
- <para>
- The talloc_strndup() function is the talloc equivalent of the C
- library function strndup(3).
- </para>
- <para>
- This function sets the name of the new pointer to the passed
- string. This is equivalent to:
- </para>
- <programlisting>talloc_set_name_const(ptr, ptr)</programlisting>
- </refsect2>
- <refsect2><title>char *talloc_append_string(const void *<emphasis role="italic">t</emphasis>, char *<emphasis role="italic">orig</emphasis>, const char *<emphasis role="italic">append</emphasis>);</title>
- <para>
- The talloc_append_string() function appends the given formatted
- string to the given string.
- </para>
- <para>
- This function sets the name of the new pointer to the new
- string. This is equivalent to:
- </para>
- <programlisting>talloc_set_name_const(ptr, ptr)</programlisting>
- </refsect2>
- <refsect2><title>char *talloc_vasprintf(const void *<emphasis role="italic">t</emphasis>, const char *<emphasis role="italic">fmt</emphasis>, va_list <emphasis role="italic">ap</emphasis>);</title>
- <para>
- The talloc_vasprintf() function is the talloc equivalent of the C
- library function vasprintf(3).
- </para>
- <para>
- This function sets the name of the new pointer to the new
- string. This is equivalent to:
- </para>
- <programlisting>talloc_set_name_const(ptr, ptr)</programlisting>
- </refsect2>
- <refsect2><title>char *talloc_asprintf(const void *<emphasis role="italic">t</emphasis>, const char *<emphasis role="italic">fmt</emphasis>, ...);</title>
- <para>
- The talloc_asprintf() function is the talloc equivalent of the C
- library function asprintf(3).
- </para>
- <para>
- This function sets the name of the new pointer to the passed
- string. This is equivalent to:
- </para>
- <programlisting>talloc_set_name_const(ptr, ptr)</programlisting>
- </refsect2>
- <refsect2><title>char *talloc_asprintf_append(char *s, const char *fmt, ...);</title>
- <para>
- The talloc_asprintf_append() function appends the given formatted
- string to the given string.
- </para>
- <para>
- This function sets the name of the new pointer to the new
- string. This is equivalent to:
- </para>
- <programlisting>talloc_set_name_const(ptr, ptr)</programlisting>
- </refsect2>
- <refsect2><title>(type *)talloc_array(const void *ctx, type, uint_t count);</title>
- <para>
- The talloc_array() macro is equivalent to:
- </para>
- <programlisting>(type *)talloc_size(ctx, sizeof(type) * count);</programlisting>
- <para>
- except that it provides integer overflow protection for the
- multiply, returning NULL if the multiply overflows.
- </para>
- </refsect2>
- <refsect2><title>void *talloc_array_size(const void *ctx, size_t size, uint_t count);</title>
- <para>
- The talloc_array_size() function is useful when the type is not
- known. It operates in the same way as talloc_array(), but takes a
- size instead of a type.
- </para>
- </refsect2>
- <refsect2><title>(typeof(ptr)) talloc_array_ptrtype(const void *ctx, ptr, uint_t count);</title>
- <para>
- The talloc_ptrtype() macro should be used when you have a pointer to an array
- and want to allocate memory of an array to point at with this pointer. When compiling
- with gcc >= 3 it is typesafe. Note this is a wrapper of talloc_array_size()
- and talloc_get_name() will return the current location in the source file.
- and not the type.
- </para>
- </refsect2>
- <refsect2><title>void *talloc_realloc_fn(const void *ctx, void *ptr, size_t size)</title>
- <para>
- This is a non-macro version of talloc_realloc(), which is useful
- as libraries sometimes want a realloc function pointer. A
- realloc(3) implementation encapsulates the functionality of
- malloc(3), free(3) and realloc(3) in one call, which is why it is
- useful to be able to pass around a single function pointer.
- </para>
- </refsect2>
- <refsect2><title>void *talloc_autofree_context(void);</title>
- <para>
- This is a handy utility function that returns a talloc context
- which will be automatically freed on program exit. This can be
- used to reduce the noise in memory leak reports.
- </para>
- </refsect2>
- <refsect2><title>void *talloc_check_name(const void *ptr, const char *name);</title>
- <para>
- This function checks if a pointer has the specified <emphasis
- role="italic">name</emphasis>. If it does then the pointer is
- returned. It it doesn't then NULL is returned.
- </para>
- </refsect2>
- <refsect2><title>(type *)talloc_get_type(const void *ptr, type);</title>
- <para>
- This macro allows you to do type checking on talloc pointers. It
- is particularly useful for void* private pointers. It is
- equivalent to this:
- </para>
- <programlisting>(type *)talloc_check_name(ptr, #type)</programlisting>
- </refsect2>
- <refsect2><title>talloc_set_type(const void *ptr, type);</title>
- <para>
- This macro allows you to force the name of a pointer to be a
- particular <emphasis>type</emphasis>. This can be
- used in conjunction with talloc_get_type() to do type checking on
- void* pointers.
- </para>
- <para>
- It is equivalent to this:
- </para>
- <programlisting>talloc_set_name_const(ptr, #type)</programlisting>
- </refsect2>
- </refsect1>
- <refsect1><title>PERFORMANCE</title>
- <para>
- All the additional features of talloc(3) over malloc(3) do come at a
- price. We have a simple performance test in Samba4 that measures
- talloc() versus malloc() performance, and it seems that talloc() is
- about 10% slower than malloc() on my x86 Debian Linux box. For
- Samba, the great reduction in code complexity that we get by using
- talloc makes this worthwhile, especially as the total overhead of
- talloc/malloc in Samba is already quite small.
- </para>
- </refsect1>
- <refsect1><title>SEE ALSO</title>
- <para>
- malloc(3), strndup(3), vasprintf(3), asprintf(3),
- <ulink url="http://talloc.samba.org/"/>
- </para>
- </refsect1>
- <refsect1><title>COPYRIGHT/LICENSE</title>
- <para>
- Copyright (C) Andrew Tridgell 2004
- </para>
- <para>
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or (at
- your option) any later version.
- </para>
- <para>
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
- </para>
- <para>
- You should have received a copy of the GNU General Public License
- along with this program; if not, see http://www.gnu.org/licenses/.
- </para>
- </refsect1>
-</refentry>
diff --git a/source4/lib/talloc/talloc.c b/source4/lib/talloc/talloc.c
deleted file mode 100644
index 1f7e52439f..0000000000
--- a/source4/lib/talloc/talloc.c
+++ /dev/null
@@ -1,1732 +0,0 @@
-/*
- Samba Unix SMB/CIFS implementation.
-
- Samba trivial allocation library - new interface
-
- NOTE: Please read talloc_guide.txt for full documentation
-
- Copyright (C) Andrew Tridgell 2004
- Copyright (C) Stefan Metzmacher 2006
-
- ** NOTE! The following LGPL license applies to the talloc
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-/*
- inspired by http://swapped.cc/halloc/
-*/
-
-#ifdef _SAMBA_BUILD_
-#include "version.h"
-#if (SAMBA_VERSION_MAJOR<4)
-#include "includes.h"
-/* This is to circumvent SAMBA3's paranoid malloc checker. Here in this file
- * we trust ourselves... */
-#ifdef malloc
-#undef malloc
-#endif
-#ifdef realloc
-#undef realloc
-#endif
-#define _TALLOC_SAMBA3
-#endif /* (SAMBA_VERSION_MAJOR<4) */
-#endif /* _SAMBA_BUILD_ */
-
-#ifndef _TALLOC_SAMBA3
-#include "replace.h"
-#include "talloc.h"
-#endif /* not _TALLOC_SAMBA3 */
-
-/* use this to force every realloc to change the pointer, to stress test
- code that might not cope */
-#define ALWAYS_REALLOC 0
-
-
-#define MAX_TALLOC_SIZE 0x10000000
-#define TALLOC_MAGIC 0xe814ec70
-#define TALLOC_FLAG_FREE 0x01
-#define TALLOC_FLAG_LOOP 0x02
-#define TALLOC_FLAG_POOL 0x04 /* This is a talloc pool */
-#define TALLOC_FLAG_POOLMEM 0x08 /* This is allocated in a pool */
-#define TALLOC_MAGIC_REFERENCE ((const char *)1)
-
-/* by default we abort when given a bad pointer (such as when talloc_free() is called
- on a pointer that came from malloc() */
-#ifndef TALLOC_ABORT
-#define TALLOC_ABORT(reason) abort()
-#endif
-
-#ifndef discard_const_p
-#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T)
-# define discard_const_p(type, ptr) ((type *)((intptr_t)(ptr)))
-#else
-# define discard_const_p(type, ptr) ((type *)(ptr))
-#endif
-#endif
-
-/* these macros gain us a few percent of speed on gcc */
-#if (__GNUC__ >= 3)
-/* the strange !! is to ensure that __builtin_expect() takes either 0 or 1
- as its first argument */
-#ifndef likely
-#define likely(x) __builtin_expect(!!(x), 1)
-#endif
-#ifndef unlikely
-#define unlikely(x) __builtin_expect(!!(x), 0)
-#endif
-#else
-#ifndef likely
-#define likely(x) (x)
-#endif
-#ifndef unlikely
-#define unlikely(x) (x)
-#endif
-#endif
-
-/* this null_context is only used if talloc_enable_leak_report() or
- talloc_enable_leak_report_full() is called, otherwise it remains
- NULL
-*/
-static void *null_context;
-static void *autofree_context;
-
-struct talloc_reference_handle {
- struct talloc_reference_handle *next, *prev;
- void *ptr;
-};
-
-typedef int (*talloc_destructor_t)(void *);
-
-struct talloc_chunk {
- struct talloc_chunk *next, *prev;
- struct talloc_chunk *parent, *child;
- struct talloc_reference_handle *refs;
- talloc_destructor_t destructor;
- const char *name;
- size_t size;
- unsigned flags;
-
- /*
- * "pool" has dual use:
- *
- * For the talloc pool itself (i.e. TALLOC_FLAG_POOL is set), "pool"
- * marks the end of the currently allocated area.
- *
- * For members of the pool (i.e. TALLOC_FLAG_POOLMEM is set), "pool"
- * is a pointer to the struct talloc_chunk of the pool that it was
- * allocated from. This way children can quickly find the pool to chew
- * from.
- */
- void *pool;
-};
-
-/* 16 byte alignment seems to keep everyone happy */
-#define TC_HDR_SIZE ((sizeof(struct talloc_chunk)+15)&~15)
-#define TC_PTR_FROM_CHUNK(tc) ((void *)(TC_HDR_SIZE + (char*)tc))
-
-static void talloc_abort_double_free(void)
-{
- TALLOC_ABORT("Bad talloc magic value - double free");
-}
-
-static void talloc_abort_unknown_value(void)
-{
- TALLOC_ABORT("Bad talloc magic value - unknown value");
-}
-
-/* panic if we get a bad magic value */
-static inline struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr)
-{
- const char *pp = (const char *)ptr;
- struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, pp - TC_HDR_SIZE);
- if (unlikely((tc->flags & (TALLOC_FLAG_FREE | ~0xF)) != TALLOC_MAGIC)) {
- if (tc->flags & TALLOC_FLAG_FREE) {
- talloc_abort_double_free();
- } else {
- talloc_abort_unknown_value();
- }
- }
- return tc;
-}
-
-/* hook into the front of the list */
-#define _TLIST_ADD(list, p) \
-do { \
- if (!(list)) { \
- (list) = (p); \
- (p)->next = (p)->prev = NULL; \
- } else { \
- (list)->prev = (p); \
- (p)->next = (list); \
- (p)->prev = NULL; \
- (list) = (p); \
- }\
-} while (0)
-
-/* remove an element from a list - element doesn't have to be in list. */
-#define _TLIST_REMOVE(list, p) \
-do { \
- if ((p) == (list)) { \
- (list) = (p)->next; \
- if (list) (list)->prev = NULL; \
- } else { \
- if ((p)->prev) (p)->prev->next = (p)->next; \
- if ((p)->next) (p)->next->prev = (p)->prev; \
- } \
- if ((p) && ((p) != (list))) (p)->next = (p)->prev = NULL; \
-} while (0)
-
-
-/*
- return the parent chunk of a pointer
-*/
-static inline struct talloc_chunk *talloc_parent_chunk(const void *ptr)
-{
- struct talloc_chunk *tc;
-
- if (unlikely(ptr == NULL)) {
- return NULL;
- }
-
- tc = talloc_chunk_from_ptr(ptr);
- while (tc->prev) tc=tc->prev;
-
- return tc->parent;
-}
-
-void *talloc_parent(const void *ptr)
-{
- struct talloc_chunk *tc = talloc_parent_chunk(ptr);
- return tc? TC_PTR_FROM_CHUNK(tc) : NULL;
-}
-
-/*
- find parents name
-*/
-const char *talloc_parent_name(const void *ptr)
-{
- struct talloc_chunk *tc = talloc_parent_chunk(ptr);
- return tc? tc->name : NULL;
-}
-
-/*
- A pool carries an in-pool object count count in the first 16 bytes.
- bytes. This is done to support talloc_steal() to a parent outside of the
- pool. The count includes the pool itself, so a talloc_free() on a pool will
- only destroy the pool if the count has dropped to zero. A talloc_free() of a
- pool member will reduce the count, and eventually also call free(3) on the
- pool memory.
-
- The object count is not put into "struct talloc_chunk" because it is only
- relevant for talloc pools and the alignment to 16 bytes would increase the
- memory footprint of each talloc chunk by those 16 bytes.
-*/
-
-#define TALLOC_POOL_HDR_SIZE 16
-
-static unsigned int *talloc_pool_objectcount(struct talloc_chunk *tc)
-{
- return (unsigned int *)((char *)tc + sizeof(struct talloc_chunk));
-}
-
-/*
- Allocate from a pool
-*/
-
-static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
- size_t size)
-{
- struct talloc_chunk *pool_ctx = NULL;
- size_t space_left;
- struct talloc_chunk *result;
- size_t chunk_size;
-
- if (parent == NULL) {
- return NULL;
- }
-
- if (parent->flags & TALLOC_FLAG_POOL) {
- pool_ctx = parent;
- }
- else if (parent->flags & TALLOC_FLAG_POOLMEM) {
- pool_ctx = (struct talloc_chunk *)parent->pool;
- }
-
- if (pool_ctx == NULL) {
- return NULL;
- }
-
- space_left = ((char *)pool_ctx + TC_HDR_SIZE + pool_ctx->size)
- - ((char *)pool_ctx->pool);
-
- /*
- * Align size to 16 bytes
- */
- chunk_size = ((size + 15) & ~15);
-
- if (space_left < chunk_size) {
- return NULL;
- }
-
- result = (struct talloc_chunk *)pool_ctx->pool;
-
-#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_UNDEFINED)
- VALGRIND_MAKE_MEM_UNDEFINED(result, size);
-#endif
-
- pool_ctx->pool = (void *)((char *)result + chunk_size);
-
- result->flags = TALLOC_MAGIC | TALLOC_FLAG_POOLMEM;
- result->pool = pool_ctx;
-
- *talloc_pool_objectcount(pool_ctx) += 1;
-
- return result;
-}
-
-/*
- Allocate a bit of memory as a child of an existing pointer
-*/
-static inline void *__talloc(const void *context, size_t size)
-{
- struct talloc_chunk *tc = NULL;
-
- if (unlikely(context == NULL)) {
- context = null_context;
- }
-
- if (unlikely(size >= MAX_TALLOC_SIZE)) {
- return NULL;
- }
-
- if (context != NULL) {
- tc = talloc_alloc_pool(talloc_chunk_from_ptr(context),
- TC_HDR_SIZE+size);
- }
-
- if (tc == NULL) {
- tc = (struct talloc_chunk *)malloc(TC_HDR_SIZE+size);
- if (unlikely(tc == NULL)) return NULL;
- tc->flags = TALLOC_MAGIC;
- tc->pool = NULL;
- }
-
- tc->size = size;
- tc->destructor = NULL;
- tc->child = NULL;
- tc->name = NULL;
- tc->refs = NULL;
-
- if (likely(context)) {
- struct talloc_chunk *parent = talloc_chunk_from_ptr(context);
-
- if (parent->child) {
- parent->child->parent = NULL;
- tc->next = parent->child;
- tc->next->prev = tc;
- } else {
- tc->next = NULL;
- }
- tc->parent = parent;
- tc->prev = NULL;
- parent->child = tc;
- } else {
- tc->next = tc->prev = tc->parent = NULL;
- }
-
- return TC_PTR_FROM_CHUNK(tc);
-}
-
-/*
- * Create a talloc pool
- */
-
-void *talloc_pool(const void *context, size_t size)
-{
- void *result = __talloc(context, size + TALLOC_POOL_HDR_SIZE);
- struct talloc_chunk *tc;
-
- if (unlikely(result == NULL)) {
- return NULL;
- }
-
- tc = talloc_chunk_from_ptr(result);
-
- tc->flags |= TALLOC_FLAG_POOL;
- tc->pool = (char *)result + TALLOC_POOL_HDR_SIZE;
-
- *talloc_pool_objectcount(tc) = 1;
-
-#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS)
- VALGRIND_MAKE_MEM_NOACCESS(tc->pool, size);
-#endif
-
- return result;
-}
-
-/*
- setup a destructor to be called on free of a pointer
- the destructor should return 0 on success, or -1 on failure.
- if the destructor fails then the free is failed, and the memory can
- be continued to be used
-*/
-void _talloc_set_destructor(const void *ptr, int (*destructor)(void *))
-{
- struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
- tc->destructor = destructor;
-}
-
-/*
- increase the reference count on a piece of memory.
-*/
-int talloc_increase_ref_count(const void *ptr)
-{
- if (unlikely(!talloc_reference(null_context, ptr))) {
- return -1;
- }
- return 0;
-}
-
-/*
- helper for talloc_reference()
-
- this is referenced by a function pointer and should not be inline
-*/
-static int talloc_reference_destructor(struct talloc_reference_handle *handle)
-{
- struct talloc_chunk *ptr_tc = talloc_chunk_from_ptr(handle->ptr);
- _TLIST_REMOVE(ptr_tc->refs, handle);
- return 0;
-}
-
-/*
- more efficient way to add a name to a pointer - the name must point to a
- true string constant
-*/
-static inline void _talloc_set_name_const(const void *ptr, const char *name)
-{
- struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
- tc->name = name;
-}
-
-/*
- internal talloc_named_const()
-*/
-static inline void *_talloc_named_const(const void *context, size_t size, const char *name)
-{
- void *ptr;
-
- ptr = __talloc(context, size);
- if (unlikely(ptr == NULL)) {
- return NULL;
- }
-
- _talloc_set_name_const(ptr, name);
-
- return ptr;
-}
-
-/*
- make a secondary reference to a pointer, hanging off the given context.
- the pointer remains valid until both the original caller and this given
- context are freed.
-
- the major use for this is when two different structures need to reference the
- same underlying data, and you want to be able to free the two instances separately,
- and in either order
-*/
-void *_talloc_reference(const void *context, const void *ptr)
-{
- struct talloc_chunk *tc;
- struct talloc_reference_handle *handle;
- if (unlikely(ptr == NULL)) return NULL;
-
- tc = talloc_chunk_from_ptr(ptr);
- handle = (struct talloc_reference_handle *)_talloc_named_const(context,
- sizeof(struct talloc_reference_handle),
- TALLOC_MAGIC_REFERENCE);
- if (unlikely(handle == NULL)) return NULL;
-
- /* note that we hang the destructor off the handle, not the
- main context as that allows the caller to still setup their
- own destructor on the context if they want to */
- talloc_set_destructor(handle, talloc_reference_destructor);
- handle->ptr = discard_const_p(void, ptr);
- _TLIST_ADD(tc->refs, handle);
- return handle->ptr;
-}
-
-
-/*
- internal talloc_free call
-*/
-static inline int _talloc_free(void *ptr)
-{
- struct talloc_chunk *tc;
-
- if (unlikely(ptr == NULL)) {
- return -1;
- }
-
- tc = talloc_chunk_from_ptr(ptr);
-
- if (unlikely(tc->refs)) {
- int is_child;
- /* check this is a reference from a child or grantchild
- * back to it's parent or grantparent
- *
- * in that case we need to remove the reference and
- * call another instance of talloc_free() on the current
- * pointer.
- */
- is_child = talloc_is_parent(tc->refs, ptr);
- _talloc_free(tc->refs);
- if (is_child) {
- return _talloc_free(ptr);
- }
- return -1;
- }
-
- if (unlikely(tc->flags & TALLOC_FLAG_LOOP)) {
- /* we have a free loop - stop looping */
- return 0;
- }
-
- if (unlikely(tc->destructor)) {
- talloc_destructor_t d = tc->destructor;
- if (d == (talloc_destructor_t)-1) {
- return -1;
- }
- tc->destructor = (talloc_destructor_t)-1;
- if (d(ptr) == -1) {
- tc->destructor = d;
- return -1;
- }
- tc->destructor = NULL;
- }
-
- if (tc->parent) {
- _TLIST_REMOVE(tc->parent->child, tc);
- if (tc->parent->child) {
- tc->parent->child->parent = tc->parent;
- }
- } else {
- if (tc->prev) tc->prev->next = tc->next;
- if (tc->next) tc->next->prev = tc->prev;
- }
-
- tc->flags |= TALLOC_FLAG_LOOP;
-
- while (tc->child) {
- /* we need to work out who will own an abandoned child
- if it cannot be freed. In priority order, the first
- choice is owner of any remaining reference to this
- pointer, the second choice is our parent, and the
- final choice is the null context. */
- void *child = TC_PTR_FROM_CHUNK(tc->child);
- const void *new_parent = null_context;
- if (unlikely(tc->child->refs)) {
- struct talloc_chunk *p = talloc_parent_chunk(tc->child->refs);
- if (p) new_parent = TC_PTR_FROM_CHUNK(p);
- }
- if (unlikely(_talloc_free(child) == -1)) {
- if (new_parent == null_context) {
- struct talloc_chunk *p = talloc_parent_chunk(ptr);
- if (p) new_parent = TC_PTR_FROM_CHUNK(p);
- }
- talloc_steal(new_parent, child);
- }
- }
-
- tc->flags |= TALLOC_FLAG_FREE;
-
- if (tc->flags & (TALLOC_FLAG_POOL|TALLOC_FLAG_POOLMEM)) {
- struct talloc_chunk *pool;
- unsigned int *pool_object_count;
-
- pool = (tc->flags & TALLOC_FLAG_POOL)
- ? tc : (struct talloc_chunk *)tc->pool;
-
- pool_object_count = talloc_pool_objectcount(pool);
-
- if (*pool_object_count == 0) {
- TALLOC_ABORT("Pool object count zero!");
- }
-
- *pool_object_count -= 1;
-
- if (*pool_object_count == 0) {
- free(pool);
- }
- }
- else {
- free(tc);
- }
- return 0;
-}
-
-/*
- move a lump of memory from one talloc context to another return the
- ptr on success, or NULL if it could not be transferred.
- passing NULL as ptr will always return NULL with no side effects.
-*/
-void *_talloc_steal(const void *new_ctx, const void *ptr)
-{
- struct talloc_chunk *tc, *new_tc;
-
- if (unlikely(!ptr)) {
- return NULL;
- }
-
- if (unlikely(new_ctx == NULL)) {
- new_ctx = null_context;
- }
-
- tc = talloc_chunk_from_ptr(ptr);
-
- if (unlikely(new_ctx == NULL)) {
- if (tc->parent) {
- _TLIST_REMOVE(tc->parent->child, tc);
- if (tc->parent->child) {
- tc->parent->child->parent = tc->parent;
- }
- } else {
- if (tc->prev) tc->prev->next = tc->next;
- if (tc->next) tc->next->prev = tc->prev;
- }
-
- tc->parent = tc->next = tc->prev = NULL;
- return discard_const_p(void, ptr);
- }
-
- new_tc = talloc_chunk_from_ptr(new_ctx);
-
- if (unlikely(tc == new_tc || tc->parent == new_tc)) {
- return discard_const_p(void, ptr);
- }
-
- if (tc->parent) {
- _TLIST_REMOVE(tc->parent->child, tc);
- if (tc->parent->child) {
- tc->parent->child->parent = tc->parent;
- }
- } else {
- if (tc->prev) tc->prev->next = tc->next;
- if (tc->next) tc->next->prev = tc->prev;
- }
-
- tc->parent = new_tc;
- if (new_tc->child) new_tc->child->parent = NULL;
- _TLIST_ADD(new_tc->child, tc);
-
- return discard_const_p(void, ptr);
-}
-
-
-
-/*
- remove a secondary reference to a pointer. This undo's what
- talloc_reference() has done. The context and pointer arguments
- must match those given to a talloc_reference()
-*/
-static inline int talloc_unreference(const void *context, const void *ptr)
-{
- struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
- struct talloc_reference_handle *h;
-
- if (unlikely(context == NULL)) {
- context = null_context;
- }
-
- for (h=tc->refs;h;h=h->next) {
- struct talloc_chunk *p = talloc_parent_chunk(h);
- if (p == NULL) {
- if (context == NULL) break;
- } else if (TC_PTR_FROM_CHUNK(p) == context) {
- break;
- }
- }
- if (h == NULL) {
- return -1;
- }
-
- return _talloc_free(h);
-}
-
-/*
- remove a specific parent context from a pointer. This is a more
- controlled varient of talloc_free()
-*/
-int talloc_unlink(const void *context, void *ptr)
-{
- struct talloc_chunk *tc_p, *new_p;
- void *new_parent;
-
- if (ptr == NULL) {
- return -1;
- }
-
- if (context == NULL) {
- context = null_context;
- }
-
- if (talloc_unreference(context, ptr) == 0) {
- return 0;
- }
-
- if (context == NULL) {
- if (talloc_parent_chunk(ptr) != NULL) {
- return -1;
- }
- } else {
- if (talloc_chunk_from_ptr(context) != talloc_parent_chunk(ptr)) {
- return -1;
- }
- }
-
- tc_p = talloc_chunk_from_ptr(ptr);
-
- if (tc_p->refs == NULL) {
- return _talloc_free(ptr);
- }
-
- new_p = talloc_parent_chunk(tc_p->refs);
- if (new_p) {
- new_parent = TC_PTR_FROM_CHUNK(new_p);
- } else {
- new_parent = NULL;
- }
-
- if (talloc_unreference(new_parent, ptr) != 0) {
- return -1;
- }
-
- talloc_steal(new_parent, ptr);
-
- return 0;
-}
-
-/*
- add a name to an existing pointer - va_list version
-*/
-static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
-
-static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap)
-{
- struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
- tc->name = talloc_vasprintf(ptr, fmt, ap);
- if (likely(tc->name)) {
- _talloc_set_name_const(tc->name, ".name");
- }
- return tc->name;
-}
-
-/*
- add a name to an existing pointer
-*/
-const char *talloc_set_name(const void *ptr, const char *fmt, ...)
-{
- const char *name;
- va_list ap;
- va_start(ap, fmt);
- name = talloc_set_name_v(ptr, fmt, ap);
- va_end(ap);
- return name;
-}
-
-
-/*
- create a named talloc pointer. Any talloc pointer can be named, and
- talloc_named() operates just like talloc() except that it allows you
- to name the pointer.
-*/
-void *talloc_named(const void *context, size_t size, const char *fmt, ...)
-{
- va_list ap;
- void *ptr;
- const char *name;
-
- ptr = __talloc(context, size);
- if (unlikely(ptr == NULL)) return NULL;
-
- va_start(ap, fmt);
- name = talloc_set_name_v(ptr, fmt, ap);
- va_end(ap);
-
- if (unlikely(name == NULL)) {
- _talloc_free(ptr);
- return NULL;
- }
-
- return ptr;
-}
-
-/*
- return the name of a talloc ptr, or "UNNAMED"
-*/
-const char *talloc_get_name(const void *ptr)
-{
- struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
- if (unlikely(tc->name == TALLOC_MAGIC_REFERENCE)) {
- return ".reference";
- }
- if (likely(tc->name)) {
- return tc->name;
- }
- return "UNNAMED";
-}
-
-
-/*
- check if a pointer has the given name. If it does, return the pointer,
- otherwise return NULL
-*/
-void *talloc_check_name(const void *ptr, const char *name)
-{
- const char *pname;
- if (unlikely(ptr == NULL)) return NULL;
- pname = talloc_get_name(ptr);
- if (likely(pname == name || strcmp(pname, name) == 0)) {
- return discard_const_p(void, ptr);
- }
- return NULL;
-}
-
-
-/*
- this is for compatibility with older versions of talloc
-*/
-void *talloc_init(const char *fmt, ...)
-{
- va_list ap;
- void *ptr;
- const char *name;
-
- /*
- * samba3 expects talloc_report_depth_cb(NULL, ...)
- * reports all talloc'ed memory, so we need to enable
- * null_tracking
- */
- talloc_enable_null_tracking();
-
- ptr = __talloc(NULL, 0);
- if (unlikely(ptr == NULL)) return NULL;
-
- va_start(ap, fmt);
- name = talloc_set_name_v(ptr, fmt, ap);
- va_end(ap);
-
- if (unlikely(name == NULL)) {
- _talloc_free(ptr);
- return NULL;
- }
-
- return ptr;
-}
-
-/*
- this is a replacement for the Samba3 talloc_destroy_pool functionality. It
- should probably not be used in new code. It's in here to keep the talloc
- code consistent across Samba 3 and 4.
-*/
-void talloc_free_children(void *ptr)
-{
- struct talloc_chunk *tc;
-
- if (unlikely(ptr == NULL)) {
- return;
- }
-
- tc = talloc_chunk_from_ptr(ptr);
-
- while (tc->child) {
- /* we need to work out who will own an abandoned child
- if it cannot be freed. In priority order, the first
- choice is owner of any remaining reference to this
- pointer, the second choice is our parent, and the
- final choice is the null context. */
- void *child = TC_PTR_FROM_CHUNK(tc->child);
- const void *new_parent = null_context;
- if (unlikely(tc->child->refs)) {
- struct talloc_chunk *p = talloc_parent_chunk(tc->child->refs);
- if (p) new_parent = TC_PTR_FROM_CHUNK(p);
- }
- if (unlikely(_talloc_free(child) == -1)) {
- if (new_parent == null_context) {
- struct talloc_chunk *p = talloc_parent_chunk(ptr);
- if (p) new_parent = TC_PTR_FROM_CHUNK(p);
- }
- talloc_steal(new_parent, child);
- }
- }
-
- if ((tc->flags & TALLOC_FLAG_POOL)
- && (*talloc_pool_objectcount(tc) == 1)) {
- tc->pool = ((char *)tc + TC_HDR_SIZE + TALLOC_POOL_HDR_SIZE);
-#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS)
- VALGRIND_MAKE_MEM_NOACCESS(
- tc->pool, tc->size - TALLOC_POOL_HDR_SIZE);
-#endif
- }
-}
-
-/*
- Allocate a bit of memory as a child of an existing pointer
-*/
-void *_talloc(const void *context, size_t size)
-{
- return __talloc(context, size);
-}
-
-/*
- externally callable talloc_set_name_const()
-*/
-void talloc_set_name_const(const void *ptr, const char *name)
-{
- _talloc_set_name_const(ptr, name);
-}
-
-/*
- create a named talloc pointer. Any talloc pointer can be named, and
- talloc_named() operates just like talloc() except that it allows you
- to name the pointer.
-*/
-void *talloc_named_const(const void *context, size_t size, const char *name)
-{
- return _talloc_named_const(context, size, name);
-}
-
-/*
- free a talloc pointer. This also frees all child pointers of this
- pointer recursively
-
- return 0 if the memory is actually freed, otherwise -1. The memory
- will not be freed if the ref_count is > 1 or the destructor (if
- any) returns non-zero
-*/
-int talloc_free(void *ptr)
-{
- return _talloc_free(ptr);
-}
-
-
-
-/*
- A talloc version of realloc. The context argument is only used if
- ptr is NULL
-*/
-void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name)
-{
- struct talloc_chunk *tc;
- void *new_ptr;
- bool malloced = false;
-
- /* size zero is equivalent to free() */
- if (unlikely(size == 0)) {
- _talloc_free(ptr);
- return NULL;
- }
-
- if (unlikely(size >= MAX_TALLOC_SIZE)) {
- return NULL;
- }
-
- /* realloc(NULL) is equivalent to malloc() */
- if (ptr == NULL) {
- return _talloc_named_const(context, size, name);
- }
-
- tc = talloc_chunk_from_ptr(ptr);
-
- /* don't allow realloc on referenced pointers */
- if (unlikely(tc->refs)) {
- return NULL;
- }
-
- /* don't shrink if we have less than 1k to gain */
- if ((size < tc->size) && ((tc->size - size) < 1024)) {
- tc->size = size;
- return ptr;
- }
-
- /* by resetting magic we catch users of the old memory */
- tc->flags |= TALLOC_FLAG_FREE;
-
-#if ALWAYS_REALLOC
- new_ptr = malloc(size + TC_HDR_SIZE);
- if (new_ptr) {
- memcpy(new_ptr, tc, tc->size + TC_HDR_SIZE);
- free(tc);
- }
-#else
- if (tc->flags & TALLOC_FLAG_POOLMEM) {
-
- new_ptr = talloc_alloc_pool(tc, size + TC_HDR_SIZE);
- *talloc_pool_objectcount((struct talloc_chunk *)
- (tc->pool)) -= 1;
-
- if (new_ptr == NULL) {
- new_ptr = malloc(TC_HDR_SIZE+size);
- malloced = true;
- }
-
- if (new_ptr) {
- memcpy(new_ptr, tc, MIN(tc->size,size) + TC_HDR_SIZE);
- }
- }
- else {
- new_ptr = realloc(tc, size + TC_HDR_SIZE);
- }
-#endif
- if (unlikely(!new_ptr)) {
- tc->flags &= ~TALLOC_FLAG_FREE;
- return NULL;
- }
-
- tc = (struct talloc_chunk *)new_ptr;
- tc->flags &= ~TALLOC_FLAG_FREE;
- if (malloced) {
- tc->flags &= ~TALLOC_FLAG_POOLMEM;
- }
- if (tc->parent) {
- tc->parent->child = tc;
- }
- if (tc->child) {
- tc->child->parent = tc;
- }
-
- if (tc->prev) {
- tc->prev->next = tc;
- }
- if (tc->next) {
- tc->next->prev = tc;
- }
-
- tc->size = size;
- _talloc_set_name_const(TC_PTR_FROM_CHUNK(tc), name);
-
- return TC_PTR_FROM_CHUNK(tc);
-}
-
-/*
- a wrapper around talloc_steal() for situations where you are moving a pointer
- between two structures, and want the old pointer to be set to NULL
-*/
-void *_talloc_move(const void *new_ctx, const void *_pptr)
-{
- const void **pptr = discard_const_p(const void *,_pptr);
- void *ret = _talloc_steal(new_ctx, *pptr);
- (*pptr) = NULL;
- return ret;
-}
-
-/*
- return the total size of a talloc pool (subtree)
-*/
-size_t talloc_total_size(const void *ptr)
-{
- size_t total = 0;
- struct talloc_chunk *c, *tc;
-
- if (ptr == NULL) {
- ptr = null_context;
- }
- if (ptr == NULL) {
- return 0;
- }
-
- tc = talloc_chunk_from_ptr(ptr);
-
- if (tc->flags & TALLOC_FLAG_LOOP) {
- return 0;
- }
-
- tc->flags |= TALLOC_FLAG_LOOP;
-
- total = tc->size;
- for (c=tc->child;c;c=c->next) {
- total += talloc_total_size(TC_PTR_FROM_CHUNK(c));
- }
-
- tc->flags &= ~TALLOC_FLAG_LOOP;
-
- return total;
-}
-
-/*
- return the total number of blocks in a talloc pool (subtree)
-*/
-size_t talloc_total_blocks(const void *ptr)
-{
- size_t total = 0;
- struct talloc_chunk *c, *tc = talloc_chunk_from_ptr(ptr);
-
- if (tc->flags & TALLOC_FLAG_LOOP) {
- return 0;
- }
-
- tc->flags |= TALLOC_FLAG_LOOP;
-
- total++;
- for (c=tc->child;c;c=c->next) {
- total += talloc_total_blocks(TC_PTR_FROM_CHUNK(c));
- }
-
- tc->flags &= ~TALLOC_FLAG_LOOP;
-
- return total;
-}
-
-/*
- return the number of external references to a pointer
-*/
-size_t talloc_reference_count(const void *ptr)
-{
- struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
- struct talloc_reference_handle *h;
- size_t ret = 0;
-
- for (h=tc->refs;h;h=h->next) {
- ret++;
- }
- return ret;
-}
-
-/*
- report on memory usage by all children of a pointer, giving a full tree view
-*/
-void talloc_report_depth_cb(const void *ptr, int depth, int max_depth,
- void (*callback)(const void *ptr,
- int depth, int max_depth,
- int is_ref,
- void *private_data),
- void *private_data)
-{
- struct talloc_chunk *c, *tc;
-
- if (ptr == NULL) {
- ptr = null_context;
- }
- if (ptr == NULL) return;
-
- tc = talloc_chunk_from_ptr(ptr);
-
- if (tc->flags & TALLOC_FLAG_LOOP) {
- return;
- }
-
- callback(ptr, depth, max_depth, 0, private_data);
-
- if (max_depth >= 0 && depth >= max_depth) {
- return;
- }
-
- tc->flags |= TALLOC_FLAG_LOOP;
- for (c=tc->child;c;c=c->next) {
- if (c->name == TALLOC_MAGIC_REFERENCE) {
- struct talloc_reference_handle *h = (struct talloc_reference_handle *)TC_PTR_FROM_CHUNK(c);
- callback(h->ptr, depth + 1, max_depth, 1, private_data);
- } else {
- talloc_report_depth_cb(TC_PTR_FROM_CHUNK(c), depth + 1, max_depth, callback, private_data);
- }
- }
- tc->flags &= ~TALLOC_FLAG_LOOP;
-}
-
-static void talloc_report_depth_FILE_helper(const void *ptr, int depth, int max_depth, int is_ref, void *_f)
-{
- const char *name = talloc_get_name(ptr);
- FILE *f = (FILE *)_f;
-
- if (is_ref) {
- fprintf(f, "%*sreference to: %s\n", depth*4, "", name);
- return;
- }
-
- if (depth == 0) {
- fprintf(f,"%stalloc report on '%s' (total %6lu bytes in %3lu blocks)\n",
- (max_depth < 0 ? "full " :""), name,
- (unsigned long)talloc_total_size(ptr),
- (unsigned long)talloc_total_blocks(ptr));
- return;
- }
-
- fprintf(f, "%*s%-30s contains %6lu bytes in %3lu blocks (ref %d) %p\n",
- depth*4, "",
- name,
- (unsigned long)talloc_total_size(ptr),
- (unsigned long)talloc_total_blocks(ptr),
- (int)talloc_reference_count(ptr), ptr);
-
-#if 0
- fprintf(f, "content: ");
- if (talloc_total_size(ptr)) {
- int tot = talloc_total_size(ptr);
- int i;
-
- for (i = 0; i < tot; i++) {
- if ((((char *)ptr)[i] > 31) && (((char *)ptr)[i] < 126)) {
- fprintf(f, "%c", ((char *)ptr)[i]);
- } else {
- fprintf(f, "~%02x", ((char *)ptr)[i]);
- }
- }
- }
- fprintf(f, "\n");
-#endif
-}
-
-/*
- report on memory usage by all children of a pointer, giving a full tree view
-*/
-void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f)
-{
- talloc_report_depth_cb(ptr, depth, max_depth, talloc_report_depth_FILE_helper, f);
- fflush(f);
-}
-
-/*
- report on memory usage by all children of a pointer, giving a full tree view
-*/
-void talloc_report_full(const void *ptr, FILE *f)
-{
- talloc_report_depth_file(ptr, 0, -1, f);
-}
-
-/*
- report on memory usage by all children of a pointer
-*/
-void talloc_report(const void *ptr, FILE *f)
-{
- talloc_report_depth_file(ptr, 0, 1, f);
-}
-
-/*
- report on any memory hanging off the null context
-*/
-static void talloc_report_null(void)
-{
- if (talloc_total_size(null_context) != 0) {
- talloc_report(null_context, stderr);
- }
-}
-
-/*
- report on any memory hanging off the null context
-*/
-static void talloc_report_null_full(void)
-{
- if (talloc_total_size(null_context) != 0) {
- talloc_report_full(null_context, stderr);
- }
-}
-
-/*
- enable tracking of the NULL context
-*/
-void talloc_enable_null_tracking(void)
-{
- if (null_context == NULL) {
- null_context = _talloc_named_const(NULL, 0, "null_context");
- }
-}
-
-/*
- disable tracking of the NULL context
-*/
-void talloc_disable_null_tracking(void)
-{
- _talloc_free(null_context);
- null_context = NULL;
-}
-
-/*
- enable leak reporting on exit
-*/
-void talloc_enable_leak_report(void)
-{
- talloc_enable_null_tracking();
- atexit(talloc_report_null);
-}
-
-/*
- enable full leak reporting on exit
-*/
-void talloc_enable_leak_report_full(void)
-{
- talloc_enable_null_tracking();
- atexit(talloc_report_null_full);
-}
-
-/*
- talloc and zero memory.
-*/
-void *_talloc_zero(const void *ctx, size_t size, const char *name)
-{
- void *p = _talloc_named_const(ctx, size, name);
-
- if (p) {
- memset(p, '\0', size);
- }
-
- return p;
-}
-
-/*
- memdup with a talloc.
-*/
-void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name)
-{
- void *newp = _talloc_named_const(t, size, name);
-
- if (likely(newp)) {
- memcpy(newp, p, size);
- }
-
- return newp;
-}
-
-static inline char *__talloc_strlendup(const void *t, const char *p, size_t len)
-{
- char *ret;
-
- ret = (char *)__talloc(t, len + 1);
- if (unlikely(!ret)) return NULL;
-
- memcpy(ret, p, len);
- ret[len] = 0;
-
- _talloc_set_name_const(ret, ret);
- return ret;
-}
-
-/*
- strdup with a talloc
-*/
-char *talloc_strdup(const void *t, const char *p)
-{
- if (unlikely(!p)) return NULL;
- return __talloc_strlendup(t, p, strlen(p));
-}
-
-/*
- strndup with a talloc
-*/
-char *talloc_strndup(const void *t, const char *p, size_t n)
-{
- if (unlikely(!p)) return NULL;
- return __talloc_strlendup(t, p, strnlen(p, n));
-}
-
-static inline char *__talloc_strlendup_append(char *s, size_t slen,
- const char *a, size_t alen)
-{
- char *ret;
-
- ret = talloc_realloc(NULL, s, char, slen + alen + 1);
- if (unlikely(!ret)) return NULL;
-
- /* append the string and the trailing \0 */
- memcpy(&ret[slen], a, alen);
- ret[slen+alen] = 0;
-
- _talloc_set_name_const(ret, ret);
- return ret;
-}
-
-/*
- * Appends at the end of the string.
- */
-char *talloc_strdup_append(char *s, const char *a)
-{
- if (unlikely(!s)) {
- return talloc_strdup(NULL, a);
- }
-
- if (unlikely(!a)) {
- return s;
- }
-
- return __talloc_strlendup_append(s, strlen(s), a, strlen(a));
-}
-
-/*
- * Appends at the end of the talloc'ed buffer,
- * not the end of the string.
- */
-char *talloc_strdup_append_buffer(char *s, const char *a)
-{
- size_t slen;
-
- if (unlikely(!s)) {
- return talloc_strdup(NULL, a);
- }
-
- if (unlikely(!a)) {
- return s;
- }
-
- slen = talloc_get_size(s);
- if (likely(slen > 0)) {
- slen--;
- }
-
- return __talloc_strlendup_append(s, slen, a, strlen(a));
-}
-
-/*
- * Appends at the end of the string.
- */
-char *talloc_strndup_append(char *s, const char *a, size_t n)
-{
- if (unlikely(!s)) {
- return talloc_strdup(NULL, a);
- }
-
- if (unlikely(!a)) {
- return s;
- }
-
- return __talloc_strlendup_append(s, strlen(s), a, strnlen(a, n));
-}
-
-/*
- * Appends at the end of the talloc'ed buffer,
- * not the end of the string.
- */
-char *talloc_strndup_append_buffer(char *s, const char *a, size_t n)
-{
- size_t slen;
-
- if (unlikely(!s)) {
- return talloc_strdup(NULL, a);
- }
-
- if (unlikely(!a)) {
- return s;
- }
-
- slen = talloc_get_size(s);
- if (likely(slen > 0)) {
- slen--;
- }
-
- return __talloc_strlendup_append(s, slen, a, strnlen(a, n));
-}
-
-#ifndef HAVE_VA_COPY
-#ifdef HAVE___VA_COPY
-#define va_copy(dest, src) __va_copy(dest, src)
-#else
-#define va_copy(dest, src) (dest) = (src)
-#endif
-#endif
-
-char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
-{
- int len;
- char *ret;
- va_list ap2;
- char c;
-
- /* this call looks strange, but it makes it work on older solaris boxes */
- va_copy(ap2, ap);
- len = vsnprintf(&c, 1, fmt, ap2);
- va_end(ap2);
- if (unlikely(len < 0)) {
- return NULL;
- }
-
- ret = (char *)__talloc(t, len+1);
- if (unlikely(!ret)) return NULL;
-
- va_copy(ap2, ap);
- vsnprintf(ret, len+1, fmt, ap2);
- va_end(ap2);
-
- _talloc_set_name_const(ret, ret);
- return ret;
-}
-
-
-/*
- Perform string formatting, and return a pointer to newly allocated
- memory holding the result, inside a memory pool.
- */
-char *talloc_asprintf(const void *t, const char *fmt, ...)
-{
- va_list ap;
- char *ret;
-
- va_start(ap, fmt);
- ret = talloc_vasprintf(t, fmt, ap);
- va_end(ap);
- return ret;
-}
-
-static inline char *__talloc_vaslenprintf_append(char *s, size_t slen,
- const char *fmt, va_list ap)
- PRINTF_ATTRIBUTE(3,0);
-
-static inline char *__talloc_vaslenprintf_append(char *s, size_t slen,
- const char *fmt, va_list ap)
-{
- ssize_t alen;
- va_list ap2;
- char c;
-
- va_copy(ap2, ap);
- alen = vsnprintf(&c, 1, fmt, ap2);
- va_end(ap2);
-
- if (alen <= 0) {
- /* Either the vsnprintf failed or the format resulted in
- * no characters being formatted. In the former case, we
- * ought to return NULL, in the latter we ought to return
- * the original string. Most current callers of this
- * function expect it to never return NULL.
- */
- return s;
- }
-
- s = talloc_realloc(NULL, s, char, slen + alen + 1);
- if (!s) return NULL;
-
- va_copy(ap2, ap);
- vsnprintf(s + slen, alen + 1, fmt, ap2);
- va_end(ap2);
-
- _talloc_set_name_const(s, s);
- return s;
-}
-
-/**
- * Realloc @p s to append the formatted result of @p fmt and @p ap,
- * and return @p s, which may have moved. Good for gradually
- * accumulating output into a string buffer. Appends at the end
- * of the string.
- **/
-char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
-{
- if (unlikely(!s)) {
- return talloc_vasprintf(NULL, fmt, ap);
- }
-
- return __talloc_vaslenprintf_append(s, strlen(s), fmt, ap);
-}
-
-/**
- * Realloc @p s to append the formatted result of @p fmt and @p ap,
- * and return @p s, which may have moved. Always appends at the
- * end of the talloc'ed buffer, not the end of the string.
- **/
-char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap)
-{
- size_t slen;
-
- if (unlikely(!s)) {
- return talloc_vasprintf(NULL, fmt, ap);
- }
-
- slen = talloc_get_size(s);
- if (likely(slen > 0)) {
- slen--;
- }
-
- return __talloc_vaslenprintf_append(s, slen, fmt, ap);
-}
-
-/*
- Realloc @p s to append the formatted result of @p fmt and return @p
- s, which may have moved. Good for gradually accumulating output
- into a string buffer.
- */
-char *talloc_asprintf_append(char *s, const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- s = talloc_vasprintf_append(s, fmt, ap);
- va_end(ap);
- return s;
-}
-
-/*
- Realloc @p s to append the formatted result of @p fmt and return @p
- s, which may have moved. Good for gradually accumulating output
- into a buffer.
- */
-char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- s = talloc_vasprintf_append_buffer(s, fmt, ap);
- va_end(ap);
- return s;
-}
-
-/*
- alloc an array, checking for integer overflow in the array size
-*/
-void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name)
-{
- if (count >= MAX_TALLOC_SIZE/el_size) {
- return NULL;
- }
- return _talloc_named_const(ctx, el_size * count, name);
-}
-
-/*
- alloc an zero array, checking for integer overflow in the array size
-*/
-void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name)
-{
- if (count >= MAX_TALLOC_SIZE/el_size) {
- return NULL;
- }
- return _talloc_zero(ctx, el_size * count, name);
-}
-
-/*
- realloc an array, checking for integer overflow in the array size
-*/
-void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name)
-{
- if (count >= MAX_TALLOC_SIZE/el_size) {
- return NULL;
- }
- return _talloc_realloc(ctx, ptr, el_size * count, name);
-}
-
-/*
- a function version of talloc_realloc(), so it can be passed as a function pointer
- to libraries that want a realloc function (a realloc function encapsulates
- all the basic capabilities of an allocation library, which is why this is useful)
-*/
-void *talloc_realloc_fn(const void *context, void *ptr, size_t size)
-{
- return _talloc_realloc(context, ptr, size, NULL);
-}
-
-
-static int talloc_autofree_destructor(void *ptr)
-{
- autofree_context = NULL;
- return 0;
-}
-
-static void talloc_autofree(void)
-{
- _talloc_free(autofree_context);
-}
-
-/*
- return a context which will be auto-freed on exit
- this is useful for reducing the noise in leak reports
-*/
-void *talloc_autofree_context(void)
-{
- if (autofree_context == NULL) {
- autofree_context = _talloc_named_const(NULL, 0, "autofree_context");
- talloc_set_destructor(autofree_context, talloc_autofree_destructor);
- atexit(talloc_autofree);
- }
- return autofree_context;
-}
-
-size_t talloc_get_size(const void *context)
-{
- struct talloc_chunk *tc;
-
- if (context == NULL)
- return 0;
-
- tc = talloc_chunk_from_ptr(context);
-
- return tc->size;
-}
-
-/*
- find a parent of this context that has the given name, if any
-*/
-void *talloc_find_parent_byname(const void *context, const char *name)
-{
- struct talloc_chunk *tc;
-
- if (context == NULL) {
- return NULL;
- }
-
- tc = talloc_chunk_from_ptr(context);
- while (tc) {
- if (tc->name && strcmp(tc->name, name) == 0) {
- return TC_PTR_FROM_CHUNK(tc);
- }
- while (tc && tc->prev) tc = tc->prev;
- if (tc) {
- tc = tc->parent;
- }
- }
- return NULL;
-}
-
-/*
- show the parentage of a context
-*/
-void talloc_show_parents(const void *context, FILE *file)
-{
- struct talloc_chunk *tc;
-
- if (context == NULL) {
- fprintf(file, "talloc no parents for NULL\n");
- return;
- }
-
- tc = talloc_chunk_from_ptr(context);
- fprintf(file, "talloc parents of '%s'\n", talloc_get_name(context));
- while (tc) {
- fprintf(file, "\t'%s'\n", talloc_get_name(TC_PTR_FROM_CHUNK(tc)));
- while (tc && tc->prev) tc = tc->prev;
- if (tc) {
- tc = tc->parent;
- }
- }
- fflush(file);
-}
-
-/*
- return 1 if ptr is a parent of context
-*/
-int talloc_is_parent(const void *context, const void *ptr)
-{
- struct talloc_chunk *tc;
-
- if (context == NULL) {
- return 0;
- }
-
- tc = talloc_chunk_from_ptr(context);
- while (tc) {
- if (TC_PTR_FROM_CHUNK(tc) == ptr) return 1;
- while (tc && tc->prev) tc = tc->prev;
- if (tc) {
- tc = tc->parent;
- }
- }
- return 0;
-}
diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h
deleted file mode 100644
index 5431971655..0000000000
--- a/source4/lib/talloc/talloc.h
+++ /dev/null
@@ -1,183 +0,0 @@
-#ifndef _TALLOC_H_
-#define _TALLOC_H_
-/*
- Unix SMB/CIFS implementation.
- Samba temporary memory allocation functions
-
- Copyright (C) Andrew Tridgell 2004-2005
- Copyright (C) Stefan Metzmacher 2006
-
- ** NOTE! The following LGPL license applies to the talloc
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-
-/* this is only needed for compatibility with the old talloc */
-typedef void TALLOC_CTX;
-
-/*
- this uses a little trick to allow __LINE__ to be stringified
-*/
-#ifndef __location__
-#define __TALLOC_STRING_LINE1__(s) #s
-#define __TALLOC_STRING_LINE2__(s) __TALLOC_STRING_LINE1__(s)
-#define __TALLOC_STRING_LINE3__ __TALLOC_STRING_LINE2__(__LINE__)
-#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__
-#endif
-
-#ifndef TALLOC_DEPRECATED
-#define TALLOC_DEPRECATED 0
-#endif
-
-#ifndef PRINTF_ATTRIBUTE
-#if (__GNUC__ >= 3)
-/** Use gcc attribute to check printf fns. a1 is the 1-based index of
- * the parameter containing the format, and a2 the index of the first
- * argument. Note that some gcc 2.x versions don't handle this
- * properly **/
-#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
-#else
-#define PRINTF_ATTRIBUTE(a1, a2)
-#endif
-#endif
-
-/* try to make talloc_set_destructor() and talloc_steal() type safe,
- if we have a recent gcc */
-#if (__GNUC__ >= 3)
-#define _TALLOC_TYPEOF(ptr) __typeof__(ptr)
-#define talloc_set_destructor(ptr, function) \
- do { \
- int (*_talloc_destructor_fn)(_TALLOC_TYPEOF(ptr)) = (function); \
- _talloc_set_destructor((ptr), (int (*)(void *))_talloc_destructor_fn); \
- } while(0)
-/* this extremely strange macro is to avoid some braindamaged warning
- stupidity in gcc 4.1.x */
-#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)); __talloc_steal_ret; })
-#else
-#define talloc_set_destructor(ptr, function) \
- _talloc_set_destructor((ptr), (int (*)(void *))(function))
-#define _TALLOC_TYPEOF(ptr) void *
-#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr))
-#endif
-
-#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr))
-#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr))
-
-/* useful macros for creating type checked pointers */
-#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)
-#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__)
-#define talloc_ptrtype(ctx, ptr) (_TALLOC_TYPEOF(ptr))talloc_size(ctx, sizeof(*(ptr)))
-
-#define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__)
-
-#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
-#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__)
-
-#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type)
-#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type)
-#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__)
-#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count)
-
-#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type)
-#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__)
-
-#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__)
-
-#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type)
-#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type)
-
-#define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type)
-
-#if TALLOC_DEPRECATED
-#define talloc_zero_p(ctx, type) talloc_zero(ctx, type)
-#define talloc_p(ctx, type) talloc(ctx, type)
-#define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count)
-#define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count)
-#define talloc_destroy(ctx) talloc_free(ctx)
-#define talloc_append_string(c, s, a) (s?talloc_strdup_append(s,a):talloc_strdup(c, a))
-#endif
-
-/* The following definitions come from talloc.c */
-void *_talloc(const void *context, size_t size);
-void *talloc_pool(const void *context, size_t size);
-void _talloc_set_destructor(const void *ptr, int (*destructor)(void *));
-int talloc_increase_ref_count(const void *ptr);
-size_t talloc_reference_count(const void *ptr);
-void *_talloc_reference(const void *context, const void *ptr);
-int talloc_unlink(const void *context, void *ptr);
-const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
-void talloc_set_name_const(const void *ptr, const char *name);
-void *talloc_named(const void *context, size_t size,
- const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
-void *talloc_named_const(const void *context, size_t size, const char *name);
-const char *talloc_get_name(const void *ptr);
-void *talloc_check_name(const void *ptr, const char *name);
-void *talloc_parent(const void *ptr);
-const char *talloc_parent_name(const void *ptr);
-void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
-int talloc_free(void *ptr);
-void talloc_free_children(void *ptr);
-void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name);
-void *_talloc_steal(const void *new_ctx, const void *ptr);
-void *_talloc_move(const void *new_ctx, const void *pptr);
-size_t talloc_total_size(const void *ptr);
-size_t talloc_total_blocks(const void *ptr);
-void talloc_report_depth_cb(const void *ptr, int depth, int max_depth,
- void (*callback)(const void *ptr,
- int depth, int max_depth,
- int is_ref,
- void *private_data),
- void *private_data);
-void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f);
-void talloc_report_full(const void *ptr, FILE *f);
-void talloc_report(const void *ptr, FILE *f);
-void talloc_enable_null_tracking(void);
-void talloc_disable_null_tracking(void);
-void talloc_enable_leak_report(void);
-void talloc_enable_leak_report_full(void);
-void *_talloc_zero(const void *ctx, size_t size, const char *name);
-void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name);
-void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name);
-void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name);
-void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name);
-void *talloc_realloc_fn(const void *context, void *ptr, size_t size);
-void *talloc_autofree_context(void);
-size_t talloc_get_size(const void *ctx);
-void *talloc_find_parent_byname(const void *ctx, const char *name);
-void talloc_show_parents(const void *context, FILE *file);
-int talloc_is_parent(const void *context, const void *ptr);
-
-char *talloc_strdup(const void *t, const char *p);
-char *talloc_strdup_append(char *s, const char *a);
-char *talloc_strdup_append_buffer(char *s, const char *a);
-
-char *talloc_strndup(const void *t, const char *p, size_t n);
-char *talloc_strndup_append(char *s, const char *a, size_t n);
-char *talloc_strndup_append_buffer(char *s, const char *a, size_t n);
-
-char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
-char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
-char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
-
-char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
-char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
-char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
-
-#endif
diff --git a/source4/lib/talloc/talloc.i b/source4/lib/talloc/talloc.i
deleted file mode 100644
index a9afb97ed7..0000000000
--- a/source4/lib/talloc/talloc.i
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/* Don't expose talloc contexts in Python code. Python does reference
- counting for us, so just create a new top-level talloc context.
- */
-%typemap(in, numinputs=0, noblock=1) TALLOC_CTX * {
- $1 = NULL;
-}
-
-%define %talloctype(TYPE)
-%nodefaultctor TYPE;
-%extend TYPE {
- ~TYPE() { talloc_free($self); }
-}
-%enddef
diff --git a/source4/lib/talloc/talloc.mk b/source4/lib/talloc/talloc.mk
deleted file mode 100644
index e1fe88c84b..0000000000
--- a/source4/lib/talloc/talloc.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-TALLOC_OBJ = $(tallocdir)/talloc.o
-
-TALLOC_SOLIB = libtalloc.$(SHLIBEXT).$(PACKAGE_VERSION)
-TALLOC_SONAME = libtalloc.$(SHLIBEXT).1
-
-all:: libtalloc.a $(TALLOC_SOLIB) testsuite
-
-testsuite:: $(LIBOBJ) testsuite.o
- $(CC) $(CFLAGS) -o testsuite testsuite.o $(LIBOBJ) $(LIBS)
-
-libtalloc.a: $(LIBOBJ)
- ar -rv $@ $(LIBOBJ)
- @-ranlib $@
-
-install:: all
- ${INSTALLCMD} -d $(DESTDIR)$(libdir)
- ${INSTALLCMD} -d $(DESTDIR)$(libdir)/pkgconfig
- ${INSTALLCMD} -m 755 libtalloc.a $(DESTDIR)$(libdir)
- ${INSTALLCMD} -m 755 $(TALLOC_SOLIB) $(DESTDIR)$(libdir)
- ${INSTALLCMD} -d $(DESTDIR)${includedir}
- ${INSTALLCMD} -m 644 $(srcdir)/talloc.h $(DESTDIR)$(includedir)
- ${INSTALLCMD} -m 644 talloc.pc $(DESTDIR)$(libdir)/pkgconfig
- if [ -f talloc.3 ];then ${INSTALLCMD} -d $(DESTDIR)$(mandir)/man3; fi
- if [ -f talloc.3 ];then ${INSTALLCMD} -m 644 talloc.3 $(DESTDIR)$(mandir)/man3; fi
- which swig >/dev/null 2>&1 && ${INSTALLCMD} -d $(DESTDIR)`swig -swiglib` || true
- which swig >/dev/null 2>&1 && ${INSTALLCMD} -m 644 talloc.i $(DESTDIR)`swig -swiglib` || true
-
-doc:: talloc.3 talloc.3.html
-
-clean::
- rm -f *~ $(LIBOBJ) $(TALLOC_SOLIB) libtalloc.a testsuite testsuite.o *.gc?? talloc.3 talloc.3.html
-
-test:: testsuite
- ./testsuite
-
-gcov::
- gcov talloc.c
diff --git a/source4/lib/talloc/talloc.pc.in b/source4/lib/talloc/talloc.pc.in
deleted file mode 100644
index 459cce70b1..0000000000
--- a/source4/lib/talloc/talloc.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: talloc
-Description: A hierarchical pool based memory system with destructors
-Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -ltalloc
-Cflags: -I${includedir}
-URL: http://talloc.samba.org/
diff --git a/source4/lib/talloc/talloc_guide.txt b/source4/lib/talloc/talloc_guide.txt
deleted file mode 100644
index 18663b370d..0000000000
--- a/source4/lib/talloc/talloc_guide.txt
+++ /dev/null
@@ -1,685 +0,0 @@
-Using talloc in Samba4
-----------------------
-
-Andrew Tridgell
-September 2004
-
-The most current version of this document is available at
- http://samba.org/ftp/unpacked/samba4/source/lib/talloc/talloc_guide.txt
-
-If you are used to the "old" talloc from Samba3 before 3.0.20 then please read
-this carefully, as talloc has changed a lot. With 3.0.20 (or 3.0.14?) the
-Samba4 talloc has been ported back to Samba3, so this guide applies to both.
-
-The new talloc is a hierarchical, reference counted memory pool system
-with destructors. Quite a mouthful really, but not too bad once you
-get used to it.
-
-Perhaps the biggest change from Samba3 is that there is no distinction
-between a "talloc context" and a "talloc pointer". Any pointer
-returned from talloc() is itself a valid talloc context. This means
-you can do this:
-
- struct foo *X = talloc(mem_ctx, struct foo);
- X->name = talloc_strdup(X, "foo");
-
-and the pointer X->name would be a "child" of the talloc context "X"
-which is itself a child of mem_ctx. So if you do talloc_free(mem_ctx)
-then it is all destroyed, whereas if you do talloc_free(X) then just X
-and X->name are destroyed, and if you do talloc_free(X->name) then
-just the name element of X is destroyed.
-
-If you think about this, then what this effectively gives you is an
-n-ary tree, where you can free any part of the tree with
-talloc_free().
-
-If you find this confusing, then I suggest you run the testsuite to
-watch talloc in action. You may also like to add your own tests to
-testsuite.c to clarify how some particular situation is handled.
-
-
-Performance
------------
-
-All the additional features of talloc() over malloc() do come at a
-price. We have a simple performance test in Samba4 that measures
-talloc() versus malloc() performance, and it seems that talloc() is
-about 4% slower than malloc() on my x86 Debian Linux box. For Samba,
-the great reduction in code complexity that we get by using talloc
-makes this worthwhile, especially as the total overhead of
-talloc/malloc in Samba is already quite small.
-
-
-talloc API
-----------
-
-The following is a complete guide to the talloc API. Read it all at
-least twice.
-
-Multi-threading
----------------
-
-talloc itself does not deal with threads. It is thread-safe (assuming
-the underlying "malloc" is), as long as each thread uses different
-memory contexts.
-If two threads uses the same context then they need to synchronize in
-order to be safe. In particular:
-- when using talloc_enable_leak_report(), giving directly NULL as a
-parent context implicitly refers to a hidden "null context" global
-variable, so this should not be used in a multi-threaded environment
-without proper synchronization ;
-- the context returned by talloc_autofree_context() is also global so
-shouldn't be used by several threads simultaneously without
-synchronization.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-(type *)talloc(const void *context, type);
-
-The talloc() macro is the core of the talloc library. It takes a
-memory context and a type, and returns a pointer to a new area of
-memory of the given type.
-
-The returned pointer is itself a talloc context, so you can use it as
-the context argument to more calls to talloc if you wish.
-
-The returned pointer is a "child" of the supplied context. This means
-that if you talloc_free() the context then the new child disappears as
-well. Alternatively you can free just the child.
-
-The context argument to talloc() can be NULL, in which case a new top
-level context is created.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_size(const void *context, size_t size);
-
-The function talloc_size() should be used when you don't have a
-convenient type to pass to talloc(). Unlike talloc(), it is not type
-safe (as it returns a void *), so you are on your own for type checking.
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-(typeof(ptr)) talloc_ptrtype(const void *ctx, ptr);
-
-The talloc_ptrtype() macro should be used when you have a pointer and
-want to allocate memory to point at with this pointer. When compiling
-with gcc >= 3 it is typesafe. Note this is a wrapper of talloc_size()
-and talloc_get_name() will return the current location in the source file.
-and not the type.
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-int talloc_free(void *ptr);
-
-The talloc_free() function frees a piece of talloc memory, and all its
-children. You can call talloc_free() on any pointer returned by
-talloc().
-
-The return value of talloc_free() indicates success or failure, with 0
-returned for success and -1 for failure. The only possible failure
-condition is if the pointer had a destructor attached to it and the
-destructor returned -1. See talloc_set_destructor() for details on
-destructors.
-
-If this pointer has an additional parent when talloc_free() is called
-then the memory is not actually released, but instead the most
-recently established parent is destroyed. See talloc_reference() for
-details on establishing additional parents.
-
-For more control on which parent is removed, see talloc_unlink()
-
-talloc_free() operates recursively on its children.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-int talloc_free_children(void *ptr);
-
-The talloc_free_children() walks along the list of all children of a
-talloc context and talloc_free()s only the children, not the context
-itself.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_reference(const void *context, const void *ptr);
-
-The talloc_reference() function makes "context" an additional parent
-of "ptr".
-
-The return value of talloc_reference() is always the original pointer
-"ptr", unless talloc ran out of memory in creating the reference in
-which case it will return NULL (each additional reference consumes
-around 48 bytes of memory on intel x86 platforms).
-
-If "ptr" is NULL, then the function is a no-op, and simply returns NULL.
-
-After creating a reference you can free it in one of the following
-ways:
-
- - you can talloc_free() any parent of the original pointer. That
- will reduce the number of parents of this pointer by 1, and will
- cause this pointer to be freed if it runs out of parents.
-
- - you can talloc_free() the pointer itself. That will destroy the
- most recently established parent to the pointer and leave the
- pointer as a child of its current parent.
-
-For more control on which parent to remove, see talloc_unlink()
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-int talloc_unlink(const void *context, const void *ptr);
-
-The talloc_unlink() function removes a specific parent from ptr. The
-context passed must either be a context used in talloc_reference()
-with this pointer, or must be a direct parent of ptr.
-
-Note that if the parent has already been removed using talloc_free()
-then this function will fail and will return -1. Likewise, if "ptr"
-is NULL, then the function will make no modifications and return -1.
-
-Usually you can just use talloc_free() instead of talloc_unlink(), but
-sometimes it is useful to have the additional control on which parent
-is removed.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void talloc_set_destructor(const void *ptr, int (*destructor)(void *));
-
-The function talloc_set_destructor() sets the "destructor" for the
-pointer "ptr". A destructor is a function that is called when the
-memory used by a pointer is about to be released. The destructor
-receives the pointer as an argument, and should return 0 for success
-and -1 for failure.
-
-The destructor can do anything it wants to, including freeing other
-pieces of memory. A common use for destructors is to clean up
-operating system resources (such as open file descriptors) contained
-in the structure the destructor is placed on.
-
-You can only place one destructor on a pointer. If you need more than
-one destructor then you can create a zero-length child of the pointer
-and place an additional destructor on that.
-
-To remove a destructor call talloc_set_destructor() with NULL for the
-destructor.
-
-If your destructor attempts to talloc_free() the pointer that it is
-the destructor for then talloc_free() will return -1 and the free will
-be ignored. This would be a pointless operation anyway, as the
-destructor is only called when the memory is just about to go away.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-int talloc_increase_ref_count(const void *ptr);
-
-The talloc_increase_ref_count(ptr) function is exactly equivalent to:
-
- talloc_reference(NULL, ptr);
-
-You can use either syntax, depending on which you think is clearer in
-your code.
-
-It returns 0 on success and -1 on failure.
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-size_t talloc_reference_count(const void *ptr);
-
-Return the number of references to the pointer.
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void talloc_set_name(const void *ptr, const char *fmt, ...);
-
-Each talloc pointer has a "name". The name is used principally for
-debugging purposes, although it is also possible to set and get the
-name on a pointer in as a way of "marking" pointers in your code.
-
-The main use for names on pointer is for "talloc reports". See
-talloc_report() and talloc_report_full() for details. Also see
-talloc_enable_leak_report() and talloc_enable_leak_report_full().
-
-The talloc_set_name() function allocates memory as a child of the
-pointer. It is logically equivalent to:
- talloc_set_name_const(ptr, talloc_asprintf(ptr, fmt, ...));
-
-Note that multiple calls to talloc_set_name() will allocate more
-memory without releasing the name. All of the memory is released when
-the ptr is freed using talloc_free().
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void talloc_set_name_const(const void *ptr, const char *name);
-
-The function talloc_set_name_const() is just like talloc_set_name(),
-but it takes a string constant, and is much faster. It is extensively
-used by the "auto naming" macros, such as talloc_p().
-
-This function does not allocate any memory. It just copies the
-supplied pointer into the internal representation of the talloc
-ptr. This means you must not pass a name pointer to memory that will
-disappear before the ptr is freed with talloc_free().
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_named(const void *context, size_t size, const char *fmt, ...);
-
-The talloc_named() function creates a named talloc pointer. It is
-equivalent to:
-
- ptr = talloc_size(context, size);
- talloc_set_name(ptr, fmt, ....);
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_named_const(const void *context, size_t size, const char *name);
-
-This is equivalent to:
-
- ptr = talloc_size(context, size);
- talloc_set_name_const(ptr, name);
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-const char *talloc_get_name(const void *ptr);
-
-This returns the current name for the given talloc pointer. See
-talloc_set_name() for details.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_init(const char *fmt, ...);
-
-This function creates a zero length named talloc context as a top
-level context. It is equivalent to:
-
- talloc_named(NULL, 0, fmt, ...);
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_new(void *ctx);
-
-This is a utility macro that creates a new memory context hanging
-off an exiting context, automatically naming it "talloc_new: __location__"
-where __location__ is the source line it is called from. It is
-particularly useful for creating a new temporary working context.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-(type *)talloc_realloc(const void *context, void *ptr, type, count);
-
-The talloc_realloc() macro changes the size of a talloc
-pointer. The "count" argument is the number of elements of type "type"
-that you want the resulting pointer to hold.
-
-talloc_realloc() has the following equivalences:
-
- talloc_realloc(context, NULL, type, 1) ==> talloc(context, type);
- talloc_realloc(context, NULL, type, N) ==> talloc_array(context, type, N);
- talloc_realloc(context, ptr, type, 0) ==> talloc_free(ptr);
-
-The "context" argument is only used if "ptr" is NULL, otherwise it is
-ignored.
-
-talloc_realloc() returns the new pointer, or NULL on failure. The call
-will fail either due to a lack of memory, or because the pointer has
-more than one parent (see talloc_reference()).
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_realloc_size(const void *context, void *ptr, size_t size);
-
-the talloc_realloc_size() function is useful when the type is not
-known so the typesafe talloc_realloc() cannot be used.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_steal(const void *new_ctx, const void *ptr);
-
-The talloc_steal() function changes the parent context of a talloc
-pointer. It is typically used when the context that the pointer is
-currently a child of is going to be freed and you wish to keep the
-memory for a longer time.
-
-The talloc_steal() function returns the pointer that you pass it. It
-does not have any failure modes.
-
-NOTE: It is possible to produce loops in the parent/child relationship
-if you are not careful with talloc_steal(). No guarantees are provided
-as to your sanity or the safety of your data if you do this.
-
-talloc_steal (new_ctx, NULL) will return NULL with no sideeffects.
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-size_t talloc_total_size(const void *ptr);
-
-The talloc_total_size() function returns the total size in bytes used
-by this pointer and all child pointers. Mostly useful for debugging.
-
-Passing NULL is allowed, but it will only give a meaningful result if
-talloc_enable_leak_report() or talloc_enable_leak_report_full() has
-been called.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-size_t talloc_total_blocks(const void *ptr);
-
-The talloc_total_blocks() function returns the total memory block
-count used by this pointer and all child pointers. Mostly useful for
-debugging.
-
-Passing NULL is allowed, but it will only give a meaningful result if
-talloc_enable_leak_report() or talloc_enable_leak_report_full() has
-been called.
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void talloc_report_depth_cb(const void *ptr, int depth, int max_depth,
- void (*callback)(const void *ptr,
- int depth, int max_depth,
- int is_ref,
- void *priv),
- void *priv);
-
-This provides a more flexible reports than talloc_report(). It
-will recursively call the callback for the entire tree of memory
-referenced by the pointer. References in the tree are passed with
-is_ref = 1 and the pointer that is referenced.
-
-You can pass NULL for the pointer, in which case a report is
-printed for the top level memory context, but only if
-talloc_enable_leak_report() or talloc_enable_leak_report_full()
-has been called.
-
-The recursion is stopped when depth >= max_depth.
-max_depth = -1 means only stop at leaf nodes.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f);
-
-This provides a more flexible reports than talloc_report(). It
-will let you specify the depth and max_depth.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void talloc_report(const void *ptr, FILE *f);
-
-The talloc_report() function prints a summary report of all memory
-used by ptr. One line of report is printed for each immediate child of
-ptr, showing the total memory and number of blocks used by that child.
-
-You can pass NULL for the pointer, in which case a report is printed
-for the top level memory context, but only if
-talloc_enable_leak_report() or talloc_enable_leak_report_full() has
-been called.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void talloc_report_full(const void *ptr, FILE *f);
-
-This provides a more detailed report than talloc_report(). It will
-recursively print the ensire tree of memory referenced by the
-pointer. References in the tree are shown by giving the name of the
-pointer that is referenced.
-
-You can pass NULL for the pointer, in which case a report is printed
-for the top level memory context, but only if
-talloc_enable_leak_report() or talloc_enable_leak_report_full() has
-been called.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void talloc_enable_leak_report(void);
-
-This enables calling of talloc_report(NULL, stderr) when the program
-exits. In Samba4 this is enabled by using the --leak-report command
-line option.
-
-For it to be useful, this function must be called before any other
-talloc function as it establishes a "null context" that acts as the
-top of the tree. If you don't call this function first then passing
-NULL to talloc_report() or talloc_report_full() won't give you the
-full tree printout.
-
-Here is a typical talloc report:
-
-talloc report on 'null_context' (total 267 bytes in 15 blocks)
- libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks
- libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks
- iconv(UTF8,CP850) contains 42 bytes in 2 blocks
- libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks
- iconv(CP850,UTF8) contains 42 bytes in 2 blocks
- iconv(UTF8,UTF-16LE) contains 45 bytes in 2 blocks
- iconv(UTF-16LE,UTF8) contains 45 bytes in 2 blocks
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void talloc_enable_leak_report_full(void);
-
-This enables calling of talloc_report_full(NULL, stderr) when the
-program exits. In Samba4 this is enabled by using the
---leak-report-full command line option.
-
-For it to be useful, this function must be called before any other
-talloc function as it establishes a "null context" that acts as the
-top of the tree. If you don't call this function first then passing
-NULL to talloc_report() or talloc_report_full() won't give you the
-full tree printout.
-
-Here is a typical full report:
-
-full talloc report on 'root' (total 18 bytes in 8 blocks)
- p1 contains 18 bytes in 7 blocks (ref 0)
- r1 contains 13 bytes in 2 blocks (ref 0)
- reference to: p2
- p2 contains 1 bytes in 1 blocks (ref 1)
- x3 contains 1 bytes in 1 blocks (ref 0)
- x2 contains 1 bytes in 1 blocks (ref 0)
- x1 contains 1 bytes in 1 blocks (ref 0)
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void talloc_enable_null_tracking(void);
-
-This enables tracking of the NULL memory context without enabling leak
-reporting on exit. Useful for when you want to do your own leak
-reporting call via talloc_report_null_full();
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void talloc_disable_null_tracking(void);
-
-This disables tracking of the NULL memory context.
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-(type *)talloc_zero(const void *ctx, type);
-
-The talloc_zero() macro is equivalent to:
-
- ptr = talloc(ctx, type);
- if (ptr) memset(ptr, 0, sizeof(type));
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_zero_size(const void *ctx, size_t size)
-
-The talloc_zero_size() function is useful when you don't have a known type
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_memdup(const void *ctx, const void *p, size_t size);
-
-The talloc_memdup() function is equivalent to:
-
- ptr = talloc_size(ctx, size);
- if (ptr) memcpy(ptr, p, size);
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-char *talloc_strdup(const void *ctx, const char *p);
-
-The talloc_strdup() function is equivalent to:
-
- ptr = talloc_size(ctx, strlen(p)+1);
- if (ptr) memcpy(ptr, p, strlen(p)+1);
-
-This functions sets the name of the new pointer to the passed
-string. This is equivalent to:
- talloc_set_name_const(ptr, ptr)
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-char *talloc_strndup(const void *t, const char *p, size_t n);
-
-The talloc_strndup() function is the talloc equivalent of the C
-library function strndup()
-
-This functions sets the name of the new pointer to the passed
-string. This is equivalent to:
- talloc_set_name_const(ptr, ptr)
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-char *talloc_append_string(const void *t, char *orig, const char *append);
-
-The talloc_append_string() function appends the given formatted
-string to the given string.
-
-This function sets the name of the new pointer to the new
-string. This is equivalent to:
- talloc_set_name_const(ptr, ptr)
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-char *talloc_vasprintf(const void *t, const char *fmt, va_list ap);
-
-The talloc_vasprintf() function is the talloc equivalent of the C
-library function vasprintf()
-
-This functions sets the name of the new pointer to the new
-string. This is equivalent to:
- talloc_set_name_const(ptr, ptr)
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-char *talloc_asprintf(const void *t, const char *fmt, ...);
-
-The talloc_asprintf() function is the talloc equivalent of the C
-library function asprintf()
-
-This functions sets the name of the new pointer to the new
-string. This is equivalent to:
- talloc_set_name_const(ptr, ptr)
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-char *talloc_asprintf_append(char *s, const char *fmt, ...);
-
-The talloc_asprintf_append() function appends the given formatted
-string to the given string.
-Use this varient when the string in the current talloc buffer may
-have been truncated in length.
-
-This functions sets the name of the new pointer to the new
-string. This is equivalent to:
- talloc_set_name_const(ptr, ptr)
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...);
-
-The talloc_asprintf_append() function appends the given formatted
-string to the end of the currently allocated talloc buffer.
-Use this varient when the string in the current talloc buffer has
-not been changed.
-
-This functions sets the name of the new pointer to the new
-string. This is equivalent to:
- talloc_set_name_const(ptr, ptr)
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-((type *)talloc_array(const void *ctx, type, uint_t count);
-
-The talloc_array() macro is equivalent to:
-
- (type *)talloc_size(ctx, sizeof(type) * count);
-
-except that it provides integer overflow protection for the multiply,
-returning NULL if the multiply overflows.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_array_size(const void *ctx, size_t size, uint_t count);
-
-The talloc_array_size() function is useful when the type is not
-known. It operates in the same way as talloc_array(), but takes a size
-instead of a type.
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-(typeof(ptr)) talloc_array_ptrtype(const void *ctx, ptr, uint_t count);
-
-The talloc_ptrtype() macro should be used when you have a pointer to an array
-and want to allocate memory of an array to point at with this pointer. When compiling
-with gcc >= 3 it is typesafe. Note this is a wrapper of talloc_array_size()
-and talloc_get_name() will return the current location in the source file.
-and not the type.
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_realloc_fn(const void *ctx, void *ptr, size_t size);
-
-This is a non-macro version of talloc_realloc(), which is useful
-as libraries sometimes want a ralloc function pointer. A realloc()
-implementation encapsulates the functionality of malloc(), free() and
-realloc() in one call, which is why it is useful to be able to pass
-around a single function pointer.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_autofree_context(void);
-
-This is a handy utility function that returns a talloc context
-which will be automatically freed on program exit. This can be used
-to reduce the noise in memory leak reports.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_check_name(const void *ptr, const char *name);
-
-This function checks if a pointer has the specified name. If it does
-then the pointer is returned. It it doesn't then NULL is returned.
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-(type *)talloc_get_type(const void *ptr, type);
-
-This macro allows you to do type checking on talloc pointers. It is
-particularly useful for void* private pointers. It is equivalent to
-this:
-
- (type *)talloc_check_name(ptr, #type)
-
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-talloc_set_type(const void *ptr, type);
-
-This macro allows you to force the name of a pointer to be a
-particular type. This can be used in conjunction with
-talloc_get_type() to do type checking on void* pointers.
-
-It is equivalent to this:
- talloc_set_name_const(ptr, #type)
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-talloc_get_size(const void *ctx);
-
-This function lets you know the amount of memory alloced so far by
-this context. It does NOT account for subcontext memory.
-This can be used to calculate the size of an array.
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_find_parent_byname(const void *ctx, const char *name);
-
-Find a parent memory context of the current context that has the given
-name. This can be very useful in complex programs where it may be
-difficult to pass all information down to the level you need, but you
-know the structure you want is a parent of another context.
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-(type *)talloc_find_parent_bytype(ctx, type);
-
-Like talloc_find_parent_byname() but takes a type, making it typesafe.
-
diff --git a/source4/lib/talloc/testsuite.c b/source4/lib/talloc/testsuite.c
deleted file mode 100644
index 3f06eee566..0000000000
--- a/source4/lib/talloc/testsuite.c
+++ /dev/null
@@ -1,1152 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- local testing of talloc routines.
-
- Copyright (C) Andrew Tridgell 2004
-
- ** NOTE! The following LGPL license applies to the talloc
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "replace.h"
-#include "system/time.h"
-#include "talloc.h"
-
-static struct timeval timeval_current(void)
-{
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return tv;
-}
-
-static double timeval_elapsed(struct timeval *tv)
-{
- struct timeval tv2 = timeval_current();
- return (tv2.tv_sec - tv->tv_sec) +
- (tv2.tv_usec - tv->tv_usec)*1.0e-6;
-}
-
-#define torture_assert(test, expr, str) if (!(expr)) { \
- printf("failure: %s [\n%s: Expression %s failed: %s\n]\n", \
- test, __location__, #expr, str); \
- return false; \
-}
-
-#define torture_assert_str_equal(test, arg1, arg2, desc) \
- if (arg1 == NULL && arg2 == NULL) { \
- } else if (strcmp(arg1, arg2)) { \
- printf("failure: %s [\n%s: Expected %s, got %s: %s\n]\n", \
- test, __location__, arg1, arg2, desc); \
- return false; \
- }
-
-#if _SAMBA_BUILD_==3
-#ifdef malloc
-#undef malloc
-#endif
-#ifdef strdup
-#undef strdup
-#endif
-#endif
-
-#define CHECK_SIZE(test, ptr, tsize) do { \
- if (talloc_total_size(ptr) != (tsize)) { \
- printf("failed: %s [\nwrong '%s' tree size: got %u expected %u\n]\n", \
- test, #ptr, \
- (unsigned)talloc_total_size(ptr), \
- (unsigned)tsize); \
- talloc_report_full(ptr, stdout); \
- return false; \
- } \
-} while (0)
-
-#define CHECK_BLOCKS(test, ptr, tblocks) do { \
- if (talloc_total_blocks(ptr) != (tblocks)) { \
- printf("failed: %s [\nwrong '%s' tree blocks: got %u expected %u\n]\n", \
- test, #ptr, \
- (unsigned)talloc_total_blocks(ptr), \
- (unsigned)tblocks); \
- talloc_report_full(ptr, stdout); \
- return false; \
- } \
-} while (0)
-
-#define CHECK_PARENT(test, ptr, parent) do { \
- if (talloc_parent(ptr) != (parent)) { \
- printf("failed: %s [\n'%s' has wrong parent: got %p expected %p\n]\n", \
- test, #ptr, \
- talloc_parent(ptr), \
- (parent)); \
- talloc_report_full(ptr, stdout); \
- talloc_report_full(parent, stdout); \
- talloc_report_full(NULL, stdout); \
- return false; \
- } \
-} while (0)
-
-
-/*
- test references
-*/
-static bool test_ref1(void)
-{
- void *root, *p1, *p2, *ref, *r1;
-
- printf("test: ref1\n# SINGLE REFERENCE FREE\n");
-
- root = talloc_named_const(NULL, 0, "root");
- p1 = talloc_named_const(root, 1, "p1");
- p2 = talloc_named_const(p1, 1, "p2");
- talloc_named_const(p1, 1, "x1");
- talloc_named_const(p1, 2, "x2");
- talloc_named_const(p1, 3, "x3");
-
- r1 = talloc_named_const(root, 1, "r1");
- ref = talloc_reference(r1, p2);
- talloc_report_full(root, stderr);
-
- CHECK_BLOCKS("ref1", p1, 5);
- CHECK_BLOCKS("ref1", p2, 1);
- CHECK_BLOCKS("ref1", r1, 2);
-
- fprintf(stderr, "Freeing p2\n");
- talloc_free(p2);
- talloc_report_full(root, stderr);
-
- CHECK_BLOCKS("ref1", p1, 5);
- CHECK_BLOCKS("ref1", p2, 1);
- CHECK_BLOCKS("ref1", r1, 1);
-
- fprintf(stderr, "Freeing p1\n");
- talloc_free(p1);
- talloc_report_full(root, stderr);
-
- CHECK_BLOCKS("ref1", r1, 1);
-
- fprintf(stderr, "Freeing r1\n");
- talloc_free(r1);
- talloc_report_full(NULL, stderr);
-
- fprintf(stderr, "Testing NULL\n");
- if (talloc_reference(root, NULL)) {
- return false;
- }
-
- CHECK_BLOCKS("ref1", root, 1);
-
- CHECK_SIZE("ref1", root, 0);
-
- talloc_free(root);
- printf("success: ref1\n");
- return true;
-}
-
-/*
- test references
-*/
-static bool test_ref2(void)
-{
- void *root, *p1, *p2, *ref, *r1;
-
- printf("test: ref2\n# DOUBLE REFERENCE FREE\n");
- root = talloc_named_const(NULL, 0, "root");
- p1 = talloc_named_const(root, 1, "p1");
- talloc_named_const(p1, 1, "x1");
- talloc_named_const(p1, 1, "x2");
- talloc_named_const(p1, 1, "x3");
- p2 = talloc_named_const(p1, 1, "p2");
-
- r1 = talloc_named_const(root, 1, "r1");
- ref = talloc_reference(r1, p2);
- talloc_report_full(root, stderr);
-
- CHECK_BLOCKS("ref2", p1, 5);
- CHECK_BLOCKS("ref2", p2, 1);
- CHECK_BLOCKS("ref2", r1, 2);
-
- fprintf(stderr, "Freeing ref\n");
- talloc_free(ref);
- talloc_report_full(root, stderr);
-
- CHECK_BLOCKS("ref2", p1, 5);
- CHECK_BLOCKS("ref2", p2, 1);
- CHECK_BLOCKS("ref2", r1, 1);
-
- fprintf(stderr, "Freeing p2\n");
- talloc_free(p2);
- talloc_report_full(root, stderr);
-
- CHECK_BLOCKS("ref2", p1, 4);
- CHECK_BLOCKS("ref2", r1, 1);
-
- fprintf(stderr, "Freeing p1\n");
- talloc_free(p1);
- talloc_report_full(root, stderr);
-
- CHECK_BLOCKS("ref2", r1, 1);
-
- fprintf(stderr, "Freeing r1\n");
- talloc_free(r1);
- talloc_report_full(root, stderr);
-
- CHECK_SIZE("ref2", root, 0);
-
- talloc_free(root);
- printf("success: ref2\n");
- return true;
-}
-
-/*
- test references
-*/
-static bool test_ref3(void)
-{
- void *root, *p1, *p2, *ref, *r1;
-
- printf("test: ref3\n# PARENT REFERENCE FREE\n");
-
- root = talloc_named_const(NULL, 0, "root");
- p1 = talloc_named_const(root, 1, "p1");
- p2 = talloc_named_const(root, 1, "p2");
- r1 = talloc_named_const(p1, 1, "r1");
- ref = talloc_reference(p2, r1);
- talloc_report_full(root, stderr);
-
- CHECK_BLOCKS("ref3", p1, 2);
- CHECK_BLOCKS("ref3", p2, 2);
- CHECK_BLOCKS("ref3", r1, 1);
-
- fprintf(stderr, "Freeing p1\n");
- talloc_free(p1);
- talloc_report_full(root, stderr);
-
- CHECK_BLOCKS("ref3", p2, 2);
- CHECK_BLOCKS("ref3", r1, 1);
-
- fprintf(stderr, "Freeing p2\n");
- talloc_free(p2);
- talloc_report_full(root, stderr);
-
- CHECK_SIZE("ref3", root, 0);
-
- talloc_free(root);
-
- printf("success: ref3\n");
- return true;
-}
-
-/*
- test references
-*/
-static bool test_ref4(void)
-{
- void *root, *p1, *p2, *ref, *r1;
-
- printf("test: ref4\n# REFERRER REFERENCE FREE\n");
-
- root = talloc_named_const(NULL, 0, "root");
- p1 = talloc_named_const(root, 1, "p1");
- talloc_named_const(p1, 1, "x1");
- talloc_named_const(p1, 1, "x2");
- talloc_named_const(p1, 1, "x3");
- p2 = talloc_named_const(p1, 1, "p2");
-
- r1 = talloc_named_const(root, 1, "r1");
- ref = talloc_reference(r1, p2);
- talloc_report_full(root, stderr);
-
- CHECK_BLOCKS("ref4", p1, 5);
- CHECK_BLOCKS("ref4", p2, 1);
- CHECK_BLOCKS("ref4", r1, 2);
-
- fprintf(stderr, "Freeing r1\n");
- talloc_free(r1);
- talloc_report_full(root, stderr);
-
- CHECK_BLOCKS("ref4", p1, 5);
- CHECK_BLOCKS("ref4", p2, 1);
-
- fprintf(stderr, "Freeing p2\n");
- talloc_free(p2);
- talloc_report_full(root, stderr);
-
- CHECK_BLOCKS("ref4", p1, 4);
-
- fprintf(stderr, "Freeing p1\n");
- talloc_free(p1);
- talloc_report_full(root, stderr);
-
- CHECK_SIZE("ref4", root, 0);
-
- talloc_free(root);
-
- printf("success: ref4\n");
- return true;
-}
-
-
-/*
- test references
-*/
-static bool test_unlink1(void)
-{
- void *root, *p1, *p2, *ref, *r1;
-
- printf("test: unlink\n# UNLINK\n");
-
- root = talloc_named_const(NULL, 0, "root");
- p1 = talloc_named_const(root, 1, "p1");
- talloc_named_const(p1, 1, "x1");
- talloc_named_const(p1, 1, "x2");
- talloc_named_const(p1, 1, "x3");
- p2 = talloc_named_const(p1, 1, "p2");
-
- r1 = talloc_named_const(p1, 1, "r1");
- ref = talloc_reference(r1, p2);
- talloc_report_full(root, stderr);
-
- CHECK_BLOCKS("unlink", p1, 7);
- CHECK_BLOCKS("unlink", p2, 1);
- CHECK_BLOCKS("unlink", r1, 2);
-
- fprintf(stderr, "Unreferencing r1\n");
- talloc_unlink(r1, p2);
- talloc_report_full(root, stderr);
-
- CHECK_BLOCKS("unlink", p1, 6);
- CHECK_BLOCKS("unlink", p2, 1);
- CHECK_BLOCKS("unlink", r1, 1);
-
- fprintf(stderr, "Freeing p1\n");
- talloc_free(p1);
- talloc_report_full(root, stderr);
-
- CHECK_SIZE("unlink", root, 0);
-
- talloc_free(root);
-
- printf("success: unlink\n");
- return true;
-}
-
-static int fail_destructor(void *ptr)
-{
- return -1;
-}
-
-/*
- miscellaneous tests to try to get a higher test coverage percentage
-*/
-static bool test_misc(void)
-{
- void *root, *p1;
- char *p2;
- double *d;
- const char *name;
-
- printf("test: misc\n# MISCELLANEOUS\n");
-
- root = talloc_new(NULL);
-
- p1 = talloc_size(root, 0x7fffffff);
- torture_assert("misc", !p1, "failed: large talloc allowed\n");
-
- p1 = talloc_strdup(root, "foo");
- talloc_increase_ref_count(p1);
- talloc_increase_ref_count(p1);
- talloc_increase_ref_count(p1);
- CHECK_BLOCKS("misc", p1, 1);
- CHECK_BLOCKS("misc", root, 2);
- talloc_free(p1);
- CHECK_BLOCKS("misc", p1, 1);
- CHECK_BLOCKS("misc", root, 2);
- talloc_unlink(NULL, p1);
- CHECK_BLOCKS("misc", p1, 1);
- CHECK_BLOCKS("misc", root, 2);
- p2 = talloc_strdup(p1, "foo");
- torture_assert("misc", talloc_unlink(root, p2) == -1,
- "failed: talloc_unlink() of non-reference context should return -1\n");
- torture_assert("misc", talloc_unlink(p1, p2) == 0,
- "failed: talloc_unlink() of parent should succeed\n");
- talloc_free(p1);
- CHECK_BLOCKS("misc", p1, 1);
- CHECK_BLOCKS("misc", root, 2);
-
- name = talloc_set_name(p1, "my name is %s", "foo");
- torture_assert_str_equal("misc", talloc_get_name(p1), "my name is foo",
- "failed: wrong name after talloc_set_name(my name is foo)");
- CHECK_BLOCKS("misc", p1, 2);
- CHECK_BLOCKS("misc", root, 3);
-
- talloc_set_name_const(p1, NULL);
- torture_assert_str_equal ("misc", talloc_get_name(p1), "UNNAMED",
- "failed: wrong name after talloc_set_name(NULL)");
- CHECK_BLOCKS("misc", p1, 2);
- CHECK_BLOCKS("misc", root, 3);
-
- torture_assert("misc", talloc_free(NULL) == -1,
- "talloc_free(NULL) should give -1\n");
-
- talloc_set_destructor(p1, fail_destructor);
- torture_assert("misc", talloc_free(p1) == -1,
- "Failed destructor should cause talloc_free to fail\n");
- talloc_set_destructor(p1, NULL);
-
- talloc_report(root, stderr);
-
-
- p2 = (char *)talloc_zero_size(p1, 20);
- torture_assert("misc", p2[19] == 0, "Failed to give zero memory\n");
- talloc_free(p2);
-
- torture_assert("misc", talloc_strdup(root, NULL) == NULL,
- "failed: strdup on NULL should give NULL\n");
-
- p2 = talloc_strndup(p1, "foo", 2);
- torture_assert("misc", strcmp("fo", p2) == 0,
- "strndup doesn't work\n");
- p2 = talloc_asprintf_append_buffer(p2, "o%c", 'd');
- torture_assert("misc", strcmp("food", p2) == 0,
- "talloc_asprintf_append_buffer doesn't work\n");
- CHECK_BLOCKS("misc", p2, 1);
- CHECK_BLOCKS("misc", p1, 3);
-
- p2 = talloc_asprintf_append_buffer(NULL, "hello %s", "world");
- torture_assert("misc", strcmp("hello world", p2) == 0,
- "talloc_asprintf_append_buffer doesn't work\n");
- CHECK_BLOCKS("misc", p2, 1);
- CHECK_BLOCKS("misc", p1, 3);
- talloc_free(p2);
-
- d = talloc_array(p1, double, 0x20000000);
- torture_assert("misc", !d, "failed: integer overflow not detected\n");
-
- d = talloc_realloc(p1, d, double, 0x20000000);
- torture_assert("misc", !d, "failed: integer overflow not detected\n");
-
- talloc_free(p1);
- CHECK_BLOCKS("misc", root, 1);
-
- p1 = talloc_named(root, 100, "%d bytes", 100);
- CHECK_BLOCKS("misc", p1, 2);
- CHECK_BLOCKS("misc", root, 3);
- talloc_unlink(root, p1);
-
- p1 = talloc_init("%d bytes", 200);
- p2 = talloc_asprintf(p1, "my test '%s'", "string");
- torture_assert_str_equal("misc", p2, "my test 'string'",
- "failed: talloc_asprintf(\"my test '%%s'\", \"string\") gave: \"%s\"");
- CHECK_BLOCKS("misc", p1, 3);
- CHECK_SIZE("misc", p2, 17);
- CHECK_BLOCKS("misc", root, 1);
- talloc_unlink(NULL, p1);
-
- p1 = talloc_named_const(root, 10, "p1");
- p2 = (char *)talloc_named_const(root, 20, "p2");
- (void)talloc_reference(p1, p2);
- talloc_report_full(root, stderr);
- talloc_unlink(root, p2);
- talloc_report_full(root, stderr);
- CHECK_BLOCKS("misc", p2, 1);
- CHECK_BLOCKS("misc", p1, 2);
- CHECK_BLOCKS("misc", root, 3);
- talloc_unlink(p1, p2);
- talloc_unlink(root, p1);
-
- p1 = talloc_named_const(root, 10, "p1");
- p2 = (char *)talloc_named_const(root, 20, "p2");
- (void)talloc_reference(NULL, p2);
- talloc_report_full(root, stderr);
- talloc_unlink(root, p2);
- talloc_report_full(root, stderr);
- CHECK_BLOCKS("misc", p2, 1);
- CHECK_BLOCKS("misc", p1, 1);
- CHECK_BLOCKS("misc", root, 2);
- talloc_unlink(NULL, p2);
- talloc_unlink(root, p1);
-
- /* Test that talloc_unlink is a no-op */
-
- torture_assert("misc", talloc_unlink(root, NULL) == -1,
- "failed: talloc_unlink(root, NULL) == -1\n");
-
- talloc_report(root, stderr);
- talloc_report(NULL, stderr);
-
- CHECK_SIZE("misc", root, 0);
-
- talloc_free(root);
-
- CHECK_SIZE("misc", NULL, 0);
-
- talloc_enable_leak_report();
- talloc_enable_leak_report_full();
-
- printf("success: misc\n");
-
- return true;
-}
-
-
-/*
- test realloc
-*/
-static bool test_realloc(void)
-{
- void *root, *p1, *p2;
-
- printf("test: realloc\n# REALLOC\n");
-
- root = talloc_new(NULL);
-
- p1 = talloc_size(root, 10);
- CHECK_SIZE("realloc", p1, 10);
-
- p1 = talloc_realloc_size(NULL, p1, 20);
- CHECK_SIZE("realloc", p1, 20);
-
- talloc_new(p1);
-
- p2 = talloc_realloc_size(p1, NULL, 30);
-
- talloc_new(p1);
-
- p2 = talloc_realloc_size(p1, p2, 40);
-
- CHECK_SIZE("realloc", p2, 40);
- CHECK_SIZE("realloc", root, 60);
- CHECK_BLOCKS("realloc", p1, 4);
-
- p1 = talloc_realloc_size(NULL, p1, 20);
- CHECK_SIZE("realloc", p1, 60);
-
- talloc_increase_ref_count(p2);
- torture_assert("realloc", talloc_realloc_size(NULL, p2, 5) == NULL,
- "failed: talloc_realloc() on a referenced pointer should fail\n");
- CHECK_BLOCKS("realloc", p1, 4);
-
- talloc_realloc_size(NULL, p2, 0);
- talloc_realloc_size(NULL, p2, 0);
- CHECK_BLOCKS("realloc", p1, 3);
-
- torture_assert("realloc", talloc_realloc_size(NULL, p1, 0x7fffffff) == NULL,
- "failed: oversize talloc should fail\n");
-
- talloc_realloc_size(NULL, p1, 0);
-
- CHECK_BLOCKS("realloc", root, 1);
- CHECK_SIZE("realloc", root, 0);
-
- talloc_free(root);
-
- printf("success: realloc\n");
-
- return true;
-}
-
-/*
- test realloc with a child
-*/
-static bool test_realloc_child(void)
-{
- void *root;
- struct el2 {
- const char *name;
- } *el2;
- struct el1 {
- int count;
- struct el2 **list, **list2, **list3;
- } *el1;
-
- printf("test: REALLOC WITH CHILD\n");
-
- root = talloc_new(NULL);
-
- el1 = talloc(root, struct el1);
- el1->list = talloc(el1, struct el2 *);
- el1->list[0] = talloc(el1->list, struct el2);
- el1->list[0]->name = talloc_strdup(el1->list[0], "testing");
-
- el1->list2 = talloc(el1, struct el2 *);
- el1->list2[0] = talloc(el1->list2, struct el2);
- el1->list2[0]->name = talloc_strdup(el1->list2[0], "testing2");
-
- el1->list3 = talloc(el1, struct el2 *);
- el1->list3[0] = talloc(el1->list3, struct el2);
- el1->list3[0]->name = talloc_strdup(el1->list3[0], "testing2");
-
- el2 = talloc(el1->list, struct el2);
- el2 = talloc(el1->list2, struct el2);
- el2 = talloc(el1->list3, struct el2);
-
- el1->list = talloc_realloc(el1, el1->list, struct el2 *, 100);
- el1->list2 = talloc_realloc(el1, el1->list2, struct el2 *, 200);
- el1->list3 = talloc_realloc(el1, el1->list3, struct el2 *, 300);
-
- talloc_free(root);
-
- printf("success: REALLOC WITH CHILD\n");
- return true;
-}
-
-/*
- test type checking
-*/
-static bool test_type(void)
-{
- void *root;
- struct el1 {
- int count;
- };
- struct el2 {
- int count;
- };
- struct el1 *el1;
-
- printf("test: type\n# talloc type checking\n");
-
- root = talloc_new(NULL);
-
- el1 = talloc(root, struct el1);
-
- el1->count = 1;
-
- torture_assert("type", talloc_get_type(el1, struct el1) == el1,
- "type check failed on el1\n");
- torture_assert("type", talloc_get_type(el1, struct el2) == NULL,
- "type check failed on el1 with el2\n");
- talloc_set_type(el1, struct el2);
- torture_assert("type", talloc_get_type(el1, struct el2) == (struct el2 *)el1,
- "type set failed on el1 with el2\n");
-
- talloc_free(root);
-
- printf("success: type\n");
- return true;
-}
-
-/*
- test steal
-*/
-static bool test_steal(void)
-{
- void *root, *p1, *p2;
-
- printf("test: steal\n# STEAL\n");
-
- root = talloc_new(NULL);
-
- p1 = talloc_array(root, char, 10);
- CHECK_SIZE("steal", p1, 10);
-
- p2 = talloc_realloc(root, NULL, char, 20);
- CHECK_SIZE("steal", p1, 10);
- CHECK_SIZE("steal", root, 30);
-
- torture_assert("steal", talloc_steal(p1, NULL) == NULL,
- "failed: stealing NULL should give NULL\n");
-
- torture_assert("steal", talloc_steal(p1, p1) == p1,
- "failed: stealing to ourselves is a nop\n");
- CHECK_BLOCKS("steal", root, 3);
- CHECK_SIZE("steal", root, 30);
-
- talloc_steal(NULL, p1);
- talloc_steal(NULL, p2);
- CHECK_BLOCKS("steal", root, 1);
- CHECK_SIZE("steal", root, 0);
-
- talloc_free(p1);
- talloc_steal(root, p2);
- CHECK_BLOCKS("steal", root, 2);
- CHECK_SIZE("steal", root, 20);
-
- talloc_free(p2);
-
- CHECK_BLOCKS("steal", root, 1);
- CHECK_SIZE("steal", root, 0);
-
- talloc_free(root);
-
- p1 = talloc_size(NULL, 3);
- talloc_report_full(NULL, stderr);
- CHECK_SIZE("steal", NULL, 3);
- talloc_free(p1);
-
- printf("success: steal\n");
- return true;
-}
-
-/*
- test move
-*/
-static bool test_move(void)
-{
- void *root;
- struct t_move {
- char *p;
- int *x;
- } *t1, *t2;
-
- printf("test: move\n# MOVE\n");
-
- root = talloc_new(NULL);
-
- t1 = talloc(root, struct t_move);
- t2 = talloc(root, struct t_move);
- t1->p = talloc_strdup(t1, "foo");
- t1->x = talloc(t1, int);
- *t1->x = 42;
-
- t2->p = talloc_move(t2, &t1->p);
- t2->x = talloc_move(t2, &t1->x);
- torture_assert("move", t1->p == NULL && t1->x == NULL &&
- strcmp(t2->p, "foo") == 0 && *t2->x == 42,
- "talloc move failed");
-
- talloc_free(root);
-
- printf("success: move\n");
-
- return true;
-}
-
-/*
- test talloc_realloc_fn
-*/
-static bool test_realloc_fn(void)
-{
- void *root, *p1;
-
- printf("test: realloc_fn\n# talloc_realloc_fn\n");
-
- root = talloc_new(NULL);
-
- p1 = talloc_realloc_fn(root, NULL, 10);
- CHECK_BLOCKS("realloc_fn", root, 2);
- CHECK_SIZE("realloc_fn", root, 10);
- p1 = talloc_realloc_fn(root, p1, 20);
- CHECK_BLOCKS("realloc_fn", root, 2);
- CHECK_SIZE("realloc_fn", root, 20);
- p1 = talloc_realloc_fn(root, p1, 0);
- CHECK_BLOCKS("realloc_fn", root, 1);
- CHECK_SIZE("realloc_fn", root, 0);
-
- talloc_free(root);
-
- printf("success: realloc_fn\n");
- return true;
-}
-
-
-static bool test_unref_reparent(void)
-{
- void *root, *p1, *p2, *c1;
-
- printf("test: unref_reparent\n# UNREFERENCE AFTER PARENT FREED\n");
-
- root = talloc_named_const(NULL, 0, "root");
- p1 = talloc_named_const(root, 1, "orig parent");
- p2 = talloc_named_const(root, 1, "parent by reference");
-
- c1 = talloc_named_const(p1, 1, "child");
- talloc_reference(p2, c1);
-
- CHECK_PARENT("unref_reparent", c1, p1);
-
- talloc_free(p1);
-
- CHECK_PARENT("unref_reparent", c1, p2);
-
- talloc_unlink(p2, c1);
-
- CHECK_SIZE("unref_reparent", root, 1);
-
- talloc_free(p2);
- talloc_free(root);
-
- printf("success: unref_reparent\n");
- return true;
-}
-
-/*
- measure the speed of talloc versus malloc
-*/
-static bool test_speed(void)
-{
- void *ctx = talloc_new(NULL);
- unsigned count;
- const int loop = 1000;
- int i;
- struct timeval tv;
-
- printf("test: speed\n# TALLOC VS MALLOC SPEED\n");
-
- tv = timeval_current();
- count = 0;
- do {
- void *p1, *p2, *p3;
- for (i=0;i<loop;i++) {
- p1 = talloc_size(ctx, loop % 100);
- p2 = talloc_strdup(p1, "foo bar");
- p3 = talloc_size(p1, 300);
- talloc_free(p1);
- }
- count += 3 * loop;
- } while (timeval_elapsed(&tv) < 5.0);
-
- fprintf(stderr, "talloc: %.0f ops/sec\n", count/timeval_elapsed(&tv));
-
- talloc_free(ctx);
-
- ctx = talloc_pool(NULL, 1024);
-
- tv = timeval_current();
- count = 0;
- do {
- void *p1, *p2, *p3;
- for (i=0;i<loop;i++) {
- p1 = talloc_size(ctx, loop % 100);
- p2 = talloc_strdup(p1, "foo bar");
- p3 = talloc_size(p1, 300);
- talloc_free_children(ctx);
- }
- count += 3 * loop;
- } while (timeval_elapsed(&tv) < 5.0);
-
- talloc_free(ctx);
-
- fprintf(stderr, "talloc_pool: %.0f ops/sec\n", count/timeval_elapsed(&tv));
-
- tv = timeval_current();
- count = 0;
- do {
- void *p1, *p2, *p3;
- for (i=0;i<loop;i++) {
- p1 = malloc(loop % 100);
- p2 = strdup("foo bar");
- p3 = malloc(300);
- free(p1);
- free(p2);
- free(p3);
- }
- count += 3 * loop;
- } while (timeval_elapsed(&tv) < 5.0);
- fprintf(stderr, "malloc: %.0f ops/sec\n", count/timeval_elapsed(&tv));
-
- printf("success: speed\n");
-
- return true;
-}
-
-static bool test_lifeless(void)
-{
- void *top = talloc_new(NULL);
- char *parent, *child;
- void *child_owner = talloc_new(NULL);
-
- printf("test: lifeless\n# TALLOC_UNLINK LOOP\n");
-
- parent = talloc_strdup(top, "parent");
- child = talloc_strdup(parent, "child");
- (void)talloc_reference(child, parent);
- (void)talloc_reference(child_owner, child);
- talloc_report_full(top, stderr);
- talloc_unlink(top, parent);
- talloc_free(child);
- talloc_report_full(top, stderr);
- talloc_free(top);
- talloc_free(child_owner);
- talloc_free(child);
-
- printf("success: lifeless\n");
- return true;
-}
-
-static int loop_destructor_count;
-
-static int test_loop_destructor(char *ptr)
-{
- loop_destructor_count++;
- return 0;
-}
-
-static bool test_loop(void)
-{
- void *top = talloc_new(NULL);
- char *parent;
- struct req1 {
- char *req2, *req3;
- } *req1;
-
- printf("test: loop\n# TALLOC LOOP DESTRUCTION\n");
-
- parent = talloc_strdup(top, "parent");
- req1 = talloc(parent, struct req1);
- req1->req2 = talloc_strdup(req1, "req2");
- talloc_set_destructor(req1->req2, test_loop_destructor);
- req1->req3 = talloc_strdup(req1, "req3");
- (void)talloc_reference(req1->req3, req1);
- talloc_report_full(top, stderr);
- talloc_free(parent);
- talloc_report_full(top, stderr);
- talloc_report_full(NULL, stderr);
- talloc_free(top);
-
- torture_assert("loop", loop_destructor_count == 1,
- "FAILED TO FIRE LOOP DESTRUCTOR\n");
- loop_destructor_count = 0;
-
- printf("success: loop\n");
- return true;
-}
-
-static int fail_destructor_str(char *ptr)
-{
- return -1;
-}
-
-static bool test_free_parent_deny_child(void)
-{
- void *top = talloc_new(NULL);
- char *level1;
- char *level2;
- char *level3;
-
- printf("test: free_parent_deny_child\n# TALLOC FREE PARENT DENY CHILD\n");
-
- level1 = talloc_strdup(top, "level1");
- level2 = talloc_strdup(level1, "level2");
- level3 = talloc_strdup(level2, "level3");
-
- talloc_set_destructor(level3, fail_destructor_str);
- talloc_free(level1);
- talloc_set_destructor(level3, NULL);
-
- CHECK_PARENT("free_parent_deny_child", level3, top);
-
- talloc_free(top);
-
- printf("success: free_parent_deny_child\n");
- return true;
-}
-
-static bool test_talloc_ptrtype(void)
-{
- void *top = talloc_new(NULL);
- struct struct1 {
- int foo;
- int bar;
- } *s1, *s2, **s3, ***s4;
- const char *location1;
- const char *location2;
- const char *location3;
- const char *location4;
-
- printf("test: ptrtype\n# TALLOC PTRTYPE\n");
-
- s1 = talloc_ptrtype(top, s1);location1 = __location__;
-
- if (talloc_get_size(s1) != sizeof(struct struct1)) {
- printf("failure: ptrtype [\n"
- "talloc_ptrtype() allocated the wrong size %lu (should be %lu)\n"
- "]\n", (unsigned long)talloc_get_size(s1),
- (unsigned long)sizeof(struct struct1));
- return false;
- }
-
- if (strcmp(location1, talloc_get_name(s1)) != 0) {
- printf("failure: ptrtype [\n"
- "talloc_ptrtype() sets the wrong name '%s' (should be '%s')\n]\n",
- talloc_get_name(s1), location1);
- return false;
- }
-
- s2 = talloc_array_ptrtype(top, s2, 10);location2 = __location__;
-
- if (talloc_get_size(s2) != (sizeof(struct struct1) * 10)) {
- printf("failure: ptrtype [\n"
- "talloc_array_ptrtype() allocated the wrong size "
- "%lu (should be %lu)\n]\n",
- (unsigned long)talloc_get_size(s2),
- (unsigned long)(sizeof(struct struct1)*10));
- return false;
- }
-
- if (strcmp(location2, talloc_get_name(s2)) != 0) {
- printf("failure: ptrtype [\n"
- "talloc_array_ptrtype() sets the wrong name '%s' (should be '%s')\n]\n",
- talloc_get_name(s2), location2);
- return false;
- }
-
- s3 = talloc_array_ptrtype(top, s3, 10);location3 = __location__;
-
- if (talloc_get_size(s3) != (sizeof(struct struct1 *) * 10)) {
- printf("failure: ptrtype [\n"
- "talloc_array_ptrtype() allocated the wrong size "
- "%lu (should be %lu)\n]\n",
- (unsigned long)talloc_get_size(s3),
- (unsigned long)(sizeof(struct struct1 *)*10));
- return false;
- }
-
- torture_assert_str_equal("ptrtype", location3, talloc_get_name(s3),
- "talloc_array_ptrtype() sets the wrong name");
-
- s4 = talloc_array_ptrtype(top, s4, 10);location4 = __location__;
-
- if (talloc_get_size(s4) != (sizeof(struct struct1 **) * 10)) {
- printf("failure: ptrtype [\n"
- "talloc_array_ptrtype() allocated the wrong size "
- "%lu (should be %lu)\n]\n",
- (unsigned long)talloc_get_size(s4),
- (unsigned long)(sizeof(struct struct1 **)*10));
- return false;
- }
-
- torture_assert_str_equal("ptrtype", location4, talloc_get_name(s4),
- "talloc_array_ptrtype() sets the wrong name");
-
- talloc_free(top);
-
- printf("success: ptrtype\n");
- return true;
-}
-
-static int _test_talloc_free_in_destructor(void **ptr)
-{
- talloc_free(*ptr);
- return 0;
-}
-
-static bool test_talloc_free_in_destructor(void)
-{
- void *level0;
- void *level1;
- void *level2;
- void *level3;
- void *level4;
- void **level5;
-
- printf("test: free_in_destructor\n# TALLOC FREE IN DESTRUCTOR\n");
-
- level0 = talloc_new(NULL);
- level1 = talloc_new(level0);
- level2 = talloc_new(level1);
- level3 = talloc_new(level2);
- level4 = talloc_new(level3);
- level5 = talloc(level4, void *);
-
- *level5 = level3;
- (void)talloc_reference(level0, level3);
- (void)talloc_reference(level3, level3);
- (void)talloc_reference(level5, level3);
-
- talloc_set_destructor(level5, _test_talloc_free_in_destructor);
-
- talloc_free(level1);
-
- talloc_free(level0);
-
- printf("success: free_in_destructor\n");
- return true;
-}
-
-static bool test_autofree(void)
-{
-#if _SAMBA_BUILD_ < 4
- /* autofree test would kill smbtorture */
- void *p;
- printf("test: autofree\n# TALLOC AUTOFREE CONTEXT\n");
-
- p = talloc_autofree_context();
- talloc_free(p);
-
- p = talloc_autofree_context();
- talloc_free(p);
-
- printf("success: autofree\n");
-#endif
- return true;
-}
-
-static bool test_pool(void)
-{
- void *pool;
- void *p1, *p2, *p3, *p4;
-
- pool = talloc_pool(NULL, 1024);
-
- p1 = talloc_size(pool, 80);
- p2 = talloc_size(pool, 20);
- p3 = talloc_size(p1, 50);
- p4 = talloc_size(p3, 1000);
-
- talloc_free(pool);
-
- return true;
-}
-
-struct torture_context;
-bool torture_local_talloc(struct torture_context *tctx)
-{
- bool ret = true;
-
- setlinebuf(stdout);
-
- talloc_disable_null_tracking();
- talloc_enable_null_tracking();
-
- ret &= test_ref1();
- ret &= test_ref2();
- ret &= test_ref3();
- ret &= test_ref4();
- ret &= test_unlink1();
- ret &= test_misc();
- ret &= test_realloc();
- ret &= test_realloc_child();
- ret &= test_steal();
- ret &= test_move();
- ret &= test_unref_reparent();
- ret &= test_realloc_fn();
- ret &= test_type();
- ret &= test_lifeless();
- ret &= test_loop();
- ret &= test_free_parent_deny_child();
- ret &= test_talloc_ptrtype();
- ret &= test_talloc_free_in_destructor();
- ret &= test_pool();
-
- if (ret) {
- ret &= test_speed();
- }
- ret &= test_autofree();
-
- return ret;
-}
-
-#if _SAMBA_BUILD_ < 4
-int main(void)
-{
- bool ret = torture_local_talloc(NULL);
- if (!ret)
- return -1;
- return 0;
-}
-#endif
diff --git a/source4/lib/talloc/web/index.html b/source4/lib/talloc/web/index.html
deleted file mode 100644
index 5deab93665..0000000000
--- a/source4/lib/talloc/web/index.html
+++ /dev/null
@@ -1,46 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<HTML>
-<HEAD>
-<TITLE>talloc</TITLE>
-</HEAD>
-<BODY BGCOLOR="#ffffff" TEXT="#000000" VLINK="#292555" LINK="#292555" ALINK="#cc0033">
-
-<h1>talloc</h1>
-
-talloc is a hierarchical pool based memory allocator with
-destructors. It is the core memory allocator used in Samba4, and has
-made a huge difference in many aspects of Samba4 development.<p>
-
-To get started with talloc, I would recommend you read the <a
-href="http://samba.org/ftp/unpacked/talloc/talloc_guide.txt">talloc guide</a>.
-
-<h2>Discussion and bug reports</h2>
-
-talloc does not currently have its own mailing list or bug tracking
-system. For now, please use the <a
-href="https://lists.samba.org/mailman/listinfo/samba-technical">samba-technical</a>
-mailing list, and the <a href="http://bugzilla.samba.org/">Samba
-bugzilla</a> bug tracking system.
-
-<h2>Download</h2>
-
-You can download the latest release either via rsync or git.<br>
-<br>
-To fetch via git see the following guide:<br>
-<a href="http://wiki.samba.org/index.php/Using_Git_for_Samba_Development">Using Git for Samba Development</a><br>
-Once you have cloned the tree switch to the v4-0-test branch and cd into the source/lib/talloc directory.<br>
-<br>
-To fetch via rsync use this command:
-
-<pre>
- rsync -Pavz samba.org::ftp/unpacked/talloc .
-</pre>
-
-<hr>
-<tiny>
-<a href="http://samba.org/~tridge/">Andrew Tridgell</a><br>
-talloc AT tridgell.net
-</tiny>
-
-</BODY>
-</HTML>
diff --git a/source4/lib/tdb/Makefile.in b/source4/lib/tdb/Makefile.in
deleted file mode 100644
index 090bb6e2dc..0000000000
--- a/source4/lib/tdb/Makefile.in
+++ /dev/null
@@ -1,59 +0,0 @@
-#!gmake
-#
-# Makefile for tdb directory
-#
-
-CC = @CC@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-bindir = @bindir@
-includedir = @includedir@
-libdir = @libdir@
-VPATH = @srcdir@:@libreplacedir@
-srcdir = @srcdir@
-builddir = @builddir@
-CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -Iinclude
-CFLAGS = $(CPPFLAGS) @CFLAGS@
-LDFLAGS = @LDFLAGS@
-EXEEXT = @EXEEXT@
-SHLD = @SHLD@
-SHLD_FLAGS = @SHLD_FLAGS@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PICFLAG = @PICFLAG@
-SHLIBEXT = @SHLIBEXT@
-SWIG = swig
-PYTHON = @PYTHON@
-PYTHON_CONFIG = @PYTHON_CONFIG@
-PYTHON_BUILD_TARGET = @PYTHON_BUILD_TARGET@
-PYTHON_INSTALL_TARGET = @PYTHON_INSTALL_TARGET@
-PYTHON_CHECK_TARGET = @PYTHON_CHECK_TARGET@
-LIB_PATH_VAR = @LIB_PATH_VAR@
-tdbdir = @tdbdir@
-
-TDB_OBJ = @TDB_OBJ@ @LIBREPLACEOBJ@
-
-default: all
-
-include $(tdbdir)/tdb.mk
-include $(tdbdir)/rules.mk
-
-all:: showflags dirs $(PROGS) $(TDB_SOLIB) libtdb.a $(PYTHON_BUILD_TARGET)
-
-install:: all
-$(TDB_SOLIB): $(TDB_OBJ)
- $(SHLD) $(SHLD_FLAGS) -o $@ $(TDB_OBJ) @SONAMEFLAG@$(TDB_SONAME)
-
-check: test
-
-test:: $(PYTHON_CHECK_TARGET)
-installcheck:: test install
-
-clean::
- rm -f *.o *.a */*.o
-
-distclean:: clean
- rm -f config.log config.status include/config.h config.cache
- rm -f Makefile
-
-realdistclean:: distclean
- rm -f configure include/config.h.in
diff --git a/source4/lib/tdb/aclocal.m4 b/source4/lib/tdb/aclocal.m4
deleted file mode 100644
index 5605e476ba..0000000000
--- a/source4/lib/tdb/aclocal.m4
+++ /dev/null
@@ -1 +0,0 @@
-m4_include(libreplace.m4)
diff --git a/source4/lib/tdb/autogen.sh b/source4/lib/tdb/autogen.sh
deleted file mode 100755
index 88ac4cfcf7..0000000000
--- a/source4/lib/tdb/autogen.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-rm -rf autom4te.cache
-rm -f configure config.h.in
-
-IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace"
-autoconf $IPATHS || exit 1
-autoheader $IPATHS || exit 1
-
-rm -rf autom4te.cache
-
-swig -O -Wall -python -keyword tdb.i # Ignore errors for now
-
-echo "Now run ./configure and then make."
-exit 0
-
diff --git a/source4/lib/tdb/common/dump.c b/source4/lib/tdb/common/dump.c
deleted file mode 100644
index d1c902ddfd..0000000000
--- a/source4/lib/tdb/common/dump.c
+++ /dev/null
@@ -1,137 +0,0 @@
- /*
- Unix SMB/CIFS implementation.
-
- trivial database library
-
- Copyright (C) Andrew Tridgell 1999-2005
- Copyright (C) Paul `Rusty' Russell 2000
- Copyright (C) Jeremy Allison 2000-2003
-
- ** NOTE! The following LGPL license applies to the tdb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "tdb_private.h"
-
-static tdb_off_t tdb_dump_record(struct tdb_context *tdb, int hash,
- tdb_off_t offset)
-{
- struct list_struct rec;
- tdb_off_t tailer_ofs, tailer;
-
- if (tdb->methods->tdb_read(tdb, offset, (char *)&rec,
- sizeof(rec), DOCONV()) == -1) {
- printf("ERROR: failed to read record at %u\n", offset);
- return 0;
- }
-
- printf(" rec: hash=%d offset=0x%08x next=0x%08x rec_len=%d "
- "key_len=%d data_len=%d full_hash=0x%x magic=0x%x\n",
- hash, offset, rec.next, rec.rec_len, rec.key_len, rec.data_len,
- rec.full_hash, rec.magic);
-
- tailer_ofs = offset + sizeof(rec) + rec.rec_len - sizeof(tdb_off_t);
-
- if (tdb_ofs_read(tdb, tailer_ofs, &tailer) == -1) {
- printf("ERROR: failed to read tailer at %u\n", tailer_ofs);
- return rec.next;
- }
-
- if (tailer != rec.rec_len + sizeof(rec)) {
- printf("ERROR: tailer does not match record! tailer=%u totalsize=%u\n",
- (unsigned int)tailer, (unsigned int)(rec.rec_len + sizeof(rec)));
- }
- return rec.next;
-}
-
-static int tdb_dump_chain(struct tdb_context *tdb, int i)
-{
- tdb_off_t rec_ptr, top;
-
- top = TDB_HASH_TOP(i);
-
- if (tdb_lock(tdb, i, F_WRLCK) != 0)
- return -1;
-
- if (tdb_ofs_read(tdb, top, &rec_ptr) == -1)
- return tdb_unlock(tdb, i, F_WRLCK);
-
- if (rec_ptr)
- printf("hash=%d\n", i);
-
- while (rec_ptr) {
- rec_ptr = tdb_dump_record(tdb, i, rec_ptr);
- }
-
- return tdb_unlock(tdb, i, F_WRLCK);
-}
-
-void tdb_dump_all(struct tdb_context *tdb)
-{
- int i;
- for (i=0;i<tdb->header.hash_size;i++) {
- tdb_dump_chain(tdb, i);
- }
- printf("freelist:\n");
- tdb_dump_chain(tdb, -1);
-}
-
-int tdb_printfreelist(struct tdb_context *tdb)
-{
- int ret;
- long total_free = 0;
- tdb_off_t offset, rec_ptr;
- struct list_struct rec;
-
- if ((ret = tdb_lock(tdb, -1, F_WRLCK)) != 0)
- return ret;
-
- offset = FREELIST_TOP;
-
- /* read in the freelist top */
- if (tdb_ofs_read(tdb, offset, &rec_ptr) == -1) {
- tdb_unlock(tdb, -1, F_WRLCK);
- return 0;
- }
-
- printf("freelist top=[0x%08x]\n", rec_ptr );
- while (rec_ptr) {
- if (tdb->methods->tdb_read(tdb, rec_ptr, (char *)&rec,
- sizeof(rec), DOCONV()) == -1) {
- tdb_unlock(tdb, -1, F_WRLCK);
- return -1;
- }
-
- if (rec.magic != TDB_FREE_MAGIC) {
- printf("bad magic 0x%08x in free list\n", rec.magic);
- tdb_unlock(tdb, -1, F_WRLCK);
- return -1;
- }
-
- printf("entry offset=[0x%08x], rec.rec_len = [0x%08x (%d)] (end = 0x%08x)\n",
- rec_ptr, rec.rec_len, rec.rec_len, rec_ptr + rec.rec_len);
- total_free += rec.rec_len;
-
- /* move to the next record */
- rec_ptr = rec.next;
- }
- printf("total rec_len = [0x%08x (%d)]\n", (int)total_free,
- (int)total_free);
-
- return tdb_unlock(tdb, -1, F_WRLCK);
-}
-
diff --git a/source4/lib/tdb/common/error.c b/source4/lib/tdb/common/error.c
deleted file mode 100644
index 195ab23815..0000000000
--- a/source4/lib/tdb/common/error.c
+++ /dev/null
@@ -1,57 +0,0 @@
- /*
- Unix SMB/CIFS implementation.
-
- trivial database library
-
- Copyright (C) Andrew Tridgell 1999-2005
- Copyright (C) Paul `Rusty' Russell 2000
- Copyright (C) Jeremy Allison 2000-2003
-
- ** NOTE! The following LGPL license applies to the tdb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "tdb_private.h"
-
-enum TDB_ERROR tdb_error(struct tdb_context *tdb)
-{
- return tdb->ecode;
-}
-
-static struct tdb_errname {
- enum TDB_ERROR ecode; const char *estring;
-} emap[] = { {TDB_SUCCESS, "Success"},
- {TDB_ERR_CORRUPT, "Corrupt database"},
- {TDB_ERR_IO, "IO Error"},
- {TDB_ERR_LOCK, "Locking error"},
- {TDB_ERR_OOM, "Out of memory"},
- {TDB_ERR_EXISTS, "Record exists"},
- {TDB_ERR_NOLOCK, "Lock exists on other keys"},
- {TDB_ERR_EINVAL, "Invalid parameter"},
- {TDB_ERR_NOEXIST, "Record does not exist"},
- {TDB_ERR_RDONLY, "write not permitted"} };
-
-/* Error string for the last tdb error */
-const char *tdb_errorstr(struct tdb_context *tdb)
-{
- uint32_t i;
- for (i = 0; i < sizeof(emap) / sizeof(struct tdb_errname); i++)
- if (tdb->ecode == emap[i].ecode)
- return emap[i].estring;
- return "Invalid error code";
-}
-
diff --git a/source4/lib/tdb/common/freelist.c b/source4/lib/tdb/common/freelist.c
deleted file mode 100644
index 2f2a4c379b..0000000000
--- a/source4/lib/tdb/common/freelist.c
+++ /dev/null
@@ -1,382 +0,0 @@
- /*
- Unix SMB/CIFS implementation.
-
- trivial database library
-
- Copyright (C) Andrew Tridgell 1999-2005
- Copyright (C) Paul `Rusty' Russell 2000
- Copyright (C) Jeremy Allison 2000-2003
-
- ** NOTE! The following LGPL license applies to the tdb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "tdb_private.h"
-
-/* 'right' merges can involve O(n^2) cost when combined with a
- traverse, so they are disabled until we find a way to do them in
- O(1) time
-*/
-#define USE_RIGHT_MERGES 0
-
-/* read a freelist record and check for simple errors */
-int tdb_rec_free_read(struct tdb_context *tdb, tdb_off_t off, struct list_struct *rec)
-{
- if (tdb->methods->tdb_read(tdb, off, rec, sizeof(*rec),DOCONV()) == -1)
- return -1;
-
- if (rec->magic == TDB_MAGIC) {
- /* this happens when a app is showdown while deleting a record - we should
- not completely fail when this happens */
- TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_rec_free_read non-free magic 0x%x at offset=%d - fixing\n",
- rec->magic, off));
- rec->magic = TDB_FREE_MAGIC;
- if (tdb->methods->tdb_write(tdb, off, rec, sizeof(*rec)) == -1)
- return -1;
- }
-
- if (rec->magic != TDB_FREE_MAGIC) {
- /* Ensure ecode is set for log fn. */
- tdb->ecode = TDB_ERR_CORRUPT;
- TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_rec_free_read bad magic 0x%x at offset=%d\n",
- rec->magic, off));
- return TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
- }
- if (tdb->methods->tdb_oob(tdb, rec->next+sizeof(*rec), 0) != 0)
- return -1;
- return 0;
-}
-
-
-#if USE_RIGHT_MERGES
-/* Remove an element from the freelist. Must have alloc lock. */
-static int remove_from_freelist(struct tdb_context *tdb, tdb_off_t off, tdb_off_t next)
-{
- tdb_off_t last_ptr, i;
-
- /* read in the freelist top */
- last_ptr = FREELIST_TOP;
- while (tdb_ofs_read(tdb, last_ptr, &i) != -1 && i != 0) {
- if (i == off) {
- /* We've found it! */
- return tdb_ofs_write(tdb, last_ptr, &next);
- }
- /* Follow chain (next offset is at start of record) */
- last_ptr = i;
- }
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"remove_from_freelist: not on list at off=%d\n", off));
- return TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
-}
-#endif
-
-
-/* update a record tailer (must hold allocation lock) */
-static int update_tailer(struct tdb_context *tdb, tdb_off_t offset,
- const struct list_struct *rec)
-{
- tdb_off_t totalsize;
-
- /* Offset of tailer from record header */
- totalsize = sizeof(*rec) + rec->rec_len;
- return tdb_ofs_write(tdb, offset + totalsize - sizeof(tdb_off_t),
- &totalsize);
-}
-
-/* Add an element into the freelist. Merge adjacent records if
- neccessary. */
-int tdb_free(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec)
-{
- /* Allocation and tailer lock */
- if (tdb_lock(tdb, -1, F_WRLCK) != 0)
- return -1;
-
- /* set an initial tailer, so if we fail we don't leave a bogus record */
- if (update_tailer(tdb, offset, rec) != 0) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_tailer failed!\n"));
- goto fail;
- }
-
-#if USE_RIGHT_MERGES
- /* Look right first (I'm an Australian, dammit) */
- if (offset + sizeof(*rec) + rec->rec_len + sizeof(*rec) <= tdb->map_size) {
- tdb_off_t right = offset + sizeof(*rec) + rec->rec_len;
- struct list_struct r;
-
- if (tdb->methods->tdb_read(tdb, right, &r, sizeof(r), DOCONV()) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: right read failed at %u\n", right));
- goto left;
- }
-
- /* If it's free, expand to include it. */
- if (r.magic == TDB_FREE_MAGIC) {
- if (remove_from_freelist(tdb, right, r.next) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: right free failed at %u\n", right));
- goto left;
- }
- rec->rec_len += sizeof(r) + r.rec_len;
- if (update_tailer(tdb, offset, rec) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_tailer failed at %u\n", offset));
- goto fail;
- }
- }
- }
-left:
-#endif
-
- /* Look left */
- if (offset - sizeof(tdb_off_t) > TDB_DATA_START(tdb->header.hash_size)) {
- tdb_off_t left = offset - sizeof(tdb_off_t);
- struct list_struct l;
- tdb_off_t leftsize;
-
- /* Read in tailer and jump back to header */
- if (tdb_ofs_read(tdb, left, &leftsize) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: left offset read failed at %u\n", left));
- goto update;
- }
-
- /* it could be uninitialised data */
- if (leftsize == 0 || leftsize == TDB_PAD_U32) {
- goto update;
- }
-
- left = offset - leftsize;
-
- if (leftsize > offset ||
- left < TDB_DATA_START(tdb->header.hash_size)) {
- goto update;
- }
-
- /* Now read in the left record */
- if (tdb->methods->tdb_read(tdb, left, &l, sizeof(l), DOCONV()) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: left read failed at %u (%u)\n", left, leftsize));
- goto update;
- }
-
- /* If it's free, expand to include it. */
- if (l.magic == TDB_FREE_MAGIC) {
- /* we now merge the new record into the left record, rather than the other
- way around. This makes the operation O(1) instead of O(n). This change
- prevents traverse from being O(n^2) after a lot of deletes */
- l.rec_len += sizeof(*rec) + rec->rec_len;
- if (tdb_rec_write(tdb, left, &l) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_left failed at %u\n", left));
- goto fail;
- }
- if (update_tailer(tdb, left, &l) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_tailer failed at %u\n", offset));
- goto fail;
- }
- tdb_unlock(tdb, -1, F_WRLCK);
- return 0;
- }
- }
-
-update:
-
- /* Now, prepend to free list */
- rec->magic = TDB_FREE_MAGIC;
-
- if (tdb_ofs_read(tdb, FREELIST_TOP, &rec->next) == -1 ||
- tdb_rec_write(tdb, offset, rec) == -1 ||
- tdb_ofs_write(tdb, FREELIST_TOP, &offset) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free record write failed at offset=%d\n", offset));
- goto fail;
- }
-
- /* And we're done. */
- tdb_unlock(tdb, -1, F_WRLCK);
- return 0;
-
- fail:
- tdb_unlock(tdb, -1, F_WRLCK);
- return -1;
-}
-
-
-
-/*
- the core of tdb_allocate - called when we have decided which
- free list entry to use
-
- Note that we try to allocate by grabbing data from the end of an existing record,
- not the beginning. This is so the left merge in a free is more likely to be
- able to free up the record without fragmentation
- */
-static tdb_off_t tdb_allocate_ofs(struct tdb_context *tdb,
- tdb_len_t length, tdb_off_t rec_ptr,
- struct list_struct *rec, tdb_off_t last_ptr)
-{
-#define MIN_REC_SIZE (sizeof(struct list_struct) + sizeof(tdb_off_t) + 8)
-
- if (rec->rec_len < length + MIN_REC_SIZE) {
- /* we have to grab the whole record */
-
- /* unlink it from the previous record */
- if (tdb_ofs_write(tdb, last_ptr, &rec->next) == -1) {
- return 0;
- }
-
- /* mark it not free */
- rec->magic = TDB_MAGIC;
- if (tdb_rec_write(tdb, rec_ptr, rec) == -1) {
- return 0;
- }
- return rec_ptr;
- }
-
- /* we're going to just shorten the existing record */
- rec->rec_len -= (length + sizeof(*rec));
- if (tdb_rec_write(tdb, rec_ptr, rec) == -1) {
- return 0;
- }
- if (update_tailer(tdb, rec_ptr, rec) == -1) {
- return 0;
- }
-
- /* and setup the new record */
- rec_ptr += sizeof(*rec) + rec->rec_len;
-
- memset(rec, '\0', sizeof(*rec));
- rec->rec_len = length;
- rec->magic = TDB_MAGIC;
-
- if (tdb_rec_write(tdb, rec_ptr, rec) == -1) {
- return 0;
- }
-
- if (update_tailer(tdb, rec_ptr, rec) == -1) {
- return 0;
- }
-
- return rec_ptr;
-}
-
-/* allocate some space from the free list. The offset returned points
- to a unconnected list_struct within the database with room for at
- least length bytes of total data
-
- 0 is returned if the space could not be allocated
- */
-tdb_off_t tdb_allocate(struct tdb_context *tdb, tdb_len_t length, struct list_struct *rec)
-{
- tdb_off_t rec_ptr, last_ptr, newrec_ptr;
- struct {
- tdb_off_t rec_ptr, last_ptr;
- tdb_len_t rec_len;
- } bestfit;
- float multiplier = 1.0;
-
- if (tdb_lock(tdb, -1, F_WRLCK) == -1)
- return 0;
-
- /* Extra bytes required for tailer */
- length += sizeof(tdb_off_t);
- length = TDB_ALIGN(length, TDB_ALIGNMENT);
-
- again:
- last_ptr = FREELIST_TOP;
-
- /* read in the freelist top */
- if (tdb_ofs_read(tdb, FREELIST_TOP, &rec_ptr) == -1)
- goto fail;
-
- bestfit.rec_ptr = 0;
- bestfit.last_ptr = 0;
- bestfit.rec_len = 0;
-
- /*
- this is a best fit allocation strategy. Originally we used
- a first fit strategy, but it suffered from massive fragmentation
- issues when faced with a slowly increasing record size.
- */
- while (rec_ptr) {
- if (tdb_rec_free_read(tdb, rec_ptr, rec) == -1) {
- goto fail;
- }
-
- if (rec->rec_len >= length) {
- if (bestfit.rec_ptr == 0 ||
- rec->rec_len < bestfit.rec_len) {
- bestfit.rec_len = rec->rec_len;
- bestfit.rec_ptr = rec_ptr;
- bestfit.last_ptr = last_ptr;
- }
- }
-
- /* move to the next record */
- last_ptr = rec_ptr;
- rec_ptr = rec->next;
-
- /* if we've found a record that is big enough, then
- stop searching if its also not too big. The
- definition of 'too big' changes as we scan
- through */
- if (bestfit.rec_len > 0 &&
- bestfit.rec_len < length * multiplier) {
- break;
- }
-
- /* this multiplier means we only extremely rarely
- search more than 50 or so records. At 50 records we
- accept records up to 11 times larger than what we
- want */
- multiplier *= 1.05;
- }
-
- if (bestfit.rec_ptr != 0) {
- if (tdb_rec_free_read(tdb, bestfit.rec_ptr, rec) == -1) {
- goto fail;
- }
-
- newrec_ptr = tdb_allocate_ofs(tdb, length, bestfit.rec_ptr,
- rec, bestfit.last_ptr);
- tdb_unlock(tdb, -1, F_WRLCK);
- return newrec_ptr;
- }
-
- /* we didn't find enough space. See if we can expand the
- database and if we can then try again */
- if (tdb_expand(tdb, length + sizeof(*rec)) == 0)
- goto again;
- fail:
- tdb_unlock(tdb, -1, F_WRLCK);
- return 0;
-}
-
-
-
-/*
- return the size of the freelist - used to decide if we should repack
-*/
-int tdb_freelist_size(struct tdb_context *tdb)
-{
- tdb_off_t ptr;
- int count=0;
-
- if (tdb_lock(tdb, -1, F_RDLCK) == -1) {
- return -1;
- }
-
- ptr = FREELIST_TOP;
- while (tdb_ofs_read(tdb, ptr, &ptr) == 0 && ptr != 0) {
- count++;
- }
-
- tdb_unlock(tdb, -1, F_RDLCK);
- return count;
-}
diff --git a/source4/lib/tdb/common/freelistcheck.c b/source4/lib/tdb/common/freelistcheck.c
deleted file mode 100644
index efc050df9c..0000000000
--- a/source4/lib/tdb/common/freelistcheck.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- trivial database library
-
- Copyright (C) Jeremy Allison 2006
-
- ** NOTE! The following LGPL license applies to the tdb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "tdb_private.h"
-
-/* Check the freelist is good and contains no loops.
- Very memory intensive - only do this as a consistency
- checker. Heh heh - uses an in memory tdb as the storage
- for the "seen" record list. For some reason this strikes
- me as extremely clever as I don't have to write another tree
- data structure implementation :-).
- */
-
-static int seen_insert(struct tdb_context *mem_tdb, tdb_off_t rec_ptr)
-{
- TDB_DATA key, data;
-
- memset(&data, '\0', sizeof(data));
- key.dptr = (unsigned char *)&rec_ptr;
- key.dsize = sizeof(rec_ptr);
- return tdb_store(mem_tdb, key, data, TDB_INSERT);
-}
-
-int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries)
-{
- struct tdb_context *mem_tdb = NULL;
- struct list_struct rec;
- tdb_off_t rec_ptr, last_ptr;
- int ret = -1;
-
- *pnum_entries = 0;
-
- mem_tdb = tdb_open("flval", tdb->header.hash_size,
- TDB_INTERNAL, O_RDWR, 0600);
- if (!mem_tdb) {
- return -1;
- }
-
- if (tdb_lock(tdb, -1, F_WRLCK) == -1) {
- tdb_close(mem_tdb);
- return 0;
- }
-
- last_ptr = FREELIST_TOP;
-
- /* Store the FREELIST_TOP record. */
- if (seen_insert(mem_tdb, last_ptr) == -1) {
- ret = TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
- goto fail;
- }
-
- /* read in the freelist top */
- if (tdb_ofs_read(tdb, FREELIST_TOP, &rec_ptr) == -1) {
- goto fail;
- }
-
- while (rec_ptr) {
-
- /* If we can't store this record (we've seen it
- before) then the free list has a loop and must
- be corrupt. */
-
- if (seen_insert(mem_tdb, rec_ptr)) {
- ret = TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
- goto fail;
- }
-
- if (tdb_rec_free_read(tdb, rec_ptr, &rec) == -1) {
- goto fail;
- }
-
- /* move to the next record */
- last_ptr = rec_ptr;
- rec_ptr = rec.next;
- *pnum_entries += 1;
- }
-
- ret = 0;
-
- fail:
-
- tdb_close(mem_tdb);
- tdb_unlock(tdb, -1, F_WRLCK);
- return ret;
-}
diff --git a/source4/lib/tdb/common/io.c b/source4/lib/tdb/common/io.c
deleted file mode 100644
index 661f761489..0000000000
--- a/source4/lib/tdb/common/io.c
+++ /dev/null
@@ -1,473 +0,0 @@
- /*
- Unix SMB/CIFS implementation.
-
- trivial database library
-
- Copyright (C) Andrew Tridgell 1999-2005
- Copyright (C) Paul `Rusty' Russell 2000
- Copyright (C) Jeremy Allison 2000-2003
-
- ** NOTE! The following LGPL license applies to the tdb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-
-#include "tdb_private.h"
-
-/* check for an out of bounds access - if it is out of bounds then
- see if the database has been expanded by someone else and expand
- if necessary
- note that "len" is the minimum length needed for the db
-*/
-static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, int probe)
-{
- struct stat st;
- if (len <= tdb->map_size)
- return 0;
- if (tdb->flags & TDB_INTERNAL) {
- if (!probe) {
- /* Ensure ecode is set for log fn. */
- tdb->ecode = TDB_ERR_IO;
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_oob len %d beyond internal malloc size %d\n",
- (int)len, (int)tdb->map_size));
- }
- return TDB_ERRCODE(TDB_ERR_IO, -1);
- }
-
- if (fstat(tdb->fd, &st) == -1) {
- return TDB_ERRCODE(TDB_ERR_IO, -1);
- }
-
- if (st.st_size < (size_t)len) {
- if (!probe) {
- /* Ensure ecode is set for log fn. */
- tdb->ecode = TDB_ERR_IO;
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_oob len %d beyond eof at %d\n",
- (int)len, (int)st.st_size));
- }
- return TDB_ERRCODE(TDB_ERR_IO, -1);
- }
-
- /* Unmap, update size, remap */
- if (tdb_munmap(tdb) == -1)
- return TDB_ERRCODE(TDB_ERR_IO, -1);
- tdb->map_size = st.st_size;
- tdb_mmap(tdb);
- return 0;
-}
-
-/* write a lump of data at a specified offset */
-static int tdb_write(struct tdb_context *tdb, tdb_off_t off,
- const void *buf, tdb_len_t len)
-{
- if (len == 0) {
- return 0;
- }
-
- if (tdb->read_only || tdb->traverse_read) {
- tdb->ecode = TDB_ERR_RDONLY;
- return -1;
- }
-
- if (tdb->methods->tdb_oob(tdb, off + len, 0) != 0)
- return -1;
-
- if (tdb->map_ptr) {
- memcpy(off + (char *)tdb->map_ptr, buf, len);
- } else {
- ssize_t written = pwrite(tdb->fd, buf, len, off);
- if ((written != (ssize_t)len) && (written != -1)) {
- /* try once more */
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_write: wrote only "
- "%d of %d bytes at %d, trying once more\n",
- (int)written, len, off));
- errno = ENOSPC;
- written = pwrite(tdb->fd, (const void *)((const char *)buf+written),
- len-written,
- off+written);
- }
- if (written == -1) {
- /* Ensure ecode is set for log fn. */
- tdb->ecode = TDB_ERR_IO;
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_write failed at %d "
- "len=%d (%s)\n", off, len, strerror(errno)));
- return TDB_ERRCODE(TDB_ERR_IO, -1);
- } else if (written != (ssize_t)len) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_write: failed to "
- "write %d bytes at %d in two attempts\n",
- len, off));
- errno = ENOSPC;
- return TDB_ERRCODE(TDB_ERR_IO, -1);
- }
- }
- return 0;
-}
-
-/* Endian conversion: we only ever deal with 4 byte quantities */
-void *tdb_convert(void *buf, uint32_t size)
-{
- uint32_t i, *p = (uint32_t *)buf;
- for (i = 0; i < size / 4; i++)
- p[i] = TDB_BYTEREV(p[i]);
- return buf;
-}
-
-
-/* read a lump of data at a specified offset, maybe convert */
-static int tdb_read(struct tdb_context *tdb, tdb_off_t off, void *buf,
- tdb_len_t len, int cv)
-{
- if (tdb->methods->tdb_oob(tdb, off + len, 0) != 0) {
- return -1;
- }
-
- if (tdb->map_ptr) {
- memcpy(buf, off + (char *)tdb->map_ptr, len);
- } else {
- ssize_t ret = pread(tdb->fd, buf, len, off);
- if (ret != (ssize_t)len) {
- /* Ensure ecode is set for log fn. */
- tdb->ecode = TDB_ERR_IO;
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_read failed at %d "
- "len=%d ret=%d (%s) map_size=%d\n",
- (int)off, (int)len, (int)ret, strerror(errno),
- (int)tdb->map_size));
- return TDB_ERRCODE(TDB_ERR_IO, -1);
- }
- }
- if (cv) {
- tdb_convert(buf, len);
- }
- return 0;
-}
-
-
-
-/*
- do an unlocked scan of the hash table heads to find the next non-zero head. The value
- will then be confirmed with the lock held
-*/
-static void tdb_next_hash_chain(struct tdb_context *tdb, uint32_t *chain)
-{
- uint32_t h = *chain;
- if (tdb->map_ptr) {
- for (;h < tdb->header.hash_size;h++) {
- if (0 != *(uint32_t *)(TDB_HASH_TOP(h) + (unsigned char *)tdb->map_ptr)) {
- break;
- }
- }
- } else {
- uint32_t off=0;
- for (;h < tdb->header.hash_size;h++) {
- if (tdb_ofs_read(tdb, TDB_HASH_TOP(h), &off) != 0 || off != 0) {
- break;
- }
- }
- }
- (*chain) = h;
-}
-
-
-int tdb_munmap(struct tdb_context *tdb)
-{
- if (tdb->flags & TDB_INTERNAL)
- return 0;
-
-#ifdef HAVE_MMAP
- if (tdb->map_ptr) {
- int ret;
-
- ret = munmap(tdb->map_ptr, tdb->map_size);
- if (ret != 0)
- return ret;
- }
-#endif
- tdb->map_ptr = NULL;
- return 0;
-}
-
-void tdb_mmap(struct tdb_context *tdb)
-{
- if (tdb->flags & TDB_INTERNAL)
- return;
-
-#ifdef HAVE_MMAP
- if (!(tdb->flags & TDB_NOMMAP)) {
- tdb->map_ptr = mmap(NULL, tdb->map_size,
- PROT_READ|(tdb->read_only? 0:PROT_WRITE),
- MAP_SHARED|MAP_FILE, tdb->fd, 0);
-
- /*
- * NB. When mmap fails it returns MAP_FAILED *NOT* NULL !!!!
- */
-
- if (tdb->map_ptr == MAP_FAILED) {
- tdb->map_ptr = NULL;
- TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_mmap failed for size %d (%s)\n",
- tdb->map_size, strerror(errno)));
- }
- } else {
- tdb->map_ptr = NULL;
- }
-#else
- tdb->map_ptr = NULL;
-#endif
-}
-
-/* expand a file. we prefer to use ftruncate, as that is what posix
- says to use for mmap expansion */
-static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t addition)
-{
- char buf[8192];
-
- if (tdb->read_only || tdb->traverse_read) {
- tdb->ecode = TDB_ERR_RDONLY;
- return -1;
- }
-
- if (ftruncate(tdb->fd, size+addition) == -1) {
- char b = 0;
- ssize_t written = pwrite(tdb->fd, &b, 1, (size+addition) - 1);
- if (written == 0) {
- /* try once more, potentially revealing errno */
- written = pwrite(tdb->fd, &b, 1, (size+addition) - 1);
- }
- if (written == 0) {
- /* again - give up, guessing errno */
- errno = ENOSPC;
- }
- if (written != 1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file to %d failed (%s)\n",
- size+addition, strerror(errno)));
- return -1;
- }
- }
-
- /* now fill the file with something. This ensures that the
- file isn't sparse, which would be very bad if we ran out of
- disk. This must be done with write, not via mmap */
- memset(buf, TDB_PAD_BYTE, sizeof(buf));
- while (addition) {
- size_t n = addition>sizeof(buf)?sizeof(buf):addition;
- ssize_t written = pwrite(tdb->fd, buf, n, size);
- if (written == 0) {
- /* prevent infinite loops: try _once_ more */
- written = pwrite(tdb->fd, buf, n, size);
- }
- if (written == 0) {
- /* give up, trying to provide a useful errno */
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file write "
- "returned 0 twice: giving up!\n"));
- errno = ENOSPC;
- return -1;
- } else if (written == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file write of "
- "%d bytes failed (%s)\n", (int)n,
- strerror(errno)));
- return -1;
- } else if (written != n) {
- TDB_LOG((tdb, TDB_DEBUG_WARNING, "expand_file: wrote "
- "only %d of %d bytes - retrying\n", (int)written,
- (int)n));
- }
- addition -= written;
- size += written;
- }
- return 0;
-}
-
-
-/* expand the database at least size bytes by expanding the underlying
- file and doing the mmap again if necessary */
-int tdb_expand(struct tdb_context *tdb, tdb_off_t size)
-{
- struct list_struct rec;
- tdb_off_t offset, new_size;
-
- if (tdb_lock(tdb, -1, F_WRLCK) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "lock failed in tdb_expand\n"));
- return -1;
- }
-
- /* must know about any previous expansions by another process */
- tdb->methods->tdb_oob(tdb, tdb->map_size + 1, 1);
-
- /* always make room for at least 100 more records, and at
- least 25% more space. Round the database up to a multiple
- of the page size */
- new_size = MAX(tdb->map_size + size*100, tdb->map_size * 1.25);
- size = TDB_ALIGN(new_size, tdb->page_size) - tdb->map_size;
-
- if (!(tdb->flags & TDB_INTERNAL))
- tdb_munmap(tdb);
-
- /*
- * We must ensure the file is unmapped before doing this
- * to ensure consistency with systems like OpenBSD where
- * writes and mmaps are not consistent.
- */
-
- /* expand the file itself */
- if (!(tdb->flags & TDB_INTERNAL)) {
- if (tdb->methods->tdb_expand_file(tdb, tdb->map_size, size) != 0)
- goto fail;
- }
-
- tdb->map_size += size;
-
- if (tdb->flags & TDB_INTERNAL) {
- char *new_map_ptr = (char *)realloc(tdb->map_ptr,
- tdb->map_size);
- if (!new_map_ptr) {
- tdb->map_size -= size;
- goto fail;
- }
- tdb->map_ptr = new_map_ptr;
- } else {
- /*
- * We must ensure the file is remapped before adding the space
- * to ensure consistency with systems like OpenBSD where
- * writes and mmaps are not consistent.
- */
-
- /* We're ok if the mmap fails as we'll fallback to read/write */
- tdb_mmap(tdb);
- }
-
- /* form a new freelist record */
- memset(&rec,'\0',sizeof(rec));
- rec.rec_len = size - sizeof(rec);
-
- /* link it into the free list */
- offset = tdb->map_size - size;
- if (tdb_free(tdb, offset, &rec) == -1)
- goto fail;
-
- tdb_unlock(tdb, -1, F_WRLCK);
- return 0;
- fail:
- tdb_unlock(tdb, -1, F_WRLCK);
- return -1;
-}
-
-/* read/write a tdb_off_t */
-int tdb_ofs_read(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d)
-{
- return tdb->methods->tdb_read(tdb, offset, (char*)d, sizeof(*d), DOCONV());
-}
-
-int tdb_ofs_write(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d)
-{
- tdb_off_t off = *d;
- return tdb->methods->tdb_write(tdb, offset, CONVERT(off), sizeof(*d));
-}
-
-
-/* read a lump of data, allocating the space for it */
-unsigned char *tdb_alloc_read(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t len)
-{
- unsigned char *buf;
-
- /* some systems don't like zero length malloc */
- if (len == 0) {
- len = 1;
- }
-
- if (!(buf = (unsigned char *)malloc(len))) {
- /* Ensure ecode is set for log fn. */
- tdb->ecode = TDB_ERR_OOM;
- TDB_LOG((tdb, TDB_DEBUG_ERROR,"tdb_alloc_read malloc failed len=%d (%s)\n",
- len, strerror(errno)));
- return TDB_ERRCODE(TDB_ERR_OOM, buf);
- }
- if (tdb->methods->tdb_read(tdb, offset, buf, len, 0) == -1) {
- SAFE_FREE(buf);
- return NULL;
- }
- return buf;
-}
-
-/* Give a piece of tdb data to a parser */
-
-int tdb_parse_data(struct tdb_context *tdb, TDB_DATA key,
- tdb_off_t offset, tdb_len_t len,
- int (*parser)(TDB_DATA key, TDB_DATA data,
- void *private_data),
- void *private_data)
-{
- TDB_DATA data;
- int result;
-
- data.dsize = len;
-
- if ((tdb->transaction == NULL) && (tdb->map_ptr != NULL)) {
- /*
- * Optimize by avoiding the malloc/memcpy/free, point the
- * parser directly at the mmap area.
- */
- if (tdb->methods->tdb_oob(tdb, offset+len, 0) != 0) {
- return -1;
- }
- data.dptr = offset + (unsigned char *)tdb->map_ptr;
- return parser(key, data, private_data);
- }
-
- if (!(data.dptr = tdb_alloc_read(tdb, offset, len))) {
- return -1;
- }
-
- result = parser(key, data, private_data);
- free(data.dptr);
- return result;
-}
-
-/* read/write a record */
-int tdb_rec_read(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec)
-{
- if (tdb->methods->tdb_read(tdb, offset, rec, sizeof(*rec),DOCONV()) == -1)
- return -1;
- if (TDB_BAD_MAGIC(rec)) {
- /* Ensure ecode is set for log fn. */
- tdb->ecode = TDB_ERR_CORRUPT;
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_rec_read bad magic 0x%x at offset=%d\n", rec->magic, offset));
- return TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
- }
- return tdb->methods->tdb_oob(tdb, rec->next+sizeof(*rec), 0);
-}
-
-int tdb_rec_write(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec)
-{
- struct list_struct r = *rec;
- return tdb->methods->tdb_write(tdb, offset, CONVERT(r), sizeof(r));
-}
-
-static const struct tdb_methods io_methods = {
- tdb_read,
- tdb_write,
- tdb_next_hash_chain,
- tdb_oob,
- tdb_expand_file,
- tdb_brlock
-};
-
-/*
- initialise the default methods table
-*/
-void tdb_io_init(struct tdb_context *tdb)
-{
- tdb->methods = &io_methods;
-}
diff --git a/source4/lib/tdb/common/lock.c b/source4/lib/tdb/common/lock.c
deleted file mode 100644
index f156c0fa7b..0000000000
--- a/source4/lib/tdb/common/lock.c
+++ /dev/null
@@ -1,553 +0,0 @@
- /*
- Unix SMB/CIFS implementation.
-
- trivial database library
-
- Copyright (C) Andrew Tridgell 1999-2005
- Copyright (C) Paul `Rusty' Russell 2000
- Copyright (C) Jeremy Allison 2000-2003
-
- ** NOTE! The following LGPL license applies to the tdb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "tdb_private.h"
-
-#define TDB_MARK_LOCK 0x80000000
-
-void tdb_setalarm_sigptr(struct tdb_context *tdb, volatile sig_atomic_t *ptr)
-{
- tdb->interrupt_sig_ptr = ptr;
-}
-
-/* a byte range locking function - return 0 on success
- this functions locks/unlocks 1 byte at the specified offset.
-
- On error, errno is also set so that errors are passed back properly
- through tdb_open().
-
- note that a len of zero means lock to end of file
-*/
-int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset,
- int rw_type, int lck_type, int probe, size_t len)
-{
- struct flock fl;
- int ret;
-
- if (tdb->flags & TDB_NOLOCK) {
- return 0;
- }
-
- if ((rw_type == F_WRLCK) && (tdb->read_only || tdb->traverse_read)) {
- tdb->ecode = TDB_ERR_RDONLY;
- return -1;
- }
-
- fl.l_type = rw_type;
- fl.l_whence = SEEK_SET;
- fl.l_start = offset;
- fl.l_len = len;
- fl.l_pid = 0;
-
- do {
- ret = fcntl(tdb->fd,lck_type,&fl);
-
- /* Check for a sigalarm break. */
- if (ret == -1 && errno == EINTR &&
- tdb->interrupt_sig_ptr &&
- *tdb->interrupt_sig_ptr) {
- break;
- }
- } while (ret == -1 && errno == EINTR);
-
- if (ret == -1) {
- /* Generic lock error. errno set by fcntl.
- * EAGAIN is an expected return from non-blocking
- * locks. */
- if (!probe && lck_type != F_SETLK) {
- /* Ensure error code is set for log fun to examine. */
- tdb->ecode = TDB_ERR_LOCK;
- TDB_LOG((tdb, TDB_DEBUG_TRACE,"tdb_brlock failed (fd=%d) at offset %d rw_type=%d lck_type=%d len=%d\n",
- tdb->fd, offset, rw_type, lck_type, (int)len));
- }
- return TDB_ERRCODE(TDB_ERR_LOCK, -1);
- }
- return 0;
-}
-
-
-/*
- upgrade a read lock to a write lock. This needs to be handled in a
- special way as some OSes (such as solaris) have too conservative
- deadlock detection and claim a deadlock when progress can be
- made. For those OSes we may loop for a while.
-*/
-int tdb_brlock_upgrade(struct tdb_context *tdb, tdb_off_t offset, size_t len)
-{
- int count = 1000;
- while (count--) {
- struct timeval tv;
- if (tdb_brlock(tdb, offset, F_WRLCK, F_SETLKW, 1, len) == 0) {
- return 0;
- }
- if (errno != EDEADLK) {
- break;
- }
- /* sleep for as short a time as we can - more portable than usleep() */
- tv.tv_sec = 0;
- tv.tv_usec = 1;
- select(0, NULL, NULL, NULL, &tv);
- }
- TDB_LOG((tdb, TDB_DEBUG_TRACE,"tdb_brlock_upgrade failed at offset %d\n", offset));
- return -1;
-}
-
-
-/* lock a list in the database. list -1 is the alloc list */
-static int _tdb_lock(struct tdb_context *tdb, int list, int ltype, int op)
-{
- struct tdb_lock_type *new_lck;
- int i;
- bool mark_lock = ((ltype & TDB_MARK_LOCK) == TDB_MARK_LOCK);
-
- ltype &= ~TDB_MARK_LOCK;
-
- /* a global lock allows us to avoid per chain locks */
- if (tdb->global_lock.count &&
- (ltype == tdb->global_lock.ltype || ltype == F_RDLCK)) {
- return 0;
- }
-
- if (tdb->global_lock.count) {
- return TDB_ERRCODE(TDB_ERR_LOCK, -1);
- }
-
- if (list < -1 || list >= (int)tdb->header.hash_size) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR,"tdb_lock: invalid list %d for ltype=%d\n",
- list, ltype));
- return -1;
- }
- if (tdb->flags & TDB_NOLOCK)
- return 0;
-
- for (i=0; i<tdb->num_lockrecs; i++) {
- if (tdb->lockrecs[i].list == list) {
- if (tdb->lockrecs[i].count == 0) {
- /*
- * Can't happen, see tdb_unlock(). It should
- * be an assert.
- */
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_lock: "
- "lck->count == 0 for list %d", list));
- }
- /*
- * Just increment the in-memory struct, posix locks
- * don't stack.
- */
- tdb->lockrecs[i].count++;
- return 0;
- }
- }
-
- new_lck = (struct tdb_lock_type *)realloc(
- tdb->lockrecs,
- sizeof(*tdb->lockrecs) * (tdb->num_lockrecs+1));
- if (new_lck == NULL) {
- errno = ENOMEM;
- return -1;
- }
- tdb->lockrecs = new_lck;
-
- /* Since fcntl locks don't nest, we do a lock for the first one,
- and simply bump the count for future ones */
- if (!mark_lock &&
- tdb->methods->tdb_brlock(tdb,FREELIST_TOP+4*list, ltype, op,
- 0, 1)) {
- return -1;
- }
-
- tdb->num_locks++;
-
- tdb->lockrecs[tdb->num_lockrecs].list = list;
- tdb->lockrecs[tdb->num_lockrecs].count = 1;
- tdb->lockrecs[tdb->num_lockrecs].ltype = ltype;
- tdb->num_lockrecs += 1;
-
- return 0;
-}
-
-/* lock a list in the database. list -1 is the alloc list */
-int tdb_lock(struct tdb_context *tdb, int list, int ltype)
-{
- int ret;
- ret = _tdb_lock(tdb, list, ltype, F_SETLKW);
- if (ret) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_lock failed on list %d "
- "ltype=%d (%s)\n", list, ltype, strerror(errno)));
- }
- return ret;
-}
-
-/* lock a list in the database. list -1 is the alloc list. non-blocking lock */
-int tdb_lock_nonblock(struct tdb_context *tdb, int list, int ltype)
-{
- return _tdb_lock(tdb, list, ltype, F_SETLK);
-}
-
-
-/* unlock the database: returns void because it's too late for errors. */
- /* changed to return int it may be interesting to know there
- has been an error --simo */
-int tdb_unlock(struct tdb_context *tdb, int list, int ltype)
-{
- int ret = -1;
- int i;
- struct tdb_lock_type *lck = NULL;
- bool mark_lock = ((ltype & TDB_MARK_LOCK) == TDB_MARK_LOCK);
-
- ltype &= ~TDB_MARK_LOCK;
-
- /* a global lock allows us to avoid per chain locks */
- if (tdb->global_lock.count &&
- (ltype == tdb->global_lock.ltype || ltype == F_RDLCK)) {
- return 0;
- }
-
- if (tdb->global_lock.count) {
- return TDB_ERRCODE(TDB_ERR_LOCK, -1);
- }
-
- if (tdb->flags & TDB_NOLOCK)
- return 0;
-
- /* Sanity checks */
- if (list < -1 || list >= (int)tdb->header.hash_size) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlock: list %d invalid (%d)\n", list, tdb->header.hash_size));
- return ret;
- }
-
- for (i=0; i<tdb->num_lockrecs; i++) {
- if (tdb->lockrecs[i].list == list) {
- lck = &tdb->lockrecs[i];
- break;
- }
- }
-
- if ((lck == NULL) || (lck->count == 0)) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlock: count is 0\n"));
- return -1;
- }
-
- if (lck->count > 1) {
- lck->count--;
- return 0;
- }
-
- /*
- * This lock has count==1 left, so we need to unlock it in the
- * kernel. We don't bother with decrementing the in-memory array
- * element, we're about to overwrite it with the last array element
- * anyway.
- */
-
- if (mark_lock) {
- ret = 0;
- } else {
- ret = tdb->methods->tdb_brlock(tdb, FREELIST_TOP+4*list, F_UNLCK,
- F_SETLKW, 0, 1);
- }
- tdb->num_locks--;
-
- /*
- * Shrink the array by overwriting the element just unlocked with the
- * last array element.
- */
-
- if (tdb->num_lockrecs > 1) {
- *lck = tdb->lockrecs[tdb->num_lockrecs-1];
- }
- tdb->num_lockrecs -= 1;
-
- /*
- * We don't bother with realloc when the array shrinks, but if we have
- * a completely idle tdb we should get rid of the locked array.
- */
-
- if (tdb->num_lockrecs == 0) {
- SAFE_FREE(tdb->lockrecs);
- }
-
- if (ret)
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlock: An error occurred unlocking!\n"));
- return ret;
-}
-
-/*
- get the transaction lock
- */
-int tdb_transaction_lock(struct tdb_context *tdb, int ltype)
-{
- if (tdb->have_transaction_lock || tdb->global_lock.count) {
- return 0;
- }
- if (tdb->methods->tdb_brlock(tdb, TRANSACTION_LOCK, ltype,
- F_SETLKW, 0, 1) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_lock: failed to get transaction lock\n"));
- tdb->ecode = TDB_ERR_LOCK;
- return -1;
- }
- tdb->have_transaction_lock = 1;
- return 0;
-}
-
-/*
- release the transaction lock
- */
-int tdb_transaction_unlock(struct tdb_context *tdb)
-{
- int ret;
- if (!tdb->have_transaction_lock) {
- return 0;
- }
- ret = tdb->methods->tdb_brlock(tdb, TRANSACTION_LOCK, F_UNLCK, F_SETLKW, 0, 1);
- if (ret == 0) {
- tdb->have_transaction_lock = 0;
- }
- return ret;
-}
-
-
-
-
-/* lock/unlock entire database */
-static int _tdb_lockall(struct tdb_context *tdb, int ltype, int op)
-{
- bool mark_lock = ((ltype & TDB_MARK_LOCK) == TDB_MARK_LOCK);
-
- ltype &= ~TDB_MARK_LOCK;
-
- /* There are no locks on read-only dbs */
- if (tdb->read_only || tdb->traverse_read)
- return TDB_ERRCODE(TDB_ERR_LOCK, -1);
-
- if (tdb->global_lock.count && tdb->global_lock.ltype == ltype) {
- tdb->global_lock.count++;
- return 0;
- }
-
- if (tdb->global_lock.count) {
- /* a global lock of a different type exists */
- return TDB_ERRCODE(TDB_ERR_LOCK, -1);
- }
-
- if (tdb->num_locks != 0) {
- /* can't combine global and chain locks */
- return TDB_ERRCODE(TDB_ERR_LOCK, -1);
- }
-
- if (!mark_lock &&
- tdb->methods->tdb_brlock(tdb, FREELIST_TOP, ltype, op,
- 0, 4*tdb->header.hash_size)) {
- if (op == F_SETLKW) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_lockall failed (%s)\n", strerror(errno)));
- }
- return -1;
- }
-
- tdb->global_lock.count = 1;
- tdb->global_lock.ltype = ltype;
-
- return 0;
-}
-
-
-
-/* unlock entire db */
-static int _tdb_unlockall(struct tdb_context *tdb, int ltype)
-{
- bool mark_lock = ((ltype & TDB_MARK_LOCK) == TDB_MARK_LOCK);
-
- ltype &= ~TDB_MARK_LOCK;
-
- /* There are no locks on read-only dbs */
- if (tdb->read_only || tdb->traverse_read) {
- return TDB_ERRCODE(TDB_ERR_LOCK, -1);
- }
-
- if (tdb->global_lock.ltype != ltype || tdb->global_lock.count == 0) {
- return TDB_ERRCODE(TDB_ERR_LOCK, -1);
- }
-
- if (tdb->global_lock.count > 1) {
- tdb->global_lock.count--;
- return 0;
- }
-
- if (!mark_lock &&
- tdb->methods->tdb_brlock(tdb, FREELIST_TOP, F_UNLCK, F_SETLKW,
- 0, 4*tdb->header.hash_size)) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlockall failed (%s)\n", strerror(errno)));
- return -1;
- }
-
- tdb->global_lock.count = 0;
- tdb->global_lock.ltype = 0;
-
- return 0;
-}
-
-/* lock entire database with write lock */
-int tdb_lockall(struct tdb_context *tdb)
-{
- return _tdb_lockall(tdb, F_WRLCK, F_SETLKW);
-}
-
-/* lock entire database with write lock - mark only */
-int tdb_lockall_mark(struct tdb_context *tdb)
-{
- return _tdb_lockall(tdb, F_WRLCK | TDB_MARK_LOCK, F_SETLKW);
-}
-
-/* unlock entire database with write lock - unmark only */
-int tdb_lockall_unmark(struct tdb_context *tdb)
-{
- return _tdb_unlockall(tdb, F_WRLCK | TDB_MARK_LOCK);
-}
-
-/* lock entire database with write lock - nonblocking varient */
-int tdb_lockall_nonblock(struct tdb_context *tdb)
-{
- return _tdb_lockall(tdb, F_WRLCK, F_SETLK);
-}
-
-/* unlock entire database with write lock */
-int tdb_unlockall(struct tdb_context *tdb)
-{
- return _tdb_unlockall(tdb, F_WRLCK);
-}
-
-/* lock entire database with read lock */
-int tdb_lockall_read(struct tdb_context *tdb)
-{
- return _tdb_lockall(tdb, F_RDLCK, F_SETLKW);
-}
-
-/* lock entire database with read lock - nonblock varient */
-int tdb_lockall_read_nonblock(struct tdb_context *tdb)
-{
- return _tdb_lockall(tdb, F_RDLCK, F_SETLK);
-}
-
-/* unlock entire database with read lock */
-int tdb_unlockall_read(struct tdb_context *tdb)
-{
- return _tdb_unlockall(tdb, F_RDLCK);
-}
-
-/* lock/unlock one hash chain. This is meant to be used to reduce
- contention - it cannot guarantee how many records will be locked */
-int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key)
-{
- return tdb_lock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK);
-}
-
-/* lock/unlock one hash chain, non-blocking. This is meant to be used
- to reduce contention - it cannot guarantee how many records will be
- locked */
-int tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key)
-{
- return tdb_lock_nonblock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK);
-}
-
-/* mark a chain as locked without actually locking it. Warning! use with great caution! */
-int tdb_chainlock_mark(struct tdb_context *tdb, TDB_DATA key)
-{
- return tdb_lock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK | TDB_MARK_LOCK);
-}
-
-/* unmark a chain as locked without actually locking it. Warning! use with great caution! */
-int tdb_chainlock_unmark(struct tdb_context *tdb, TDB_DATA key)
-{
- return tdb_unlock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK | TDB_MARK_LOCK);
-}
-
-int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key)
-{
- return tdb_unlock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK);
-}
-
-int tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key)
-{
- return tdb_lock(tdb, BUCKET(tdb->hash_fn(&key)), F_RDLCK);
-}
-
-int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key)
-{
- return tdb_unlock(tdb, BUCKET(tdb->hash_fn(&key)), F_RDLCK);
-}
-
-
-
-/* record lock stops delete underneath */
-int tdb_lock_record(struct tdb_context *tdb, tdb_off_t off)
-{
- if (tdb->global_lock.count) {
- return 0;
- }
- return off ? tdb->methods->tdb_brlock(tdb, off, F_RDLCK, F_SETLKW, 0, 1) : 0;
-}
-
-/*
- Write locks override our own fcntl readlocks, so check it here.
- Note this is meant to be F_SETLK, *not* F_SETLKW, as it's not
- an error to fail to get the lock here.
-*/
-int tdb_write_lock_record(struct tdb_context *tdb, tdb_off_t off)
-{
- struct tdb_traverse_lock *i;
- for (i = &tdb->travlocks; i; i = i->next)
- if (i->off == off)
- return -1;
- return tdb->methods->tdb_brlock(tdb, off, F_WRLCK, F_SETLK, 1, 1);
-}
-
-/*
- Note this is meant to be F_SETLK, *not* F_SETLKW, as it's not
- an error to fail to get the lock here.
-*/
-int tdb_write_unlock_record(struct tdb_context *tdb, tdb_off_t off)
-{
- return tdb->methods->tdb_brlock(tdb, off, F_UNLCK, F_SETLK, 0, 1);
-}
-
-/* fcntl locks don't stack: avoid unlocking someone else's */
-int tdb_unlock_record(struct tdb_context *tdb, tdb_off_t off)
-{
- struct tdb_traverse_lock *i;
- uint32_t count = 0;
-
- if (tdb->global_lock.count) {
- return 0;
- }
-
- if (off == 0)
- return 0;
- for (i = &tdb->travlocks; i; i = i->next)
- if (i->off == off)
- count++;
- return (count == 1 ? tdb->methods->tdb_brlock(tdb, off, F_UNLCK, F_SETLKW, 0, 1) : 0);
-}
diff --git a/source4/lib/tdb/common/open.c b/source4/lib/tdb/common/open.c
deleted file mode 100644
index b19e4cea29..0000000000
--- a/source4/lib/tdb/common/open.c
+++ /dev/null
@@ -1,488 +0,0 @@
- /*
- Unix SMB/CIFS implementation.
-
- trivial database library
-
- Copyright (C) Andrew Tridgell 1999-2005
- Copyright (C) Paul `Rusty' Russell 2000
- Copyright (C) Jeremy Allison 2000-2003
-
- ** NOTE! The following LGPL license applies to the tdb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "tdb_private.h"
-
-/* all contexts, to ensure no double-opens (fcntl locks don't nest!) */
-static struct tdb_context *tdbs = NULL;
-
-
-/* This is based on the hash algorithm from gdbm */
-static unsigned int default_tdb_hash(TDB_DATA *key)
-{
- uint32_t value; /* Used to compute the hash value. */
- uint32_t i; /* Used to cycle through random values. */
-
- /* Set the initial value from the key size. */
- for (value = 0x238F13AF * key->dsize, i=0; i < key->dsize; i++)
- value = (value + (key->dptr[i] << (i*5 % 24)));
-
- return (1103515243 * value + 12345);
-}
-
-
-/* initialise a new database with a specified hash size */
-static int tdb_new_database(struct tdb_context *tdb, int hash_size)
-{
- struct tdb_header *newdb;
- size_t size;
- int ret = -1;
- ssize_t written;
-
- /* We make it up in memory, then write it out if not internal */
- size = sizeof(struct tdb_header) + (hash_size+1)*sizeof(tdb_off_t);
- if (!(newdb = (struct tdb_header *)calloc(size, 1)))
- return TDB_ERRCODE(TDB_ERR_OOM, -1);
-
- /* Fill in the header */
- newdb->version = TDB_VERSION;
- newdb->hash_size = hash_size;
- if (tdb->flags & TDB_INTERNAL) {
- tdb->map_size = size;
- tdb->map_ptr = (char *)newdb;
- memcpy(&tdb->header, newdb, sizeof(tdb->header));
- /* Convert the `ondisk' version if asked. */
- CONVERT(*newdb);
- return 0;
- }
- if (lseek(tdb->fd, 0, SEEK_SET) == -1)
- goto fail;
-
- if (ftruncate(tdb->fd, 0) == -1)
- goto fail;
-
- /* This creates an endian-converted header, as if read from disk */
- CONVERT(*newdb);
- memcpy(&tdb->header, newdb, sizeof(tdb->header));
- /* Don't endian-convert the magic food! */
- memcpy(newdb->magic_food, TDB_MAGIC_FOOD, strlen(TDB_MAGIC_FOOD)+1);
- /* we still have "ret == -1" here */
- written = write(tdb->fd, newdb, size);
- if (written == size) {
- ret = 0;
- } else if (written != -1) {
- /* call write once again, this usually should return -1 and
- * set errno appropriately */
- size -= written;
- written = write(tdb->fd, newdb+written, size);
- if (written == size) {
- ret = 0;
- } else if (written >= 0) {
- /* a second incomplete write - we give up.
- * guessing the errno... */
- errno = ENOSPC;
- }
- }
-
- fail:
- SAFE_FREE(newdb);
- return ret;
-}
-
-
-
-static int tdb_already_open(dev_t device,
- ino_t ino)
-{
- struct tdb_context *i;
-
- for (i = tdbs; i; i = i->next) {
- if (i->device == device && i->inode == ino) {
- return 1;
- }
- }
-
- return 0;
-}
-
-/* open the database, creating it if necessary
-
- The open_flags and mode are passed straight to the open call on the
- database file. A flags value of O_WRONLY is invalid. The hash size
- is advisory, use zero for a default value.
-
- Return is NULL on error, in which case errno is also set. Don't
- try to call tdb_error or tdb_errname, just do strerror(errno).
-
- @param name may be NULL for internal databases. */
-struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags,
- int open_flags, mode_t mode)
-{
- return tdb_open_ex(name, hash_size, tdb_flags, open_flags, mode, NULL, NULL);
-}
-
-/* a default logging function */
-static void null_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
-static void null_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...)
-{
-}
-
-
-struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
- int open_flags, mode_t mode,
- const struct tdb_logging_context *log_ctx,
- tdb_hash_func hash_fn)
-{
- struct tdb_context *tdb;
- struct stat st;
- int rev = 0, locked = 0;
- unsigned char *vp;
- uint32_t vertest;
- unsigned v;
-
- if (!(tdb = (struct tdb_context *)calloc(1, sizeof *tdb))) {
- /* Can't log this */
- errno = ENOMEM;
- goto fail;
- }
- tdb_io_init(tdb);
- tdb->fd = -1;
- tdb->name = NULL;
- tdb->map_ptr = NULL;
- tdb->flags = tdb_flags;
- tdb->open_flags = open_flags;
- if (log_ctx) {
- tdb->log = *log_ctx;
- } else {
- tdb->log.log_fn = null_log_fn;
- tdb->log.log_private = NULL;
- }
- tdb->hash_fn = hash_fn ? hash_fn : default_tdb_hash;
-
- /* cache the page size */
- tdb->page_size = getpagesize();
- if (tdb->page_size <= 0) {
- tdb->page_size = 0x2000;
- }
-
- tdb->max_dead_records = (tdb_flags & TDB_VOLATILE) ? 5 : 0;
-
- if ((open_flags & O_ACCMODE) == O_WRONLY) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: can't open tdb %s write-only\n",
- name));
- errno = EINVAL;
- goto fail;
- }
-
- if (hash_size == 0)
- hash_size = DEFAULT_HASH_SIZE;
- if ((open_flags & O_ACCMODE) == O_RDONLY) {
- tdb->read_only = 1;
- /* read only databases don't do locking or clear if first */
- tdb->flags |= TDB_NOLOCK;
- tdb->flags &= ~TDB_CLEAR_IF_FIRST;
- }
-
- /* internal databases don't mmap or lock, and start off cleared */
- if (tdb->flags & TDB_INTERNAL) {
- tdb->flags |= (TDB_NOLOCK | TDB_NOMMAP);
- tdb->flags &= ~TDB_CLEAR_IF_FIRST;
- if (tdb_new_database(tdb, hash_size) != 0) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: tdb_new_database failed!"));
- goto fail;
- }
- goto internal;
- }
-
- if ((tdb->fd = open(name, open_flags, mode)) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_open_ex: could not open file %s: %s\n",
- name, strerror(errno)));
- goto fail; /* errno set by open(2) */
- }
-
- /* on exec, don't inherit the fd */
- v = fcntl(tdb->fd, F_GETFD, 0);
- fcntl(tdb->fd, F_SETFD, v | FD_CLOEXEC);
-
- /* ensure there is only one process initialising at once */
- if (tdb->methods->tdb_brlock(tdb, GLOBAL_LOCK, F_WRLCK, F_SETLKW, 0, 1) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: failed to get global lock on %s: %s\n",
- name, strerror(errno)));
- goto fail; /* errno set by tdb_brlock */
- }
-
- /* we need to zero database if we are the only one with it open */
- if ((tdb_flags & TDB_CLEAR_IF_FIRST) &&
- (!tdb->read_only) &&
- (locked = (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_WRLCK, F_SETLK, 0, 1) == 0))) {
- open_flags |= O_CREAT;
- if (ftruncate(tdb->fd, 0) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: "
- "failed to truncate %s: %s\n",
- name, strerror(errno)));
- goto fail; /* errno set by ftruncate */
- }
- }
-
- errno = 0;
- if (read(tdb->fd, &tdb->header, sizeof(tdb->header)) != sizeof(tdb->header)
- || strcmp(tdb->header.magic_food, TDB_MAGIC_FOOD) != 0
- || (tdb->header.version != TDB_VERSION
- && !(rev = (tdb->header.version==TDB_BYTEREV(TDB_VERSION))))) {
- /* its not a valid database - possibly initialise it */
- if (!(open_flags & O_CREAT) || tdb_new_database(tdb, hash_size) == -1) {
- if (errno == 0) {
- errno = EIO; /* ie bad format or something */
- }
- goto fail;
- }
- rev = (tdb->flags & TDB_CONVERT);
- }
- vp = (unsigned char *)&tdb->header.version;
- vertest = (((uint32_t)vp[0]) << 24) | (((uint32_t)vp[1]) << 16) |
- (((uint32_t)vp[2]) << 8) | (uint32_t)vp[3];
- tdb->flags |= (vertest==TDB_VERSION) ? TDB_BIGENDIAN : 0;
- if (!rev)
- tdb->flags &= ~TDB_CONVERT;
- else {
- tdb->flags |= TDB_CONVERT;
- tdb_convert(&tdb->header, sizeof(tdb->header));
- }
- if (fstat(tdb->fd, &st) == -1)
- goto fail;
-
- if (tdb->header.rwlocks != 0) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: spinlocks no longer supported\n"));
- goto fail;
- }
-
- /* Is it already in the open list? If so, fail. */
- if (tdb_already_open(st.st_dev, st.st_ino)) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: "
- "%s (%d,%d) is already open in this process\n",
- name, (int)st.st_dev, (int)st.st_ino));
- errno = EBUSY;
- goto fail;
- }
-
- if (!(tdb->name = (char *)strdup(name))) {
- errno = ENOMEM;
- goto fail;
- }
-
- tdb->map_size = st.st_size;
- tdb->device = st.st_dev;
- tdb->inode = st.st_ino;
- tdb_mmap(tdb);
- if (locked) {
- if (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_UNLCK, F_SETLK, 0, 1) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: "
- "failed to take ACTIVE_LOCK on %s: %s\n",
- name, strerror(errno)));
- goto fail;
- }
-
- }
-
- /* We always need to do this if the CLEAR_IF_FIRST flag is set, even if
- we didn't get the initial exclusive lock as we need to let all other
- users know we're using it. */
-
- if (tdb_flags & TDB_CLEAR_IF_FIRST) {
- /* leave this lock in place to indicate it's in use */
- if (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_RDLCK, F_SETLKW, 0, 1) == -1)
- goto fail;
- }
-
- /* if needed, run recovery */
- if (tdb_transaction_recover(tdb) == -1) {
- goto fail;
- }
-
- internal:
- /* Internal (memory-only) databases skip all the code above to
- * do with disk files, and resume here by releasing their
- * global lock and hooking into the active list. */
- if (tdb->methods->tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1) == -1)
- goto fail;
- tdb->next = tdbs;
- tdbs = tdb;
- return tdb;
-
- fail:
- { int save_errno = errno;
-
- if (!tdb)
- return NULL;
-
- if (tdb->map_ptr) {
- if (tdb->flags & TDB_INTERNAL)
- SAFE_FREE(tdb->map_ptr);
- else
- tdb_munmap(tdb);
- }
- SAFE_FREE(tdb->name);
- if (tdb->fd != -1)
- if (close(tdb->fd) != 0)
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: failed to close tdb->fd on error!\n"));
- SAFE_FREE(tdb);
- errno = save_errno;
- return NULL;
- }
-}
-
-/*
- * Set the maximum number of dead records per hash chain
- */
-
-void tdb_set_max_dead(struct tdb_context *tdb, int max_dead)
-{
- tdb->max_dead_records = max_dead;
-}
-
-/**
- * Close a database.
- *
- * @returns -1 for error; 0 for success.
- **/
-int tdb_close(struct tdb_context *tdb)
-{
- struct tdb_context **i;
- int ret = 0;
-
- if (tdb->transaction) {
- tdb_transaction_cancel(tdb);
- }
-
- if (tdb->map_ptr) {
- if (tdb->flags & TDB_INTERNAL)
- SAFE_FREE(tdb->map_ptr);
- else
- tdb_munmap(tdb);
- }
- SAFE_FREE(tdb->name);
- if (tdb->fd != -1)
- ret = close(tdb->fd);
- SAFE_FREE(tdb->lockrecs);
-
- /* Remove from contexts list */
- for (i = &tdbs; *i; i = &(*i)->next) {
- if (*i == tdb) {
- *i = tdb->next;
- break;
- }
- }
-
- memset(tdb, 0, sizeof(*tdb));
- SAFE_FREE(tdb);
-
- return ret;
-}
-
-/* register a loging function */
-void tdb_set_logging_function(struct tdb_context *tdb,
- const struct tdb_logging_context *log_ctx)
-{
- tdb->log = *log_ctx;
-}
-
-void *tdb_get_logging_private(struct tdb_context *tdb)
-{
- return tdb->log.log_private;
-}
-
-/* reopen a tdb - this can be used after a fork to ensure that we have an independent
- seek pointer from our parent and to re-establish locks */
-int tdb_reopen(struct tdb_context *tdb)
-{
- struct stat st;
-
- if (tdb->flags & TDB_INTERNAL) {
- return 0; /* Nothing to do. */
- }
-
- if (tdb->num_locks != 0 || tdb->global_lock.count) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_reopen: reopen not allowed with locks held\n"));
- goto fail;
- }
-
- if (tdb->transaction != 0) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_reopen: reopen not allowed inside a transaction\n"));
- goto fail;
- }
-
- if (tdb_munmap(tdb) != 0) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: munmap failed (%s)\n", strerror(errno)));
- goto fail;
- }
- if (close(tdb->fd) != 0)
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: WARNING closing tdb->fd failed!\n"));
- tdb->fd = open(tdb->name, tdb->open_flags & ~(O_CREAT|O_TRUNC), 0);
- if (tdb->fd == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: open failed (%s)\n", strerror(errno)));
- goto fail;
- }
- if ((tdb->flags & TDB_CLEAR_IF_FIRST) &&
- (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_RDLCK, F_SETLKW, 0, 1) == -1)) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: failed to obtain active lock\n"));
- goto fail;
- }
- if (fstat(tdb->fd, &st) != 0) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: fstat failed (%s)\n", strerror(errno)));
- goto fail;
- }
- if (st.st_ino != tdb->inode || st.st_dev != tdb->device) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: file dev/inode has changed!\n"));
- goto fail;
- }
- tdb_mmap(tdb);
-
- return 0;
-
-fail:
- tdb_close(tdb);
- return -1;
-}
-
-/* reopen all tdb's */
-int tdb_reopen_all(int parent_longlived)
-{
- struct tdb_context *tdb;
-
- for (tdb=tdbs; tdb; tdb = tdb->next) {
- /*
- * If the parent is longlived (ie. a
- * parent daemon architecture), we know
- * it will keep it's active lock on a
- * tdb opened with CLEAR_IF_FIRST. Thus
- * for child processes we don't have to
- * add an active lock. This is essential
- * to improve performance on systems that
- * keep POSIX locks as a non-scalable data
- * structure in the kernel.
- */
- if (parent_longlived) {
- /* Ensure no clear-if-first. */
- tdb->flags &= ~TDB_CLEAR_IF_FIRST;
- }
-
- if (tdb_reopen(tdb) != 0)
- return -1;
- }
-
- return 0;
-}
diff --git a/source4/lib/tdb/common/tdb.c b/source4/lib/tdb/common/tdb.c
deleted file mode 100644
index c7cec297f6..0000000000
--- a/source4/lib/tdb/common/tdb.c
+++ /dev/null
@@ -1,802 +0,0 @@
- /*
- Unix SMB/CIFS implementation.
-
- trivial database library
-
- Copyright (C) Andrew Tridgell 1999-2005
- Copyright (C) Paul `Rusty' Russell 2000
- Copyright (C) Jeremy Allison 2000-2003
-
- ** NOTE! The following LGPL license applies to the tdb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "tdb_private.h"
-
-TDB_DATA tdb_null;
-
-/*
- non-blocking increment of the tdb sequence number if the tdb has been opened using
- the TDB_SEQNUM flag
-*/
-void tdb_increment_seqnum_nonblock(struct tdb_context *tdb)
-{
- tdb_off_t seqnum=0;
-
- if (!(tdb->flags & TDB_SEQNUM)) {
- return;
- }
-
- /* we ignore errors from this, as we have no sane way of
- dealing with them.
- */
- tdb_ofs_read(tdb, TDB_SEQNUM_OFS, &seqnum);
- seqnum++;
- tdb_ofs_write(tdb, TDB_SEQNUM_OFS, &seqnum);
-}
-
-/*
- increment the tdb sequence number if the tdb has been opened using
- the TDB_SEQNUM flag
-*/
-static void tdb_increment_seqnum(struct tdb_context *tdb)
-{
- if (!(tdb->flags & TDB_SEQNUM)) {
- return;
- }
-
- if (tdb_brlock(tdb, TDB_SEQNUM_OFS, F_WRLCK, F_SETLKW, 1, 1) != 0) {
- return;
- }
-
- tdb_increment_seqnum_nonblock(tdb);
-
- tdb_brlock(tdb, TDB_SEQNUM_OFS, F_UNLCK, F_SETLKW, 1, 1);
-}
-
-static int tdb_key_compare(TDB_DATA key, TDB_DATA data, void *private_data)
-{
- return memcmp(data.dptr, key.dptr, data.dsize);
-}
-
-/* Returns 0 on fail. On success, return offset of record, and fills
- in rec */
-static tdb_off_t tdb_find(struct tdb_context *tdb, TDB_DATA key, uint32_t hash,
- struct list_struct *r)
-{
- tdb_off_t rec_ptr;
-
- /* read in the hash top */
- if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1)
- return 0;
-
- /* keep looking until we find the right record */
- while (rec_ptr) {
- if (tdb_rec_read(tdb, rec_ptr, r) == -1)
- return 0;
-
- if (!TDB_DEAD(r) && hash==r->full_hash
- && key.dsize==r->key_len
- && tdb_parse_data(tdb, key, rec_ptr + sizeof(*r),
- r->key_len, tdb_key_compare,
- NULL) == 0) {
- return rec_ptr;
- }
- rec_ptr = r->next;
- }
- return TDB_ERRCODE(TDB_ERR_NOEXIST, 0);
-}
-
-/* As tdb_find, but if you succeed, keep the lock */
-tdb_off_t tdb_find_lock_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash, int locktype,
- struct list_struct *rec)
-{
- uint32_t rec_ptr;
-
- if (tdb_lock(tdb, BUCKET(hash), locktype) == -1)
- return 0;
- if (!(rec_ptr = tdb_find(tdb, key, hash, rec)))
- tdb_unlock(tdb, BUCKET(hash), locktype);
- return rec_ptr;
-}
-
-
-/* update an entry in place - this only works if the new data size
- is <= the old data size and the key exists.
- on failure return -1.
-*/
-static int tdb_update_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash, TDB_DATA dbuf)
-{
- struct list_struct rec;
- tdb_off_t rec_ptr;
-
- /* find entry */
- if (!(rec_ptr = tdb_find(tdb, key, hash, &rec)))
- return -1;
-
- /* must be long enough key, data and tailer */
- if (rec.rec_len < key.dsize + dbuf.dsize + sizeof(tdb_off_t)) {
- tdb->ecode = TDB_SUCCESS; /* Not really an error */
- return -1;
- }
-
- if (tdb->methods->tdb_write(tdb, rec_ptr + sizeof(rec) + rec.key_len,
- dbuf.dptr, dbuf.dsize) == -1)
- return -1;
-
- if (dbuf.dsize != rec.data_len) {
- /* update size */
- rec.data_len = dbuf.dsize;
- return tdb_rec_write(tdb, rec_ptr, &rec);
- }
-
- return 0;
-}
-
-/* find an entry in the database given a key */
-/* If an entry doesn't exist tdb_err will be set to
- * TDB_ERR_NOEXIST. If a key has no data attached
- * then the TDB_DATA will have zero length but
- * a non-zero pointer
- */
-TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key)
-{
- tdb_off_t rec_ptr;
- struct list_struct rec;
- TDB_DATA ret;
- uint32_t hash;
-
- /* find which hash bucket it is in */
- hash = tdb->hash_fn(&key);
- if (!(rec_ptr = tdb_find_lock_hash(tdb,key,hash,F_RDLCK,&rec)))
- return tdb_null;
-
- ret.dptr = tdb_alloc_read(tdb, rec_ptr + sizeof(rec) + rec.key_len,
- rec.data_len);
- ret.dsize = rec.data_len;
- tdb_unlock(tdb, BUCKET(rec.full_hash), F_RDLCK);
- return ret;
-}
-
-/*
- * Find an entry in the database and hand the record's data to a parsing
- * function. The parsing function is executed under the chain read lock, so it
- * should be fast and should not block on other syscalls.
- *
- * DONT CALL OTHER TDB CALLS FROM THE PARSER, THIS MIGHT LEAD TO SEGFAULTS.
- *
- * For mmapped tdb's that do not have a transaction open it points the parsing
- * function directly at the mmap area, it avoids the malloc/memcpy in this
- * case. If a transaction is open or no mmap is available, it has to do
- * malloc/read/parse/free.
- *
- * This is interesting for all readers of potentially large data structures in
- * the tdb records, ldb indexes being one example.
- */
-
-int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key,
- int (*parser)(TDB_DATA key, TDB_DATA data,
- void *private_data),
- void *private_data)
-{
- tdb_off_t rec_ptr;
- struct list_struct rec;
- int ret;
- uint32_t hash;
-
- /* find which hash bucket it is in */
- hash = tdb->hash_fn(&key);
-
- if (!(rec_ptr = tdb_find_lock_hash(tdb,key,hash,F_RDLCK,&rec))) {
- return TDB_ERRCODE(TDB_ERR_NOEXIST, 0);
- }
-
- ret = tdb_parse_data(tdb, key, rec_ptr + sizeof(rec) + rec.key_len,
- rec.data_len, parser, private_data);
-
- tdb_unlock(tdb, BUCKET(rec.full_hash), F_RDLCK);
-
- return ret;
-}
-
-/* check if an entry in the database exists
-
- note that 1 is returned if the key is found and 0 is returned if not found
- this doesn't match the conventions in the rest of this module, but is
- compatible with gdbm
-*/
-static int tdb_exists_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash)
-{
- struct list_struct rec;
-
- if (tdb_find_lock_hash(tdb, key, hash, F_RDLCK, &rec) == 0)
- return 0;
- tdb_unlock(tdb, BUCKET(rec.full_hash), F_RDLCK);
- return 1;
-}
-
-int tdb_exists(struct tdb_context *tdb, TDB_DATA key)
-{
- uint32_t hash = tdb->hash_fn(&key);
- return tdb_exists_hash(tdb, key, hash);
-}
-
-/* actually delete an entry in the database given the offset */
-int tdb_do_delete(struct tdb_context *tdb, tdb_off_t rec_ptr, struct list_struct *rec)
-{
- tdb_off_t last_ptr, i;
- struct list_struct lastrec;
-
- if (tdb->read_only || tdb->traverse_read) return -1;
-
- if (((tdb->traverse_write != 0) && (!TDB_DEAD(rec))) ||
- tdb_write_lock_record(tdb, rec_ptr) == -1) {
- /* Someone traversing here: mark it as dead */
- rec->magic = TDB_DEAD_MAGIC;
- return tdb_rec_write(tdb, rec_ptr, rec);
- }
- if (tdb_write_unlock_record(tdb, rec_ptr) != 0)
- return -1;
-
- /* find previous record in hash chain */
- if (tdb_ofs_read(tdb, TDB_HASH_TOP(rec->full_hash), &i) == -1)
- return -1;
- for (last_ptr = 0; i != rec_ptr; last_ptr = i, i = lastrec.next)
- if (tdb_rec_read(tdb, i, &lastrec) == -1)
- return -1;
-
- /* unlink it: next ptr is at start of record. */
- if (last_ptr == 0)
- last_ptr = TDB_HASH_TOP(rec->full_hash);
- if (tdb_ofs_write(tdb, last_ptr, &rec->next) == -1)
- return -1;
-
- /* recover the space */
- if (tdb_free(tdb, rec_ptr, rec) == -1)
- return -1;
- return 0;
-}
-
-static int tdb_count_dead(struct tdb_context *tdb, uint32_t hash)
-{
- int res = 0;
- tdb_off_t rec_ptr;
- struct list_struct rec;
-
- /* read in the hash top */
- if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1)
- return 0;
-
- while (rec_ptr) {
- if (tdb_rec_read(tdb, rec_ptr, &rec) == -1)
- return 0;
-
- if (rec.magic == TDB_DEAD_MAGIC) {
- res += 1;
- }
- rec_ptr = rec.next;
- }
- return res;
-}
-
-/*
- * Purge all DEAD records from a hash chain
- */
-static int tdb_purge_dead(struct tdb_context *tdb, uint32_t hash)
-{
- int res = -1;
- struct list_struct rec;
- tdb_off_t rec_ptr;
-
- if (tdb_lock(tdb, -1, F_WRLCK) == -1) {
- return -1;
- }
-
- /* read in the hash top */
- if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1)
- goto fail;
-
- while (rec_ptr) {
- tdb_off_t next;
-
- if (tdb_rec_read(tdb, rec_ptr, &rec) == -1) {
- goto fail;
- }
-
- next = rec.next;
-
- if (rec.magic == TDB_DEAD_MAGIC
- && tdb_do_delete(tdb, rec_ptr, &rec) == -1) {
- goto fail;
- }
- rec_ptr = next;
- }
- res = 0;
- fail:
- tdb_unlock(tdb, -1, F_WRLCK);
- return res;
-}
-
-/* delete an entry in the database given a key */
-static int tdb_delete_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash)
-{
- tdb_off_t rec_ptr;
- struct list_struct rec;
- int ret;
-
- if (tdb->max_dead_records != 0) {
-
- /*
- * Allow for some dead records per hash chain, mainly for
- * tdb's with a very high create/delete rate like locking.tdb.
- */
-
- if (tdb_lock(tdb, BUCKET(hash), F_WRLCK) == -1)
- return -1;
-
- if (tdb_count_dead(tdb, hash) >= tdb->max_dead_records) {
- /*
- * Don't let the per-chain freelist grow too large,
- * delete all existing dead records
- */
- tdb_purge_dead(tdb, hash);
- }
-
- if (!(rec_ptr = tdb_find(tdb, key, hash, &rec))) {
- tdb_unlock(tdb, BUCKET(hash), F_WRLCK);
- return -1;
- }
-
- /*
- * Just mark the record as dead.
- */
- rec.magic = TDB_DEAD_MAGIC;
- ret = tdb_rec_write(tdb, rec_ptr, &rec);
- }
- else {
- if (!(rec_ptr = tdb_find_lock_hash(tdb, key, hash, F_WRLCK,
- &rec)))
- return -1;
-
- ret = tdb_do_delete(tdb, rec_ptr, &rec);
- }
-
- if (ret == 0) {
- tdb_increment_seqnum(tdb);
- }
-
- if (tdb_unlock(tdb, BUCKET(rec.full_hash), F_WRLCK) != 0)
- TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_delete: WARNING tdb_unlock failed!\n"));
- return ret;
-}
-
-int tdb_delete(struct tdb_context *tdb, TDB_DATA key)
-{
- uint32_t hash = tdb->hash_fn(&key);
- return tdb_delete_hash(tdb, key, hash);
-}
-
-/*
- * See if we have a dead record around with enough space
- */
-static tdb_off_t tdb_find_dead(struct tdb_context *tdb, uint32_t hash,
- struct list_struct *r, tdb_len_t length)
-{
- tdb_off_t rec_ptr;
-
- /* read in the hash top */
- if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1)
- return 0;
-
- /* keep looking until we find the right record */
- while (rec_ptr) {
- if (tdb_rec_read(tdb, rec_ptr, r) == -1)
- return 0;
-
- if (TDB_DEAD(r) && r->rec_len >= length) {
- /*
- * First fit for simple coding, TODO: change to best
- * fit
- */
- return rec_ptr;
- }
- rec_ptr = r->next;
- }
- return 0;
-}
-
-/* store an element in the database, replacing any existing element
- with the same key
-
- return 0 on success, -1 on failure
-*/
-int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag)
-{
- struct list_struct rec;
- uint32_t hash;
- tdb_off_t rec_ptr;
- char *p = NULL;
- int ret = -1;
-
- if (tdb->read_only || tdb->traverse_read) {
- tdb->ecode = TDB_ERR_RDONLY;
- return -1;
- }
-
- /* find which hash bucket it is in */
- hash = tdb->hash_fn(&key);
- if (tdb_lock(tdb, BUCKET(hash), F_WRLCK) == -1)
- return -1;
-
- /* check for it existing, on insert. */
- if (flag == TDB_INSERT) {
- if (tdb_exists_hash(tdb, key, hash)) {
- tdb->ecode = TDB_ERR_EXISTS;
- goto fail;
- }
- } else {
- /* first try in-place update, on modify or replace. */
- if (tdb_update_hash(tdb, key, hash, dbuf) == 0) {
- goto done;
- }
- if (tdb->ecode == TDB_ERR_NOEXIST &&
- flag == TDB_MODIFY) {
- /* if the record doesn't exist and we are in TDB_MODIFY mode then
- we should fail the store */
- goto fail;
- }
- }
- /* reset the error code potentially set by the tdb_update() */
- tdb->ecode = TDB_SUCCESS;
-
- /* delete any existing record - if it doesn't exist we don't
- care. Doing this first reduces fragmentation, and avoids
- coalescing with `allocated' block before it's updated. */
- if (flag != TDB_INSERT)
- tdb_delete_hash(tdb, key, hash);
-
- /* Copy key+value *before* allocating free space in case malloc
- fails and we are left with a dead spot in the tdb. */
-
- if (!(p = (char *)malloc(key.dsize + dbuf.dsize))) {
- tdb->ecode = TDB_ERR_OOM;
- goto fail;
- }
-
- memcpy(p, key.dptr, key.dsize);
- if (dbuf.dsize)
- memcpy(p+key.dsize, dbuf.dptr, dbuf.dsize);
-
- if (tdb->max_dead_records != 0) {
- /*
- * Allow for some dead records per hash chain, look if we can
- * find one that can hold the new record. We need enough space
- * for key, data and tailer. If we find one, we don't have to
- * consult the central freelist.
- */
- rec_ptr = tdb_find_dead(
- tdb, hash, &rec,
- key.dsize + dbuf.dsize + sizeof(tdb_off_t));
-
- if (rec_ptr != 0) {
- rec.key_len = key.dsize;
- rec.data_len = dbuf.dsize;
- rec.full_hash = hash;
- rec.magic = TDB_MAGIC;
- if (tdb_rec_write(tdb, rec_ptr, &rec) == -1
- || tdb->methods->tdb_write(
- tdb, rec_ptr + sizeof(rec),
- p, key.dsize + dbuf.dsize) == -1) {
- goto fail;
- }
- goto done;
- }
- }
-
- /*
- * We have to allocate some space from the freelist, so this means we
- * have to lock it. Use the chance to purge all the DEAD records from
- * the hash chain under the freelist lock.
- */
-
- if (tdb_lock(tdb, -1, F_WRLCK) == -1) {
- goto fail;
- }
-
- if ((tdb->max_dead_records != 0)
- && (tdb_purge_dead(tdb, hash) == -1)) {
- tdb_unlock(tdb, -1, F_WRLCK);
- goto fail;
- }
-
- /* we have to allocate some space */
- rec_ptr = tdb_allocate(tdb, key.dsize + dbuf.dsize, &rec);
-
- tdb_unlock(tdb, -1, F_WRLCK);
-
- if (rec_ptr == 0) {
- goto fail;
- }
-
- /* Read hash top into next ptr */
- if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec.next) == -1)
- goto fail;
-
- rec.key_len = key.dsize;
- rec.data_len = dbuf.dsize;
- rec.full_hash = hash;
- rec.magic = TDB_MAGIC;
-
- /* write out and point the top of the hash chain at it */
- if (tdb_rec_write(tdb, rec_ptr, &rec) == -1
- || tdb->methods->tdb_write(tdb, rec_ptr+sizeof(rec), p, key.dsize+dbuf.dsize)==-1
- || tdb_ofs_write(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) {
- /* Need to tdb_unallocate() here */
- goto fail;
- }
-
- done:
- ret = 0;
- fail:
- if (ret == 0) {
- tdb_increment_seqnum(tdb);
- }
-
- SAFE_FREE(p);
- tdb_unlock(tdb, BUCKET(hash), F_WRLCK);
- return ret;
-}
-
-
-/* Append to an entry. Create if not exist. */
-int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf)
-{
- uint32_t hash;
- TDB_DATA dbuf;
- int ret = -1;
-
- /* find which hash bucket it is in */
- hash = tdb->hash_fn(&key);
- if (tdb_lock(tdb, BUCKET(hash), F_WRLCK) == -1)
- return -1;
-
- dbuf = tdb_fetch(tdb, key);
-
- if (dbuf.dptr == NULL) {
- dbuf.dptr = (unsigned char *)malloc(new_dbuf.dsize);
- } else {
- unsigned char *new_dptr = (unsigned char *)realloc(dbuf.dptr,
- dbuf.dsize + new_dbuf.dsize);
- if (new_dptr == NULL) {
- free(dbuf.dptr);
- }
- dbuf.dptr = new_dptr;
- }
-
- if (dbuf.dptr == NULL) {
- tdb->ecode = TDB_ERR_OOM;
- goto failed;
- }
-
- memcpy(dbuf.dptr + dbuf.dsize, new_dbuf.dptr, new_dbuf.dsize);
- dbuf.dsize += new_dbuf.dsize;
-
- ret = tdb_store(tdb, key, dbuf, 0);
-
-failed:
- tdb_unlock(tdb, BUCKET(hash), F_WRLCK);
- SAFE_FREE(dbuf.dptr);
- return ret;
-}
-
-
-/*
- return the name of the current tdb file
- useful for external logging functions
-*/
-const char *tdb_name(struct tdb_context *tdb)
-{
- return tdb->name;
-}
-
-/*
- return the underlying file descriptor being used by tdb, or -1
- useful for external routines that want to check the device/inode
- of the fd
-*/
-int tdb_fd(struct tdb_context *tdb)
-{
- return tdb->fd;
-}
-
-/*
- return the current logging function
- useful for external tdb routines that wish to log tdb errors
-*/
-tdb_log_func tdb_log_fn(struct tdb_context *tdb)
-{
- return tdb->log.log_fn;
-}
-
-
-/*
- get the tdb sequence number. Only makes sense if the writers opened
- with TDB_SEQNUM set. Note that this sequence number will wrap quite
- quickly, so it should only be used for a 'has something changed'
- test, not for code that relies on the count of the number of changes
- made. If you want a counter then use a tdb record.
-
- The aim of this sequence number is to allow for a very lightweight
- test of a possible tdb change.
-*/
-int tdb_get_seqnum(struct tdb_context *tdb)
-{
- tdb_off_t seqnum=0;
-
- tdb_ofs_read(tdb, TDB_SEQNUM_OFS, &seqnum);
- return seqnum;
-}
-
-int tdb_hash_size(struct tdb_context *tdb)
-{
- return tdb->header.hash_size;
-}
-
-size_t tdb_map_size(struct tdb_context *tdb)
-{
- return tdb->map_size;
-}
-
-int tdb_get_flags(struct tdb_context *tdb)
-{
- return tdb->flags;
-}
-
-void tdb_add_flags(struct tdb_context *tdb, unsigned flags)
-{
- tdb->flags |= flags;
-}
-
-void tdb_remove_flags(struct tdb_context *tdb, unsigned flags)
-{
- tdb->flags &= ~flags;
-}
-
-
-/*
- enable sequence number handling on an open tdb
-*/
-void tdb_enable_seqnum(struct tdb_context *tdb)
-{
- tdb->flags |= TDB_SEQNUM;
-}
-
-
-/*
- add a region of the file to the freelist. Length is the size of the region in bytes,
- which includes the free list header that needs to be added
- */
-static int tdb_free_region(struct tdb_context *tdb, tdb_off_t offset, ssize_t length)
-{
- struct list_struct rec;
- if (length <= sizeof(rec)) {
- /* the region is not worth adding */
- return 0;
- }
- if (length + offset > tdb->map_size) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_free_region: adding region beyond end of file\n"));
- return -1;
- }
- memset(&rec,'\0',sizeof(rec));
- rec.rec_len = length - sizeof(rec);
- if (tdb_free(tdb, offset, &rec) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_free_region: failed to add free record\n"));
- return -1;
- }
- return 0;
-}
-
-/*
- wipe the entire database, deleting all records. This can be done
- very fast by using a global lock. The entire data portion of the
- file becomes a single entry in the freelist.
-
- This code carefully steps around the recovery area, leaving it alone
- */
-int tdb_wipe_all(struct tdb_context *tdb)
-{
- int i;
- tdb_off_t offset = 0;
- ssize_t data_len;
- tdb_off_t recovery_head;
- tdb_len_t recovery_size = 0;
-
- if (tdb_lockall(tdb) != 0) {
- return -1;
- }
-
- /* see if the tdb has a recovery area, and remember its size
- if so. We don't want to lose this as otherwise each
- tdb_wipe_all() in a transaction will increase the size of
- the tdb by the size of the recovery area */
- if (tdb_ofs_read(tdb, TDB_RECOVERY_HEAD, &recovery_head) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_wipe_all: failed to read recovery head\n"));
- goto failed;
- }
-
- if (recovery_head != 0) {
- struct list_struct rec;
- if (tdb->methods->tdb_read(tdb, recovery_head, &rec, sizeof(rec), DOCONV()) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_wipe_all: failed to read recovery record\n"));
- return -1;
- }
- recovery_size = rec.rec_len + sizeof(rec);
- }
-
- /* wipe the hashes */
- for (i=0;i<tdb->header.hash_size;i++) {
- if (tdb_ofs_write(tdb, TDB_HASH_TOP(i), &offset) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to write hash %d\n", i));
- goto failed;
- }
- }
-
- /* wipe the freelist */
- if (tdb_ofs_write(tdb, FREELIST_TOP, &offset) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to write freelist\n"));
- goto failed;
- }
-
- /* add all the rest of the file to the freelist, possibly leaving a gap
- for the recovery area */
- if (recovery_size == 0) {
- /* the simple case - the whole file can be used as a freelist */
- data_len = (tdb->map_size - TDB_DATA_START(tdb->header.hash_size));
- if (tdb_free_region(tdb, TDB_DATA_START(tdb->header.hash_size), data_len) != 0) {
- goto failed;
- }
- } else {
- /* we need to add two freelist entries - one on either
- side of the recovery area
-
- Note that we cannot shift the recovery area during
- this operation. Only the transaction.c code may
- move the recovery area or we risk subtle data
- corruption
- */
- data_len = (recovery_head - TDB_DATA_START(tdb->header.hash_size));
- if (tdb_free_region(tdb, TDB_DATA_START(tdb->header.hash_size), data_len) != 0) {
- goto failed;
- }
- /* and the 2nd free list entry after the recovery area - if any */
- data_len = tdb->map_size - (recovery_head+recovery_size);
- if (tdb_free_region(tdb, recovery_head+recovery_size, data_len) != 0) {
- goto failed;
- }
- }
-
- if (tdb_unlockall(tdb) != 0) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to unlock\n"));
- goto failed;
- }
-
- return 0;
-
-failed:
- tdb_unlockall(tdb);
- return -1;
-}
diff --git a/source4/lib/tdb/common/tdb_private.h b/source4/lib/tdb/common/tdb_private.h
deleted file mode 100644
index ffac89ff0e..0000000000
--- a/source4/lib/tdb/common/tdb_private.h
+++ /dev/null
@@ -1,213 +0,0 @@
- /*
- Unix SMB/CIFS implementation.
-
- trivial database library - private includes
-
- Copyright (C) Andrew Tridgell 2005
-
- ** NOTE! The following LGPL license applies to the tdb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "replace.h"
-#include "system/filesys.h"
-#include "system/time.h"
-#include "system/shmem.h"
-#include "system/select.h"
-#include "system/wait.h"
-#include "tdb.h"
-
-#ifndef HAVE_GETPAGESIZE
-#define getpagesize() 0x2000
-#endif
-
-typedef uint32_t tdb_len_t;
-typedef uint32_t tdb_off_t;
-
-#ifndef offsetof
-#define offsetof(t,f) ((unsigned int)&((t *)0)->f)
-#endif
-
-#define TDB_MAGIC_FOOD "TDB file\n"
-#define TDB_VERSION (0x26011967 + 6)
-#define TDB_MAGIC (0x26011999U)
-#define TDB_FREE_MAGIC (~TDB_MAGIC)
-#define TDB_DEAD_MAGIC (0xFEE1DEAD)
-#define TDB_RECOVERY_MAGIC (0xf53bc0e7U)
-#define TDB_ALIGNMENT 4
-#define DEFAULT_HASH_SIZE 131
-#define FREELIST_TOP (sizeof(struct tdb_header))
-#define TDB_ALIGN(x,a) (((x) + (a)-1) & ~((a)-1))
-#define TDB_BYTEREV(x) (((((x)&0xff)<<24)|((x)&0xFF00)<<8)|(((x)>>8)&0xFF00)|((x)>>24))
-#define TDB_DEAD(r) ((r)->magic == TDB_DEAD_MAGIC)
-#define TDB_BAD_MAGIC(r) ((r)->magic != TDB_MAGIC && !TDB_DEAD(r))
-#define TDB_HASH_TOP(hash) (FREELIST_TOP + (BUCKET(hash)+1)*sizeof(tdb_off_t))
-#define TDB_HASHTABLE_SIZE(tdb) ((tdb->header.hash_size+1)*sizeof(tdb_off_t))
-#define TDB_DATA_START(hash_size) (TDB_HASH_TOP(hash_size-1) + sizeof(tdb_off_t))
-#define TDB_RECOVERY_HEAD offsetof(struct tdb_header, recovery_start)
-#define TDB_SEQNUM_OFS offsetof(struct tdb_header, sequence_number)
-#define TDB_PAD_BYTE 0x42
-#define TDB_PAD_U32 0x42424242
-
-/* NB assumes there is a local variable called "tdb" that is the
- * current context, also takes doubly-parenthesized print-style
- * argument. */
-#define TDB_LOG(x) tdb->log.log_fn x
-
-/* lock offsets */
-#define GLOBAL_LOCK 0
-#define ACTIVE_LOCK 4
-#define TRANSACTION_LOCK 8
-
-/* free memory if the pointer is valid and zero the pointer */
-#ifndef SAFE_FREE
-#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0)
-#endif
-
-#define BUCKET(hash) ((hash) % tdb->header.hash_size)
-
-#define DOCONV() (tdb->flags & TDB_CONVERT)
-#define CONVERT(x) (DOCONV() ? tdb_convert(&x, sizeof(x)) : &x)
-
-
-/* the body of the database is made of one list_struct for the free space
- plus a separate data list for each hash value */
-struct list_struct {
- tdb_off_t next; /* offset of the next record in the list */
- tdb_len_t rec_len; /* total byte length of record */
- tdb_len_t key_len; /* byte length of key */
- tdb_len_t data_len; /* byte length of data */
- uint32_t full_hash; /* the full 32 bit hash of the key */
- uint32_t magic; /* try to catch errors */
- /* the following union is implied:
- union {
- char record[rec_len];
- struct {
- char key[key_len];
- char data[data_len];
- }
- uint32_t totalsize; (tailer)
- }
- */
-};
-
-
-/* this is stored at the front of every database */
-struct tdb_header {
- char magic_food[32]; /* for /etc/magic */
- uint32_t version; /* version of the code */
- uint32_t hash_size; /* number of hash entries */
- tdb_off_t rwlocks; /* obsolete - kept to detect old formats */
- tdb_off_t recovery_start; /* offset of transaction recovery region */
- tdb_off_t sequence_number; /* used when TDB_SEQNUM is set */
- tdb_off_t reserved[29];
-};
-
-struct tdb_lock_type {
- int list;
- uint32_t count;
- uint32_t ltype;
-};
-
-struct tdb_traverse_lock {
- struct tdb_traverse_lock *next;
- uint32_t off;
- uint32_t hash;
- int lock_rw;
-};
-
-
-struct tdb_methods {
- int (*tdb_read)(struct tdb_context *, tdb_off_t , void *, tdb_len_t , int );
- int (*tdb_write)(struct tdb_context *, tdb_off_t, const void *, tdb_len_t);
- void (*next_hash_chain)(struct tdb_context *, uint32_t *);
- int (*tdb_oob)(struct tdb_context *, tdb_off_t , int );
- int (*tdb_expand_file)(struct tdb_context *, tdb_off_t , tdb_off_t );
- int (*tdb_brlock)(struct tdb_context *, tdb_off_t , int, int, int, size_t);
-};
-
-struct tdb_context {
- char *name; /* the name of the database */
- void *map_ptr; /* where it is currently mapped */
- int fd; /* open file descriptor for the database */
- tdb_len_t map_size; /* how much space has been mapped */
- int read_only; /* opened read-only */
- int traverse_read; /* read-only traversal */
- int traverse_write; /* read-write traversal */
- struct tdb_lock_type global_lock;
- int num_lockrecs;
- struct tdb_lock_type *lockrecs; /* only real locks, all with count>0 */
- enum TDB_ERROR ecode; /* error code for last tdb error */
- struct tdb_header header; /* a cached copy of the header */
- uint32_t flags; /* the flags passed to tdb_open */
- struct tdb_traverse_lock travlocks; /* current traversal locks */
- struct tdb_context *next; /* all tdbs to avoid multiple opens */
- dev_t device; /* uniquely identifies this tdb */
- ino_t inode; /* uniquely identifies this tdb */
- struct tdb_logging_context log;
- unsigned int (*hash_fn)(TDB_DATA *key);
- int open_flags; /* flags used in the open - needed by reopen */
- unsigned int num_locks; /* number of chain locks held */
- const struct tdb_methods *methods;
- struct tdb_transaction *transaction;
- int page_size;
- int max_dead_records;
- bool have_transaction_lock;
- volatile sig_atomic_t *interrupt_sig_ptr;
-};
-
-
-/*
- internal prototypes
-*/
-int tdb_munmap(struct tdb_context *tdb);
-void tdb_mmap(struct tdb_context *tdb);
-int tdb_lock(struct tdb_context *tdb, int list, int ltype);
-int tdb_lock_nonblock(struct tdb_context *tdb, int list, int ltype);
-int tdb_unlock(struct tdb_context *tdb, int list, int ltype);
-int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, int rw_type, int lck_type, int probe, size_t len);
-int tdb_transaction_lock(struct tdb_context *tdb, int ltype);
-int tdb_transaction_unlock(struct tdb_context *tdb);
-int tdb_brlock_upgrade(struct tdb_context *tdb, tdb_off_t offset, size_t len);
-int tdb_write_lock_record(struct tdb_context *tdb, tdb_off_t off);
-int tdb_write_unlock_record(struct tdb_context *tdb, tdb_off_t off);
-int tdb_ofs_read(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d);
-int tdb_ofs_write(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d);
-void *tdb_convert(void *buf, uint32_t size);
-int tdb_free(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec);
-tdb_off_t tdb_allocate(struct tdb_context *tdb, tdb_len_t length, struct list_struct *rec);
-int tdb_ofs_read(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d);
-int tdb_ofs_write(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d);
-int tdb_lock_record(struct tdb_context *tdb, tdb_off_t off);
-int tdb_unlock_record(struct tdb_context *tdb, tdb_off_t off);
-int tdb_rec_read(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec);
-int tdb_rec_write(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec);
-int tdb_do_delete(struct tdb_context *tdb, tdb_off_t rec_ptr, struct list_struct *rec);
-unsigned char *tdb_alloc_read(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t len);
-int tdb_parse_data(struct tdb_context *tdb, TDB_DATA key,
- tdb_off_t offset, tdb_len_t len,
- int (*parser)(TDB_DATA key, TDB_DATA data,
- void *private_data),
- void *private_data);
-tdb_off_t tdb_find_lock_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash, int locktype,
- struct list_struct *rec);
-void tdb_io_init(struct tdb_context *tdb);
-int tdb_expand(struct tdb_context *tdb, tdb_off_t size);
-int tdb_rec_free_read(struct tdb_context *tdb, tdb_off_t off,
- struct list_struct *rec);
-
-
diff --git a/source4/lib/tdb/common/transaction.c b/source4/lib/tdb/common/transaction.c
deleted file mode 100644
index 7acda640c8..0000000000
--- a/source4/lib/tdb/common/transaction.c
+++ /dev/null
@@ -1,1119 +0,0 @@
- /*
- Unix SMB/CIFS implementation.
-
- trivial database library
-
- Copyright (C) Andrew Tridgell 2005
-
- ** NOTE! The following LGPL license applies to the tdb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "tdb_private.h"
-
-/*
- transaction design:
-
- - only allow a single transaction at a time per database. This makes
- using the transaction API simpler, as otherwise the caller would
- have to cope with temporary failures in transactions that conflict
- with other current transactions
-
- - keep the transaction recovery information in the same file as the
- database, using a special 'transaction recovery' record pointed at
- by the header. This removes the need for extra journal files as
- used by some other databases
-
- - dynamically allocated the transaction recover record, re-using it
- for subsequent transactions. If a larger record is needed then
- tdb_free() the old record to place it on the normal tdb freelist
- before allocating the new record
-
- - during transactions, keep a linked list of writes all that have
- been performed by intercepting all tdb_write() calls. The hooked
- transaction versions of tdb_read() and tdb_write() check this
- linked list and try to use the elements of the list in preference
- to the real database.
-
- - don't allow any locks to be held when a transaction starts,
- otherwise we can end up with deadlock (plus lack of lock nesting
- in posix locks would mean the lock is lost)
-
- - if the caller gains a lock during the transaction but doesn't
- release it then fail the commit
-
- - allow for nested calls to tdb_transaction_start(), re-using the
- existing transaction record. If the inner transaction is cancelled
- then a subsequent commit will fail
-
- - keep a mirrored copy of the tdb hash chain heads to allow for the
- fast hash heads scan on traverse, updating the mirrored copy in
- the transaction version of tdb_write
-
- - allow callers to mix transaction and non-transaction use of tdb,
- although once a transaction is started then an exclusive lock is
- gained until the transaction is committed or cancelled
-
- - the commit stategy involves first saving away all modified data
- into a linearised buffer in the transaction recovery area, then
- marking the transaction recovery area with a magic value to
- indicate a valid recovery record. In total 4 fsync/msync calls are
- needed per commit to prevent race conditions. It might be possible
- to reduce this to 3 or even 2 with some more work.
-
- - check for a valid recovery record on open of the tdb, while the
- global lock is held. Automatically recover from the transaction
- recovery area if needed, then continue with the open as
- usual. This allows for smooth crash recovery with no administrator
- intervention.
-
- - if TDB_NOSYNC is passed to flags in tdb_open then transactions are
- still available, but no transaction recovery area is used and no
- fsync/msync calls are made.
-
-*/
-
-
-/*
- hold the context of any current transaction
-*/
-struct tdb_transaction {
- /* we keep a mirrored copy of the tdb hash heads here so
- tdb_next_hash_chain() can operate efficiently */
- uint32_t *hash_heads;
-
- /* the original io methods - used to do IOs to the real db */
- const struct tdb_methods *io_methods;
-
- /* the list of transaction blocks. When a block is first
- written to, it gets created in this list */
- uint8_t **blocks;
- uint32_t num_blocks;
- uint32_t block_size; /* bytes in each block */
- uint32_t last_block_size; /* number of valid bytes in the last block */
-
- /* non-zero when an internal transaction error has
- occurred. All write operations will then fail until the
- transaction is ended */
- int transaction_error;
-
- /* when inside a transaction we need to keep track of any
- nested tdb_transaction_start() calls, as these are allowed,
- but don't create a new transaction */
- int nesting;
-
- /* old file size before transaction */
- tdb_len_t old_map_size;
-};
-
-
-/*
- read while in a transaction. We need to check first if the data is in our list
- of transaction elements, then if not do a real read
-*/
-static int transaction_read(struct tdb_context *tdb, tdb_off_t off, void *buf,
- tdb_len_t len, int cv)
-{
- uint32_t blk;
-
- /* break it down into block sized ops */
- while (len + (off % tdb->transaction->block_size) > tdb->transaction->block_size) {
- tdb_len_t len2 = tdb->transaction->block_size - (off % tdb->transaction->block_size);
- if (transaction_read(tdb, off, buf, len2, cv) != 0) {
- return -1;
- }
- len -= len2;
- off += len2;
- buf = (void *)(len2 + (char *)buf);
- }
-
- if (len == 0) {
- return 0;
- }
-
- blk = off / tdb->transaction->block_size;
-
- /* see if we have it in the block list */
- if (tdb->transaction->num_blocks <= blk ||
- tdb->transaction->blocks[blk] == NULL) {
- /* nope, do a real read */
- if (tdb->transaction->io_methods->tdb_read(tdb, off, buf, len, cv) != 0) {
- goto fail;
- }
- return 0;
- }
-
- /* it is in the block list. Now check for the last block */
- if (blk == tdb->transaction->num_blocks-1) {
- if (len > tdb->transaction->last_block_size) {
- goto fail;
- }
- }
-
- /* now copy it out of this block */
- memcpy(buf, tdb->transaction->blocks[blk] + (off % tdb->transaction->block_size), len);
- if (cv) {
- tdb_convert(buf, len);
- }
- return 0;
-
-fail:
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "transaction_read: failed at off=%d len=%d\n", off, len));
- tdb->ecode = TDB_ERR_IO;
- tdb->transaction->transaction_error = 1;
- return -1;
-}
-
-
-/*
- write while in a transaction
-*/
-static int transaction_write(struct tdb_context *tdb, tdb_off_t off,
- const void *buf, tdb_len_t len)
-{
- uint32_t blk;
-
- /* if the write is to a hash head, then update the transaction
- hash heads */
- if (len == sizeof(tdb_off_t) && off >= FREELIST_TOP &&
- off < FREELIST_TOP+TDB_HASHTABLE_SIZE(tdb)) {
- uint32_t chain = (off-FREELIST_TOP) / sizeof(tdb_off_t);
- memcpy(&tdb->transaction->hash_heads[chain], buf, len);
- }
-
- /* break it up into block sized chunks */
- while (len + (off % tdb->transaction->block_size) > tdb->transaction->block_size) {
- tdb_len_t len2 = tdb->transaction->block_size - (off % tdb->transaction->block_size);
- if (transaction_write(tdb, off, buf, len2) != 0) {
- return -1;
- }
- len -= len2;
- off += len2;
- if (buf != NULL) {
- buf = (const void *)(len2 + (const char *)buf);
- }
- }
-
- if (len == 0) {
- return 0;
- }
-
- blk = off / tdb->transaction->block_size;
- off = off % tdb->transaction->block_size;
-
- if (tdb->transaction->num_blocks <= blk) {
- uint8_t **new_blocks;
- /* expand the blocks array */
- if (tdb->transaction->blocks == NULL) {
- new_blocks = (uint8_t **)malloc(
- (blk+1)*sizeof(uint8_t *));
- } else {
- new_blocks = (uint8_t **)realloc(
- tdb->transaction->blocks,
- (blk+1)*sizeof(uint8_t *));
- }
- if (new_blocks == NULL) {
- tdb->ecode = TDB_ERR_OOM;
- goto fail;
- }
- memset(&new_blocks[tdb->transaction->num_blocks], 0,
- (1+(blk - tdb->transaction->num_blocks))*sizeof(uint8_t *));
- tdb->transaction->blocks = new_blocks;
- tdb->transaction->num_blocks = blk+1;
- tdb->transaction->last_block_size = 0;
- }
-
- /* allocate and fill a block? */
- if (tdb->transaction->blocks[blk] == NULL) {
- tdb->transaction->blocks[blk] = (uint8_t *)calloc(tdb->transaction->block_size, 1);
- if (tdb->transaction->blocks[blk] == NULL) {
- tdb->ecode = TDB_ERR_OOM;
- tdb->transaction->transaction_error = 1;
- return -1;
- }
- if (tdb->transaction->old_map_size > blk * tdb->transaction->block_size) {
- tdb_len_t len2 = tdb->transaction->block_size;
- if (len2 + (blk * tdb->transaction->block_size) > tdb->transaction->old_map_size) {
- len2 = tdb->transaction->old_map_size - (blk * tdb->transaction->block_size);
- }
- if (tdb->transaction->io_methods->tdb_read(tdb, blk * tdb->transaction->block_size,
- tdb->transaction->blocks[blk],
- len2, 0) != 0) {
- SAFE_FREE(tdb->transaction->blocks[blk]);
- tdb->ecode = TDB_ERR_IO;
- goto fail;
- }
- if (blk == tdb->transaction->num_blocks-1) {
- tdb->transaction->last_block_size = len2;
- }
- }
- }
-
- /* overwrite part of an existing block */
- if (buf == NULL) {
- memset(tdb->transaction->blocks[blk] + off, 0, len);
- } else {
- memcpy(tdb->transaction->blocks[blk] + off, buf, len);
- }
- if (blk == tdb->transaction->num_blocks-1) {
- if (len + off > tdb->transaction->last_block_size) {
- tdb->transaction->last_block_size = len + off;
- }
- }
-
- return 0;
-
-fail:
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "transaction_write: failed at off=%d len=%d\n",
- (blk*tdb->transaction->block_size) + off, len));
- tdb->transaction->transaction_error = 1;
- return -1;
-}
-
-
-/*
- write while in a transaction - this varient never expands the transaction blocks, it only
- updates existing blocks. This means it cannot change the recovery size
-*/
-static int transaction_write_existing(struct tdb_context *tdb, tdb_off_t off,
- const void *buf, tdb_len_t len)
-{
- uint32_t blk;
-
- /* break it up into block sized chunks */
- while (len + (off % tdb->transaction->block_size) > tdb->transaction->block_size) {
- tdb_len_t len2 = tdb->transaction->block_size - (off % tdb->transaction->block_size);
- if (transaction_write_existing(tdb, off, buf, len2) != 0) {
- return -1;
- }
- len -= len2;
- off += len2;
- if (buf != NULL) {
- buf = (const void *)(len2 + (const char *)buf);
- }
- }
-
- if (len == 0) {
- return 0;
- }
-
- blk = off / tdb->transaction->block_size;
- off = off % tdb->transaction->block_size;
-
- if (tdb->transaction->num_blocks <= blk ||
- tdb->transaction->blocks[blk] == NULL) {
- return 0;
- }
-
- if (blk == tdb->transaction->num_blocks-1 &&
- off + len > tdb->transaction->last_block_size) {
- if (off >= tdb->transaction->last_block_size) {
- return 0;
- }
- len = tdb->transaction->last_block_size - off;
- }
-
- /* overwrite part of an existing block */
- memcpy(tdb->transaction->blocks[blk] + off, buf, len);
-
- return 0;
-}
-
-
-/*
- accelerated hash chain head search, using the cached hash heads
-*/
-static void transaction_next_hash_chain(struct tdb_context *tdb, uint32_t *chain)
-{
- uint32_t h = *chain;
- for (;h < tdb->header.hash_size;h++) {
- /* the +1 takes account of the freelist */
- if (0 != tdb->transaction->hash_heads[h+1]) {
- break;
- }
- }
- (*chain) = h;
-}
-
-/*
- out of bounds check during a transaction
-*/
-static int transaction_oob(struct tdb_context *tdb, tdb_off_t len, int probe)
-{
- if (len <= tdb->map_size) {
- return 0;
- }
- return TDB_ERRCODE(TDB_ERR_IO, -1);
-}
-
-/*
- transaction version of tdb_expand().
-*/
-static int transaction_expand_file(struct tdb_context *tdb, tdb_off_t size,
- tdb_off_t addition)
-{
- /* add a write to the transaction elements, so subsequent
- reads see the zero data */
- if (transaction_write(tdb, size, NULL, addition) != 0) {
- return -1;
- }
-
- return 0;
-}
-
-/*
- brlock during a transaction - ignore them
-*/
-static int transaction_brlock(struct tdb_context *tdb, tdb_off_t offset,
- int rw_type, int lck_type, int probe, size_t len)
-{
- return 0;
-}
-
-static const struct tdb_methods transaction_methods = {
- transaction_read,
- transaction_write,
- transaction_next_hash_chain,
- transaction_oob,
- transaction_expand_file,
- transaction_brlock
-};
-
-
-/*
- start a tdb transaction. No token is returned, as only a single
- transaction is allowed to be pending per tdb_context
-*/
-int tdb_transaction_start(struct tdb_context *tdb)
-{
- /* some sanity checks */
- if (tdb->read_only || (tdb->flags & TDB_INTERNAL) || tdb->traverse_read) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_start: cannot start a transaction on a read-only or internal db\n"));
- tdb->ecode = TDB_ERR_EINVAL;
- return -1;
- }
-
- /* cope with nested tdb_transaction_start() calls */
- if (tdb->transaction != NULL) {
- tdb->transaction->nesting++;
- TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: nesting %d\n",
- tdb->transaction->nesting));
- return 0;
- }
-
- if (tdb->num_locks != 0 || tdb->global_lock.count) {
- /* the caller must not have any locks when starting a
- transaction as otherwise we'll be screwed by lack
- of nested locks in posix */
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_start: cannot start a transaction with locks held\n"));
- tdb->ecode = TDB_ERR_LOCK;
- return -1;
- }
-
- if (tdb->travlocks.next != NULL) {
- /* you cannot use transactions inside a traverse (although you can use
- traverse inside a transaction) as otherwise you can end up with
- deadlock */
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_start: cannot start a transaction within a traverse\n"));
- tdb->ecode = TDB_ERR_LOCK;
- return -1;
- }
-
- tdb->transaction = (struct tdb_transaction *)
- calloc(sizeof(struct tdb_transaction), 1);
- if (tdb->transaction == NULL) {
- tdb->ecode = TDB_ERR_OOM;
- return -1;
- }
-
- /* a page at a time seems like a reasonable compromise between compactness and efficiency */
- tdb->transaction->block_size = tdb->page_size;
-
- /* get the transaction write lock. This is a blocking lock. As
- discussed with Volker, there are a number of ways we could
- make this async, which we will probably do in the future */
- if (tdb_transaction_lock(tdb, F_WRLCK) == -1) {
- SAFE_FREE(tdb->transaction->blocks);
- SAFE_FREE(tdb->transaction);
- return -1;
- }
-
- /* get a read lock from the freelist to the end of file. This
- is upgraded to a write lock during the commit */
- if (tdb_brlock(tdb, FREELIST_TOP, F_RDLCK, F_SETLKW, 0, 0) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_start: failed to get hash locks\n"));
- tdb->ecode = TDB_ERR_LOCK;
- goto fail;
- }
-
- /* setup a copy of the hash table heads so the hash scan in
- traverse can be fast */
- tdb->transaction->hash_heads = (uint32_t *)
- calloc(tdb->header.hash_size+1, sizeof(uint32_t));
- if (tdb->transaction->hash_heads == NULL) {
- tdb->ecode = TDB_ERR_OOM;
- goto fail;
- }
- if (tdb->methods->tdb_read(tdb, FREELIST_TOP, tdb->transaction->hash_heads,
- TDB_HASHTABLE_SIZE(tdb), 0) != 0) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_start: failed to read hash heads\n"));
- tdb->ecode = TDB_ERR_IO;
- goto fail;
- }
-
- /* make sure we know about any file expansions already done by
- anyone else */
- tdb->methods->tdb_oob(tdb, tdb->map_size + 1, 1);
- tdb->transaction->old_map_size = tdb->map_size;
-
- /* finally hook the io methods, replacing them with
- transaction specific methods */
- tdb->transaction->io_methods = tdb->methods;
- tdb->methods = &transaction_methods;
-
- return 0;
-
-fail:
- tdb_brlock(tdb, FREELIST_TOP, F_UNLCK, F_SETLKW, 0, 0);
- tdb_transaction_unlock(tdb);
- SAFE_FREE(tdb->transaction->blocks);
- SAFE_FREE(tdb->transaction->hash_heads);
- SAFE_FREE(tdb->transaction);
- return -1;
-}
-
-
-/*
- cancel the current transaction
-*/
-int tdb_transaction_cancel(struct tdb_context *tdb)
-{
- int i;
-
- if (tdb->transaction == NULL) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_cancel: no transaction\n"));
- return -1;
- }
-
- if (tdb->transaction->nesting != 0) {
- tdb->transaction->transaction_error = 1;
- tdb->transaction->nesting--;
- return 0;
- }
-
- tdb->map_size = tdb->transaction->old_map_size;
-
- /* free all the transaction blocks */
- for (i=0;i<tdb->transaction->num_blocks;i++) {
- if (tdb->transaction->blocks[i] != NULL) {
- free(tdb->transaction->blocks[i]);
- }
- }
- SAFE_FREE(tdb->transaction->blocks);
-
- /* remove any global lock created during the transaction */
- if (tdb->global_lock.count != 0) {
- tdb_brlock(tdb, FREELIST_TOP, F_UNLCK, F_SETLKW, 0, 4*tdb->header.hash_size);
- tdb->global_lock.count = 0;
- }
-
- /* remove any locks created during the transaction */
- if (tdb->num_locks != 0) {
- for (i=0;i<tdb->num_lockrecs;i++) {
- tdb_brlock(tdb,FREELIST_TOP+4*tdb->lockrecs[i].list,
- F_UNLCK,F_SETLKW, 0, 1);
- }
- tdb->num_locks = 0;
- tdb->num_lockrecs = 0;
- SAFE_FREE(tdb->lockrecs);
- }
-
- /* restore the normal io methods */
- tdb->methods = tdb->transaction->io_methods;
-
- tdb_brlock(tdb, FREELIST_TOP, F_UNLCK, F_SETLKW, 0, 0);
- tdb_transaction_unlock(tdb);
- SAFE_FREE(tdb->transaction->hash_heads);
- SAFE_FREE(tdb->transaction);
-
- return 0;
-}
-
-/*
- sync to disk
-*/
-static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t length)
-{
- if (fsync(tdb->fd) != 0) {
- tdb->ecode = TDB_ERR_IO;
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction: fsync failed\n"));
- return -1;
- }
-#ifdef HAVE_MMAP
- if (tdb->map_ptr) {
- tdb_off_t moffset = offset & ~(tdb->page_size-1);
- if (msync(moffset + (char *)tdb->map_ptr,
- length + (offset - moffset), MS_SYNC) != 0) {
- tdb->ecode = TDB_ERR_IO;
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction: msync failed - %s\n",
- strerror(errno)));
- return -1;
- }
- }
-#endif
- return 0;
-}
-
-
-/*
- work out how much space the linearised recovery data will consume
-*/
-static tdb_len_t tdb_recovery_size(struct tdb_context *tdb)
-{
- tdb_len_t recovery_size = 0;
- int i;
-
- recovery_size = sizeof(uint32_t);
- for (i=0;i<tdb->transaction->num_blocks;i++) {
- if (i * tdb->transaction->block_size >= tdb->transaction->old_map_size) {
- break;
- }
- if (tdb->transaction->blocks[i] == NULL) {
- continue;
- }
- recovery_size += 2*sizeof(tdb_off_t);
- if (i == tdb->transaction->num_blocks-1) {
- recovery_size += tdb->transaction->last_block_size;
- } else {
- recovery_size += tdb->transaction->block_size;
- }
- }
-
- return recovery_size;
-}
-
-/*
- allocate the recovery area, or use an existing recovery area if it is
- large enough
-*/
-static int tdb_recovery_allocate(struct tdb_context *tdb,
- tdb_len_t *recovery_size,
- tdb_off_t *recovery_offset,
- tdb_len_t *recovery_max_size)
-{
- struct list_struct rec;
- const struct tdb_methods *methods = tdb->transaction->io_methods;
- tdb_off_t recovery_head;
-
- if (tdb_ofs_read(tdb, TDB_RECOVERY_HEAD, &recovery_head) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to read recovery head\n"));
- return -1;
- }
-
- rec.rec_len = 0;
-
- if (recovery_head != 0 &&
- methods->tdb_read(tdb, recovery_head, &rec, sizeof(rec), DOCONV()) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to read recovery record\n"));
- return -1;
- }
-
- *recovery_size = tdb_recovery_size(tdb);
-
- if (recovery_head != 0 && *recovery_size <= rec.rec_len) {
- /* it fits in the existing area */
- *recovery_max_size = rec.rec_len;
- *recovery_offset = recovery_head;
- return 0;
- }
-
- /* we need to free up the old recovery area, then allocate a
- new one at the end of the file. Note that we cannot use
- tdb_allocate() to allocate the new one as that might return
- us an area that is being currently used (as of the start of
- the transaction) */
- if (recovery_head != 0) {
- if (tdb_free(tdb, recovery_head, &rec) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to free previous recovery area\n"));
- return -1;
- }
- }
-
- /* the tdb_free() call might have increased the recovery size */
- *recovery_size = tdb_recovery_size(tdb);
-
- /* round up to a multiple of page size */
- *recovery_max_size = TDB_ALIGN(sizeof(rec) + *recovery_size, tdb->page_size) - sizeof(rec);
- *recovery_offset = tdb->map_size;
- recovery_head = *recovery_offset;
-
- if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size,
- (tdb->map_size - tdb->transaction->old_map_size) +
- sizeof(rec) + *recovery_max_size) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to create recovery area\n"));
- return -1;
- }
-
- /* remap the file (if using mmap) */
- methods->tdb_oob(tdb, tdb->map_size + 1, 1);
-
- /* we have to reset the old map size so that we don't try to expand the file
- again in the transaction commit, which would destroy the recovery area */
- tdb->transaction->old_map_size = tdb->map_size;
-
- /* write the recovery header offset and sync - we can sync without a race here
- as the magic ptr in the recovery record has not been set */
- CONVERT(recovery_head);
- if (methods->tdb_write(tdb, TDB_RECOVERY_HEAD,
- &recovery_head, sizeof(tdb_off_t)) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to write recovery head\n"));
- return -1;
- }
- if (transaction_write_existing(tdb, TDB_RECOVERY_HEAD, &recovery_head, sizeof(tdb_off_t)) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to write recovery head\n"));
- return -1;
- }
-
- return 0;
-}
-
-
-/*
- setup the recovery data that will be used on a crash during commit
-*/
-static int transaction_setup_recovery(struct tdb_context *tdb,
- tdb_off_t *magic_offset)
-{
- tdb_len_t recovery_size;
- unsigned char *data, *p;
- const struct tdb_methods *methods = tdb->transaction->io_methods;
- struct list_struct *rec;
- tdb_off_t recovery_offset, recovery_max_size;
- tdb_off_t old_map_size = tdb->transaction->old_map_size;
- uint32_t magic, tailer;
- int i;
-
- /*
- check that the recovery area has enough space
- */
- if (tdb_recovery_allocate(tdb, &recovery_size,
- &recovery_offset, &recovery_max_size) == -1) {
- return -1;
- }
-
- data = (unsigned char *)malloc(recovery_size + sizeof(*rec));
- if (data == NULL) {
- tdb->ecode = TDB_ERR_OOM;
- return -1;
- }
-
- rec = (struct list_struct *)data;
- memset(rec, 0, sizeof(*rec));
-
- rec->magic = 0;
- rec->data_len = recovery_size;
- rec->rec_len = recovery_max_size;
- rec->key_len = old_map_size;
- CONVERT(rec);
-
- /* build the recovery data into a single blob to allow us to do a single
- large write, which should be more efficient */
- p = data + sizeof(*rec);
- for (i=0;i<tdb->transaction->num_blocks;i++) {
- tdb_off_t offset;
- tdb_len_t length;
-
- if (tdb->transaction->blocks[i] == NULL) {
- continue;
- }
-
- offset = i * tdb->transaction->block_size;
- length = tdb->transaction->block_size;
- if (i == tdb->transaction->num_blocks-1) {
- length = tdb->transaction->last_block_size;
- }
-
- if (offset >= old_map_size) {
- continue;
- }
- if (offset + length > tdb->transaction->old_map_size) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_setup_recovery: transaction data over new region boundary\n"));
- free(data);
- tdb->ecode = TDB_ERR_CORRUPT;
- return -1;
- }
- memcpy(p, &offset, 4);
- memcpy(p+4, &length, 4);
- if (DOCONV()) {
- tdb_convert(p, 8);
- }
- /* the recovery area contains the old data, not the
- new data, so we have to call the original tdb_read
- method to get it */
- if (methods->tdb_read(tdb, offset, p + 8, length, 0) != 0) {
- free(data);
- tdb->ecode = TDB_ERR_IO;
- return -1;
- }
- p += 8 + length;
- }
-
- /* and the tailer */
- tailer = sizeof(*rec) + recovery_max_size;
- memcpy(p, &tailer, 4);
- CONVERT(p);
-
- /* write the recovery data to the recovery area */
- if (methods->tdb_write(tdb, recovery_offset, data, sizeof(*rec) + recovery_size) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_setup_recovery: failed to write recovery data\n"));
- free(data);
- tdb->ecode = TDB_ERR_IO;
- return -1;
- }
- if (transaction_write_existing(tdb, recovery_offset, data, sizeof(*rec) + recovery_size) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_setup_recovery: failed to write secondary recovery data\n"));
- free(data);
- tdb->ecode = TDB_ERR_IO;
- return -1;
- }
-
- /* as we don't have ordered writes, we have to sync the recovery
- data before we update the magic to indicate that the recovery
- data is present */
- if (transaction_sync(tdb, recovery_offset, sizeof(*rec) + recovery_size) == -1) {
- free(data);
- return -1;
- }
-
- free(data);
-
- magic = TDB_RECOVERY_MAGIC;
- CONVERT(magic);
-
- *magic_offset = recovery_offset + offsetof(struct list_struct, magic);
-
- if (methods->tdb_write(tdb, *magic_offset, &magic, sizeof(magic)) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_setup_recovery: failed to write recovery magic\n"));
- tdb->ecode = TDB_ERR_IO;
- return -1;
- }
- if (transaction_write_existing(tdb, *magic_offset, &magic, sizeof(magic)) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_setup_recovery: failed to write secondary recovery magic\n"));
- tdb->ecode = TDB_ERR_IO;
- return -1;
- }
-
- /* ensure the recovery magic marker is on disk */
- if (transaction_sync(tdb, *magic_offset, sizeof(magic)) == -1) {
- return -1;
- }
-
- return 0;
-}
-
-/*
- commit the current transaction
-*/
-int tdb_transaction_commit(struct tdb_context *tdb)
-{
- const struct tdb_methods *methods;
- tdb_off_t magic_offset = 0;
- uint32_t zero = 0;
- int i;
-
- if (tdb->transaction == NULL) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_commit: no transaction\n"));
- return -1;
- }
-
- if (tdb->transaction->transaction_error) {
- tdb->ecode = TDB_ERR_IO;
- tdb_transaction_cancel(tdb);
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_commit: transaction error pending\n"));
- return -1;
- }
-
-
- if (tdb->transaction->nesting != 0) {
- tdb->transaction->nesting--;
- return 0;
- }
-
- /* check for a null transaction */
- if (tdb->transaction->blocks == NULL) {
- tdb_transaction_cancel(tdb);
- return 0;
- }
-
- methods = tdb->transaction->io_methods;
-
- /* if there are any locks pending then the caller has not
- nested their locks properly, so fail the transaction */
- if (tdb->num_locks || tdb->global_lock.count) {
- tdb->ecode = TDB_ERR_LOCK;
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_commit: locks pending on commit\n"));
- tdb_transaction_cancel(tdb);
- return -1;
- }
-
- /* upgrade the main transaction lock region to a write lock */
- if (tdb_brlock_upgrade(tdb, FREELIST_TOP, 0) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_start: failed to upgrade hash locks\n"));
- tdb->ecode = TDB_ERR_LOCK;
- tdb_transaction_cancel(tdb);
- return -1;
- }
-
- /* get the global lock - this prevents new users attaching to the database
- during the commit */
- if (tdb_brlock(tdb, GLOBAL_LOCK, F_WRLCK, F_SETLKW, 0, 1) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_commit: failed to get global lock\n"));
- tdb->ecode = TDB_ERR_LOCK;
- tdb_transaction_cancel(tdb);
- return -1;
- }
-
- if (!(tdb->flags & TDB_NOSYNC)) {
- /* write the recovery data to the end of the file */
- if (transaction_setup_recovery(tdb, &magic_offset) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: failed to setup recovery data\n"));
- tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1);
- tdb_transaction_cancel(tdb);
- return -1;
- }
- }
-
- /* expand the file to the new size if needed */
- if (tdb->map_size != tdb->transaction->old_map_size) {
- if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size,
- tdb->map_size -
- tdb->transaction->old_map_size) == -1) {
- tdb->ecode = TDB_ERR_IO;
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: expansion failed\n"));
- tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1);
- tdb_transaction_cancel(tdb);
- return -1;
- }
- tdb->map_size = tdb->transaction->old_map_size;
- methods->tdb_oob(tdb, tdb->map_size + 1, 1);
- }
-
- /* perform all the writes */
- for (i=0;i<tdb->transaction->num_blocks;i++) {
- tdb_off_t offset;
- tdb_len_t length;
-
- if (tdb->transaction->blocks[i] == NULL) {
- continue;
- }
-
- offset = i * tdb->transaction->block_size;
- length = tdb->transaction->block_size;
- if (i == tdb->transaction->num_blocks-1) {
- length = tdb->transaction->last_block_size;
- }
-
- if (methods->tdb_write(tdb, offset, tdb->transaction->blocks[i], length) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: write failed during commit\n"));
-
- /* we've overwritten part of the data and
- possibly expanded the file, so we need to
- run the crash recovery code */
- tdb->methods = methods;
- tdb_transaction_recover(tdb);
-
- tdb_transaction_cancel(tdb);
- tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1);
-
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: write failed\n"));
- return -1;
- }
- SAFE_FREE(tdb->transaction->blocks[i]);
- }
-
- SAFE_FREE(tdb->transaction->blocks);
- tdb->transaction->num_blocks = 0;
-
- if (!(tdb->flags & TDB_NOSYNC)) {
- /* ensure the new data is on disk */
- if (transaction_sync(tdb, 0, tdb->map_size) == -1) {
- return -1;
- }
-
- /* remove the recovery marker */
- if (methods->tdb_write(tdb, magic_offset, &zero, 4) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: failed to remove recovery magic\n"));
- return -1;
- }
-
- /* ensure the recovery marker has been removed on disk */
- if (transaction_sync(tdb, magic_offset, 4) == -1) {
- return -1;
- }
- }
-
- tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1);
-
- /*
- TODO: maybe write to some dummy hdr field, or write to magic
- offset without mmap, before the last sync, instead of the
- utime() call
- */
-
- /* on some systems (like Linux 2.6.x) changes via mmap/msync
- don't change the mtime of the file, this means the file may
- not be backed up (as tdb rounding to block sizes means that
- file size changes are quite rare too). The following forces
- mtime changes when a transaction completes */
-#ifdef HAVE_UTIME
- utime(tdb->name, NULL);
-#endif
-
- /* use a transaction cancel to free memory and remove the
- transaction locks */
- tdb_transaction_cancel(tdb);
-
- return 0;
-}
-
-
-/*
- recover from an aborted transaction. Must be called with exclusive
- database write access already established (including the global
- lock to prevent new processes attaching)
-*/
-int tdb_transaction_recover(struct tdb_context *tdb)
-{
- tdb_off_t recovery_head, recovery_eof;
- unsigned char *data, *p;
- uint32_t zero = 0;
- struct list_struct rec;
-
- /* find the recovery area */
- if (tdb_ofs_read(tdb, TDB_RECOVERY_HEAD, &recovery_head) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery head\n"));
- tdb->ecode = TDB_ERR_IO;
- return -1;
- }
-
- if (recovery_head == 0) {
- /* we have never allocated a recovery record */
- return 0;
- }
-
- /* read the recovery record */
- if (tdb->methods->tdb_read(tdb, recovery_head, &rec,
- sizeof(rec), DOCONV()) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery record\n"));
- tdb->ecode = TDB_ERR_IO;
- return -1;
- }
-
- if (rec.magic != TDB_RECOVERY_MAGIC) {
- /* there is no valid recovery data */
- return 0;
- }
-
- if (tdb->read_only) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: attempt to recover read only database\n"));
- tdb->ecode = TDB_ERR_CORRUPT;
- return -1;
- }
-
- recovery_eof = rec.key_len;
-
- data = (unsigned char *)malloc(rec.data_len);
- if (data == NULL) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to allocate recovery data\n"));
- tdb->ecode = TDB_ERR_OOM;
- return -1;
- }
-
- /* read the full recovery data */
- if (tdb->methods->tdb_read(tdb, recovery_head + sizeof(rec), data,
- rec.data_len, 0) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery data\n"));
- tdb->ecode = TDB_ERR_IO;
- return -1;
- }
-
- /* recover the file data */
- p = data;
- while (p+8 < data + rec.data_len) {
- uint32_t ofs, len;
- if (DOCONV()) {
- tdb_convert(p, 8);
- }
- memcpy(&ofs, p, 4);
- memcpy(&len, p+4, 4);
-
- if (tdb->methods->tdb_write(tdb, ofs, p+8, len) == -1) {
- free(data);
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to recover %d bytes at offset %d\n", len, ofs));
- tdb->ecode = TDB_ERR_IO;
- return -1;
- }
- p += 8 + len;
- }
-
- free(data);
-
- if (transaction_sync(tdb, 0, tdb->map_size) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to sync recovery\n"));
- tdb->ecode = TDB_ERR_IO;
- return -1;
- }
-
- /* if the recovery area is after the recovered eof then remove it */
- if (recovery_eof <= recovery_head) {
- if (tdb_ofs_write(tdb, TDB_RECOVERY_HEAD, &zero) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to remove recovery head\n"));
- tdb->ecode = TDB_ERR_IO;
- return -1;
- }
- }
-
- /* remove the recovery magic */
- if (tdb_ofs_write(tdb, recovery_head + offsetof(struct list_struct, magic),
- &zero) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to remove recovery magic\n"));
- tdb->ecode = TDB_ERR_IO;
- return -1;
- }
-
- /* reduce the file size to the old size */
- tdb_munmap(tdb);
- if (ftruncate(tdb->fd, recovery_eof) != 0) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to reduce to recovery size\n"));
- tdb->ecode = TDB_ERR_IO;
- return -1;
- }
- tdb->map_size = recovery_eof;
- tdb_mmap(tdb);
-
- if (transaction_sync(tdb, 0, recovery_eof) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to sync2 recovery\n"));
- tdb->ecode = TDB_ERR_IO;
- return -1;
- }
-
- TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_recover: recovered %d byte database\n",
- recovery_eof));
-
- /* all done */
- return 0;
-}
diff --git a/source4/lib/tdb/common/traverse.c b/source4/lib/tdb/common/traverse.c
deleted file mode 100644
index 69c81e6e98..0000000000
--- a/source4/lib/tdb/common/traverse.c
+++ /dev/null
@@ -1,348 +0,0 @@
- /*
- Unix SMB/CIFS implementation.
-
- trivial database library
-
- Copyright (C) Andrew Tridgell 1999-2005
- Copyright (C) Paul `Rusty' Russell 2000
- Copyright (C) Jeremy Allison 2000-2003
-
- ** NOTE! The following LGPL license applies to the tdb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "tdb_private.h"
-
-/* Uses traverse lock: 0 = finish, -1 = error, other = record offset */
-static int tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock *tlock,
- struct list_struct *rec)
-{
- int want_next = (tlock->off != 0);
-
- /* Lock each chain from the start one. */
- for (; tlock->hash < tdb->header.hash_size; tlock->hash++) {
- if (!tlock->off && tlock->hash != 0) {
- /* this is an optimisation for the common case where
- the hash chain is empty, which is particularly
- common for the use of tdb with ldb, where large
- hashes are used. In that case we spend most of our
- time in tdb_brlock(), locking empty hash chains.
-
- To avoid this, we do an unlocked pre-check to see
- if the hash chain is empty before starting to look
- inside it. If it is empty then we can avoid that
- hash chain. If it isn't empty then we can't believe
- the value we get back, as we read it without a
- lock, so instead we get the lock and re-fetch the
- value below.
-
- Notice that not doing this optimisation on the
- first hash chain is critical. We must guarantee
- that we have done at least one fcntl lock at the
- start of a search to guarantee that memory is
- coherent on SMP systems. If records are added by
- others during the search then thats OK, and we
- could possibly miss those with this trick, but we
- could miss them anyway without this trick, so the
- semantics don't change.
-
- With a non-indexed ldb search this trick gains us a
- factor of around 80 in speed on a linux 2.6.x
- system (testing using ldbtest).
- */
- tdb->methods->next_hash_chain(tdb, &tlock->hash);
- if (tlock->hash == tdb->header.hash_size) {
- continue;
- }
- }
-
- if (tdb_lock(tdb, tlock->hash, tlock->lock_rw) == -1)
- return -1;
-
- /* No previous record? Start at top of chain. */
- if (!tlock->off) {
- if (tdb_ofs_read(tdb, TDB_HASH_TOP(tlock->hash),
- &tlock->off) == -1)
- goto fail;
- } else {
- /* Otherwise unlock the previous record. */
- if (tdb_unlock_record(tdb, tlock->off) != 0)
- goto fail;
- }
-
- if (want_next) {
- /* We have offset of old record: grab next */
- if (tdb_rec_read(tdb, tlock->off, rec) == -1)
- goto fail;
- tlock->off = rec->next;
- }
-
- /* Iterate through chain */
- while( tlock->off) {
- tdb_off_t current;
- if (tdb_rec_read(tdb, tlock->off, rec) == -1)
- goto fail;
-
- /* Detect infinite loops. From "Shlomi Yaakobovich" <Shlomi@exanet.com>. */
- if (tlock->off == rec->next) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_next_lock: loop detected.\n"));
- goto fail;
- }
-
- if (!TDB_DEAD(rec)) {
- /* Woohoo: we found one! */
- if (tdb_lock_record(tdb, tlock->off) != 0)
- goto fail;
- return tlock->off;
- }
-
- /* Try to clean dead ones from old traverses */
- current = tlock->off;
- tlock->off = rec->next;
- if (!(tdb->read_only || tdb->traverse_read) &&
- tdb_do_delete(tdb, current, rec) != 0)
- goto fail;
- }
- tdb_unlock(tdb, tlock->hash, tlock->lock_rw);
- want_next = 0;
- }
- /* We finished iteration without finding anything */
- return TDB_ERRCODE(TDB_SUCCESS, 0);
-
- fail:
- tlock->off = 0;
- if (tdb_unlock(tdb, tlock->hash, tlock->lock_rw) != 0)
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_next_lock: On error unlock failed!\n"));
- return -1;
-}
-
-/* traverse the entire database - calling fn(tdb, key, data) on each element.
- return -1 on error or the record count traversed
- if fn is NULL then it is not called
- a non-zero return value from fn() indicates that the traversal should stop
- */
-static int tdb_traverse_internal(struct tdb_context *tdb,
- tdb_traverse_func fn, void *private_data,
- struct tdb_traverse_lock *tl)
-{
- TDB_DATA key, dbuf;
- struct list_struct rec;
- int ret, count = 0;
-
- /* This was in the initializaton, above, but the IRIX compiler
- * did not like it. crh
- */
- tl->next = tdb->travlocks.next;
-
- /* fcntl locks don't stack: beware traverse inside traverse */
- tdb->travlocks.next = tl;
-
- /* tdb_next_lock places locks on the record returned, and its chain */
- while ((ret = tdb_next_lock(tdb, tl, &rec)) > 0) {
- count++;
- /* now read the full record */
- key.dptr = tdb_alloc_read(tdb, tl->off + sizeof(rec),
- rec.key_len + rec.data_len);
- if (!key.dptr) {
- ret = -1;
- if (tdb_unlock(tdb, tl->hash, tl->lock_rw) != 0)
- goto out;
- if (tdb_unlock_record(tdb, tl->off) != 0)
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_traverse: key.dptr == NULL and unlock_record failed!\n"));
- goto out;
- }
- key.dsize = rec.key_len;
- dbuf.dptr = key.dptr + rec.key_len;
- dbuf.dsize = rec.data_len;
-
- /* Drop chain lock, call out */
- if (tdb_unlock(tdb, tl->hash, tl->lock_rw) != 0) {
- ret = -1;
- SAFE_FREE(key.dptr);
- goto out;
- }
- if (fn && fn(tdb, key, dbuf, private_data)) {
- /* They want us to terminate traversal */
- ret = count;
- if (tdb_unlock_record(tdb, tl->off) != 0) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_traverse: unlock_record failed!\n"));;
- ret = -1;
- }
- SAFE_FREE(key.dptr);
- goto out;
- }
- SAFE_FREE(key.dptr);
- }
-out:
- tdb->travlocks.next = tl->next;
- if (ret < 0)
- return -1;
- else
- return count;
-}
-
-
-/*
- a write style traverse - temporarily marks the db read only
-*/
-int tdb_traverse_read(struct tdb_context *tdb,
- tdb_traverse_func fn, void *private_data)
-{
- struct tdb_traverse_lock tl = { NULL, 0, 0, F_RDLCK };
- int ret;
- bool in_transaction = (tdb->transaction != NULL);
-
- /* we need to get a read lock on the transaction lock here to
- cope with the lock ordering semantics of solaris10 */
- if (!in_transaction) {
- if (tdb_transaction_lock(tdb, F_RDLCK)) {
- return -1;
- }
- }
-
- tdb->traverse_read++;
- ret = tdb_traverse_internal(tdb, fn, private_data, &tl);
- tdb->traverse_read--;
-
- if (!in_transaction) {
- tdb_transaction_unlock(tdb);
- }
-
- return ret;
-}
-
-/*
- a write style traverse - needs to get the transaction lock to
- prevent deadlocks
-
- WARNING: The data buffer given to the callback fn does NOT meet the
- alignment restrictions malloc gives you.
-*/
-int tdb_traverse(struct tdb_context *tdb,
- tdb_traverse_func fn, void *private_data)
-{
- struct tdb_traverse_lock tl = { NULL, 0, 0, F_WRLCK };
- int ret;
- bool in_transaction = (tdb->transaction != NULL);
-
- if (tdb->read_only || tdb->traverse_read) {
- return tdb_traverse_read(tdb, fn, private_data);
- }
-
- if (!in_transaction) {
- if (tdb_transaction_lock(tdb, F_WRLCK)) {
- return -1;
- }
- }
-
- tdb->traverse_write++;
- ret = tdb_traverse_internal(tdb, fn, private_data, &tl);
- tdb->traverse_write--;
-
- if (!in_transaction) {
- tdb_transaction_unlock(tdb);
- }
-
- return ret;
-}
-
-
-/* find the first entry in the database and return its key */
-TDB_DATA tdb_firstkey(struct tdb_context *tdb)
-{
- TDB_DATA key;
- struct list_struct rec;
-
- /* release any old lock */
- if (tdb_unlock_record(tdb, tdb->travlocks.off) != 0)
- return tdb_null;
- tdb->travlocks.off = tdb->travlocks.hash = 0;
- tdb->travlocks.lock_rw = F_RDLCK;
-
- /* Grab first record: locks chain and returned record. */
- if (tdb_next_lock(tdb, &tdb->travlocks, &rec) <= 0)
- return tdb_null;
- /* now read the key */
- key.dsize = rec.key_len;
- key.dptr =tdb_alloc_read(tdb,tdb->travlocks.off+sizeof(rec),key.dsize);
-
- /* Unlock the hash chain of the record we just read. */
- if (tdb_unlock(tdb, tdb->travlocks.hash, tdb->travlocks.lock_rw) != 0)
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_firstkey: error occurred while tdb_unlocking!\n"));
- return key;
-}
-
-/* find the next entry in the database, returning its key */
-TDB_DATA tdb_nextkey(struct tdb_context *tdb, TDB_DATA oldkey)
-{
- uint32_t oldhash;
- TDB_DATA key = tdb_null;
- struct list_struct rec;
- unsigned char *k = NULL;
-
- /* Is locked key the old key? If so, traverse will be reliable. */
- if (tdb->travlocks.off) {
- if (tdb_lock(tdb,tdb->travlocks.hash,tdb->travlocks.lock_rw))
- return tdb_null;
- if (tdb_rec_read(tdb, tdb->travlocks.off, &rec) == -1
- || !(k = tdb_alloc_read(tdb,tdb->travlocks.off+sizeof(rec),
- rec.key_len))
- || memcmp(k, oldkey.dptr, oldkey.dsize) != 0) {
- /* No, it wasn't: unlock it and start from scratch */
- if (tdb_unlock_record(tdb, tdb->travlocks.off) != 0) {
- SAFE_FREE(k);
- return tdb_null;
- }
- if (tdb_unlock(tdb, tdb->travlocks.hash, tdb->travlocks.lock_rw) != 0) {
- SAFE_FREE(k);
- return tdb_null;
- }
- tdb->travlocks.off = 0;
- }
-
- SAFE_FREE(k);
- }
-
- if (!tdb->travlocks.off) {
- /* No previous element: do normal find, and lock record */
- tdb->travlocks.off = tdb_find_lock_hash(tdb, oldkey, tdb->hash_fn(&oldkey), tdb->travlocks.lock_rw, &rec);
- if (!tdb->travlocks.off)
- return tdb_null;
- tdb->travlocks.hash = BUCKET(rec.full_hash);
- if (tdb_lock_record(tdb, tdb->travlocks.off) != 0) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_nextkey: lock_record failed (%s)!\n", strerror(errno)));
- return tdb_null;
- }
- }
- oldhash = tdb->travlocks.hash;
-
- /* Grab next record: locks chain and returned record,
- unlocks old record */
- if (tdb_next_lock(tdb, &tdb->travlocks, &rec) > 0) {
- key.dsize = rec.key_len;
- key.dptr = tdb_alloc_read(tdb, tdb->travlocks.off+sizeof(rec),
- key.dsize);
- /* Unlock the chain of this new record */
- if (tdb_unlock(tdb, tdb->travlocks.hash, tdb->travlocks.lock_rw) != 0)
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_nextkey: WARNING tdb_unlock failed!\n"));
- }
- /* Unlock the chain of old record */
- if (tdb_unlock(tdb, BUCKET(oldhash), tdb->travlocks.lock_rw) != 0)
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_nextkey: WARNING tdb_unlock failed!\n"));
- return key;
-}
-
diff --git a/source4/lib/tdb/config.guess b/source4/lib/tdb/config.guess
deleted file mode 100755
index 354dbe175a..0000000000
--- a/source4/lib/tdb/config.guess
+++ /dev/null
@@ -1,1464 +0,0 @@
-#! /bin/sh
-# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2005-08-03'
-
-# This file is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Originally written by Per Bothner <per@bothner.com>.
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# This script attempts to guess a canonical system name similar to
-# config.sub. If it succeeds, it prints the system name on stdout, and
-# exits with 0. Otherwise, it exits with 1.
-#
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit build system type.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION]
-
-Output the configuration name of the system \`$me' is run on.
-
-Operation modes:
- -h, --help print this help, then exit
- -t, --time-stamp print date of last modification, then exit
- -v, --version print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.guess ($timestamp)
-
-Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
- case $1 in
- --time-stamp | --time* | -t )
- echo "$timestamp" ; exit ;;
- --version | -v )
- echo "$version" ; exit ;;
- --help | --h* | -h )
- echo "$usage"; exit ;;
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- echo "$me: invalid option $1$help" >&2
- exit 1 ;;
- * )
- break ;;
- esac
-done
-
-if test $# != 0; then
- echo "$me: too many arguments$help" >&2
- exit 1
-fi
-
-trap 'exit 1' 1 2 15
-
-# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
-# compiler to aid in system detection is discouraged as it requires
-# temporary files to be created and, as you can see below, it is a
-# headache to deal with in a portable fashion.
-
-# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
-# use `HOST_CC' if defined, but it is deprecated.
-
-# Portable tmp directory creation inspired by the Autoconf team.
-
-set_cc_for_build='
-trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
-trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
-: ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
-dummy=$tmp/dummy ;
-tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
-case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,) echo "int x;" > $dummy.c ;
- for c in cc gcc c89 c99 ; do
- if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
- CC_FOR_BUILD="$c"; break ;
- fi ;
- done ;
- if test x"$CC_FOR_BUILD" = x ; then
- CC_FOR_BUILD=no_compiler_found ;
- fi
- ;;
- ,,*) CC_FOR_BUILD=$CC ;;
- ,*,*) CC_FOR_BUILD=$HOST_CC ;;
-esac ; set_cc_for_build= ;'
-
-# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-# (ghazi@noc.rutgers.edu 1994-08-24)
-if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
- PATH=$PATH:/.attbin ; export PATH
-fi
-
-UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
-UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
-UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-
-# Note: order is significant - the case branches are not exclusive.
-
-case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
- *:NetBSD:*:*)
- # NetBSD (nbsd) targets should (where applicable) match one or
- # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
- # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
- # switched to ELF, *-*-netbsd* would select the old
- # object file format. This provides both forward
- # compatibility and a consistent mechanism for selecting the
- # object file format.
- #
- # Note: NetBSD doesn't particularly care about the vendor
- # portion of the name. We always set it to "unknown".
- sysctl="sysctl -n hw.machine_arch"
- UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
- /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
- case "${UNAME_MACHINE_ARCH}" in
- armeb) machine=armeb-unknown ;;
- arm*) machine=arm-unknown ;;
- sh3el) machine=shl-unknown ;;
- sh3eb) machine=sh-unknown ;;
- *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
- esac
- # The Operating System including object format, if it has switched
- # to ELF recently, or will in the future.
- case "${UNAME_MACHINE_ARCH}" in
- arm*|i386|m68k|ns32k|sh3*|sparc|vax)
- eval $set_cc_for_build
- if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
- | grep __ELF__ >/dev/null
- then
- # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
- # Return netbsd for either. FIX?
- os=netbsd
- else
- os=netbsdelf
- fi
- ;;
- *)
- os=netbsd
- ;;
- esac
- # The OS release
- # Debian GNU/NetBSD machines have a different userland, and
- # thus, need a distinct triplet. However, they do not need
- # kernel version information, so it can be replaced with a
- # suitable tag, in the style of linux-gnu.
- case "${UNAME_VERSION}" in
- Debian*)
- release='-gnu'
- ;;
- *)
- release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
- ;;
- esac
- # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
- # contains redundant information, the shorter form:
- # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
- echo "${machine}-${os}${release}"
- exit ;;
- *:OpenBSD:*:*)
- UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
- echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
- exit ;;
- *:ekkoBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
- exit ;;
- macppc:MirBSD:*:*)
- echo powerppc-unknown-mirbsd${UNAME_RELEASE}
- exit ;;
- *:MirBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
- exit ;;
- alpha:OSF1:*:*)
- case $UNAME_RELEASE in
- *4.0)
- UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
- ;;
- *5.*)
- UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
- ;;
- esac
- # According to Compaq, /usr/sbin/psrinfo has been available on
- # OSF/1 and Tru64 systems produced since 1995. I hope that
- # covers most systems running today. This code pipes the CPU
- # types through head -n 1, so we only detect the type of CPU 0.
- ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
- case "$ALPHA_CPU_TYPE" in
- "EV4 (21064)")
- UNAME_MACHINE="alpha" ;;
- "EV4.5 (21064)")
- UNAME_MACHINE="alpha" ;;
- "LCA4 (21066/21068)")
- UNAME_MACHINE="alpha" ;;
- "EV5 (21164)")
- UNAME_MACHINE="alphaev5" ;;
- "EV5.6 (21164A)")
- UNAME_MACHINE="alphaev56" ;;
- "EV5.6 (21164PC)")
- UNAME_MACHINE="alphapca56" ;;
- "EV5.7 (21164PC)")
- UNAME_MACHINE="alphapca57" ;;
- "EV6 (21264)")
- UNAME_MACHINE="alphaev6" ;;
- "EV6.7 (21264A)")
- UNAME_MACHINE="alphaev67" ;;
- "EV6.8CB (21264C)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.8AL (21264B)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.8CX (21264D)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.9A (21264/EV69A)")
- UNAME_MACHINE="alphaev69" ;;
- "EV7 (21364)")
- UNAME_MACHINE="alphaev7" ;;
- "EV7.9 (21364A)")
- UNAME_MACHINE="alphaev79" ;;
- esac
- # A Pn.n version is a patched version.
- # A Vn.n version is a released version.
- # A Tn.n version is a released field test version.
- # A Xn.n version is an unreleased experimental baselevel.
- # 1.2 uses "1.2" for uname -r.
- echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- exit ;;
- Alpha\ *:Windows_NT*:*)
- # How do we know it's Interix rather than the generic POSIX subsystem?
- # Should we change UNAME_MACHINE based on the output of uname instead
- # of the specific Alpha model?
- echo alpha-pc-interix
- exit ;;
- 21064:Windows_NT:50:3)
- echo alpha-dec-winnt3.5
- exit ;;
- Amiga*:UNIX_System_V:4.0:*)
- echo m68k-unknown-sysv4
- exit ;;
- *:[Aa]miga[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-amigaos
- exit ;;
- *:[Mm]orph[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-morphos
- exit ;;
- *:OS/390:*:*)
- echo i370-ibm-openedition
- exit ;;
- *:z/VM:*:*)
- echo s390-ibm-zvmoe
- exit ;;
- *:OS400:*:*)
- echo powerpc-ibm-os400
- exit ;;
- arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
- echo arm-acorn-riscix${UNAME_RELEASE}
- exit ;;
- arm:riscos:*:*|arm:RISCOS:*:*)
- echo arm-unknown-riscos
- exit ;;
- SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
- echo hppa1.1-hitachi-hiuxmpp
- exit ;;
- Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
- # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
- if test "`(/bin/universe) 2>/dev/null`" = att ; then
- echo pyramid-pyramid-sysv3
- else
- echo pyramid-pyramid-bsd
- fi
- exit ;;
- NILE*:*:*:dcosx)
- echo pyramid-pyramid-svr4
- exit ;;
- DRS?6000:unix:4.0:6*)
- echo sparc-icl-nx6
- exit ;;
- DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
- case `/usr/bin/uname -p` in
- sparc) echo sparc-icl-nx7; exit ;;
- esac ;;
- sun4H:SunOS:5.*:*)
- echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
- echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- i86pc:SunOS:5.*:*)
- echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:6*:*)
- # According to config.sub, this is the proper way to canonicalize
- # SunOS6. Hard to guess exactly what SunOS6 will be like, but
- # it's likely to be more like Solaris than SunOS4.
- echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:*:*)
- case "`/usr/bin/arch -k`" in
- Series*|S4*)
- UNAME_RELEASE=`uname -v`
- ;;
- esac
- # Japanese Language versions have a version number like `4.1.3-JL'.
- echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
- exit ;;
- sun3*:SunOS:*:*)
- echo m68k-sun-sunos${UNAME_RELEASE}
- exit ;;
- sun*:*:4.2BSD:*)
- UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
- test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
- case "`/bin/arch`" in
- sun3)
- echo m68k-sun-sunos${UNAME_RELEASE}
- ;;
- sun4)
- echo sparc-sun-sunos${UNAME_RELEASE}
- ;;
- esac
- exit ;;
- aushp:SunOS:*:*)
- echo sparc-auspex-sunos${UNAME_RELEASE}
- exit ;;
- # The situation for MiNT is a little confusing. The machine name
- # can be virtually everything (everything which is not
- # "atarist" or "atariste" at least should have a processor
- # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
- # to the lowercase version "mint" (or "freemint"). Finally
- # the system name "TOS" denotes a system which is actually not
- # MiNT. But MiNT is downward compatible to TOS, so this should
- # be no problem.
- atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
- echo m68k-milan-mint${UNAME_RELEASE}
- exit ;;
- hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
- echo m68k-hades-mint${UNAME_RELEASE}
- exit ;;
- *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
- echo m68k-unknown-mint${UNAME_RELEASE}
- exit ;;
- m68k:machten:*:*)
- echo m68k-apple-machten${UNAME_RELEASE}
- exit ;;
- powerpc:machten:*:*)
- echo powerpc-apple-machten${UNAME_RELEASE}
- exit ;;
- RISC*:Mach:*:*)
- echo mips-dec-mach_bsd4.3
- exit ;;
- RISC*:ULTRIX:*:*)
- echo mips-dec-ultrix${UNAME_RELEASE}
- exit ;;
- VAX*:ULTRIX*:*:*)
- echo vax-dec-ultrix${UNAME_RELEASE}
- exit ;;
- 2020:CLIX:*:* | 2430:CLIX:*:*)
- echo clipper-intergraph-clix${UNAME_RELEASE}
- exit ;;
- mips:*:*:UMIPS | mips:*:*:RISCos)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
-#ifdef __cplusplus
-#include <stdio.h> /* for printf() prototype */
- int main (int argc, char *argv[]) {
-#else
- int main (argc, argv) int argc; char *argv[]; {
-#endif
- #if defined (host_mips) && defined (MIPSEB)
- #if defined (SYSTYPE_SYSV)
- printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
- #endif
- #if defined (SYSTYPE_SVR4)
- printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
- #endif
- #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
- printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
- #endif
- #endif
- exit (-1);
- }
-EOF
- $CC_FOR_BUILD -o $dummy $dummy.c &&
- dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
- SYSTEM_NAME=`$dummy $dummyarg` &&
- { echo "$SYSTEM_NAME"; exit; }
- echo mips-mips-riscos${UNAME_RELEASE}
- exit ;;
- Motorola:PowerMAX_OS:*:*)
- echo powerpc-motorola-powermax
- exit ;;
- Motorola:*:4.3:PL8-*)
- echo powerpc-harris-powermax
- exit ;;
- Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
- echo powerpc-harris-powermax
- exit ;;
- Night_Hawk:Power_UNIX:*:*)
- echo powerpc-harris-powerunix
- exit ;;
- m88k:CX/UX:7*:*)
- echo m88k-harris-cxux7
- exit ;;
- m88k:*:4*:R4*)
- echo m88k-motorola-sysv4
- exit ;;
- m88k:*:3*:R3*)
- echo m88k-motorola-sysv3
- exit ;;
- AViiON:dgux:*:*)
- # DG/UX returns AViiON for all architectures
- UNAME_PROCESSOR=`/usr/bin/uname -p`
- if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
- then
- if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
- [ ${TARGET_BINARY_INTERFACE}x = x ]
- then
- echo m88k-dg-dgux${UNAME_RELEASE}
- else
- echo m88k-dg-dguxbcs${UNAME_RELEASE}
- fi
- else
- echo i586-dg-dgux${UNAME_RELEASE}
- fi
- exit ;;
- M88*:DolphinOS:*:*) # DolphinOS (SVR3)
- echo m88k-dolphin-sysv3
- exit ;;
- M88*:*:R3*:*)
- # Delta 88k system running SVR3
- echo m88k-motorola-sysv3
- exit ;;
- XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
- echo m88k-tektronix-sysv3
- exit ;;
- Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
- echo m68k-tektronix-bsd
- exit ;;
- *:IRIX*:*:*)
- echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
- exit ;;
- ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
- echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
- exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
- i*86:AIX:*:*)
- echo i386-ibm-aix
- exit ;;
- ia64:AIX:*:*)
- if [ -x /usr/bin/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
- else
- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
- fi
- echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
- exit ;;
- *:AIX:2:3)
- if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <sys/systemcfg.h>
-
- main()
- {
- if (!__power_pc())
- exit(1);
- puts("powerpc-ibm-aix3.2.5");
- exit(0);
- }
-EOF
- if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
- then
- echo "$SYSTEM_NAME"
- else
- echo rs6000-ibm-aix3.2.5
- fi
- elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
- echo rs6000-ibm-aix3.2.4
- else
- echo rs6000-ibm-aix3.2
- fi
- exit ;;
- *:AIX:*:[45])
- IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
- if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
- IBM_ARCH=rs6000
- else
- IBM_ARCH=powerpc
- fi
- if [ -x /usr/bin/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
- else
- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
- fi
- echo ${IBM_ARCH}-ibm-aix${IBM_REV}
- exit ;;
- *:AIX:*:*)
- echo rs6000-ibm-aix
- exit ;;
- ibmrt:4.4BSD:*|romp-ibm:BSD:*)
- echo romp-ibm-bsd4.4
- exit ;;
- ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
- echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
- exit ;; # report: romp-ibm BSD 4.3
- *:BOSX:*:*)
- echo rs6000-bull-bosx
- exit ;;
- DPX/2?00:B.O.S.:*:*)
- echo m68k-bull-sysv3
- exit ;;
- 9000/[34]??:4.3bsd:1.*:*)
- echo m68k-hp-bsd
- exit ;;
- hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
- echo m68k-hp-bsd4.4
- exit ;;
- 9000/[34678]??:HP-UX:*:*)
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- case "${UNAME_MACHINE}" in
- 9000/31? ) HP_ARCH=m68000 ;;
- 9000/[34]?? ) HP_ARCH=m68k ;;
- 9000/[678][0-9][0-9])
- if [ -x /usr/bin/getconf ]; then
- sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
- sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
- case "${sc_cpu_version}" in
- 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
- 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
- 532) # CPU_PA_RISC2_0
- case "${sc_kernel_bits}" in
- 32) HP_ARCH="hppa2.0n" ;;
- 64) HP_ARCH="hppa2.0w" ;;
- '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
- esac ;;
- esac
- fi
- if [ "${HP_ARCH}" = "" ]; then
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
-
- #define _HPUX_SOURCE
- #include <stdlib.h>
- #include <unistd.h>
-
- int main ()
- {
- #if defined(_SC_KERNEL_BITS)
- long bits = sysconf(_SC_KERNEL_BITS);
- #endif
- long cpu = sysconf (_SC_CPU_VERSION);
-
- switch (cpu)
- {
- case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
- case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
- case CPU_PA_RISC2_0:
- #if defined(_SC_KERNEL_BITS)
- switch (bits)
- {
- case 64: puts ("hppa2.0w"); break;
- case 32: puts ("hppa2.0n"); break;
- default: puts ("hppa2.0"); break;
- } break;
- #else /* !defined(_SC_KERNEL_BITS) */
- puts ("hppa2.0"); break;
- #endif
- default: puts ("hppa1.0"); break;
- }
- exit (0);
- }
-EOF
- (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
- test -z "$HP_ARCH" && HP_ARCH=hppa
- fi ;;
- esac
- if [ ${HP_ARCH} = "hppa2.0w" ]
- then
- eval $set_cc_for_build
-
- # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
- # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
- # generating 64-bit code. GNU and HP use different nomenclature:
- #
- # $ CC_FOR_BUILD=cc ./config.guess
- # => hppa2.0w-hp-hpux11.23
- # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
- # => hppa64-hp-hpux11.23
-
- if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
- grep __LP64__ >/dev/null
- then
- HP_ARCH="hppa2.0w"
- else
- HP_ARCH="hppa64"
- fi
- fi
- echo ${HP_ARCH}-hp-hpux${HPUX_REV}
- exit ;;
- ia64:HP-UX:*:*)
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- echo ia64-hp-hpux${HPUX_REV}
- exit ;;
- 3050*:HI-UX:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <unistd.h>
- int
- main ()
- {
- long cpu = sysconf (_SC_CPU_VERSION);
- /* The order matters, because CPU_IS_HP_MC68K erroneously returns
- true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
- results, however. */
- if (CPU_IS_PA_RISC (cpu))
- {
- switch (cpu)
- {
- case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
- case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
- case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
- default: puts ("hppa-hitachi-hiuxwe2"); break;
- }
- }
- else if (CPU_IS_HP_MC68K (cpu))
- puts ("m68k-hitachi-hiuxwe2");
- else puts ("unknown-hitachi-hiuxwe2");
- exit (0);
- }
-EOF
- $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
- { echo "$SYSTEM_NAME"; exit; }
- echo unknown-hitachi-hiuxwe2
- exit ;;
- 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
- echo hppa1.1-hp-bsd
- exit ;;
- 9000/8??:4.3bsd:*:*)
- echo hppa1.0-hp-bsd
- exit ;;
- *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
- echo hppa1.0-hp-mpeix
- exit ;;
- hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
- echo hppa1.1-hp-osf
- exit ;;
- hp8??:OSF1:*:*)
- echo hppa1.0-hp-osf
- exit ;;
- i*86:OSF1:*:*)
- if [ -x /usr/sbin/sysversion ] ; then
- echo ${UNAME_MACHINE}-unknown-osf1mk
- else
- echo ${UNAME_MACHINE}-unknown-osf1
- fi
- exit ;;
- parisc*:Lites*:*:*)
- echo hppa1.1-hp-lites
- exit ;;
- C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
- echo c1-convex-bsd
- exit ;;
- C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit ;;
- C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
- echo c34-convex-bsd
- exit ;;
- C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
- echo c38-convex-bsd
- exit ;;
- C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
- echo c4-convex-bsd
- exit ;;
- CRAY*Y-MP:*:*:*)
- echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*[A-Z]90:*:*:*)
- echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
- | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
- -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
- -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*TS:*:*:*)
- echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*T3E:*:*:*)
- echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*SV1:*:*:*)
- echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- *:UNICOS/mp:*:*)
- echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
- FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
- echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
- 5000:UNIX_System_V:4.*:*)
- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
- echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
- i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
- echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
- exit ;;
- sparc*:BSD/OS:*:*)
- echo sparc-unknown-bsdi${UNAME_RELEASE}
- exit ;;
- *:BSD/OS:*:*)
- echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
- exit ;;
- *:FreeBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit ;;
- i*:CYGWIN*:*)
- echo ${UNAME_MACHINE}-pc-cygwin
- exit ;;
- i*:MINGW*:*)
- echo ${UNAME_MACHINE}-pc-mingw32
- exit ;;
- i*:windows32*:*)
- # uname -m includes "-pc" on this system.
- echo ${UNAME_MACHINE}-mingw32
- exit ;;
- i*:PW*:*)
- echo ${UNAME_MACHINE}-pc-pw32
- exit ;;
- x86:Interix*:[34]*)
- echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
- exit ;;
- [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
- echo i${UNAME_MACHINE}-pc-mks
- exit ;;
- i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
- # How do we know it's Interix rather than the generic POSIX subsystem?
- # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
- # UNAME_MACHINE based on the output of uname instead of i386?
- echo i586-pc-interix
- exit ;;
- i*:UWIN*:*)
- echo ${UNAME_MACHINE}-pc-uwin
- exit ;;
- amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
- echo x86_64-unknown-cygwin
- exit ;;
- p*:CYGWIN*:*)
- echo powerpcle-unknown-cygwin
- exit ;;
- prep*:SunOS:5.*:*)
- echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- *:GNU:*:*)
- # the GNU system
- echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
- exit ;;
- *:GNU/*:*:*)
- # other systems with GNU libc and userland
- echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
- exit ;;
- i*86:Minix:*:*)
- echo ${UNAME_MACHINE}-pc-minix
- exit ;;
- arm*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- cris:Linux:*:*)
- echo cris-axis-linux-gnu
- exit ;;
- crisv32:Linux:*:*)
- echo crisv32-axis-linux-gnu
- exit ;;
- frv:Linux:*:*)
- echo frv-unknown-linux-gnu
- exit ;;
- ia64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- m32r*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- m68*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- mips:Linux:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #undef CPU
- #undef mips
- #undef mipsel
- #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mipsel
- #else
- #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips
- #else
- CPU=
- #endif
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
- ;;
- mips64:Linux:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #undef CPU
- #undef mips64
- #undef mips64el
- #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mips64el
- #else
- #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips64
- #else
- CPU=
- #endif
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
- ;;
- or32:Linux:*:*)
- echo or32-unknown-linux-gnu
- exit ;;
- ppc:Linux:*:*)
- echo powerpc-unknown-linux-gnu
- exit ;;
- ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-gnu
- exit ;;
- alpha:Linux:*:*)
- case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
- EV5) UNAME_MACHINE=alphaev5 ;;
- EV56) UNAME_MACHINE=alphaev56 ;;
- PCA56) UNAME_MACHINE=alphapca56 ;;
- PCA57) UNAME_MACHINE=alphapca56 ;;
- EV6) UNAME_MACHINE=alphaev6 ;;
- EV67) UNAME_MACHINE=alphaev67 ;;
- EV68*) UNAME_MACHINE=alphaev68 ;;
- esac
- objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
- if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
- exit ;;
- parisc:Linux:*:* | hppa:Linux:*:*)
- # Look for CPU level
- case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
- PA7*) echo hppa1.1-unknown-linux-gnu ;;
- PA8*) echo hppa2.0-unknown-linux-gnu ;;
- *) echo hppa-unknown-linux-gnu ;;
- esac
- exit ;;
- parisc64:Linux:*:* | hppa64:Linux:*:*)
- echo hppa64-unknown-linux-gnu
- exit ;;
- s390:Linux:*:* | s390x:Linux:*:*)
- echo ${UNAME_MACHINE}-ibm-linux
- exit ;;
- sh64*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- sh*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- sparc:Linux:*:* | sparc64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- x86_64:Linux:*:*)
- echo x86_64-unknown-linux-gnu
- exit ;;
- i*86:Linux:*:*)
- # The BFD linker knows what the default object file format is, so
- # first see if it will tell us. cd to the root directory to prevent
- # problems with other programs or directories called `ld' in the path.
- # Set LC_ALL=C to ensure ld outputs messages in English.
- ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
- | sed -ne '/supported targets:/!d
- s/[ ][ ]*/ /g
- s/.*supported targets: *//
- s/ .*//
- p'`
- case "$ld_supported_targets" in
- elf32-i386)
- TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
- ;;
- a.out-i386-linux)
- echo "${UNAME_MACHINE}-pc-linux-gnuaout"
- exit ;;
- coff-i386)
- echo "${UNAME_MACHINE}-pc-linux-gnucoff"
- exit ;;
- "")
- # Either a pre-BFD a.out linker (linux-gnuoldld) or
- # one that does not give us useful --help.
- echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
- exit ;;
- esac
- # Determine whether the default compiler is a.out or elf
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <features.h>
- #ifdef __ELF__
- # ifdef __GLIBC__
- # if __GLIBC__ >= 2
- LIBC=gnu
- # else
- LIBC=gnulibc1
- # endif
- # else
- LIBC=gnulibc1
- # endif
- #else
- #ifdef __INTEL_COMPILER
- LIBC=gnu
- #else
- LIBC=gnuaout
- #endif
- #endif
- #ifdef __dietlibc__
- LIBC=dietlibc
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
- test x"${LIBC}" != x && {
- echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
- exit
- }
- test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
- ;;
- i*86:DYNIX/ptx:4*:*)
- # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
- # earlier versions are messed up and put the nodename in both
- # sysname and nodename.
- echo i386-sequent-sysv4
- exit ;;
- i*86:UNIX_SV:4.2MP:2.*)
- # Unixware is an offshoot of SVR4, but it has its own version
- # number series starting with 2...
- # I am not positive that other SVR4 systems won't match this,
- # I just have to hope. -- rms.
- # Use sysv4.2uw... so that sysv4* matches it.
- echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
- exit ;;
- i*86:OS/2:*:*)
- # If we were able to find `uname', then EMX Unix compatibility
- # is probably installed.
- echo ${UNAME_MACHINE}-pc-os2-emx
- exit ;;
- i*86:XTS-300:*:STOP)
- echo ${UNAME_MACHINE}-unknown-stop
- exit ;;
- i*86:atheos:*:*)
- echo ${UNAME_MACHINE}-unknown-atheos
- exit ;;
- i*86:syllable:*:*)
- echo ${UNAME_MACHINE}-pc-syllable
- exit ;;
- i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
- echo i386-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- i*86:*DOS:*:*)
- echo ${UNAME_MACHINE}-pc-msdosdjgpp
- exit ;;
- i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
- UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
- if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
- echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
- else
- echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
- fi
- exit ;;
- i*86:*:5:[678]*)
- # UnixWare 7.x, OpenUNIX and OpenServer 6.
- case `/bin/uname -X | grep "^Machine"` in
- *486*) UNAME_MACHINE=i486 ;;
- *Pentium) UNAME_MACHINE=i586 ;;
- *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
- esac
- echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
- exit ;;
- i*86:*:3.2:*)
- if test -f /usr/options/cb.name; then
- UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
- echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
- elif /bin/uname -X 2>/dev/null >/dev/null ; then
- UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
- (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
- (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
- && UNAME_MACHINE=i586
- (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
- && UNAME_MACHINE=i686
- (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
- && UNAME_MACHINE=i686
- echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
- else
- echo ${UNAME_MACHINE}-pc-sysv32
- fi
- exit ;;
- pc:*:*:*)
- # Left here for compatibility:
- # uname -m prints for DJGPP always 'pc', but it prints nothing about
- # the processor, so we play safe by assuming i386.
- echo i386-pc-msdosdjgpp
- exit ;;
- Intel:Mach:3*:*)
- echo i386-pc-mach3
- exit ;;
- paragon:*:*:*)
- echo i860-intel-osf1
- exit ;;
- i860:*:4.*:*) # i860-SVR4
- if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
- echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
- else # Add other i860-SVR4 vendors below as they are discovered.
- echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
- fi
- exit ;;
- mini*:CTIX:SYS*5:*)
- # "miniframe"
- echo m68010-convergent-sysv
- exit ;;
- mc68k:UNIX:SYSTEM5:3.51m)
- echo m68k-convergent-sysv
- exit ;;
- M680?0:D-NIX:5.3:*)
- echo m68k-diab-dnix
- exit ;;
- M68*:*:R3V[5678]*:*)
- test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
- 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
- OS_REL=''
- test -r /etc/.relid \
- && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
- /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
- /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
- && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
- 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
- /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && { echo i486-ncr-sysv4; exit; } ;;
- m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
- echo m68k-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- mc68030:UNIX_System_V:4.*:*)
- echo m68k-atari-sysv4
- exit ;;
- TSUNAMI:LynxOS:2.*:*)
- echo sparc-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- rs6000:LynxOS:2.*:*)
- echo rs6000-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
- echo powerpc-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- SM[BE]S:UNIX_SV:*:*)
- echo mips-dde-sysv${UNAME_RELEASE}
- exit ;;
- RM*:ReliantUNIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
- RM*:SINIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
- *:SINIX-*:*:*)
- if uname -p 2>/dev/null >/dev/null ; then
- UNAME_MACHINE=`(uname -p) 2>/dev/null`
- echo ${UNAME_MACHINE}-sni-sysv4
- else
- echo ns32k-sni-sysv
- fi
- exit ;;
- PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
- # says <Richard.M.Bartel@ccMail.Census.GOV>
- echo i586-unisys-sysv4
- exit ;;
- *:UNIX_System_V:4*:FTX*)
- # From Gerald Hewes <hewes@openmarket.com>.
- # How about differentiating between stratus architectures? -djm
- echo hppa1.1-stratus-sysv4
- exit ;;
- *:*:*:FTX*)
- # From seanf@swdc.stratus.com.
- echo i860-stratus-sysv4
- exit ;;
- i*86:VOS:*:*)
- # From Paul.Green@stratus.com.
- echo ${UNAME_MACHINE}-stratus-vos
- exit ;;
- *:VOS:*:*)
- # From Paul.Green@stratus.com.
- echo hppa1.1-stratus-vos
- exit ;;
- mc68*:A/UX:*:*)
- echo m68k-apple-aux${UNAME_RELEASE}
- exit ;;
- news*:NEWS-OS:6*:*)
- echo mips-sony-newsos6
- exit ;;
- R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
- if [ -d /usr/nec ]; then
- echo mips-nec-sysv${UNAME_RELEASE}
- else
- echo mips-unknown-sysv${UNAME_RELEASE}
- fi
- exit ;;
- BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
- echo powerpc-be-beos
- exit ;;
- BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
- echo powerpc-apple-beos
- exit ;;
- BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
- echo i586-pc-beos
- exit ;;
- SX-4:SUPER-UX:*:*)
- echo sx4-nec-superux${UNAME_RELEASE}
- exit ;;
- SX-5:SUPER-UX:*:*)
- echo sx5-nec-superux${UNAME_RELEASE}
- exit ;;
- SX-6:SUPER-UX:*:*)
- echo sx6-nec-superux${UNAME_RELEASE}
- exit ;;
- Power*:Rhapsody:*:*)
- echo powerpc-apple-rhapsody${UNAME_RELEASE}
- exit ;;
- *:Rhapsody:*:*)
- echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
- exit ;;
- *:Darwin:*:*)
- UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
- case $UNAME_PROCESSOR in
- *86) UNAME_PROCESSOR=i686 ;;
- unknown) UNAME_PROCESSOR=powerpc ;;
- esac
- echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
- exit ;;
- *:procnto*:*:* | *:QNX:[0123456789]*:*)
- UNAME_PROCESSOR=`uname -p`
- if test "$UNAME_PROCESSOR" = "x86"; then
- UNAME_PROCESSOR=i386
- UNAME_MACHINE=pc
- fi
- echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
- exit ;;
- *:QNX:*:4*)
- echo i386-pc-qnx
- exit ;;
- NSE-?:NONSTOP_KERNEL:*:*)
- echo nse-tandem-nsk${UNAME_RELEASE}
- exit ;;
- NSR-?:NONSTOP_KERNEL:*:*)
- echo nsr-tandem-nsk${UNAME_RELEASE}
- exit ;;
- *:NonStop-UX:*:*)
- echo mips-compaq-nonstopux
- exit ;;
- BS2000:POSIX*:*:*)
- echo bs2000-siemens-sysv
- exit ;;
- DS/*:UNIX_System_V:*:*)
- echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
- exit ;;
- *:Plan9:*:*)
- # "uname -m" is not consistent, so use $cputype instead. 386
- # is converted to i386 for consistency with other x86
- # operating systems.
- if test "$cputype" = "386"; then
- UNAME_MACHINE=i386
- else
- UNAME_MACHINE="$cputype"
- fi
- echo ${UNAME_MACHINE}-unknown-plan9
- exit ;;
- *:TOPS-10:*:*)
- echo pdp10-unknown-tops10
- exit ;;
- *:TENEX:*:*)
- echo pdp10-unknown-tenex
- exit ;;
- KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
- echo pdp10-dec-tops20
- exit ;;
- XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
- echo pdp10-xkl-tops20
- exit ;;
- *:TOPS-20:*:*)
- echo pdp10-unknown-tops20
- exit ;;
- *:ITS:*:*)
- echo pdp10-unknown-its
- exit ;;
- SEI:*:*:SEIUX)
- echo mips-sei-seiux${UNAME_RELEASE}
- exit ;;
- *:DragonFly:*:*)
- echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit ;;
- *:*VMS:*:*)
- UNAME_MACHINE=`(uname -p) 2>/dev/null`
- case "${UNAME_MACHINE}" in
- A*) echo alpha-dec-vms ; exit ;;
- I*) echo ia64-dec-vms ; exit ;;
- V*) echo vax-dec-vms ; exit ;;
- esac ;;
- *:XENIX:*:SysV)
- echo i386-pc-xenix
- exit ;;
- i*86:skyos:*:*)
- echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
- exit ;;
-esac
-
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
- /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
- I don't know.... */
- printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
- printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
- "4"
-#else
- ""
-#endif
- ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
- printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
- printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
- int version;
- version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
- if (version < 4)
- printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
- else
- printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
- exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
- printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
- printf ("ns32k-encore-mach\n"); exit (0);
-#else
- printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
- printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
- printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
- printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
- struct utsname un;
-
- uname(&un);
-
- if (strncmp(un.version, "V2", 2) == 0) {
- printf ("i386-sequent-ptx2\n"); exit (0);
- }
- if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
- printf ("i386-sequent-ptx1\n"); exit (0);
- }
- printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-# include <sys/param.h>
-# if defined (BSD)
-# if BSD == 43
- printf ("vax-dec-bsd4.3\n"); exit (0);
-# else
-# if BSD == 199006
- printf ("vax-dec-bsd4.3reno\n"); exit (0);
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# endif
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# else
- printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
- printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
- exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
- { echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
- case `getsysinfo -f cpu_type` in
- c1*)
- echo c1-convex-bsd
- exit ;;
- c2*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit ;;
- c34*)
- echo c34-convex-bsd
- exit ;;
- c38*)
- echo c38-convex-bsd
- exit ;;
- c4*)
- echo c4-convex-bsd
- exit ;;
- esac
-fi
-
-cat >&2 <<EOF
-$0: unable to guess system type
-
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
-
- http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
-and
- http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
-
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
-
-config.guess timestamp = $timestamp
-
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
-/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
-
-hostinfo = `(hostinfo) 2>/dev/null`
-/bin/universe = `(/bin/universe) 2>/dev/null`
-/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
-/bin/arch = `(/bin/arch) 2>/dev/null`
-/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
-
-UNAME_MACHINE = ${UNAME_MACHINE}
-UNAME_RELEASE = ${UNAME_RELEASE}
-UNAME_SYSTEM = ${UNAME_SYSTEM}
-UNAME_VERSION = ${UNAME_VERSION}
-EOF
-
-exit 1
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/source4/lib/tdb/config.mk b/source4/lib/tdb/config.mk
deleted file mode 100644
index b9a8f80dda..0000000000
--- a/source4/lib/tdb/config.mk
+++ /dev/null
@@ -1,57 +0,0 @@
-################################################
-# Start SUBSYSTEM LIBTDB
-[LIBRARY::LIBTDB]
-OUTPUT_TYPE = STATIC_LIBRARY
-CFLAGS = -Ilib/tdb/include
-#
-# End SUBSYSTEM ldb
-################################################
-
-LIBTDB_OBJ_FILES = $(addprefix lib/tdb/common/, \
- tdb.o dump.o io.o lock.o \
- open.o traverse.o freelist.o \
- error.o transaction.o)
-
-################################################
-# Start BINARY tdbtool
-[BINARY::tdbtool]
-INSTALLDIR = BINDIR
-PRIVATE_DEPENDENCIES = \
- LIBTDB
-# End BINARY tdbtool
-################################################
-
-tdbtool_OBJ_FILES = lib/tdb/tools/tdbtool.o
-
-################################################
-# Start BINARY tdbtorture
-[BINARY::tdbtorture]
-INSTALLDIR = BINDIR
-PRIVATE_DEPENDENCIES = \
- LIBTDB
-# End BINARY tdbtorture
-################################################
-
-tdbtorture_OBJ_FILES = lib/tdb/tools/tdbtorture.o
-
-################################################
-# Start BINARY tdbdump
-[BINARY::tdbdump]
-INSTALLDIR = BINDIR
-PRIVATE_DEPENDENCIES = \
- LIBTDB
-# End BINARY tdbdump
-################################################
-
-tdbdump_OBJ_FILES = lib/tdb/tools/tdbdump.o
-
-################################################
-# Start BINARY tdbbackup
-[BINARY::tdbbackup]
-INSTALLDIR = BINDIR
-PRIVATE_DEPENDENCIES = \
- LIBTDB
-# End BINARY tdbbackup
-################################################
-
-tdbbackup_OBJ_FILES = lib/tdb/tools/tdbbackup.o
diff --git a/source4/lib/tdb/config.sub b/source4/lib/tdb/config.sub
deleted file mode 100755
index 23cd6fd75c..0000000000
--- a/source4/lib/tdb/config.sub
+++ /dev/null
@@ -1,1577 +0,0 @@
-#! /bin/sh
-# Configuration validation subroutine script.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2005-07-08'
-
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine. It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# Configuration subroutine to validate and canonicalize a configuration type.
-# Supply the specified configuration type as an argument.
-# If it is invalid, we print an error message on stderr and exit with code 1.
-# Otherwise, we print the canonical config type on stdout and succeed.
-
-# This file is supposed to be the same for all GNU packages
-# and recognize all the CPU types, system types and aliases
-# that are meaningful with *any* GNU software.
-# Each package is responsible for reporting which valid configurations
-# it does not support. The user should be able to distinguish
-# a failure to support a valid configuration from a meaningless
-# configuration.
-
-# The goal of this file is to map all the various variations of a given
-# machine specification into a single specification in the form:
-# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-# or in some cases, the newer four-part form:
-# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-# It is wrong to echo any other type of specification.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION] CPU-MFR-OPSYS
- $0 [OPTION] ALIAS
-
-Canonicalize a configuration name.
-
-Operation modes:
- -h, --help print this help, then exit
- -t, --time-stamp print date of last modification, then exit
- -v, --version print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.sub ($timestamp)
-
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
- case $1 in
- --time-stamp | --time* | -t )
- echo "$timestamp" ; exit ;;
- --version | -v )
- echo "$version" ; exit ;;
- --help | --h* | -h )
- echo "$usage"; exit ;;
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- echo "$me: invalid option $1$help"
- exit 1 ;;
-
- *local*)
- # First pass through any local machine types.
- echo $1
- exit ;;
-
- * )
- break ;;
- esac
-done
-
-case $# in
- 0) echo "$me: missing argument$help" >&2
- exit 1;;
- 1) ;;
- *) echo "$me: too many arguments$help" >&2
- exit 1;;
-esac
-
-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-case $maybe_os in
- nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
- kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
- os=-$maybe_os
- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
- ;;
- *)
- basic_machine=`echo $1 | sed 's/-[^-]*$//'`
- if [ $basic_machine != $1 ]
- then os=`echo $1 | sed 's/.*-/-/'`
- else os=; fi
- ;;
-esac
-
-### Let's recognize common machines as not being operating systems so
-### that things like config.sub decstation-3100 work. We also
-### recognize some manufacturers as not being operating systems, so we
-### can provide default operating systems below.
-case $os in
- -sun*os*)
- # Prevent following clause from handling this invalid input.
- ;;
- -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
- -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
- -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
- -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
- -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
- -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
- -apple | -axis | -knuth | -cray)
- os=
- basic_machine=$1
- ;;
- -sim | -cisco | -oki | -wec | -winbond)
- os=
- basic_machine=$1
- ;;
- -scout)
- ;;
- -wrs)
- os=-vxworks
- basic_machine=$1
- ;;
- -chorusos*)
- os=-chorusos
- basic_machine=$1
- ;;
- -chorusrdb)
- os=-chorusrdb
- basic_machine=$1
- ;;
- -hiux*)
- os=-hiuxwe2
- ;;
- -sco5)
- os=-sco3.2v5
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco4)
- os=-sco3.2v4
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2.[4-9]*)
- os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2v[4-9]*)
- # Don't forget version if it is 3.2v4 or newer.
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco*)
- os=-sco3.2v2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -udk*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -isc)
- os=-isc2.2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -clix*)
- basic_machine=clipper-intergraph
- ;;
- -isc*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -lynx*)
- os=-lynxos
- ;;
- -ptx*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
- ;;
- -windowsnt*)
- os=`echo $os | sed -e 's/windowsnt/winnt/'`
- ;;
- -psos*)
- os=-psos
- ;;
- -mint | -mint[0-9]*)
- basic_machine=m68k-atari
- os=-mint
- ;;
-esac
-
-# Decode aliases for certain CPU-COMPANY combinations.
-case $basic_machine in
- # Recognize the basic CPU types without company name.
- # Some are omitted here because they have special meanings below.
- 1750a | 580 \
- | a29k \
- | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
- | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
- | am33_2.0 \
- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
- | bfin \
- | c4x | clipper \
- | d10v | d30v | dlx | dsp16xx \
- | fr30 | frv \
- | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
- | i370 | i860 | i960 | ia64 \
- | ip2k | iq2000 \
- | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
- | mips | mipsbe | mipseb | mipsel | mipsle \
- | mips16 \
- | mips64 | mips64el \
- | mips64vr | mips64vrel \
- | mips64orion | mips64orionel \
- | mips64vr4100 | mips64vr4100el \
- | mips64vr4300 | mips64vr4300el \
- | mips64vr5000 | mips64vr5000el \
- | mips64vr5900 | mips64vr5900el \
- | mipsisa32 | mipsisa32el \
- | mipsisa32r2 | mipsisa32r2el \
- | mipsisa64 | mipsisa64el \
- | mipsisa64r2 | mipsisa64r2el \
- | mipsisa64sb1 | mipsisa64sb1el \
- | mipsisa64sr71k | mipsisa64sr71kel \
- | mipstx39 | mipstx39el \
- | mn10200 | mn10300 \
- | ms1 \
- | msp430 \
- | ns16k | ns32k \
- | or32 \
- | pdp10 | pdp11 | pj | pjl \
- | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
- | pyramid \
- | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
- | sh64 | sh64le \
- | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
- | sparcv8 | sparcv9 | sparcv9b \
- | strongarm \
- | tahoe | thumb | tic4x | tic80 | tron \
- | v850 | v850e \
- | we32k \
- | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
- | z8k)
- basic_machine=$basic_machine-unknown
- ;;
- m32c)
- basic_machine=$basic_machine-unknown
- ;;
- m6811 | m68hc11 | m6812 | m68hc12)
- # Motorola 68HC11/12.
- basic_machine=$basic_machine-unknown
- os=-none
- ;;
- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
- ;;
-
- # We use `pc' rather than `unknown'
- # because (1) that's what they normally are, and
- # (2) the word "unknown" tends to confuse beginning users.
- i*86 | x86_64)
- basic_machine=$basic_machine-pc
- ;;
- # Object if more than one company name word.
- *-*-*)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
- # Recognize the basic CPU types with company name.
- 580-* \
- | a29k-* \
- | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
- | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
- | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
- | avr-* \
- | bfin-* | bs2000-* \
- | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
- | clipper-* | craynv-* | cydra-* \
- | d10v-* | d30v-* | dlx-* \
- | elxsi-* \
- | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
- | h8300-* | h8500-* \
- | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
- | i*86-* | i860-* | i960-* | ia64-* \
- | ip2k-* | iq2000-* \
- | m32r-* | m32rle-* \
- | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
- | m88110-* | m88k-* | maxq-* | mcore-* \
- | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
- | mips16-* \
- | mips64-* | mips64el-* \
- | mips64vr-* | mips64vrel-* \
- | mips64orion-* | mips64orionel-* \
- | mips64vr4100-* | mips64vr4100el-* \
- | mips64vr4300-* | mips64vr4300el-* \
- | mips64vr5000-* | mips64vr5000el-* \
- | mips64vr5900-* | mips64vr5900el-* \
- | mipsisa32-* | mipsisa32el-* \
- | mipsisa32r2-* | mipsisa32r2el-* \
- | mipsisa64-* | mipsisa64el-* \
- | mipsisa64r2-* | mipsisa64r2el-* \
- | mipsisa64sb1-* | mipsisa64sb1el-* \
- | mipsisa64sr71k-* | mipsisa64sr71kel-* \
- | mipstx39-* | mipstx39el-* \
- | mmix-* \
- | ms1-* \
- | msp430-* \
- | none-* | np1-* | ns16k-* | ns32k-* \
- | orion-* \
- | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
- | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
- | pyramid-* \
- | romp-* | rs6000-* \
- | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
- | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
- | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
- | sparclite-* \
- | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
- | tahoe-* | thumb-* \
- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
- | tron-* \
- | v850-* | v850e-* | vax-* \
- | we32k-* \
- | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
- | xstormy16-* | xtensa-* \
- | ymp-* \
- | z8k-*)
- ;;
- m32c-*)
- ;;
- # Recognize the various machine names and aliases which stand
- # for a CPU type and a company and sometimes even an OS.
- 386bsd)
- basic_machine=i386-unknown
- os=-bsd
- ;;
- 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
- basic_machine=m68000-att
- ;;
- 3b*)
- basic_machine=we32k-att
- ;;
- a29khif)
- basic_machine=a29k-amd
- os=-udi
- ;;
- abacus)
- basic_machine=abacus-unknown
- ;;
- adobe68k)
- basic_machine=m68010-adobe
- os=-scout
- ;;
- alliant | fx80)
- basic_machine=fx80-alliant
- ;;
- altos | altos3068)
- basic_machine=m68k-altos
- ;;
- am29k)
- basic_machine=a29k-none
- os=-bsd
- ;;
- amd64)
- basic_machine=x86_64-pc
- ;;
- amd64-*)
- basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- amdahl)
- basic_machine=580-amdahl
- os=-sysv
- ;;
- amiga | amiga-*)
- basic_machine=m68k-unknown
- ;;
- amigaos | amigados)
- basic_machine=m68k-unknown
- os=-amigaos
- ;;
- amigaunix | amix)
- basic_machine=m68k-unknown
- os=-sysv4
- ;;
- apollo68)
- basic_machine=m68k-apollo
- os=-sysv
- ;;
- apollo68bsd)
- basic_machine=m68k-apollo
- os=-bsd
- ;;
- aux)
- basic_machine=m68k-apple
- os=-aux
- ;;
- balance)
- basic_machine=ns32k-sequent
- os=-dynix
- ;;
- c90)
- basic_machine=c90-cray
- os=-unicos
- ;;
- convex-c1)
- basic_machine=c1-convex
- os=-bsd
- ;;
- convex-c2)
- basic_machine=c2-convex
- os=-bsd
- ;;
- convex-c32)
- basic_machine=c32-convex
- os=-bsd
- ;;
- convex-c34)
- basic_machine=c34-convex
- os=-bsd
- ;;
- convex-c38)
- basic_machine=c38-convex
- os=-bsd
- ;;
- cray | j90)
- basic_machine=j90-cray
- os=-unicos
- ;;
- craynv)
- basic_machine=craynv-cray
- os=-unicosmp
- ;;
- cr16c)
- basic_machine=cr16c-unknown
- os=-elf
- ;;
- crds | unos)
- basic_machine=m68k-crds
- ;;
- crisv32 | crisv32-* | etraxfs*)
- basic_machine=crisv32-axis
- ;;
- cris | cris-* | etrax*)
- basic_machine=cris-axis
- ;;
- crx)
- basic_machine=crx-unknown
- os=-elf
- ;;
- da30 | da30-*)
- basic_machine=m68k-da30
- ;;
- decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
- basic_machine=mips-dec
- ;;
- decsystem10* | dec10*)
- basic_machine=pdp10-dec
- os=-tops10
- ;;
- decsystem20* | dec20*)
- basic_machine=pdp10-dec
- os=-tops20
- ;;
- delta | 3300 | motorola-3300 | motorola-delta \
- | 3300-motorola | delta-motorola)
- basic_machine=m68k-motorola
- ;;
- delta88)
- basic_machine=m88k-motorola
- os=-sysv3
- ;;
- djgpp)
- basic_machine=i586-pc
- os=-msdosdjgpp
- ;;
- dpx20 | dpx20-*)
- basic_machine=rs6000-bull
- os=-bosx
- ;;
- dpx2* | dpx2*-bull)
- basic_machine=m68k-bull
- os=-sysv3
- ;;
- ebmon29k)
- basic_machine=a29k-amd
- os=-ebmon
- ;;
- elxsi)
- basic_machine=elxsi-elxsi
- os=-bsd
- ;;
- encore | umax | mmax)
- basic_machine=ns32k-encore
- ;;
- es1800 | OSE68k | ose68k | ose | OSE)
- basic_machine=m68k-ericsson
- os=-ose
- ;;
- fx2800)
- basic_machine=i860-alliant
- ;;
- genix)
- basic_machine=ns32k-ns
- ;;
- gmicro)
- basic_machine=tron-gmicro
- os=-sysv
- ;;
- go32)
- basic_machine=i386-pc
- os=-go32
- ;;
- h3050r* | hiux*)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- h8300hms)
- basic_machine=h8300-hitachi
- os=-hms
- ;;
- h8300xray)
- basic_machine=h8300-hitachi
- os=-xray
- ;;
- h8500hms)
- basic_machine=h8500-hitachi
- os=-hms
- ;;
- harris)
- basic_machine=m88k-harris
- os=-sysv3
- ;;
- hp300-*)
- basic_machine=m68k-hp
- ;;
- hp300bsd)
- basic_machine=m68k-hp
- os=-bsd
- ;;
- hp300hpux)
- basic_machine=m68k-hp
- os=-hpux
- ;;
- hp3k9[0-9][0-9] | hp9[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hp9k2[0-9][0-9] | hp9k31[0-9])
- basic_machine=m68000-hp
- ;;
- hp9k3[2-9][0-9])
- basic_machine=m68k-hp
- ;;
- hp9k6[0-9][0-9] | hp6[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hp9k7[0-79][0-9] | hp7[0-79][0-9])
- basic_machine=hppa1.1-hp
- ;;
- hp9k78[0-9] | hp78[0-9])
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][13679] | hp8[0-9][13679])
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][0-9] | hp8[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hppa-next)
- os=-nextstep3
- ;;
- hppaosf)
- basic_machine=hppa1.1-hp
- os=-osf
- ;;
- hppro)
- basic_machine=hppa1.1-hp
- os=-proelf
- ;;
- i370-ibm* | ibm*)
- basic_machine=i370-ibm
- ;;
-# I'm not sure what "Sysv32" means. Should this be sysv3.2?
- i*86v32)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv32
- ;;
- i*86v4*)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv4
- ;;
- i*86v)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv
- ;;
- i*86sol2)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-solaris2
- ;;
- i386mach)
- basic_machine=i386-mach
- os=-mach
- ;;
- i386-vsta | vsta)
- basic_machine=i386-unknown
- os=-vsta
- ;;
- iris | iris4d)
- basic_machine=mips-sgi
- case $os in
- -irix*)
- ;;
- *)
- os=-irix4
- ;;
- esac
- ;;
- isi68 | isi)
- basic_machine=m68k-isi
- os=-sysv
- ;;
- m88k-omron*)
- basic_machine=m88k-omron
- ;;
- magnum | m3230)
- basic_machine=mips-mips
- os=-sysv
- ;;
- merlin)
- basic_machine=ns32k-utek
- os=-sysv
- ;;
- mingw32)
- basic_machine=i386-pc
- os=-mingw32
- ;;
- miniframe)
- basic_machine=m68000-convergent
- ;;
- *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
- basic_machine=m68k-atari
- os=-mint
- ;;
- mips3*-*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
- ;;
- mips3*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
- ;;
- monitor)
- basic_machine=m68k-rom68k
- os=-coff
- ;;
- morphos)
- basic_machine=powerpc-unknown
- os=-morphos
- ;;
- msdos)
- basic_machine=i386-pc
- os=-msdos
- ;;
- mvs)
- basic_machine=i370-ibm
- os=-mvs
- ;;
- ncr3000)
- basic_machine=i486-ncr
- os=-sysv4
- ;;
- netbsd386)
- basic_machine=i386-unknown
- os=-netbsd
- ;;
- netwinder)
- basic_machine=armv4l-rebel
- os=-linux
- ;;
- news | news700 | news800 | news900)
- basic_machine=m68k-sony
- os=-newsos
- ;;
- news1000)
- basic_machine=m68030-sony
- os=-newsos
- ;;
- news-3600 | risc-news)
- basic_machine=mips-sony
- os=-newsos
- ;;
- necv70)
- basic_machine=v70-nec
- os=-sysv
- ;;
- next | m*-next )
- basic_machine=m68k-next
- case $os in
- -nextstep* )
- ;;
- -ns2*)
- os=-nextstep2
- ;;
- *)
- os=-nextstep3
- ;;
- esac
- ;;
- nh3000)
- basic_machine=m68k-harris
- os=-cxux
- ;;
- nh[45]000)
- basic_machine=m88k-harris
- os=-cxux
- ;;
- nindy960)
- basic_machine=i960-intel
- os=-nindy
- ;;
- mon960)
- basic_machine=i960-intel
- os=-mon960
- ;;
- nonstopux)
- basic_machine=mips-compaq
- os=-nonstopux
- ;;
- np1)
- basic_machine=np1-gould
- ;;
- nsr-tandem)
- basic_machine=nsr-tandem
- ;;
- op50n-* | op60c-*)
- basic_machine=hppa1.1-oki
- os=-proelf
- ;;
- openrisc | openrisc-*)
- basic_machine=or32-unknown
- ;;
- os400)
- basic_machine=powerpc-ibm
- os=-os400
- ;;
- OSE68000 | ose68000)
- basic_machine=m68000-ericsson
- os=-ose
- ;;
- os68k)
- basic_machine=m68k-none
- os=-os68k
- ;;
- pa-hitachi)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- paragon)
- basic_machine=i860-intel
- os=-osf
- ;;
- pbd)
- basic_machine=sparc-tti
- ;;
- pbb)
- basic_machine=m68k-tti
- ;;
- pc532 | pc532-*)
- basic_machine=ns32k-pc532
- ;;
- pentium | p5 | k5 | k6 | nexgen | viac3)
- basic_machine=i586-pc
- ;;
- pentiumpro | p6 | 6x86 | athlon | athlon_*)
- basic_machine=i686-pc
- ;;
- pentiumii | pentium2 | pentiumiii | pentium3)
- basic_machine=i686-pc
- ;;
- pentium4)
- basic_machine=i786-pc
- ;;
- pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
- basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentiumpro-* | p6-* | 6x86-* | athlon-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentium4-*)
- basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pn)
- basic_machine=pn-gould
- ;;
- power) basic_machine=power-ibm
- ;;
- ppc) basic_machine=powerpc-unknown
- ;;
- ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppcle | powerpclittle | ppc-le | powerpc-little)
- basic_machine=powerpcle-unknown
- ;;
- ppcle-* | powerpclittle-*)
- basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppc64) basic_machine=powerpc64-unknown
- ;;
- ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppc64le | powerpc64little | ppc64-le | powerpc64-little)
- basic_machine=powerpc64le-unknown
- ;;
- ppc64le-* | powerpc64little-*)
- basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ps2)
- basic_machine=i386-ibm
- ;;
- pw32)
- basic_machine=i586-unknown
- os=-pw32
- ;;
- rom68k)
- basic_machine=m68k-rom68k
- os=-coff
- ;;
- rm[46]00)
- basic_machine=mips-siemens
- ;;
- rtpc | rtpc-*)
- basic_machine=romp-ibm
- ;;
- s390 | s390-*)
- basic_machine=s390-ibm
- ;;
- s390x | s390x-*)
- basic_machine=s390x-ibm
- ;;
- sa29200)
- basic_machine=a29k-amd
- os=-udi
- ;;
- sb1)
- basic_machine=mipsisa64sb1-unknown
- ;;
- sb1el)
- basic_machine=mipsisa64sb1el-unknown
- ;;
- sei)
- basic_machine=mips-sei
- os=-seiux
- ;;
- sequent)
- basic_machine=i386-sequent
- ;;
- sh)
- basic_machine=sh-hitachi
- os=-hms
- ;;
- sh64)
- basic_machine=sh64-unknown
- ;;
- sparclite-wrs | simso-wrs)
- basic_machine=sparclite-wrs
- os=-vxworks
- ;;
- sps7)
- basic_machine=m68k-bull
- os=-sysv2
- ;;
- spur)
- basic_machine=spur-unknown
- ;;
- st2000)
- basic_machine=m68k-tandem
- ;;
- stratus)
- basic_machine=i860-stratus
- os=-sysv4
- ;;
- sun2)
- basic_machine=m68000-sun
- ;;
- sun2os3)
- basic_machine=m68000-sun
- os=-sunos3
- ;;
- sun2os4)
- basic_machine=m68000-sun
- os=-sunos4
- ;;
- sun3os3)
- basic_machine=m68k-sun
- os=-sunos3
- ;;
- sun3os4)
- basic_machine=m68k-sun
- os=-sunos4
- ;;
- sun4os3)
- basic_machine=sparc-sun
- os=-sunos3
- ;;
- sun4os4)
- basic_machine=sparc-sun
- os=-sunos4
- ;;
- sun4sol2)
- basic_machine=sparc-sun
- os=-solaris2
- ;;
- sun3 | sun3-*)
- basic_machine=m68k-sun
- ;;
- sun4)
- basic_machine=sparc-sun
- ;;
- sun386 | sun386i | roadrunner)
- basic_machine=i386-sun
- ;;
- sv1)
- basic_machine=sv1-cray
- os=-unicos
- ;;
- symmetry)
- basic_machine=i386-sequent
- os=-dynix
- ;;
- t3e)
- basic_machine=alphaev5-cray
- os=-unicos
- ;;
- t90)
- basic_machine=t90-cray
- os=-unicos
- ;;
- tic54x | c54x*)
- basic_machine=tic54x-unknown
- os=-coff
- ;;
- tic55x | c55x*)
- basic_machine=tic55x-unknown
- os=-coff
- ;;
- tic6x | c6x*)
- basic_machine=tic6x-unknown
- os=-coff
- ;;
- tx39)
- basic_machine=mipstx39-unknown
- ;;
- tx39el)
- basic_machine=mipstx39el-unknown
- ;;
- toad1)
- basic_machine=pdp10-xkl
- os=-tops20
- ;;
- tower | tower-32)
- basic_machine=m68k-ncr
- ;;
- tpf)
- basic_machine=s390x-ibm
- os=-tpf
- ;;
- udi29k)
- basic_machine=a29k-amd
- os=-udi
- ;;
- ultra3)
- basic_machine=a29k-nyu
- os=-sym1
- ;;
- v810 | necv810)
- basic_machine=v810-nec
- os=-none
- ;;
- vaxv)
- basic_machine=vax-dec
- os=-sysv
- ;;
- vms)
- basic_machine=vax-dec
- os=-vms
- ;;
- vpp*|vx|vx-*)
- basic_machine=f301-fujitsu
- ;;
- vxworks960)
- basic_machine=i960-wrs
- os=-vxworks
- ;;
- vxworks68)
- basic_machine=m68k-wrs
- os=-vxworks
- ;;
- vxworks29k)
- basic_machine=a29k-wrs
- os=-vxworks
- ;;
- w65*)
- basic_machine=w65-wdc
- os=-none
- ;;
- w89k-*)
- basic_machine=hppa1.1-winbond
- os=-proelf
- ;;
- xbox)
- basic_machine=i686-pc
- os=-mingw32
- ;;
- xps | xps100)
- basic_machine=xps100-honeywell
- ;;
- ymp)
- basic_machine=ymp-cray
- os=-unicos
- ;;
- z8k-*-coff)
- basic_machine=z8k-unknown
- os=-sim
- ;;
- none)
- basic_machine=none-none
- os=-none
- ;;
-
-# Here we handle the default manufacturer of certain CPU types. It is in
-# some cases the only manufacturer, in others, it is the most popular.
- w89k)
- basic_machine=hppa1.1-winbond
- ;;
- op50n)
- basic_machine=hppa1.1-oki
- ;;
- op60c)
- basic_machine=hppa1.1-oki
- ;;
- romp)
- basic_machine=romp-ibm
- ;;
- mmix)
- basic_machine=mmix-knuth
- ;;
- rs6000)
- basic_machine=rs6000-ibm
- ;;
- vax)
- basic_machine=vax-dec
- ;;
- pdp10)
- # there are many clones, so DEC is not a safe bet
- basic_machine=pdp10-unknown
- ;;
- pdp11)
- basic_machine=pdp11-dec
- ;;
- we32k)
- basic_machine=we32k-att
- ;;
- sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
- basic_machine=sh-unknown
- ;;
- sparc | sparcv8 | sparcv9 | sparcv9b)
- basic_machine=sparc-sun
- ;;
- cydra)
- basic_machine=cydra-cydrome
- ;;
- orion)
- basic_machine=orion-highlevel
- ;;
- orion105)
- basic_machine=clipper-highlevel
- ;;
- mac | mpw | mac-mpw)
- basic_machine=m68k-apple
- ;;
- pmac | pmac-mpw)
- basic_machine=powerpc-apple
- ;;
- *-unknown)
- # Make sure to match an already-canonicalized machine name.
- ;;
- *)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
-esac
-
-# Here we canonicalize certain aliases for manufacturers.
-case $basic_machine in
- *-digital*)
- basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
- ;;
- *-commodore*)
- basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
- ;;
- *)
- ;;
-esac
-
-# Decode manufacturer-specific aliases for certain operating systems.
-
-if [ x"$os" != x"" ]
-then
-case $os in
- # First match some system type aliases
- # that might get confused with valid system types.
- # -solaris* is a basic system type, with this one exception.
- -solaris1 | -solaris1.*)
- os=`echo $os | sed -e 's|solaris1|sunos4|'`
- ;;
- -solaris)
- os=-solaris2
- ;;
- -svr4*)
- os=-sysv4
- ;;
- -unixware*)
- os=-sysv4.2uw
- ;;
- -gnu/linux*)
- os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
- ;;
- # First accept the basic system types.
- # The portable systems comes first.
- # Each alternative MUST END IN A *, to match a version number.
- # -sysv* is not here because it comes later, after sysvr4.
- -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
- | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
- | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
- | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
- | -aos* \
- | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
- | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
- | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
- | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
- | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
- | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
- | -chorusos* | -chorusrdb* \
- | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
- | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
- | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
- | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
- | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
- | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
- | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
- | -skyos* | -haiku*)
- # Remember, each alternative MUST END IN *, to match a version number.
- ;;
- -qnx*)
- case $basic_machine in
- x86-* | i*86-*)
- ;;
- *)
- os=-nto$os
- ;;
- esac
- ;;
- -nto-qnx*)
- ;;
- -nto*)
- os=`echo $os | sed -e 's|nto|nto-qnx|'`
- ;;
- -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
- | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
- | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
- ;;
- -mac*)
- os=`echo $os | sed -e 's|mac|macos|'`
- ;;
- -linux-dietlibc)
- os=-linux-dietlibc
- ;;
- -linux*)
- os=`echo $os | sed -e 's|linux|linux-gnu|'`
- ;;
- -sunos5*)
- os=`echo $os | sed -e 's|sunos5|solaris2|'`
- ;;
- -sunos6*)
- os=`echo $os | sed -e 's|sunos6|solaris3|'`
- ;;
- -opened*)
- os=-openedition
- ;;
- -os400*)
- os=-os400
- ;;
- -wince*)
- os=-wince
- ;;
- -osfrose*)
- os=-osfrose
- ;;
- -osf*)
- os=-osf
- ;;
- -utek*)
- os=-bsd
- ;;
- -dynix*)
- os=-bsd
- ;;
- -acis*)
- os=-aos
- ;;
- -atheos*)
- os=-atheos
- ;;
- -syllable*)
- os=-syllable
- ;;
- -386bsd)
- os=-bsd
- ;;
- -ctix* | -uts*)
- os=-sysv
- ;;
- -nova*)
- os=-rtmk-nova
- ;;
- -ns2 )
- os=-nextstep2
- ;;
- -nsk*)
- os=-nsk
- ;;
- # Preserve the version number of sinix5.
- -sinix5.*)
- os=`echo $os | sed -e 's|sinix|sysv|'`
- ;;
- -sinix*)
- os=-sysv4
- ;;
- -tpf*)
- os=-tpf
- ;;
- -triton*)
- os=-sysv3
- ;;
- -oss*)
- os=-sysv3
- ;;
- -svr4)
- os=-sysv4
- ;;
- -svr3)
- os=-sysv3
- ;;
- -sysvr4)
- os=-sysv4
- ;;
- # This must come after -sysvr4.
- -sysv*)
- ;;
- -ose*)
- os=-ose
- ;;
- -es1800*)
- os=-ose
- ;;
- -xenix)
- os=-xenix
- ;;
- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
- os=-mint
- ;;
- -aros*)
- os=-aros
- ;;
- -kaos*)
- os=-kaos
- ;;
- -zvmoe)
- os=-zvmoe
- ;;
- -none)
- ;;
- *)
- # Get rid of the `-' at the beginning of $os.
- os=`echo $os | sed 's/[^-]*-//'`
- echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
- exit 1
- ;;
-esac
-else
-
-# Here we handle the default operating systems that come with various machines.
-# The value should be what the vendor currently ships out the door with their
-# machine or put another way, the most popular os provided with the machine.
-
-# Note that if you're going to try to match "-MANUFACTURER" here (say,
-# "-sun"), then you have to tell the case statement up towards the top
-# that MANUFACTURER isn't an operating system. Otherwise, code above
-# will signal an error saying that MANUFACTURER isn't an operating
-# system, and we'll never get to this point.
-
-case $basic_machine in
- *-acorn)
- os=-riscix1.2
- ;;
- arm*-rebel)
- os=-linux
- ;;
- arm*-semi)
- os=-aout
- ;;
- c4x-* | tic4x-*)
- os=-coff
- ;;
- # This must come before the *-dec entry.
- pdp10-*)
- os=-tops20
- ;;
- pdp11-*)
- os=-none
- ;;
- *-dec | vax-*)
- os=-ultrix4.2
- ;;
- m68*-apollo)
- os=-domain
- ;;
- i386-sun)
- os=-sunos4.0.2
- ;;
- m68000-sun)
- os=-sunos3
- # This also exists in the configure program, but was not the
- # default.
- # os=-sunos4
- ;;
- m68*-cisco)
- os=-aout
- ;;
- mips*-cisco)
- os=-elf
- ;;
- mips*-*)
- os=-elf
- ;;
- or32-*)
- os=-coff
- ;;
- *-tti) # must be before sparc entry or we get the wrong os.
- os=-sysv3
- ;;
- sparc-* | *-sun)
- os=-sunos4.1.1
- ;;
- *-be)
- os=-beos
- ;;
- *-haiku)
- os=-haiku
- ;;
- *-ibm)
- os=-aix
- ;;
- *-knuth)
- os=-mmixware
- ;;
- *-wec)
- os=-proelf
- ;;
- *-winbond)
- os=-proelf
- ;;
- *-oki)
- os=-proelf
- ;;
- *-hp)
- os=-hpux
- ;;
- *-hitachi)
- os=-hiux
- ;;
- i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
- os=-sysv
- ;;
- *-cbm)
- os=-amigaos
- ;;
- *-dg)
- os=-dgux
- ;;
- *-dolphin)
- os=-sysv3
- ;;
- m68k-ccur)
- os=-rtu
- ;;
- m88k-omron*)
- os=-luna
- ;;
- *-next )
- os=-nextstep
- ;;
- *-sequent)
- os=-ptx
- ;;
- *-crds)
- os=-unos
- ;;
- *-ns)
- os=-genix
- ;;
- i370-*)
- os=-mvs
- ;;
- *-next)
- os=-nextstep3
- ;;
- *-gould)
- os=-sysv
- ;;
- *-highlevel)
- os=-bsd
- ;;
- *-encore)
- os=-bsd
- ;;
- *-sgi)
- os=-irix
- ;;
- *-siemens)
- os=-sysv4
- ;;
- *-masscomp)
- os=-rtu
- ;;
- f30[01]-fujitsu | f700-fujitsu)
- os=-uxpv
- ;;
- *-rom68k)
- os=-coff
- ;;
- *-*bug)
- os=-coff
- ;;
- *-apple)
- os=-macos
- ;;
- *-atari*)
- os=-mint
- ;;
- *)
- os=-none
- ;;
-esac
-fi
-
-# Here we handle the case where we know the os, and the CPU type, but not the
-# manufacturer. We pick the logical manufacturer.
-vendor=unknown
-case $basic_machine in
- *-unknown)
- case $os in
- -riscix*)
- vendor=acorn
- ;;
- -sunos*)
- vendor=sun
- ;;
- -aix*)
- vendor=ibm
- ;;
- -beos*)
- vendor=be
- ;;
- -hpux*)
- vendor=hp
- ;;
- -mpeix*)
- vendor=hp
- ;;
- -hiux*)
- vendor=hitachi
- ;;
- -unos*)
- vendor=crds
- ;;
- -dgux*)
- vendor=dg
- ;;
- -luna*)
- vendor=omron
- ;;
- -genix*)
- vendor=ns
- ;;
- -mvs* | -opened*)
- vendor=ibm
- ;;
- -os400*)
- vendor=ibm
- ;;
- -ptx*)
- vendor=sequent
- ;;
- -tpf*)
- vendor=ibm
- ;;
- -vxsim* | -vxworks* | -windiss*)
- vendor=wrs
- ;;
- -aux*)
- vendor=apple
- ;;
- -hms*)
- vendor=hitachi
- ;;
- -mpw* | -macos*)
- vendor=apple
- ;;
- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
- vendor=atari
- ;;
- -vos*)
- vendor=stratus
- ;;
- esac
- basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
- ;;
-esac
-
-echo $basic_machine$os
-exit
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/source4/lib/tdb/configure.ac b/source4/lib/tdb/configure.ac
deleted file mode 100644
index eaf70d30b4..0000000000
--- a/source4/lib/tdb/configure.ac
+++ /dev/null
@@ -1,30 +0,0 @@
-AC_PREREQ(2.50)
-AC_DEFUN([SMB_MODULE_DEFAULT], [echo -n ""])
-AC_DEFUN([SMB_LIBRARY_ENABLE], [echo -n ""])
-AC_DEFUN([SMB_ENABLE], [echo -n ""])
-AC_INIT(tdb, 1.1.2)
-AC_CONFIG_SRCDIR([common/tdb.c])
-AC_CONFIG_HEADER(include/config.h)
-AC_LIBREPLACE_ALL_CHECKS
-AC_LD_SONAMEFLAG
-AC_LD_PICFLAG
-AC_LD_SHLIBEXT
-AC_LIBREPLACE_SHLD
-AC_LIBREPLACE_SHLD_FLAGS
-AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
-m4_include(libtdb.m4)
-AC_PATH_PROGS([PYTHON_CONFIG], [python2.6-config python2.5-config python2.4-config python-config])
-AC_PATH_PROGS([PYTHON], [python2.6 python2.5 python2.4 python])
-
-PYTHON_BUILD_TARGET="build-python"
-PYTHON_INSTALL_TARGET="install-python"
-PYTHON_CHECK_TARGET="check-python"
-AC_SUBST(PYTHON_BUILD_TARGET)
-AC_SUBST(PYTHON_INSTALL_TARGET)
-AC_SUBST(PYTHON_CHECK_TARGET)
-if test -z "$PYTHON_CONFIG"; then
- PYTHON_BUILD_TARGET=""
- PYTHON_INSTALL_TARGET=""
- PYTHON_CHECK_TARGET=""
-fi
-AC_OUTPUT(Makefile tdb.pc)
diff --git a/source4/lib/tdb/docs/README b/source4/lib/tdb/docs/README
deleted file mode 100644
index 63fcf5e049..0000000000
--- a/source4/lib/tdb/docs/README
+++ /dev/null
@@ -1,238 +0,0 @@
-tdb - a trivial database system
-tridge@linuxcare.com December 1999
-==================================
-
-This is a simple database API. It was inspired by the realisation that
-in Samba we have several ad-hoc bits of code that essentially
-implement small databases for sharing structures between parts of
-Samba. As I was about to add another I realised that a generic
-database module was called for to replace all the ad-hoc bits.
-
-I based the interface on gdbm. I couldn't use gdbm as we need to be
-able to have multiple writers to the databases at one time.
-
-Compilation
------------
-
-add HAVE_MMAP=1 to use mmap instead of read/write
-add NOLOCK=1 to disable locking code
-
-Testing
--------
-
-Compile tdbtest.c and link with gdbm for testing. tdbtest will perform
-identical operations via tdb and gdbm then make sure the result is the
-same
-
-Also included is tdbtool, which allows simple database manipulation
-on the commandline.
-
-tdbtest and tdbtool are not built as part of Samba, but are included
-for completeness.
-
-Interface
----------
-
-The interface is very similar to gdbm except for the following:
-
-- different open interface. The tdb_open call is more similar to a
- traditional open()
-- no tdbm_reorganise() function
-- no tdbm_sync() function. No operations are cached in the library anyway
-- added a tdb_traverse() function for traversing the whole database
-- added transactions support
-
-A general rule for using tdb is that the caller frees any returned
-TDB_DATA structures. Just call free(p.dptr) to free a TDB_DATA
-return value called p. This is the same as gdbm.
-
-here is a full list of tdb functions with brief descriptions.
-
-
-----------------------------------------------------------------------
-TDB_CONTEXT *tdb_open(char *name, int hash_size, int tdb_flags,
- int open_flags, mode_t mode)
-
- open the database, creating it if necessary
-
- The open_flags and mode are passed straight to the open call on the database
- file. A flags value of O_WRONLY is invalid
-
- The hash size is advisory, use zero for a default value.
-
- return is NULL on error
-
- possible tdb_flags are:
- TDB_CLEAR_IF_FIRST - clear database if we are the only one with it open
- TDB_INTERNAL - don't use a file, instaed store the data in
- memory. The filename is ignored in this case.
- TDB_NOLOCK - don't do any locking
- TDB_NOMMAP - don't use mmap
- TDB_NOSYNC - don't synchronise transactions to disk
-
-----------------------------------------------------------------------
-TDB_CONTEXT *tdb_open_ex(char *name, int hash_size, int tdb_flags,
- int open_flags, mode_t mode,
- tdb_log_func log_fn,
- tdb_hash_func hash_fn)
-
-This is like tdb_open(), but allows you to pass an initial logging and
-hash function. Be careful when passing a hash function - all users of
-the database must use the same hash function or you will get data
-corruption.
-
-
-----------------------------------------------------------------------
-char *tdb_error(TDB_CONTEXT *tdb);
-
- return a error string for the last tdb error
-
-----------------------------------------------------------------------
-int tdb_close(TDB_CONTEXT *tdb);
-
- close a database
-
-----------------------------------------------------------------------
-int tdb_update(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf);
-
- update an entry in place - this only works if the new data size
- is <= the old data size and the key exists.
- on failure return -1
-
-----------------------------------------------------------------------
-TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key);
-
- fetch an entry in the database given a key
- if the return value has a null dptr then a error occurred
-
- caller must free the resulting data
-
-----------------------------------------------------------------------
-int tdb_exists(TDB_CONTEXT *tdb, TDB_DATA key);
-
- check if an entry in the database exists
-
- note that 1 is returned if the key is found and 0 is returned if not found
- this doesn't match the conventions in the rest of this module, but is
- compatible with gdbm
-
-----------------------------------------------------------------------
-int tdb_traverse(TDB_CONTEXT *tdb, int (*fn)(TDB_CONTEXT *tdb,
- TDB_DATA key, TDB_DATA dbuf, void *state), void *state);
-
- traverse the entire database - calling fn(tdb, key, data, state) on each
- element.
-
- return -1 on error or the record count traversed
-
- if fn is NULL then it is not called
-
- a non-zero return value from fn() indicates that the traversal
- should stop. Traversal callbacks may not start transactions.
-
- WARNING: The data buffer given to the callback fn does NOT meet the
- alignment restrictions malloc gives you.
-
-----------------------------------------------------------------------
-int tdb_traverse_read(TDB_CONTEXT *tdb, int (*fn)(TDB_CONTEXT *tdb,
- TDB_DATA key, TDB_DATA dbuf, void *state), void *state);
-
- traverse the entire database - calling fn(tdb, key, data, state) on
- each element, but marking the database read only during the
- traversal, so any write operations will fail. This allows tdb to
- use read locks, which increases the parallelism possible during the
- traversal.
-
- return -1 on error or the record count traversed
-
- if fn is NULL then it is not called
-
- a non-zero return value from fn() indicates that the traversal
- should stop. Traversal callbacks may not start transactions.
-
-----------------------------------------------------------------------
-TDB_DATA tdb_firstkey(TDB_CONTEXT *tdb);
-
- find the first entry in the database and return its key
-
- the caller must free the returned data
-
-----------------------------------------------------------------------
-TDB_DATA tdb_nextkey(TDB_CONTEXT *tdb, TDB_DATA key);
-
- find the next entry in the database, returning its key
-
- the caller must free the returned data
-
-----------------------------------------------------------------------
-int tdb_delete(TDB_CONTEXT *tdb, TDB_DATA key);
-
- delete an entry in the database given a key
-
-----------------------------------------------------------------------
-int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag);
-
- store an element in the database, replacing any existing element
- with the same key
-
- If flag==TDB_INSERT then don't overwrite an existing entry
- If flag==TDB_MODIFY then don't create a new entry
-
- return 0 on success, -1 on failure
-
-----------------------------------------------------------------------
-int tdb_writelock(TDB_CONTEXT *tdb);
-
- lock the database. If we already have it locked then don't do anything
-
-----------------------------------------------------------------------
-int tdb_writeunlock(TDB_CONTEXT *tdb);
- unlock the database
-
-----------------------------------------------------------------------
-int tdb_lockchain(TDB_CONTEXT *tdb, TDB_DATA key);
-
- lock one hash chain. This is meant to be used to reduce locking
- contention - it cannot guarantee how many records will be locked
-
-----------------------------------------------------------------------
-int tdb_unlockchain(TDB_CONTEXT *tdb, TDB_DATA key);
-
- unlock one hash chain
-
-----------------------------------------------------------------------
-int tdb_transaction_start(TDB_CONTEXT *tdb)
-
- start a transaction. All operations after the transaction start can
- either be committed with tdb_transaction_commit() or cancelled with
- tdb_transaction_cancel().
-
- If you call tdb_transaction_start() again on the same tdb context
- while a transaction is in progress, then the same transaction
- buffer is re-used. The number of tdb_transaction_{commit,cancel}
- operations must match the number of successful
- tdb_transaction_start() calls.
-
- Note that transactions are by default disk synchronous, and use a
- recover area in the database to automatically recover the database
- on the next open if the system crashes during a transaction. You
- can disable the synchronous transaction recovery setup using the
- TDB_NOSYNC flag, which will greatly speed up operations at the risk
- of corrupting your database if the system crashes.
-
- Operations made within a transaction are not visible to other users
- of the database until a successful commit.
-
-----------------------------------------------------------------------
-int tdb_transaction_cancel(TDB_CONTEXT *tdb)
-
- cancel a current transaction, discarding all write and lock
- operations that have been made since the transaction started.
-
-
-----------------------------------------------------------------------
-int tdb_transaction_commit(TDB_CONTEXT *tdb)
-
- commit a current transaction, updating the database and releasing
- the transaction locks.
-
diff --git a/source4/lib/tdb/docs/tdb.magic b/source4/lib/tdb/docs/tdb.magic
deleted file mode 100644
index f5619e7327..0000000000
--- a/source4/lib/tdb/docs/tdb.magic
+++ /dev/null
@@ -1,10 +0,0 @@
-# Magic file(1) information about tdb files.
-#
-# Install this into /etc/magic or the corresponding location for your
-# system, or pass as a -m argument to file(1).
-
-# You may use and redistribute this file without restriction.
-
-0 string TDB\ file TDB database
->32 lelong =0x2601196D version 6, little-endian
->>36 lelong x hash size %d bytes
diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h
deleted file mode 100644
index 0008085de5..0000000000
--- a/source4/lib/tdb/include/tdb.h
+++ /dev/null
@@ -1,167 +0,0 @@
-#ifndef __TDB_H__
-#define __TDB_H__
-
-/*
- Unix SMB/CIFS implementation.
-
- trivial database library
-
- Copyright (C) Andrew Tridgell 1999-2004
-
- ** NOTE! The following LGPL license applies to the tdb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* flags to tdb_store() */
-#define TDB_REPLACE 1 /* Unused */
-#define TDB_INSERT 2 /* Don't overwrite an existing entry */
-#define TDB_MODIFY 3 /* Don't create an existing entry */
-
-/* flags for tdb_open() */
-#define TDB_DEFAULT 0 /* just a readability place holder */
-#define TDB_CLEAR_IF_FIRST 1
-#define TDB_INTERNAL 2 /* don't store on disk */
-#define TDB_NOLOCK 4 /* don't do any locking */
-#define TDB_NOMMAP 8 /* don't use mmap */
-#define TDB_CONVERT 16 /* convert endian (internal use) */
-#define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */
-#define TDB_NOSYNC 64 /* don't use synchronous transactions */
-#define TDB_SEQNUM 128 /* maintain a sequence number */
-#define TDB_VOLATILE 256 /* Activate the per-hashchain freelist, default 5 */
-
-#define TDB_ERRCODE(code, ret) ((tdb->ecode = (code)), ret)
-
-/* error codes */
-enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK,
- TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT,
- TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY};
-
-/* debugging uses one of the following levels */
-enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR,
- TDB_DEBUG_WARNING, TDB_DEBUG_TRACE};
-
-typedef struct TDB_DATA {
- unsigned char *dptr;
- size_t dsize;
-} TDB_DATA;
-
-#ifndef PRINTF_ATTRIBUTE
-#if (__GNUC__ >= 3)
-/** Use gcc attribute to check printf fns. a1 is the 1-based index of
- * the parameter containing the format, and a2 the index of the first
- * argument. Note that some gcc 2.x versions don't handle this
- * properly **/
-#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
-#else
-#define PRINTF_ATTRIBUTE(a1, a2)
-#endif
-#endif
-
-/* this is the context structure that is returned from a db open */
-typedef struct tdb_context TDB_CONTEXT;
-
-typedef int (*tdb_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *);
-typedef void (*tdb_log_func)(struct tdb_context *, enum tdb_debug_level, const char *, ...) PRINTF_ATTRIBUTE(3, 4);
-typedef unsigned int (*tdb_hash_func)(TDB_DATA *key);
-
-struct tdb_logging_context {
- tdb_log_func log_fn;
- void *log_private;
-};
-
-struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags,
- int open_flags, mode_t mode);
-struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
- int open_flags, mode_t mode,
- const struct tdb_logging_context *log_ctx,
- tdb_hash_func hash_fn);
-void tdb_set_max_dead(struct tdb_context *tdb, int max_dead);
-
-int tdb_reopen(struct tdb_context *tdb);
-int tdb_reopen_all(int parent_longlived);
-void tdb_set_logging_function(struct tdb_context *tdb, const struct tdb_logging_context *log_ctx);
-enum TDB_ERROR tdb_error(struct tdb_context *tdb);
-const char *tdb_errorstr(struct tdb_context *tdb);
-TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key);
-int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key,
- int (*parser)(TDB_DATA key, TDB_DATA data,
- void *private_data),
- void *private_data);
-int tdb_delete(struct tdb_context *tdb, TDB_DATA key);
-int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag);
-int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf);
-int tdb_close(struct tdb_context *tdb);
-TDB_DATA tdb_firstkey(struct tdb_context *tdb);
-TDB_DATA tdb_nextkey(struct tdb_context *tdb, TDB_DATA key);
-int tdb_traverse(struct tdb_context *tdb, tdb_traverse_func fn, void *);
-int tdb_traverse_read(struct tdb_context *tdb, tdb_traverse_func fn, void *);
-int tdb_exists(struct tdb_context *tdb, TDB_DATA key);
-int tdb_lockall(struct tdb_context *tdb);
-int tdb_lockall_nonblock(struct tdb_context *tdb);
-int tdb_unlockall(struct tdb_context *tdb);
-int tdb_lockall_read(struct tdb_context *tdb);
-int tdb_lockall_read_nonblock(struct tdb_context *tdb);
-int tdb_unlockall_read(struct tdb_context *tdb);
-int tdb_lockall_mark(struct tdb_context *tdb);
-int tdb_lockall_unmark(struct tdb_context *tdb);
-const char *tdb_name(struct tdb_context *tdb);
-int tdb_fd(struct tdb_context *tdb);
-tdb_log_func tdb_log_fn(struct tdb_context *tdb);
-void *tdb_get_logging_private(struct tdb_context *tdb);
-int tdb_transaction_start(struct tdb_context *tdb);
-int tdb_transaction_commit(struct tdb_context *tdb);
-int tdb_transaction_cancel(struct tdb_context *tdb);
-int tdb_transaction_recover(struct tdb_context *tdb);
-int tdb_get_seqnum(struct tdb_context *tdb);
-int tdb_hash_size(struct tdb_context *tdb);
-size_t tdb_map_size(struct tdb_context *tdb);
-int tdb_get_flags(struct tdb_context *tdb);
-void tdb_add_flags(struct tdb_context *tdb, unsigned flag);
-void tdb_remove_flags(struct tdb_context *tdb, unsigned flag);
-void tdb_enable_seqnum(struct tdb_context *tdb);
-void tdb_increment_seqnum_nonblock(struct tdb_context *tdb);
-
-/* Low level locking functions: use with care */
-int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key);
-int tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key);
-int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key);
-int tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key);
-int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key);
-int tdb_chainlock_mark(struct tdb_context *tdb, TDB_DATA key);
-int tdb_chainlock_unmark(struct tdb_context *tdb, TDB_DATA key);
-
-void tdb_setalarm_sigptr(struct tdb_context *tdb, volatile sig_atomic_t *sigptr);
-
-/* Debug functions. Not used in production. */
-void tdb_dump_all(struct tdb_context *tdb);
-int tdb_printfreelist(struct tdb_context *tdb);
-int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries);
-int tdb_wipe_all(struct tdb_context *tdb);
-int tdb_freelist_size(struct tdb_context *tdb);
-
-extern TDB_DATA tdb_null;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* tdb.h */
diff --git a/source4/lib/tdb/install-sh b/source4/lib/tdb/install-sh
deleted file mode 100755
index 58719246f0..0000000000
--- a/source4/lib/tdb/install-sh
+++ /dev/null
@@ -1,238 +0,0 @@
-#! /bin/sh
-#
-# install - install a program, script, or datafile
-# This comes from X11R5.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-#
-
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-transformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd="$stripprog"
- shift
- continue;;
-
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
-
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
-done
-
-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
-else
- true
-fi
-
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- else
- instcmd=mkdir
- fi
-else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
-
- if [ -f $src -o -d $src ]
- then
- true
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- true
- fi
-
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- true
- fi
-fi
-
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
-
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-'
-IFS="${IFS-${defaultIFS}}"
-
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
-
-pathcomp=''
-
-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
-
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- true
- fi
-
- pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
-
-# If we're going to rename the final executable, determine the name now.
-
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
-
-# don't allow the sed command to completely eliminate the filename
-
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- true
- fi
-
-# Make a temp file name in the proper directory.
-
- dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-
- $doit $instcmd $src $dsttmp &&
-
- trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
-
-# Now rename the file to the real destination.
-
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
-
-fi &&
-
-
-exit 0
diff --git a/source4/lib/tdb/libtdb.m4 b/source4/lib/tdb/libtdb.m4
deleted file mode 100644
index 1e17a7a4f2..0000000000
--- a/source4/lib/tdb/libtdb.m4
+++ /dev/null
@@ -1,30 +0,0 @@
-dnl find the tdb sources. This is meant to work both for
-dnl tdb standalone builds, and builds of packages using tdb
-tdbdir=""
-tdbpaths="$srcdir $srcdir/lib/tdb $srcdir/tdb $srcdir/../tdb"
-for d in $tdbpaths; do
- if test -f "$d/common/tdb.c"; then
- tdbdir="$d"
- AC_SUBST(tdbdir)
- break;
- fi
-done
-if test x"$tdbdir" = "x"; then
- AC_MSG_ERROR([cannot find tdb source in $tdbpaths])
-fi
-TDB_OBJ="common/tdb.o common/dump.o common/transaction.o common/error.o common/traverse.o"
-TDB_OBJ="$TDB_OBJ common/freelist.o common/freelistcheck.o common/io.o common/lock.o common/open.o"
-AC_SUBST(TDB_OBJ)
-AC_SUBST(LIBREPLACEOBJ)
-
-TDB_LIBS=""
-AC_SUBST(TDB_LIBS)
-
-TDB_CFLAGS="-I$tdbdir/include"
-AC_SUBST(TDB_CFLAGS)
-
-AC_CHECK_FUNCS(mmap pread pwrite getpagesize utime)
-AC_CHECK_HEADERS(getopt.h sys/select.h sys/time.h)
-
-AC_HAVE_DECL(pread, [#include <unistd.h>])
-AC_HAVE_DECL(pwrite, [#include <unistd.h>])
diff --git a/source4/lib/tdb/python.mk b/source4/lib/tdb/python.mk
deleted file mode 100644
index 12e8217df9..0000000000
--- a/source4/lib/tdb/python.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-[PYTHON::swig_tdb]
-LIBRARY_REALNAME = _tdb.$(SHLIBEXT)
-PUBLIC_DEPENDENCIES = LIBTDB DYNCONFIG
-
-swig_tdb_OBJ_FILES = $(tdbsrcdir)/tdb_wrap.o
-
-$(eval $(call python_py_module_template,tdb.py,$(tdbsrcdir)/tdb.py))
-
-$(swig_tdb_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
-
diff --git a/source4/lib/tdb/python/tdbdump.py b/source4/lib/tdb/python/tdbdump.py
deleted file mode 100644
index d759d771c8..0000000000
--- a/source4/lib/tdb/python/tdbdump.py
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/python
-# Trivial reimplementation of tdbdump in Python
-
-import tdb, sys
-
-if len(sys.argv) < 2:
- print "Usage: tdbdump.py <tdb-file>"
- sys.exit(1)
-
-db = tdb.Tdb(sys.argv[1])
-for (k, v) in db.iteritems():
- print "{\nkey(%d) = %r\ndata(%d) = %r\n}" % (len(k), k, len(v), v)
diff --git a/source4/lib/tdb/python/tests/simple.py b/source4/lib/tdb/python/tests/simple.py
deleted file mode 100644
index 7147718c91..0000000000
--- a/source4/lib/tdb/python/tests/simple.py
+++ /dev/null
@@ -1,152 +0,0 @@
-#!/usr/bin/python
-# Some simple tests for the Python bindings for TDB
-# Note that this tests the interface of the Python bindings
-# It does not test tdb itself.
-#
-# Copyright (C) 2007-2008 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU LGPLv3 or later
-
-import tdb
-from unittest import TestCase
-import os, tempfile
-
-
-class OpenTdbTests(TestCase):
- def test_nonexistant_read(self):
- self.assertRaises(IOError, tdb.Tdb, "/some/nonexistant/file", 0, tdb.DEFAULT, os.O_RDWR)
-
-
-class SimpleTdbTests(TestCase):
- def setUp(self):
- super(SimpleTdbTests, self).setUp()
- self.tdb = tdb.Tdb(tempfile.mkstemp()[1], 0, tdb.DEFAULT, os.O_CREAT|os.O_RDWR)
- self.assertNotEqual(None, self.tdb)
-
- def tearDown(self):
- del self.tdb
-
- def test_repr(self):
- self.assertTrue(repr(self.tdb).startswith("Tdb('"))
-
- def test_lockall(self):
- self.tdb.lock_all()
-
- def test_max_dead(self):
- self.tdb.max_dead = 20
-
- def test_unlockall(self):
- self.tdb.lock_all()
- self.tdb.unlock_all()
-
- def test_lockall_read(self):
- self.tdb.read_lock_all()
- self.tdb.read_unlock_all()
-
- def test_reopen(self):
- self.tdb.reopen()
-
- def test_store(self):
- self.tdb.store("bar", "bla")
- self.assertEquals("bla", self.tdb.get("bar"))
-
- def test_getitem(self):
- self.tdb["bar"] = "foo"
- self.tdb.reopen()
- self.assertEquals("foo", self.tdb["bar"])
-
- def test_delete(self):
- self.tdb["bar"] = "foo"
- del self.tdb["bar"]
- self.assertRaises(KeyError, lambda: self.tdb["bar"])
-
- def test_contains(self):
- self.tdb["bla"] = "bloe"
- self.assertTrue("bla" in self.tdb)
-
- def test_keyerror(self):
- self.assertRaises(KeyError, lambda: self.tdb["bla"])
-
- def test_hash_size(self):
- self.tdb.hash_size
-
- def test_map_size(self):
- self.tdb.map_size
-
- def test_name(self):
- self.tdb.name
-
- def test_iterator(self):
- self.tdb["bla"] = "1"
- self.tdb["brainslug"] = "2"
- self.assertEquals(["bla", "brainslug"], list(self.tdb))
-
- def test_items(self):
- self.tdb["bla"] = "1"
- self.tdb["brainslug"] = "2"
- self.assertEquals([("bla", "1"), ("brainslug", "2")], self.tdb.items())
-
- def test_iteritems(self):
- self.tdb["bloe"] = "2"
- self.tdb["bla"] = "25"
- i = self.tdb.iteritems()
- self.assertEquals(set([("bla", "25"), ("bloe", "2")]),
- set([i.next(), i.next()]))
-
- def test_transaction_cancel(self):
- self.tdb["bloe"] = "2"
- self.tdb.transaction_start()
- self.tdb["bloe"] = "1"
- self.tdb.transaction_cancel()
- self.assertEquals("2", self.tdb["bloe"])
-
- def test_transaction_commit(self):
- self.tdb["bloe"] = "2"
- self.tdb.transaction_start()
- self.tdb["bloe"] = "1"
- self.tdb.transaction_commit()
- self.assertEquals("1", self.tdb["bloe"])
-
- def test_iterator(self):
- self.tdb["bloe"] = "2"
- self.tdb["bla"] = "hoi"
- i = iter(self.tdb)
- self.assertEquals(set(["bloe", "bla"]), set([i.next(), i.next()]))
-
- def test_keys(self):
- self.tdb["bloe"] = "2"
- self.tdb["bla"] = "25"
- self.assertEquals(["bla", "bloe"], self.tdb.keys())
-
- def test_iterkeys(self):
- self.tdb["bloe"] = "2"
- self.tdb["bla"] = "25"
- i = self.tdb.iterkeys()
- self.assertEquals(set(["bloe", "bla"]), set([i.next(), i.next()]))
-
- def test_values(self):
- self.tdb["bloe"] = "2"
- self.tdb["bla"] = "25"
- self.assertEquals(["25", "2"], self.tdb.values())
-
- def test_itervalues(self):
- self.tdb["bloe"] = "2"
- self.tdb["bla"] = "25"
- i = self.tdb.itervalues()
- self.assertEquals(set(["25", "2"]), set([i.next(), i.next()]))
-
- def test_clear(self):
- self.tdb["bloe"] = "2"
- self.tdb["bla"] = "25"
- self.assertEquals(2, len(self.tdb))
- self.tdb.clear()
- self.assertEquals(0, len(self.tdb))
-
- def test_len(self):
- self.assertEquals(0, len(self.tdb))
- self.tdb["entry"] = "value"
- self.assertEquals(1, len(self.tdb))
-
-
-if __name__ == '__main__':
- import unittest
- unittest.TestProgram()
diff --git a/source4/lib/tdb/rules.mk b/source4/lib/tdb/rules.mk
deleted file mode 100644
index 7b765625df..0000000000
--- a/source4/lib/tdb/rules.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-.SUFFIXES: .i _wrap.c
-
-.i_wrap.c:
- $(SWIG) -O -Wall -python -keyword $<
-
-showflags::
- @echo 'tdb will be compiled with flags:'
- @echo ' CFLAGS = $(CFLAGS)'
- @echo ' CPPFLAGS = $(CPPFLAGS)'
- @echo ' LDFLAGS = $(LDFLAGS)'
- @echo ' LIBS = $(LIBS)'
-
-.SUFFIXES: .c .o
-
-.c.o:
- @echo Compiling $*.c
- @mkdir -p `dirname $@`
- @$(CC) $(PICFLAG) $(CFLAGS) -c $< -o $@
-
-distclean::
- rm -f *~ */*~
diff --git a/source4/lib/tdb/tdb.i b/source4/lib/tdb/tdb.i
deleted file mode 100644
index 3d8b697732..0000000000
--- a/source4/lib/tdb/tdb.i
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Swig interface to tdb.
-
- Copyright (C) 2004-2006 Tim Potter <tpot@samba.org>
- Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-
- ** NOTE! The following LGPL license applies to the tdb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-%define DOCSTRING
-"TDB is a simple key-value database similar to GDBM that supports multiple writers."
-%enddef
-
-%module(docstring=DOCSTRING) tdb
-
-%{
-
-/* This symbol is used in both includes.h and Python.h which causes an
- annoying compiler warning. */
-
-#ifdef HAVE_FSTAT
-#undef HAVE_FSTAT
-#endif
-
-/* Include tdb headers */
-#include <stdint.h>
-#include <signal.h>
-#include <tdb.h>
-#include <fcntl.h>
-
-typedef TDB_CONTEXT tdb;
-%}
-
-/* The tdb functions will crash if a NULL tdb context is passed */
-
-%import exception.i
-%import stdint.i
-
-%typemap(check,noblock=1) TDB_CONTEXT* {
- if ($1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "tdb context must be non-NULL");
-}
-
-/* In and out typemaps for the TDB_DATA structure. This is converted to
- and from the Python string type which can contain arbitrary binary
- data.. */
-
-%typemap(in,noblock=1) TDB_DATA {
- if ($input == Py_None) {
- $1.dsize = 0;
- $1.dptr = NULL;
- } else if (!PyString_Check($input)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- } else {
- $1.dsize = PyString_Size($input);
- $1.dptr = (uint8_t *)PyString_AsString($input);
- }
-}
-
-%typemap(out,noblock=1) TDB_DATA {
- if ($1.dptr == NULL && $1.dsize == 0) {
- $result = Py_None;
- } else {
- $result = PyString_FromStringAndSize((const char *)$1.dptr, $1.dsize);
- free($1.dptr);
- }
-}
-
-/* Treat a mode_t as an unsigned integer */
-typedef int mode_t;
-
-/* flags to tdb_store() */
-%constant int REPLACE = TDB_REPLACE;
-%constant int INSERT = TDB_INSERT;
-%constant int MODIFY = TDB_MODIFY;
-
-/* flags for tdb_open() */
-%constant int DEFAULT = TDB_DEFAULT;
-%constant int CLEAR_IF_FIRST = TDB_CLEAR_IF_FIRST;
-%constant int INTERNAL = TDB_INTERNAL;
-%constant int NOLOCK = TDB_NOLOCK;
-%constant int NOMMAP = TDB_NOMMAP;
-%constant int CONVERT = TDB_CONVERT;
-%constant int BIGENDIAN = TDB_BIGENDIAN;
-
-enum TDB_ERROR {
- TDB_SUCCESS=0,
- TDB_ERR_CORRUPT,
- TDB_ERR_IO,
- TDB_ERR_LOCK,
- TDB_ERR_OOM,
- TDB_ERR_EXISTS,
- TDB_ERR_NOLOCK,
- TDB_ERR_LOCK_TIMEOUT,
- TDB_ERR_NOEXIST,
- TDB_ERR_EINVAL,
- TDB_ERR_RDONLY
-};
-
-%rename(lock_all) tdb_context::lockall;
-%rename(unlock_all) tdb_context::unlockall;
-
-%rename(read_lock_all) tdb_context::lockall_read;
-%rename(read_unlock_all) tdb_context::unlockall_read;
-
-%typemap(default,noblock=1) int tdb_flags {
- $1 = TDB_DEFAULT;
-}
-
-%typemap(default,noblock=1) int flags {
- $1 = O_RDWR;
-}
-
-%typemap(default,noblock=1) int hash_size {
- $1 = 0;
-}
-
-%typemap(default,noblock=1) mode_t mode {
- $1 = 0600;
-}
-
-%typemap(default,noblock=1) int flag {
- $1 = TDB_REPLACE;
-}
-
-%rename(Tdb) tdb_context;
-%feature("docstring") tdb_context "A TDB file.";
-%typemap(out,noblock=1) tdb * {
- /* Throw an IOError exception from errno if tdb_open() returns NULL */
- if ($1 == NULL) {
- PyErr_SetFromErrno(PyExc_IOError);
- SWIG_fail;
- }
- $result = SWIG_NewPointerObj($1, $1_descriptor, 0);
-}
-
-typedef struct tdb_context {
- %extend {
- %feature("docstring") tdb "S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)\n"
- "Open a TDB file.";
- tdb(const char *name, int hash_size, int tdb_flags, int flags, mode_t mode) {
- return tdb_open(name, hash_size, tdb_flags, flags, mode);
- }
- %feature("docstring") error "S.error() -> int\n"
- "Find last error number returned by operation on this TDB.";
- enum TDB_ERROR error();
- ~tdb() { tdb_close($self); }
- %feature("docstring") close "S.close() -> None\n"
- "Close the TDB file.";
- int close();
- int append(TDB_DATA key, TDB_DATA new_dbuf);
- %feature("docstring") errorstr "S.errorstr() -> errorstring\n"
- "Obtain last error message.";
- const char *errorstr();
- %rename(get) fetch;
- %feature("docstring") fetch "S.fetch(key) -> value\n"
- "Fetch a value.";
- TDB_DATA fetch(TDB_DATA key);
- %feature("docstring") delete "S.delete(key) -> None\n"
- "Delete an entry.";
- int delete(TDB_DATA key);
- %feature("docstring") store "S.store(key, value, flag=TDB_REPLACE) -> None\n"
- "Store an entry.";
- int store(TDB_DATA key, TDB_DATA dbuf, int flag);
- %feature("docstring") exists "S.exists(key) -> bool\n"
- "Check whether key exists in this database.";
- int exists(TDB_DATA key);
- %feature("docstring") firstkey "S.firstkey() -> data\n"
- "Return the first key in this database.";
- TDB_DATA firstkey();
- %feature("docstring") nextkey "S.nextkey(prev) -> data\n"
- "Return the next key in this database.";
- TDB_DATA nextkey(TDB_DATA key);
- %feature("docstring") lockall "S.lockall() -> bool";
- int lockall();
- %feature("docstring") unlockall "S.unlockall() -> bool";
- int unlockall();
- %feature("docstring") unlockall "S.lockall_read() -> bool";
- int lockall_read();
- %feature("docstring") unlockall "S.unlockall_read() -> bool";
- int unlockall_read();
- %feature("docstring") reopen "S.reopen() -> bool\n"
- "Reopen this file.";
- int reopen();
- %feature("docstring") transaction_start "S.transaction_start() -> None\n"
- "Start a new transaction.";
- int transaction_start();
- %feature("docstring") transaction_commit "S.transaction_commit() -> None\n"
- "Commit the currently active transaction.";
- int transaction_commit();
- %feature("docstring") transaction_cancel "S.transaction_cancel() -> None\n"
- "Cancel the currently active transaction.";
- int transaction_cancel();
- int transaction_recover();
- %feature("docstring") hash_size "S.hash_size() -> int";
- int hash_size();
- %feature("docstring") map_size "S.map_size() -> int";
- size_t map_size();
- %feature("docstring") get_flags "S.get_flags() -> int";
- int get_flags();
- %feature("docstring") set_max_dead "S.set_max_dead(int) -> None";
- void set_max_dead(int max_dead);
- %feature("docstring") name "S.name() -> path\n" \
- "Return filename of this TDB file.";
- const char *name();
- }
-
- %pythoncode {
- def __repr__(self):
- return "Tdb('%s')" % self.name()
-
- # Random access to keys, values
- def __getitem__(self, key):
- result = self.get(key)
- if result is None:
- raise KeyError, '%s: %s' % (key, self.errorstr())
- return result
-
- def __setitem__(self, key, item):
- if self.store(key, item) == -1:
- raise IOError, self.errorstr()
-
- def __delitem__(self, key):
- if not self.exists(key):
- raise KeyError, '%s: %s' % (key, self.errorstr())
- self.delete(key)
-
- def __contains__(self, key):
- return self.exists(key) != 0
-
- def has_key(self, key):
- return self.exists(key) != 0
-
- def fetch_uint32(self, key):
- data = self.get(key)
- if data is None:
- return None
- import struct
- return struct.unpack("<L", data)[0]
-
- def fetch_int32(self, key):
- data = self.get(key)
- if data is None:
- return None
- import struct
- return struct.unpack("<l", data)[0]
-
- # Tdb iterator
- class TdbIterator:
- def __init__(self, tdb):
- self.tdb = tdb
- self.key = None
-
- def __iter__(self):
- return self
-
- def next(self):
- if self.key is None:
- self.key = self.tdb.firstkey()
- if self.key is None:
- raise StopIteration
- return self.key
- else:
- self.key = self.tdb.nextkey(self.key)
- if self.key is None:
- raise StopIteration
- return self.key
-
- def __iter__(self):
- return self.TdbIterator(self)
-
- # Implement other dict functions using TdbIterator
-
- def keys(self):
- return [k for k in iter(self)]
-
- def values(self):
- return [self[k] for k in iter(self)]
-
- def items(self):
- return [(k, self[k]) for k in iter(self)]
-
- def __len__(self):
- return len(self.keys())
-
- def clear(self):
- for k in iter(self):
- del(self[k])
-
- def iterkeys(self):
- for k in iter(self):
- yield k
-
- def itervalues(self):
- for k in iter(self):
- yield self[k]
-
- def iteritems(self):
- for k in iter(self):
- yield (k, self[k])
-
- # TODO: any other missing methods for container types
- }
-} tdb;
diff --git a/source4/lib/tdb/tdb.mk b/source4/lib/tdb/tdb.mk
deleted file mode 100644
index fa8db6d34c..0000000000
--- a/source4/lib/tdb/tdb.mk
+++ /dev/null
@@ -1,86 +0,0 @@
-dirs::
- @mkdir -p bin common tools
-
-PROGS = bin/tdbtool$(EXEEXT) bin/tdbdump$(EXEEXT) bin/tdbbackup$(EXEEXT)
-PROGS_NOINSTALL = bin/tdbtest$(EXEEXT) bin/tdbtorture$(EXEEXT)
-ALL_PROGS = $(PROGS) $(PROGS_NOINSTALL)
-
-TDB_SONAME = libtdb.$(SHLIBEXT).1
-TDB_SOLIB = libtdb.$(SHLIBEXT).$(PACKAGE_VERSION)
-
-TDB_LIB = libtdb.a
-
-bin/tdbtest$(EXEEXT): tools/tdbtest.o $(TDB_LIB)
- $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtest tools/tdbtest.o -L. -ltdb -lgdbm
-
-bin/tdbtool$(EXEEXT): tools/tdbtool.o $(TDB_LIB)
- $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtool tools/tdbtool.o -L. -ltdb
-
-bin/tdbtorture$(EXEEXT): tools/tdbtorture.o $(TDB_LIB)
- $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtorture tools/tdbtorture.o -L. -ltdb
-
-bin/tdbdump$(EXEEXT): tools/tdbdump.o $(TDB_LIB)
- $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbdump tools/tdbdump.o -L. -ltdb
-
-bin/tdbbackup$(EXEEXT): tools/tdbbackup.o $(TDB_LIB)
- $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbbackup tools/tdbbackup.o -L. -ltdb
-
-test:: bin/tdbtorture$(EXEEXT) $(TDB_SONAME)
- $(LIB_PATH_VAR)=. bin/tdbtorture$(EXEEXT)
-
-clean::
- rm -f test.db test.tdb torture.tdb test.gdbm
- rm -f $(TDB_SONAME) $(TDB_SOLIB) libtdb.a libtdb.$(SHLIBEXT)
- rm -f $(ALL_PROGS) tdb.pc
-
-build-python:: _tdb.$(SHLIBEXT)
-
-tdb_wrap.o: $(tdbdir)/tdb_wrap.c
- $(CC) $(PICFLAG) -c $(tdbdir)/tdb_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags`
-
-_tdb.$(SHLIBEXT): libtdb.$(SHLIBEXT) tdb_wrap.o
- $(SHLD) $(SHLD_FLAGS) -o $@ tdb_wrap.o -L. -ltdb `$(PYTHON_CONFIG) --ldflags`
-
-install:: installdirs installbin installheaders installlibs \
- $(PYTHON_INSTALL_TARGET)
-
-install-python:: build-python
- mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` \
- $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"`
- cp $(tdbdir)/tdb.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"`
- cp _tdb.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"`
-
-check-python:: build-python $(TDB_SONAME)
- $(LIB_PATH_VAR)=. PYTHONPATH=".:$(tdbdir)" $(PYTHON) $(tdbdir)/python/tests/simple.py
-
-install-swig::
- mkdir -p $(DESTDIR)`$(SWIG) -swiglib`
- cp tdb.i $(DESTDIR)`$(SWIG) -swiglib`
-
-clean::
- rm -f _tdb.$(SHLIBEXT)
-
-installdirs::
- mkdir -p $(DESTDIR)$(bindir)
- mkdir -p $(DESTDIR)$(includedir)
- mkdir -p $(DESTDIR)$(libdir)
- mkdir -p $(DESTDIR)$(libdir)/pkgconfig
-
-installbin:: all installdirs
- cp $(PROGS) $(DESTDIR)$(bindir)
-
-installheaders:: installdirs
- cp $(srcdir)/include/tdb.h $(DESTDIR)$(includedir)
-
-installlibs:: all installdirs
- cp tdb.pc $(DESTDIR)$(libdir)/pkgconfig
- cp libtdb.a $(TDB_SOLIB) $(DESTDIR)$(libdir)
-
-libtdb.a: $(TDB_OBJ)
- ar -rv libtdb.a $(TDB_OBJ)
-
-libtdb.$(SHLIBEXT): $(TDB_SOLIB)
- ln -fs $< $@
-
-$(TDB_SONAME): $(TDB_SOLIB)
- ln -fs $< $@
diff --git a/source4/lib/tdb/tdb.pc.in b/source4/lib/tdb/tdb.pc.in
deleted file mode 100644
index 6f8f553736..0000000000
--- a/source4/lib/tdb/tdb.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: tdb
-Description: A trivial database
-Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -ltdb
-Cflags: -I${includedir}
-URL: http://tdb.samba.org/
diff --git a/source4/lib/tdb/tdb.py b/source4/lib/tdb/tdb.py
deleted file mode 100644
index 9f306bab8c..0000000000
--- a/source4/lib/tdb/tdb.py
+++ /dev/null
@@ -1,341 +0,0 @@
-# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.35
-#
-# Don't modify this file, modify the SWIG interface instead.
-
-"""
-TDB is a simple key-value database similar to GDBM that supports multiple writers.
-"""
-
-import _tdb
-import new
-new_instancemethod = new.instancemethod
-try:
- _swig_property = property
-except NameError:
- pass # Python < 2.2 doesn't have 'property'.
-def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
- if (name == "thisown"): return self.this.own(value)
- if (name == "this"):
- if type(value).__name__ == 'PySwigObject':
- self.__dict__[name] = value
- return
- method = class_type.__swig_setmethods__.get(name,None)
- if method: return method(self,value)
- if (not static) or hasattr(self,name):
- self.__dict__[name] = value
- else:
- raise AttributeError("You cannot add attributes to %s" % self)
-
-def _swig_setattr(self,class_type,name,value):
- return _swig_setattr_nondynamic(self,class_type,name,value,0)
-
-def _swig_getattr(self,class_type,name):
- if (name == "thisown"): return self.this.own()
- method = class_type.__swig_getmethods__.get(name,None)
- if method: return method(self)
- raise AttributeError,name
-
-def _swig_repr(self):
- try: strthis = "proxy of " + self.this.__repr__()
- except: strthis = ""
- return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
-
-import types
-try:
- _object = types.ObjectType
- _newclass = 1
-except AttributeError:
- class _object : pass
- _newclass = 0
-del types
-
-
-def _swig_setattr_nondynamic_method(set):
- def set_attr(self,name,value):
- if (name == "thisown"): return self.this.own(value)
- if hasattr(self,name) or (name == "this"):
- set(self,name,value)
- else:
- raise AttributeError("You cannot add attributes to %s" % self)
- return set_attr
-
-
-REPLACE = _tdb.REPLACE
-INSERT = _tdb.INSERT
-MODIFY = _tdb.MODIFY
-DEFAULT = _tdb.DEFAULT
-CLEAR_IF_FIRST = _tdb.CLEAR_IF_FIRST
-INTERNAL = _tdb.INTERNAL
-NOLOCK = _tdb.NOLOCK
-NOMMAP = _tdb.NOMMAP
-CONVERT = _tdb.CONVERT
-BIGENDIAN = _tdb.BIGENDIAN
-TDB_SUCCESS = _tdb.TDB_SUCCESS
-TDB_ERR_CORRUPT = _tdb.TDB_ERR_CORRUPT
-TDB_ERR_IO = _tdb.TDB_ERR_IO
-TDB_ERR_LOCK = _tdb.TDB_ERR_LOCK
-TDB_ERR_OOM = _tdb.TDB_ERR_OOM
-TDB_ERR_EXISTS = _tdb.TDB_ERR_EXISTS
-TDB_ERR_NOLOCK = _tdb.TDB_ERR_NOLOCK
-TDB_ERR_LOCK_TIMEOUT = _tdb.TDB_ERR_LOCK_TIMEOUT
-TDB_ERR_NOEXIST = _tdb.TDB_ERR_NOEXIST
-TDB_ERR_EINVAL = _tdb.TDB_ERR_EINVAL
-TDB_ERR_RDONLY = _tdb.TDB_ERR_RDONLY
-class Tdb(object):
- """A TDB file."""
- thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
- __repr__ = _swig_repr
- def __init__(self, *args, **kwargs):
- """
- S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)
- Open a TDB file.
- """
- _tdb.Tdb_swiginit(self,_tdb.new_Tdb(*args, **kwargs))
- def error(*args, **kwargs):
- """
- S.error() -> int
- Find last error number returned by operation on this TDB.
- """
- return _tdb.Tdb_error(*args, **kwargs)
-
- __swig_destroy__ = _tdb.delete_Tdb
- def close(*args, **kwargs):
- """
- S.close() -> None
- Close the TDB file.
- """
- return _tdb.Tdb_close(*args, **kwargs)
-
- def errorstr(*args, **kwargs):
- """
- S.errorstr() -> errorstring
- Obtain last error message.
- """
- return _tdb.Tdb_errorstr(*args, **kwargs)
-
- def get(*args, **kwargs):
- """
- S.fetch(key) -> value
- Fetch a value.
- """
- return _tdb.Tdb_get(*args, **kwargs)
-
- def delete(*args, **kwargs):
- """
- S.delete(key) -> None
- Delete an entry.
- """
- return _tdb.Tdb_delete(*args, **kwargs)
-
- def store(*args, **kwargs):
- """
- S.store(key, value, flag=TDB_REPLACE) -> None
- Store an entry.
- """
- return _tdb.Tdb_store(*args, **kwargs)
-
- def exists(*args, **kwargs):
- """
- S.exists(key) -> bool
- Check whether key exists in this database.
- """
- return _tdb.Tdb_exists(*args, **kwargs)
-
- def firstkey(*args, **kwargs):
- """
- S.firstkey() -> data
- Return the first key in this database.
- """
- return _tdb.Tdb_firstkey(*args, **kwargs)
-
- def nextkey(*args, **kwargs):
- """
- S.nextkey(prev) -> data
- Return the next key in this database.
- """
- return _tdb.Tdb_nextkey(*args, **kwargs)
-
- def lock_all(*args, **kwargs):
- """S.lockall() -> bool"""
- return _tdb.Tdb_lock_all(*args, **kwargs)
-
- def unlock_all(*args, **kwargs):
- """S.unlockall() -> bool"""
- return _tdb.Tdb_unlock_all(*args, **kwargs)
-
- def reopen(*args, **kwargs):
- """
- S.reopen() -> bool
- Reopen this file.
- """
- return _tdb.Tdb_reopen(*args, **kwargs)
-
- def transaction_start(*args, **kwargs):
- """
- S.transaction_start() -> None
- Start a new transaction.
- """
- return _tdb.Tdb_transaction_start(*args, **kwargs)
-
- def transaction_commit(*args, **kwargs):
- """
- S.transaction_commit() -> None
- Commit the currently active transaction.
- """
- return _tdb.Tdb_transaction_commit(*args, **kwargs)
-
- def transaction_cancel(*args, **kwargs):
- """
- S.transaction_cancel() -> None
- Cancel the currently active transaction.
- """
- return _tdb.Tdb_transaction_cancel(*args, **kwargs)
-
- def hash_size(*args, **kwargs):
- """S.hash_size() -> int"""
- return _tdb.Tdb_hash_size(*args, **kwargs)
-
- def map_size(*args, **kwargs):
- """S.map_size() -> int"""
- return _tdb.Tdb_map_size(*args, **kwargs)
-
- def get_flags(*args, **kwargs):
- """S.get_flags() -> int"""
- return _tdb.Tdb_get_flags(*args, **kwargs)
-
- def set_max_dead(*args, **kwargs):
- """S.set_max_dead(int) -> None"""
- return _tdb.Tdb_set_max_dead(*args, **kwargs)
-
- def name(*args, **kwargs):
- """
- S.name() -> path
- Return filename of this TDB file.
- """
- return _tdb.Tdb_name(*args, **kwargs)
-
- def __repr__(self):
- return "Tdb('%s')" % self.name()
-
-
- def __getitem__(self, key):
- result = self.get(key)
- if result is None:
- raise KeyError, '%s: %s' % (key, self.errorstr())
- return result
-
- def __setitem__(self, key, item):
- if self.store(key, item) == -1:
- raise IOError, self.errorstr()
-
- def __delitem__(self, key):
- if not self.exists(key):
- raise KeyError, '%s: %s' % (key, self.errorstr())
- self.delete(key)
-
- def __contains__(self, key):
- return self.exists(key) != 0
-
- def has_key(self, key):
- return self.exists(key) != 0
-
- def fetch_uint32(self, key):
- data = self.get(key)
- if data is None:
- return None
- import struct
- return struct.unpack("<L", data)[0]
-
- def fetch_int32(self, key):
- data = self.get(key)
- if data is None:
- return None
- import struct
- return struct.unpack("<l", data)[0]
-
-
- class TdbIterator:
- def __init__(self, tdb):
- self.tdb = tdb
- self.key = None
-
- def __iter__(self):
- return self
-
- def next(self):
- if self.key is None:
- self.key = self.tdb.firstkey()
- if self.key is None:
- raise StopIteration
- return self.key
- else:
- self.key = self.tdb.nextkey(self.key)
- if self.key is None:
- raise StopIteration
- return self.key
-
- def __iter__(self):
- return self.TdbIterator(self)
-
-
-
- def keys(self):
- return [k for k in iter(self)]
-
- def values(self):
- return [self[k] for k in iter(self)]
-
- def items(self):
- return [(k, self[k]) for k in iter(self)]
-
- def __len__(self):
- return len(self.keys())
-
- def clear(self):
- for k in iter(self):
- del(self[k])
-
- def iterkeys(self):
- for k in iter(self):
- yield k
-
- def itervalues(self):
- for k in iter(self):
- yield self[k]
-
- def iteritems(self):
- for k in iter(self):
- yield (k, self[k])
-
-
-
-Tdb.error = new_instancemethod(_tdb.Tdb_error,None,Tdb)
-Tdb.close = new_instancemethod(_tdb.Tdb_close,None,Tdb)
-Tdb.append = new_instancemethod(_tdb.Tdb_append,None,Tdb)
-Tdb.errorstr = new_instancemethod(_tdb.Tdb_errorstr,None,Tdb)
-Tdb.get = new_instancemethod(_tdb.Tdb_get,None,Tdb)
-Tdb.delete = new_instancemethod(_tdb.Tdb_delete,None,Tdb)
-Tdb.store = new_instancemethod(_tdb.Tdb_store,None,Tdb)
-Tdb.exists = new_instancemethod(_tdb.Tdb_exists,None,Tdb)
-Tdb.firstkey = new_instancemethod(_tdb.Tdb_firstkey,None,Tdb)
-Tdb.nextkey = new_instancemethod(_tdb.Tdb_nextkey,None,Tdb)
-Tdb.lock_all = new_instancemethod(_tdb.Tdb_lock_all,None,Tdb)
-Tdb.unlock_all = new_instancemethod(_tdb.Tdb_unlock_all,None,Tdb)
-Tdb.read_lock_all = new_instancemethod(_tdb.Tdb_read_lock_all,None,Tdb)
-Tdb.read_unlock_all = new_instancemethod(_tdb.Tdb_read_unlock_all,None,Tdb)
-Tdb.reopen = new_instancemethod(_tdb.Tdb_reopen,None,Tdb)
-Tdb.transaction_start = new_instancemethod(_tdb.Tdb_transaction_start,None,Tdb)
-Tdb.transaction_commit = new_instancemethod(_tdb.Tdb_transaction_commit,None,Tdb)
-Tdb.transaction_cancel = new_instancemethod(_tdb.Tdb_transaction_cancel,None,Tdb)
-Tdb.transaction_recover = new_instancemethod(_tdb.Tdb_transaction_recover,None,Tdb)
-Tdb.hash_size = new_instancemethod(_tdb.Tdb_hash_size,None,Tdb)
-Tdb.map_size = new_instancemethod(_tdb.Tdb_map_size,None,Tdb)
-Tdb.get_flags = new_instancemethod(_tdb.Tdb_get_flags,None,Tdb)
-Tdb.set_max_dead = new_instancemethod(_tdb.Tdb_set_max_dead,None,Tdb)
-Tdb.name = new_instancemethod(_tdb.Tdb_name,None,Tdb)
-Tdb_swigregister = _tdb.Tdb_swigregister
-Tdb_swigregister(Tdb)
-
-
-
diff --git a/source4/lib/tdb/tdb_wrap.c b/source4/lib/tdb/tdb_wrap.c
deleted file mode 100644
index 32665d79fd..0000000000
--- a/source4/lib/tdb/tdb_wrap.c
+++ /dev/null
@@ -1,4307 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.35
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-#define SWIGPYTHON
-#define SWIG_PYTHON_NO_BUILD_NONE
-/* -----------------------------------------------------------------------------
- * This section contains generic SWIG labels for method/variable
- * declarations/attributes, and other compiler dependent labels.
- * ----------------------------------------------------------------------------- */
-
-/* template workaround for compilers that cannot correctly implement the C++ standard */
-#ifndef SWIGTEMPLATEDISAMBIGUATOR
-# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
-# define SWIGTEMPLATEDISAMBIGUATOR template
-# elif defined(__HP_aCC)
-/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
-/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
-# define SWIGTEMPLATEDISAMBIGUATOR template
-# else
-# define SWIGTEMPLATEDISAMBIGUATOR
-# endif
-#endif
-
-/* inline attribute */
-#ifndef SWIGINLINE
-# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
-# define SWIGINLINE inline
-# else
-# define SWIGINLINE
-# endif
-#endif
-
-/* attribute recognised by some compilers to avoid 'unused' warnings */
-#ifndef SWIGUNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define SWIGUNUSED __attribute__ ((__unused__))
-# else
-# define SWIGUNUSED
-# endif
-# elif defined(__ICC)
-# define SWIGUNUSED __attribute__ ((__unused__))
-# else
-# define SWIGUNUSED
-# endif
-#endif
-
-#ifndef SWIGUNUSEDPARM
-# ifdef __cplusplus
-# define SWIGUNUSEDPARM(p)
-# else
-# define SWIGUNUSEDPARM(p) p SWIGUNUSED
-# endif
-#endif
-
-/* internal SWIG method */
-#ifndef SWIGINTERN
-# define SWIGINTERN static SWIGUNUSED
-#endif
-
-/* internal inline SWIG method */
-#ifndef SWIGINTERNINLINE
-# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
-#endif
-
-/* exporting methods */
-#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
-# ifndef GCC_HASCLASSVISIBILITY
-# define GCC_HASCLASSVISIBILITY
-# endif
-#endif
-
-#ifndef SWIGEXPORT
-# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# if defined(STATIC_LINKED)
-# define SWIGEXPORT
-# else
-# define SWIGEXPORT __declspec(dllexport)
-# endif
-# else
-# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
-# define SWIGEXPORT __attribute__ ((visibility("default")))
-# else
-# define SWIGEXPORT
-# endif
-# endif
-#endif
-
-/* calling conventions for Windows */
-#ifndef SWIGSTDCALL
-# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# define SWIGSTDCALL __stdcall
-# else
-# define SWIGSTDCALL
-# endif
-#endif
-
-/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
-#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
-# define _CRT_SECURE_NO_DEPRECATE
-#endif
-
-/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
-#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
-# define _SCL_SECURE_NO_DEPRECATE
-#endif
-
-
-
-/* Python.h has to appear first */
-#include <Python.h>
-
-/* -----------------------------------------------------------------------------
- * swigrun.swg
- *
- * This file contains generic CAPI SWIG runtime support for pointer
- * type checking.
- * ----------------------------------------------------------------------------- */
-
-/* This should only be incremented when either the layout of swig_type_info changes,
- or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "4"
-
-/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
-#ifdef SWIG_TYPE_TABLE
-# define SWIG_QUOTE_STRING(x) #x
-# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
-# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
-#else
-# define SWIG_TYPE_TABLE_NAME
-#endif
-
-/*
- You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
- creating a static or dynamic library from the swig runtime code.
- In 99.9% of the cases, swig just needs to declare them as 'static'.
-
- But only do this if is strictly necessary, ie, if you have problems
- with your compiler or so.
-*/
-
-#ifndef SWIGRUNTIME
-# define SWIGRUNTIME SWIGINTERN
-#endif
-
-#ifndef SWIGRUNTIMEINLINE
-# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
-#endif
-
-/* Generic buffer size */
-#ifndef SWIG_BUFFER_SIZE
-# define SWIG_BUFFER_SIZE 1024
-#endif
-
-/* Flags for pointer conversions */
-#define SWIG_POINTER_DISOWN 0x1
-#define SWIG_CAST_NEW_MEMORY 0x2
-
-/* Flags for new pointer objects */
-#define SWIG_POINTER_OWN 0x1
-
-
-/*
- Flags/methods for returning states.
-
- The swig conversion methods, as ConvertPtr, return and integer
- that tells if the conversion was successful or not. And if not,
- an error code can be returned (see swigerrors.swg for the codes).
-
- Use the following macros/flags to set or process the returning
- states.
-
- In old swig versions, you usually write code as:
-
- if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
- // success code
- } else {
- //fail code
- }
-
- Now you can be more explicit as:
-
- int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
- if (SWIG_IsOK(res)) {
- // success code
- } else {
- // fail code
- }
-
- that seems to be the same, but now you can also do
-
- Type *ptr;
- int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
- if (SWIG_IsOK(res)) {
- // success code
- if (SWIG_IsNewObj(res) {
- ...
- delete *ptr;
- } else {
- ...
- }
- } else {
- // fail code
- }
-
- I.e., now SWIG_ConvertPtr can return new objects and you can
- identify the case and take care of the deallocation. Of course that
- requires also to SWIG_ConvertPtr to return new result values, as
-
- int SWIG_ConvertPtr(obj, ptr,...) {
- if (<obj is ok>) {
- if (<need new object>) {
- *ptr = <ptr to new allocated object>;
- return SWIG_NEWOBJ;
- } else {
- *ptr = <ptr to old object>;
- return SWIG_OLDOBJ;
- }
- } else {
- return SWIG_BADOBJ;
- }
- }
-
- Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
- more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
- swig errors code.
-
- Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
- allows to return the 'cast rank', for example, if you have this
-
- int food(double)
- int fooi(int);
-
- and you call
-
- food(1) // cast rank '1' (1 -> 1.0)
- fooi(1) // cast rank '0'
-
- just use the SWIG_AddCast()/SWIG_CheckState()
-
-
- */
-#define SWIG_OK (0)
-#define SWIG_ERROR (-1)
-#define SWIG_IsOK(r) (r >= 0)
-#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
-
-/* The CastRankLimit says how many bits are used for the cast rank */
-#define SWIG_CASTRANKLIMIT (1 << 8)
-/* The NewMask denotes the object was created (using new/malloc) */
-#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
-/* The TmpMask is for in/out typemaps that use temporal objects */
-#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
-/* Simple returning values */
-#define SWIG_BADOBJ (SWIG_ERROR)
-#define SWIG_OLDOBJ (SWIG_OK)
-#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
-#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
-/* Check, add and del mask methods */
-#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
-#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
-#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
-#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
-#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
-#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
-
-
-/* Cast-Rank Mode */
-#if defined(SWIG_CASTRANK_MODE)
-# ifndef SWIG_TypeRank
-# define SWIG_TypeRank unsigned long
-# endif
-# ifndef SWIG_MAXCASTRANK /* Default cast allowed */
-# define SWIG_MAXCASTRANK (2)
-# endif
-# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
-# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
-SWIGINTERNINLINE int SWIG_AddCast(int r) {
- return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
-}
-SWIGINTERNINLINE int SWIG_CheckState(int r) {
- return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
-}
-#else /* no cast-rank mode */
-# define SWIG_AddCast
-# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
-#endif
-
-
-
-
-#include <string.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void *(*swig_converter_func)(void *, int *);
-typedef struct swig_type_info *(*swig_dycast_func)(void **);
-
-/* Structure to store information on one type */
-typedef struct swig_type_info {
- const char *name; /* mangled name of this type */
- const char *str; /* human readable name of this type */
- swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
- struct swig_cast_info *cast; /* linked list of types that can cast into this type */
- void *clientdata; /* language specific type data */
- int owndata; /* flag if the structure owns the clientdata */
-} swig_type_info;
-
-/* Structure to store a type and conversion function used for casting */
-typedef struct swig_cast_info {
- swig_type_info *type; /* pointer to type that is equivalent to this type */
- swig_converter_func converter; /* function to cast the void pointers */
- struct swig_cast_info *next; /* pointer to next cast in linked list */
- struct swig_cast_info *prev; /* pointer to the previous cast */
-} swig_cast_info;
-
-/* Structure used to store module information
- * Each module generates one structure like this, and the runtime collects
- * all of these structures and stores them in a circularly linked list.*/
-typedef struct swig_module_info {
- swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
- size_t size; /* Number of types in this module */
- struct swig_module_info *next; /* Pointer to next element in circularly linked list */
- swig_type_info **type_initial; /* Array of initially generated type structures */
- swig_cast_info **cast_initial; /* Array of initially generated casting structures */
- void *clientdata; /* Language specific module data */
-} swig_module_info;
-
-/*
- Compare two type names skipping the space characters, therefore
- "char*" == "char *" and "Class<int>" == "Class<int >", etc.
-
- Return 0 when the two name types are equivalent, as in
- strncmp, but skipping ' '.
-*/
-SWIGRUNTIME int
-SWIG_TypeNameComp(const char *f1, const char *l1,
- const char *f2, const char *l2) {
- for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
- while ((*f1 == ' ') && (f1 != l1)) ++f1;
- while ((*f2 == ' ') && (f2 != l2)) ++f2;
- if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
- }
- return (int)((l1 - f1) - (l2 - f2));
-}
-
-/*
- Check type equivalence in a name list like <name1>|<name2>|...
- Return 0 if not equal, 1 if equal
-*/
-SWIGRUNTIME int
-SWIG_TypeEquiv(const char *nb, const char *tb) {
- int equiv = 0;
- const char* te = tb + strlen(tb);
- const char* ne = nb;
- while (!equiv && *ne) {
- for (nb = ne; *ne; ++ne) {
- if (*ne == '|') break;
- }
- equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
- if (*ne) ++ne;
- }
- return equiv;
-}
-
-/*
- Check type equivalence in a name list like <name1>|<name2>|...
- Return 0 if equal, -1 if nb < tb, 1 if nb > tb
-*/
-SWIGRUNTIME int
-SWIG_TypeCompare(const char *nb, const char *tb) {
- int equiv = 0;
- const char* te = tb + strlen(tb);
- const char* ne = nb;
- while (!equiv && *ne) {
- for (nb = ne; *ne; ++ne) {
- if (*ne == '|') break;
- }
- equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
- if (*ne) ++ne;
- }
- return equiv;
-}
-
-
-/* think of this as a c++ template<> or a scheme macro */
-#define SWIG_TypeCheck_Template(comparison, ty) \
- if (ty) { \
- swig_cast_info *iter = ty->cast; \
- while (iter) { \
- if (comparison) { \
- if (iter == ty->cast) return iter; \
- /* Move iter to the top of the linked list */ \
- iter->prev->next = iter->next; \
- if (iter->next) \
- iter->next->prev = iter->prev; \
- iter->next = ty->cast; \
- iter->prev = 0; \
- if (ty->cast) ty->cast->prev = iter; \
- ty->cast = iter; \
- return iter; \
- } \
- iter = iter->next; \
- } \
- } \
- return 0
-
-/*
- Check the typename
-*/
-SWIGRUNTIME swig_cast_info *
-SWIG_TypeCheck(const char *c, swig_type_info *ty) {
- SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
-}
-
-/* Same as previous function, except strcmp is replaced with a pointer comparison */
-SWIGRUNTIME swig_cast_info *
-SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
- SWIG_TypeCheck_Template(iter->type == from, into);
-}
-
-/*
- Cast a pointer up an inheritance hierarchy
-*/
-SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
-}
-
-/*
- Dynamic pointer casting. Down an inheritance hierarchy
-*/
-SWIGRUNTIME swig_type_info *
-SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
- swig_type_info *lastty = ty;
- if (!ty || !ty->dcast) return ty;
- while (ty && (ty->dcast)) {
- ty = (*ty->dcast)(ptr);
- if (ty) lastty = ty;
- }
- return lastty;
-}
-
-/*
- Return the name associated with this type
-*/
-SWIGRUNTIMEINLINE const char *
-SWIG_TypeName(const swig_type_info *ty) {
- return ty->name;
-}
-
-/*
- Return the pretty name associated with this type,
- that is an unmangled type name in a form presentable to the user.
-*/
-SWIGRUNTIME const char *
-SWIG_TypePrettyName(const swig_type_info *type) {
- /* The "str" field contains the equivalent pretty names of the
- type, separated by vertical-bar characters. We choose
- to print the last name, as it is often (?) the most
- specific. */
- if (!type) return NULL;
- if (type->str != NULL) {
- const char *last_name = type->str;
- const char *s;
- for (s = type->str; *s; s++)
- if (*s == '|') last_name = s+1;
- return last_name;
- }
- else
- return type->name;
-}
-
-/*
- Set the clientdata field for a type
-*/
-SWIGRUNTIME void
-SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
- swig_cast_info *cast = ti->cast;
- /* if (ti->clientdata == clientdata) return; */
- ti->clientdata = clientdata;
-
- while (cast) {
- if (!cast->converter) {
- swig_type_info *tc = cast->type;
- if (!tc->clientdata) {
- SWIG_TypeClientData(tc, clientdata);
- }
- }
- cast = cast->next;
- }
-}
-SWIGRUNTIME void
-SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
- SWIG_TypeClientData(ti, clientdata);
- ti->owndata = 1;
-}
-
-/*
- Search for a swig_type_info structure only by mangled name
- Search is a O(log #types)
-
- We start searching at module start, and finish searching when start == end.
- Note: if start == end at the beginning of the function, we go all the way around
- the circular list.
-*/
-SWIGRUNTIME swig_type_info *
-SWIG_MangledTypeQueryModule(swig_module_info *start,
- swig_module_info *end,
- const char *name) {
- swig_module_info *iter = start;
- do {
- if (iter->size) {
- register size_t l = 0;
- register size_t r = iter->size - 1;
- do {
- /* since l+r >= 0, we can (>> 1) instead (/ 2) */
- register size_t i = (l + r) >> 1;
- const char *iname = iter->types[i]->name;
- if (iname) {
- register int compare = strcmp(name, iname);
- if (compare == 0) {
- return iter->types[i];
- } else if (compare < 0) {
- if (i) {
- r = i - 1;
- } else {
- break;
- }
- } else if (compare > 0) {
- l = i + 1;
- }
- } else {
- break; /* should never happen */
- }
- } while (l <= r);
- }
- iter = iter->next;
- } while (iter != end);
- return 0;
-}
-
-/*
- Search for a swig_type_info structure for either a mangled name or a human readable name.
- It first searches the mangled names of the types, which is a O(log #types)
- If a type is not found it then searches the human readable names, which is O(#types).
-
- We start searching at module start, and finish searching when start == end.
- Note: if start == end at the beginning of the function, we go all the way around
- the circular list.
-*/
-SWIGRUNTIME swig_type_info *
-SWIG_TypeQueryModule(swig_module_info *start,
- swig_module_info *end,
- const char *name) {
- /* STEP 1: Search the name field using binary search */
- swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
- if (ret) {
- return ret;
- } else {
- /* STEP 2: If the type hasn't been found, do a complete search
- of the str field (the human readable name) */
- swig_module_info *iter = start;
- do {
- register size_t i = 0;
- for (; i < iter->size; ++i) {
- if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
- return iter->types[i];
- }
- iter = iter->next;
- } while (iter != end);
- }
-
- /* neither found a match */
- return 0;
-}
-
-/*
- Pack binary data into a string
-*/
-SWIGRUNTIME char *
-SWIG_PackData(char *c, void *ptr, size_t sz) {
- static const char hex[17] = "0123456789abcdef";
- register const unsigned char *u = (unsigned char *) ptr;
- register const unsigned char *eu = u + sz;
- for (; u != eu; ++u) {
- register unsigned char uu = *u;
- *(c++) = hex[(uu & 0xf0) >> 4];
- *(c++) = hex[uu & 0xf];
- }
- return c;
-}
-
-/*
- Unpack binary data from a string
-*/
-SWIGRUNTIME const char *
-SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
- register unsigned char *u = (unsigned char *) ptr;
- register const unsigned char *eu = u + sz;
- for (; u != eu; ++u) {
- register char d = *(c++);
- register unsigned char uu;
- if ((d >= '0') && (d <= '9'))
- uu = ((d - '0') << 4);
- else if ((d >= 'a') && (d <= 'f'))
- uu = ((d - ('a'-10)) << 4);
- else
- return (char *) 0;
- d = *(c++);
- if ((d >= '0') && (d <= '9'))
- uu |= (d - '0');
- else if ((d >= 'a') && (d <= 'f'))
- uu |= (d - ('a'-10));
- else
- return (char *) 0;
- *u = uu;
- }
- return c;
-}
-
-/*
- Pack 'void *' into a string buffer.
-*/
-SWIGRUNTIME char *
-SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
- char *r = buff;
- if ((2*sizeof(void *) + 2) > bsz) return 0;
- *(r++) = '_';
- r = SWIG_PackData(r,&ptr,sizeof(void *));
- if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
- strcpy(r,name);
- return buff;
-}
-
-SWIGRUNTIME const char *
-SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
- if (*c != '_') {
- if (strcmp(c,"NULL") == 0) {
- *ptr = (void *) 0;
- return name;
- } else {
- return 0;
- }
- }
- return SWIG_UnpackData(++c,ptr,sizeof(void *));
-}
-
-SWIGRUNTIME char *
-SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
- char *r = buff;
- size_t lname = (name ? strlen(name) : 0);
- if ((2*sz + 2 + lname) > bsz) return 0;
- *(r++) = '_';
- r = SWIG_PackData(r,ptr,sz);
- if (lname) {
- strncpy(r,name,lname+1);
- } else {
- *r = 0;
- }
- return buff;
-}
-
-SWIGRUNTIME const char *
-SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
- if (*c != '_') {
- if (strcmp(c,"NULL") == 0) {
- memset(ptr,0,sz);
- return name;
- } else {
- return 0;
- }
- }
- return SWIG_UnpackData(++c,ptr,sz);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-/* Errors in SWIG */
-#define SWIG_UnknownError -1
-#define SWIG_IOError -2
-#define SWIG_RuntimeError -3
-#define SWIG_IndexError -4
-#define SWIG_TypeError -5
-#define SWIG_DivisionByZero -6
-#define SWIG_OverflowError -7
-#define SWIG_SyntaxError -8
-#define SWIG_ValueError -9
-#define SWIG_SystemError -10
-#define SWIG_AttributeError -11
-#define SWIG_MemoryError -12
-#define SWIG_NullReferenceError -13
-
-
-
-
-/* Add PyOS_snprintf for old Pythons */
-#if PY_VERSION_HEX < 0x02020000
-# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
-# define PyOS_snprintf _snprintf
-# else
-# define PyOS_snprintf snprintf
-# endif
-#endif
-
-/* A crude PyString_FromFormat implementation for old Pythons */
-#if PY_VERSION_HEX < 0x02020000
-
-#ifndef SWIG_PYBUFFER_SIZE
-# define SWIG_PYBUFFER_SIZE 1024
-#endif
-
-static PyObject *
-PyString_FromFormat(const char *fmt, ...) {
- va_list ap;
- char buf[SWIG_PYBUFFER_SIZE * 2];
- int res;
- va_start(ap, fmt);
- res = vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);
-}
-#endif
-
-/* Add PyObject_Del for old Pythons */
-#if PY_VERSION_HEX < 0x01060000
-# define PyObject_Del(op) PyMem_DEL((op))
-#endif
-#ifndef PyObject_DEL
-# define PyObject_DEL PyObject_Del
-#endif
-
-/* A crude PyExc_StopIteration exception for old Pythons */
-#if PY_VERSION_HEX < 0x02020000
-# ifndef PyExc_StopIteration
-# define PyExc_StopIteration PyExc_RuntimeError
-# endif
-# ifndef PyObject_GenericGetAttr
-# define PyObject_GenericGetAttr 0
-# endif
-#endif
-/* Py_NotImplemented is defined in 2.1 and up. */
-#if PY_VERSION_HEX < 0x02010000
-# ifndef Py_NotImplemented
-# define Py_NotImplemented PyExc_RuntimeError
-# endif
-#endif
-
-
-/* A crude PyString_AsStringAndSize implementation for old Pythons */
-#if PY_VERSION_HEX < 0x02010000
-# ifndef PyString_AsStringAndSize
-# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
-# endif
-#endif
-
-/* PySequence_Size for old Pythons */
-#if PY_VERSION_HEX < 0x02000000
-# ifndef PySequence_Size
-# define PySequence_Size PySequence_Length
-# endif
-#endif
-
-
-/* PyBool_FromLong for old Pythons */
-#if PY_VERSION_HEX < 0x02030000
-static
-PyObject *PyBool_FromLong(long ok)
-{
- PyObject *result = ok ? Py_True : Py_False;
- Py_INCREF(result);
- return result;
-}
-#endif
-
-/* Py_ssize_t for old Pythons */
-/* This code is as recommended by: */
-/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
-#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
-typedef int Py_ssize_t;
-# define PY_SSIZE_T_MAX INT_MAX
-# define PY_SSIZE_T_MIN INT_MIN
-#endif
-
-/* -----------------------------------------------------------------------------
- * error manipulation
- * ----------------------------------------------------------------------------- */
-
-SWIGRUNTIME PyObject*
-SWIG_Python_ErrorType(int code) {
- PyObject* type = 0;
- switch(code) {
- case SWIG_MemoryError:
- type = PyExc_MemoryError;
- break;
- case SWIG_IOError:
- type = PyExc_IOError;
- break;
- case SWIG_RuntimeError:
- type = PyExc_RuntimeError;
- break;
- case SWIG_IndexError:
- type = PyExc_IndexError;
- break;
- case SWIG_TypeError:
- type = PyExc_TypeError;
- break;
- case SWIG_DivisionByZero:
- type = PyExc_ZeroDivisionError;
- break;
- case SWIG_OverflowError:
- type = PyExc_OverflowError;
- break;
- case SWIG_SyntaxError:
- type = PyExc_SyntaxError;
- break;
- case SWIG_ValueError:
- type = PyExc_ValueError;
- break;
- case SWIG_SystemError:
- type = PyExc_SystemError;
- break;
- case SWIG_AttributeError:
- type = PyExc_AttributeError;
- break;
- default:
- type = PyExc_RuntimeError;
- }
- return type;
-}
-
-
-SWIGRUNTIME void
-SWIG_Python_AddErrorMsg(const char* mesg)
-{
- PyObject *type = 0;
- PyObject *value = 0;
- PyObject *traceback = 0;
-
- if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
- if (value) {
- PyObject *old_str = PyObject_Str(value);
- PyErr_Clear();
- Py_XINCREF(type);
- PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
- Py_DECREF(old_str);
- Py_DECREF(value);
- } else {
- PyErr_SetString(PyExc_RuntimeError, mesg);
- }
-}
-
-
-
-#if defined(SWIG_PYTHON_NO_THREADS)
-# if defined(SWIG_PYTHON_THREADS)
-# undef SWIG_PYTHON_THREADS
-# endif
-#endif
-#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */
-# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)
-# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */
-# define SWIG_PYTHON_USE_GIL
-# endif
-# endif
-# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
-# ifndef SWIG_PYTHON_INITIALIZE_THREADS
-# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads()
-# endif
-# ifdef __cplusplus /* C++ code */
- class SWIG_Python_Thread_Block {
- bool status;
- PyGILState_STATE state;
- public:
- void end() { if (status) { PyGILState_Release(state); status = false;} }
- SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
- ~SWIG_Python_Thread_Block() { end(); }
- };
- class SWIG_Python_Thread_Allow {
- bool status;
- PyThreadState *save;
- public:
- void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
- SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
- ~SWIG_Python_Thread_Allow() { end(); }
- };
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block
-# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end()
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow
-# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end()
-# else /* C code */
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
-# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block)
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread()
-# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow)
-# endif
-# else /* Old thread way, not implemented, user must provide it */
-# if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
-# define SWIG_PYTHON_INITIALIZE_THREADS
-# endif
-# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
-# endif
-# if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
-# define SWIG_PYTHON_THREAD_END_BLOCK
-# endif
-# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
-# endif
-# if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
-# define SWIG_PYTHON_THREAD_END_ALLOW
-# endif
-# endif
-#else /* No thread support */
-# define SWIG_PYTHON_INITIALIZE_THREADS
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
-# define SWIG_PYTHON_THREAD_END_BLOCK
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
-# define SWIG_PYTHON_THREAD_END_ALLOW
-#endif
-
-/* -----------------------------------------------------------------------------
- * Python API portion that goes into the runtime
- * ----------------------------------------------------------------------------- */
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-} /* cc-mode */
-#endif
-#endif
-
-/* -----------------------------------------------------------------------------
- * Constant declarations
- * ----------------------------------------------------------------------------- */
-
-/* Constant Types */
-#define SWIG_PY_POINTER 4
-#define SWIG_PY_BINARY 5
-
-/* Constant information structure */
-typedef struct swig_const_info {
- int type;
- char *name;
- long lvalue;
- double dvalue;
- void *pvalue;
- swig_type_info **ptype;
-} swig_const_info;
-
-#ifdef __cplusplus
-#if 0
-{ /* cc-mode */
-#endif
-}
-#endif
-
-
-/* -----------------------------------------------------------------------------
- * See the LICENSE file for information on copyright, usage and redistribution
- * of SWIG, and the README file for authors - http://www.swig.org/release.html.
- *
- * pyrun.swg
- *
- * This file contains the runtime support for Python modules
- * and includes code for managing global variables and pointer
- * type checking.
- *
- * ----------------------------------------------------------------------------- */
-
-/* Common SWIG API */
-
-/* for raw pointers */
-#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
-#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
-#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
-#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags)
-#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty)
-#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src)
-#define swig_owntype int
-
-/* for raw packed data */
-#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
-#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
-
-/* for class or struct pointers */
-#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
-#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
-
-/* for C or C++ function pointers */
-#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
-#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0)
-
-/* for C++ member pointers, ie, member methods */
-#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
-#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
-
-
-/* Runtime API */
-
-#define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
-#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
-#define SWIG_NewClientData(obj) PySwigClientData_New(obj)
-
-#define SWIG_SetErrorObj SWIG_Python_SetErrorObj
-#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
-#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
-#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg)
-#define SWIG_fail goto fail
-
-
-/* Runtime API implementation */
-
-/* Error manipulation */
-
-SWIGINTERN void
-SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
- SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyErr_SetObject(errtype, obj);
- Py_DECREF(obj);
- SWIG_PYTHON_THREAD_END_BLOCK;
-}
-
-SWIGINTERN void
-SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
- SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyErr_SetString(errtype, (char *) msg);
- SWIG_PYTHON_THREAD_END_BLOCK;
-}
-
-#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
-
-/* Set a constant value */
-
-SWIGINTERN void
-SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
- PyDict_SetItemString(d, (char*) name, obj);
- Py_DECREF(obj);
-}
-
-/* Append a value to the result obj */
-
-SWIGINTERN PyObject*
-SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
-#if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
- if (!result) {
- result = obj;
- } else if (result == Py_None) {
- Py_DECREF(result);
- result = obj;
- } else {
- if (!PyList_Check(result)) {
- PyObject *o2 = result;
- result = PyList_New(1);
- PyList_SetItem(result, 0, o2);
- }
- PyList_Append(result,obj);
- Py_DECREF(obj);
- }
- return result;
-#else
- PyObject* o2;
- PyObject* o3;
- if (!result) {
- result = obj;
- } else if (result == Py_None) {
- Py_DECREF(result);
- result = obj;
- } else {
- if (!PyTuple_Check(result)) {
- o2 = result;
- result = PyTuple_New(1);
- PyTuple_SET_ITEM(result, 0, o2);
- }
- o3 = PyTuple_New(1);
- PyTuple_SET_ITEM(o3, 0, obj);
- o2 = result;
- result = PySequence_Concat(o2, o3);
- Py_DECREF(o2);
- Py_DECREF(o3);
- }
- return result;
-#endif
-}
-
-/* Unpack the argument tuple */
-
-SWIGINTERN int
-SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
-{
- if (!args) {
- if (!min && !max) {
- return 1;
- } else {
- PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none",
- name, (min == max ? "" : "at least "), (int)min);
- return 0;
- }
- }
- if (!PyTuple_Check(args)) {
- PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
- return 0;
- } else {
- register Py_ssize_t l = PyTuple_GET_SIZE(args);
- if (l < min) {
- PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
- name, (min == max ? "" : "at least "), (int)min, (int)l);
- return 0;
- } else if (l > max) {
- PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
- name, (min == max ? "" : "at most "), (int)max, (int)l);
- return 0;
- } else {
- register int i;
- for (i = 0; i < l; ++i) {
- objs[i] = PyTuple_GET_ITEM(args, i);
- }
- for (; l < max; ++l) {
- objs[l] = 0;
- }
- return i + 1;
- }
- }
-}
-
-/* A functor is a function object with one single object argument */
-#if PY_VERSION_HEX >= 0x02020000
-#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
-#else
-#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj);
-#endif
-
-/*
- Helper for static pointer initialization for both C and C++ code, for example
- static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
-*/
-#ifdef __cplusplus
-#define SWIG_STATIC_POINTER(var) var
-#else
-#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
-#endif
-
-/* -----------------------------------------------------------------------------
- * Pointer declarations
- * ----------------------------------------------------------------------------- */
-
-/* Flags for new pointer objects */
-#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1)
-#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
-
-#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1)
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-} /* cc-mode */
-#endif
-#endif
-
-/* How to access Py_None */
-#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# ifndef SWIG_PYTHON_NO_BUILD_NONE
-# ifndef SWIG_PYTHON_BUILD_NONE
-# define SWIG_PYTHON_BUILD_NONE
-# endif
-# endif
-#endif
-
-#ifdef SWIG_PYTHON_BUILD_NONE
-# ifdef Py_None
-# undef Py_None
-# define Py_None SWIG_Py_None()
-# endif
-SWIGRUNTIMEINLINE PyObject *
-_SWIG_Py_None(void)
-{
- PyObject *none = Py_BuildValue((char*)"");
- Py_DECREF(none);
- return none;
-}
-SWIGRUNTIME PyObject *
-SWIG_Py_None(void)
-{
- static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
- return none;
-}
-#endif
-
-/* The python void return value */
-
-SWIGRUNTIMEINLINE PyObject *
-SWIG_Py_Void(void)
-{
- PyObject *none = Py_None;
- Py_INCREF(none);
- return none;
-}
-
-/* PySwigClientData */
-
-typedef struct {
- PyObject *klass;
- PyObject *newraw;
- PyObject *newargs;
- PyObject *destroy;
- int delargs;
- int implicitconv;
-} PySwigClientData;
-
-SWIGRUNTIMEINLINE int
-SWIG_Python_CheckImplicit(swig_type_info *ty)
-{
- PySwigClientData *data = (PySwigClientData *)ty->clientdata;
- return data ? data->implicitconv : 0;
-}
-
-SWIGRUNTIMEINLINE PyObject *
-SWIG_Python_ExceptionType(swig_type_info *desc) {
- PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0;
- PyObject *klass = data ? data->klass : 0;
- return (klass ? klass : PyExc_RuntimeError);
-}
-
-
-SWIGRUNTIME PySwigClientData *
-PySwigClientData_New(PyObject* obj)
-{
- if (!obj) {
- return 0;
- } else {
- PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData));
- /* the klass element */
- data->klass = obj;
- Py_INCREF(data->klass);
- /* the newraw method and newargs arguments used to create a new raw instance */
- if (PyClass_Check(obj)) {
- data->newraw = 0;
- data->newargs = obj;
- Py_INCREF(obj);
- } else {
-#if (PY_VERSION_HEX < 0x02020000)
- data->newraw = 0;
-#else
- data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
-#endif
- if (data->newraw) {
- Py_INCREF(data->newraw);
- data->newargs = PyTuple_New(1);
- PyTuple_SetItem(data->newargs, 0, obj);
- } else {
- data->newargs = obj;
- }
- Py_INCREF(data->newargs);
- }
- /* the destroy method, aka as the C++ delete method */
- data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
- if (PyErr_Occurred()) {
- PyErr_Clear();
- data->destroy = 0;
- }
- if (data->destroy) {
- int flags;
- Py_INCREF(data->destroy);
- flags = PyCFunction_GET_FLAGS(data->destroy);
-#ifdef METH_O
- data->delargs = !(flags & (METH_O));
-#else
- data->delargs = 0;
-#endif
- } else {
- data->delargs = 0;
- }
- data->implicitconv = 0;
- return data;
- }
-}
-
-SWIGRUNTIME void
-PySwigClientData_Del(PySwigClientData* data)
-{
- Py_XDECREF(data->newraw);
- Py_XDECREF(data->newargs);
- Py_XDECREF(data->destroy);
-}
-
-/* =============== PySwigObject =====================*/
-
-typedef struct {
- PyObject_HEAD
- void *ptr;
- swig_type_info *ty;
- int own;
- PyObject *next;
-} PySwigObject;
-
-SWIGRUNTIME PyObject *
-PySwigObject_long(PySwigObject *v)
-{
- return PyLong_FromVoidPtr(v->ptr);
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_format(const char* fmt, PySwigObject *v)
-{
- PyObject *res = NULL;
- PyObject *args = PyTuple_New(1);
- if (args) {
- if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) {
- PyObject *ofmt = PyString_FromString(fmt);
- if (ofmt) {
- res = PyString_Format(ofmt,args);
- Py_DECREF(ofmt);
- }
- Py_DECREF(args);
- }
- }
- return res;
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_oct(PySwigObject *v)
-{
- return PySwigObject_format("%o",v);
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_hex(PySwigObject *v)
-{
- return PySwigObject_format("%x",v);
-}
-
-SWIGRUNTIME PyObject *
-#ifdef METH_NOARGS
-PySwigObject_repr(PySwigObject *v)
-#else
-PySwigObject_repr(PySwigObject *v, PyObject *args)
-#endif
-{
- const char *name = SWIG_TypePrettyName(v->ty);
- PyObject *hex = PySwigObject_hex(v);
- PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex));
- Py_DECREF(hex);
- if (v->next) {
-#ifdef METH_NOARGS
- PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next);
-#else
- PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args);
-#endif
- PyString_ConcatAndDel(&repr,nrep);
- }
- return repr;
-}
-
-SWIGRUNTIME int
-PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
-{
-#ifdef METH_NOARGS
- PyObject *repr = PySwigObject_repr(v);
-#else
- PyObject *repr = PySwigObject_repr(v, NULL);
-#endif
- if (repr) {
- fputs(PyString_AsString(repr), fp);
- Py_DECREF(repr);
- return 0;
- } else {
- return 1;
- }
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_str(PySwigObject *v)
-{
- char result[SWIG_BUFFER_SIZE];
- return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
- PyString_FromString(result) : 0;
-}
-
-SWIGRUNTIME int
-PySwigObject_compare(PySwigObject *v, PySwigObject *w)
-{
- void *i = v->ptr;
- void *j = w->ptr;
- return (i < j) ? -1 : ((i > j) ? 1 : 0);
-}
-
-SWIGRUNTIME PyTypeObject* _PySwigObject_type(void);
-
-SWIGRUNTIME PyTypeObject*
-PySwigObject_type(void) {
- static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type();
- return type;
-}
-
-SWIGRUNTIMEINLINE int
-PySwigObject_Check(PyObject *op) {
- return ((op)->ob_type == PySwigObject_type())
- || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0);
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_New(void *ptr, swig_type_info *ty, int own);
-
-SWIGRUNTIME void
-PySwigObject_dealloc(PyObject *v)
-{
- PySwigObject *sobj = (PySwigObject *) v;
- PyObject *next = sobj->next;
- if (sobj->own == SWIG_POINTER_OWN) {
- swig_type_info *ty = sobj->ty;
- PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
- PyObject *destroy = data ? data->destroy : 0;
- if (destroy) {
- /* destroy is always a VARARGS method */
- PyObject *res;
- if (data->delargs) {
- /* we need to create a temporal object to carry the destroy operation */
- PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0);
- res = SWIG_Python_CallFunctor(destroy, tmp);
- Py_DECREF(tmp);
- } else {
- PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
- PyObject *mself = PyCFunction_GET_SELF(destroy);
- res = ((*meth)(mself, v));
- }
- Py_XDECREF(res);
- }
-#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- else {
- const char *name = SWIG_TypePrettyName(ty);
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
- }
-#endif
- }
- Py_XDECREF(next);
- PyObject_DEL(v);
-}
-
-SWIGRUNTIME PyObject*
-PySwigObject_append(PyObject* v, PyObject* next)
-{
- PySwigObject *sobj = (PySwigObject *) v;
-#ifndef METH_O
- PyObject *tmp = 0;
- if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
- next = tmp;
-#endif
- if (!PySwigObject_Check(next)) {
- return NULL;
- }
- sobj->next = next;
- Py_INCREF(next);
- return SWIG_Py_Void();
-}
-
-SWIGRUNTIME PyObject*
-#ifdef METH_NOARGS
-PySwigObject_next(PyObject* v)
-#else
-PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
-#endif
-{
- PySwigObject *sobj = (PySwigObject *) v;
- if (sobj->next) {
- Py_INCREF(sobj->next);
- return sobj->next;
- } else {
- return SWIG_Py_Void();
- }
-}
-
-SWIGINTERN PyObject*
-#ifdef METH_NOARGS
-PySwigObject_disown(PyObject *v)
-#else
-PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
-#endif
-{
- PySwigObject *sobj = (PySwigObject *)v;
- sobj->own = 0;
- return SWIG_Py_Void();
-}
-
-SWIGINTERN PyObject*
-#ifdef METH_NOARGS
-PySwigObject_acquire(PyObject *v)
-#else
-PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
-#endif
-{
- PySwigObject *sobj = (PySwigObject *)v;
- sobj->own = SWIG_POINTER_OWN;
- return SWIG_Py_Void();
-}
-
-SWIGINTERN PyObject*
-PySwigObject_own(PyObject *v, PyObject *args)
-{
- PyObject *val = 0;
-#if (PY_VERSION_HEX < 0x02020000)
- if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
-#else
- if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val))
-#endif
- {
- return NULL;
- }
- else
- {
- PySwigObject *sobj = (PySwigObject *)v;
- PyObject *obj = PyBool_FromLong(sobj->own);
- if (val) {
-#ifdef METH_NOARGS
- if (PyObject_IsTrue(val)) {
- PySwigObject_acquire(v);
- } else {
- PySwigObject_disown(v);
- }
-#else
- if (PyObject_IsTrue(val)) {
- PySwigObject_acquire(v,args);
- } else {
- PySwigObject_disown(v,args);
- }
-#endif
- }
- return obj;
- }
-}
-
-#ifdef METH_O
-static PyMethodDef
-swigobject_methods[] = {
- {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
- {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"},
- {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
- {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"},
- {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
- {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"},
- {0, 0, 0, 0}
-};
-#else
-static PyMethodDef
-swigobject_methods[] = {
- {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
- {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"},
- {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
- {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
- {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
- {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"},
- {0, 0, 0, 0}
-};
-#endif
-
-#if PY_VERSION_HEX < 0x02020000
-SWIGINTERN PyObject *
-PySwigObject_getattr(PySwigObject *sobj,char *name)
-{
- return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
-}
-#endif
-
-SWIGRUNTIME PyTypeObject*
-_PySwigObject_type(void) {
- static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
-
- static PyNumberMethods PySwigObject_as_number = {
- (binaryfunc)0, /*nb_add*/
- (binaryfunc)0, /*nb_subtract*/
- (binaryfunc)0, /*nb_multiply*/
- (binaryfunc)0, /*nb_divide*/
- (binaryfunc)0, /*nb_remainder*/
- (binaryfunc)0, /*nb_divmod*/
- (ternaryfunc)0,/*nb_power*/
- (unaryfunc)0, /*nb_negative*/
- (unaryfunc)0, /*nb_positive*/
- (unaryfunc)0, /*nb_absolute*/
- (inquiry)0, /*nb_nonzero*/
- 0, /*nb_invert*/
- 0, /*nb_lshift*/
- 0, /*nb_rshift*/
- 0, /*nb_and*/
- 0, /*nb_xor*/
- 0, /*nb_or*/
- (coercion)0, /*nb_coerce*/
- (unaryfunc)PySwigObject_long, /*nb_int*/
- (unaryfunc)PySwigObject_long, /*nb_long*/
- (unaryfunc)0, /*nb_float*/
- (unaryfunc)PySwigObject_oct, /*nb_oct*/
- (unaryfunc)PySwigObject_hex, /*nb_hex*/
-#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
-#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
-#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */
- 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
-#endif
- };
-
- static PyTypeObject pyswigobject_type;
- static int type_init = 0;
- if (!type_init) {
- const PyTypeObject tmp
- = {
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- (char *)"PySwigObject", /* tp_name */
- sizeof(PySwigObject), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)PySwigObject_dealloc, /* tp_dealloc */
- (printfunc)PySwigObject_print, /* tp_print */
-#if PY_VERSION_HEX < 0x02020000
- (getattrfunc)PySwigObject_getattr, /* tp_getattr */
-#else
- (getattrfunc)0, /* tp_getattr */
-#endif
- (setattrfunc)0, /* tp_setattr */
- (cmpfunc)PySwigObject_compare, /* tp_compare */
- (reprfunc)PySwigObject_repr, /* tp_repr */
- &PySwigObject_as_number, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- (hashfunc)0, /* tp_hash */
- (ternaryfunc)0, /* tp_call */
- (reprfunc)PySwigObject_str, /* tp_str */
- PyObject_GenericGetAttr, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- swigobject_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
-#if PY_VERSION_HEX >= 0x02020000
- 0, /* tp_iter */
- 0, /* tp_iternext */
- swigobject_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
- 0, /* tp_bases */
- 0, /* tp_mro */
- 0, /* tp_cache */
- 0, /* tp_subclasses */
- 0, /* tp_weaklist */
-#endif
-#if PY_VERSION_HEX >= 0x02030000
- 0, /* tp_del */
-#endif
-#ifdef COUNT_ALLOCS
- 0,0,0,0 /* tp_alloc -> tp_next */
-#endif
- };
- pyswigobject_type = tmp;
- pyswigobject_type.ob_type = &PyType_Type;
- type_init = 1;
- }
- return &pyswigobject_type;
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_New(void *ptr, swig_type_info *ty, int own)
-{
- PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type());
- if (sobj) {
- sobj->ptr = ptr;
- sobj->ty = ty;
- sobj->own = own;
- sobj->next = 0;
- }
- return (PyObject *)sobj;
-}
-
-/* -----------------------------------------------------------------------------
- * Implements a simple Swig Packed type, and use it instead of string
- * ----------------------------------------------------------------------------- */
-
-typedef struct {
- PyObject_HEAD
- void *pack;
- swig_type_info *ty;
- size_t size;
-} PySwigPacked;
-
-SWIGRUNTIME int
-PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
-{
- char result[SWIG_BUFFER_SIZE];
- fputs("<Swig Packed ", fp);
- if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
- fputs("at ", fp);
- fputs(result, fp);
- }
- fputs(v->ty->name,fp);
- fputs(">", fp);
- return 0;
-}
-
-SWIGRUNTIME PyObject *
-PySwigPacked_repr(PySwigPacked *v)
-{
- char result[SWIG_BUFFER_SIZE];
- if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
- return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
- } else {
- return PyString_FromFormat("<Swig Packed %s>", v->ty->name);
- }
-}
-
-SWIGRUNTIME PyObject *
-PySwigPacked_str(PySwigPacked *v)
-{
- char result[SWIG_BUFFER_SIZE];
- if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
- return PyString_FromFormat("%s%s", result, v->ty->name);
- } else {
- return PyString_FromString(v->ty->name);
- }
-}
-
-SWIGRUNTIME int
-PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
-{
- size_t i = v->size;
- size_t j = w->size;
- int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
- return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
-}
-
-SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void);
-
-SWIGRUNTIME PyTypeObject*
-PySwigPacked_type(void) {
- static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type();
- return type;
-}
-
-SWIGRUNTIMEINLINE int
-PySwigPacked_Check(PyObject *op) {
- return ((op)->ob_type == _PySwigPacked_type())
- || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0);
-}
-
-SWIGRUNTIME void
-PySwigPacked_dealloc(PyObject *v)
-{
- if (PySwigPacked_Check(v)) {
- PySwigPacked *sobj = (PySwigPacked *) v;
- free(sobj->pack);
- }
- PyObject_DEL(v);
-}
-
-SWIGRUNTIME PyTypeObject*
-_PySwigPacked_type(void) {
- static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
- static PyTypeObject pyswigpacked_type;
- static int type_init = 0;
- if (!type_init) {
- const PyTypeObject tmp
- = {
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- (char *)"PySwigPacked", /* tp_name */
- sizeof(PySwigPacked), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)PySwigPacked_dealloc, /* tp_dealloc */
- (printfunc)PySwigPacked_print, /* tp_print */
- (getattrfunc)0, /* tp_getattr */
- (setattrfunc)0, /* tp_setattr */
- (cmpfunc)PySwigPacked_compare, /* tp_compare */
- (reprfunc)PySwigPacked_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- (hashfunc)0, /* tp_hash */
- (ternaryfunc)0, /* tp_call */
- (reprfunc)PySwigPacked_str, /* tp_str */
- PyObject_GenericGetAttr, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- swigpacked_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
-#if PY_VERSION_HEX >= 0x02020000
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
- 0, /* tp_bases */
- 0, /* tp_mro */
- 0, /* tp_cache */
- 0, /* tp_subclasses */
- 0, /* tp_weaklist */
-#endif
-#if PY_VERSION_HEX >= 0x02030000
- 0, /* tp_del */
-#endif
-#ifdef COUNT_ALLOCS
- 0,0,0,0 /* tp_alloc -> tp_next */
-#endif
- };
- pyswigpacked_type = tmp;
- pyswigpacked_type.ob_type = &PyType_Type;
- type_init = 1;
- }
- return &pyswigpacked_type;
-}
-
-SWIGRUNTIME PyObject *
-PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty)
-{
- PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type());
- if (sobj) {
- void *pack = malloc(size);
- if (pack) {
- memcpy(pack, ptr, size);
- sobj->pack = pack;
- sobj->ty = ty;
- sobj->size = size;
- } else {
- PyObject_DEL((PyObject *) sobj);
- sobj = 0;
- }
- }
- return (PyObject *) sobj;
-}
-
-SWIGRUNTIME swig_type_info *
-PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
-{
- if (PySwigPacked_Check(obj)) {
- PySwigPacked *sobj = (PySwigPacked *)obj;
- if (sobj->size != size) return 0;
- memcpy(ptr, sobj->pack, size);
- return sobj->ty;
- } else {
- return 0;
- }
-}
-
-/* -----------------------------------------------------------------------------
- * pointers/data manipulation
- * ----------------------------------------------------------------------------- */
-
-SWIGRUNTIMEINLINE PyObject *
-_SWIG_This(void)
-{
- return PyString_FromString("this");
-}
-
-SWIGRUNTIME PyObject *
-SWIG_This(void)
-{
- static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
- return swig_this;
-}
-
-/* #define SWIG_PYTHON_SLOW_GETSET_THIS */
-
-SWIGRUNTIME PySwigObject *
-SWIG_Python_GetSwigThis(PyObject *pyobj)
-{
- if (PySwigObject_Check(pyobj)) {
- return (PySwigObject *) pyobj;
- } else {
- PyObject *obj = 0;
-#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
- if (PyInstance_Check(pyobj)) {
- obj = _PyInstance_Lookup(pyobj, SWIG_This());
- } else {
- PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
- if (dictptr != NULL) {
- PyObject *dict = *dictptr;
- obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
- } else {
-#ifdef PyWeakref_CheckProxy
- if (PyWeakref_CheckProxy(pyobj)) {
- PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
- return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
- }
-#endif
- obj = PyObject_GetAttr(pyobj,SWIG_This());
- if (obj) {
- Py_DECREF(obj);
- } else {
- if (PyErr_Occurred()) PyErr_Clear();
- return 0;
- }
- }
- }
-#else
- obj = PyObject_GetAttr(pyobj,SWIG_This());
- if (obj) {
- Py_DECREF(obj);
- } else {
- if (PyErr_Occurred()) PyErr_Clear();
- return 0;
- }
-#endif
- if (obj && !PySwigObject_Check(obj)) {
- /* a PyObject is called 'this', try to get the 'real this'
- PySwigObject from it */
- return SWIG_Python_GetSwigThis(obj);
- }
- return (PySwigObject *)obj;
- }
-}
-
-/* Acquire a pointer value */
-
-SWIGRUNTIME int
-SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own == SWIG_POINTER_OWN) {
- PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
- if (sobj) {
- int oldown = sobj->own;
- sobj->own = own;
- return oldown;
- }
- }
- return 0;
-}
-
-/* Convert a pointer value */
-
-SWIGRUNTIME int
-SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
- if (!obj) return SWIG_ERROR;
- if (obj == Py_None) {
- if (ptr) *ptr = 0;
- return SWIG_OK;
- } else {
- PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
- if (own)
- *own = 0;
- while (sobj) {
- void *vptr = sobj->ptr;
- if (ty) {
- swig_type_info *to = sobj->ty;
- if (to == ty) {
- /* no type cast needed */
- if (ptr) *ptr = vptr;
- break;
- } else {
- swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
- if (!tc) {
- sobj = (PySwigObject *)sobj->next;
- } else {
- if (ptr) {
- int newmemory = 0;
- *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
- if (newmemory == SWIG_CAST_NEW_MEMORY) {
- assert(own);
- if (own)
- *own = *own | SWIG_CAST_NEW_MEMORY;
- }
- }
- break;
- }
- }
- } else {
- if (ptr) *ptr = vptr;
- break;
- }
- }
- if (sobj) {
- if (own)
- *own = *own | sobj->own;
- if (flags & SWIG_POINTER_DISOWN) {
- sobj->own = 0;
- }
- return SWIG_OK;
- } else {
- int res = SWIG_ERROR;
- if (flags & SWIG_POINTER_IMPLICIT_CONV) {
- PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
- if (data && !data->implicitconv) {
- PyObject *klass = data->klass;
- if (klass) {
- PyObject *impconv;
- data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
- impconv = SWIG_Python_CallFunctor(klass, obj);
- data->implicitconv = 0;
- if (PyErr_Occurred()) {
- PyErr_Clear();
- impconv = 0;
- }
- if (impconv) {
- PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv);
- if (iobj) {
- void *vptr;
- res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
- if (SWIG_IsOK(res)) {
- if (ptr) {
- *ptr = vptr;
- /* transfer the ownership to 'ptr' */
- iobj->own = 0;
- res = SWIG_AddCast(res);
- res = SWIG_AddNewMask(res);
- } else {
- res = SWIG_AddCast(res);
- }
- }
- }
- Py_DECREF(impconv);
- }
- }
- }
- }
- return res;
- }
- }
-}
-
-/* Convert a function ptr value */
-
-SWIGRUNTIME int
-SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
- if (!PyCFunction_Check(obj)) {
- return SWIG_ConvertPtr(obj, ptr, ty, 0);
- } else {
- void *vptr = 0;
-
- /* here we get the method pointer for callbacks */
- const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
- const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
- if (desc) {
- desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
- if (!desc) return SWIG_ERROR;
- }
- if (ty) {
- swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (tc) {
- int newmemory = 0;
- *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
- assert(!newmemory); /* newmemory handling not yet implemented */
- } else {
- return SWIG_ERROR;
- }
- } else {
- *ptr = vptr;
- }
- return SWIG_OK;
- }
-}
-
-/* Convert a packed value value */
-
-SWIGRUNTIME int
-SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
- swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz);
- if (!to) return SWIG_ERROR;
- if (ty) {
- if (to != ty) {
- /* check type cast? */
- swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
- if (!tc) return SWIG_ERROR;
- }
- }
- return SWIG_OK;
-}
-
-/* -----------------------------------------------------------------------------
- * Create a new pointer object
- * ----------------------------------------------------------------------------- */
-
-/*
- Create a new instance object, whitout calling __init__, and set the
- 'this' attribute.
-*/
-
-SWIGRUNTIME PyObject*
-SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this)
-{
-#if (PY_VERSION_HEX >= 0x02020000)
- PyObject *inst = 0;
- PyObject *newraw = data->newraw;
- if (newraw) {
- inst = PyObject_Call(newraw, data->newargs, NULL);
- if (inst) {
-#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
- PyObject **dictptr = _PyObject_GetDictPtr(inst);
- if (dictptr != NULL) {
- PyObject *dict = *dictptr;
- if (dict == NULL) {
- dict = PyDict_New();
- *dictptr = dict;
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- }
- }
-#else
- PyObject *key = SWIG_This();
- PyObject_SetAttr(inst, key, swig_this);
-#endif
- }
- } else {
- PyObject *dict = PyDict_New();
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- inst = PyInstance_NewRaw(data->newargs, dict);
- Py_DECREF(dict);
- }
- return inst;
-#else
-#if (PY_VERSION_HEX >= 0x02010000)
- PyObject *inst;
- PyObject *dict = PyDict_New();
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- inst = PyInstance_NewRaw(data->newargs, dict);
- Py_DECREF(dict);
- return (PyObject *) inst;
-#else
- PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
- if (inst == NULL) {
- return NULL;
- }
- inst->in_class = (PyClassObject *)data->newargs;
- Py_INCREF(inst->in_class);
- inst->in_dict = PyDict_New();
- if (inst->in_dict == NULL) {
- Py_DECREF(inst);
- return NULL;
- }
-#ifdef Py_TPFLAGS_HAVE_WEAKREFS
- inst->in_weakreflist = NULL;
-#endif
-#ifdef Py_TPFLAGS_GC
- PyObject_GC_Init(inst);
-#endif
- PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);
- return (PyObject *) inst;
-#endif
-#endif
-}
-
-SWIGRUNTIME void
-SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
-{
- PyObject *dict;
-#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
- PyObject **dictptr = _PyObject_GetDictPtr(inst);
- if (dictptr != NULL) {
- dict = *dictptr;
- if (dict == NULL) {
- dict = PyDict_New();
- *dictptr = dict;
- }
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- return;
- }
-#endif
- dict = PyObject_GetAttrString(inst, (char*)"__dict__");
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- Py_DECREF(dict);
-}
-
-
-SWIGINTERN PyObject *
-SWIG_Python_InitShadowInstance(PyObject *args) {
- PyObject *obj[2];
- if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) {
- return NULL;
- } else {
- PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
- if (sthis) {
- PySwigObject_append((PyObject*) sthis, obj[1]);
- } else {
- SWIG_Python_SetSwigThis(obj[0], obj[1]);
- }
- return SWIG_Py_Void();
- }
-}
-
-/* Create a new pointer object */
-
-SWIGRUNTIME PyObject *
-SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
- if (!ptr) {
- return SWIG_Py_Void();
- } else {
- int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
- PyObject *robj = PySwigObject_New(ptr, type, own);
- PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0;
- if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
- PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
- if (inst) {
- Py_DECREF(robj);
- robj = inst;
- }
- }
- return robj;
- }
-}
-
-/* Create a new packed object */
-
-SWIGRUNTIMEINLINE PyObject *
-SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
- return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
-}
-
-/* -----------------------------------------------------------------------------*
- * Get type list
- * -----------------------------------------------------------------------------*/
-
-#ifdef SWIG_LINK_RUNTIME
-void *SWIG_ReturnGlobalTypeList(void *);
-#endif
-
-SWIGRUNTIME swig_module_info *
-SWIG_Python_GetModule(void) {
- static void *type_pointer = (void *)0;
- /* first check if module already created */
- if (!type_pointer) {
-#ifdef SWIG_LINK_RUNTIME
- type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
-#else
- type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
- (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
- if (PyErr_Occurred()) {
- PyErr_Clear();
- type_pointer = (void *)0;
- }
-#endif
- }
- return (swig_module_info *) type_pointer;
-}
-
-#if PY_MAJOR_VERSION < 2
-/* PyModule_AddObject function was introduced in Python 2.0. The following function
- is copied out of Python/modsupport.c in python version 2.3.4 */
-SWIGINTERN int
-PyModule_AddObject(PyObject *m, char *name, PyObject *o)
-{
- PyObject *dict;
- if (!PyModule_Check(m)) {
- PyErr_SetString(PyExc_TypeError,
- "PyModule_AddObject() needs module as first arg");
- return SWIG_ERROR;
- }
- if (!o) {
- PyErr_SetString(PyExc_TypeError,
- "PyModule_AddObject() needs non-NULL value");
- return SWIG_ERROR;
- }
-
- dict = PyModule_GetDict(m);
- if (dict == NULL) {
- /* Internal error -- modules must have a dict! */
- PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
- PyModule_GetName(m));
- return SWIG_ERROR;
- }
- if (PyDict_SetItemString(dict, name, o))
- return SWIG_ERROR;
- Py_DECREF(o);
- return SWIG_OK;
-}
-#endif
-
-SWIGRUNTIME void
-SWIG_Python_DestroyModule(void *vptr)
-{
- swig_module_info *swig_module = (swig_module_info *) vptr;
- swig_type_info **types = swig_module->types;
- size_t i;
- for (i =0; i < swig_module->size; ++i) {
- swig_type_info *ty = types[i];
- if (ty->owndata) {
- PySwigClientData *data = (PySwigClientData *) ty->clientdata;
- if (data) PySwigClientData_Del(data);
- }
- }
- Py_DECREF(SWIG_This());
-}
-
-SWIGRUNTIME void
-SWIG_Python_SetModule(swig_module_info *swig_module) {
- static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
-
- PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
- swig_empty_runtime_method_table);
- PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
- if (pointer && module) {
- PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
- } else {
- Py_XDECREF(pointer);
- }
-}
-
-/* The python cached type query */
-SWIGRUNTIME PyObject *
-SWIG_Python_TypeCache(void) {
- static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
- return cache;
-}
-
-SWIGRUNTIME swig_type_info *
-SWIG_Python_TypeQuery(const char *type)
-{
- PyObject *cache = SWIG_Python_TypeCache();
- PyObject *key = PyString_FromString(type);
- PyObject *obj = PyDict_GetItem(cache, key);
- swig_type_info *descriptor;
- if (obj) {
- descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
- } else {
- swig_module_info *swig_module = SWIG_Python_GetModule();
- descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
- if (descriptor) {
- obj = PyCObject_FromVoidPtr(descriptor, NULL);
- PyDict_SetItem(cache, key, obj);
- Py_DECREF(obj);
- }
- }
- Py_DECREF(key);
- return descriptor;
-}
-
-/*
- For backward compatibility only
-*/
-#define SWIG_POINTER_EXCEPTION 0
-#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg)
-#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
-
-SWIGRUNTIME int
-SWIG_Python_AddErrMesg(const char* mesg, int infront)
-{
- if (PyErr_Occurred()) {
- PyObject *type = 0;
- PyObject *value = 0;
- PyObject *traceback = 0;
- PyErr_Fetch(&type, &value, &traceback);
- if (value) {
- PyObject *old_str = PyObject_Str(value);
- Py_XINCREF(type);
- PyErr_Clear();
- if (infront) {
- PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
- } else {
- PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
- }
- Py_DECREF(old_str);
- }
- return 1;
- } else {
- return 0;
- }
-}
-
-SWIGRUNTIME int
-SWIG_Python_ArgFail(int argnum)
-{
- if (PyErr_Occurred()) {
- /* add information about failing argument */
- char mesg[256];
- PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
- return SWIG_Python_AddErrMesg(mesg, 1);
- } else {
- return 0;
- }
-}
-
-SWIGRUNTIMEINLINE const char *
-PySwigObject_GetDesc(PyObject *self)
-{
- PySwigObject *v = (PySwigObject *)self;
- swig_type_info *ty = v ? v->ty : 0;
- return ty ? ty->str : (char*)"";
-}
-
-SWIGRUNTIME void
-SWIG_Python_TypeError(const char *type, PyObject *obj)
-{
- if (type) {
-#if defined(SWIG_COBJECT_TYPES)
- if (obj && PySwigObject_Check(obj)) {
- const char *otype = (const char *) PySwigObject_GetDesc(obj);
- if (otype) {
- PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received",
- type, otype);
- return;
- }
- } else
-#endif
- {
- const char *otype = (obj ? obj->ob_type->tp_name : 0);
- if (otype) {
- PyObject *str = PyObject_Str(obj);
- const char *cstr = str ? PyString_AsString(str) : 0;
- if (cstr) {
- PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
- type, otype, cstr);
- } else {
- PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
- type, otype);
- }
- Py_XDECREF(str);
- return;
- }
- }
- PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
- } else {
- PyErr_Format(PyExc_TypeError, "unexpected type is received");
- }
-}
-
-
-/* Convert a pointer value, signal an exception on a type mismatch */
-SWIGRUNTIME void *
-SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
- void *result;
- if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
- PyErr_Clear();
- if (flags & SWIG_POINTER_EXCEPTION) {
- SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
- SWIG_Python_ArgFail(argnum);
- }
- }
- return result;
-}
-
-
-#ifdef __cplusplus
-#if 0
-{ /* cc-mode */
-#endif
-}
-#endif
-
-
-
-#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
-
-#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
-
-
-
-/* -------- TYPES TABLE (BEGIN) -------- */
-
-#define SWIGTYPE_p_TDB_DATA swig_types[0]
-#define SWIGTYPE_p_char swig_types[1]
-#define SWIGTYPE_p_int swig_types[2]
-#define SWIGTYPE_p_long_long swig_types[3]
-#define SWIGTYPE_p_short swig_types[4]
-#define SWIGTYPE_p_signed_char swig_types[5]
-#define SWIGTYPE_p_tdb_context swig_types[6]
-#define SWIGTYPE_p_unsigned_char swig_types[7]
-#define SWIGTYPE_p_unsigned_int swig_types[8]
-#define SWIGTYPE_p_unsigned_long_long swig_types[9]
-#define SWIGTYPE_p_unsigned_short swig_types[10]
-static swig_type_info *swig_types[12];
-static swig_module_info swig_module = {swig_types, 11, 0, 0, 0, 0};
-#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
-#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
-
-/* -------- TYPES TABLE (END) -------- */
-
-#if (PY_VERSION_HEX <= 0x02000000)
-# if !defined(SWIG_PYTHON_CLASSIC)
-# error "This python version requires swig to be run with the '-classic' option"
-# endif
-#endif
-#if (PY_VERSION_HEX <= 0x02020000)
-# error "This python version requires swig to be run with the '-nomodern' option"
-#endif
-#if (PY_VERSION_HEX <= 0x02020000)
-# error "This python version requires swig to be run with the '-nomodernargs' option"
-#endif
-#ifndef METH_O
-# error "This python version requires swig to be run with the '-nofastunpack' option"
-#endif
-#ifdef SWIG_TypeQuery
-# undef SWIG_TypeQuery
-#endif
-#define SWIG_TypeQuery SWIG_Python_TypeQuery
-
-/*-----------------------------------------------
- @(target):= _tdb.so
- ------------------------------------------------*/
-#define SWIG_init init_tdb
-
-#define SWIG_name "_tdb"
-
-#define SWIGVERSION 0x010335
-#define SWIG_VERSION SWIGVERSION
-
-
-#define SWIG_as_voidptr(a) (void *)((const void *)(a))
-#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
-
-
-
-/* This symbol is used in both includes.h and Python.h which causes an
- annoying compiler warning. */
-
-#ifdef HAVE_FSTAT
-#undef HAVE_FSTAT
-#endif
-
-/* Include tdb headers */
-#include <stdint.h>
-#include <signal.h>
-#include <tdb.h>
-#include <fcntl.h>
-
-typedef TDB_CONTEXT tdb;
-
-
- #define SWIG_From_long PyInt_FromLong
-
-
-SWIGINTERNINLINE PyObject *
-SWIG_From_int (int value)
-{
- return SWIG_From_long (value);
-}
-
-
-SWIGINTERN swig_type_info*
-SWIG_pchar_descriptor(void)
-{
- static int init = 0;
- static swig_type_info* info = 0;
- if (!init) {
- info = SWIG_TypeQuery("_p_char");
- init = 1;
- }
- return info;
-}
-
-
-SWIGINTERN int
-SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
-{
- if (PyString_Check(obj)) {
- char *cstr; Py_ssize_t len;
- PyString_AsStringAndSize(obj, &cstr, &len);
- if (cptr) {
- if (alloc) {
- /*
- In python the user should not be able to modify the inner
- string representation. To warranty that, if you define
- SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string
- buffer is always returned.
-
- The default behavior is just to return the pointer value,
- so, be careful.
- */
-#if defined(SWIG_PYTHON_SAFE_CSTRINGS)
- if (*alloc != SWIG_OLDOBJ)
-#else
- if (*alloc == SWIG_NEWOBJ)
-#endif
- {
- *cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1));
- *alloc = SWIG_NEWOBJ;
- }
- else {
- *cptr = cstr;
- *alloc = SWIG_OLDOBJ;
- }
- } else {
- *cptr = PyString_AsString(obj);
- }
- }
- if (psize) *psize = len + 1;
- return SWIG_OK;
- } else {
- swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
- if (pchar_descriptor) {
- void* vptr = 0;
- if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
- if (cptr) *cptr = (char *) vptr;
- if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
- if (alloc) *alloc = SWIG_OLDOBJ;
- return SWIG_OK;
- }
- }
- }
- return SWIG_TypeError;
-}
-
-
-
-
-
-#include <limits.h>
-#if !defined(SWIG_NO_LLONG_MAX)
-# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
-# define LLONG_MAX __LONG_LONG_MAX__
-# define LLONG_MIN (-LLONG_MAX - 1LL)
-# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
-# endif
-#endif
-
-
-SWIGINTERN int
-SWIG_AsVal_double (PyObject *obj, double *val)
-{
- int res = SWIG_TypeError;
- if (PyFloat_Check(obj)) {
- if (val) *val = PyFloat_AsDouble(obj);
- return SWIG_OK;
- } else if (PyInt_Check(obj)) {
- if (val) *val = PyInt_AsLong(obj);
- return SWIG_OK;
- } else if (PyLong_Check(obj)) {
- double v = PyLong_AsDouble(obj);
- if (!PyErr_Occurred()) {
- if (val) *val = v;
- return SWIG_OK;
- } else {
- PyErr_Clear();
- }
- }
-#ifdef SWIG_PYTHON_CAST_MODE
- {
- int dispatch = 0;
- double d = PyFloat_AsDouble(obj);
- if (!PyErr_Occurred()) {
- if (val) *val = d;
- return SWIG_AddCast(SWIG_OK);
- } else {
- PyErr_Clear();
- }
- if (!dispatch) {
- long v = PyLong_AsLong(obj);
- if (!PyErr_Occurred()) {
- if (val) *val = v;
- return SWIG_AddCast(SWIG_AddCast(SWIG_OK));
- } else {
- PyErr_Clear();
- }
- }
- }
-#endif
- return res;
-}
-
-
-#include <float.h>
-
-
-#include <math.h>
-
-
-SWIGINTERNINLINE int
-SWIG_CanCastAsInteger(double *d, double min, double max) {
- double x = *d;
- if ((min <= x && x <= max)) {
- double fx = floor(x);
- double cx = ceil(x);
- double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */
- if ((errno == EDOM) || (errno == ERANGE)) {
- errno = 0;
- } else {
- double summ, reps, diff;
- if (rd < x) {
- diff = x - rd;
- } else if (rd > x) {
- diff = rd - x;
- } else {
- return 1;
- }
- summ = rd + x;
- reps = diff/summ;
- if (reps < 8*DBL_EPSILON) {
- *d = rd;
- return 1;
- }
- }
- }
- return 0;
-}
-
-
-SWIGINTERN int
-SWIG_AsVal_long (PyObject *obj, long* val)
-{
- if (PyInt_Check(obj)) {
- if (val) *val = PyInt_AsLong(obj);
- return SWIG_OK;
- } else if (PyLong_Check(obj)) {
- long v = PyLong_AsLong(obj);
- if (!PyErr_Occurred()) {
- if (val) *val = v;
- return SWIG_OK;
- } else {
- PyErr_Clear();
- }
- }
-#ifdef SWIG_PYTHON_CAST_MODE
- {
- int dispatch = 0;
- long v = PyInt_AsLong(obj);
- if (!PyErr_Occurred()) {
- if (val) *val = v;
- return SWIG_AddCast(SWIG_OK);
- } else {
- PyErr_Clear();
- }
- if (!dispatch) {
- double d;
- int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
- if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
- if (val) *val = (long)(d);
- return res;
- }
- }
- }
-#endif
- return SWIG_TypeError;
-}
-
-
-SWIGINTERN int
-SWIG_AsVal_int (PyObject * obj, int *val)
-{
- long v;
- int res = SWIG_AsVal_long (obj, &v);
- if (SWIG_IsOK(res)) {
- if ((v < INT_MIN || v > INT_MAX)) {
- return SWIG_OverflowError;
- } else {
- if (val) *val = (int)(v);
- }
- }
- return res;
-}
-
-SWIGINTERN tdb *new_tdb(char const *name,int hash_size,int tdb_flags,int flags,mode_t mode){
- return tdb_open(name, hash_size, tdb_flags, flags, mode);
- }
-SWIGINTERN void delete_tdb(tdb *self){ tdb_close(self); }
-
-SWIGINTERNINLINE PyObject *
-SWIG_FromCharPtrAndSize(const char* carray, size_t size)
-{
- if (carray) {
- if (size > INT_MAX) {
- swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
- return pchar_descriptor ?
- SWIG_NewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void();
- } else {
- return PyString_FromStringAndSize(carray, (int)(size));
- }
- } else {
- return SWIG_Py_Void();
- }
-}
-
-
-SWIGINTERNINLINE PyObject *
-SWIG_FromCharPtr(const char *cptr)
-{
- return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
-}
-
-
-SWIGINTERNINLINE PyObject*
-SWIG_From_unsigned_SS_long (unsigned long value)
-{
- return (value > LONG_MAX) ?
- PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value));
-}
-
-
-SWIGINTERNINLINE PyObject *
-SWIG_From_size_t (size_t value)
-{
- return SWIG_From_unsigned_SS_long ((unsigned long)(value));
-}
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-SWIGINTERN PyObject *_wrap_new_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- char *arg1 = (char *) 0 ;
- int arg2 ;
- int arg3 ;
- int arg4 ;
- mode_t arg5 ;
- tdb *result = 0 ;
- int res1 ;
- char *buf1 = 0 ;
- int alloc1 = 0 ;
- int val2 ;
- int ecode2 = 0 ;
- int val3 ;
- int ecode3 = 0 ;
- int val4 ;
- int ecode4 = 0 ;
- int val5 ;
- int ecode5 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- PyObject * obj2 = 0 ;
- PyObject * obj3 = 0 ;
- PyObject * obj4 = 0 ;
- char * kwnames[] = {
- (char *) "name",(char *) "hash_size",(char *) "tdb_flags",(char *) "flags",(char *) "mode", NULL
- };
-
- arg2 = 0;
- arg3 = TDB_DEFAULT;
- arg4 = O_RDWR;
- arg5 = 0600;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOOO:new_Tdb",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
- res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Tdb" "', argument " "1"" of type '" "char const *""'");
- }
- arg1 = (char *)(buf1);
- if (obj1) {
- ecode2 = SWIG_AsVal_int(obj1, &val2);
- if (!SWIG_IsOK(ecode2)) {
- SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_Tdb" "', argument " "2"" of type '" "int""'");
- }
- arg2 = (int)(val2);
- }
- if (obj2) {
- ecode3 = SWIG_AsVal_int(obj2, &val3);
- if (!SWIG_IsOK(ecode3)) {
- SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_Tdb" "', argument " "3"" of type '" "int""'");
- }
- arg3 = (int)(val3);
- }
- if (obj3) {
- ecode4 = SWIG_AsVal_int(obj3, &val4);
- if (!SWIG_IsOK(ecode4)) {
- SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "new_Tdb" "', argument " "4"" of type '" "int""'");
- }
- arg4 = (int)(val4);
- }
- if (obj4) {
- ecode5 = SWIG_AsVal_int(obj4, &val5);
- if (!SWIG_IsOK(ecode5)) {
- SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "new_Tdb" "', argument " "5"" of type '" "mode_t""'");
- }
- arg5 = (mode_t)(val5);
- }
- result = (tdb *)new_tdb((char const *)arg1,arg2,arg3,arg4,arg5);
- /* Throw an IOError exception from errno if tdb_open() returns NULL */
- if (result == NULL) {
- PyErr_SetFromErrno(PyExc_IOError);
- SWIG_fail;
- }
- resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_tdb_context, 0);
- if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
- return resultobj;
-fail:
- if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_error(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- enum TDB_ERROR result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_error" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = (enum TDB_ERROR)tdb_error(arg1);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_delete_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, SWIG_POINTER_DISOWN | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Tdb" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- delete_tdb(arg1);
-
- resultobj = SWIG_Py_Void();
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_close(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_close" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = (int)tdb_close(arg1);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- TDB_DATA arg2 ;
- TDB_DATA arg3 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- PyObject * obj2 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "key",(char *) "new_dbuf", NULL
- };
-
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:Tdb_append",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_append" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- if (obj1 == Py_None) {
- (&arg2)->dsize = 0;
- (&arg2)->dptr = NULL;
- } else if (!PyString_Check(obj1)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- } else {
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
- }
- if (obj2 == Py_None) {
- (&arg3)->dsize = 0;
- (&arg3)->dptr = NULL;
- } else if (!PyString_Check(obj2)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- } else {
- (&arg3)->dsize = PyString_Size(obj2);
- (&arg3)->dptr = (uint8_t *)PyString_AsString(obj2);
- }
- result = (int)tdb_append(arg1,arg2,arg3);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_errorstr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- char *result = 0 ;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_errorstr" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = (char *)tdb_errorstr(arg1);
- resultobj = SWIG_FromCharPtr((const char *)result);
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- TDB_DATA arg2 ;
- TDB_DATA result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "key", NULL
- };
-
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_get",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_get" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- if (obj1 == Py_None) {
- (&arg2)->dsize = 0;
- (&arg2)->dptr = NULL;
- } else if (!PyString_Check(obj1)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- } else {
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
- }
- result = tdb_fetch(arg1,arg2);
- if ((&result)->dptr == NULL && (&result)->dsize == 0) {
- resultobj = Py_None;
- } else {
- resultobj = PyString_FromStringAndSize((const char *)(&result)->dptr, (&result)->dsize);
- free((&result)->dptr);
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- TDB_DATA arg2 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "key", NULL
- };
-
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_delete",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_delete" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- if (obj1 == Py_None) {
- (&arg2)->dsize = 0;
- (&arg2)->dptr = NULL;
- } else if (!PyString_Check(obj1)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- } else {
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
- }
- result = (int)tdb_delete(arg1,arg2);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- TDB_DATA arg2 ;
- TDB_DATA arg3 ;
- int arg4 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- int val4 ;
- int ecode4 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- PyObject * obj2 = 0 ;
- PyObject * obj3 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "key",(char *) "dbuf",(char *) "flag", NULL
- };
-
- arg4 = TDB_REPLACE;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:Tdb_store",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_store" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- if (obj1 == Py_None) {
- (&arg2)->dsize = 0;
- (&arg2)->dptr = NULL;
- } else if (!PyString_Check(obj1)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- } else {
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
- }
- if (obj2 == Py_None) {
- (&arg3)->dsize = 0;
- (&arg3)->dptr = NULL;
- } else if (!PyString_Check(obj2)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- } else {
- (&arg3)->dsize = PyString_Size(obj2);
- (&arg3)->dptr = (uint8_t *)PyString_AsString(obj2);
- }
- if (obj3) {
- ecode4 = SWIG_AsVal_int(obj3, &val4);
- if (!SWIG_IsOK(ecode4)) {
- SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Tdb_store" "', argument " "4"" of type '" "int""'");
- }
- arg4 = (int)(val4);
- }
- result = (int)tdb_store(arg1,arg2,arg3,arg4);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- TDB_DATA arg2 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "key", NULL
- };
-
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_exists",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_exists" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- if (obj1 == Py_None) {
- (&arg2)->dsize = 0;
- (&arg2)->dptr = NULL;
- } else if (!PyString_Check(obj1)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- } else {
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
- }
- result = (int)tdb_exists(arg1,arg2);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_firstkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- TDB_DATA result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_firstkey" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = tdb_firstkey(arg1);
- if ((&result)->dptr == NULL && (&result)->dsize == 0) {
- resultobj = Py_None;
- } else {
- resultobj = PyString_FromStringAndSize((const char *)(&result)->dptr, (&result)->dsize);
- free((&result)->dptr);
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- TDB_DATA arg2 ;
- TDB_DATA result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "key", NULL
- };
-
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_nextkey",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_nextkey" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- if (obj1 == Py_None) {
- (&arg2)->dsize = 0;
- (&arg2)->dptr = NULL;
- } else if (!PyString_Check(obj1)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- } else {
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
- }
- result = tdb_nextkey(arg1,arg2);
- if ((&result)->dptr == NULL && (&result)->dsize == 0) {
- resultobj = Py_None;
- } else {
- resultobj = PyString_FromStringAndSize((const char *)(&result)->dptr, (&result)->dsize);
- free((&result)->dptr);
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_lock_all" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = (int)tdb_lockall(arg1);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_unlock_all" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = (int)tdb_unlockall(arg1);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_read_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_read_lock_all" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = (int)tdb_lockall_read(arg1);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_read_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_read_unlock_all" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = (int)tdb_unlockall_read(arg1);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_reopen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_reopen" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = (int)tdb_reopen(arg1);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_transaction_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_start" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = (int)tdb_transaction_start(arg1);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_transaction_commit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_commit" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = (int)tdb_transaction_commit(arg1);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_transaction_cancel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_cancel" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = (int)tdb_transaction_cancel(arg1);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_transaction_recover(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_recover" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = (int)tdb_transaction_recover(arg1);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_hash_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_hash_size" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = (int)tdb_hash_size(arg1);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_map_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- size_t result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_map_size" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = tdb_map_size(arg1);
- resultobj = SWIG_From_size_t((size_t)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_get_flags(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_get_flags" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = (int)tdb_get_flags(arg1);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_set_max_dead(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- int arg2 ;
- void *argp1 = 0 ;
- int res1 = 0 ;
- int val2 ;
- int ecode2 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "max_dead", NULL
- };
-
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_set_max_dead",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_set_max_dead" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- ecode2 = SWIG_AsVal_int(obj1, &val2);
- if (!SWIG_IsOK(ecode2)) {
- SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Tdb_set_max_dead" "', argument " "2"" of type '" "int""'");
- }
- arg2 = (int)(val2);
- tdb_set_max_dead(arg1,arg2);
- resultobj = SWIG_Py_Void();
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Tdb_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- tdb *arg1 = (tdb *) 0 ;
- char *result = 0 ;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_name" "', argument " "1"" of type '" "tdb *""'");
- }
- arg1 = (tdb *)(argp1);
- result = (char *)tdb_name(arg1);
- resultobj = SWIG_FromCharPtr((const char *)result);
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *Tdb_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *obj;
- if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
- SWIG_TypeNewClientData(SWIGTYPE_p_tdb_context, SWIG_NewClientData(obj));
- return SWIG_Py_Void();
-}
-
-SWIGINTERN PyObject *Tdb_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- return SWIG_Python_InitShadowInstance(args);
-}
-
-static PyMethodDef SwigMethods[] = {
- { (char *)"new_Tdb", (PyCFunction) _wrap_new_Tdb, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
- "S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)\n"
- "Open a TDB file.\n"
- ""},
- { (char *)"Tdb_error", (PyCFunction)_wrap_Tdb_error, METH_O, (char *)"\n"
- "S.error() -> int\n"
- "Find last error number returned by operation on this TDB.\n"
- ""},
- { (char *)"delete_Tdb", (PyCFunction)_wrap_delete_Tdb, METH_O, NULL},
- { (char *)"Tdb_close", (PyCFunction)_wrap_Tdb_close, METH_O, (char *)"\n"
- "S.close() -> None\n"
- "Close the TDB file.\n"
- ""},
- { (char *)"Tdb_append", (PyCFunction) _wrap_Tdb_append, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Tdb_errorstr", (PyCFunction)_wrap_Tdb_errorstr, METH_O, (char *)"\n"
- "S.errorstr() -> errorstring\n"
- "Obtain last error message.\n"
- ""},
- { (char *)"Tdb_get", (PyCFunction) _wrap_Tdb_get, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
- "S.fetch(key) -> value\n"
- "Fetch a value.\n"
- ""},
- { (char *)"Tdb_delete", (PyCFunction) _wrap_Tdb_delete, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
- "S.delete(key) -> None\n"
- "Delete an entry.\n"
- ""},
- { (char *)"Tdb_store", (PyCFunction) _wrap_Tdb_store, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
- "S.store(key, value, flag=TDB_REPLACE) -> None\n"
- "Store an entry.\n"
- ""},
- { (char *)"Tdb_exists", (PyCFunction) _wrap_Tdb_exists, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
- "S.exists(key) -> bool\n"
- "Check whether key exists in this database.\n"
- ""},
- { (char *)"Tdb_firstkey", (PyCFunction)_wrap_Tdb_firstkey, METH_O, (char *)"\n"
- "S.firstkey() -> data\n"
- "Return the first key in this database.\n"
- ""},
- { (char *)"Tdb_nextkey", (PyCFunction) _wrap_Tdb_nextkey, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
- "S.nextkey(prev) -> data\n"
- "Return the next key in this database.\n"
- ""},
- { (char *)"Tdb_lock_all", (PyCFunction)_wrap_Tdb_lock_all, METH_O, (char *)"S.lockall() -> bool"},
- { (char *)"Tdb_unlock_all", (PyCFunction)_wrap_Tdb_unlock_all, METH_O, (char *)"S.unlockall() -> bool"},
- { (char *)"Tdb_read_lock_all", (PyCFunction)_wrap_Tdb_read_lock_all, METH_O, NULL},
- { (char *)"Tdb_read_unlock_all", (PyCFunction)_wrap_Tdb_read_unlock_all, METH_O, NULL},
- { (char *)"Tdb_reopen", (PyCFunction)_wrap_Tdb_reopen, METH_O, (char *)"\n"
- "S.reopen() -> bool\n"
- "Reopen this file.\n"
- ""},
- { (char *)"Tdb_transaction_start", (PyCFunction)_wrap_Tdb_transaction_start, METH_O, (char *)"\n"
- "S.transaction_start() -> None\n"
- "Start a new transaction.\n"
- ""},
- { (char *)"Tdb_transaction_commit", (PyCFunction)_wrap_Tdb_transaction_commit, METH_O, (char *)"\n"
- "S.transaction_commit() -> None\n"
- "Commit the currently active transaction.\n"
- ""},
- { (char *)"Tdb_transaction_cancel", (PyCFunction)_wrap_Tdb_transaction_cancel, METH_O, (char *)"\n"
- "S.transaction_cancel() -> None\n"
- "Cancel the currently active transaction.\n"
- ""},
- { (char *)"Tdb_transaction_recover", (PyCFunction)_wrap_Tdb_transaction_recover, METH_O, NULL},
- { (char *)"Tdb_hash_size", (PyCFunction)_wrap_Tdb_hash_size, METH_O, (char *)"S.hash_size() -> int"},
- { (char *)"Tdb_map_size", (PyCFunction)_wrap_Tdb_map_size, METH_O, (char *)"S.map_size() -> int"},
- { (char *)"Tdb_get_flags", (PyCFunction)_wrap_Tdb_get_flags, METH_O, (char *)"S.get_flags() -> int"},
- { (char *)"Tdb_set_max_dead", (PyCFunction) _wrap_Tdb_set_max_dead, METH_VARARGS | METH_KEYWORDS, (char *)"S.set_max_dead(int) -> None"},
- { (char *)"Tdb_name", (PyCFunction)_wrap_Tdb_name, METH_O, (char *)"\n"
- "S.name() -> path\n"
- "Return filename of this TDB file.\n"
- ""},
- { (char *)"Tdb_swigregister", Tdb_swigregister, METH_VARARGS, NULL},
- { (char *)"Tdb_swiginit", Tdb_swiginit, METH_VARARGS, NULL},
- { NULL, NULL, 0, NULL }
-};
-
-
-/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
-
-static swig_type_info _swigt__p_TDB_DATA = {"_p_TDB_DATA", "TDB_DATA *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *|mode_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_tdb_context = {"_p_tdb_context", "struct tdb_context *|tdb *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uintptr_t *|uint_least32_t *|uint_fast32_t *|uint32_t *|unsigned int *|uint_fast16_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "uint_least64_t *|uint_fast64_t *|uint64_t *|unsigned long long *|uintmax_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *|uint_least16_t *|uint16_t *", 0, 0, (void*)0, 0};
-
-static swig_type_info *swig_type_initial[] = {
- &_swigt__p_TDB_DATA,
- &_swigt__p_char,
- &_swigt__p_int,
- &_swigt__p_long_long,
- &_swigt__p_short,
- &_swigt__p_signed_char,
- &_swigt__p_tdb_context,
- &_swigt__p_unsigned_char,
- &_swigt__p_unsigned_int,
- &_swigt__p_unsigned_long_long,
- &_swigt__p_unsigned_short,
-};
-
-static swig_cast_info _swigc__p_TDB_DATA[] = { {&_swigt__p_TDB_DATA, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_tdb_context[] = { {&_swigt__p_tdb_context, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_unsigned_long_long[] = { {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}};
-
-static swig_cast_info *swig_cast_initial[] = {
- _swigc__p_TDB_DATA,
- _swigc__p_char,
- _swigc__p_int,
- _swigc__p_long_long,
- _swigc__p_short,
- _swigc__p_signed_char,
- _swigc__p_tdb_context,
- _swigc__p_unsigned_char,
- _swigc__p_unsigned_int,
- _swigc__p_unsigned_long_long,
- _swigc__p_unsigned_short,
-};
-
-
-/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
-
-static swig_const_info swig_const_table[] = {
-{0, 0, 0, 0.0, 0, 0}};
-
-#ifdef __cplusplus
-}
-#endif
-/* -----------------------------------------------------------------------------
- * Type initialization:
- * This problem is tough by the requirement that no dynamic
- * memory is used. Also, since swig_type_info structures store pointers to
- * swig_cast_info structures and swig_cast_info structures store pointers back
- * to swig_type_info structures, we need some lookup code at initialization.
- * The idea is that swig generates all the structures that are needed.
- * The runtime then collects these partially filled structures.
- * The SWIG_InitializeModule function takes these initial arrays out of
- * swig_module, and does all the lookup, filling in the swig_module.types
- * array with the correct data and linking the correct swig_cast_info
- * structures together.
- *
- * The generated swig_type_info structures are assigned staticly to an initial
- * array. We just loop through that array, and handle each type individually.
- * First we lookup if this type has been already loaded, and if so, use the
- * loaded structure instead of the generated one. Then we have to fill in the
- * cast linked list. The cast data is initially stored in something like a
- * two-dimensional array. Each row corresponds to a type (there are the same
- * number of rows as there are in the swig_type_initial array). Each entry in
- * a column is one of the swig_cast_info structures for that type.
- * The cast_initial array is actually an array of arrays, because each row has
- * a variable number of columns. So to actually build the cast linked list,
- * we find the array of casts associated with the type, and loop through it
- * adding the casts to the list. The one last trick we need to do is making
- * sure the type pointer in the swig_cast_info struct is correct.
- *
- * First off, we lookup the cast->type name to see if it is already loaded.
- * There are three cases to handle:
- * 1) If the cast->type has already been loaded AND the type we are adding
- * casting info to has not been loaded (it is in this module), THEN we
- * replace the cast->type pointer with the type pointer that has already
- * been loaded.
- * 2) If BOTH types (the one we are adding casting info to, and the
- * cast->type) are loaded, THEN the cast info has already been loaded by
- * the previous module so we just ignore it.
- * 3) Finally, if cast->type has not already been loaded, then we add that
- * swig_cast_info to the linked list (because the cast->type) pointer will
- * be correct.
- * ----------------------------------------------------------------------------- */
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-} /* c-mode */
-#endif
-#endif
-
-#if 0
-#define SWIGRUNTIME_DEBUG
-#endif
-
-
-SWIGRUNTIME void
-SWIG_InitializeModule(void *clientdata) {
- size_t i;
- swig_module_info *module_head, *iter;
- int found, init;
-
- clientdata = clientdata;
-
- /* check to see if the circular list has been setup, if not, set it up */
- if (swig_module.next==0) {
- /* Initialize the swig_module */
- swig_module.type_initial = swig_type_initial;
- swig_module.cast_initial = swig_cast_initial;
- swig_module.next = &swig_module;
- init = 1;
- } else {
- init = 0;
- }
-
- /* Try and load any already created modules */
- module_head = SWIG_GetModule(clientdata);
- if (!module_head) {
- /* This is the first module loaded for this interpreter */
- /* so set the swig module into the interpreter */
- SWIG_SetModule(clientdata, &swig_module);
- module_head = &swig_module;
- } else {
- /* the interpreter has loaded a SWIG module, but has it loaded this one? */
- found=0;
- iter=module_head;
- do {
- if (iter==&swig_module) {
- found=1;
- break;
- }
- iter=iter->next;
- } while (iter!= module_head);
-
- /* if the is found in the list, then all is done and we may leave */
- if (found) return;
- /* otherwise we must add out module into the list */
- swig_module.next = module_head->next;
- module_head->next = &swig_module;
- }
-
- /* When multiple interpeters are used, a module could have already been initialized in
- a different interpreter, but not yet have a pointer in this interpreter.
- In this case, we do not want to continue adding types... everything should be
- set up already */
- if (init == 0) return;
-
- /* Now work on filling in swig_module.types */
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: size %d\n", swig_module.size);
-#endif
- for (i = 0; i < swig_module.size; ++i) {
- swig_type_info *type = 0;
- swig_type_info *ret;
- swig_cast_info *cast;
-
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
-#endif
-
- /* if there is another module already loaded */
- if (swig_module.next != &swig_module) {
- type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
- }
- if (type) {
- /* Overwrite clientdata field */
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: found type %s\n", type->name);
-#endif
- if (swig_module.type_initial[i]->clientdata) {
- type->clientdata = swig_module.type_initial[i]->clientdata;
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
-#endif
- }
- } else {
- type = swig_module.type_initial[i];
- }
-
- /* Insert casting types */
- cast = swig_module.cast_initial[i];
- while (cast->type) {
- /* Don't need to add information already in the list */
- ret = 0;
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
-#endif
- if (swig_module.next != &swig_module) {
- ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
-#ifdef SWIGRUNTIME_DEBUG
- if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
-#endif
- }
- if (ret) {
- if (type == swig_module.type_initial[i]) {
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
-#endif
- cast->type = ret;
- ret = 0;
- } else {
- /* Check for casting already in the list */
- swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
-#ifdef SWIGRUNTIME_DEBUG
- if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
-#endif
- if (!ocast) ret = 0;
- }
- }
-
- if (!ret) {
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
-#endif
- if (type->cast) {
- type->cast->prev = cast;
- cast->next = type->cast;
- }
- type->cast = cast;
- }
- cast++;
- }
- /* Set entry in modules->types array equal to the type */
- swig_module.types[i] = type;
- }
- swig_module.types[i] = 0;
-
-#ifdef SWIGRUNTIME_DEBUG
- printf("**** SWIG_InitializeModule: Cast List ******\n");
- for (i = 0; i < swig_module.size; ++i) {
- int j = 0;
- swig_cast_info *cast = swig_module.cast_initial[i];
- printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
- while (cast->type) {
- printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
- cast++;
- ++j;
- }
- printf("---- Total casts: %d\n",j);
- }
- printf("**** SWIG_InitializeModule: Cast List ******\n");
-#endif
-}
-
-/* This function will propagate the clientdata field of type to
-* any new swig_type_info structures that have been added into the list
-* of equivalent types. It is like calling
-* SWIG_TypeClientData(type, clientdata) a second time.
-*/
-SWIGRUNTIME void
-SWIG_PropagateClientData(void) {
- size_t i;
- swig_cast_info *equiv;
- static int init_run = 0;
-
- if (init_run) return;
- init_run = 1;
-
- for (i = 0; i < swig_module.size; i++) {
- if (swig_module.types[i]->clientdata) {
- equiv = swig_module.types[i]->cast;
- while (equiv) {
- if (!equiv->converter) {
- if (equiv->type && !equiv->type->clientdata)
- SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
- }
- equiv = equiv->next;
- }
- }
- }
-}
-
-#ifdef __cplusplus
-#if 0
-{
- /* c-mode */
-#endif
-}
-#endif
-
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- /* Python-specific SWIG API */
-#define SWIG_newvarlink() SWIG_Python_newvarlink()
-#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
-#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
-
- /* -----------------------------------------------------------------------------
- * global variable support code.
- * ----------------------------------------------------------------------------- */
-
- typedef struct swig_globalvar {
- char *name; /* Name of global variable */
- PyObject *(*get_attr)(void); /* Return the current value */
- int (*set_attr)(PyObject *); /* Set the value */
- struct swig_globalvar *next;
- } swig_globalvar;
-
- typedef struct swig_varlinkobject {
- PyObject_HEAD
- swig_globalvar *vars;
- } swig_varlinkobject;
-
- SWIGINTERN PyObject *
- swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
- return PyString_FromString("<Swig global variables>");
- }
-
- SWIGINTERN PyObject *
- swig_varlink_str(swig_varlinkobject *v) {
- PyObject *str = PyString_FromString("(");
- swig_globalvar *var;
- for (var = v->vars; var; var=var->next) {
- PyString_ConcatAndDel(&str,PyString_FromString(var->name));
- if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
- }
- PyString_ConcatAndDel(&str,PyString_FromString(")"));
- return str;
- }
-
- SWIGINTERN int
- swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {
- PyObject *str = swig_varlink_str(v);
- fprintf(fp,"Swig global variables ");
- fprintf(fp,"%s\n", PyString_AsString(str));
- Py_DECREF(str);
- return 0;
- }
-
- SWIGINTERN void
- swig_varlink_dealloc(swig_varlinkobject *v) {
- swig_globalvar *var = v->vars;
- while (var) {
- swig_globalvar *n = var->next;
- free(var->name);
- free(var);
- var = n;
- }
- }
-
- SWIGINTERN PyObject *
- swig_varlink_getattr(swig_varlinkobject *v, char *n) {
- PyObject *res = NULL;
- swig_globalvar *var = v->vars;
- while (var) {
- if (strcmp(var->name,n) == 0) {
- res = (*var->get_attr)();
- break;
- }
- var = var->next;
- }
- if (res == NULL && !PyErr_Occurred()) {
- PyErr_SetString(PyExc_NameError,"Unknown C global variable");
- }
- return res;
- }
-
- SWIGINTERN int
- swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
- int res = 1;
- swig_globalvar *var = v->vars;
- while (var) {
- if (strcmp(var->name,n) == 0) {
- res = (*var->set_attr)(p);
- break;
- }
- var = var->next;
- }
- if (res == 1 && !PyErr_Occurred()) {
- PyErr_SetString(PyExc_NameError,"Unknown C global variable");
- }
- return res;
- }
-
- SWIGINTERN PyTypeObject*
- swig_varlink_type(void) {
- static char varlink__doc__[] = "Swig var link object";
- static PyTypeObject varlink_type;
- static int type_init = 0;
- if (!type_init) {
- const PyTypeObject tmp
- = {
- PyObject_HEAD_INIT(NULL)
- 0, /* Number of items in variable part (ob_size) */
- (char *)"swigvarlink", /* Type name (tp_name) */
- sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */
- 0, /* Itemsize (tp_itemsize) */
- (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */
- (printfunc) swig_varlink_print, /* Print (tp_print) */
- (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
- (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
- 0, /* tp_compare */
- (reprfunc) swig_varlink_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- (reprfunc)swig_varlink_str, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- 0, /* tp_flags */
- varlink__doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
-#if PY_VERSION_HEX >= 0x02020000
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
-#endif
-#if PY_VERSION_HEX >= 0x02030000
- 0, /* tp_del */
-#endif
-#ifdef COUNT_ALLOCS
- 0,0,0,0 /* tp_alloc -> tp_next */
-#endif
- };
- varlink_type = tmp;
- varlink_type.ob_type = &PyType_Type;
- type_init = 1;
- }
- return &varlink_type;
- }
-
- /* Create a variable linking object for use later */
- SWIGINTERN PyObject *
- SWIG_Python_newvarlink(void) {
- swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
- if (result) {
- result->vars = 0;
- }
- return ((PyObject*) result);
- }
-
- SWIGINTERN void
- SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
- swig_varlinkobject *v = (swig_varlinkobject *) p;
- swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
- if (gv) {
- size_t size = strlen(name)+1;
- gv->name = (char *)malloc(size);
- if (gv->name) {
- strncpy(gv->name,name,size);
- gv->get_attr = get_attr;
- gv->set_attr = set_attr;
- gv->next = v->vars;
- }
- }
- v->vars = gv;
- }
-
- SWIGINTERN PyObject *
- SWIG_globals(void) {
- static PyObject *_SWIG_globals = 0;
- if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink();
- return _SWIG_globals;
- }
-
- /* -----------------------------------------------------------------------------
- * constants/methods manipulation
- * ----------------------------------------------------------------------------- */
-
- /* Install Constants */
- SWIGINTERN void
- SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
- PyObject *obj = 0;
- size_t i;
- for (i = 0; constants[i].type; ++i) {
- switch(constants[i].type) {
- case SWIG_PY_POINTER:
- obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
- break;
- case SWIG_PY_BINARY:
- obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
- break;
- default:
- obj = 0;
- break;
- }
- if (obj) {
- PyDict_SetItemString(d, constants[i].name, obj);
- Py_DECREF(obj);
- }
- }
- }
-
- /* -----------------------------------------------------------------------------*/
- /* Fix SwigMethods to carry the callback ptrs when needed */
- /* -----------------------------------------------------------------------------*/
-
- SWIGINTERN void
- SWIG_Python_FixMethods(PyMethodDef *methods,
- swig_const_info *const_table,
- swig_type_info **types,
- swig_type_info **types_initial) {
- size_t i;
- for (i = 0; methods[i].ml_name; ++i) {
- const char *c = methods[i].ml_doc;
- if (c && (c = strstr(c, "swig_ptr: "))) {
- int j;
- swig_const_info *ci = 0;
- const char *name = c + 10;
- for (j = 0; const_table[j].type; ++j) {
- if (strncmp(const_table[j].name, name,
- strlen(const_table[j].name)) == 0) {
- ci = &(const_table[j]);
- break;
- }
- }
- if (ci) {
- size_t shift = (ci->ptype) - types;
- swig_type_info *ty = types_initial[shift];
- size_t ldoc = (c - methods[i].ml_doc);
- size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
- char *ndoc = (char*)malloc(ldoc + lptr + 10);
- if (ndoc) {
- char *buff = ndoc;
- void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
- if (ptr) {
- strncpy(buff, methods[i].ml_doc, ldoc);
- buff += ldoc;
- strncpy(buff, "swig_ptr: ", 10);
- buff += 10;
- SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
- methods[i].ml_doc = ndoc;
- }
- }
- }
- }
- }
- }
-
-#ifdef __cplusplus
-}
-#endif
-
-/* -----------------------------------------------------------------------------*
- * Partial Init method
- * -----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-SWIGEXPORT void SWIG_init(void) {
- PyObject *m, *d;
-
- /* Fix SwigMethods to carry the callback ptrs when needed */
- SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
-
- m = Py_InitModule((char *) SWIG_name, SwigMethods);
- d = PyModule_GetDict(m);
-
- SWIG_InitializeModule(0);
- SWIG_InstallConstants(d,swig_const_table);
-
-
- SWIG_Python_SetConstant(d, "REPLACE",SWIG_From_int((int)(TDB_REPLACE)));
- SWIG_Python_SetConstant(d, "INSERT",SWIG_From_int((int)(TDB_INSERT)));
- SWIG_Python_SetConstant(d, "MODIFY",SWIG_From_int((int)(TDB_MODIFY)));
- SWIG_Python_SetConstant(d, "DEFAULT",SWIG_From_int((int)(TDB_DEFAULT)));
- SWIG_Python_SetConstant(d, "CLEAR_IF_FIRST",SWIG_From_int((int)(TDB_CLEAR_IF_FIRST)));
- SWIG_Python_SetConstant(d, "INTERNAL",SWIG_From_int((int)(TDB_INTERNAL)));
- SWIG_Python_SetConstant(d, "NOLOCK",SWIG_From_int((int)(TDB_NOLOCK)));
- SWIG_Python_SetConstant(d, "NOMMAP",SWIG_From_int((int)(TDB_NOMMAP)));
- SWIG_Python_SetConstant(d, "CONVERT",SWIG_From_int((int)(TDB_CONVERT)));
- SWIG_Python_SetConstant(d, "BIGENDIAN",SWIG_From_int((int)(TDB_BIGENDIAN)));
- SWIG_Python_SetConstant(d, "TDB_SUCCESS",SWIG_From_int((int)(TDB_SUCCESS)));
- SWIG_Python_SetConstant(d, "TDB_ERR_CORRUPT",SWIG_From_int((int)(TDB_ERR_CORRUPT)));
- SWIG_Python_SetConstant(d, "TDB_ERR_IO",SWIG_From_int((int)(TDB_ERR_IO)));
- SWIG_Python_SetConstant(d, "TDB_ERR_LOCK",SWIG_From_int((int)(TDB_ERR_LOCK)));
- SWIG_Python_SetConstant(d, "TDB_ERR_OOM",SWIG_From_int((int)(TDB_ERR_OOM)));
- SWIG_Python_SetConstant(d, "TDB_ERR_EXISTS",SWIG_From_int((int)(TDB_ERR_EXISTS)));
- SWIG_Python_SetConstant(d, "TDB_ERR_NOLOCK",SWIG_From_int((int)(TDB_ERR_NOLOCK)));
- SWIG_Python_SetConstant(d, "TDB_ERR_LOCK_TIMEOUT",SWIG_From_int((int)(TDB_ERR_LOCK_TIMEOUT)));
- SWIG_Python_SetConstant(d, "TDB_ERR_NOEXIST",SWIG_From_int((int)(TDB_ERR_NOEXIST)));
- SWIG_Python_SetConstant(d, "TDB_ERR_EINVAL",SWIG_From_int((int)(TDB_ERR_EINVAL)));
- SWIG_Python_SetConstant(d, "TDB_ERR_RDONLY",SWIG_From_int((int)(TDB_ERR_RDONLY)));
-}
-
diff --git a/source4/lib/tdb/tools/tdbbackup.c b/source4/lib/tdb/tools/tdbbackup.c
deleted file mode 100644
index 6f3ca48314..0000000000
--- a/source4/lib/tdb/tools/tdbbackup.c
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- low level tdb backup and restore utility
- Copyright (C) Andrew Tridgell 2002
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/*
-
- This program is meant for backup/restore of tdb databases. Typical usage would be:
- tdbbackup *.tdb
- when Samba shuts down cleanly, which will make a backup of all the local databases
- to *.bak files. Then on Samba startup you would use:
- tdbbackup -v *.tdb
- and this will check the databases for corruption and if corruption is detected then
- the backup will be restored.
-
- You may also like to do a backup on a regular basis while Samba is
- running, perhaps using cron.
-
- The reason this program is needed is to cope with power failures
- while Samba is running. A power failure could lead to database
- corruption and Samba will then not start correctly.
-
- Note that many of the databases in Samba are transient and thus
- don't need to be backed up, so you can optimise the above a little
- by only running the backup on the critical databases.
-
- */
-
-#include "replace.h"
-#include "system/locale.h"
-#include "system/time.h"
-#include "system/filesys.h"
-#include "system/wait.h"
-#include "tdb.h"
-
-#ifdef HAVE_GETOPT_H
-#include <getopt.h>
-#endif
-
-static int failed;
-
-static char *add_suffix(const char *name, const char *suffix)
-{
- char *ret;
- int len = strlen(name) + strlen(suffix) + 1;
- ret = (char *)malloc(len);
- if (!ret) {
- fprintf(stderr,"Out of memory!\n");
- exit(1);
- }
- snprintf(ret, len, "%s%s", name, suffix);
- return ret;
-}
-
-static int copy_fn(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
-{
- TDB_CONTEXT *tdb_new = (TDB_CONTEXT *)state;
-
- if (tdb_store(tdb_new, key, dbuf, TDB_INSERT) != 0) {
- fprintf(stderr,"Failed to insert into %s\n", tdb_name(tdb_new));
- failed = 1;
- return 1;
- }
- return 0;
-}
-
-
-static int test_fn(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
-{
- return 0;
-}
-
-/*
- carefully backup a tdb, validating the contents and
- only doing the backup if its OK
- this function is also used for restore
-*/
-static int backup_tdb(const char *old_name, const char *new_name, int hash_size)
-{
- TDB_CONTEXT *tdb;
- TDB_CONTEXT *tdb_new;
- char *tmp_name;
- struct stat st;
- int count1, count2;
-
- tmp_name = add_suffix(new_name, ".tmp");
-
- /* stat the old tdb to find its permissions */
- if (stat(old_name, &st) != 0) {
- perror(old_name);
- free(tmp_name);
- return 1;
- }
-
- /* open the old tdb */
- tdb = tdb_open(old_name, 0, 0, O_RDWR, 0);
- if (!tdb) {
- printf("Failed to open %s\n", old_name);
- free(tmp_name);
- return 1;
- }
-
- /* create the new tdb */
- unlink(tmp_name);
- tdb_new = tdb_open(tmp_name,
- hash_size ? hash_size : tdb_hash_size(tdb),
- TDB_DEFAULT, O_RDWR|O_CREAT|O_EXCL,
- st.st_mode & 0777);
- if (!tdb_new) {
- perror(tmp_name);
- free(tmp_name);
- return 1;
- }
-
- /* lock the old tdb */
- if (tdb_lockall(tdb) != 0) {
- fprintf(stderr,"Failed to lock %s\n", old_name);
- tdb_close(tdb);
- tdb_close(tdb_new);
- unlink(tmp_name);
- free(tmp_name);
- return 1;
- }
-
- failed = 0;
-
- /* traverse and copy */
- count1 = tdb_traverse(tdb, copy_fn, (void *)tdb_new);
- if (count1 < 0 || failed) {
- fprintf(stderr,"failed to copy %s\n", old_name);
- tdb_close(tdb);
- tdb_close(tdb_new);
- unlink(tmp_name);
- free(tmp_name);
- return 1;
- }
-
- /* close the old tdb */
- tdb_close(tdb);
-
- /* close the new tdb and re-open read-only */
- tdb_close(tdb_new);
- tdb_new = tdb_open(tmp_name, 0, TDB_DEFAULT, O_RDONLY, 0);
- if (!tdb_new) {
- fprintf(stderr,"failed to reopen %s\n", tmp_name);
- unlink(tmp_name);
- perror(tmp_name);
- free(tmp_name);
- return 1;
- }
-
- /* traverse the new tdb to confirm */
- count2 = tdb_traverse(tdb_new, test_fn, NULL);
- if (count2 != count1) {
- fprintf(stderr,"failed to copy %s\n", old_name);
- tdb_close(tdb_new);
- unlink(tmp_name);
- free(tmp_name);
- return 1;
- }
-
- /* make sure the new tdb has reached stable storage */
- fsync(tdb_fd(tdb_new));
-
- /* close the new tdb and rename it to .bak */
- tdb_close(tdb_new);
- if (rename(tmp_name, new_name) != 0) {
- perror(new_name);
- free(tmp_name);
- return 1;
- }
-
- free(tmp_name);
-
- return 0;
-}
-
-/*
- verify a tdb and if it is corrupt then restore from *.bak
-*/
-static int verify_tdb(const char *fname, const char *bak_name)
-{
- TDB_CONTEXT *tdb;
- int count = -1;
-
- /* open the tdb */
- tdb = tdb_open(fname, 0, 0, O_RDONLY, 0);
-
- /* traverse the tdb, then close it */
- if (tdb) {
- count = tdb_traverse(tdb, test_fn, NULL);
- tdb_close(tdb);
- }
-
- /* count is < 0 means an error */
- if (count < 0) {
- printf("restoring %s\n", fname);
- return backup_tdb(bak_name, fname, 0);
- }
-
- printf("%s : %d records\n", fname, count);
-
- return 0;
-}
-
-/*
- see if one file is newer than another
-*/
-static int file_newer(const char *fname1, const char *fname2)
-{
- struct stat st1, st2;
- if (stat(fname1, &st1) != 0) {
- return 0;
- }
- if (stat(fname2, &st2) != 0) {
- return 1;
- }
- return (st1.st_mtime > st2.st_mtime);
-}
-
-static void usage(void)
-{
- printf("Usage: tdbbackup [options] <fname...>\n\n");
- printf(" -h this help message\n");
- printf(" -s suffix set the backup suffix\n");
- printf(" -v verify mode (restore if corrupt)\n");
- printf(" -n hashsize set the new hash size for the backup\n");
-}
-
-
- int main(int argc, char *argv[])
-{
- int i;
- int ret = 0;
- int c;
- int verify = 0;
- int hashsize = 0;
- const char *suffix = ".bak";
-
- while ((c = getopt(argc, argv, "vhs:n:")) != -1) {
- switch (c) {
- case 'h':
- usage();
- exit(0);
- case 'v':
- verify = 1;
- break;
- case 's':
- suffix = optarg;
- break;
- case 'n':
- hashsize = atoi(optarg);
- break;
- }
- }
-
- argc -= optind;
- argv += optind;
-
- if (argc < 1) {
- usage();
- exit(1);
- }
-
- for (i=0; i<argc; i++) {
- const char *fname = argv[i];
- char *bak_name;
-
- bak_name = add_suffix(fname, suffix);
-
- if (verify) {
- if (verify_tdb(fname, bak_name) != 0) {
- ret = 1;
- }
- } else {
- if (file_newer(fname, bak_name) &&
- backup_tdb(fname, bak_name, hashsize) != 0) {
- ret = 1;
- }
- }
-
- free(bak_name);
- }
-
- return ret;
-}
diff --git a/source4/lib/tdb/tools/tdbdump.c b/source4/lib/tdb/tools/tdbdump.c
deleted file mode 100644
index 8d930383b0..0000000000
--- a/source4/lib/tdb/tools/tdbdump.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- simple tdb dump util
- Copyright (C) Andrew Tridgell 2001
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "replace.h"
-#include "system/locale.h"
-#include "system/time.h"
-#include "system/filesys.h"
-#include "system/wait.h"
-#include "tdb.h"
-
-static void print_data(TDB_DATA d)
-{
- unsigned char *p = (unsigned char *)d.dptr;
- int len = d.dsize;
- while (len--) {
- if (isprint(*p) && !strchr("\"\\", *p)) {
- fputc(*p, stdout);
- } else {
- printf("\\%02X", *p);
- }
- p++;
- }
-}
-
-static int traverse_fn(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
-{
- printf("{\n");
- printf("key(%d) = \"", (int)key.dsize);
- print_data(key);
- printf("\"\n");
- printf("data(%d) = \"", (int)dbuf.dsize);
- print_data(dbuf);
- printf("\"\n");
- printf("}\n");
- return 0;
-}
-
-static int dump_tdb(const char *fname, const char *keyname)
-{
- TDB_CONTEXT *tdb;
- TDB_DATA key, value;
-
- tdb = tdb_open(fname, 0, 0, O_RDONLY, 0);
- if (!tdb) {
- printf("Failed to open %s\n", fname);
- return 1;
- }
-
- if (!keyname) {
- tdb_traverse(tdb, traverse_fn, NULL);
- } else {
- key.dptr = discard_const_p(uint8_t,keyname);
- key.dsize = strlen( keyname);
- value = tdb_fetch(tdb, key);
- if (!value.dptr) {
- return 1;
- } else {
- print_data(value);
- free(value.dptr);
- }
- }
-
- return 0;
-}
-
-static void usage( void)
-{
- printf( "Usage: tdbdump [options] <filename>\n\n");
- printf( " -h this help message\n");
- printf( " -k keyname dumps value of keyname\n");
-}
-
- int main(int argc, char *argv[])
-{
- char *fname, *keyname=NULL;
- int c;
-
- if (argc < 2) {
- printf("Usage: tdbdump <fname>\n");
- exit(1);
- }
-
- while ((c = getopt( argc, argv, "hk:")) != -1) {
- switch (c) {
- case 'h':
- usage();
- exit( 0);
- case 'k':
- keyname = optarg;
- break;
- default:
- usage();
- exit( 1);
- }
- }
-
- fname = argv[optind];
-
- return dump_tdb(fname, keyname);
-}
diff --git a/source4/lib/tdb/tools/tdbtest.c b/source4/lib/tdb/tools/tdbtest.c
deleted file mode 100644
index 416bc50a5b..0000000000
--- a/source4/lib/tdb/tools/tdbtest.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/* a test program for tdb - the trivial database */
-
-#include "replace.h"
-#include "tdb.h"
-#include "system/filesys.h"
-#include "system/time.h"
-
-#include <gdbm.h>
-
-
-#define DELETE_PROB 7
-#define STORE_PROB 5
-
-static struct tdb_context *db;
-static GDBM_FILE gdbm;
-
-struct timeval tp1,tp2;
-
-static void _start_timer(void)
-{
- gettimeofday(&tp1,NULL);
-}
-
-static double _end_timer(void)
-{
- gettimeofday(&tp2,NULL);
- return((tp2.tv_sec - tp1.tv_sec) +
- (tp2.tv_usec - tp1.tv_usec)*1.0e-6);
-}
-
-static void fatal(const char *why)
-{
- perror(why);
- exit(1);
-}
-
-#ifdef PRINTF_ATTRIBUTE
-static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...) PRINTF_ATTRIBUTE(3,4);
-#endif
-static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vfprintf(stdout, format, ap);
- va_end(ap);
- fflush(stdout);
-}
-
-static void compare_db(void)
-{
- TDB_DATA d, key, nextkey;
- datum gd, gkey, gnextkey;
-
- key = tdb_firstkey(db);
- while (key.dptr) {
- d = tdb_fetch(db, key);
- gkey.dptr = key.dptr;
- gkey.dsize = key.dsize;
-
- gd = gdbm_fetch(gdbm, gkey);
-
- if (!gd.dptr) fatal("key not in gdbm");
- if (gd.dsize != d.dsize) fatal("data sizes differ");
- if (memcmp(gd.dptr, d.dptr, d.dsize)) {
- fatal("data differs");
- }
-
- nextkey = tdb_nextkey(db, key);
- free(key.dptr);
- free(d.dptr);
- free(gd.dptr);
- key = nextkey;
- }
-
- gkey = gdbm_firstkey(gdbm);
- while (gkey.dptr) {
- gd = gdbm_fetch(gdbm, gkey);
- key.dptr = gkey.dptr;
- key.dsize = gkey.dsize;
-
- d = tdb_fetch(db, key);
-
- if (!d.dptr) fatal("key not in db");
- if (d.dsize != gd.dsize) fatal("data sizes differ");
- if (memcmp(d.dptr, gd.dptr, gd.dsize)) {
- fatal("data differs");
- }
-
- gnextkey = gdbm_nextkey(gdbm, gkey);
- free(gkey.dptr);
- free(gd.dptr);
- free(d.dptr);
- gkey = gnextkey;
- }
-}
-
-static char *randbuf(int len)
-{
- char *buf;
- int i;
- buf = (char *)malloc(len+1);
-
- for (i=0;i<len;i++) {
- buf[i] = 'a' + (rand() % 26);
- }
- buf[i] = 0;
- return buf;
-}
-
-static void addrec_db(void)
-{
- int klen, dlen;
- char *k, *d;
- TDB_DATA key, data;
-
- klen = 1 + (rand() % 4);
- dlen = 1 + (rand() % 100);
-
- k = randbuf(klen);
- d = randbuf(dlen);
-
- key.dptr = k;
- key.dsize = klen+1;
-
- data.dptr = d;
- data.dsize = dlen+1;
-
- if (rand() % DELETE_PROB == 0) {
- tdb_delete(db, key);
- } else if (rand() % STORE_PROB == 0) {
- if (tdb_store(db, key, data, TDB_REPLACE) != 0) {
- fatal("tdb_store failed");
- }
- } else {
- data = tdb_fetch(db, key);
- if (data.dptr) free(data.dptr);
- }
-
- free(k);
- free(d);
-}
-
-static void addrec_gdbm(void)
-{
- int klen, dlen;
- char *k, *d;
- datum key, data;
-
- klen = 1 + (rand() % 4);
- dlen = 1 + (rand() % 100);
-
- k = randbuf(klen);
- d = randbuf(dlen);
-
- key.dptr = k;
- key.dsize = klen+1;
-
- data.dptr = d;
- data.dsize = dlen+1;
-
- if (rand() % DELETE_PROB == 0) {
- gdbm_delete(gdbm, key);
- } else if (rand() % STORE_PROB == 0) {
- if (gdbm_store(gdbm, key, data, GDBM_REPLACE) != 0) {
- fatal("gdbm_store failed");
- }
- } else {
- data = gdbm_fetch(gdbm, key);
- if (data.dptr) free(data.dptr);
- }
-
- free(k);
- free(d);
-}
-
-static int traverse_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
-{
-#if 0
- printf("[%s] [%s]\n", key.dptr, dbuf.dptr);
-#endif
- tdb_delete(tdb, key);
- return 0;
-}
-
-static void merge_test(void)
-{
- int i;
- char keys[5][2];
- char tdata[] = "test";
- TDB_DATA key, data;
-
- for (i = 0; i < 5; i++) {
- snprintf(keys[i],2, "%d", i);
- key.dptr = keys[i];
- key.dsize = 2;
-
- data.dptr = tdata;
- data.dsize = 4;
-
- if (tdb_store(db, key, data, TDB_REPLACE) != 0) {
- fatal("tdb_store failed");
- }
- }
-
- key.dptr = keys[0];
- tdb_delete(db, key);
- key.dptr = keys[4];
- tdb_delete(db, key);
- key.dptr = keys[2];
- tdb_delete(db, key);
- key.dptr = keys[1];
- tdb_delete(db, key);
- key.dptr = keys[3];
- tdb_delete(db, key);
-}
-
- int main(int argc, const char *argv[])
-{
- int i, seed=0;
- int loops = 10000;
- int num_entries;
- char test_gdbm[] = "test.gdbm";
-
- unlink("test.gdbm");
-
- db = tdb_open("test.tdb", 0, TDB_CLEAR_IF_FIRST,
- O_RDWR | O_CREAT | O_TRUNC, 0600);
- gdbm = gdbm_open(test_gdbm, 512, GDBM_WRITER|GDBM_NEWDB|GDBM_FAST,
- 0600, NULL);
-
- if (!db || !gdbm) {
- fatal("db open failed");
- }
-
-#if 1
- srand(seed);
- _start_timer();
- for (i=0;i<loops;i++) addrec_gdbm();
- printf("gdbm got %.2f ops/sec\n", i/_end_timer());
-#endif
-
- merge_test();
-
- srand(seed);
- _start_timer();
- for (i=0;i<loops;i++) addrec_db();
- printf("tdb got %.2f ops/sec\n", i/_end_timer());
-
- if (tdb_validate_freelist(db, &num_entries) == -1) {
- printf("tdb freelist is corrupt\n");
- } else {
- printf("tdb freelist is good (%d entries)\n", num_entries);
- }
-
- compare_db();
-
- printf("traversed %d records\n", tdb_traverse(db, traverse_fn, NULL));
- printf("traversed %d records\n", tdb_traverse(db, traverse_fn, NULL));
-
- tdb_close(db);
- gdbm_close(gdbm);
-
- return 0;
-}
diff --git a/source4/lib/tdb/tools/tdbtool.c b/source4/lib/tdb/tools/tdbtool.c
deleted file mode 100644
index d104ccd7c4..0000000000
--- a/source4/lib/tdb/tools/tdbtool.c
+++ /dev/null
@@ -1,659 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba database functions
- Copyright (C) Andrew Tridgell 1999-2000
- Copyright (C) Paul `Rusty' Russell 2000
- Copyright (C) Jeremy Allison 2000
- Copyright (C) Andrew Esh 2001
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "replace.h"
-#include "system/locale.h"
-#include "system/time.h"
-#include "system/filesys.h"
-#include "system/wait.h"
-#include "tdb.h"
-
-static int do_command(void);
-const char *cmdname;
-char *arg1, *arg2;
-size_t arg1len, arg2len;
-int bIterate = 0;
-char *line;
-TDB_DATA iterate_kbuf;
-char cmdline[1024];
-static int disable_mmap;
-
-enum commands {
- CMD_CREATE_TDB,
- CMD_OPEN_TDB,
- CMD_ERASE,
- CMD_DUMP,
- CMD_INSERT,
- CMD_MOVE,
- CMD_STORE,
- CMD_SHOW,
- CMD_KEYS,
- CMD_HEXKEYS,
- CMD_DELETE,
- CMD_LIST_HASH_FREE,
- CMD_LIST_FREE,
- CMD_INFO,
- CMD_MMAP,
- CMD_SPEED,
- CMD_FIRST,
- CMD_NEXT,
- CMD_SYSTEM,
- CMD_QUIT,
- CMD_HELP
-};
-
-typedef struct {
- const char *name;
- enum commands cmd;
-} COMMAND_TABLE;
-
-COMMAND_TABLE cmd_table[] = {
- {"create", CMD_CREATE_TDB},
- {"open", CMD_OPEN_TDB},
- {"erase", CMD_ERASE},
- {"dump", CMD_DUMP},
- {"insert", CMD_INSERT},
- {"move", CMD_MOVE},
- {"store", CMD_STORE},
- {"show", CMD_SHOW},
- {"keys", CMD_KEYS},
- {"hexkeys", CMD_HEXKEYS},
- {"delete", CMD_DELETE},
- {"list", CMD_LIST_HASH_FREE},
- {"free", CMD_LIST_FREE},
- {"info", CMD_INFO},
- {"speed", CMD_SPEED},
- {"mmap", CMD_MMAP},
- {"first", CMD_FIRST},
- {"1", CMD_FIRST},
- {"next", CMD_NEXT},
- {"n", CMD_NEXT},
- {"quit", CMD_QUIT},
- {"q", CMD_QUIT},
- {"!", CMD_SYSTEM},
- {NULL, CMD_HELP}
-};
-
-struct timeval tp1,tp2;
-
-static void _start_timer(void)
-{
- gettimeofday(&tp1,NULL);
-}
-
-static double _end_timer(void)
-{
- gettimeofday(&tp2,NULL);
- return((tp2.tv_sec - tp1.tv_sec) +
- (tp2.tv_usec - tp1.tv_usec)*1.0e-6);
-}
-
-/* a tdb tool for manipulating a tdb database */
-
-static TDB_CONTEXT *tdb;
-
-static int print_rec(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state);
-static int print_key(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state);
-static int print_hexkey(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state);
-
-static void print_asc(const char *buf,int len)
-{
- int i;
-
- /* We're probably printing ASCII strings so don't try to display
- the trailing NULL character. */
-
- if (buf[len - 1] == 0)
- len--;
-
- for (i=0;i<len;i++)
- printf("%c",isprint(buf[i])?buf[i]:'.');
-}
-
-static void print_data(const char *buf,int len)
-{
- int i=0;
- if (len<=0) return;
- printf("[%03X] ",i);
- for (i=0;i<len;) {
- printf("%02X ",(int)((unsigned char)buf[i]));
- i++;
- if (i%8 == 0) printf(" ");
- if (i%16 == 0) {
- print_asc(&buf[i-16],8); printf(" ");
- print_asc(&buf[i-8],8); printf("\n");
- if (i<len) printf("[%03X] ",i);
- }
- }
- if (i%16) {
- int n;
-
- n = 16 - (i%16);
- printf(" ");
- if (n>8) printf(" ");
- while (n--) printf(" ");
-
- n = i%16;
- if (n > 8) n = 8;
- print_asc(&buf[i-(i%16)],n); printf(" ");
- n = (i%16) - n;
- if (n>0) print_asc(&buf[i-n],n);
- printf("\n");
- }
-}
-
-static void help(void)
-{
- printf("\n"
-"tdbtool: \n"
-" create dbname : create a database\n"
-" open dbname : open an existing database\n"
-" erase : erase the database\n"
-" dump : dump the database as strings\n"
-" keys : dump the database keys as strings\n"
-" hexkeys : dump the database keys as hex values\n"
-" info : print summary info about the database\n"
-" insert key data : insert a record\n"
-" move key file : move a record to a destination tdb\n"
-" store key data : store a record (replace)\n"
-" show key : show a record by key\n"
-" delete key : delete a record by key\n"
-" list : print the database hash table and freelist\n"
-" free : print the database freelist\n"
-" ! command : execute system command\n"
-" 1 | first : print the first record\n"
-" n | next : print the next record\n"
-" q | quit : terminate\n"
-" \\n : repeat 'next' command\n"
-"\n");
-}
-
-static void terror(const char *why)
-{
- printf("%s\n", why);
-}
-
-static void create_tdb(const char *tdbname)
-{
- if (tdb) tdb_close(tdb);
- tdb = tdb_open(tdbname, 0, TDB_CLEAR_IF_FIRST | (disable_mmap?TDB_NOMMAP:0),
- O_RDWR | O_CREAT | O_TRUNC, 0600);
- if (!tdb) {
- printf("Could not create %s: %s\n", tdbname, strerror(errno));
- }
-}
-
-static void open_tdb(const char *tdbname)
-{
- if (tdb) tdb_close(tdb);
- tdb = tdb_open(tdbname, 0, disable_mmap?TDB_NOMMAP:0, O_RDWR, 0600);
- if (!tdb) {
- printf("Could not open %s: %s\n", tdbname, strerror(errno));
- }
-}
-
-static void insert_tdb(char *keyname, size_t keylen, char* data, size_t datalen)
-{
- TDB_DATA key, dbuf;
-
- if ((keyname == NULL) || (keylen == 0)) {
- terror("need key");
- return;
- }
-
- key.dptr = (unsigned char *)keyname;
- key.dsize = keylen;
- dbuf.dptr = (unsigned char *)data;
- dbuf.dsize = datalen;
-
- if (tdb_store(tdb, key, dbuf, TDB_INSERT) == -1) {
- terror("insert failed");
- }
-}
-
-static void store_tdb(char *keyname, size_t keylen, char* data, size_t datalen)
-{
- TDB_DATA key, dbuf;
-
- if ((keyname == NULL) || (keylen == 0)) {
- terror("need key");
- return;
- }
-
- if ((data == NULL) || (datalen == 0)) {
- terror("need data");
- return;
- }
-
- key.dptr = (unsigned char *)keyname;
- key.dsize = keylen;
- dbuf.dptr = (unsigned char *)data;
- dbuf.dsize = datalen;
-
- printf("Storing key:\n");
- print_rec(tdb, key, dbuf, NULL);
-
- if (tdb_store(tdb, key, dbuf, TDB_REPLACE) == -1) {
- terror("store failed");
- }
-}
-
-static void show_tdb(char *keyname, size_t keylen)
-{
- TDB_DATA key, dbuf;
-
- if ((keyname == NULL) || (keylen == 0)) {
- terror("need key");
- return;
- }
-
- key.dptr = (unsigned char *)keyname;
- key.dsize = keylen;
-
- dbuf = tdb_fetch(tdb, key);
- if (!dbuf.dptr) {
- terror("fetch failed");
- return;
- }
-
- print_rec(tdb, key, dbuf, NULL);
-
- free( dbuf.dptr );
-
- return;
-}
-
-static void delete_tdb(char *keyname, size_t keylen)
-{
- TDB_DATA key;
-
- if ((keyname == NULL) || (keylen == 0)) {
- terror("need key");
- return;
- }
-
- key.dptr = (unsigned char *)keyname;
- key.dsize = keylen;
-
- if (tdb_delete(tdb, key) != 0) {
- terror("delete failed");
- }
-}
-
-static void move_rec(char *keyname, size_t keylen, char* tdbname)
-{
- TDB_DATA key, dbuf;
- TDB_CONTEXT *dst_tdb;
-
- if ((keyname == NULL) || (keylen == 0)) {
- terror("need key");
- return;
- }
-
- if ( !tdbname ) {
- terror("need destination tdb name");
- return;
- }
-
- key.dptr = (unsigned char *)keyname;
- key.dsize = keylen;
-
- dbuf = tdb_fetch(tdb, key);
- if (!dbuf.dptr) {
- terror("fetch failed");
- return;
- }
-
- print_rec(tdb, key, dbuf, NULL);
-
- dst_tdb = tdb_open(tdbname, 0, 0, O_RDWR, 0600);
- if ( !dst_tdb ) {
- terror("unable to open destination tdb");
- return;
- }
-
- if ( tdb_store( dst_tdb, key, dbuf, TDB_REPLACE ) == -1 ) {
- terror("failed to move record");
- }
- else
- printf("record moved\n");
-
- tdb_close( dst_tdb );
-
- return;
-}
-
-static int print_rec(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
-{
- printf("\nkey %d bytes\n", (int)key.dsize);
- print_asc((const char *)key.dptr, key.dsize);
- printf("\ndata %d bytes\n", (int)dbuf.dsize);
- print_data((const char *)dbuf.dptr, dbuf.dsize);
- return 0;
-}
-
-static int print_key(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
-{
- printf("key %d bytes: ", (int)key.dsize);
- print_asc((const char *)key.dptr, key.dsize);
- printf("\n");
- return 0;
-}
-
-static int print_hexkey(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
-{
- printf("key %d bytes\n", (int)key.dsize);
- print_data((const char *)key.dptr, key.dsize);
- printf("\n");
- return 0;
-}
-
-static int total_bytes;
-
-static int traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
-{
- total_bytes += dbuf.dsize;
- return 0;
-}
-
-static void info_tdb(void)
-{
- int count;
- total_bytes = 0;
- if ((count = tdb_traverse(tdb, traverse_fn, NULL)) == -1)
- printf("Error = %s\n", tdb_errorstr(tdb));
- else
- printf("%d records totalling %d bytes\n", count, total_bytes);
-}
-
-static void speed_tdb(const char *tlimit)
-{
- unsigned timelimit = tlimit?atoi(tlimit):0;
- double t;
- int ops=0;
- if (timelimit == 0) timelimit = 10;
- printf("Testing traverse speed for %u seconds\n", timelimit);
- _start_timer();
- while ((t=_end_timer()) < timelimit) {
- tdb_traverse(tdb, traverse_fn, NULL);
- printf("%10.3f ops/sec\r", (++ops)/t);
- }
- printf("\n");
-}
-
-static void toggle_mmap(void)
-{
- disable_mmap = !disable_mmap;
- if (disable_mmap) {
- printf("mmap is disabled\n");
- } else {
- printf("mmap is enabled\n");
- }
-}
-
-static char *tdb_getline(const char *prompt)
-{
- static char thisline[1024];
- char *p;
- fputs(prompt, stdout);
- thisline[0] = 0;
- p = fgets(thisline, sizeof(thisline)-1, stdin);
- if (p) p = strchr(p, '\n');
- if (p) *p = 0;
- return p?thisline:NULL;
-}
-
-static int do_delete_fn(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf,
- void *state)
-{
- return tdb_delete(the_tdb, key);
-}
-
-static void first_record(TDB_CONTEXT *the_tdb, TDB_DATA *pkey)
-{
- TDB_DATA dbuf;
- *pkey = tdb_firstkey(the_tdb);
-
- dbuf = tdb_fetch(the_tdb, *pkey);
- if (!dbuf.dptr) terror("fetch failed");
- else {
- print_rec(the_tdb, *pkey, dbuf, NULL);
- }
-}
-
-static void next_record(TDB_CONTEXT *the_tdb, TDB_DATA *pkey)
-{
- TDB_DATA dbuf;
- *pkey = tdb_nextkey(the_tdb, *pkey);
-
- dbuf = tdb_fetch(the_tdb, *pkey);
- if (!dbuf.dptr)
- terror("fetch failed");
- else
- print_rec(the_tdb, *pkey, dbuf, NULL);
-}
-
-static int do_command(void)
-{
- COMMAND_TABLE *ctp = cmd_table;
- enum commands mycmd = CMD_HELP;
- int cmd_len;
-
- if (cmdname && strlen(cmdname) == 0) {
- mycmd = CMD_NEXT;
- } else {
- while (ctp->name) {
- cmd_len = strlen(ctp->name);
- if (strncmp(ctp->name,cmdname,cmd_len) == 0) {
- mycmd = ctp->cmd;
- break;
- }
- ctp++;
- }
- }
-
- switch (mycmd) {
- case CMD_CREATE_TDB:
- bIterate = 0;
- create_tdb(arg1);
- return 0;
- case CMD_OPEN_TDB:
- bIterate = 0;
- open_tdb(arg1);
- return 0;
- case CMD_SYSTEM:
- /* Shell command */
- system(arg1);
- return 0;
- case CMD_QUIT:
- return 1;
- default:
- /* all the rest require a open database */
- if (!tdb) {
- bIterate = 0;
- terror("database not open");
- help();
- return 0;
- }
- switch (mycmd) {
- case CMD_ERASE:
- bIterate = 0;
- tdb_traverse(tdb, do_delete_fn, NULL);
- return 0;
- case CMD_DUMP:
- bIterate = 0;
- tdb_traverse(tdb, print_rec, NULL);
- return 0;
- case CMD_INSERT:
- bIterate = 0;
- insert_tdb(arg1, arg1len,arg2,arg2len);
- return 0;
- case CMD_MOVE:
- bIterate = 0;
- move_rec(arg1,arg1len,arg2);
- return 0;
- case CMD_STORE:
- bIterate = 0;
- store_tdb(arg1,arg1len,arg2,arg2len);
- return 0;
- case CMD_SHOW:
- bIterate = 0;
- show_tdb(arg1, arg1len);
- return 0;
- case CMD_KEYS:
- tdb_traverse(tdb, print_key, NULL);
- return 0;
- case CMD_HEXKEYS:
- tdb_traverse(tdb, print_hexkey, NULL);
- return 0;
- case CMD_DELETE:
- bIterate = 0;
- delete_tdb(arg1,arg1len);
- return 0;
- case CMD_LIST_HASH_FREE:
- tdb_dump_all(tdb);
- return 0;
- case CMD_LIST_FREE:
- tdb_printfreelist(tdb);
- return 0;
- case CMD_INFO:
- info_tdb();
- return 0;
- case CMD_SPEED:
- speed_tdb(arg1);
- return 0;
- case CMD_MMAP:
- toggle_mmap();
- return 0;
- case CMD_FIRST:
- bIterate = 1;
- first_record(tdb, &iterate_kbuf);
- return 0;
- case CMD_NEXT:
- if (bIterate)
- next_record(tdb, &iterate_kbuf);
- return 0;
- case CMD_HELP:
- help();
- return 0;
- case CMD_CREATE_TDB:
- case CMD_OPEN_TDB:
- case CMD_SYSTEM:
- case CMD_QUIT:
- /*
- * unhandled commands. cases included here to avoid compiler
- * warnings.
- */
- return 0;
- }
- }
-
- return 0;
-}
-
-static char *convert_string(char *instring, size_t *sizep)
-{
- size_t length = 0;
- char *outp, *inp;
- char temp[3];
-
-
- outp = inp = instring;
-
- while (*inp) {
- if (*inp == '\\') {
- inp++;
- if (*inp && strchr("0123456789abcdefABCDEF",(int)*inp)) {
- temp[0] = *inp++;
- temp[1] = '\0';
- if (*inp && strchr("0123456789abcdefABCDEF",(int)*inp)) {
- temp[1] = *inp++;
- temp[2] = '\0';
- }
- *outp++ = (char)strtol((const char *)temp,NULL,16);
- } else {
- *outp++ = *inp++;
- }
- } else {
- *outp++ = *inp++;
- }
- length++;
- }
- *sizep = length;
- return instring;
-}
-
-int main(int argc, char *argv[])
-{
- cmdname = "";
- arg1 = NULL;
- arg1len = 0;
- arg2 = NULL;
- arg2len = 0;
-
- if (argv[1]) {
- cmdname = "open";
- arg1 = argv[1];
- do_command();
- cmdname = "";
- arg1 = NULL;
- }
-
- switch (argc) {
- case 1:
- case 2:
- /* Interactive mode */
- while ((cmdname = tdb_getline("tdb> "))) {
- arg2 = arg1 = NULL;
- if ((arg1 = strchr((const char *)cmdname,' ')) != NULL) {
- arg1++;
- arg2 = arg1;
- while (*arg2) {
- if (*arg2 == ' ') {
- *arg2++ = '\0';
- break;
- }
- if ((*arg2++ == '\\') && (*arg2 == ' ')) {
- arg2++;
- }
- }
- }
- if (arg1) arg1 = convert_string(arg1,&arg1len);
- if (arg2) arg2 = convert_string(arg2,&arg2len);
- if (do_command()) break;
- }
- break;
- case 5:
- arg2 = convert_string(argv[4],&arg2len);
- case 4:
- arg1 = convert_string(argv[3],&arg1len);
- case 3:
- cmdname = argv[2];
- default:
- do_command();
- break;
- }
-
- if (tdb) tdb_close(tdb);
-
- return 0;
-}
diff --git a/source4/lib/tdb/tools/tdbtorture.c b/source4/lib/tdb/tools/tdbtorture.c
deleted file mode 100644
index 9265cf07aa..0000000000
--- a/source4/lib/tdb/tools/tdbtorture.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/* this tests tdb by doing lots of ops from several simultaneous
- writers - that stresses the locking code.
-*/
-
-#include "replace.h"
-#include "system/time.h"
-#include "system/wait.h"
-#include "system/filesys.h"
-#include "tdb.h"
-
-#ifdef HAVE_GETOPT_H
-#include <getopt.h>
-#endif
-
-
-#define REOPEN_PROB 30
-#define DELETE_PROB 8
-#define STORE_PROB 4
-#define APPEND_PROB 6
-#define TRANSACTION_PROB 10
-#define LOCKSTORE_PROB 5
-#define TRAVERSE_PROB 20
-#define TRAVERSE_READ_PROB 20
-#define CULL_PROB 100
-#define KEYLEN 3
-#define DATALEN 100
-
-static struct tdb_context *db;
-static int in_transaction;
-static int error_count;
-
-#ifdef PRINTF_ATTRIBUTE
-static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, const char *format, ...) PRINTF_ATTRIBUTE(3,4);
-#endif
-static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, const char *format, ...)
-{
- va_list ap;
-
- error_count++;
-
- va_start(ap, format);
- vfprintf(stdout, format, ap);
- va_end(ap);
- fflush(stdout);
-#if 0
- {
- char *ptr;
- asprintf(&ptr,"xterm -e gdb /proc/%d/exe %d", getpid(), getpid());
- system(ptr);
- free(ptr);
- }
-#endif
-}
-
-static void fatal(const char *why)
-{
- perror(why);
- error_count++;
-}
-
-static char *randbuf(int len)
-{
- char *buf;
- int i;
- buf = (char *)malloc(len+1);
-
- for (i=0;i<len;i++) {
- buf[i] = 'a' + (rand() % 26);
- }
- buf[i] = 0;
- return buf;
-}
-
-static int cull_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf,
- void *state)
-{
-#if CULL_PROB
- if (random() % CULL_PROB == 0) {
- tdb_delete(tdb, key);
- }
-#endif
- return 0;
-}
-
-static void addrec_db(void)
-{
- int klen, dlen;
- char *k, *d;
- TDB_DATA key, data;
-
- klen = 1 + (rand() % KEYLEN);
- dlen = 1 + (rand() % DATALEN);
-
- k = randbuf(klen);
- d = randbuf(dlen);
-
- key.dptr = (unsigned char *)k;
- key.dsize = klen+1;
-
- data.dptr = (unsigned char *)d;
- data.dsize = dlen+1;
-
-#if TRANSACTION_PROB
- if (in_transaction == 0 && random() % TRANSACTION_PROB == 0) {
- if (tdb_transaction_start(db) != 0) {
- fatal("tdb_transaction_start failed");
- }
- in_transaction++;
- goto next;
- }
- if (in_transaction && random() % TRANSACTION_PROB == 0) {
- if (tdb_transaction_commit(db) != 0) {
- fatal("tdb_transaction_commit failed");
- }
- in_transaction--;
- goto next;
- }
- if (in_transaction && random() % TRANSACTION_PROB == 0) {
- if (tdb_transaction_cancel(db) != 0) {
- fatal("tdb_transaction_cancel failed");
- }
- in_transaction--;
- goto next;
- }
-#endif
-
-#if REOPEN_PROB
- if (in_transaction == 0 && random() % REOPEN_PROB == 0) {
- tdb_reopen_all(0);
- goto next;
- }
-#endif
-
-#if DELETE_PROB
- if (random() % DELETE_PROB == 0) {
- tdb_delete(db, key);
- goto next;
- }
-#endif
-
-#if STORE_PROB
- if (random() % STORE_PROB == 0) {
- if (tdb_store(db, key, data, TDB_REPLACE) != 0) {
- fatal("tdb_store failed");
- }
- goto next;
- }
-#endif
-
-#if APPEND_PROB
- if (random() % APPEND_PROB == 0) {
- if (tdb_append(db, key, data) != 0) {
- fatal("tdb_append failed");
- }
- goto next;
- }
-#endif
-
-#if LOCKSTORE_PROB
- if (random() % LOCKSTORE_PROB == 0) {
- tdb_chainlock(db, key);
- data = tdb_fetch(db, key);
- if (tdb_store(db, key, data, TDB_REPLACE) != 0) {
- fatal("tdb_store failed");
- }
- if (data.dptr) free(data.dptr);
- tdb_chainunlock(db, key);
- goto next;
- }
-#endif
-
-#if TRAVERSE_PROB
- if (random() % TRAVERSE_PROB == 0) {
- tdb_traverse(db, cull_traverse, NULL);
- goto next;
- }
-#endif
-
-#if TRAVERSE_READ_PROB
- if (random() % TRAVERSE_READ_PROB == 0) {
- tdb_traverse_read(db, NULL, NULL);
- goto next;
- }
-#endif
-
- data = tdb_fetch(db, key);
- if (data.dptr) free(data.dptr);
-
-next:
- free(k);
- free(d);
-}
-
-static int traverse_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf,
- void *state)
-{
- tdb_delete(tdb, key);
- return 0;
-}
-
-static void usage(void)
-{
- printf("Usage: tdbtorture [-n NUM_PROCS] [-l NUM_LOOPS] [-s SEED] [-H HASH_SIZE]\n");
- exit(0);
-}
-
- int main(int argc, char * const *argv)
-{
- int i, seed = -1;
- int num_procs = 3;
- int num_loops = 5000;
- int hash_size = 2;
- int c;
- extern char *optarg;
- pid_t *pids;
-
- struct tdb_logging_context log_ctx;
- log_ctx.log_fn = tdb_log;
-
- while ((c = getopt(argc, argv, "n:l:s:H:h")) != -1) {
- switch (c) {
- case 'n':
- num_procs = strtol(optarg, NULL, 0);
- break;
- case 'l':
- num_loops = strtol(optarg, NULL, 0);
- break;
- case 'H':
- hash_size = strtol(optarg, NULL, 0);
- break;
- case 's':
- seed = strtol(optarg, NULL, 0);
- break;
- default:
- usage();
- }
- }
-
- unlink("torture.tdb");
-
- pids = (pid_t *)calloc(sizeof(pid_t), num_procs);
- pids[0] = getpid();
-
- for (i=0;i<num_procs-1;i++) {
- if ((pids[i+1]=fork()) == 0) break;
- }
-
- db = tdb_open_ex("torture.tdb", hash_size, TDB_CLEAR_IF_FIRST,
- O_RDWR | O_CREAT, 0600, &log_ctx, NULL);
- if (!db) {
- fatal("db open failed");
- }
-
- if (seed == -1) {
- seed = (getpid() + time(NULL)) & 0x7FFFFFFF;
- }
-
- if (i == 0) {
- printf("testing with %d processes, %d loops, %d hash_size, seed=%d\n",
- num_procs, num_loops, hash_size, seed);
- }
-
- srand(seed + i);
- srandom(seed + i);
-
- for (i=0;i<num_loops && error_count == 0;i++) {
- addrec_db();
- }
-
- if (error_count == 0) {
- tdb_traverse_read(db, NULL, NULL);
- tdb_traverse(db, traverse_fn, NULL);
- tdb_traverse(db, traverse_fn, NULL);
- }
-
- tdb_close(db);
-
- if (getpid() != pids[0]) {
- return error_count;
- }
-
- for (i=1;i<num_procs;i++) {
- int status, j;
- pid_t pid;
- if (error_count != 0) {
- /* try and stop the test on any failure */
- for (j=1;j<num_procs;j++) {
- if (pids[j] != 0) {
- kill(pids[j], SIGTERM);
- }
- }
- }
- pid = waitpid(-1, &status, 0);
- if (pid == -1) {
- perror("failed to wait for child\n");
- exit(1);
- }
- for (j=1;j<num_procs;j++) {
- if (pids[j] == pid) break;
- }
- if (j == num_procs) {
- printf("unknown child %d exited!?\n", (int)pid);
- exit(1);
- }
- if (WEXITSTATUS(status) != 0) {
- printf("child %d exited with status %d\n",
- (int)pid, WEXITSTATUS(status));
- error_count++;
- }
- pids[j] = 0;
- }
-
- if (error_count == 0) {
- printf("OK\n");
- }
-
- return error_count;
-}
diff --git a/source4/lib/tdb/web/index.html b/source4/lib/tdb/web/index.html
deleted file mode 100644
index a53da6b8f7..0000000000
--- a/source4/lib/tdb/web/index.html
+++ /dev/null
@@ -1,42 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<HTML>
-<HEAD>
-<TITLE>ldb</TITLE>
-</HEAD>
-<BODY BGCOLOR="#ffffff" TEXT="#000000" VLINK="#292555" LINK="#292555" ALINK="#cc0033">
-
-<h1>tdb</h1>
-
-TDB is a Trivial Database. In concept, it is very much like GDBM, and BSD's DB
-except that it allows multiple simultaneous writers and uses locking
-internally to keep writers from trampling on each other. TDB is also extremely
-small.
-
-<h2>Discussion and bug reports</h2>
-
-tdb does not currently have its own mailing list or bug tracking
-system. For now, please use the <a
-href="https://lists.samba.org/mailman/listinfo/samba-technical">samba-technical</a>
-mailing list, and the <a href="http://bugzilla.samba.org/">Samba
-bugzilla</a> bug tracking system.
-
-<h2>Download</h2>
-
-You can download the latest release either via rsync or git.<br>
-<br>
-To fetch via git see the following guide:<br>
-<a href="http://wiki.samba.org/index.php/Using_Git_for_Samba_Development">Using Git for Samba Development</a><br>
-Once you have cloned the tree switch to the v4-0-test branch and cd into the source/lib/tdb directory.<br>
-<br>
-To fetch via rsync use these commands:
-
-<pre>
- rsync -Pavz samba.org::ftp/unpacked/tdb .
- rsync -Pavz samba.org::ftp/unpacked/libreplace .
-</pre>
-
-and build in tdb. It will find the replace library in the directory
-above automatically.
-
-</BODY>
-</HTML>
diff --git a/source4/lib/tdb_wrap.c b/source4/lib/tdb_wrap.c
index 37095dff2c..fadf1736dc 100644
--- a/source4/lib/tdb_wrap.c
+++ b/source4/lib/tdb_wrap.c
@@ -20,7 +20,7 @@
*/
#include "includes.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/util/dlinklist.h"
#include "tdb_wrap.h"
#include "tdb.h"
diff --git a/source4/lib/util/util_tdb.c b/source4/lib/util/util_tdb.c
index e4219dfd69..e89085a31b 100644
--- a/source4/lib/util/util_tdb.c
+++ b/source4/lib/util/util_tdb.c
@@ -20,7 +20,7 @@
*/
#include "includes.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "pstring.h"
#include "lib/util/util_tdb.h"
diff --git a/source4/librpc/idl/dfs.idl b/source4/librpc/idl/dfs.idl
index b279f555d9..1b145f3dfa 100644
--- a/source4/librpc/idl/dfs.idl
+++ b/source4/librpc/idl/dfs.idl
@@ -16,7 +16,8 @@ import "misc.idl";
typedef [v1_enum] enum {
DFS_MANAGER_VERSION_NT4 = 1,
DFS_MANAGER_VERSION_W2K = 2,
- DFS_MANAGER_VERSION_W2K3 = 4
+ DFS_MANAGER_VERSION_W2K3 = 4,
+ DFS_MANAGER_VERSION_W2K8 = 6
} dfs_ManagerVersion;
[public] void dfs_GetManagerVersion(
diff --git a/source4/librpc/idl/drsuapi.idl b/source4/librpc/idl/drsuapi.idl
index cc76599be6..0a5a081dd7 100644
--- a/source4/librpc/idl/drsuapi.idl
+++ b/source4/librpc/idl/drsuapi.idl
@@ -419,10 +419,17 @@ interface drsuapi
DRSUAPI_ATTRIBUTE_searchFlags = 0x0002014e,
DRSUAPI_ATTRIBUTE_lDAPDisplayName = 0x000201cc,
DRSUAPI_ATTRIBUTE_name = 0x00090001,
+ DRSUAPI_ATTRIBUTE_userAccountControl = 0x00090008,
DRSUAPI_ATTRIBUTE_currentValue = 0x0009001b,
+ DRSUAPI_ATTRIBUTE_homeDirectory = 0x0009002c,
+ DRSUAPI_ATTRIBUTE_homeDrive = 0x0009002d,
+ DRSUAPI_ATTRIBUTE_scriptPath = 0x0009003e,
+ DRSUAPI_ATTRIBUTE_profilePath = 0x0009008b,
DRSUAPI_ATTRIBUTE_objectSid = 0x00090092,
DRSUAPI_ATTRIBUTE_schemaIDGUID = 0x00090094,
DRSUAPI_ATTRIBUTE_dBCSPwd = 0x00090037,/* lmPwdHash */
+ DRSUAPI_ATTRIBUTE_logonHours = 0x00090040,
+ DRSUAPI_ATTRIBUTE_userWorkstations = 0x00090056,
DRSUAPI_ATTRIBUTE_unicodePwd = 0x0009005a,/* ntPwdHash */
DRSUAPI_ATTRIBUTE_ntPwdHistory = 0x0009005e,
DRSUAPI_ATTRIBUTE_priorValue = 0x00090064,
@@ -431,6 +438,7 @@ interface drsuapi
DRSUAPI_ATTRIBUTE_trustAuthOutgoing = 0x00090087,
DRSUAPI_ATTRIBUTE_lmPwdHistory = 0x000900a0,
DRSUAPI_ATTRIBUTE_sAMAccountName = 0x000900dd,
+ DRSUAPI_ATTRIBUTE_sAMAccountType = 0x0009012e,
DRSUAPI_ATTRIBUTE_fSMORoleOwner = 0x00090171,
DRSUAPI_ATTRIBUTE_systemFlags = 0x00090177,
DRSUAPI_ATTRIBUTE_serverReference = 0x00090203,
@@ -438,7 +446,11 @@ interface drsuapi
DRSUAPI_ATTRIBUTE_initialAuthIncoming = 0x0009021b,
DRSUAPI_ATTRIBUTE_initialAuthOutgoing = 0x0009021c,
DRSUAPI_ATTRIBUTE_wellKnownObjects = 0x0009026a,
+ DRSUAPI_ATTRIBUTE_dNSHostName = 0x0009026b,
DRSUAPI_ATTRIBUTE_isMemberOfPartialAttributeSet = 0x0009027f,
+ DRSUAPI_ATTRIBUTE_userPrincipalName = 0x00090290,
+ DRSUAPI_ATTRIBUTE_groupType = 0x000902ee,
+ DRSUAPI_ATTRIBUTE_servicePrincipalName = 0x00090303,
DRSUAPI_ATTRIBUTE_objectCategory = 0x0009030e,
DRSUAPI_ATTRIBUTE_gPLink = 0x0009037b,
DRSUAPI_ATTRIBUTE_msDS_Behavior_Version = 0x000905b3,
diff --git a/source4/librpc/idl/eventlog.idl b/source4/librpc/idl/eventlog.idl
index ee42300c7c..4a62ce14f3 100644
--- a/source4/librpc/idl/eventlog.idl
+++ b/source4/librpc/idl/eventlog.idl
@@ -86,7 +86,10 @@ import "lsa.idl", "security.idl";
/******************/
/* Function: 0x05 */
- [todo] NTSTATUS eventlog_GetOldestRecord();
+ NTSTATUS eventlog_GetOldestRecord(
+ [in] policy_handle *handle,
+ [out,ref] uint32 *oldest_entry
+ );
/******************/
/* Function: 0x06 */
diff --git a/source4/librpc/idl/lsa.idl b/source4/librpc/idl/lsa.idl
index b26d50c173..9a6e4a202c 100644
--- a/source4/librpc/idl/lsa.idl
+++ b/source4/librpc/idl/lsa.idl
@@ -95,8 +95,11 @@ import "misc.idl", "security.idl";
/******************/
/* Function: 0x04 */
- [todo] NTSTATUS lsa_SetSecObj ();
-
+ NTSTATUS lsa_SetSecObj(
+ [in] policy_handle *handle,
+ [in] security_secinfo sec_info,
+ [in,ref] sec_desc_buf *sdbuf
+ );
/******************/
/* Function: 0x05 */
@@ -484,9 +487,16 @@ import "misc.idl", "security.idl";
[todo] NTSTATUS lsa_SetQuotasForAccount();
/* Function: 0x17 */
- [todo] NTSTATUS lsa_GetSystemAccessAccount();
+ NTSTATUS lsa_GetSystemAccessAccount(
+ [in] policy_handle *handle,
+ [out,ref] uint32 *access_mask
+ );
+
/* Function: 0x18 */
- [todo] NTSTATUS lsa_SetSystemAccessAccount();
+ NTSTATUS lsa_SetSystemAccessAccount(
+ [in] policy_handle *handle,
+ [in] uint32 access_mask
+ );
/* Function: 0x19 */
NTSTATUS lsa_OpenTrustedDomain(
diff --git a/source4/librpc/idl/netlogon.idl b/source4/librpc/idl/netlogon.idl
index 2298106851..8a36922fdd 100644
--- a/source4/librpc/idl/netlogon.idl
+++ b/source4/librpc/idl/netlogon.idl
@@ -827,6 +827,7 @@ interface netlogon
/* function_code values */
typedef [v1_enum] enum {
+ NETLOGON_CONTROL_SYNC = 2,
NETLOGON_CONTROL_REDISCOVER = 5,
NETLOGON_CONTROL_TC_QUERY = 6,
NETLOGON_CONTROL_TRANSPORT_NOTIFY = 7,
@@ -880,6 +881,33 @@ interface netlogon
/*****************/
/* Function 0x0F */
+ typedef [bitmap32bit] bitmap {
+ NETLOGON_NEG_ACCOUNT_LOCKOUT = 0x00000001,
+ NETLOGON_NEG_PERSISTENT_SAMREPL = 0x00000002,
+ NETLOGON_NEG_ARCFOUR = 0x00000004,
+ NETLOGON_NEG_PROMOTION_COUNT = 0x00000008,
+ NETLOGON_NEG_CHANGELOG_BDC = 0x00000010,
+ NETLOGON_NEG_FULL_SYNC_REPL = 0x00000020,
+ NETLOGON_NEG_MULTIPLE_SIDS = 0x00000040,
+ NETLOGON_NEG_REDO = 0x00000080,
+ NETLOGON_NEG_PASSWORD_CHANGE_REFUSAL = 0x00000100,
+ NETLOGON_NEG_SEND_PASSWORD_INFO_PDC = 0x00000200,
+ NETLOGON_NEG_GENERIC_PASSTHROUGH = 0x00000400,
+ NETLOGON_NEG_CONCURRENT_RPC = 0x00000800,
+ NETLOGON_NEG_AVOID_ACCOUNT_DB_REPL = 0x00001000,
+ NETLOGON_NEG_AVOID_SECURITYAUTH_DB_REPL = 0x00002000,
+ NETLOGON_NEG_128BIT = 0x00004000, /* STRONG_KEYS */
+ NETLOGON_NEG_TRANSITIVE_TRUSTS = 0x00008000,
+ NETLOGON_NEG_DNS_DOMAIN_TRUSTS = 0x00010000,
+ NETLOGON_NEG_PASSWORD_SET2 = 0x00020000,
+ NETLOGON_NEG_GETDOMAININFO = 0x00040000,
+ NETLOGON_NEG_CROSS_FOREST_TRUSTS = 0x00080000,
+ NETLOGON_NEG_NEUTRALIZE_NT4_EMULATION = 0x00100000,
+ NETLOGON_NEG_RODC_PASSTHROUGH = 0x00200000,
+ NETLOGON_NEG_AUTHENTICATED_RPC_LSASS = 0x20000000,
+ NETLOGON_NEG_SCHANNEL = 0x40000000 /* AUTHENTICATED_RPC */
+ } netr_NegotiateFlags;
+
NTSTATUS netr_ServerAuthenticate2(
[in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] [string,charset(UTF16)] uint16 account_name[],
@@ -967,6 +995,8 @@ interface netlogon
DS_ONLY_LDAP_NEEDED = 0x00008000,
DS_IS_FLAT_NAME = 0x00010000,
DS_IS_DNS_NAME = 0x00020000,
+ DS_TRY_NEXTCLOSEST_SITE = 0x00040000,
+ DS_DIRECTORY_SERVICE_6_REQUIRED = 0x00080000,
DS_RETURN_DNS_NAME = 0x40000000,
DS_RETURN_FLAT_NAME = 0x80000000
} netr_DsRGetDCName_flags;
diff --git a/source4/librpc/idl/ntsvcs.idl b/source4/librpc/idl/ntsvcs.idl
index 1cdf8eecaa..9c7bdae42d 100644
--- a/source4/librpc/idl/ntsvcs.idl
+++ b/source4/librpc/idl/ntsvcs.idl
@@ -20,9 +20,31 @@ interface ntsvcs
[todo] void PNP_GetRelatedDeviceInstance();
[todo] void PNP_EnumerateSubKeys();
[todo] void PNP_GetDeviceList();
- [todo] void PNP_GetDeviceListSize();
+ /******************/
+ /* Function: 0x0b */
+
+ WERROR PNP_GetDeviceListSize(
+ [in,unique] [string,charset(UTF16)] uint16 *devicename,
+ [out,ref] uint32 *size,
+ [in] uint32 flags
+ );
+
[todo] void PNP_GetDepth();
- [todo] void PNP_GetDeviceRegProp();
+ /******************/
+ /* Function: 0x0d */
+
+ const int DEV_REGPROP_DESC = 1;
+
+ WERROR PNP_GetDeviceRegProp(
+ [in,ref] [string,charset(UTF16)] uint16 *devicepath,
+ [in] uint32 property,
+ [in,out,ref] uint32 *unknown1,
+ [out,ref] [size_is(*buffer_size)] [length_is(*buffer_size)] uint8 *buffer,
+ [in,out,ref] uint32 *buffer_size,
+ [in,out,ref] uint32 *needed,
+ [in] uint32 unknown3
+ );
+
[todo] void PNP_SetDeviceRegProp();
[todo] void PNP_GetClassInstance();
[todo] void PNP_CreateKey();
@@ -49,8 +71,37 @@ interface ntsvcs
[todo] void PNP_RequestDeviceEject();
[todo] void PNP_IsDockStationPresent();
[todo] void PNP_RequestEjectPC();
- [todo] void PNP_HwProfFlags();
- [todo] void PNP_GetHwProfInfo();
+ /******************/
+ /* Function: 0x28 */
+
+ WERROR PNP_HwProfFlags(
+ [in] uint32 unknown1,
+ [in,ref] [string,charset(UTF16)] uint16 *devicepath,
+ [in] uint32 unknown2,
+ [in,out,ref] uint32 *unknown3,
+ [in,out,unique] uint16 *unknown4,
+ [in,unique] [string,charset(UTF16)] uint16 *unknown5,
+ [out,unique] [string,charset(UTF16)] uint16 **unknown5a,
+ [in] uint32 unknown6,
+ [in] uint32 unknown7
+ );
+
+ /******************/
+ /* Function: 0x29 */
+
+ typedef struct {
+ uint32 unknown1;
+ uint16 unknown2[160];
+ uint32 unknown3;
+ } PNP_HwProfInfo;
+
+ WERROR PNP_GetHwProfInfo(
+ [in] uint32 idx,
+ [in,out,ref] PNP_HwProfInfo *info,
+ [in] uint32 unknown1,
+ [in] uint32 unknown2
+ );
+
[todo] void PNP_AddEmptyLogConf();
[todo] void PNP_FreeLogConf();
[todo] void PNP_GetFirstLogConf();
diff --git a/source4/librpc/idl/svcctl.idl b/source4/librpc/idl/svcctl.idl
index 615f4e3dab..961493d9b2 100644
--- a/source4/librpc/idl/svcctl.idl
+++ b/source4/librpc/idl/svcctl.idl
@@ -115,12 +115,21 @@ import "misc.idl";
/*****************/
/* Function 0x04 */
- [todo] WERROR svcctl_QueryServiceObjectSecurity(
+ WERROR svcctl_QueryServiceObjectSecurity(
+ [in] policy_handle *handle,
+ [in] uint32 security_flags,
+ [out,ref,size_is(buffer_size)] uint8 *buffer,
+ [in,range(0,0x40000)] uint32 buffer_size,
+ [out,ref,range(0,0x40000)] uint32 *needed
);
/*****************/
/* Function 0x05 */
- [todo] WERROR svcctl_SetServiceObjectSecurity(
+ WERROR svcctl_SetServiceObjectSecurity(
+ [in] policy_handle *handle,
+ [in] uint32 security_flags,
+ [in,ref,size_is(buffer_size)] uint8 *buffer,
+ [in] uint32 buffer_size
);
/*****************/
@@ -227,10 +236,22 @@ import "misc.idl";
/*****************/
/* Function 0x10 */
+ typedef [bitmap32bit] bitmap {
+ SC_RIGHT_SVC_QUERY_CONFIG = 0x0001,
+ SC_RIGHT_SVC_CHANGE_CONFIG = 0x0002,
+ SC_RIGHT_SVC_QUERY_STATUS = 0x0004,
+ SC_RIGHT_SVC_ENUMERATE_DEPENDENTS = 0x0008,
+ SC_RIGHT_SVC_START = 0x0010,
+ SC_RIGHT_SVC_STOP = 0x0020,
+ SC_RIGHT_SVC_PAUSE_CONTINUE = 0x0040,
+ SC_RIGHT_SVC_INTERROGATE = 0x0080,
+ SC_RIGHT_SVC_USER_DEFINED_CONTROL = 0x0100
+ } svcctl_ServiceAccessMask;
+
WERROR svcctl_OpenServiceW(
[in,ref] policy_handle *scmanager_handle,
[in] [string,charset(UTF16)] uint16 ServiceName[],
- [in] uint32 access_mask,
+ [in] svcctl_ServiceAccessMask access_mask,
[out,ref] policy_handle *handle
);
diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h
index b719be2bab..3f4de7801a 100644
--- a/source4/librpc/ndr/libndr.h
+++ b/source4/librpc/ndr/libndr.h
@@ -342,6 +342,7 @@ void ndr_print_dom_sid0(struct ndr_print *ndr, const char *name, const struct do
size_t ndr_size_dom_sid0(const struct dom_sid *sid, int flags);
void ndr_print_ipv4_addr(struct ndr_print *ndr, const char *name, const struct in_addr *_ip);
void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid);
+bool ndr_syntax_id_equal(const struct ndr_syntax_id *i1, const struct ndr_syntax_id *i2);
enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, const void *p, ndr_push_flags_fn_t fn);
enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, void *p, uint32_t level, ndr_push_flags_fn_t fn);
size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push);
diff --git a/source4/librpc/ndr/ndr_compression.c b/source4/librpc/ndr/ndr_compression.c
index 92c5b049df..05a80e20b2 100644
--- a/source4/librpc/ndr/ndr_compression.c
+++ b/source4/librpc/ndr/ndr_compression.c
@@ -21,7 +21,7 @@
*/
#include "includes.h"
-#include "lib/compression/lzxpress.h"
+#include "../lib/compression/lzxpress.h"
#include "librpc/ndr/libndr.h"
#include "librpc/ndr/ndr_compression.h"
#include <zlib.h>
diff --git a/source4/librpc/ndr/ndr_misc.c b/source4/librpc/ndr/ndr_misc.c
index be7dab93d2..2e5ecbac6d 100644
--- a/source4/librpc/ndr/ndr_misc.c
+++ b/source4/librpc/ndr/ndr_misc.c
@@ -38,3 +38,9 @@ _PUBLIC_ void ndr_print_GUID(struct ndr_print *ndr, const char *name, const stru
ndr->print(ndr, "%-25s: %s", name, GUID_string(ndr, guid));
}
+bool ndr_syntax_id_equal(const struct ndr_syntax_id *i1,
+ const struct ndr_syntax_id *i2)
+{
+ return GUID_equal(&i1->uuid, &i2->uuid)
+ && (i1->if_version == i2->if_version);
+}
diff --git a/source4/librpc/tests/samr-CreateUser-in.dat b/source4/librpc/tests/samr-CreateUser-in.dat
new file mode 100644
index 0000000000..a5840e1f7f
--- /dev/null
+++ b/source4/librpc/tests/samr-CreateUser-in.dat
Binary files differ
diff --git a/source4/librpc/tests/samr-CreateUser-out.dat b/source4/librpc/tests/samr-CreateUser-out.dat
new file mode 100644
index 0000000000..cf9131dba9
--- /dev/null
+++ b/source4/librpc/tests/samr-CreateUser-out.dat
Binary files differ
diff --git a/source4/librpc/tests/test_ndrdump.sh b/source4/librpc/tests/test_ndrdump.sh
new file mode 100755
index 0000000000..dddfc0eae1
--- /dev/null
+++ b/source4/librpc/tests/test_ndrdump.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+# Blackbox tests for masktest
+# Copyright (C) 2008 Andrew Tridgell
+# Copyright (C) 2008 Andrew Bartlett
+# based on test_smbclient.sh
+
+. `dirname $0`/../../../testprogs/blackbox/subunit.sh
+
+failed=0
+
+samba4bindir=`dirname $0`/../../source4/bin
+ndrdump=$samba4bindir/ndrdump
+files=`dirname $0`/ndrdump
+
+testit "ndrdump with in" $VALGRIND $ndrdump samr samr_CreateUser in $files/samr-CreateUser-in.dat $@ || failed=`expr $failed + 1`
+testit "ndrdump with out" $VALGRIND $ndrdump samr samr_CreateUser out $files/samr-CreateUser-out.dat $@ || failed=`expr $failed + 1`
+testit "ndrdump with --context-file" $VALGRIND $ndrdump --context-file $files/samr-CreateUser-in.dat samr samr_CreateUser out $files/samr-CreateUser-out.dat $@ || failed=`expr $failed + 1`
+testit "ndrdump with validate" $VALGRIND $ndrdump --validate samr samr_CreateUser in $files/samr-CreateUser-in.dat $@ || failed=`expr $failed + 1`
+
+exit $failed
diff --git a/source4/main.mk b/source4/main.mk
index ea410bd055..0edfa1c144 100644
--- a/source4/main.mk
+++ b/source4/main.mk
@@ -16,8 +16,8 @@ mkinclude lib/registry/config.mk
mkinclude lib/messaging/config.mk
mkinclude lib/events/config.mk
mkinclude lib/cmdline/config.mk
-mkinclude lib/socket_wrapper/config.mk
-mkinclude lib/nss_wrapper/config.mk
+mkinclude ../lib/socket_wrapper/config.mk
+mkinclude ../lib/nss_wrapper/config.mk
mkinclude lib/stream/config.mk
mkinclude lib/util/config.mk
mkinclude lib/tdr/config.mk
diff --git a/source4/nsswitch/winbind_nss_config.h b/source4/nsswitch/winbind_nss_config.h
index e0828dc905..ba6153ec28 100644
--- a/source4/nsswitch/winbind_nss_config.h
+++ b/source4/nsswitch/winbind_nss_config.h
@@ -31,7 +31,7 @@
/* Include header files from data in config.h file */
#ifndef NO_CONFIG_H
-#include "lib/replace/replace.h"
+#include "../replace/replace.h"
#endif
#include "system/passwd.h"
diff --git a/source4/ntvfs/common/brlock.c b/source4/ntvfs/common/brlock.c
index 3b34873152..21670bbea5 100644
--- a/source4/ntvfs/common/brlock.c
+++ b/source4/ntvfs/common/brlock.c
@@ -26,7 +26,7 @@
#include "includes.h"
#include "system/filesys.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "messaging/messaging.h"
#include "lib/messaging/irpc.h"
#include "libcli/libcli.h"
diff --git a/source4/ntvfs/common/brlock_tdb.c b/source4/ntvfs/common/brlock_tdb.c
index c94b9b446e..ba955038f8 100644
--- a/source4/ntvfs/common/brlock_tdb.c
+++ b/source4/ntvfs/common/brlock_tdb.c
@@ -26,7 +26,7 @@
#include "includes.h"
#include "system/filesys.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "messaging/messaging.h"
#include "lib/dbwrap/dbwrap.h"
#include "lib/messaging/irpc.h"
diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c
index 9055d6ece3..a35ef365b0 100644
--- a/source4/ntvfs/common/notify.c
+++ b/source4/ntvfs/common/notify.c
@@ -25,7 +25,7 @@
#include "includes.h"
#include "system/filesys.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/util/util_tdb.h"
#include "messaging/messaging.h"
#include "tdb_wrap.h"
diff --git a/source4/ntvfs/common/opendb_tdb.c b/source4/ntvfs/common/opendb_tdb.c
index d7531297ed..83da122fe2 100644
--- a/source4/ntvfs/common/opendb_tdb.c
+++ b/source4/ntvfs/common/opendb_tdb.c
@@ -40,7 +40,7 @@
#include "includes.h"
#include "system/filesys.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "messaging/messaging.h"
#include "tdb_wrap.h"
#include "lib/messaging/irpc.h"
diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c
index ce0da7033d..797496dd78 100644
--- a/source4/ntvfs/posix/vfs_posix.c
+++ b/source4/ntvfs/posix/vfs_posix.c
@@ -26,7 +26,7 @@
#include "includes.h"
#include "vfs_posix.h"
#include "librpc/gen_ndr/security.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "tdb_wrap.h"
#include "util/util_ldb.h"
#include "libcli/security/security.h"
diff --git a/source4/ntvfs/posix/xattr_tdb.c b/source4/ntvfs/posix/xattr_tdb.c
index 1113ac1739..aa13fee4c8 100644
--- a/source4/ntvfs/posix/xattr_tdb.c
+++ b/source4/ntvfs/posix/xattr_tdb.c
@@ -21,7 +21,7 @@
#include "includes.h"
#include "vfs_posix.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "tdb_wrap.h"
#define XATTR_LIST_ATTR ".xattr_list"
diff --git a/source4/param/secrets.c b/source4/param/secrets.c
index 16fbb3b108..45d3765b7a 100644
--- a/source4/param/secrets.c
+++ b/source4/param/secrets.c
@@ -27,7 +27,7 @@
#include "system/filesys.h"
#include "tdb_wrap.h"
#include "lib/ldb/include/ldb.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/util/util_tdb.h"
#include "lib/util/util_ldb.h"
#include "librpc/gen_ndr/ndr_security.h"
diff --git a/source4/pidl/MANIFEST b/source4/pidl/MANIFEST
deleted file mode 100644
index 051c5d2b19..0000000000
--- a/source4/pidl/MANIFEST
+++ /dev/null
@@ -1,43 +0,0 @@
-MANIFEST
-tests/parse_idl.pl
-tests/Util.pm
-tests/ndr_refptr.pl
-tests/ndr_string.pl
-tests/ndr_simple.pl
-tests/ndr_align.pl
-tests/ndr_alloc.pl
-tests/ndr_array.pl
-tests/ndr.pl
-tests/samba-ndr.pl
-tests/util.pl
-tests/test_util.pl
-tests/ndr_represent.pl
-tests/ndr_compat.pl
-tests/ndr_fullptr.pl
-tests/ndr_tagtype.pl
-tests/header.pl
-lib/Parse/Pidl/Samba3/ClientNDR.pm
-lib/Parse/Pidl/Samba3/ServerNDR.pm
-lib/Parse/Pidl/Samba4/NDR/Server.pm
-lib/Parse/Pidl/Samba4/NDR/Parser.pm
-lib/Parse/Pidl/Samba4/NDR/Client.pm
-lib/Parse/Pidl/Samba4/Header.pm
-lib/Parse/Pidl/Samba4/SWIG.pm
-lib/Parse/Pidl/Samba4/TDR.pm
-lib/Parse/Pidl/Samba4/Template.pm
-lib/Parse/Pidl/Samba4/EJS.pm
-lib/Parse/Pidl/Samba4.pm
-lib/Parse/Pidl/Wireshark/Conformance.pm
-lib/Parse/Pidl/Wireshark/NDR.pm
-lib/Parse/Pidl/Typelist.pm
-lib/Parse/Pidl/Dump.pm
-lib/Parse/Pidl/Compat.pm
-lib/Parse/Pidl/Util.pm
-lib/Parse/Pidl/NDR.pm
-lib/Parse/Pidl.pm
-Makefile.PL
-idl.yp
-TODO
-README
-pidl
-META.yml
diff --git a/source4/pidl/META.yml b/source4/pidl/META.yml
deleted file mode 100644
index 4822b50f09..0000000000
--- a/source4/pidl/META.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-name: Parse-Pidl
-abstract: Generate parsers / DCE/RPC-clients from IDL
-author:
- - Andrew Tridgell <tridge@samba.org>
- - Jelmer Vernooij <jelmer@samba.org>
- - Stefan Metzmacher <metze@samba.org>
- - Tim Potter <tpot@samba.org>
-license: gplv3
-installdirs: site
-homepage: http://www.samba.org/
-bugtracker: http://bugzilla.samba.org/
-requires:
- Parse::Yapp: 0
-recommends:
- Data::Dumper: 0
-meta-spec:
- version: 1.3
- url: http://module-build.sourceforge.net/META-spec-v1.3.html
diff --git a/source4/pidl/Makefile.PL b/source4/pidl/Makefile.PL
deleted file mode 100755
index 2a405fcc2b..0000000000
--- a/source4/pidl/Makefile.PL
+++ /dev/null
@@ -1,17 +0,0 @@
-use ExtUtils::MakeMaker;
-WriteMakefile(
- 'NAME' => 'Parse::Pidl',
- 'VERSION_FROM' => 'lib/Parse/Pidl.pm',
- 'EXE_FILES' => [ 'pidl' ],
- 'test' => { 'TESTS' => 'tests/*.pl' }
-);
-
-sub MY::postamble {
-<<'EOT';
-lib/Parse/Pidl/IDL.pm: idl.yp
- yapp -m 'Parse::Pidl::IDL' -o lib/Parse/Pidl/IDL.pm idl.yp
-
-lib/Parse/Pidl/Expr.pm: expr.yp
- yapp -m 'Parse::Pidl::Expr' -o lib/Parse/Pidl/Expr.pm expr.yp
-EOT
-}
diff --git a/source4/pidl/README b/source4/pidl/README
deleted file mode 100644
index d678387282..0000000000
--- a/source4/pidl/README
+++ /dev/null
@@ -1,64 +0,0 @@
-Introduction:
-=============
-This directory contains the source code of the pidl (Perl IDL)
-compiler for Samba 4.
-
-The main sources for pidl are available by Subversion on
-svn://svnanon.samba.org/samba/branches/SAMBA_4_0/source/pidl
-
-Pidl works by building a parse tree from a .pidl file (a simple
-dump of it's internal parse tree) or a .idl file
-(a file format mostly like the IDL file format midl uses).
-The IDL file parser is in idl.yp (a yacc file converted to
-perl code by yapp)
-
-After a parse tree is present, pidl will call one of it's backends
-(which one depends on the options given on the command-line). Here is
-a list of current backends:
-
-Standalone installation:
-========================
-Run Makefile.PL to generate the Makefile.
-
-Then run "make install" (as root) to install.
-
-Internals overview:
-===================
-
--- Generic --
-Parse::Pidl::Dump - Converts the parse tree back to an IDL file
-Parse::Pidl::Samba4::Header - Generates header file with data structures defined in IDL file
-Parse::Pidl::NDR - Generates intermediate datastructures for use by NDR parses/generators
-Parse::Pidl::ODL - Generates IDL structures from ODL structures for use in the NDR parser generator
-Parse::Pidl::Test - Utility functions for use in pidl's testsuite
-
--- Samba NDR --
-Parse::Pidl::Samba4::NDR::Client - Generates client call functions in C using the NDR parser
-Parse::Pidl::Samba4::SWIG - Generates SWIG interface files (.i)
-Parse::Pidl::Samba4::NDR::Parser - Generates pull/push functions for parsing NDR
-Parse::Pidl::Samba4::NDR::Server - Generates server side implementation in C
-Parse::Pidl::Samba4::TDR - Parser generator for the "Trivial Data Representation"
-Parse::Pidl::Samba4::Template - Generates stubs in C for server implementation
-Parse::Pidl::Samba4::EJS - Generates bindings for Embedded JavaScript (EJS)
-Parse::Pidl::Samba4::Python - Generates bindings for Python
-
--- Samba COM / DCOM --
-Parse::Pidl::Samba4::COM::Proxy - Generates proxy object for DCOM (client-side)
-Parse::Pidl::Samba4::COM::Stub - Generates stub call handler for DCOM (server-side)
-Parse::Pidl::Samba4::COM::Header - Generates headers for COM
-
--- Wireshark --
-Parse::Pidl::Wireshark::NDR - Generates a parser for the Wireshark network sniffer
-Parse::Pidl::Wireshark::Conformance - Reads conformance files containing additional data for generating Wireshark parsers
-
--- Utility modules --
-Parse::Pidl::Util - Misc utility functions used by *.pm and pidl.pl
-Parse::Pidl::Typelist - Utility functions for keeping track of known types and their representation in C
-
-Tips for hacking on pidl:
- - Look at the pidl's parse tree by using the --keep option and looking
- at the generated .pidl file.
- - The various backends have a lot in common, if you don't understand how one
- implements something, look at the others
- - See pidl(1) and the documentation on midl
- - See 'info bison' and yapp(1) for information on the file format of idl.yp
diff --git a/source4/pidl/TODO b/source4/pidl/TODO
deleted file mode 100644
index 8886441a75..0000000000
--- a/source4/pidl/TODO
+++ /dev/null
@@ -1,47 +0,0 @@
-- warn when union instances don't have a discriminant
-
-- EJS output backend shouldn't use the NDR levels stuff but instead
- as the "C levels" and NDR levels don't necessarily match.
-
-- true multiple dimension array / strings in arrays support
-
-- compatibility mode for generating MIDL-readable data:
- - strip out pidl-specific properties
-
-- make bitmap an optional attribute on enum
-- support nested elements
-- support typedefs properly (e.g. allow "typedef void **bla;")
-- make typedefs generate real typedefs
-- improve represent_as(): allow it to be used for arrays and other complex
- types
-
-- --explain-ndr option that dumps out parse tree ?
-
-- seperate tables for NDR and DCE/RPC
- - maybe no tables for NDR at all? we only need them for ndrdump
- and that can use dlsym()
-
-- allow data structures outside of interfaces
-
-- mem_ctx in the interface rather than as struct ndr member.
-
-- real typelibs
-
-- fix [in,out] handling and allocation for samba3:
- - add inout
- - make NULL to mean "allocate me"
- - remove NDR_AUTO_REF_ALLOC flag
-
-- automatic test generator based on IDL pointer types
-
-- support converting structs to tuples in Python rather than objects
-- convert structs with a single mattering member to that member directly, e.g.:
- struct bar {
- int size;
- [size_is(size)] uint32 *array;
- };
-
- should be converted to an array of uint32's
-
-- python: fill in size members automatically in some places if the struct isn't being returned
- (so we don't have to cope with the array growing)
diff --git a/source4/pidl/config.m4 b/source4/pidl/config.m4
deleted file mode 100644
index 8b8bc5acf0..0000000000
--- a/source4/pidl/config.m4
+++ /dev/null
@@ -1,9 +0,0 @@
-# Check whether ExtUtils::ExtMaker is available
-
-if perl -e "use ExtUtils::MakeMaker" 2>/dev/null; then
- HAVE_PERL_EXTUTILS_MAKEMAKER=1
-else
- HAVE_PERL_EXTUTILS_MAKEMAKER=0
-fi
-
-AC_SUBST(HAVE_PERL_EXTUTILS_MAKEMAKER)
diff --git a/source4/pidl/config.mk b/source4/pidl/config.mk
deleted file mode 100644
index 07c8647ecd..0000000000
--- a/source4/pidl/config.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-PIDL = $(PERL) $(pidldir)/pidl
-
-$(pidldir)/Makefile: $(pidldir)/Makefile.PL
- cd $(pidldir) && $(PERL) Makefile.PL PREFIX=$(prefix)
-
-pidl-testcov: $(pidldir)/Makefile
- cd $(pidldir) && cover -test
-
-installpidl:: $(pidldir)/Makefile
- $(MAKE) -C $(pidldir) install_vendor VENDORPREFIX=$(prefix) \
- INSTALLVENDORLIB=$(datarootdir)/perl5 \
- INSTALLVENDORBIN=$(bindir) \
- INSTALLVENDORSCRIPT=$(bindir) \
- INSTALLVENDORMAN1DIR=$(mandir)/man1 \
- INSTALLVENDORMAN3DIR=$(mandir)/man3
-
-ifeq ($(HAVE_PERL_EXTUTILS_MAKEMAKER),1)
-install:: installpidl
-endif
-
-$(pidldir)/lib/Parse/Pidl/IDL.pm: $(pidldir)/idl.yp
- -$(YAPP) -m 'Parse::Pidl::IDL' -o $(pidldir)/lib/Parse/Pidl/IDL.pm $(pidldir)/idl.yp ||\
- touch $(pidldir)/lib/Parse/Pidl/IDL.pm
-
-$(pidldir)/lib/Parse/Pidl/Expr.pm: $(pidldir)/idl.yp
- -$(YAPP) -m 'Parse::Pidl::Expr' -o $(pidldir)/lib/Parse/Pidl/Expr.pm $(pidldir)/expr.yp ||\
- touch $(pidldir)/lib/Parse/Pidl/Expr.pm
-
-testcov-html:: pidl-testcov
-
-
diff --git a/source4/pidl/expr.yp b/source4/pidl/expr.yp
deleted file mode 100644
index a8074875ff..0000000000
--- a/source4/pidl/expr.yp
+++ /dev/null
@@ -1,150 +0,0 @@
-# expr.yp
-# Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU GPL
-#
-%left '->'
-%right '!' '~'
-%left '*' '/' '%'
-%left '+' '-'
-%left '<<' '>>'
-%left '>' '<'
-%left '==' '!='
-%left '&'
-%left '|'
-%left '&&'
-%left '||'
-%left '?' ':'
-%left NEG DEREF ADDROF INV
-%left '.'
-
-%%
-exp: NUM
- | TEXT { "\"$_[1]\"" }
- | func
- | var
- | '~' exp %prec INV { "~$_[2]" }
- | exp '+' exp { "$_[1] + $_[3]" }
- | exp '-' exp { "$_[1] - $_[3]" }
- | exp '*' exp { "$_[1] * $_[3]" }
- | exp '%' exp { "$_[1] % $_[3]" }
- | exp '<' exp { "$_[1] < $_[3]" }
- | exp '>' exp { "$_[1] > $_[3]" }
- | exp '|' exp { "$_[1] | $_[3]" }
- | exp '==' exp { "$_[1] == $_[3]" }
- | exp '<=' exp { "$_[1] <= $_[3]" }
- | exp '=>' exp { "$_[1] => $_[3]" }
- | exp '<<' exp { "$_[1] << $_[3]" }
- | exp '>>' exp { "$_[1] >> $_[3]" }
- | exp '!=' exp { "$_[1] != $_[3]" }
- | exp '||' exp { "$_[1] || $_[3]" }
- | exp '&&' exp { "$_[1] && $_[3]" }
- | exp '&' exp { "$_[1] & $_[3]" }
- | exp '?' exp ':' exp { "$_[1]?$_[3]:$_[5]" }
- | '~' exp { "~$_[1]" }
- | '!' exp { "not $_[1]" }
- | exp '/' exp { "$_[1] / $_[3]" }
- | '-' exp %prec NEG { "-$_[2]" }
- | '&' exp %prec ADDROF { "&$_[2]" }
- | exp '^' exp { "$_[1]^$_[3]" }
- | '(' exp ')' { "($_[2])" }
-;
-
-possible_pointer:
- VAR { $_[0]->_Lookup($_[1]) }
- | '*' possible_pointer %prec DEREF { $_[0]->_Dereference($_[2]); "*$_[2]" }
- ;
-
-var: possible_pointer { $_[0]->_Use($_[1]) }
- | var '.' VAR { $_[0]->_Use("$_[1].$_[3]") }
- | '(' var ')' { "($_[2])" }
- | var '->' VAR { $_[0]->_Use("*$_[1]"); $_[1]."->".$_[3] }
-;
-
-
-func: VAR '(' opt_args ')' { "$_[1]($_[3])" };
-opt_args: { "" } | args;
-exp_or_possible_pointer: exp | possible_pointer;
-args: exp_or_possible_pointer
- | exp_or_possible_pointer ',' args { "$_[1], $_[3]" }
-;
-
-%%
-
-package Parse::Pidl::Expr;
-
-sub _Lexer {
- my($parser)=shift;
-
- $parser->YYData->{INPUT}=~s/^[ \t]//;
-
- for ($parser->YYData->{INPUT}) {
- if (s/^(0x[0-9A-Fa-f]+)//) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return('NUM',$1);
- }
- if (s/^([0-9]+(?:\.[0-9]+)?)//) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return('NUM',$1);
- }
- if (s/^([A-Za-z_][A-Za-z0-9_]*)//) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return('VAR',$1);
- }
- if (s/^\"(.*?)\"//) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return('TEXT',$1);
- }
- if (s/^(==|!=|<=|>=|->|\|\||<<|>>|&&)//s) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return($1,$1);
- }
- if (s/^(.)//s) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return($1,$1);
- }
- }
-}
-
-sub _Use($$)
-{
- my ($self, $x) = @_;
- if (defined($self->YYData->{USE})) {
- return $self->YYData->{USE}->($x);
- }
- return $x;
-}
-
-sub _Lookup($$)
-{
- my ($self, $x) = @_;
- return $self->YYData->{LOOKUP}->($x);
-}
-
-sub _Dereference($$)
-{
- my ($self, $x) = @_;
- if (defined($self->YYData->{DEREFERENCE})) {
- $self->YYData->{DEREFERENCE}->($x);
- }
-}
-
-sub _Error($)
-{
- my ($self) = @_;
- if (defined($self->YYData->{LAST_TOKEN})) {
- $self->YYData->{ERROR}->("Parse error in `".$self->YYData->{FULL_INPUT}."' near `". $self->YYData->{LAST_TOKEN} . "'");
- } else {
- $self->YYData->{ERROR}->("Parse error in `".$self->YYData->{FULL_INPUT}."'");
- }
-}
-
-sub Run {
- my($self, $data, $error, $lookup, $deref, $use) = @_;
- $self->YYData->{FULL_INPUT} = $data;
- $self->YYData->{INPUT} = $data;
- $self->YYData->{LOOKUP} = $lookup;
- $self->YYData->{DEREFERENCE} = $deref;
- $self->YYData->{ERROR} = $error;
- $self->YYData->{USE} = $use;
- return $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error);
-}
diff --git a/source4/pidl/idl.yp b/source4/pidl/idl.yp
deleted file mode 100644
index d557590494..0000000000
--- a/source4/pidl/idl.yp
+++ /dev/null
@@ -1,497 +0,0 @@
-########################
-# IDL Parse::Yapp parser
-# Copyright (C) Andrew Tridgell <tridge@samba.org>
-# released under the GNU GPL version 3 or later
-
-
-
-# the precedence actually doesn't matter at all for this grammar, but
-# by providing a precedence we reduce the number of conflicts
-# enormously
-%left '-' '+' '&' '|' '*' '>' '.' '/' '(' ')' '[' ',' ';'
-
-
-################
-# grammar
-%%
-idl:
- #empty { {} }
- | idl interface { push(@{$_[1]}, $_[2]); $_[1] }
- | idl coclass { push(@{$_[1]}, $_[2]); $_[1] }
- | idl import { push(@{$_[1]}, $_[2]); $_[1] }
- | idl include { push(@{$_[1]}, $_[2]); $_[1] }
- | idl importlib { push(@{$_[1]}, $_[2]); $_[1] }
- | idl cpp_quote { push(@{$_[1]}, $_[2]); $_[1] }
-;
-
-import: 'import' commalist ';' {{
- "TYPE" => "IMPORT",
- "PATHS" => $_[2],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE}
- }}
-;
-include: 'include' commalist ';' {{
- "TYPE" => "INCLUDE",
- "PATHS" => $_[2],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE}
- }}
-;
-importlib: 'importlib' commalist ';' {{
- "TYPE" => "IMPORTLIB",
- "PATHS" => $_[2],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE}
- }}
-;
-
-commalist:
- text { [ $_[1] ] }
- | commalist ',' text { push(@{$_[1]}, $_[3]); $_[1] }
-;
-
-coclass: property_list 'coclass' identifier '{' interface_names '}' optional_semicolon
- {{
- "TYPE" => "COCLASS",
- "PROPERTIES" => $_[1],
- "NAME" => $_[3],
- "DATA" => $_[5],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
-;
-
-interface_names:
- #empty { {} }
- | interface_names 'interface' identifier ';' { push(@{$_[1]}, $_[2]); $_[1] }
-;
-
-interface: property_list 'interface' identifier base_interface '{' definitions '}' optional_semicolon
- {{
- "TYPE" => "INTERFACE",
- "PROPERTIES" => $_[1],
- "NAME" => $_[3],
- "BASE" => $_[4],
- "DATA" => $_[6],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
-;
-
-base_interface:
- #empty
- | ':' identifier { $_[2] }
-;
-
-
-cpp_quote: 'cpp_quote' '(' text ')'
- {{
- "TYPE" => "CPP_QUOTE",
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- "DATA" => $_[3]
- }}
-;
-
-definitions:
- definition { [ $_[1] ] }
- | definitions definition { push(@{$_[1]}, $_[2]); $_[1] }
-;
-
-
-definition: function | const | typedef | typedecl
-;
-
-const: 'const' identifier pointers identifier '=' anytext ';'
- {{
- "TYPE" => "CONST",
- "DTYPE" => $_[2],
- "POINTERS" => $_[3],
- "NAME" => $_[4],
- "VALUE" => $_[6],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
- | 'const' identifier pointers identifier array_len '=' anytext ';'
- {{
- "TYPE" => "CONST",
- "DTYPE" => $_[2],
- "POINTERS" => $_[3],
- "NAME" => $_[4],
- "ARRAY_LEN" => $_[5],
- "VALUE" => $_[7],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
-;
-
-
-function: property_list type identifier '(' element_list2 ')' ';'
- {{
- "TYPE" => "FUNCTION",
- "NAME" => $_[3],
- "RETURN_TYPE" => $_[2],
- "PROPERTIES" => $_[1],
- "ELEMENTS" => $_[5],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
-;
-
-typedef: property_list 'typedef' type identifier array_len ';'
- {{
- "TYPE" => "TYPEDEF",
- "PROPERTIES" => $_[1],
- "NAME" => $_[4],
- "DATA" => $_[3],
- "ARRAY_LEN" => $_[5],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
-;
-
-usertype: struct | union | enum | bitmap;
-
-typedecl: usertype ';' { $_[1] };
-
-sign: 'signed' | 'unsigned';
-
-existingtype:
- sign identifier { ($_[1]?$_[1]:"signed") ." $_[2]" }
- | identifier
-;
-
-type: usertype | existingtype | void { "void" } ;
-
-enum_body: '{' enum_elements '}' { $_[2] };
-opt_enum_body: | enum_body;
-enum: property_list 'enum' optional_identifier opt_enum_body
- {{
- "TYPE" => "ENUM",
- "PROPERTIES" => $_[1],
- "NAME" => $_[3],
- "ELEMENTS" => $_[4]
- }}
-;
-
-enum_elements:
- enum_element { [ $_[1] ] }
- | enum_elements ',' enum_element { push(@{$_[1]}, $_[3]); $_[1] }
-;
-
-enum_element: identifier
- | identifier '=' anytext { "$_[1]$_[2]$_[3]" }
-;
-
-bitmap_body: '{' opt_bitmap_elements '}' { $_[2] };
-opt_bitmap_body: | bitmap_body;
-bitmap: property_list 'bitmap' optional_identifier opt_bitmap_body
- {{
- "TYPE" => "BITMAP",
- "PROPERTIES" => $_[1],
- "NAME" => $_[3],
- "ELEMENTS" => $_[4]
- }}
-;
-
-bitmap_elements:
- bitmap_element { [ $_[1] ] }
- | bitmap_elements ',' bitmap_element { push(@{$_[1]}, $_[3]); $_[1] }
-;
-
-opt_bitmap_elements: | bitmap_elements;
-
-bitmap_element: identifier '=' anytext { "$_[1] ( $_[3] )" }
-;
-
-struct_body: '{' element_list1 '}' { $_[2] };
-opt_struct_body: | struct_body;
-
-struct: property_list 'struct' optional_identifier opt_struct_body
- {{
- "TYPE" => "STRUCT",
- "PROPERTIES" => $_[1],
- "NAME" => $_[3],
- "ELEMENTS" => $_[4]
- }}
-;
-
-empty_element: property_list ';'
- {{
- "NAME" => "",
- "TYPE" => "EMPTY",
- "PROPERTIES" => $_[1],
- "POINTERS" => 0,
- "ARRAY_LEN" => [],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
-;
-
-base_or_empty: base_element ';' | empty_element;
-
-optional_base_element:
- property_list base_or_empty { $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
-;
-
-union_elements:
- #empty
- | union_elements optional_base_element { push(@{$_[1]}, $_[2]); $_[1] }
-;
-
-union_body: '{' union_elements '}' { $_[2] };
-opt_union_body: | union_body;
-
-union: property_list 'union' optional_identifier opt_union_body
- {{
- "TYPE" => "UNION",
- "PROPERTIES" => $_[1],
- "NAME" => $_[3],
- "ELEMENTS" => $_[4]
- }}
-;
-
-base_element: property_list type pointers identifier array_len
- {{
- "NAME" => $_[4],
- "TYPE" => $_[2],
- "PROPERTIES" => $_[1],
- "POINTERS" => $_[3],
- "ARRAY_LEN" => $_[5],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
-;
-
-
-pointers:
- #empty
- { 0 }
- | pointers '*' { $_[1]+1 }
-;
-
-element_list1:
- { [] }
- | element_list1 base_element ';' { push(@{$_[1]}, $_[2]); $_[1] }
-;
-
-optional_const:
- #empty
- | 'const'
-;
-
-element_list2:
- #empty
- | 'void'
- | optional_const base_element { [ $_[2] ] }
- | element_list2 ',' optional_const base_element { push(@{$_[1]}, $_[4]); $_[1] }
-;
-
-array_len:
- #empty { [] }
- | '[' ']' array_len { push(@{$_[3]}, "*"); $_[3] }
- | '[' anytext ']' array_len { push(@{$_[4]}, "$_[2]"); $_[4] }
-;
-
-
-property_list:
- #empty
- | property_list '[' properties ']' { FlattenHash([$_[1],$_[3]]); }
-;
-
-properties: property { $_[1] }
- | properties ',' property { FlattenHash([$_[1], $_[3]]); }
-;
-
-property: identifier {{ "$_[1]" => "1" }}
- | identifier '(' commalisttext ')' {{ "$_[1]" => "$_[3]" }}
-;
-
-commalisttext:
- anytext
- | commalisttext ',' anytext { "$_[1],$_[3]" }
-;
-
-anytext: #empty
- { "" }
- | identifier | constant | text
- | anytext '-' anytext { "$_[1]$_[2]$_[3]" }
- | anytext '.' anytext { "$_[1]$_[2]$_[3]" }
- | anytext '*' anytext { "$_[1]$_[2]$_[3]" }
- | anytext '>' anytext { "$_[1]$_[2]$_[3]" }
- | anytext '<' anytext { "$_[1]$_[2]$_[3]" }
- | anytext '|' anytext { "$_[1]$_[2]$_[3]" }
- | anytext '&' anytext { "$_[1]$_[2]$_[3]" }
- | anytext '/' anytext { "$_[1]$_[2]$_[3]" }
- | anytext '?' anytext { "$_[1]$_[2]$_[3]" }
- | anytext ':' anytext { "$_[1]$_[2]$_[3]" }
- | anytext '=' anytext { "$_[1]$_[2]$_[3]" }
- | anytext '+' anytext { "$_[1]$_[2]$_[3]" }
- | anytext '~' anytext { "$_[1]$_[2]$_[3]" }
- | anytext '(' commalisttext ')' anytext { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
- | anytext '{' commalisttext '}' anytext { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
-;
-
-identifier: IDENTIFIER
-;
-
-optional_identifier:
- IDENTIFIER
- | #empty { undef }
-;
-
-constant: CONSTANT
-;
-
-text: TEXT { "\"$_[1]\"" }
-;
-
-optional_semicolon:
- #empty
- | ';'
-;
-
-
-#####################################
-# start code
-%%
-
-use Parse::Pidl qw(error);
-
-#####################################################################
-# flatten an array of hashes into a single hash
-sub FlattenHash($)
-{
- my $a = shift;
- my %b;
- for my $d (@{$a}) {
- for my $k (keys %{$d}) {
- $b{$k} = $d->{$k};
- }
- }
- return \%b;
-}
-
-
-
-#####################################################################
-# traverse a perl data structure removing any empty arrays or
-# hashes and any hash elements that map to undef
-sub CleanData($)
-{
- sub CleanData($);
- my($v) = shift;
- return undef if (not defined($v));
- if (ref($v) eq "ARRAY") {
- foreach my $i (0 .. $#{$v}) {
- CleanData($v->[$i]);
- }
- # this removes any undefined elements from the array
- @{$v} = grep { defined $_ } @{$v};
- } elsif (ref($v) eq "HASH") {
- foreach my $x (keys %{$v}) {
- CleanData($v->{$x});
- if (!defined $v->{$x}) { delete($v->{$x}); next; }
- }
- }
- return $v;
-}
-
-sub _Error {
- if (exists $_[0]->YYData->{ERRMSG}) {
- error($_[0]->YYData, $_[0]->YYData->{ERRMSG});
- delete $_[0]->YYData->{ERRMSG};
- return;
- }
- my $last_token = $_[0]->YYData->{LAST_TOKEN};
-
- error($_[0]->YYData, "Syntax error near '$last_token'");
-}
-
-sub _Lexer($)
-{
- my($parser)=shift;
-
- $parser->YYData->{INPUT} or return('',undef);
-
-again:
- $parser->YYData->{INPUT} =~ s/^[ \t]*//;
-
- for ($parser->YYData->{INPUT}) {
- if (/^\#/) {
- if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
- $parser->YYData->{LINE} = $1-1;
- $parser->YYData->{FILE} = $2;
- goto again;
- }
- if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
- $parser->YYData->{LINE} = $1-1;
- $parser->YYData->{FILE} = $2;
- goto again;
- }
- if (s/^(\#.*)$//m) {
- goto again;
- }
- }
- if (s/^(\n)//) {
- $parser->YYData->{LINE}++;
- goto again;
- }
- if (s/^\"(.*?)\"//) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return('TEXT',$1);
- }
- if (s/^(\d+)(\W|$)/$2/) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return('CONSTANT',$1);
- }
- if (s/^([\w_]+)//) {
- $parser->YYData->{LAST_TOKEN} = $1;
- if ($1 =~
- /^(coclass|interface|const|typedef|union|cpp_quote
- |struct|enum|bitmap|void|unsigned|signed|import|include
- |importlib)$/x) {
- return $1;
- }
- return('IDENTIFIER',$1);
- }
- if (s/^(.)//s) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return($1,$1);
- }
- }
-}
-
-sub parse_string
-{
- my ($data,$filename) = @_;
-
- my $self = new Parse::Pidl::IDL;
-
- $self->YYData->{FILE} = $filename;
- $self->YYData->{INPUT} = $data;
- $self->YYData->{LINE} = 0;
- $self->YYData->{LAST_TOKEN} = "NONE";
-
- my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
-
- return CleanData($idl);
-}
-
-sub parse_file($$)
-{
- my ($filename,$incdirs) = @_;
-
- my $saved_delim = $/;
- undef $/;
- my $cpp = $ENV{CPP};
- if (! defined $cpp) {
- $cpp = "cpp";
- }
- my $includes = join('',map { " -I$_" } @$incdirs);
- my $data = `$cpp -D__PIDL__$includes -xc $filename`;
- $/ = $saved_delim;
-
- return parse_string($data, $filename);
-}
diff --git a/source4/pidl/lib/Parse/Pidl.pm b/source4/pidl/lib/Parse/Pidl.pm
deleted file mode 100644
index c2c9463d03..0000000000
--- a/source4/pidl/lib/Parse/Pidl.pm
+++ /dev/null
@@ -1,38 +0,0 @@
-###################################################
-# package to parse IDL files and generate code for
-# rpc functions in Samba
-# Copyright tridge@samba.org 2000-2003
-# Copyright jelmer@samba.org 2005
-# released under the GNU GPL
-
-package Parse::Pidl;
-
-require Exporter;
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(warning error fatal $VERSION);
-
-use strict;
-
-use vars qw ( $VERSION );
-
-$VERSION = '0.02';
-
-sub warning
-{
- my ($l,$m) = @_;
- print STDERR "$l->{FILE}:$l->{LINE}: warning: $m\n";
-}
-
-sub error
-{
- my ($l,$m) = @_;
- print STDERR "$l->{FILE}:$l->{LINE}: error: $m\n";
-}
-
-sub fatal($$)
-{
- my ($e,$s) = @_;
- die("$e->{FILE}:$e->{LINE}: $s\n");
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/CUtil.pm b/source4/pidl/lib/Parse/Pidl/CUtil.pm
deleted file mode 100644
index 9deb6ee177..0000000000
--- a/source4/pidl/lib/Parse/Pidl/CUtil.pm
+++ /dev/null
@@ -1,52 +0,0 @@
-###################################################
-# C utility functions for pidl
-# Copyright jelmer@samba.org 2005-2007
-# released under the GNU GPL
-package Parse::Pidl::CUtil;
-
-require Exporter;
-@ISA = qw(Exporter);
-@EXPORT = qw(get_pointer_to get_value_of get_array_element);
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-use strict;
-
-sub get_pointer_to($)
-{
- my $var_name = shift;
-
- if ($var_name =~ /^\*(.*)$/) {
- return $1;
- } elsif ($var_name =~ /^\&(.*)$/) {
- return "&($var_name)";
- } else {
- return "&$var_name";
- }
-}
-
-sub get_value_of($)
-{
- my $var_name = shift;
-
- if ($var_name =~ /^\&(.*)$/) {
- return $1;
- } else {
- return "*$var_name";
- }
-}
-
-sub get_array_element($$)
-{
- my ($var_name, $idx) = @_;
-
- if ($var_name =~ /^\*.*$/) {
- $var_name = "($var_name)";
- } elsif ($var_name =~ /^\&.*$/) {
- $var_name = "($var_name)";
- }
-
- return "$var_name"."[$idx]";
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Compat.pm b/source4/pidl/lib/Parse/Pidl/Compat.pm
deleted file mode 100644
index 7519021144..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Compat.pm
+++ /dev/null
@@ -1,163 +0,0 @@
-###################################################
-# IDL Compatibility checker
-# Copyright jelmer@samba.org 2005
-# released under the GNU GPL
-
-package Parse::Pidl::Compat;
-
-use Parse::Pidl qw(warning);
-use Parse::Pidl::Util qw(has_property);
-use strict;
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-my %supported_properties = (
- # interface
- "helpstring" => ["INTERFACE", "FUNCTION"],
- "version" => ["INTERFACE"],
- "uuid" => ["INTERFACE"],
- "endpoint" => ["INTERFACE"],
- "pointer_default" => ["INTERFACE"],
-
- # dcom
- "object" => ["INTERFACE"],
- "local" => ["INTERFACE", "FUNCTION"],
- "iid_is" => ["ELEMENT"],
- "call_as" => ["FUNCTION"],
- "idempotent" => ["FUNCTION"],
-
- # function
- "in" => ["ELEMENT"],
- "out" => ["ELEMENT"],
-
- # pointer
- "ref" => ["ELEMENT"],
- "ptr" => ["ELEMENT"],
- "unique" => ["ELEMENT"],
- "ignore" => ["ELEMENT"],
-
- "value" => ["ELEMENT"],
-
- # generic
- "public" => ["FUNCTION", "TYPEDEF"],
- "nopush" => ["FUNCTION", "TYPEDEF"],
- "nopull" => ["FUNCTION", "TYPEDEF"],
- "noprint" => ["FUNCTION", "TYPEDEF"],
- "noejs" => ["FUNCTION", "TYPEDEF"],
-
- # union
- "switch_is" => ["ELEMENT"],
- "switch_type" => ["ELEMENT", "TYPEDEF"],
- "case" => ["ELEMENT"],
- "default" => ["ELEMENT"],
-
- # subcontext
- "subcontext" => ["ELEMENT"],
- "subcontext_size" => ["ELEMENT"],
-
- # enum
- "enum16bit" => ["TYPEDEF"],
- "v1_enum" => ["TYPEDEF"],
-
- # bitmap
- "bitmap8bit" => ["TYPEDEF"],
- "bitmap16bit" => ["TYPEDEF"],
- "bitmap32bit" => ["TYPEDEF"],
- "bitmap64bit" => ["TYPEDEF"],
-
- # array
- "range" => ["ELEMENT"],
- "size_is" => ["ELEMENT"],
- "string" => ["ELEMENT"],
- "noheader" => ["ELEMENT"],
- "charset" => ["ELEMENT"],
- "length_is" => ["ELEMENT"],
-);
-
-sub CheckTypedef($)
-{
- my ($td) = @_;
-
- if (has_property($td, "nodiscriminant")) {
- warning($td, "nodiscriminant property not supported");
- }
-
- if ($td->{TYPE} eq "BITMAP") {
- warning($td, "converting bitmap to scalar");
- #FIXME
- }
-
- if (has_property($td, "gensize")) {
- warning($td, "ignoring gensize() property. ");
- }
-
- if (has_property($td, "enum8bit") and has_property($td, "enum16bit")) {
- warning($td, "8 and 16 bit enums not supported, converting to scalar");
- #FIXME
- }
-
- StripProperties($td);
-}
-
-sub CheckElement($)
-{
- my $e = shift;
-
- if (has_property($e, "noheader")) {
- warning($e, "noheader property not supported");
- return;
- }
-
- if (has_property($e, "subcontext")) {
- warning($e, "converting subcontext to byte array");
- #FIXME
- }
-
- if (has_property($e, "compression")) {
- warning($e, "compression() property not supported");
- }
-
- if (has_property($e, "sptr")) {
- warning($e, "sptr() pointer property not supported");
- }
-
- if (has_property($e, "relative")) {
- warning($e, "relative() pointer property not supported");
- }
-
- if (has_property($e, "flag")) {
- warning($e, "ignoring flag() property");
- }
-
- if (has_property($e, "value")) {
- warning($e, "ignoring value() property");
- }
-}
-
-sub CheckFunction($)
-{
- my $fn = shift;
-
- if (has_property($fn, "noopnum")) {
- warning($fn, "noopnum not converted. Opcodes will be out of sync.");
- }
-}
-
-sub CheckInterface($)
-{
- my $if = shift;
-
-}
-
-sub Check($)
-{
- my $pidl = shift;
- my $nidl = [];
-
- foreach (@{$pidl}) {
- push (@$nidl, CheckInterface($_)) if ($_->{TYPE} eq "INTERFACE");
- }
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Dump.pm b/source4/pidl/lib/Parse/Pidl/Dump.pm
deleted file mode 100644
index bf5811c116..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Dump.pm
+++ /dev/null
@@ -1,294 +0,0 @@
-###################################################
-# dump function for IDL structures
-# Copyright tridge@samba.org 2000
-# Copyright jelmer@samba.org 2005
-# released under the GNU GPL
-
-=pod
-
-=head1 NAME
-
-Parse::Pidl::Dump - Dump support
-
-=head1 DESCRIPTION
-
-This module provides functions that can generate IDL code from
-internal pidl data structures.
-
-=cut
-
-package Parse::Pidl::Dump;
-
-use Exporter;
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(DumpType DumpTypedef DumpStruct DumpEnum DumpBitmap DumpUnion DumpFunction);
-
-use strict;
-use Parse::Pidl::Util qw(has_property);
-
-my($res);
-
-#####################################################################
-# dump a properties list
-sub DumpProperties($)
-{
- my($props) = shift;
- my $res = "";
-
- foreach my $d ($props) {
- foreach my $k (keys %{$d}) {
- if ($k eq "in") {
- $res .= "[in] ";
- next;
- }
- if ($k eq "out") {
- $res .= "[out] ";
- next;
- }
- if ($k eq "ref") {
- $res .= "[ref] ";
- next;
- }
- $res .= "[$k($d->{$k})] ";
- }
- }
- return $res;
-}
-
-#####################################################################
-# dump a structure element
-sub DumpElement($)
-{
- my($element) = shift;
- my $res = "";
-
- (defined $element->{PROPERTIES}) &&
- ($res .= DumpProperties($element->{PROPERTIES}));
- $res .= DumpType($element->{TYPE});
- $res .= " ";
- for my $i (1..$element->{POINTERS}) {
- $res .= "*";
- }
- $res .= "$element->{NAME}";
- foreach (@{$element->{ARRAY_LEN}}) {
- $res .= "[$_]";
- }
-
- return $res;
-}
-
-#####################################################################
-# dump a struct
-sub DumpStruct($)
-{
- my($struct) = shift;
- my($res);
-
- $res .= "struct ";
- if ($struct->{NAME}) {
- $res.="$struct->{NAME} ";
- }
-
- $res.="{\n";
- if (defined $struct->{ELEMENTS}) {
- foreach (@{$struct->{ELEMENTS}}) {
- $res .= "\t" . DumpElement($_) . ";\n";
- }
- }
- $res .= "}";
-
- return $res;
-}
-
-
-#####################################################################
-# dump a struct
-sub DumpEnum($)
-{
- my($enum) = shift;
- my($res);
-
- $res .= "enum {\n";
-
- foreach (@{$enum->{ELEMENTS}}) {
- if (/^([A-Za-z0-9_]+)[ \t]*\((.*)\)$/) {
- $res .= "\t$1 = $2,\n";
- } else {
- $res .= "\t$_,\n";
- }
- }
-
- $res.= "}";
-
- return $res;
-}
-
-#####################################################################
-# dump a struct
-sub DumpBitmap($)
-{
- my($bitmap) = shift;
- my($res);
-
- $res .= "bitmap {\n";
-
- foreach (@{$bitmap->{ELEMENTS}}) {
- if (/^([A-Za-z0-9_]+)[ \t]*\((.*)\)$/) {
- $res .= "\t$1 = $2,\n";
- } else {
- die ("Bitmap $bitmap->{NAME} has field $_ without proper value");
- }
- }
-
- $res.= "}";
-
- return $res;
-}
-
-
-#####################################################################
-# dump a union element
-sub DumpUnionElement($)
-{
- my($element) = shift;
- my($res);
-
- if (has_property($element, "default")) {
- $res .= "[default] ;\n";
- } else {
- $res .= "[case($element->{PROPERTIES}->{case})] ";
- $res .= DumpElement($element), if defined($element);
- $res .= ";\n";
- }
-
- return $res;
-}
-
-#####################################################################
-# dump a union
-sub DumpUnion($)
-{
- my($union) = shift;
- my($res);
-
- (defined $union->{PROPERTIES}) &&
- ($res .= DumpProperties($union->{PROPERTIES}));
- $res .= "union {\n";
- foreach my $e (@{$union->{ELEMENTS}}) {
- $res .= DumpUnionElement($e);
- }
- $res .= "}";
-
- return $res;
-}
-
-#####################################################################
-# dump a type
-sub DumpType($)
-{
- my($data) = shift;
-
- if (ref($data) eq "HASH") {
- return DumpStruct($data) if ($data->{TYPE} eq "STRUCT");
- return DumpUnion($data) if ($data->{TYPE} eq "UNION");
- return DumpEnum($data) if ($data->{TYPE} eq "ENUM");
- return DumpBitmap($data) if ($data->{TYPE} eq "BITMAP");
- } else {
- return $data;
- }
-}
-
-#####################################################################
-# dump a typedef
-sub DumpTypedef($)
-{
- my($typedef) = shift;
- my($res);
-
- $res .= "typedef ";
- $res .= DumpType($typedef->{DATA});
- $res .= " $typedef->{NAME};\n\n";
-
- return $res;
-}
-
-#####################################################################
-# dump a typedef
-sub DumpFunction($)
-{
- my($function) = shift;
- my($first) = 1;
- my($res);
-
- $res .= DumpType($function->{RETURN_TYPE});
- $res .= " $function->{NAME}(\n";
- for my $d (@{$function->{ELEMENTS}}) {
- unless ($first) { $res .= ",\n"; } $first = 0;
- $res .= DumpElement($d);
- }
- $res .= "\n);\n\n";
-
- return $res;
-}
-
-#####################################################################
-# dump a module header
-sub DumpInterfaceProperties($)
-{
- my($header) = shift;
- my($data) = $header->{DATA};
- my($first) = 1;
- my($res);
-
- $res .= "[\n";
- foreach my $k (keys %{$data}) {
- $first || ($res .= ",\n"); $first = 0;
- $res .= "$k($data->{$k})";
- }
- $res .= "\n]\n";
-
- return $res;
-}
-
-#####################################################################
-# dump the interface definitions
-sub DumpInterface($)
-{
- my($interface) = shift;
- my($data) = $interface->{DATA};
- my($res);
-
- $res .= DumpInterfaceProperties($interface->{PROPERTIES});
-
- $res .= "interface $interface->{NAME}\n{\n";
- foreach my $d (@{$data}) {
- ($d->{TYPE} eq "TYPEDEF") &&
- ($res .= DumpTypedef($d));
- ($d->{TYPE} eq "FUNCTION") &&
- ($res .= DumpFunction($d));
- }
- $res .= "}\n";
-
- return $res;
-}
-
-
-#####################################################################
-# dump a parsed IDL structure back into an IDL file
-sub Dump($)
-{
- my($idl) = shift;
- my($res);
-
- $res = "/* Dumped by pidl */\n\n";
- foreach my $x (@{$idl}) {
- ($x->{TYPE} eq "INTERFACE") &&
- ($res .= DumpInterface($x));
- }
- return $res;
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Expr.pm b/source4/pidl/lib/Parse/Pidl/Expr.pm
deleted file mode 100644
index 5524374fae..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Expr.pm
+++ /dev/null
@@ -1,1442 +0,0 @@
-####################################################################
-#
-# This file was generated using Parse::Yapp version 1.05.
-#
-# Don't edit this file, use source file instead.
-#
-# ANY CHANGE MADE HERE WILL BE LOST !
-#
-####################################################################
-package Parse::Pidl::Expr;
-use vars qw ( @ISA );
-use strict;
-
-@ISA= qw ( Parse::Yapp::Driver );
-use Parse::Yapp::Driver;
-
-
-
-sub new {
- my($class)=shift;
- ref($class)
- and $class=ref($class);
-
- my($self)=$class->SUPER::new( yyversion => '1.05',
- yystates =>
-[
- {#State 0
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'NUM' => 5,
- 'TEXT' => 6,
- "(" => 7,
- "!" => 8,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 2,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 1
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "(" => 7,
- "!" => 8,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 14,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 2
- ACTIONS => {
- '' => 16,
- "-" => 15,
- "<" => 17,
- "+" => 18,
- "%" => 19,
- "==" => 20,
- "^" => 21,
- "*" => 22,
- ">>" => 23,
- "!=" => 24,
- "?" => 25,
- "||" => 26,
- "&&" => 27,
- "&" => 28,
- "/" => 29,
- "|" => 30,
- "<<" => 32,
- "=>" => 31,
- "<=" => 33,
- ">" => 34
- }
- },
- {#State 3
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 35,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 4
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 36,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 5
- DEFAULT => -1
- },
- {#State 6
- DEFAULT => -2
- },
- {#State 7
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 38,
- 'var' => 37,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 8
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 39,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 9
- ACTIONS => {
- "*" => 9,
- 'VAR' => 41
- },
- GOTOS => {
- 'possible_pointer' => 40
- }
- },
- {#State 10
- ACTIONS => {
- "(" => 42
- },
- DEFAULT => -30
- },
- {#State 11
- ACTIONS => {
- "->" => 43,
- "." => 44
- },
- DEFAULT => -4
- },
- {#State 12
- DEFAULT => -3
- },
- {#State 13
- DEFAULT => -32
- },
- {#State 14
- ACTIONS => {
- "^" => 21,
- "=>" => 31,
- "<=" => 33
- },
- DEFAULT => -26
- },
- {#State 15
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 45,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 16
- DEFAULT => 0
- },
- {#State 17
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 46,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 18
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 47,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 19
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 48,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 20
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 49,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 21
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 50,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 22
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 51,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 23
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 52,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 24
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 53,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 25
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 54,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 26
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 55,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 27
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 56,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 28
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 57,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 29
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 58,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 30
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 59,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 31
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 60,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 32
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 61,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 33
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 62,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 34
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 63,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 35
- ACTIONS => {
- "^" => 21,
- "=>" => 31,
- "<=" => 33
- },
- DEFAULT => -5
- },
- {#State 36
- ACTIONS => {
- "^" => 21,
- "=>" => 31,
- "<=" => 33
- },
- DEFAULT => -27
- },
- {#State 37
- ACTIONS => {
- ")" => 64,
- "->" => 43,
- "." => 44
- },
- DEFAULT => -4
- },
- {#State 38
- ACTIONS => {
- "-" => 15,
- "<" => 17,
- "+" => 18,
- "%" => 19,
- "==" => 20,
- "^" => 21,
- "*" => 22,
- ")" => 65,
- ">>" => 23,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "/" => 29,
- "|" => 30,
- "=>" => 31,
- "<<" => 32,
- "<=" => 33,
- ">" => 34
- }
- },
- {#State 39
- ACTIONS => {
- "-" => 15,
- "<" => 17,
- "+" => 18,
- "%" => 19,
- "==" => 20,
- "^" => 21,
- "*" => 22,
- ">>" => 23,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "/" => 29,
- "|" => 30,
- "=>" => 31,
- "<<" => 32,
- "<=" => 33,
- ">" => 34
- },
- DEFAULT => -24
- },
- {#State 40
- DEFAULT => -31
- },
- {#State 41
- DEFAULT => -30
- },
- {#State 42
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- DEFAULT => -37,
- GOTOS => {
- 'exp' => 69,
- 'var' => 11,
- 'args' => 66,
- 'func' => 12,
- 'opt_args' => 70,
- 'exp_or_possible_pointer' => 67,
- 'possible_pointer' => 68
- }
- },
- {#State 43
- ACTIONS => {
- 'VAR' => 71
- }
- },
- {#State 44
- ACTIONS => {
- 'VAR' => 72
- }
- },
- {#State 45
- ACTIONS => {
- "<" => 17,
- "==" => 20,
- "^" => 21,
- ">>" => 23,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "|" => 30,
- "=>" => 31,
- "<<" => 32,
- "<=" => 33,
- ">" => 34
- },
- DEFAULT => -7
- },
- {#State 46
- ACTIONS => {
- "==" => 20,
- "^" => 21,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "|" => 30,
- "=>" => 31,
- "<=" => 33
- },
- DEFAULT => -10
- },
- {#State 47
- ACTIONS => {
- "<" => 17,
- "==" => 20,
- "^" => 21,
- ">>" => 23,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "|" => 30,
- "=>" => 31,
- "<<" => 32,
- "<=" => 33,
- ">" => 34
- },
- DEFAULT => -6
- },
- {#State 48
- ACTIONS => {
- "-" => 15,
- "<" => 17,
- "+" => 18,
- "==" => 20,
- "^" => 21,
- ">>" => 23,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "|" => 30,
- "=>" => 31,
- "<<" => 32,
- "<=" => 33,
- ">" => 34
- },
- DEFAULT => -9
- },
- {#State 49
- ACTIONS => {
- "^" => 21,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "|" => 30,
- "=>" => 31,
- "<=" => 33
- },
- DEFAULT => -13
- },
- {#State 50
- ACTIONS => {
- "-" => 15,
- "<" => 17,
- "+" => 18,
- "%" => 19,
- "==" => 20,
- "^" => 21,
- "*" => 22,
- ">>" => 23,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "/" => 29,
- "|" => 30,
- "=>" => 31,
- "<<" => 32,
- "<=" => 33,
- ">" => 34
- },
- DEFAULT => -28
- },
- {#State 51
- ACTIONS => {
- "-" => 15,
- "<" => 17,
- "+" => 18,
- "==" => 20,
- "^" => 21,
- ">>" => 23,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "|" => 30,
- "=>" => 31,
- "<<" => 32,
- "<=" => 33,
- ">" => 34
- },
- DEFAULT => -8
- },
- {#State 52
- ACTIONS => {
- "<" => 17,
- "==" => 20,
- "^" => 21,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "|" => 30,
- "=>" => 31,
- "<=" => 33,
- ">" => 34
- },
- DEFAULT => -17
- },
- {#State 53
- ACTIONS => {
- "^" => 21,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "|" => 30,
- "=>" => 31,
- "<=" => 33
- },
- DEFAULT => -18
- },
- {#State 54
- ACTIONS => {
- ":" => 73,
- "-" => 15,
- "<" => 17,
- "+" => 18,
- "%" => 19,
- "==" => 20,
- "^" => 21,
- "*" => 22,
- ">>" => 23,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "/" => 29,
- "|" => 30,
- "=>" => 31,
- "<<" => 32,
- "<=" => 33,
- ">" => 34
- }
- },
- {#State 55
- ACTIONS => {
- "^" => 21,
- "?" => 25,
- "=>" => 31,
- "<=" => 33
- },
- DEFAULT => -19
- },
- {#State 56
- ACTIONS => {
- "^" => 21,
- "?" => 25,
- "||" => 26,
- "=>" => 31,
- "<=" => 33
- },
- DEFAULT => -20
- },
- {#State 57
- ACTIONS => {
- "^" => 21,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "|" => 30,
- "=>" => 31,
- "<=" => 33
- },
- DEFAULT => -21
- },
- {#State 58
- ACTIONS => {
- "-" => 15,
- "<" => 17,
- "+" => 18,
- "==" => 20,
- "^" => 21,
- ">>" => 23,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "|" => 30,
- "=>" => 31,
- "<<" => 32,
- "<=" => 33,
- ">" => 34
- },
- DEFAULT => -25
- },
- {#State 59
- ACTIONS => {
- "^" => 21,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "=>" => 31,
- "<=" => 33
- },
- DEFAULT => -12
- },
- {#State 60
- ACTIONS => {
- "-" => 15,
- "<" => 17,
- "+" => 18,
- "%" => 19,
- "==" => 20,
- "^" => 21,
- "*" => 22,
- ">>" => 23,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "/" => 29,
- "|" => 30,
- "=>" => 31,
- "<<" => 32,
- "<=" => 33,
- ">" => 34
- },
- DEFAULT => -15
- },
- {#State 61
- ACTIONS => {
- "<" => 17,
- "==" => 20,
- "^" => 21,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "|" => 30,
- "=>" => 31,
- "<=" => 33,
- ">" => 34
- },
- DEFAULT => -16
- },
- {#State 62
- ACTIONS => {
- "-" => 15,
- "<" => 17,
- "+" => 18,
- "%" => 19,
- "==" => 20,
- "^" => 21,
- "*" => 22,
- ">>" => 23,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "/" => 29,
- "|" => 30,
- "=>" => 31,
- "<<" => 32,
- "<=" => 33,
- ">" => 34
- },
- DEFAULT => -14
- },
- {#State 63
- ACTIONS => {
- "==" => 20,
- "^" => 21,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "|" => 30,
- "=>" => 31,
- "<=" => 33
- },
- DEFAULT => -11
- },
- {#State 64
- DEFAULT => -34
- },
- {#State 65
- DEFAULT => -29
- },
- {#State 66
- DEFAULT => -38
- },
- {#State 67
- ACTIONS => {
- "," => 74
- },
- DEFAULT => -41
- },
- {#State 68
- DEFAULT => -32
- },
- {#State 69
- ACTIONS => {
- "-" => 15,
- "<" => 17,
- "+" => 18,
- "%" => 19,
- "==" => 20,
- "^" => 21,
- "*" => 22,
- ">>" => 23,
- "!=" => 24,
- "?" => 25,
- "&&" => 27,
- "||" => 26,
- "&" => 28,
- "/" => 29,
- "|" => 30,
- "=>" => 31,
- "<<" => 32,
- "<=" => 33,
- ">" => 34
- },
- DEFAULT => -39
- },
- {#State 70
- ACTIONS => {
- ")" => 75
- }
- },
- {#State 71
- DEFAULT => -35
- },
- {#State 72
- DEFAULT => -33
- },
- {#State 73
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 76,
- 'var' => 11,
- 'func' => 12,
- 'possible_pointer' => 13
- }
- },
- {#State 74
- ACTIONS => {
- "-" => 1,
- "~" => 3,
- "&" => 4,
- 'TEXT' => 6,
- 'NUM' => 5,
- "!" => 8,
- "(" => 7,
- "*" => 9,
- 'VAR' => 10
- },
- GOTOS => {
- 'exp' => 69,
- 'var' => 11,
- 'args' => 77,
- 'func' => 12,
- 'exp_or_possible_pointer' => 67,
- 'possible_pointer' => 68
- }
- },
- {#State 75
- DEFAULT => -36
- },
- {#State 76
- ACTIONS => {
- "^" => 21,
- "=>" => 31,
- "<=" => 33
- },
- DEFAULT => -22
- },
- {#State 77
- DEFAULT => -42
- }
-],
- yyrules =>
-[
- [#Rule 0
- '$start', 2, undef
- ],
- [#Rule 1
- 'exp', 1, undef
- ],
- [#Rule 2
- 'exp', 1,
-sub
-#line 22 "./pidl/expr.yp"
-{ "\"$_[1]\"" }
- ],
- [#Rule 3
- 'exp', 1, undef
- ],
- [#Rule 4
- 'exp', 1, undef
- ],
- [#Rule 5
- 'exp', 2,
-sub
-#line 25 "./pidl/expr.yp"
-{ "~$_[2]" }
- ],
- [#Rule 6
- 'exp', 3,
-sub
-#line 26 "./pidl/expr.yp"
-{ "$_[1] + $_[3]" }
- ],
- [#Rule 7
- 'exp', 3,
-sub
-#line 27 "./pidl/expr.yp"
-{ "$_[1] - $_[3]" }
- ],
- [#Rule 8
- 'exp', 3,
-sub
-#line 28 "./pidl/expr.yp"
-{ "$_[1] * $_[3]" }
- ],
- [#Rule 9
- 'exp', 3,
-sub
-#line 29 "./pidl/expr.yp"
-{ "$_[1] % $_[3]" }
- ],
- [#Rule 10
- 'exp', 3,
-sub
-#line 30 "./pidl/expr.yp"
-{ "$_[1] < $_[3]" }
- ],
- [#Rule 11
- 'exp', 3,
-sub
-#line 31 "./pidl/expr.yp"
-{ "$_[1] > $_[3]" }
- ],
- [#Rule 12
- 'exp', 3,
-sub
-#line 32 "./pidl/expr.yp"
-{ "$_[1] | $_[3]" }
- ],
- [#Rule 13
- 'exp', 3,
-sub
-#line 33 "./pidl/expr.yp"
-{ "$_[1] == $_[3]" }
- ],
- [#Rule 14
- 'exp', 3,
-sub
-#line 34 "./pidl/expr.yp"
-{ "$_[1] <= $_[3]" }
- ],
- [#Rule 15
- 'exp', 3,
-sub
-#line 35 "./pidl/expr.yp"
-{ "$_[1] => $_[3]" }
- ],
- [#Rule 16
- 'exp', 3,
-sub
-#line 36 "./pidl/expr.yp"
-{ "$_[1] << $_[3]" }
- ],
- [#Rule 17
- 'exp', 3,
-sub
-#line 37 "./pidl/expr.yp"
-{ "$_[1] >> $_[3]" }
- ],
- [#Rule 18
- 'exp', 3,
-sub
-#line 38 "./pidl/expr.yp"
-{ "$_[1] != $_[3]" }
- ],
- [#Rule 19
- 'exp', 3,
-sub
-#line 39 "./pidl/expr.yp"
-{ "$_[1] || $_[3]" }
- ],
- [#Rule 20
- 'exp', 3,
-sub
-#line 40 "./pidl/expr.yp"
-{ "$_[1] && $_[3]" }
- ],
- [#Rule 21
- 'exp', 3,
-sub
-#line 41 "./pidl/expr.yp"
-{ "$_[1] & $_[3]" }
- ],
- [#Rule 22
- 'exp', 5,
-sub
-#line 42 "./pidl/expr.yp"
-{ "$_[1]?$_[3]:$_[5]" }
- ],
- [#Rule 23
- 'exp', 2,
-sub
-#line 43 "./pidl/expr.yp"
-{ "~$_[1]" }
- ],
- [#Rule 24
- 'exp', 2,
-sub
-#line 44 "./pidl/expr.yp"
-{ "not $_[1]" }
- ],
- [#Rule 25
- 'exp', 3,
-sub
-#line 45 "./pidl/expr.yp"
-{ "$_[1] / $_[3]" }
- ],
- [#Rule 26
- 'exp', 2,
-sub
-#line 46 "./pidl/expr.yp"
-{ "-$_[2]" }
- ],
- [#Rule 27
- 'exp', 2,
-sub
-#line 47 "./pidl/expr.yp"
-{ "&$_[2]" }
- ],
- [#Rule 28
- 'exp', 3,
-sub
-#line 48 "./pidl/expr.yp"
-{ "$_[1]^$_[3]" }
- ],
- [#Rule 29
- 'exp', 3,
-sub
-#line 49 "./pidl/expr.yp"
-{ "($_[2])" }
- ],
- [#Rule 30
- 'possible_pointer', 1,
-sub
-#line 53 "./pidl/expr.yp"
-{ $_[0]->_Lookup($_[1]) }
- ],
- [#Rule 31
- 'possible_pointer', 2,
-sub
-#line 54 "./pidl/expr.yp"
-{ $_[0]->_Dereference($_[2]); "*$_[2]" }
- ],
- [#Rule 32
- 'var', 1,
-sub
-#line 57 "./pidl/expr.yp"
-{ $_[0]->_Use($_[1]) }
- ],
- [#Rule 33
- 'var', 3,
-sub
-#line 58 "./pidl/expr.yp"
-{ $_[0]->_Use("$_[1].$_[3]") }
- ],
- [#Rule 34
- 'var', 3,
-sub
-#line 59 "./pidl/expr.yp"
-{ "($_[2])" }
- ],
- [#Rule 35
- 'var', 3,
-sub
-#line 60 "./pidl/expr.yp"
-{ $_[0]->_Use("*$_[1]"); $_[1]."->".$_[3] }
- ],
- [#Rule 36
- 'func', 4,
-sub
-#line 64 "./pidl/expr.yp"
-{ "$_[1]($_[3])" }
- ],
- [#Rule 37
- 'opt_args', 0,
-sub
-#line 65 "./pidl/expr.yp"
-{ "" }
- ],
- [#Rule 38
- 'opt_args', 1, undef
- ],
- [#Rule 39
- 'exp_or_possible_pointer', 1, undef
- ],
- [#Rule 40
- 'exp_or_possible_pointer', 1, undef
- ],
- [#Rule 41
- 'args', 1, undef
- ],
- [#Rule 42
- 'args', 3,
-sub
-#line 68 "./pidl/expr.yp"
-{ "$_[1], $_[3]" }
- ]
-],
- @_);
- bless($self,$class);
-}
-
-#line 71 "./pidl/expr.yp"
-
-
-package Parse::Pidl::Expr;
-
-sub _Lexer {
- my($parser)=shift;
-
- $parser->YYData->{INPUT}=~s/^[ \t]//;
-
- for ($parser->YYData->{INPUT}) {
- if (s/^(0x[0-9A-Fa-f]+)//) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return('NUM',$1);
- }
- if (s/^([0-9]+(?:\.[0-9]+)?)//) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return('NUM',$1);
- }
- if (s/^([A-Za-z_][A-Za-z0-9_]*)//) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return('VAR',$1);
- }
- if (s/^\"(.*?)\"//) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return('TEXT',$1);
- }
- if (s/^(==|!=|<=|>=|->|\|\||<<|>>|&&)//s) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return($1,$1);
- }
- if (s/^(.)//s) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return($1,$1);
- }
- }
-}
-
-sub _Use($$)
-{
- my ($self, $x) = @_;
- if (defined($self->YYData->{USE})) {
- return $self->YYData->{USE}->($x);
- }
- return $x;
-}
-
-sub _Lookup($$)
-{
- my ($self, $x) = @_;
- return $self->YYData->{LOOKUP}->($x);
-}
-
-sub _Dereference($$)
-{
- my ($self, $x) = @_;
- if (defined($self->YYData->{DEREFERENCE})) {
- $self->YYData->{DEREFERENCE}->($x);
- }
-}
-
-sub _Error($)
-{
- my ($self) = @_;
- if (defined($self->YYData->{LAST_TOKEN})) {
- $self->YYData->{ERROR}->("Parse error in `".$self->YYData->{FULL_INPUT}."' near `". $self->YYData->{LAST_TOKEN} . "'");
- } else {
- $self->YYData->{ERROR}->("Parse error in `".$self->YYData->{FULL_INPUT}."'");
- }
-}
-
-sub Run {
- my($self, $data, $error, $lookup, $deref, $use) = @_;
- $self->YYData->{FULL_INPUT} = $data;
- $self->YYData->{INPUT} = $data;
- $self->YYData->{LOOKUP} = $lookup;
- $self->YYData->{DEREFERENCE} = $deref;
- $self->YYData->{ERROR} = $error;
- $self->YYData->{USE} = $use;
- return $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error);
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/IDL.pm b/source4/pidl/lib/Parse/Pidl/IDL.pm
deleted file mode 100644
index 06d54fb4b5..0000000000
--- a/source4/pidl/lib/Parse/Pidl/IDL.pm
+++ /dev/null
@@ -1,2534 +0,0 @@
-####################################################################
-#
-# This file was generated using Parse::Yapp version 1.05.
-#
-# Don't edit this file, use source file instead.
-#
-# ANY CHANGE MADE HERE WILL BE LOST !
-#
-####################################################################
-package Parse::Pidl::IDL;
-use vars qw ( @ISA );
-use strict;
-
-@ISA= qw ( Parse::Yapp::Driver );
-use Parse::Yapp::Driver;
-
-
-
-sub new {
- my($class)=shift;
- ref($class)
- and $class=ref($class);
-
- my($self)=$class->SUPER::new( yyversion => '1.05',
- yystates =>
-[
- {#State 0
- DEFAULT => -1,
- GOTOS => {
- 'idl' => 1
- }
- },
- {#State 1
- ACTIONS => {
- '' => 2,
- "cpp_quote" => 3,
- "importlib" => 4,
- "import" => 7,
- "include" => 13
- },
- DEFAULT => -85,
- GOTOS => {
- 'cpp_quote' => 11,
- 'importlib' => 10,
- 'interface' => 9,
- 'include' => 5,
- 'coclass' => 12,
- 'import' => 8,
- 'property_list' => 6
- }
- },
- {#State 2
- DEFAULT => 0
- },
- {#State 3
- ACTIONS => {
- "(" => 14
- }
- },
- {#State 4
- ACTIONS => {
- 'TEXT' => 16
- },
- GOTOS => {
- 'commalist' => 15,
- 'text' => 17
- }
- },
- {#State 5
- DEFAULT => -5
- },
- {#State 6
- ACTIONS => {
- "coclass" => 18,
- "[" => 20,
- "interface" => 19
- }
- },
- {#State 7
- ACTIONS => {
- 'TEXT' => 16
- },
- GOTOS => {
- 'commalist' => 21,
- 'text' => 17
- }
- },
- {#State 8
- DEFAULT => -4
- },
- {#State 9
- DEFAULT => -2
- },
- {#State 10
- DEFAULT => -6
- },
- {#State 11
- DEFAULT => -7
- },
- {#State 12
- DEFAULT => -3
- },
- {#State 13
- ACTIONS => {
- 'TEXT' => 16
- },
- GOTOS => {
- 'commalist' => 22,
- 'text' => 17
- }
- },
- {#State 14
- ACTIONS => {
- 'TEXT' => 16
- },
- GOTOS => {
- 'text' => 23
- }
- },
- {#State 15
- ACTIONS => {
- ";" => 24,
- "," => 25
- }
- },
- {#State 16
- DEFAULT => -116
- },
- {#State 17
- DEFAULT => -11
- },
- {#State 18
- ACTIONS => {
- 'IDENTIFIER' => 26
- },
- GOTOS => {
- 'identifier' => 27
- }
- },
- {#State 19
- ACTIONS => {
- 'IDENTIFIER' => 26
- },
- GOTOS => {
- 'identifier' => 28
- }
- },
- {#State 20
- ACTIONS => {
- 'IDENTIFIER' => 26
- },
- GOTOS => {
- 'identifier' => 30,
- 'property' => 31,
- 'properties' => 29
- }
- },
- {#State 21
- ACTIONS => {
- ";" => 32,
- "," => 25
- }
- },
- {#State 22
- ACTIONS => {
- ";" => 33,
- "," => 25
- }
- },
- {#State 23
- ACTIONS => {
- ")" => 34
- }
- },
- {#State 24
- DEFAULT => -10
- },
- {#State 25
- ACTIONS => {
- 'TEXT' => 16
- },
- GOTOS => {
- 'text' => 35
- }
- },
- {#State 26
- DEFAULT => -112
- },
- {#State 27
- ACTIONS => {
- "{" => 36
- }
- },
- {#State 28
- ACTIONS => {
- ":" => 37
- },
- DEFAULT => -17,
- GOTOS => {
- 'base_interface' => 38
- }
- },
- {#State 29
- ACTIONS => {
- "," => 39,
- "]" => 40
- }
- },
- {#State 30
- ACTIONS => {
- "(" => 41
- },
- DEFAULT => -89
- },
- {#State 31
- DEFAULT => -87
- },
- {#State 32
- DEFAULT => -8
- },
- {#State 33
- DEFAULT => -9
- },
- {#State 34
- DEFAULT => -19
- },
- {#State 35
- DEFAULT => -12
- },
- {#State 36
- DEFAULT => -14,
- GOTOS => {
- 'interface_names' => 42
- }
- },
- {#State 37
- ACTIONS => {
- 'IDENTIFIER' => 26
- },
- GOTOS => {
- 'identifier' => 43
- }
- },
- {#State 38
- ACTIONS => {
- "{" => 44
- }
- },
- {#State 39
- ACTIONS => {
- 'IDENTIFIER' => 26
- },
- GOTOS => {
- 'identifier' => 30,
- 'property' => 45
- }
- },
- {#State 40
- DEFAULT => -86
- },
- {#State 41
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'text' => 51,
- 'anytext' => 46,
- 'constant' => 47,
- 'commalisttext' => 49
- }
- },
- {#State 42
- ACTIONS => {
- "}" => 52,
- "interface" => 53
- }
- },
- {#State 43
- DEFAULT => -18
- },
- {#State 44
- ACTIONS => {
- "const" => 63
- },
- DEFAULT => -85,
- GOTOS => {
- 'typedecl' => 54,
- 'function' => 55,
- 'definitions' => 57,
- 'bitmap' => 56,
- 'definition' => 60,
- 'property_list' => 59,
- 'usertype' => 58,
- 'const' => 62,
- 'struct' => 61,
- 'typedef' => 65,
- 'enum' => 64,
- 'union' => 66
- }
- },
- {#State 45
- DEFAULT => -88
- },
- {#State 46
- ACTIONS => {
- "-" => 68,
- ":" => 67,
- "<" => 70,
- "+" => 72,
- "~" => 71,
- "*" => 79,
- "?" => 69,
- "{" => 73,
- "&" => 74,
- "/" => 75,
- "=" => 76,
- "(" => 77,
- "|" => 78,
- "." => 80,
- ">" => 81
- },
- DEFAULT => -91
- },
- {#State 47
- DEFAULT => -95
- },
- {#State 48
- DEFAULT => -115
- },
- {#State 49
- ACTIONS => {
- "," => 82,
- ")" => 83
- }
- },
- {#State 50
- DEFAULT => -94
- },
- {#State 51
- DEFAULT => -96
- },
- {#State 52
- ACTIONS => {
- ";" => 85
- },
- DEFAULT => -117,
- GOTOS => {
- 'optional_semicolon' => 84
- }
- },
- {#State 53
- ACTIONS => {
- 'IDENTIFIER' => 26
- },
- GOTOS => {
- 'identifier' => 86
- }
- },
- {#State 54
- DEFAULT => -25
- },
- {#State 55
- DEFAULT => -22
- },
- {#State 56
- DEFAULT => -33
- },
- {#State 57
- ACTIONS => {
- "}" => 87,
- "const" => 63
- },
- DEFAULT => -85,
- GOTOS => {
- 'typedecl' => 54,
- 'function' => 55,
- 'bitmap' => 56,
- 'definition' => 88,
- 'property_list' => 59,
- 'usertype' => 58,
- 'struct' => 61,
- 'const' => 62,
- 'typedef' => 65,
- 'enum' => 64,
- 'union' => 66
- }
- },
- {#State 58
- ACTIONS => {
- ";" => 89
- }
- },
- {#State 59
- ACTIONS => {
- "typedef" => 90,
- 'IDENTIFIER' => 26,
- "signed" => 98,
- "union" => 91,
- "enum" => 100,
- "bitmap" => 101,
- 'void' => 92,
- "unsigned" => 102,
- "[" => 20,
- "struct" => 97
- },
- GOTOS => {
- 'existingtype' => 99,
- 'bitmap' => 56,
- 'usertype' => 94,
- 'property_list' => 93,
- 'identifier' => 95,
- 'struct' => 61,
- 'enum' => 64,
- 'type' => 103,
- 'union' => 66,
- 'sign' => 96
- }
- },
- {#State 60
- DEFAULT => -20
- },
- {#State 61
- DEFAULT => -30
- },
- {#State 62
- DEFAULT => -23
- },
- {#State 63
- ACTIONS => {
- 'IDENTIFIER' => 26
- },
- GOTOS => {
- 'identifier' => 104
- }
- },
- {#State 64
- DEFAULT => -32
- },
- {#State 65
- DEFAULT => -24
- },
- {#State 66
- DEFAULT => -31
- },
- {#State 67
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 105,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 68
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 106,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 69
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 107,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 70
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 108,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 71
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 109,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 72
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 110,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 73
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 46,
- 'text' => 51,
- 'constant' => 47,
- 'commalisttext' => 111
- }
- },
- {#State 74
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 112,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 75
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 113,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 76
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 114,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 77
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 46,
- 'text' => 51,
- 'constant' => 47,
- 'commalisttext' => 115
- }
- },
- {#State 78
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 116,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 79
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 117,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 80
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 118,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 81
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 119,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 82
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 120,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 83
- DEFAULT => -90
- },
- {#State 84
- DEFAULT => -13
- },
- {#State 85
- DEFAULT => -118
- },
- {#State 86
- ACTIONS => {
- ";" => 121
- }
- },
- {#State 87
- ACTIONS => {
- ";" => 85
- },
- DEFAULT => -117,
- GOTOS => {
- 'optional_semicolon' => 122
- }
- },
- {#State 88
- DEFAULT => -21
- },
- {#State 89
- DEFAULT => -34
- },
- {#State 90
- ACTIONS => {
- 'IDENTIFIER' => 26,
- "signed" => 98,
- 'void' => 92,
- "unsigned" => 102
- },
- DEFAULT => -85,
- GOTOS => {
- 'existingtype' => 99,
- 'bitmap' => 56,
- 'usertype' => 94,
- 'property_list' => 93,
- 'identifier' => 95,
- 'struct' => 61,
- 'enum' => 64,
- 'type' => 123,
- 'union' => 66,
- 'sign' => 96
- }
- },
- {#State 91
- ACTIONS => {
- 'IDENTIFIER' => 124
- },
- DEFAULT => -114,
- GOTOS => {
- 'optional_identifier' => 125
- }
- },
- {#State 92
- DEFAULT => -41
- },
- {#State 93
- ACTIONS => {
- "union" => 91,
- "enum" => 100,
- "bitmap" => 101,
- "[" => 20,
- "struct" => 97
- }
- },
- {#State 94
- DEFAULT => -39
- },
- {#State 95
- DEFAULT => -38
- },
- {#State 96
- ACTIONS => {
- 'IDENTIFIER' => 26
- },
- GOTOS => {
- 'identifier' => 126
- }
- },
- {#State 97
- ACTIONS => {
- 'IDENTIFIER' => 124
- },
- DEFAULT => -114,
- GOTOS => {
- 'optional_identifier' => 127
- }
- },
- {#State 98
- DEFAULT => -35
- },
- {#State 99
- DEFAULT => -40
- },
- {#State 100
- ACTIONS => {
- 'IDENTIFIER' => 124
- },
- DEFAULT => -114,
- GOTOS => {
- 'optional_identifier' => 128
- }
- },
- {#State 101
- ACTIONS => {
- 'IDENTIFIER' => 124
- },
- DEFAULT => -114,
- GOTOS => {
- 'optional_identifier' => 129
- }
- },
- {#State 102
- DEFAULT => -36
- },
- {#State 103
- ACTIONS => {
- 'IDENTIFIER' => 26
- },
- GOTOS => {
- 'identifier' => 130
- }
- },
- {#State 104
- DEFAULT => -74,
- GOTOS => {
- 'pointers' => 131
- }
- },
- {#State 105
- ACTIONS => {
- "-" => 68,
- ":" => 67,
- "<" => 70,
- "+" => 72,
- "~" => 71,
- "*" => 79,
- "?" => 69,
- "{" => 73,
- "&" => 74,
- "/" => 75,
- "=" => 76,
- "(" => 77,
- "|" => 78,
- "." => 80,
- ">" => 81
- },
- DEFAULT => -106
- },
- {#State 106
- ACTIONS => {
- ":" => 67,
- "<" => 70,
- "~" => 71,
- "?" => 69,
- "{" => 73,
- "=" => 76
- },
- DEFAULT => -97
- },
- {#State 107
- ACTIONS => {
- "-" => 68,
- ":" => 67,
- "<" => 70,
- "+" => 72,
- "~" => 71,
- "*" => 79,
- "?" => 69,
- "{" => 73,
- "&" => 74,
- "/" => 75,
- "=" => 76,
- "(" => 77,
- "|" => 78,
- "." => 80,
- ">" => 81
- },
- DEFAULT => -105
- },
- {#State 108
- ACTIONS => {
- "-" => 68,
- ":" => 67,
- "<" => 70,
- "+" => 72,
- "~" => 71,
- "*" => 79,
- "?" => 69,
- "{" => 73,
- "&" => 74,
- "/" => 75,
- "=" => 76,
- "(" => 77,
- "|" => 78,
- "." => 80,
- ">" => 81
- },
- DEFAULT => -101
- },
- {#State 109
- ACTIONS => {
- "-" => 68,
- ":" => 67,
- "<" => 70,
- "+" => 72,
- "~" => 71,
- "*" => 79,
- "?" => 69,
- "{" => 73,
- "&" => 74,
- "/" => 75,
- "=" => 76,
- "(" => 77,
- "|" => 78,
- "." => 80,
- ">" => 81
- },
- DEFAULT => -109
- },
- {#State 110
- ACTIONS => {
- ":" => 67,
- "<" => 70,
- "~" => 71,
- "?" => 69,
- "{" => 73,
- "=" => 76
- },
- DEFAULT => -108
- },
- {#State 111
- ACTIONS => {
- "}" => 132,
- "," => 82
- }
- },
- {#State 112
- ACTIONS => {
- ":" => 67,
- "<" => 70,
- "~" => 71,
- "?" => 69,
- "{" => 73,
- "=" => 76
- },
- DEFAULT => -103
- },
- {#State 113
- ACTIONS => {
- ":" => 67,
- "<" => 70,
- "~" => 71,
- "?" => 69,
- "{" => 73,
- "=" => 76
- },
- DEFAULT => -104
- },
- {#State 114
- ACTIONS => {
- "-" => 68,
- ":" => 67,
- "<" => 70,
- "+" => 72,
- "~" => 71,
- "*" => 79,
- "?" => 69,
- "{" => 73,
- "&" => 74,
- "/" => 75,
- "=" => 76,
- "(" => 77,
- "|" => 78,
- "." => 80,
- ">" => 81
- },
- DEFAULT => -107
- },
- {#State 115
- ACTIONS => {
- "," => 82,
- ")" => 133
- }
- },
- {#State 116
- ACTIONS => {
- ":" => 67,
- "<" => 70,
- "~" => 71,
- "?" => 69,
- "{" => 73,
- "=" => 76
- },
- DEFAULT => -102
- },
- {#State 117
- ACTIONS => {
- ":" => 67,
- "<" => 70,
- "~" => 71,
- "?" => 69,
- "{" => 73,
- "=" => 76
- },
- DEFAULT => -99
- },
- {#State 118
- ACTIONS => {
- ":" => 67,
- "<" => 70,
- "~" => 71,
- "?" => 69,
- "{" => 73,
- "=" => 76
- },
- DEFAULT => -98
- },
- {#State 119
- ACTIONS => {
- ":" => 67,
- "<" => 70,
- "~" => 71,
- "?" => 69,
- "{" => 73,
- "=" => 76
- },
- DEFAULT => -100
- },
- {#State 120
- ACTIONS => {
- "-" => 68,
- ":" => 67,
- "<" => 70,
- "+" => 72,
- "~" => 71,
- "*" => 79,
- "?" => 69,
- "{" => 73,
- "&" => 74,
- "/" => 75,
- "=" => 76,
- "(" => 77,
- "|" => 78,
- "." => 80,
- ">" => 81
- },
- DEFAULT => -92
- },
- {#State 121
- DEFAULT => -15
- },
- {#State 122
- DEFAULT => -16
- },
- {#State 123
- ACTIONS => {
- 'IDENTIFIER' => 26
- },
- GOTOS => {
- 'identifier' => 134
- }
- },
- {#State 124
- DEFAULT => -113
- },
- {#State 125
- ACTIONS => {
- "{" => 136
- },
- DEFAULT => -70,
- GOTOS => {
- 'union_body' => 137,
- 'opt_union_body' => 135
- }
- },
- {#State 126
- DEFAULT => -37
- },
- {#State 127
- ACTIONS => {
- "{" => 139
- },
- DEFAULT => -60,
- GOTOS => {
- 'struct_body' => 138,
- 'opt_struct_body' => 140
- }
- },
- {#State 128
- ACTIONS => {
- "{" => 141
- },
- DEFAULT => -43,
- GOTOS => {
- 'opt_enum_body' => 143,
- 'enum_body' => 142
- }
- },
- {#State 129
- ACTIONS => {
- "{" => 145
- },
- DEFAULT => -51,
- GOTOS => {
- 'bitmap_body' => 146,
- 'opt_bitmap_body' => 144
- }
- },
- {#State 130
- ACTIONS => {
- "(" => 147
- }
- },
- {#State 131
- ACTIONS => {
- 'IDENTIFIER' => 26,
- "*" => 149
- },
- GOTOS => {
- 'identifier' => 148
- }
- },
- {#State 132
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 150,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 133
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 151,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 134
- ACTIONS => {
- "[" => 152
- },
- DEFAULT => -82,
- GOTOS => {
- 'array_len' => 153
- }
- },
- {#State 135
- DEFAULT => -72
- },
- {#State 136
- DEFAULT => -67,
- GOTOS => {
- 'union_elements' => 154
- }
- },
- {#State 137
- DEFAULT => -71
- },
- {#State 138
- DEFAULT => -61
- },
- {#State 139
- DEFAULT => -76,
- GOTOS => {
- 'element_list1' => 155
- }
- },
- {#State 140
- DEFAULT => -62
- },
- {#State 141
- ACTIONS => {
- 'IDENTIFIER' => 26
- },
- GOTOS => {
- 'identifier' => 156,
- 'enum_element' => 157,
- 'enum_elements' => 158
- }
- },
- {#State 142
- DEFAULT => -44
- },
- {#State 143
- DEFAULT => -45
- },
- {#State 144
- DEFAULT => -53
- },
- {#State 145
- ACTIONS => {
- 'IDENTIFIER' => 26
- },
- DEFAULT => -56,
- GOTOS => {
- 'identifier' => 161,
- 'bitmap_element' => 160,
- 'bitmap_elements' => 159,
- 'opt_bitmap_elements' => 162
- }
- },
- {#State 146
- DEFAULT => -52
- },
- {#State 147
- ACTIONS => {
- "," => -78,
- "void" => 166,
- ")" => -78
- },
- DEFAULT => -85,
- GOTOS => {
- 'base_element' => 163,
- 'element_list2' => 165,
- 'property_list' => 164
- }
- },
- {#State 148
- ACTIONS => {
- "[" => 152,
- "=" => 168
- },
- GOTOS => {
- 'array_len' => 167
- }
- },
- {#State 149
- DEFAULT => -75
- },
- {#State 150
- ACTIONS => {
- "-" => 68,
- ":" => 67,
- "<" => 70,
- "+" => 72,
- "~" => 71,
- "*" => 79,
- "?" => 69,
- "{" => 73,
- "&" => 74,
- "/" => 75,
- "=" => 76,
- "(" => 77,
- "|" => 78,
- "." => 80,
- ">" => 81
- },
- DEFAULT => -111
- },
- {#State 151
- ACTIONS => {
- ":" => 67,
- "<" => 70,
- "~" => 71,
- "?" => 69,
- "{" => 73,
- "=" => 76
- },
- DEFAULT => -110
- },
- {#State 152
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- "]" => 169,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 170,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 153
- ACTIONS => {
- ";" => 171
- }
- },
- {#State 154
- ACTIONS => {
- "}" => 172
- },
- DEFAULT => -85,
- GOTOS => {
- 'optional_base_element' => 174,
- 'property_list' => 173
- }
- },
- {#State 155
- ACTIONS => {
- "}" => 175
- },
- DEFAULT => -85,
- GOTOS => {
- 'base_element' => 176,
- 'property_list' => 164
- }
- },
- {#State 156
- ACTIONS => {
- "=" => 177
- },
- DEFAULT => -48
- },
- {#State 157
- DEFAULT => -46
- },
- {#State 158
- ACTIONS => {
- "}" => 178,
- "," => 179
- }
- },
- {#State 159
- ACTIONS => {
- "," => 180
- },
- DEFAULT => -57
- },
- {#State 160
- DEFAULT => -54
- },
- {#State 161
- ACTIONS => {
- "=" => 181
- }
- },
- {#State 162
- ACTIONS => {
- "}" => 182
- }
- },
- {#State 163
- DEFAULT => -80
- },
- {#State 164
- ACTIONS => {
- 'IDENTIFIER' => 26,
- "signed" => 98,
- 'void' => 92,
- "unsigned" => 102,
- "[" => 20
- },
- DEFAULT => -85,
- GOTOS => {
- 'existingtype' => 99,
- 'bitmap' => 56,
- 'usertype' => 94,
- 'property_list' => 93,
- 'identifier' => 95,
- 'struct' => 61,
- 'enum' => 64,
- 'type' => 183,
- 'union' => 66,
- 'sign' => 96
- }
- },
- {#State 165
- ACTIONS => {
- "," => 184,
- ")" => 185
- }
- },
- {#State 166
- DEFAULT => -79
- },
- {#State 167
- ACTIONS => {
- "=" => 186
- }
- },
- {#State 168
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 187,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 169
- ACTIONS => {
- "[" => 152
- },
- DEFAULT => -82,
- GOTOS => {
- 'array_len' => 188
- }
- },
- {#State 170
- ACTIONS => {
- "-" => 68,
- ":" => 67,
- "?" => 69,
- "<" => 70,
- "+" => 72,
- "~" => 71,
- "&" => 74,
- "{" => 73,
- "/" => 75,
- "=" => 76,
- "|" => 78,
- "(" => 77,
- "*" => 79,
- "." => 80,
- "]" => 189,
- ">" => 81
- }
- },
- {#State 171
- DEFAULT => -29
- },
- {#State 172
- DEFAULT => -69
- },
- {#State 173
- ACTIONS => {
- "[" => 20
- },
- DEFAULT => -85,
- GOTOS => {
- 'base_or_empty' => 190,
- 'base_element' => 191,
- 'empty_element' => 192,
- 'property_list' => 193
- }
- },
- {#State 174
- DEFAULT => -68
- },
- {#State 175
- DEFAULT => -59
- },
- {#State 176
- ACTIONS => {
- ";" => 194
- }
- },
- {#State 177
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 195,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 178
- DEFAULT => -42
- },
- {#State 179
- ACTIONS => {
- 'IDENTIFIER' => 26
- },
- GOTOS => {
- 'identifier' => 156,
- 'enum_element' => 196
- }
- },
- {#State 180
- ACTIONS => {
- 'IDENTIFIER' => 26
- },
- GOTOS => {
- 'identifier' => 161,
- 'bitmap_element' => 197
- }
- },
- {#State 181
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 198,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 182
- DEFAULT => -50
- },
- {#State 183
- DEFAULT => -74,
- GOTOS => {
- 'pointers' => 199
- }
- },
- {#State 184
- DEFAULT => -85,
- GOTOS => {
- 'base_element' => 200,
- 'property_list' => 164
- }
- },
- {#State 185
- ACTIONS => {
- ";" => 201
- }
- },
- {#State 186
- ACTIONS => {
- 'CONSTANT' => 48,
- 'TEXT' => 16,
- 'IDENTIFIER' => 26
- },
- DEFAULT => -93,
- GOTOS => {
- 'identifier' => 50,
- 'anytext' => 202,
- 'text' => 51,
- 'constant' => 47
- }
- },
- {#State 187
- ACTIONS => {
- "-" => 68,
- ":" => 67,
- "?" => 69,
- "<" => 70,
- ";" => 203,
- "+" => 72,
- "~" => 71,
- "&" => 74,
- "{" => 73,
- "/" => 75,
- "=" => 76,
- "|" => 78,
- "(" => 77,
- "*" => 79,
- "." => 80,
- ">" => 81
- }
- },
- {#State 188
- DEFAULT => -83
- },
- {#State 189
- ACTIONS => {
- "[" => 152
- },
- DEFAULT => -82,
- GOTOS => {
- 'array_len' => 204
- }
- },
- {#State 190
- DEFAULT => -66
- },
- {#State 191
- ACTIONS => {
- ";" => 205
- }
- },
- {#State 192
- DEFAULT => -65
- },
- {#State 193
- ACTIONS => {
- 'IDENTIFIER' => 26,
- "signed" => 98,
- ";" => 206,
- 'void' => 92,
- "unsigned" => 102,
- "[" => 20
- },
- DEFAULT => -85,
- GOTOS => {
- 'existingtype' => 99,
- 'bitmap' => 56,
- 'usertype' => 94,
- 'property_list' => 93,
- 'identifier' => 95,
- 'struct' => 61,
- 'enum' => 64,
- 'type' => 183,
- 'union' => 66,
- 'sign' => 96
- }
- },
- {#State 194
- DEFAULT => -77
- },
- {#State 195
- ACTIONS => {
- "-" => 68,
- ":" => 67,
- "<" => 70,
- "+" => 72,
- "~" => 71,
- "*" => 79,
- "?" => 69,
- "{" => 73,
- "&" => 74,
- "/" => 75,
- "=" => 76,
- "(" => 77,
- "|" => 78,
- "." => 80,
- ">" => 81
- },
- DEFAULT => -49
- },
- {#State 196
- DEFAULT => -47
- },
- {#State 197
- DEFAULT => -55
- },
- {#State 198
- ACTIONS => {
- "-" => 68,
- ":" => 67,
- "<" => 70,
- "+" => 72,
- "~" => 71,
- "*" => 79,
- "?" => 69,
- "{" => 73,
- "&" => 74,
- "/" => 75,
- "=" => 76,
- "(" => 77,
- "|" => 78,
- "." => 80,
- ">" => 81
- },
- DEFAULT => -58
- },
- {#State 199
- ACTIONS => {
- 'IDENTIFIER' => 26,
- "*" => 149
- },
- GOTOS => {
- 'identifier' => 207
- }
- },
- {#State 200
- DEFAULT => -81
- },
- {#State 201
- DEFAULT => -28
- },
- {#State 202
- ACTIONS => {
- "-" => 68,
- ":" => 67,
- "?" => 69,
- "<" => 70,
- ";" => 208,
- "+" => 72,
- "~" => 71,
- "&" => 74,
- "{" => 73,
- "/" => 75,
- "=" => 76,
- "|" => 78,
- "(" => 77,
- "*" => 79,
- "." => 80,
- ">" => 81
- }
- },
- {#State 203
- DEFAULT => -26
- },
- {#State 204
- DEFAULT => -84
- },
- {#State 205
- DEFAULT => -64
- },
- {#State 206
- DEFAULT => -63
- },
- {#State 207
- ACTIONS => {
- "[" => 152
- },
- DEFAULT => -82,
- GOTOS => {
- 'array_len' => 209
- }
- },
- {#State 208
- DEFAULT => -27
- },
- {#State 209
- DEFAULT => -73
- }
-],
- yyrules =>
-[
- [#Rule 0
- '$start', 2, undef
- ],
- [#Rule 1
- 'idl', 0, undef
- ],
- [#Rule 2
- 'idl', 2,
-sub
-#line 19 "pidl/idl.yp"
-{ push(@{$_[1]}, $_[2]); $_[1] }
- ],
- [#Rule 3
- 'idl', 2,
-sub
-#line 20 "pidl/idl.yp"
-{ push(@{$_[1]}, $_[2]); $_[1] }
- ],
- [#Rule 4
- 'idl', 2,
-sub
-#line 21 "pidl/idl.yp"
-{ push(@{$_[1]}, $_[2]); $_[1] }
- ],
- [#Rule 5
- 'idl', 2,
-sub
-#line 22 "pidl/idl.yp"
-{ push(@{$_[1]}, $_[2]); $_[1] }
- ],
- [#Rule 6
- 'idl', 2,
-sub
-#line 23 "pidl/idl.yp"
-{ push(@{$_[1]}, $_[2]); $_[1] }
- ],
- [#Rule 7
- 'idl', 2,
-sub
-#line 24 "pidl/idl.yp"
-{ push(@{$_[1]}, $_[2]); $_[1] }
- ],
- [#Rule 8
- 'import', 3,
-sub
-#line 27 "pidl/idl.yp"
-{{
- "TYPE" => "IMPORT",
- "PATHS" => $_[2],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE}
- }}
- ],
- [#Rule 9
- 'include', 3,
-sub
-#line 34 "pidl/idl.yp"
-{{
- "TYPE" => "INCLUDE",
- "PATHS" => $_[2],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE}
- }}
- ],
- [#Rule 10
- 'importlib', 3,
-sub
-#line 41 "pidl/idl.yp"
-{{
- "TYPE" => "IMPORTLIB",
- "PATHS" => $_[2],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE}
- }}
- ],
- [#Rule 11
- 'commalist', 1,
-sub
-#line 50 "pidl/idl.yp"
-{ [ $_[1] ] }
- ],
- [#Rule 12
- 'commalist', 3,
-sub
-#line 51 "pidl/idl.yp"
-{ push(@{$_[1]}, $_[3]); $_[1] }
- ],
- [#Rule 13
- 'coclass', 7,
-sub
-#line 55 "pidl/idl.yp"
-{{
- "TYPE" => "COCLASS",
- "PROPERTIES" => $_[1],
- "NAME" => $_[3],
- "DATA" => $_[5],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
- ],
- [#Rule 14
- 'interface_names', 0, undef
- ],
- [#Rule 15
- 'interface_names', 4,
-sub
-#line 67 "pidl/idl.yp"
-{ push(@{$_[1]}, $_[2]); $_[1] }
- ],
- [#Rule 16
- 'interface', 8,
-sub
-#line 71 "pidl/idl.yp"
-{{
- "TYPE" => "INTERFACE",
- "PROPERTIES" => $_[1],
- "NAME" => $_[3],
- "BASE" => $_[4],
- "DATA" => $_[6],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
- ],
- [#Rule 17
- 'base_interface', 0, undef
- ],
- [#Rule 18
- 'base_interface', 2,
-sub
-#line 84 "pidl/idl.yp"
-{ $_[2] }
- ],
- [#Rule 19
- 'cpp_quote', 4,
-sub
-#line 89 "pidl/idl.yp"
-{{
- "TYPE" => "CPP_QUOTE",
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- "DATA" => $_[3]
- }}
- ],
- [#Rule 20
- 'definitions', 1,
-sub
-#line 98 "pidl/idl.yp"
-{ [ $_[1] ] }
- ],
- [#Rule 21
- 'definitions', 2,
-sub
-#line 99 "pidl/idl.yp"
-{ push(@{$_[1]}, $_[2]); $_[1] }
- ],
- [#Rule 22
- 'definition', 1, undef
- ],
- [#Rule 23
- 'definition', 1, undef
- ],
- [#Rule 24
- 'definition', 1, undef
- ],
- [#Rule 25
- 'definition', 1, undef
- ],
- [#Rule 26
- 'const', 7,
-sub
-#line 107 "pidl/idl.yp"
-{{
- "TYPE" => "CONST",
- "DTYPE" => $_[2],
- "POINTERS" => $_[3],
- "NAME" => $_[4],
- "VALUE" => $_[6],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
- ],
- [#Rule 27
- 'const', 8,
-sub
-#line 117 "pidl/idl.yp"
-{{
- "TYPE" => "CONST",
- "DTYPE" => $_[2],
- "POINTERS" => $_[3],
- "NAME" => $_[4],
- "ARRAY_LEN" => $_[5],
- "VALUE" => $_[7],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
- ],
- [#Rule 28
- 'function', 7,
-sub
-#line 131 "pidl/idl.yp"
-{{
- "TYPE" => "FUNCTION",
- "NAME" => $_[3],
- "RETURN_TYPE" => $_[2],
- "PROPERTIES" => $_[1],
- "ELEMENTS" => $_[5],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
- ],
- [#Rule 29
- 'typedef', 6,
-sub
-#line 143 "pidl/idl.yp"
-{{
- "TYPE" => "TYPEDEF",
- "PROPERTIES" => $_[1],
- "NAME" => $_[4],
- "DATA" => $_[3],
- "ARRAY_LEN" => $_[5],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
- ],
- [#Rule 30
- 'usertype', 1, undef
- ],
- [#Rule 31
- 'usertype', 1, undef
- ],
- [#Rule 32
- 'usertype', 1, undef
- ],
- [#Rule 33
- 'usertype', 1, undef
- ],
- [#Rule 34
- 'typedecl', 2,
-sub
-#line 156 "pidl/idl.yp"
-{ $_[1] }
- ],
- [#Rule 35
- 'sign', 1, undef
- ],
- [#Rule 36
- 'sign', 1, undef
- ],
- [#Rule 37
- 'existingtype', 2,
-sub
-#line 161 "pidl/idl.yp"
-{ ($_[1]?$_[1]:"signed") ." $_[2]" }
- ],
- [#Rule 38
- 'existingtype', 1, undef
- ],
- [#Rule 39
- 'type', 1, undef
- ],
- [#Rule 40
- 'type', 1, undef
- ],
- [#Rule 41
- 'type', 1,
-sub
-#line 165 "pidl/idl.yp"
-{ "void" }
- ],
- [#Rule 42
- 'enum_body', 3,
-sub
-#line 167 "pidl/idl.yp"
-{ $_[2] }
- ],
- [#Rule 43
- 'opt_enum_body', 0, undef
- ],
- [#Rule 44
- 'opt_enum_body', 1, undef
- ],
- [#Rule 45
- 'enum', 4,
-sub
-#line 170 "pidl/idl.yp"
-{{
- "TYPE" => "ENUM",
- "PROPERTIES" => $_[1],
- "NAME" => $_[3],
- "ELEMENTS" => $_[4]
- }}
- ],
- [#Rule 46
- 'enum_elements', 1,
-sub
-#line 179 "pidl/idl.yp"
-{ [ $_[1] ] }
- ],
- [#Rule 47
- 'enum_elements', 3,
-sub
-#line 180 "pidl/idl.yp"
-{ push(@{$_[1]}, $_[3]); $_[1] }
- ],
- [#Rule 48
- 'enum_element', 1, undef
- ],
- [#Rule 49
- 'enum_element', 3,
-sub
-#line 184 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]" }
- ],
- [#Rule 50
- 'bitmap_body', 3,
-sub
-#line 187 "pidl/idl.yp"
-{ $_[2] }
- ],
- [#Rule 51
- 'opt_bitmap_body', 0, undef
- ],
- [#Rule 52
- 'opt_bitmap_body', 1, undef
- ],
- [#Rule 53
- 'bitmap', 4,
-sub
-#line 190 "pidl/idl.yp"
-{{
- "TYPE" => "BITMAP",
- "PROPERTIES" => $_[1],
- "NAME" => $_[3],
- "ELEMENTS" => $_[4]
- }}
- ],
- [#Rule 54
- 'bitmap_elements', 1,
-sub
-#line 199 "pidl/idl.yp"
-{ [ $_[1] ] }
- ],
- [#Rule 55
- 'bitmap_elements', 3,
-sub
-#line 200 "pidl/idl.yp"
-{ push(@{$_[1]}, $_[3]); $_[1] }
- ],
- [#Rule 56
- 'opt_bitmap_elements', 0, undef
- ],
- [#Rule 57
- 'opt_bitmap_elements', 1, undef
- ],
- [#Rule 58
- 'bitmap_element', 3,
-sub
-#line 205 "pidl/idl.yp"
-{ "$_[1] ( $_[3] )" }
- ],
- [#Rule 59
- 'struct_body', 3,
-sub
-#line 208 "pidl/idl.yp"
-{ $_[2] }
- ],
- [#Rule 60
- 'opt_struct_body', 0, undef
- ],
- [#Rule 61
- 'opt_struct_body', 1, undef
- ],
- [#Rule 62
- 'struct', 4,
-sub
-#line 212 "pidl/idl.yp"
-{{
- "TYPE" => "STRUCT",
- "PROPERTIES" => $_[1],
- "NAME" => $_[3],
- "ELEMENTS" => $_[4]
- }}
- ],
- [#Rule 63
- 'empty_element', 2,
-sub
-#line 221 "pidl/idl.yp"
-{{
- "NAME" => "",
- "TYPE" => "EMPTY",
- "PROPERTIES" => $_[1],
- "POINTERS" => 0,
- "ARRAY_LEN" => [],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
- ],
- [#Rule 64
- 'base_or_empty', 2, undef
- ],
- [#Rule 65
- 'base_or_empty', 1, undef
- ],
- [#Rule 66
- 'optional_base_element', 2,
-sub
-#line 235 "pidl/idl.yp"
-{ $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
- ],
- [#Rule 67
- 'union_elements', 0, undef
- ],
- [#Rule 68
- 'union_elements', 2,
-sub
-#line 240 "pidl/idl.yp"
-{ push(@{$_[1]}, $_[2]); $_[1] }
- ],
- [#Rule 69
- 'union_body', 3,
-sub
-#line 243 "pidl/idl.yp"
-{ $_[2] }
- ],
- [#Rule 70
- 'opt_union_body', 0, undef
- ],
- [#Rule 71
- 'opt_union_body', 1, undef
- ],
- [#Rule 72
- 'union', 4,
-sub
-#line 247 "pidl/idl.yp"
-{{
- "TYPE" => "UNION",
- "PROPERTIES" => $_[1],
- "NAME" => $_[3],
- "ELEMENTS" => $_[4]
- }}
- ],
- [#Rule 73
- 'base_element', 5,
-sub
-#line 256 "pidl/idl.yp"
-{{
- "NAME" => $_[4],
- "TYPE" => $_[2],
- "PROPERTIES" => $_[1],
- "POINTERS" => $_[3],
- "ARRAY_LEN" => $_[5],
- "FILE" => $_[0]->YYData->{FILE},
- "LINE" => $_[0]->YYData->{LINE},
- }}
- ],
- [#Rule 74
- 'pointers', 0,
-sub
-#line 270 "pidl/idl.yp"
-{ 0 }
- ],
- [#Rule 75
- 'pointers', 2,
-sub
-#line 271 "pidl/idl.yp"
-{ $_[1]+1 }
- ],
- [#Rule 76
- 'element_list1', 0,
-sub
-#line 275 "pidl/idl.yp"
-{ [] }
- ],
- [#Rule 77
- 'element_list1', 3,
-sub
-#line 276 "pidl/idl.yp"
-{ push(@{$_[1]}, $_[2]); $_[1] }
- ],
- [#Rule 78
- 'element_list2', 0, undef
- ],
- [#Rule 79
- 'element_list2', 1, undef
- ],
- [#Rule 80
- 'element_list2', 1,
-sub
-#line 282 "pidl/idl.yp"
-{ [ $_[1] ] }
- ],
- [#Rule 81
- 'element_list2', 3,
-sub
-#line 283 "pidl/idl.yp"
-{ push(@{$_[1]}, $_[3]); $_[1] }
- ],
- [#Rule 82
- 'array_len', 0, undef
- ],
- [#Rule 83
- 'array_len', 3,
-sub
-#line 288 "pidl/idl.yp"
-{ push(@{$_[3]}, "*"); $_[3] }
- ],
- [#Rule 84
- 'array_len', 4,
-sub
-#line 289 "pidl/idl.yp"
-{ push(@{$_[4]}, "$_[2]"); $_[4] }
- ],
- [#Rule 85
- 'property_list', 0, undef
- ],
- [#Rule 86
- 'property_list', 4,
-sub
-#line 295 "pidl/idl.yp"
-{ FlattenHash([$_[1],$_[3]]); }
- ],
- [#Rule 87
- 'properties', 1,
-sub
-#line 298 "pidl/idl.yp"
-{ $_[1] }
- ],
- [#Rule 88
- 'properties', 3,
-sub
-#line 299 "pidl/idl.yp"
-{ FlattenHash([$_[1], $_[3]]); }
- ],
- [#Rule 89
- 'property', 1,
-sub
-#line 302 "pidl/idl.yp"
-{{ "$_[1]" => "1" }}
- ],
- [#Rule 90
- 'property', 4,
-sub
-#line 303 "pidl/idl.yp"
-{{ "$_[1]" => "$_[3]" }}
- ],
- [#Rule 91
- 'commalisttext', 1, undef
- ],
- [#Rule 92
- 'commalisttext', 3,
-sub
-#line 308 "pidl/idl.yp"
-{ "$_[1],$_[3]" }
- ],
- [#Rule 93
- 'anytext', 0,
-sub
-#line 312 "pidl/idl.yp"
-{ "" }
- ],
- [#Rule 94
- 'anytext', 1, undef
- ],
- [#Rule 95
- 'anytext', 1, undef
- ],
- [#Rule 96
- 'anytext', 1, undef
- ],
- [#Rule 97
- 'anytext', 3,
-sub
-#line 314 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]" }
- ],
- [#Rule 98
- 'anytext', 3,
-sub
-#line 315 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]" }
- ],
- [#Rule 99
- 'anytext', 3,
-sub
-#line 316 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]" }
- ],
- [#Rule 100
- 'anytext', 3,
-sub
-#line 317 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]" }
- ],
- [#Rule 101
- 'anytext', 3,
-sub
-#line 318 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]" }
- ],
- [#Rule 102
- 'anytext', 3,
-sub
-#line 319 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]" }
- ],
- [#Rule 103
- 'anytext', 3,
-sub
-#line 320 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]" }
- ],
- [#Rule 104
- 'anytext', 3,
-sub
-#line 321 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]" }
- ],
- [#Rule 105
- 'anytext', 3,
-sub
-#line 322 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]" }
- ],
- [#Rule 106
- 'anytext', 3,
-sub
-#line 323 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]" }
- ],
- [#Rule 107
- 'anytext', 3,
-sub
-#line 324 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]" }
- ],
- [#Rule 108
- 'anytext', 3,
-sub
-#line 325 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]" }
- ],
- [#Rule 109
- 'anytext', 3,
-sub
-#line 326 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]" }
- ],
- [#Rule 110
- 'anytext', 5,
-sub
-#line 327 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]$_[4]$_[5]" }
- ],
- [#Rule 111
- 'anytext', 5,
-sub
-#line 328 "pidl/idl.yp"
-{ "$_[1]$_[2]$_[3]$_[4]$_[5]" }
- ],
- [#Rule 112
- 'identifier', 1, undef
- ],
- [#Rule 113
- 'optional_identifier', 1, undef
- ],
- [#Rule 114
- 'optional_identifier', 0, undef
- ],
- [#Rule 115
- 'constant', 1, undef
- ],
- [#Rule 116
- 'text', 1,
-sub
-#line 342 "pidl/idl.yp"
-{ "\"$_[1]\"" }
- ],
- [#Rule 117
- 'optional_semicolon', 0, undef
- ],
- [#Rule 118
- 'optional_semicolon', 1, undef
- ]
-],
- @_);
- bless($self,$class);
-}
-
-#line 353 "pidl/idl.yp"
-
-
-use Parse::Pidl qw(error);
-
-#####################################################################
-# flatten an array of hashes into a single hash
-sub FlattenHash($)
-{
- my $a = shift;
- my %b;
- for my $d (@{$a}) {
- for my $k (keys %{$d}) {
- $b{$k} = $d->{$k};
- }
- }
- return \%b;
-}
-
-
-
-#####################################################################
-# traverse a perl data structure removing any empty arrays or
-# hashes and any hash elements that map to undef
-sub CleanData($)
-{
- sub CleanData($);
- my($v) = shift;
- return undef if (not defined($v));
- if (ref($v) eq "ARRAY") {
- foreach my $i (0 .. $#{$v}) {
- CleanData($v->[$i]);
- }
- # this removes any undefined elements from the array
- @{$v} = grep { defined $_ } @{$v};
- } elsif (ref($v) eq "HASH") {
- foreach my $x (keys %{$v}) {
- CleanData($v->{$x});
- if (!defined $v->{$x}) { delete($v->{$x}); next; }
- }
- }
- return $v;
-}
-
-sub _Error {
- if (exists $_[0]->YYData->{ERRMSG}) {
- error($_[0]->YYData, $_[0]->YYData->{ERRMSG});
- delete $_[0]->YYData->{ERRMSG};
- return;
- }
- my $last_token = $_[0]->YYData->{LAST_TOKEN};
-
- error($_[0]->YYData, "Syntax error near '$last_token'");
-}
-
-sub _Lexer($)
-{
- my($parser)=shift;
-
- $parser->YYData->{INPUT} or return('',undef);
-
-again:
- $parser->YYData->{INPUT} =~ s/^[ \t]*//;
-
- for ($parser->YYData->{INPUT}) {
- if (/^\#/) {
- if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
- $parser->YYData->{LINE} = $1-1;
- $parser->YYData->{FILE} = $2;
- goto again;
- }
- if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
- $parser->YYData->{LINE} = $1-1;
- $parser->YYData->{FILE} = $2;
- goto again;
- }
- if (s/^(\#.*)$//m) {
- goto again;
- }
- }
- if (s/^(\n)//) {
- $parser->YYData->{LINE}++;
- goto again;
- }
- if (s/^\"(.*?)\"//) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return('TEXT',$1);
- }
- if (s/^(\d+)(\W|$)/$2/) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return('CONSTANT',$1);
- }
- if (s/^([\w_]+)//) {
- $parser->YYData->{LAST_TOKEN} = $1;
- if ($1 =~
- /^(coclass|interface|const|typedef|union|cpp_quote
- |struct|enum|bitmap|void|unsigned|signed|import|include
- |importlib)$/x) {
- return $1;
- }
- return('IDENTIFIER',$1);
- }
- if (s/^(.)//s) {
- $parser->YYData->{LAST_TOKEN} = $1;
- return($1,$1);
- }
- }
-}
-
-sub parse_string
-{
- my ($data,$filename) = @_;
-
- my $self = new Parse::Pidl::IDL;
-
- $self->YYData->{FILE} = $filename;
- $self->YYData->{INPUT} = $data;
- $self->YYData->{LINE} = 0;
- $self->YYData->{LAST_TOKEN} = "NONE";
-
- my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
-
- return CleanData($idl);
-}
-
-sub parse_file($$)
-{
- my ($filename,$incdirs) = @_;
-
- my $saved_delim = $/;
- undef $/;
- my $cpp = $ENV{CPP};
- if (! defined $cpp) {
- $cpp = "cpp";
- }
- my $includes = join('',map { " -I$_" } @$incdirs);
- my $data = `$cpp -D__PIDL__$includes -xc $filename`;
- $/ = $saved_delim;
-
- return parse_string($data, $filename);
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm
deleted file mode 100644
index 9b61a370e2..0000000000
--- a/source4/pidl/lib/Parse/Pidl/NDR.pm
+++ /dev/null
@@ -1,1235 +0,0 @@
-###################################################
-# Samba4 NDR info tree generator
-# Copyright tridge@samba.org 2000-2003
-# Copyright tpot@samba.org 2001
-# Copyright jelmer@samba.org 2004-2006
-# released under the GNU GPL
-
-=pod
-
-=head1 NAME
-
-Parse::Pidl::NDR - NDR parsing information generator
-
-=head1 DESCRIPTION
-
-Return a table describing the order in which the parts of an element
-should be parsed
-Possible level types:
- - POINTER
- - ARRAY
- - SUBCONTEXT
- - SWITCH
- - DATA
-
-=head1 AUTHOR
-
-Jelmer Vernooij <jelmer@samba.org>
-
-=cut
-
-package Parse::Pidl::NDR;
-
-require Exporter;
-use vars qw($VERSION);
-$VERSION = '0.01';
-@ISA = qw(Exporter);
-@EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsString);
-@EXPORT_OK = qw(GetElementLevelTable ParseElement ValidElement align_type mapToScalar ParseType can_contain_deferred is_charset_array);
-
-use strict;
-use Parse::Pidl qw(warning fatal);
-use Parse::Pidl::Typelist qw(hasType getType expandAlias);
-use Parse::Pidl::Util qw(has_property property_matches);
-
-# Alignment of the built-in scalar types
-my $scalar_alignment = {
- 'void' => 0,
- 'char' => 1,
- 'int8' => 1,
- 'uint8' => 1,
- 'int16' => 2,
- 'uint16' => 2,
- 'int32' => 4,
- 'uint32' => 4,
- 'hyper' => 8,
- 'pointer' => 8,
- 'dlong' => 4,
- 'udlong' => 4,
- 'udlongr' => 4,
- 'DATA_BLOB' => 4,
- 'string' => 4,
- 'string_array' => 4, #???
- 'time_t' => 4,
- 'NTTIME' => 4,
- 'NTTIME_1sec' => 4,
- 'NTTIME_hyper' => 8,
- 'WERROR' => 4,
- 'NTSTATUS' => 4,
- 'COMRESULT' => 4,
- 'nbt_string' => 4,
- 'wrepl_nbt_name' => 4,
- 'ipv4address' => 4
-};
-
-sub GetElementLevelTable($$)
-{
- my ($e, $pointer_default) = @_;
-
- my $order = [];
- my $is_deferred = 0;
- my @bracket_array = ();
- my @length_is = ();
- my @size_is = ();
- my $pointer_idx = 0;
-
- if (has_property($e, "size_is")) {
- @size_is = split /,/, has_property($e, "size_is");
- }
-
- if (has_property($e, "length_is")) {
- @length_is = split /,/, has_property($e, "length_is");
- }
-
- if (defined($e->{ARRAY_LEN})) {
- @bracket_array = @{$e->{ARRAY_LEN}};
- }
-
- if (has_property($e, "out")) {
- my $needptrs = 1;
-
- if (has_property($e, "string")) { $needptrs++; }
- if ($#bracket_array >= 0) { $needptrs = 0; }
-
- warning($e, "[out] argument `$e->{NAME}' not a pointer") if ($needptrs > $e->{POINTERS});
- }
-
- # Parse the [][][][] style array stuff
- for my $i (0 .. $#bracket_array) {
- my $d = $bracket_array[$#bracket_array - $i];
- my $size = $d;
- my $length = $d;
- my $is_surrounding = 0;
- my $is_varying = 0;
- my $is_conformant = 0;
- my $is_string = 0;
- my $is_fixed = 0;
- my $is_inline = 0;
-
- if ($d eq "*") {
- $is_conformant = 1;
- if ($size = shift @size_is) {
- } elsif ((scalar(@size_is) == 0) and has_property($e, "string")) {
- $is_string = 1;
- delete($e->{PROPERTIES}->{string});
- } else {
- fatal($e, "Must specify size_is() for conformant array!")
- }
-
- if (($length = shift @length_is) or $is_string) {
- $is_varying = 1;
- } else {
- $length = $size;
- }
-
- if ($e == $e->{PARENT}->{ELEMENTS}[-1]
- and $e->{PARENT}->{TYPE} ne "FUNCTION") {
- $is_surrounding = 1;
- }
- }
-
- $is_fixed = 1 if (not $is_conformant and Parse::Pidl::Util::is_constant($size));
- $is_inline = 1 if (not $is_conformant and not Parse::Pidl::Util::is_constant($size));
-
- push (@$order, {
- TYPE => "ARRAY",
- SIZE_IS => $size,
- LENGTH_IS => $length,
- IS_DEFERRED => $is_deferred,
- IS_SURROUNDING => $is_surrounding,
- IS_ZERO_TERMINATED => $is_string,
- IS_VARYING => $is_varying,
- IS_CONFORMANT => $is_conformant,
- IS_FIXED => $is_fixed,
- IS_INLINE => $is_inline
- });
- }
-
- # Next, all the pointers
- foreach my $i (1..$e->{POINTERS}) {
- my $level = "EMBEDDED";
- # Top level "ref" pointers do not have a referrent identifier
- $level = "TOP" if ($i == 1 and $e->{PARENT}->{TYPE} eq "FUNCTION");
-
- my $pt;
- #
- # Only the first level gets the pointer type from the
- # pointer property, the others get them from
- # the pointer_default() interface property
- #
- # see http://msdn2.microsoft.com/en-us/library/aa378984(VS.85).aspx
- # (Here they talk about the rightmost pointer, but testing shows
- # they mean the leftmost pointer.)
- #
- # --metze
- #
- $pt = pointer_type($e);
- if ($i > 1) {
- $is_deferred = 1 if ($pt ne "ref" and $e->{PARENT}->{TYPE} eq "FUNCTION");
- $pt = $pointer_default;
- }
-
- push (@$order, {
- TYPE => "POINTER",
- POINTER_TYPE => $pt,
- POINTER_INDEX => $pointer_idx,
- IS_DEFERRED => "$is_deferred",
- LEVEL => $level
- });
-
- warning($e, "top-level \[out\] pointer `$e->{NAME}' is not a \[ref\] pointer")
- if ($i == 1 and $pt ne "ref" and
- $e->{PARENT}->{TYPE} eq "FUNCTION" and
- not has_property($e, "in"));
-
- $pointer_idx++;
-
- # everything that follows will be deferred
- $is_deferred = 1 if ($level ne "TOP");
-
- my $array_size = shift @size_is;
- my $array_length;
- my $is_varying;
- my $is_conformant;
- my $is_string = 0;
- if ($array_size) {
- $is_conformant = 1;
- if ($array_length = shift @length_is) {
- $is_varying = 1;
- } else {
- $array_length = $array_size;
- $is_varying =0;
- }
- }
-
- if (scalar(@size_is) == 0 and has_property($e, "string") and
- $i == $e->{POINTERS}) {
- $is_string = 1;
- $is_varying = $is_conformant = has_property($e, "noheader")?0:1;
- delete($e->{PROPERTIES}->{string});
- }
-
- if ($array_size or $is_string) {
- push (@$order, {
- TYPE => "ARRAY",
- SIZE_IS => $array_size,
- LENGTH_IS => $array_length,
- IS_DEFERRED => $is_deferred,
- IS_SURROUNDING => 0,
- IS_ZERO_TERMINATED => $is_string,
- IS_VARYING => $is_varying,
- IS_CONFORMANT => $is_conformant,
- IS_FIXED => 0,
- IS_INLINE => 0
- });
-
- $is_deferred = 0;
- }
- }
-
- if (defined(has_property($e, "subcontext"))) {
- my $hdr_size = has_property($e, "subcontext");
- my $subsize = has_property($e, "subcontext_size");
- if (not defined($subsize)) {
- $subsize = -1;
- }
-
- push (@$order, {
- TYPE => "SUBCONTEXT",
- HEADER_SIZE => $hdr_size,
- SUBCONTEXT_SIZE => $subsize,
- IS_DEFERRED => $is_deferred,
- COMPRESSION => has_property($e, "compression"),
- });
- }
-
- if (my $switch = has_property($e, "switch_is")) {
- push (@$order, {
- TYPE => "SWITCH",
- SWITCH_IS => $switch,
- IS_DEFERRED => $is_deferred
- });
- }
-
- if (scalar(@size_is) > 0) {
- fatal($e, "size_is() on non-array element");
- }
-
- if (scalar(@length_is) > 0) {
- fatal($e, "length_is() on non-array element");
- }
-
- if (has_property($e, "string")) {
- fatal($e, "string() attribute on non-array element");
- }
-
- push (@$order, {
- TYPE => "DATA",
- DATA_TYPE => $e->{TYPE},
- IS_DEFERRED => $is_deferred,
- CONTAINS_DEFERRED => can_contain_deferred($e->{TYPE}),
- IS_SURROUNDING => 0 #FIXME
- });
-
- my $i = 0;
- foreach (@$order) { $_->{LEVEL_INDEX} = $i; $i+=1; }
-
- return $order;
-}
-
-sub GetTypedefLevelTable($$$)
-{
- my ($e, $data, $pointer_default) = @_;
-
- my $order = [];
-
- push (@$order, {
- TYPE => "TYPEDEF"
- });
-
- my $i = 0;
- foreach (@$order) { $_->{LEVEL_INDEX} = $i; $i+=1; }
-
- return $order;
-}
-
-#####################################################################
-# see if a type contains any deferred data
-sub can_contain_deferred($)
-{
- sub can_contain_deferred($);
- my ($type) = @_;
-
- return 1 unless (hasType($type)); # assume the worst
-
- $type = getType($type);
-
- return 0 if (Parse::Pidl::Typelist::is_scalar($type));
-
- return can_contain_deferred($type->{DATA}) if ($type->{TYPE} eq "TYPEDEF");
-
- return 0 unless defined($type->{ELEMENTS});
-
- foreach (@{$type->{ELEMENTS}}) {
- return 1 if ($_->{POINTERS});
- return 1 if (can_contain_deferred ($_->{TYPE}));
- }
-
- return 0;
-}
-
-sub pointer_type($)
-{
- my $e = shift;
-
- return undef unless $e->{POINTERS};
-
- return "ref" if (has_property($e, "ref"));
- return "full" if (has_property($e, "ptr"));
- return "sptr" if (has_property($e, "sptr"));
- return "unique" if (has_property($e, "unique"));
- return "relative" if (has_property($e, "relative"));
- return "ignore" if (has_property($e, "ignore"));
-
- return undef;
-}
-
-#####################################################################
-# work out the correct alignment for a structure or union
-sub find_largest_alignment($)
-{
- my $s = shift;
-
- my $align = 1;
- for my $e (@{$s->{ELEMENTS}}) {
- my $a = 1;
-
- if ($e->{POINTERS}) {
- $a = 4;
- } elsif (has_property($e, "subcontext")) {
- $a = 1;
- } elsif (has_property($e, "transmit_as")) {
- $a = align_type($e->{PROPERTIES}->{transmit_as});
- } else {
- $a = align_type($e->{TYPE});
- }
-
- $align = $a if ($align < $a);
- }
-
- return $align;
-}
-
-#####################################################################
-# align a type
-sub align_type($)
-{
- sub align_type($);
- my ($e) = @_;
-
- if (ref($e) eq "HASH" and $e->{TYPE} eq "SCALAR") {
- return $scalar_alignment->{$e->{NAME}};
- }
-
- return 0 if ($e eq "EMPTY");
-
- unless (hasType($e)) {
- # it must be an external type - all we can do is guess
- # warning($e, "assuming alignment of unknown type '$e' is 4");
- return 4;
- }
-
- my $dt = getType($e);
-
- if ($dt->{TYPE} eq "TYPEDEF") {
- return align_type($dt->{DATA});
- } elsif ($dt->{TYPE} eq "ENUM") {
- return align_type(Parse::Pidl::Typelist::enum_type_fn($dt));
- } elsif ($dt->{TYPE} eq "BITMAP") {
- return align_type(Parse::Pidl::Typelist::bitmap_type_fn($dt));
- } elsif (($dt->{TYPE} eq "STRUCT") or ($dt->{TYPE} eq "UNION")) {
- # Struct/union without body: assume 4
- return 4 unless (defined($dt->{ELEMENTS}));
- return find_largest_alignment($dt);
- }
-
- die("Unknown data type type $dt->{TYPE}");
-}
-
-sub ParseElement($$)
-{
- my ($e, $pointer_default) = @_;
-
- $e->{TYPE} = expandAlias($e->{TYPE});
-
- if (ref($e->{TYPE}) eq "HASH") {
- $e->{TYPE} = ParseType($e->{TYPE}, $pointer_default);
- }
-
- return {
- NAME => $e->{NAME},
- TYPE => $e->{TYPE},
- PROPERTIES => $e->{PROPERTIES},
- LEVELS => GetElementLevelTable($e, $pointer_default),
- REPRESENTATION_TYPE => ($e->{PROPERTIES}->{represent_as} or $e->{TYPE}),
- ALIGN => align_type($e->{TYPE}),
- ORIGINAL => $e
- };
-}
-
-sub ParseStruct($$)
-{
- my ($struct, $pointer_default) = @_;
- my @elements = ();
- my $surrounding = undef;
-
- return {
- TYPE => "STRUCT",
- NAME => $struct->{NAME},
- SURROUNDING_ELEMENT => undef,
- ELEMENTS => undef,
- PROPERTIES => $struct->{PROPERTIES},
- ORIGINAL => $struct,
- ALIGN => undef
- } unless defined($struct->{ELEMENTS});
-
- CheckPointerTypes($struct, $pointer_default);
-
- foreach my $x (@{$struct->{ELEMENTS}})
- {
- my $e = ParseElement($x, $pointer_default);
- if ($x != $struct->{ELEMENTS}[-1] and
- $e->{LEVELS}[0]->{IS_SURROUNDING}) {
- fatal($x, "conformant member not at end of struct");
- }
- push @elements, $e;
- }
-
- my $e = $elements[-1];
- if (defined($e) and defined($e->{LEVELS}[0]->{IS_SURROUNDING}) and
- $e->{LEVELS}[0]->{IS_SURROUNDING}) {
- $surrounding = $e;
- }
-
- if (defined $e->{TYPE} && $e->{TYPE} eq "string"
- && property_matches($e, "flag", ".*LIBNDR_FLAG_STR_CONFORMANT.*")) {
- $surrounding = $struct->{ELEMENTS}[-1];
- }
-
- my $align = undef;
- if ($struct->{NAME}) {
- $align = align_type($struct->{NAME});
- }
-
- return {
- TYPE => "STRUCT",
- NAME => $struct->{NAME},
- SURROUNDING_ELEMENT => $surrounding,
- ELEMENTS => \@elements,
- PROPERTIES => $struct->{PROPERTIES},
- ORIGINAL => $struct,
- ALIGN => $align
- };
-}
-
-sub ParseUnion($$)
-{
- my ($e, $pointer_default) = @_;
- my @elements = ();
- my $hasdefault = 0;
- my $switch_type = has_property($e, "switch_type");
- unless (defined($switch_type)) { $switch_type = "uint32"; }
- if (has_property($e, "nodiscriminant")) { $switch_type = undef; }
-
- return {
- TYPE => "UNION",
- NAME => $e->{NAME},
- SWITCH_TYPE => $switch_type,
- ELEMENTS => undef,
- PROPERTIES => $e->{PROPERTIES},
- HAS_DEFAULT => $hasdefault,
- ORIGINAL => $e
- } unless defined($e->{ELEMENTS});
-
- CheckPointerTypes($e, $pointer_default);
-
- foreach my $x (@{$e->{ELEMENTS}})
- {
- my $t;
- if ($x->{TYPE} eq "EMPTY") {
- $t = { TYPE => "EMPTY" };
- } else {
- $t = ParseElement($x, $pointer_default);
- }
- if (has_property($x, "default")) {
- $t->{CASE} = "default";
- $hasdefault = 1;
- } elsif (defined($x->{PROPERTIES}->{case})) {
- $t->{CASE} = "case $x->{PROPERTIES}->{case}";
- } else {
- die("Union element $x->{NAME} has neither default nor case property");
- }
- push @elements, $t;
- }
-
- return {
- TYPE => "UNION",
- NAME => $e->{NAME},
- SWITCH_TYPE => $switch_type,
- ELEMENTS => \@elements,
- PROPERTIES => $e->{PROPERTIES},
- HAS_DEFAULT => $hasdefault,
- ORIGINAL => $e
- };
-}
-
-sub ParseEnum($$)
-{
- my ($e, $pointer_default) = @_;
-
- return {
- TYPE => "ENUM",
- NAME => $e->{NAME},
- BASE_TYPE => Parse::Pidl::Typelist::enum_type_fn($e),
- ELEMENTS => $e->{ELEMENTS},
- PROPERTIES => $e->{PROPERTIES},
- ORIGINAL => $e
- };
-}
-
-sub ParseBitmap($$)
-{
- my ($e, $pointer_default) = @_;
-
- return {
- TYPE => "BITMAP",
- NAME => $e->{NAME},
- BASE_TYPE => Parse::Pidl::Typelist::bitmap_type_fn($e),
- ELEMENTS => $e->{ELEMENTS},
- PROPERTIES => $e->{PROPERTIES},
- ORIGINAL => $e
- };
-}
-
-sub ParseType($$)
-{
- my ($d, $pointer_default) = @_;
-
- my $data = {
- STRUCT => \&ParseStruct,
- UNION => \&ParseUnion,
- ENUM => \&ParseEnum,
- BITMAP => \&ParseBitmap,
- TYPEDEF => \&ParseTypedef,
- }->{$d->{TYPE}}->($d, $pointer_default);
-
- return $data;
-}
-
-sub ParseTypedef($$)
-{
- my ($d, $pointer_default) = @_;
-
- if (defined($d->{DATA}->{PROPERTIES}) && !defined($d->{PROPERTIES})) {
- $d->{PROPERTIES} = $d->{DATA}->{PROPERTIES};
- }
-
- my $data = ParseType($d->{DATA}, $pointer_default);
- $data->{ALIGN} = align_type($d->{NAME});
-
- return {
- NAME => $d->{NAME},
- TYPE => $d->{TYPE},
- PROPERTIES => $d->{PROPERTIES},
- LEVELS => GetTypedefLevelTable($d, $data, $pointer_default),
- DATA => $data,
- ORIGINAL => $d
- };
-}
-
-sub ParseConst($$)
-{
- my ($ndr,$d) = @_;
-
- return $d;
-}
-
-sub ParseFunction($$$)
-{
- my ($ndr,$d,$opnum) = @_;
- my @elements = ();
- my $rettype = undef;
- my $thisopnum = undef;
-
- CheckPointerTypes($d, "ref");
-
- if (not defined($d->{PROPERTIES}{noopnum})) {
- $thisopnum = ${$opnum};
- ${$opnum}++;
- }
-
- foreach my $x (@{$d->{ELEMENTS}}) {
- my $e = ParseElement($x, $ndr->{PROPERTIES}->{pointer_default});
- push (@{$e->{DIRECTION}}, "in") if (has_property($x, "in"));
- push (@{$e->{DIRECTION}}, "out") if (has_property($x, "out"));
-
- push (@elements, $e);
- }
-
- if ($d->{RETURN_TYPE} ne "void") {
- $rettype = expandAlias($d->{RETURN_TYPE});
- }
-
- my $async = 0;
- if (has_property($d, "async")) { $async = 1; }
-
- return {
- NAME => $d->{NAME},
- TYPE => "FUNCTION",
- OPNUM => $thisopnum,
- ASYNC => $async,
- RETURN_TYPE => $rettype,
- PROPERTIES => $d->{PROPERTIES},
- ELEMENTS => \@elements,
- ORIGINAL => $d
- };
-}
-
-sub CheckPointerTypes($$)
-{
- my ($s,$default) = @_;
-
- return unless defined($s->{ELEMENTS});
-
- foreach my $e (@{$s->{ELEMENTS}}) {
- if ($e->{POINTERS} and not defined(pointer_type($e))) {
- $e->{PROPERTIES}->{$default} = '1';
- }
- }
-}
-
-sub FindNestedTypes($$)
-{
- sub FindNestedTypes($$);
- my ($l, $t) = @_;
-
- return unless defined($t->{ELEMENTS});
- return if ($t->{TYPE} eq "ENUM");
- return if ($t->{TYPE} eq "BITMAP");
-
- foreach (@{$t->{ELEMENTS}}) {
- if (ref($_->{TYPE}) eq "HASH") {
- push (@$l, $_->{TYPE}) if (defined($_->{TYPE}->{NAME}));
- FindNestedTypes($l, $_->{TYPE});
- }
- }
-}
-
-sub ParseInterface($)
-{
- my $idl = shift;
- my @types = ();
- my @consts = ();
- my @functions = ();
- my @endpoints;
- my $opnum = 0;
- my $version;
-
- if (not has_property($idl, "pointer_default")) {
- # MIDL defaults to "ptr" in DCE compatible mode (/osf)
- # and "unique" in Microsoft Extensions mode (default)
- $idl->{PROPERTIES}->{pointer_default} = "unique";
- }
-
- foreach my $d (@{$idl->{DATA}}) {
- if ($d->{TYPE} eq "FUNCTION") {
- push (@functions, ParseFunction($idl, $d, \$opnum));
- } elsif ($d->{TYPE} eq "CONST") {
- push (@consts, ParseConst($idl, $d));
- } else {
- push (@types, ParseType($d, $idl->{PROPERTIES}->{pointer_default}));
- FindNestedTypes(\@types, $d);
- }
- }
-
- $version = "0.0";
-
- if(defined $idl->{PROPERTIES}->{version}) {
- my @if_version = split(/\./, $idl->{PROPERTIES}->{version});
- if ($if_version[0] == $idl->{PROPERTIES}->{version}) {
- $version = $idl->{PROPERTIES}->{version};
- } else {
- $version = $if_version[1] << 16 | $if_version[0];
- }
- }
-
- # If no endpoint is set, default to the interface name as a named pipe
- if (!defined $idl->{PROPERTIES}->{endpoint}) {
- push @endpoints, "\"ncacn_np:[\\\\pipe\\\\" . $idl->{NAME} . "]\"";
- } else {
- @endpoints = split /,/, $idl->{PROPERTIES}->{endpoint};
- }
-
- return {
- NAME => $idl->{NAME},
- UUID => lc(has_property($idl, "uuid")),
- VERSION => $version,
- TYPE => "INTERFACE",
- PROPERTIES => $idl->{PROPERTIES},
- FUNCTIONS => \@functions,
- CONSTS => \@consts,
- TYPES => \@types,
- ENDPOINTS => \@endpoints
- };
-}
-
-# Convert a IDL tree to a NDR tree
-# Gives a result tree describing all that's necessary for easily generating
-# NDR parsers / generators
-sub Parse($)
-{
- my $idl = shift;
-
- return undef unless (defined($idl));
-
- Parse::Pidl::NDR::Validate($idl);
-
- my @ndr = ();
-
- foreach (@{$idl}) {
- ($_->{TYPE} eq "CPP_QUOTE") && push(@ndr, $_);
- ($_->{TYPE} eq "INTERFACE") && push(@ndr, ParseInterface($_));
- ($_->{TYPE} eq "IMPORT") && push(@ndr, $_);
- }
-
- return \@ndr;
-}
-
-sub GetNextLevel($$)
-{
- my $e = shift;
- my $fl = shift;
-
- my $seen = 0;
-
- foreach my $l (@{$e->{LEVELS}}) {
- return $l if ($seen);
- ($seen = 1) if ($l == $fl);
- }
-
- return undef;
-}
-
-sub GetPrevLevel($$)
-{
- my ($e,$fl) = @_;
- my $prev = undef;
-
- foreach my $l (@{$e->{LEVELS}}) {
- (return $prev) if ($l == $fl);
- $prev = $l;
- }
-
- return undef;
-}
-
-sub ContainsString($)
-{
- my ($e) = @_;
-
- foreach my $l (@{$e->{LEVELS}}) {
- return 1 if ($l->{TYPE} eq "ARRAY" and $l->{IS_ZERO_TERMINATED});
- }
-
- return 0;
-}
-
-sub ContainsDeferred($$)
-{
- my ($e,$l) = @_;
-
- return 1 if ($l->{CONTAINS_DEFERRED});
-
- while ($l = GetNextLevel($e,$l))
- {
- return 1 if ($l->{IS_DEFERRED});
- return 1 if ($l->{CONTAINS_DEFERRED});
- }
-
- return 0;
-}
-
-sub el_name($)
-{
- my $e = shift;
- my $name = "<ANONYMOUS>";
-
- $name = $e->{NAME} if defined($e->{NAME});
-
- if (defined($e->{PARENT}) and defined($e->{PARENT}->{NAME})) {
- return "$e->{PARENT}->{NAME}.$name";
- }
-
- if (defined($e->{PARENT}) and
- defined($e->{PARENT}->{PARENT}) and
- defined($e->{PARENT}->{PARENT}->{NAME})) {
- return "$e->{PARENT}->{PARENT}->{NAME}.$name";
- }
-
- return $name;
-}
-
-###################################
-# find a sibling var in a structure
-sub find_sibling($$)
-{
- my($e,$name) = @_;
- my($fn) = $e->{PARENT};
-
- if ($name =~ /\*(.*)/) {
- $name = $1;
- }
-
- for my $e2 (@{$fn->{ELEMENTS}}) {
- return $e2 if ($e2->{NAME} eq $name);
- }
-
- return undef;
-}
-
-my %property_list = (
- # interface
- "helpstring" => ["INTERFACE", "FUNCTION"],
- "version" => ["INTERFACE"],
- "uuid" => ["INTERFACE"],
- "endpoint" => ["INTERFACE"],
- "pointer_default" => ["INTERFACE"],
- "helper" => ["INTERFACE"],
- "authservice" => ["INTERFACE"],
- "restricted" => ["INTERFACE"],
-
- # dcom
- "object" => ["INTERFACE"],
- "local" => ["INTERFACE", "FUNCTION"],
- "iid_is" => ["ELEMENT"],
- "call_as" => ["FUNCTION"],
- "idempotent" => ["FUNCTION"],
-
- # function
- "noopnum" => ["FUNCTION"],
- "in" => ["ELEMENT"],
- "out" => ["ELEMENT"],
- "async" => ["FUNCTION"],
-
- # pointer
- "ref" => ["ELEMENT"],
- "ptr" => ["ELEMENT"],
- "unique" => ["ELEMENT"],
- "ignore" => ["ELEMENT"],
- "relative" => ["ELEMENT"],
- "null_is_ffffffff" => ["ELEMENT"],
- "relative_base" => ["TYPEDEF", "STRUCT", "UNION"],
-
- "gensize" => ["TYPEDEF", "STRUCT", "UNION"],
- "value" => ["ELEMENT"],
- "flag" => ["ELEMENT", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
-
- # generic
- "public" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
- "nopush" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
- "nopull" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
- "nosize" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
- "noprint" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP", "ELEMENT"],
- "noejs" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
- "todo" => ["FUNCTION"],
-
- # union
- "switch_is" => ["ELEMENT"],
- "switch_type" => ["ELEMENT", "UNION"],
- "nodiscriminant" => ["UNION"],
- "case" => ["ELEMENT"],
- "default" => ["ELEMENT"],
-
- "represent_as" => ["ELEMENT"],
- "transmit_as" => ["ELEMENT"],
-
- # subcontext
- "subcontext" => ["ELEMENT"],
- "subcontext_size" => ["ELEMENT"],
- "compression" => ["ELEMENT"],
-
- # enum
- "enum8bit" => ["ENUM"],
- "enum16bit" => ["ENUM"],
- "v1_enum" => ["ENUM"],
-
- # bitmap
- "bitmap8bit" => ["BITMAP"],
- "bitmap16bit" => ["BITMAP"],
- "bitmap32bit" => ["BITMAP"],
- "bitmap64bit" => ["BITMAP"],
-
- # array
- "range" => ["ELEMENT"],
- "size_is" => ["ELEMENT"],
- "string" => ["ELEMENT"],
- "noheader" => ["ELEMENT"],
- "charset" => ["ELEMENT"],
- "length_is" => ["ELEMENT"],
-);
-
-#####################################################################
-# check for unknown properties
-sub ValidProperties($$)
-{
- my ($e,$t) = @_;
-
- return unless defined $e->{PROPERTIES};
-
- foreach my $key (keys %{$e->{PROPERTIES}}) {
- warning($e, el_name($e) . ": unknown property '$key'")
- unless defined($property_list{$key});
-
- fatal($e, el_name($e) . ": property '$key' not allowed on '$t'")
- unless grep(/^$t$/, @{$property_list{$key}});
- }
-}
-
-sub mapToScalar($)
-{
- sub mapToScalar($);
- my $t = shift;
- return $t->{NAME} if (ref($t) eq "HASH" and $t->{TYPE} eq "SCALAR");
- my $ti = getType($t);
-
- if (not defined ($ti)) {
- return undef;
- } elsif ($ti->{TYPE} eq "TYPEDEF") {
- return mapToScalar($ti->{DATA});
- } elsif ($ti->{TYPE} eq "ENUM") {
- return Parse::Pidl::Typelist::enum_type_fn($ti);
- } elsif ($ti->{TYPE} eq "BITMAP") {
- return Parse::Pidl::Typelist::bitmap_type_fn($ti);
- }
-
- return undef;
-}
-
-#####################################################################
-# validate an element
-sub ValidElement($)
-{
- my $e = shift;
-
- ValidProperties($e,"ELEMENT");
-
- # Check whether switches are used correctly.
- if (my $switch = has_property($e, "switch_is")) {
- my $e2 = find_sibling($e, $switch);
- my $type = getType($e->{TYPE});
-
- if (defined($type) and $type->{DATA}->{TYPE} ne "UNION") {
- fatal($e, el_name($e) . ": switch_is() used on non-union type $e->{TYPE} which is a $type->{DATA}->{TYPE}");
- }
-
- if (not has_property($type->{DATA}, "nodiscriminant") and defined($e2)) {
- my $discriminator_type = has_property($type->{DATA}, "switch_type");
- $discriminator_type = "uint32" unless defined ($discriminator_type);
-
- my $t1 = mapToScalar($discriminator_type);
-
- if (not defined($t1)) {
- fatal($e, el_name($e) . ": unable to map discriminator type '$discriminator_type' to scalar");
- }
-
- my $t2 = mapToScalar($e2->{TYPE});
- if (not defined($t2)) {
- fatal($e, el_name($e) . ": unable to map variable used for switch_is() to scalar");
- }
-
- if ($t1 ne $t2) {
- warning($e, el_name($e) . ": switch_is() is of type $e2->{TYPE} ($t2), while discriminator type for union $type->{NAME} is $discriminator_type ($t1)");
- }
- }
- }
-
- if (has_property($e, "subcontext") and has_property($e, "represent_as")) {
- fatal($e, el_name($e) . " : subcontext() and represent_as() can not be used on the same element");
- }
-
- if (has_property($e, "subcontext") and has_property($e, "transmit_as")) {
- fatal($e, el_name($e) . " : subcontext() and transmit_as() can not be used on the same element");
- }
-
- if (has_property($e, "represent_as") and has_property($e, "transmit_as")) {
- fatal($e, el_name($e) . " : represent_as() and transmit_as() can not be used on the same element");
- }
-
- if (has_property($e, "represent_as") and has_property($e, "value")) {
- fatal($e, el_name($e) . " : represent_as() and value() can not be used on the same element");
- }
-
- if (has_property($e, "subcontext")) {
- warning($e, "subcontext() is deprecated. Use represent_as() or transmit_as() instead");
- }
-
- if (defined (has_property($e, "subcontext_size")) and not defined(has_property($e, "subcontext"))) {
- fatal($e, el_name($e) . " : subcontext_size() on non-subcontext element");
- }
-
- if (defined (has_property($e, "compression")) and not defined(has_property($e, "subcontext"))) {
- fatal($e, el_name($e) . " : compression() on non-subcontext element");
- }
-
- if (!$e->{POINTERS} && (
- has_property($e, "ptr") or
- has_property($e, "unique") or
- has_property($e, "relative") or
- has_property($e, "ref"))) {
- fatal($e, el_name($e) . " : pointer properties on non-pointer element\n");
- }
-}
-
-#####################################################################
-# validate an enum
-sub ValidEnum($)
-{
- my ($enum) = @_;
-
- ValidProperties($enum, "ENUM");
-}
-
-#####################################################################
-# validate a bitmap
-sub ValidBitmap($)
-{
- my ($bitmap) = @_;
-
- ValidProperties($bitmap, "BITMAP");
-}
-
-#####################################################################
-# validate a struct
-sub ValidStruct($)
-{
- my($struct) = shift;
-
- ValidProperties($struct, "STRUCT");
-
- return unless defined($struct->{ELEMENTS});
-
- foreach my $e (@{$struct->{ELEMENTS}}) {
- $e->{PARENT} = $struct;
- ValidElement($e);
- }
-}
-
-#####################################################################
-# parse a union
-sub ValidUnion($)
-{
- my($union) = shift;
-
- ValidProperties($union,"UNION");
-
- if (has_property($union->{PARENT}, "nodiscriminant") and
- has_property($union->{PARENT}, "switch_type")) {
- fatal($union->{PARENT}, $union->{PARENT}->{NAME} . ": switch_type(" . $union->{PARENT}->{PROPERTIES}->{switch_type} . ") on union without discriminant");
- }
-
- return unless defined($union->{ELEMENTS});
-
- foreach my $e (@{$union->{ELEMENTS}}) {
- $e->{PARENT} = $union;
-
- if (defined($e->{PROPERTIES}->{default}) and
- defined($e->{PROPERTIES}->{case})) {
- fatal($e, "Union member $e->{NAME} can not have both default and case properties!");
- }
-
- unless (defined ($e->{PROPERTIES}->{default}) or
- defined ($e->{PROPERTIES}->{case})) {
- fatal($e, "Union member $e->{NAME} must have default or case property");
- }
-
- if (has_property($e, "ref")) {
- fatal($e, el_name($e) . ": embedded ref pointers are not supported yet\n");
- }
-
-
- ValidElement($e);
- }
-}
-
-#####################################################################
-# parse a typedef
-sub ValidTypedef($)
-{
- my($typedef) = shift;
- my $data = $typedef->{DATA};
-
- ValidProperties($typedef, "TYPEDEF");
-
- $data->{PARENT} = $typedef;
-
- $data->{FILE} = $typedef->{FILE} unless defined($data->{FILE});
- $data->{LINE} = $typedef->{LINE} unless defined($data->{LINE});
-
- ValidType($data) if (ref($data) eq "HASH");
-}
-
-#####################################################################
-# validate a function
-sub ValidFunction($)
-{
- my($fn) = shift;
-
- ValidProperties($fn,"FUNCTION");
-
- foreach my $e (@{$fn->{ELEMENTS}}) {
- $e->{PARENT} = $fn;
- if (has_property($e, "ref") && !$e->{POINTERS}) {
- fatal($e, "[ref] variables must be pointers ($fn->{NAME}/$e->{NAME})");
- }
- ValidElement($e);
- }
-}
-
-#####################################################################
-# validate a type
-sub ValidType($)
-{
- my ($t) = @_;
-
- {
- TYPEDEF => \&ValidTypedef,
- STRUCT => \&ValidStruct,
- UNION => \&ValidUnion,
- ENUM => \&ValidEnum,
- BITMAP => \&ValidBitmap
- }->{$t->{TYPE}}->($t);
-}
-
-#####################################################################
-# parse the interface definitions
-sub ValidInterface($)
-{
- my($interface) = shift;
- my($data) = $interface->{DATA};
-
- if (has_property($interface, "helper")) {
- warning($interface, "helper() is pidl-specific and deprecated. Use `include' instead");
- }
-
- ValidProperties($interface,"INTERFACE");
-
- if (has_property($interface, "pointer_default")) {
- if (not grep (/$interface->{PROPERTIES}->{pointer_default}/,
- ("ref", "unique", "ptr"))) {
- fatal($interface, "Unknown default pointer type `$interface->{PROPERTIES}->{pointer_default}'");
- }
- }
-
- if (has_property($interface, "object")) {
- if (has_property($interface, "version") &&
- $interface->{PROPERTIES}->{version} != 0) {
- fatal($interface, "Object interfaces must have version 0.0 ($interface->{NAME})");
- }
-
- if (!defined($interface->{BASE}) &&
- not ($interface->{NAME} eq "IUnknown")) {
- fatal($interface, "Object interfaces must all derive from IUnknown ($interface->{NAME})");
- }
- }
-
- foreach my $d (@{$data}) {
- ($d->{TYPE} eq "FUNCTION") && ValidFunction($d);
- ($d->{TYPE} eq "TYPEDEF" or
- $d->{TYPE} eq "STRUCT" or
- $d->{TYPE} eq "UNION" or
- $d->{TYPE} eq "ENUM" or
- $d->{TYPE} eq "BITMAP") && ValidType($d);
- }
-
-}
-
-#####################################################################
-# Validate an IDL structure
-sub Validate($)
-{
- my($idl) = shift;
-
- foreach my $x (@{$idl}) {
- ($x->{TYPE} eq "INTERFACE") &&
- ValidInterface($x);
- ($x->{TYPE} eq "IMPORTLIB") &&
- fatal($x, "importlib() not supported");
- }
-}
-
-sub is_charset_array($$)
-{
- my ($e,$l) = @_;
-
- return 0 if ($l->{TYPE} ne "ARRAY");
-
- my $nl = GetNextLevel($e,$l);
-
- return 0 unless ($nl->{TYPE} eq "DATA");
-
- return has_property($e, "charset");
-}
-
-
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/ODL.pm b/source4/pidl/lib/Parse/Pidl/ODL.pm
deleted file mode 100644
index ad8c76f622..0000000000
--- a/source4/pidl/lib/Parse/Pidl/ODL.pm
+++ /dev/null
@@ -1,117 +0,0 @@
-##########################################
-# Converts ODL stuctures to IDL structures
-# (C) 2004-2005, 2008 Jelmer Vernooij <jelmer@samba.org>
-
-package Parse::Pidl::ODL;
-
-use Parse::Pidl qw(error);
-use Parse::Pidl::IDL;
-use Parse::Pidl::Util qw(has_property unmake_str);
-use Parse::Pidl::Typelist qw(hasType getType);
-use strict;
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-sub FunctionAddObjArgs($)
-{
- my $e = shift;
-
- unshift(@{$e->{ELEMENTS}}, {
- 'NAME' => 'ORPCthis',
- 'POINTERS' => 0,
- 'PROPERTIES' => { 'in' => '1' },
- 'TYPE' => 'ORPCTHIS',
- 'FILE' => $e->{FILE},
- 'LINE' => $e->{LINE}
- });
- unshift(@{$e->{ELEMENTS}}, {
- 'NAME' => 'ORPCthat',
- 'POINTERS' => 1,
- 'PROPERTIES' => { 'out' => '1', 'ref' => '1' },
- 'TYPE' => 'ORPCTHAT',
- 'FILE' => $e->{FILE},
- 'LINE' => $e->{LINE}
- });
-}
-
-sub ReplaceInterfacePointers($)
-{
- my ($e) = @_;
- foreach my $x (@{$e->{ELEMENTS}}) {
- next unless (hasType($x->{TYPE}));
- next unless getType($x->{TYPE})->{DATA}->{TYPE} eq "INTERFACE";
-
- $x->{TYPE} = "MInterfacePointer";
- }
-}
-
-# Add ORPC specific bits to an interface.
-sub ODL2IDL
-{
- my ($odl, $basedir, $opt_incdirs) = (@_);
- my $addedorpc = 0;
- my $interfaces = {};
-
- foreach my $x (@$odl) {
- if ($x->{TYPE} eq "IMPORT") {
- foreach my $idl_file (@{$x->{PATHS}}) {
- $idl_file = unmake_str($idl_file);
- my $podl = Parse::Pidl::IDL::parse_file("$basedir/$idl_file", $opt_incdirs);
- if (defined(@$podl)) {
- require Parse::Pidl::Typelist;
-
- Parse::Pidl::Typelist::LoadIdl($podl);
- my $pidl = ODL2IDL($podl, $basedir, $opt_incdirs);
-
- foreach my $y (@$pidl) {
- if ($y->{TYPE} eq "INTERFACE") {
- $interfaces->{$y->{NAME}} = $y;
- }
- }
- } else {
- error($x, "Failed to parse $idl_file");
- }
- }
- }
-
- if ($x->{TYPE} eq "INTERFACE") {
- $interfaces->{$x->{NAME}} = $x;
- # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that
- # and replace interfacepointers with MInterfacePointer
- # for 'object' interfaces
- if (has_property($x, "object")) {
- foreach my $e (@{$x->{DATA}}) {
- ($e->{TYPE} eq "FUNCTION") && FunctionAddObjArgs($e);
- ReplaceInterfacePointers($e);
- }
- $addedorpc = 1;
- }
-
- if ($x->{BASE}) {
- my $base = $interfaces->{$x->{BASE}};
-
- unless (defined($base)) {
- error($x, "Undefined base interface `$x->{BASE}'");
- } else {
- foreach my $fn (reverse @{$base->{DATA}}) {
- next unless ($fn->{TYPE} eq "FUNCTION");
- push (@{$x->{INHERITED_FUNCTIONS}}, $fn);
- }
- }
- }
- }
- }
-
- unshift (@$odl, {
- TYPE => "IMPORT",
- PATHS => [ "\"orpc.idl\"" ],
- FILE => undef,
- LINE => undef
- }) if ($addedorpc);
-
-
- return $odl;
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm b/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
deleted file mode 100644
index 2a23fad4a7..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
+++ /dev/null
@@ -1,243 +0,0 @@
-###################################################
-# Samba3 client generator for IDL structures
-# on top of Samba4 style NDR functions
-# Copyright jelmer@samba.org 2005-2006
-# Copyright gd@samba.org 2008
-# released under the GNU GPL
-
-package Parse::Pidl::Samba3::ClientNDR;
-
-use Exporter;
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(ParseFunction $res $res_hdr ParseOutputArgument);
-
-use strict;
-use Parse::Pidl qw(fatal warning);
-use Parse::Pidl::Util qw(has_property ParseExpr);
-use Parse::Pidl::Samba4 qw(DeclLong);
-use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv);
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-sub indent($) { my ($self) = @_; $self->{tabs}.="\t"; }
-sub deindent($) { my ($self) = @_; $self->{tabs} = substr($self->{tabs}, 1); }
-sub pidl($$) { my ($self,$txt) = @_; $self->{res} .= $txt ? "$self->{tabs}$txt\n" : "\n"; }
-sub pidl_hdr($$) { my ($self, $txt) = @_; $self->{res_hdr} .= "$txt\n"; }
-sub fn_declare($$) { my ($self,$n) = @_; $self->pidl($n); $self->pidl_hdr("$n;"); }
-
-sub genpad($)
-{
- my ($s) = @_;
- my $nt = int((length($s)+1)/8);
- my $lt = ($nt*8)-1;
- my $ns = (length($s)-$lt);
- return "\t"x($nt)." "x($ns);
-}
-
-sub new($)
-{
- my ($class) = shift;
- my $self = { res => "", res_hdr => "", tabs => "" };
- bless($self, $class);
-}
-
-sub ElementDirection($)
-{
- my ($e) = @_;
-
- return "[in,out]" if (has_property($e, "in") and has_property($e, "out"));
- return "[in]" if (has_property($e, "in"));
- return "[out]" if (has_property($e, "out"));
- return "[in,out]";
-}
-
-sub HeaderProperties($$)
-{
- my($props,$ignores) = @_;
- my $ret = "";
-
- foreach my $d (keys %{$props}) {
- next if (grep(/^$d$/, @$ignores));
- if($props->{$d} ne "1") {
- $ret.= "$d($props->{$d}),";
- } else {
- $ret.="$d,";
- }
- }
-
- if ($ret) {
- return "[" . substr($ret, 0, -1) . "]";
- }
-}
-
-sub ParseOutputArgument($$$)
-{
- my ($self, $fn, $e) = @_;
- my $level = 0;
-
- fatal($e->{ORIGINAL}, "[out] argument is not a pointer or array") if ($e->{LEVELS}[0]->{TYPE} ne "POINTER" and $e->{LEVELS}[0]->{TYPE} ne "ARRAY");
-
- if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
- $level = 1;
- if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
- $self->pidl("if ($e->{NAME} && r.out.$e->{NAME}) {");
- $self->indent;
- }
- }
-
- if ($e->{LEVELS}[$level]->{TYPE} eq "ARRAY") {
- # This is a call to GenerateFunctionInEnv intentionally.
- # Since the data is being copied into a user-provided data
- # structure, the user should be able to know the size beforehand
- # to allocate a structure of the right size.
- my $env = GenerateFunctionInEnv($fn, "r.");
- my $size_is = ParseExpr($e->{LEVELS}[$level]->{SIZE_IS}, $env, $e->{ORIGINAL});
- $self->pidl("memcpy($e->{NAME}, r.out.$e->{NAME}, $size_is * sizeof(*$e->{NAME}));");
- } else {
- $self->pidl("*$e->{NAME} = *r.out.$e->{NAME};");
- }
-
- if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
- if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
- $self->deindent;
- $self->pidl("}");
- }
- }
-}
-
-sub ParseFunction($$$)
-{
- my ($self, $if, $fn) = @_;
-
- my $fn_args = "";
- my $uif = uc($if);
- my $ufn = "NDR_".uc($fn->{NAME});
- my $fn_str = "NTSTATUS rpccli_$fn->{NAME}";
- my $pad = genpad($fn_str);
-
- $fn_args .= "struct rpc_pipe_client *cli,\n" . $pad . "TALLOC_CTX *mem_ctx";
-
- foreach (@{$fn->{ELEMENTS}}) {
- my $dir = ElementDirection($_);
- my $prop = HeaderProperties($_->{PROPERTIES}, ["in", "out"]);
- $fn_args .= ",\n" . $pad . DeclLong($_) . " /* $dir $prop */";
- }
-
- if (defined($fn->{RETURN_TYPE}) && ($fn->{RETURN_TYPE} eq "WERROR")) {
- $fn_args .= ",\n" . $pad . "WERROR *werror";
- }
-
- $self->fn_declare("$fn_str($fn_args)");
- $self->pidl("{");
- $self->indent;
- $self->pidl("struct $fn->{NAME} r;");
- $self->pidl("NTSTATUS status;");
- $self->pidl("");
- $self->pidl("/* In parameters */");
-
- foreach (@{$fn->{ELEMENTS}}) {
- if (grep(/in/, @{$_->{DIRECTION}})) {
- $self->pidl("r.in.$_->{NAME} = $_->{NAME};");
- }
- }
-
- $self->pidl("");
- $self->pidl("if (DEBUGLEVEL >= 10) {");
- $self->indent;
- $self->pidl("NDR_PRINT_IN_DEBUG($fn->{NAME}, &r);");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
- $self->pidl("status = cli_do_rpc_ndr(cli,");
- $self->pidl("\t\t\tmem_ctx,");
- $self->pidl("\t\t\t&ndr_table_$if,");
- $self->pidl("\t\t\t$ufn,");
- $self->pidl("\t\t\t&r);");
- $self->pidl("");
-
- $self->pidl("if (!NT_STATUS_IS_OK(status)) {");
- $self->indent;
- $self->pidl("return status;");
- $self->deindent;
- $self->pidl("}");
-
- $self->pidl("");
- $self->pidl("if (DEBUGLEVEL >= 10) {");
- $self->indent;
- $self->pidl("NDR_PRINT_OUT_DEBUG($fn->{NAME}, &r);");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
- $self->pidl("if (NT_STATUS_IS_ERR(status)) {");
- $self->indent;
- $self->pidl("return status;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
- $self->pidl("/* Return variables */");
- foreach my $e (@{$fn->{ELEMENTS}}) {
- next unless (grep(/out/, @{$e->{DIRECTION}}));
-
- $self->ParseOutputArgument($fn, $e);
-
- }
-
- $self->pidl("");
- $self->pidl("/* Return result */");
- if (not $fn->{RETURN_TYPE}) {
- $self->pidl("return NT_STATUS_OK;");
- } elsif ($fn->{RETURN_TYPE} eq "NTSTATUS") {
- $self->pidl("return r.out.result;");
- } elsif ($fn->{RETURN_TYPE} eq "WERROR") {
- $self->pidl("if (werror) {");
- $self->indent;
- $self->pidl("*werror = r.out.result;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
- $self->pidl("return werror_to_ntstatus(r.out.result);");
- } else {
- warning($fn->{ORIGINAL}, "Unable to convert $fn->{RETURN_TYPE} to NTSTATUS");
- $self->pidl("return NT_STATUS_OK;");
- }
-
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-}
-
-sub ParseInterface($$)
-{
- my ($self, $if) = @_;
-
- my $uif = uc($if->{NAME});
-
- $self->pidl_hdr("#ifndef __CLI_$uif\__");
- $self->pidl_hdr("#define __CLI_$uif\__");
- $self->ParseFunction($if->{NAME}, $_) foreach (@{$if->{FUNCTIONS}});
- $self->pidl_hdr("#endif /* __CLI_$uif\__ */");
-}
-
-sub Parse($$$$)
-{
- my($self,$ndr,$header,$ndr_header) = @_;
-
- $self->pidl("/*");
- $self->pidl(" * Unix SMB/CIFS implementation.");
- $self->pidl(" * client auto-generated by pidl. DO NOT MODIFY!");
- $self->pidl(" */");
- $self->pidl("");
- $self->pidl("#include \"includes.h\"");
- $self->pidl("#include \"$header\"");
- $self->pidl_hdr("#include \"$ndr_header\"");
- $self->pidl("");
-
- foreach (@$ndr) {
- $self->ParseInterface($_) if ($_->{TYPE} eq "INTERFACE");
- }
-
- return ($self->{res}, $self->{res_hdr});
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm b/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
deleted file mode 100644
index b21d3f4bbc..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
+++ /dev/null
@@ -1,268 +0,0 @@
-###################################################
-# Samba3 server generator for IDL structures
-# on top of Samba4 style NDR functions
-# Copyright jelmer@samba.org 2005-2006
-# released under the GNU GPL
-
-package Parse::Pidl::Samba3::ServerNDR;
-
-use Exporter;
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(DeclLevel);
-
-use strict;
-use Parse::Pidl qw(warning fatal);
-use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
-use Parse::Pidl::Util qw(ParseExpr has_property is_constant);
-use Parse::Pidl::NDR qw(GetNextLevel);
-use Parse::Pidl::Samba4 qw(ElementStars DeclLong);
-use Parse::Pidl::Samba4::Header qw(GenerateFunctionOutEnv);
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-my $res;
-my $res_hdr;
-my $tabs = "";
-sub indent() { $tabs.="\t"; }
-sub deindent() { $tabs = substr($tabs, 1); }
-sub pidl($) { my ($txt) = @_; $res .= $txt?$tabs.(shift)."\n":"\n"; }
-sub pidl_hdr($) { $res_hdr .= (shift)."\n"; }
-sub fn_declare($) { my ($n) = @_; pidl $n; pidl_hdr "$n;"; }
-
-sub DeclLevel($$)
-{
- my ($e, $l) = @_;
- my $res = "";
-
- if (has_property($e, "charset")) {
- $res .= "const char";
- } else {
- $res .= mapTypeName($e->{TYPE});
- }
-
- my $stars = ElementStars($e, $l);
-
- $res .= " ".$stars unless ($stars eq "");
-
- return $res;
-}
-
-sub AllocOutVar($$$$)
-{
- my ($e, $mem_ctx, $name, $env) = @_;
-
- my $l = $e->{LEVELS}[0];
-
- # we skip pointer to arrays
- if ($l->{TYPE} eq "POINTER") {
- my $nl = GetNextLevel($e, $l);
- $l = $nl if ($nl->{TYPE} eq "ARRAY");
- }
-
- # we don't support multi-dimentional arrays yet
- if ($l->{TYPE} eq "ARRAY") {
- my $nl = GetNextLevel($e, $l);
- if ($nl->{TYPE} eq "ARRAY") {
- fatal($e->{ORIGINAL},"multi-dimentional [out] arrays are not supported!");
- }
- }
-
- if ($l->{TYPE} eq "ARRAY") {
- my $size = ParseExpr($l->{SIZE_IS}, $env, $e);
- pidl "$name = talloc_zero_array($mem_ctx, " . DeclLevel($e, 1) . ", $size);";
- } else {
- pidl "$name = talloc_zero($mem_ctx, " . DeclLevel($e, 1) . ");";
- }
-
- pidl "if ($name == NULL) {";
- pidl "\ttalloc_free($mem_ctx);";
- pidl "\treturn false;";
- pidl "}";
- pidl "";
-}
-
-sub ParseFunction($$)
-{
- my ($if,$fn) = @_;
-
- my $op = "NDR_".uc($fn->{NAME});
-
- pidl "static bool api_$fn->{NAME}(pipes_struct *p)";
- pidl "{";
- indent;
- pidl "const struct ndr_interface_call *call;";
- pidl "struct ndr_pull *pull;";
- pidl "struct ndr_push *push;";
- pidl "enum ndr_err_code ndr_err;";
- pidl "DATA_BLOB blob;";
- pidl "struct $fn->{NAME} *r;";
- pidl "";
- pidl "call = &ndr_table_$if->{NAME}.calls[$op];";
- pidl "";
- pidl "r = talloc(talloc_tos(), struct $fn->{NAME});";
- pidl "if (r == NULL) {";
- pidl "\treturn false;";
- pidl "}";
- pidl "";
- pidl "if (!prs_data_blob(&p->in_data.data, &blob, r)) {";
- pidl "\ttalloc_free(r);";
- pidl "\treturn false;";
- pidl "}";
- pidl "";
- pidl "pull = ndr_pull_init_blob(&blob, r);";
- pidl "if (pull == NULL) {";
- pidl "\ttalloc_free(r);";
- pidl "\treturn false;";
- pidl "}";
- pidl "";
- pidl "pull->flags |= LIBNDR_FLAG_REF_ALLOC;";
- pidl "ndr_err = call->ndr_pull(pull, NDR_IN, r);";
- pidl "if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {";
- pidl "\ttalloc_free(r);";
- pidl "\treturn false;";
- pidl "}";
- pidl "";
- pidl "if (DEBUGLEVEL >= 10) {";
- pidl "\tNDR_PRINT_IN_DEBUG($fn->{NAME}, r);";
- pidl "}";
- pidl "";
-
- my $env = GenerateFunctionOutEnv($fn);
- my $hasout = 0;
- foreach (@{$fn->{ELEMENTS}}) {
- if (grep(/out/, @{$_->{DIRECTION}})) { $hasout = 1; }
- }
-
- pidl "ZERO_STRUCT(r->out);" if ($hasout);
-
- my $proto = "_$fn->{NAME}(pipes_struct *p, struct $fn->{NAME} *r";
- my $ret = "_$fn->{NAME}(p, r";
- foreach (@{$fn->{ELEMENTS}}) {
- my @dir = @{$_->{DIRECTION}};
- if (grep(/in/, @dir) and grep(/out/, @dir)) {
- pidl "r->out.$_->{NAME} = r->in.$_->{NAME};";
- } elsif (grep(/out/, @dir) and not
- has_property($_, "represent_as")) {
- AllocOutVar($_, "r", "r->out.$_->{NAME}", $env);
- }
- }
- $ret .= ")";
- $proto .= ");";
-
- if ($fn->{RETURN_TYPE}) {
- $ret = "r->out.result = $ret";
- $proto = "$fn->{RETURN_TYPE} $proto";
- } else {
- $proto = "void $proto";
- }
-
- pidl_hdr "$proto";
- pidl "$ret;";
-
- pidl "";
- pidl "if (p->rng_fault_state) {";
- pidl "\ttalloc_free(r);";
- pidl "\t/* Return true here, srv_pipe_hnd.c will take care */";
- pidl "\treturn true;";
- pidl "}";
- pidl "";
- pidl "if (DEBUGLEVEL >= 10) {";
- pidl "\tNDR_PRINT_OUT_DEBUG($fn->{NAME}, r);";
- pidl "}";
- pidl "";
- pidl "push = ndr_push_init_ctx(r);";
- pidl "if (push == NULL) {";
- pidl "\ttalloc_free(r);";
- pidl "\treturn false;";
- pidl "}";
- pidl "";
- pidl "ndr_err = call->ndr_push(push, NDR_OUT, r);";
- pidl "if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {";
- pidl "\ttalloc_free(r);";
- pidl "\treturn false;";
- pidl "}";
- pidl "";
- pidl "blob = ndr_push_blob(push);";
- pidl "if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {";
- pidl "\ttalloc_free(r);";
- pidl "\treturn false;";
- pidl "}";
- pidl "";
- pidl "talloc_free(r);";
- pidl "";
- pidl "return true;";
- deindent;
- pidl "}";
- pidl "";
-}
-
-sub ParseInterface($)
-{
- my $if = shift;
-
- my $uif = uc($if->{NAME});
-
- pidl_hdr "#ifndef __SRV_$uif\__";
- pidl_hdr "#define __SRV_$uif\__";
- ParseFunction($if, $_) foreach (@{$if->{FUNCTIONS}});
-
- pidl "";
- pidl "/* Tables */";
- pidl "static struct api_struct api_$if->{NAME}_cmds[] = ";
- pidl "{";
- indent;
-
- foreach (@{$if->{FUNCTIONS}}) {
- pidl "{\"" . uc($_->{NAME}) . "\", NDR_" . uc($_->{NAME}) . ", api_$_->{NAME}},";
- }
-
- deindent;
- pidl "};";
-
- pidl "";
-
- pidl_hdr "void $if->{NAME}_get_pipe_fns(struct api_struct **fns, int *n_fns);";
- pidl "void $if->{NAME}_get_pipe_fns(struct api_struct **fns, int *n_fns)";
- pidl "{";
- indent;
- pidl "*fns = api_$if->{NAME}_cmds;";
- pidl "*n_fns = sizeof(api_$if->{NAME}_cmds) / sizeof(struct api_struct);";
- deindent;
- pidl "}";
- pidl "";
-
- pidl_hdr "NTSTATUS rpc_$if->{NAME}_init(void);";
- pidl "NTSTATUS rpc_$if->{NAME}_init(void)";
- pidl "{";
- pidl "\treturn rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, \"$if->{NAME}\", \"$if->{NAME}\", \&ndr_table_$if->{NAME}.syntax_id, api_$if->{NAME}_cmds, sizeof(api_$if->{NAME}_cmds) / sizeof(struct api_struct));";
- pidl "}";
-
- pidl_hdr "#endif /* __SRV_$uif\__ */";
-}
-
-sub Parse($$$)
-{
- my($ndr,$header,$ndr_header) = @_;
-
- $res = "";
- $res_hdr = "";
-
- pidl "/*";
- pidl " * Unix SMB/CIFS implementation.";
- pidl " * server auto-generated by pidl. DO NOT MODIFY!";
- pidl " */";
- pidl "";
- pidl "#include \"includes.h\"";
- pidl "#include \"$header\"";
- pidl_hdr "#include \"$ndr_header\"";
- pidl "";
-
- foreach (@$ndr) {
- ParseInterface($_) if ($_->{TYPE} eq "INTERFACE");
- }
-
- return ($res, $res_hdr);
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4.pm b/source4/pidl/lib/Parse/Pidl/Samba4.pm
deleted file mode 100644
index d42e01cdb0..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Samba4.pm
+++ /dev/null
@@ -1,119 +0,0 @@
-###################################################
-# Common Samba4 functions
-# Copyright jelmer@samba.org 2006
-# released under the GNU GPL
-
-package Parse::Pidl::Samba4;
-
-require Exporter;
-@ISA = qw(Exporter);
-@EXPORT = qw(is_intree choose_header NumStars ElementStars ArrayBrackets DeclLong);
-
-use Parse::Pidl::Util qw(has_property is_constant);
-use Parse::Pidl::NDR qw(GetNextLevel);
-use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
-use Parse::Pidl qw(fatal);
-use strict;
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-sub is_intree()
-{
- my $srcdir = $ENV{srcdir};
- $srcdir = $srcdir ? "$srcdir/" : "";
- return 4 if (-f "${srcdir}kdc/kdc.c");
- return 3 if (-f "${srcdir}include/smb.h");
- return 0;
-}
-
-# Return an #include line depending on whether this build is an in-tree
-# build or not.
-sub choose_header($$)
-{
- my ($in,$out) = @_;
- return "#include \"$in\"" if (is_intree());
- return "#include <$out>";
-}
-
-sub NumStars($;$)
-{
- my ($e, $d) = @_;
- $d = 0 unless defined($d);
- my $n = 0;
-
- foreach my $l (@{$e->{LEVELS}}) {
- next unless ($l->{TYPE} eq "POINTER");
-
- my $nl = GetNextLevel($e, $l);
- next if (defined($nl) and $nl->{TYPE} eq "ARRAY");
-
- $n++;
- }
-
- if ($n >= 1) {
- $n-- if (scalar_is_reference($e->{TYPE}));
- }
-
- foreach my $l (@{$e->{LEVELS}}) {
- next unless ($l->{TYPE} eq "ARRAY");
- next if ($l->{IS_FIXED}) and not has_property($e, "charset");
- $n++;
- }
-
- fatal($e->{ORIGINAL}, "Too few pointers $n < $d") if ($n < $d);
-
- $n -= $d;
-
- return $n;
-}
-
-sub ElementStars($;$)
-{
- my ($e, $d) = @_;
- my $res = "";
- my $n = 0;
-
- $n = NumStars($e, $d);
- $res .= "*" foreach (1..$n);
-
- return $res;
-}
-
-sub ArrayBrackets($)
-{
- my ($e) = @_;
- my $res = "";
-
- foreach my $l (@{$e->{LEVELS}}) {
- next unless ($l->{TYPE} eq "ARRAY");
- next unless ($l->{IS_FIXED}) and not has_property($e, "charset");
- $res .= "[$l->{SIZE_IS}]";
- }
-
- return $res;
-}
-
-sub DeclLong($)
-{
- my ($e) = shift;
- my $res = "";
-
- if (has_property($e, "represent_as")) {
- $res .= mapTypeName($e->{PROPERTIES}->{represent_as})." ";
- } else {
- if (has_property($e, "charset")) {
- $res .= "const char ";
- } else {
- $res .= mapTypeName($e->{TYPE})." ";
- }
-
- $res .= ElementStars($e);
- }
- $res .= $e->{NAME};
- $res .= ArrayBrackets($e);
-
- return $res;
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm
deleted file mode 100644
index 996689b4b6..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm
+++ /dev/null
@@ -1,155 +0,0 @@
-# COM Header generation
-# (C) 2005 Jelmer Vernooij <jelmer@samba.org>
-
-package Parse::Pidl::Samba4::COM::Header;
-
-use Parse::Pidl::Typelist qw(mapTypeName);
-use Parse::Pidl::Util qw(has_property is_constant);
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-use strict;
-
-sub GetArgumentProtoList($)
-{
- my $f = shift;
- my $res = "";
-
- foreach my $a (@{$f->{ELEMENTS}}) {
-
- $res .= ", " . mapTypeName($a->{TYPE}) . " ";
-
- my $l = $a->{POINTERS};
- $l-- if (Parse::Pidl::Typelist::scalar_is_reference($a->{TYPE}));
- foreach my $i (1..$l) {
- $res .= "*";
- }
-
- if (defined $a->{ARRAY_LEN}[0] && !is_constant($a->{ARRAY_LEN}[0]) &&
- !$a->{POINTERS}) {
- $res .= "*";
- }
- $res .= $a->{NAME};
- if (defined $a->{ARRAY_LEN}[0] && is_constant($a->{ARRAY_LEN}[0])) {
- $res .= "[$a->{ARRAY_LEN}[0]]";
- }
- }
-
- return $res;
-}
-
-sub GetArgumentList($)
-{
- my $f = shift;
- my $res = "";
-
- foreach (@{$f->{ELEMENTS}}) { $res .= ", $_->{NAME}"; }
-
- return $res;
-}
-
-#####################################################################
-# generate vtable structure for COM interface
-sub HeaderVTable($)
-{
- my $interface = shift;
- my $res;
- $res .= "#define " . uc($interface->{NAME}) . "_METHODS \\\n";
- if (defined($interface->{BASE})) {
- $res .= "\t" . uc($interface->{BASE} . "_METHODS") . "\\\n";
- }
-
- my $data = $interface->{DATA};
- foreach my $d (@{$data}) {
- $res .= "\t" . mapTypeName($d->{RETURN_TYPE}) . " (*$d->{NAME}) (struct $interface->{NAME} *d, TALLOC_CTX *mem_ctx" . GetArgumentProtoList($d) . ");\\\n" if ($d->{TYPE} eq "FUNCTION");
- }
- $res .= "\n";
- $res .= "struct $interface->{NAME}_vtable {\n";
- $res .= "\tstruct GUID iid;\n";
- $res .= "\t" . uc($interface->{NAME}) . "_METHODS\n";
- $res .= "};\n\n";
-
- return $res;
-}
-
-sub ParseInterface($)
-{
- my $if = shift;
- my $res;
-
- $res .= "\n#ifndef _$if->{NAME}_\n";
- $res .= "#define _$if->{NAME}_\n";
-
- $res .="\n\n/* $if->{NAME} */\n";
-
- $res .="#define COM_" . uc($if->{NAME}) . "_UUID $if->{PROPERTIES}->{uuid}\n\n";
-
- $res .="struct $if->{NAME}_vtable;\n\n";
-
- $res .="struct $if->{NAME} {
- struct OBJREF obj;
- struct com_context *ctx;
- struct $if->{NAME}_vtable *vtable;
- void *object_data;
-};\n\n";
-
- $res.=HeaderVTable($if);
-
- foreach my $d (@{$if->{DATA}}) {
- next if ($d->{TYPE} ne "FUNCTION");
-
- $res .= "#define $if->{NAME}_$d->{NAME}(interface, mem_ctx" . GetArgumentList($d) . ") ";
-
- $res .= "((interface)->vtable->$d->{NAME}(interface, mem_ctx" . GetArgumentList($d) . "))";
-
- $res .="\n";
- }
-
- $res .= "#endif\n";
-
- return $res;
-}
-
-sub ParseCoClass($)
-{
- my ($c) = @_;
- my $res = "";
- $res .= "#define CLSID_" . uc($c->{NAME}) . " $c->{PROPERTIES}->{uuid}\n";
- if (has_property($c, "progid")) {
- $res .= "#define PROGID_" . uc($c->{NAME}) . " $c->{PROPERTIES}->{progid}\n";
- }
- $res .= "\n";
- return $res;
-}
-
-sub Parse($$)
-{
- my ($idl,$ndr_header) = @_;
- my $res = "";
-
- $res .= "#include \"librpc/gen_ndr/orpc.h\"\n" .
- "#include \"$ndr_header\"\n\n";
-
- foreach (@{$idl})
- {
- if ($_->{TYPE} eq "INTERFACE" && has_property($_, "object")) {
- $res .="struct $_->{NAME};\n";
- }
- }
-
- foreach (@{$idl})
- {
- if ($_->{TYPE} eq "INTERFACE" && has_property($_, "object")) {
- $res.=ParseInterface($_);
- }
-
- if ($_->{TYPE} eq "COCLASS") {
- $res.=ParseCoClass($_);
- }
- }
-
- return $res;
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm b/source4/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm
deleted file mode 100644
index ca9f37a053..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm
+++ /dev/null
@@ -1,221 +0,0 @@
-###################################################
-# DCOM parser for Samba
-# Basically the glue between COM and DCE/RPC with NDR
-# Copyright jelmer@samba.org 2003-2005
-# released under the GNU GPL
-
-package Parse::Pidl::Samba4::COM::Proxy;
-
-use Parse::Pidl::Samba4::COM::Header;
-use Parse::Pidl::Typelist qw(mapTypeName);
-use Parse::Pidl::Util qw(has_property);
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-use strict;
-
-my($res);
-
-sub ParseVTable($$)
-{
- my ($interface, $name) = @_;
-
- # Generate the vtable
- $res .="\tstruct $interface->{NAME}_vtable $name = {";
-
- if (defined($interface->{BASE})) {
- $res .= "\n\t\t{},";
- }
-
- my $data = $interface->{DATA};
-
- foreach my $d (@{$data}) {
- if ($d->{TYPE} eq "FUNCTION") {
- $res .= "\n\t\tdcom_proxy_$interface->{NAME}_$d->{NAME}";
- $res .= ",";
- }
- }
-
- $res .= "\n\t};\n\n";
-}
-
-sub ParseRegFunc($)
-{
- my $interface = shift;
-
- $res .= "static NTSTATUS dcom_proxy_$interface->{NAME}_init(void)
-{
- struct $interface->{NAME}_vtable *proxy_vtable = talloc(talloc_autofree_context(), struct $interface->{NAME}_vtable);
-";
-
- if (defined($interface->{BASE})) {
- $res.= "
- struct GUID base_iid;
- const void *base_vtable;
-
- base_iid = ndr_table_$interface->{BASE}.syntax_id.uuid;
-
- base_vtable = dcom_proxy_vtable_by_iid(&base_iid);
- if (base_vtable == NULL) {
- DEBUG(0, (\"No proxy registered for base interface '$interface->{BASE}'\\n\"));
- return NT_STATUS_FOOBAR;
- }
-
- memcpy(&proxy_vtable, base_vtable, sizeof(struct $interface->{BASE}_vtable));
-
-";
- }
- foreach my $x (@{$interface->{DATA}}) {
- next unless ($x->{TYPE} eq "FUNCTION");
-
- $res .= "\tproxy_vtable->$x->{NAME} = dcom_proxy_$interface->{NAME}_$x->{NAME};\n";
- }
-
- $res.= "
- proxy_vtable->iid = ndr_table_$interface->{NAME}.syntax_id.uuid;
-
- return dcom_register_proxy((struct IUnknown_vtable *)proxy_vtable);
-}\n\n";
-}
-
-#####################################################################
-# parse a function
-sub ParseFunction($$)
-{
- my ($interface, $fn) = @_;
- my $name = $fn->{NAME};
- my $uname = uc $name;
-
- my $tn = mapTypeName($fn->{RETURN_TYPE});
-
- $res.="
-static $tn dcom_proxy_$interface->{NAME}_$name(struct $interface->{NAME} *d, TALLOC_CTX *mem_ctx" . Parse::Pidl::Samba4::COM::Header::GetArgumentProtoList($fn) . ")
-{
- struct dcerpc_pipe *p;
- NTSTATUS status = dcom_get_pipe(d, &p);
- struct $name r;
- struct rpc_request *req;
-
- if (NT_STATUS_IS_ERR(status)) {
- return status;
- }
-
- ZERO_STRUCT(r.in.ORPCthis);
- r.in.ORPCthis.version.MajorVersion = COM_MAJOR_VERSION;
- r.in.ORPCthis.version.MinorVersion = COM_MINOR_VERSION;
-";
-
- # Put arguments into r
- foreach my $a (@{$fn->{ELEMENTS}}) {
- next unless (has_property($a, "in"));
- if (Parse::Pidl::Typelist::typeIs($a->{TYPE}, "INTERFACE")) {
- $res .="\tNDR_CHECK(dcom_OBJREF_from_IUnknown(mem_ctx, &r.in.$a->{NAME}.obj, $a->{NAME}));\n";
- } else {
- $res .= "\tr.in.$a->{NAME} = $a->{NAME};\n";
- }
- }
-
- $res .="
- if (p->conn->flags & DCERPC_DEBUG_PRINT_IN) {
- NDR_PRINT_IN_DEBUG($name, &r);
- }
-
- status = dcerpc_ndr_request(p, &d->ipid, &ndr_table_$interface->{NAME}, NDR_$uname, mem_ctx, &r);
-
- if (NT_STATUS_IS_OK(status) && (p->conn->flags & DCERPC_DEBUG_PRINT_OUT)) {
- NDR_PRINT_OUT_DEBUG($name, r);
- }
-
-";
-
- # Put r info back into arguments
- foreach my $a (@{$fn->{ELEMENTS}}) {
- next unless (has_property($a, "out"));
-
- if (Parse::Pidl::Typelist::typeIs($a->{TYPE}, "INTERFACE")) {
- $res .="\tNDR_CHECK(dcom_IUnknown_from_OBJREF(d->ctx, &$a->{NAME}, r.out.$a->{NAME}.obj));\n";
- } else {
- $res .= "\t*$a->{NAME} = r.out.$a->{NAME};\n";
- }
-
- }
-
- if ($fn->{RETURN_TYPE} eq "NTSTATUS") {
- $res .= "\tif (NT_STATUS_IS_OK(status)) status = r.out.result;\n";
- }
-
- $res .=
- "
- return r.out.result;
-}\n\n";
-}
-
-#####################################################################
-# parse the interface definitions
-sub ParseInterface($)
-{
- my($interface) = shift;
- my($data) = $interface->{DATA};
- $res = "/* DCOM proxy for $interface->{NAME} generated by pidl */\n\n";
- foreach my $d (@{$data}) {
- ($d->{TYPE} eq "FUNCTION") &&
- ParseFunction($interface, $d);
- }
-
- ParseRegFunc($interface);
-}
-
-sub RegistrationFunction($$)
-{
- my $idl = shift;
- my $basename = shift;
-
- my $res = "\n\nNTSTATUS dcom_$basename\_init(void)\n";
- $res .= "{\n";
- $res .="\tNTSTATUS status = NT_STATUS_OK;\n";
- foreach my $interface (@{$idl}) {
- next if $interface->{TYPE} ne "INTERFACE";
- next if not has_property($interface, "object");
-
- my $data = $interface->{DATA};
- my $count = 0;
- foreach my $d (@{$data}) {
- if ($d->{TYPE} eq "FUNCTION") { $count++; }
- }
-
- next if ($count == 0);
-
- $res .= "\tstatus = dcom_$interface->{NAME}_init();\n";
- $res .= "\tif (NT_STATUS_IS_ERR(status)) {\n";
- $res .= "\t\treturn status;\n";
- $res .= "\t}\n\n";
- }
- $res .= "\treturn status;\n";
- $res .= "}\n\n";
-
- return $res;
-}
-
-sub Parse($$)
-{
- my ($pidl,$comh_filename) = @_;
- my $res = "";
-
- $res .= "#include \"includes.h\"\n" .
- "#include \"lib/com/dcom/dcom.h\"\n" .
- "#include \"$comh_filename\"\n" .
- "#include \"librpc/rpc/dcerpc.h\"\n";
-
- foreach (@{$pidl}) {
- next if ($_->{TYPE} ne "INTERFACE");
- next if has_property($_, "local");
- next unless has_property($_, "object");
-
- $res .= ParseInterface($_);
- }
-
- return $res;
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm b/source4/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm
deleted file mode 100644
index 150acbfde9..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm
+++ /dev/null
@@ -1,327 +0,0 @@
-###################################################
-# DCOM stub boilerplate generator
-# Copyright jelmer@samba.org 2004-2005
-# Copyright tridge@samba.org 2003
-# Copyright metze@samba.org 2004
-# released under the GNU GPL
-
-package Parse::Pidl::Samba4::COM::Stub;
-
-use Parse::Pidl::Util qw(has_property);
-use strict;
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-my($res);
-
-sub pidl($)
-{
- $res .= shift;
-}
-
-#####################################################
-# generate the switch statement for function dispatch
-sub gen_dispatch_switch($)
-{
- my $data = shift;
-
- my $count = 0;
- foreach my $d (@{$data}) {
- next if ($d->{TYPE} ne "FUNCTION");
-
- pidl "\tcase $count: {\n";
- if ($d->{RETURN_TYPE} && $d->{RETURN_TYPE} ne "void") {
- pidl "\t\tNTSTATUS result;\n";
- }
- pidl "\t\tstruct $d->{NAME} *r2 = r;\n";
- pidl "\t\tif (DEBUGLEVEL > 10) {\n";
- pidl "\t\t\tNDR_PRINT_FUNCTION_DEBUG($d->{NAME}, NDR_IN, r2);\n";
- pidl "\t\t}\n";
- if ($d->{RETURN_TYPE} && $d->{RETURN_TYPE} ne "void") {
- pidl "\t\tresult = vtable->$d->{NAME}(iface, mem_ctx, r2);\n";
- } else {
- pidl "\t\tvtable->$d->{NAME}(iface, mem_ctx, r2);\n";
- }
- pidl "\t\tif (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {\n";
- pidl "\t\t\tDEBUG(5,(\"function $d->{NAME} will reply async\\n\"));\n";
- pidl "\t\t}\n";
- pidl "\t\tbreak;\n\t}\n";
- $count++;
- }
-}
-
-#####################################################
-# generate the switch statement for function reply
-sub gen_reply_switch($)
-{
- my $data = shift;
-
- my $count = 0;
- foreach my $d (@{$data}) {
- next if ($d->{TYPE} ne "FUNCTION");
-
- pidl "\tcase $count: {\n";
- pidl "\t\tstruct $d->{NAME} *r2 = r;\n";
- pidl "\t\tif (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {\n";
- pidl "\t\t\tDEBUG(5,(\"function $d->{NAME} replied async\\n\"));\n";
- pidl "\t\t}\n";
- pidl "\t\tif (DEBUGLEVEL > 10 && dce_call->fault_code == 0) {\n";
- pidl "\t\t\tNDR_PRINT_FUNCTION_DEBUG($d->{NAME}, NDR_OUT | NDR_SET_VALUES, r2);\n";
- pidl "\t\t}\n";
- pidl "\t\tif (dce_call->fault_code != 0) {\n";
- pidl "\t\t\tDEBUG(2,(\"dcerpc_fault %s in $d->{NAME}\\n\", dcerpc_errstr(mem_ctx, dce_call->fault_code)));\n";
- pidl "\t\t}\n";
- pidl "\t\tbreak;\n\t}\n";
- $count++;
- }
-}
-
-#####################################################################
-# produce boilerplate code for a interface
-sub Boilerplate_Iface($)
-{
- my($interface) = shift;
- my($data) = $interface->{DATA};
- my $name = $interface->{NAME};
- my $uname = uc $name;
- my $uuid = Parse::Pidl::Util::make_str($interface->{PROPERTIES}->{uuid});
- my $if_version = $interface->{PROPERTIES}->{version};
-
- pidl "
-static NTSTATUS $name\__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface)
-{
-#ifdef DCESRV_INTERFACE_$uname\_BIND
- return DCESRV_INTERFACE_$uname\_BIND(dce_call,iface);
-#else
- return NT_STATUS_OK;
-#endif
-}
-
-static void $name\__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
-{
-#ifdef DCESRV_INTERFACE_$uname\_UNBIND
- DCESRV_INTERFACE_$uname\_UNBIND(context, iface);
-#else
- return;
-#endif
-}
-
-static NTSTATUS $name\__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
-{
- NTSTATUS status;
- uint16_t opnum = dce_call->pkt.u.request.opnum;
-
- dce_call->fault_code = 0;
-
- if (opnum >= dcerpc_table_$name.num_calls) {
- dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
- return NT_STATUS_NET_WRITE_FAULT;
- }
-
- *r = talloc_size(mem_ctx, dcerpc_table_$name.calls[opnum].struct_size);
- NT_STATUS_HAVE_NO_MEMORY(*r);
-
- /* unravel the NDR for the packet */
- status = dcerpc_table_$name.calls[opnum].ndr_pull(pull, NDR_IN, *r);
- if (!NT_STATUS_IS_OK(status)) {
- dcerpc_log_packet(&dcerpc_table_$name, opnum, NDR_IN,
- &dce_call->pkt.u.request.stub_and_verifier);
- dce_call->fault_code = DCERPC_FAULT_NDR;
- return NT_STATUS_NET_WRITE_FAULT;
- }
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS $name\__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
-{
- uint16_t opnum = dce_call->pkt.u.request.opnum;
- struct GUID ipid = dce_call->pkt.u.request.object.object;
- struct dcom_interface_p *iface = dcom_get_local_iface_p(&ipid);
- const struct dcom_$name\_vtable *vtable = iface->vtable;
-
- switch (opnum) {
-";
- gen_dispatch_switch($data);
-
-pidl "
- default:
- dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
- break;
- }
-
- if (dce_call->fault_code != 0) {
- dcerpc_log_packet(&dcerpc_table_$name, opnum, NDR_IN,
- &dce_call->pkt.u.request.stub_and_verifier);
- return NT_STATUS_NET_WRITE_FAULT;
- }
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS $name\__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
-{
- uint16_t opnum = dce_call->pkt.u.request.opnum;
-
- switch (opnum) {
-";
- gen_reply_switch($data);
-
-pidl "
- default:
- dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
- break;
- }
-
- if (dce_call->fault_code != 0) {
- dcerpc_log_packet(&dcerpc_table_$name, opnum, NDR_IN,
- &dce_call->pkt.u.request.stub_and_verifier);
- return NT_STATUS_NET_WRITE_FAULT;
- }
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS $name\__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
-{
- NTSTATUS status;
- uint16_t opnum = dce_call->pkt.u.request.opnum;
-
- status = dcerpc_table_$name.calls[opnum].ndr_push(push, NDR_OUT, r);
- if (!NT_STATUS_IS_OK(status)) {
- dce_call->fault_code = DCERPC_FAULT_NDR;
- return NT_STATUS_NET_WRITE_FAULT;
- }
-
- return NT_STATUS_OK;
-}
-
-static const struct dcesrv_interface $name\_interface = {
- .name = \"$name\",
- .uuid = $uuid,
- .if_version = $if_version,
- .bind = $name\__op_bind,
- .unbind = $name\__op_unbind,
- .ndr_pull = $name\__op_ndr_pull,
- .dispatch = $name\__op_dispatch,
- .reply = $name\__op_reply,
- .ndr_push = $name\__op_ndr_push
-};
-
-";
-}
-
-#####################################################################
-# produce boilerplate code for an endpoint server
-sub Boilerplate_Ep_Server($)
-{
- my($interface) = shift;
- my $name = $interface->{NAME};
- my $uname = uc $name;
-
- pidl "
-static NTSTATUS $name\__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
-{
- int i;
-
- for (i=0;i<dcerpc_table_$name.endpoints->count;i++) {
- NTSTATUS ret;
- const char *name = dcerpc_table_$name.endpoints->names[i];
-
- ret = dcesrv_interface_register(dce_ctx, name, &$name\_interface, NULL);
- if (!NT_STATUS_IS_OK(ret)) {
- DEBUG(1,(\"$name\_op_init_server: failed to register endpoint \'%s\'\\n\",name));
- return ret;
- }
- }
-
- return NT_STATUS_OK;
-}
-
-static BOOL $name\__op_interface_by_uuid(struct dcesrv_interface *iface, const char *uuid, uint32_t if_version)
-{
- if (dcerpc_table_$name.if_version == if_version &&
- strcmp(dcerpc_table_$name.uuid, uuid)==0) {
- memcpy(iface,&dcerpc_table_$name, sizeof(*iface));
- return True;
- }
-
- return False;
-}
-
-static BOOL $name\__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
-{
- if (strcmp(dcerpc_table_$name.name, name)==0) {
- memcpy(iface,&dcerpc_table_$name, sizeof(*iface));
- return True;
- }
-
- return False;
-}
-
-NTSTATUS dcerpc_server_$name\_init(void)
-{
- NTSTATUS ret;
- struct dcesrv_endpoint_server ep_server;
-
- /* fill in our name */
- ep_server.name = \"$name\";
-
- /* fill in all the operations */
- ep_server.init_server = $name\__op_init_server;
-
- ep_server.interface_by_uuid = $name\__op_interface_by_uuid;
- ep_server.interface_by_name = $name\__op_interface_by_name;
-
- /* register ourselves with the DCERPC subsystem. */
- ret = dcerpc_register_ep_server(&ep_server);
-
- if (!NT_STATUS_IS_OK(ret)) {
- DEBUG(0,(\"Failed to register \'$name\' endpoint server!\\n\"));
- return ret;
- }
-
- return ret;
-}
-
-";
-}
-
-#####################################################################
-# dcom interface stub from a parsed IDL structure
-sub ParseInterface($)
-{
- my($interface) = shift;
-
- return "" if has_property($interface, "local");
-
- my($data) = $interface->{DATA};
- my $count = 0;
-
- $res = "";
-
- if (!defined $interface->{PROPERTIES}->{uuid}) {
- return $res;
- }
-
- if (!defined $interface->{PROPERTIES}->{version}) {
- $interface->{PROPERTIES}->{version} = "0.0";
- }
-
- foreach my $d (@{$data}) {
- if ($d->{TYPE} eq "FUNCTION") { $count++; }
- }
-
- if ($count == 0) {
- return $res;
- }
-
- $res = "/* dcom interface stub generated by pidl */\n\n";
- Boilerplate_Iface($interface);
- Boilerplate_Ep_Server($interface);
-
- return $res;
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm
deleted file mode 100644
index 611f0adb92..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm
+++ /dev/null
@@ -1,475 +0,0 @@
-###################################################
-# create C header files for an IDL structure
-# Copyright tridge@samba.org 2000
-# Copyright jelmer@samba.org 2005
-# released under the GNU GPL
-
-package Parse::Pidl::Samba4::Header;
-
-require Exporter;
-
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv);
-
-use strict;
-use Parse::Pidl qw(fatal);
-use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
-use Parse::Pidl::Util qw(has_property is_constant unmake_str ParseExpr);
-use Parse::Pidl::Samba4 qw(is_intree ElementStars ArrayBrackets choose_header);
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-my($res);
-my($tab_depth);
-
-sub pidl($) { $res .= shift; }
-
-sub tabs()
-{
- my $res = "";
- $res .="\t" foreach (1..$tab_depth);
- return $res;
-}
-
-#####################################################################
-# parse a properties list
-sub HeaderProperties($$)
-{
- my($props,$ignores) = @_;
- my $ret = "";
-
- foreach my $d (keys %{$props}) {
- next if (grep(/^$d$/, @$ignores));
- if($props->{$d} ne "1") {
- $ret.= "$d($props->{$d}),";
- } else {
- $ret.="$d,";
- }
- }
-
- if ($ret) {
- pidl "/* [" . substr($ret, 0, -1) . "] */";
- }
-}
-
-#####################################################################
-# parse a structure element
-sub HeaderElement($)
-{
- my($element) = shift;
-
- pidl tabs();
- if (has_property($element, "represent_as")) {
- pidl mapTypeName($element->{PROPERTIES}->{represent_as})." ";
- } else {
- if (ref($element->{TYPE}) eq "HASH") {
- HeaderType($element, $element->{TYPE}, $element->{TYPE}->{NAME});
- } else {
- HeaderType($element, $element->{TYPE}, "");
- }
- pidl " ".ElementStars($element);
- }
- pidl $element->{NAME};
- pidl ArrayBrackets($element);
-
- pidl ";";
- if (defined $element->{PROPERTIES}) {
- HeaderProperties($element->{PROPERTIES}, ["in", "out"]);
- }
- pidl "\n";
-}
-
-#####################################################################
-# parse a struct
-sub HeaderStruct($$;$)
-{
- my($struct,$name,$tail) = @_;
- pidl "struct $name";
- pidl $tail if defined($tail) and not defined($struct->{ELEMENTS});
- return if (not defined($struct->{ELEMENTS}));
- pidl " {\n";
- $tab_depth++;
- my $el_count=0;
- foreach (@{$struct->{ELEMENTS}}) {
- HeaderElement($_);
- $el_count++;
- }
- if ($el_count == 0) {
- # some compilers can't handle empty structures
- pidl tabs()."char _empty_;\n";
- }
- $tab_depth--;
- pidl tabs()."}";
- if (defined $struct->{PROPERTIES}) {
- HeaderProperties($struct->{PROPERTIES}, []);
- }
- pidl $tail if defined($tail);
-}
-
-#####################################################################
-# parse a enum
-sub HeaderEnum($$;$)
-{
- my($enum,$name,$tail) = @_;
- my $first = 1;
-
- pidl "enum $name";
- if (defined($enum->{ELEMENTS})) {
- pidl "\n#ifndef USE_UINT_ENUMS\n";
- pidl " {\n";
- $tab_depth++;
- foreach my $e (@{$enum->{ELEMENTS}}) {
- unless ($first) { pidl ",\n"; }
- $first = 0;
- pidl tabs();
- pidl $e;
- }
- pidl "\n";
- $tab_depth--;
- pidl "}";
- pidl "\n";
- pidl "#else\n";
- my $count = 0;
- my $with_val = 0;
- my $without_val = 0;
- pidl " { __donnot_use_enum_$name=0x7FFFFFFF}\n";
- foreach my $e (@{$enum->{ELEMENTS}}) {
- my $t = "$e";
- my $name;
- my $value;
- if ($t =~ /(.*)=(.*)/) {
- $name = $1;
- $value = $2;
- $with_val = 1;
- fatal($e->{ORIGINAL}, "you can't mix enum member with values and without values!")
- unless ($without_val == 0);
- } else {
- $name = $t;
- $value = $count++;
- $without_val = 1;
- fatal($e->{ORIGINAL}, "you can't mix enum member with values and without values!")
- unless ($with_val == 0);
- }
- pidl "#define $name ( $value )\n";
- }
- pidl "#endif\n";
- }
- pidl $tail if defined($tail);
-}
-
-#####################################################################
-# parse a bitmap
-sub HeaderBitmap($$)
-{
- my($bitmap,$name) = @_;
-
- return unless defined($bitmap->{ELEMENTS});
-
- pidl "/* bitmap $name */\n";
- pidl "#define $_\n" foreach (@{$bitmap->{ELEMENTS}});
- pidl "\n";
-}
-
-#####################################################################
-# parse a union
-sub HeaderUnion($$;$)
-{
- my($union,$name,$tail) = @_;
- my %done = ();
-
- pidl "union $name";
- pidl $tail if defined($tail) and not defined($union->{ELEMENTS});
- return if (not defined($union->{ELEMENTS}));
- pidl " {\n";
- $tab_depth++;
- foreach my $e (@{$union->{ELEMENTS}}) {
- if ($e->{TYPE} ne "EMPTY") {
- if (! defined $done{$e->{NAME}}) {
- HeaderElement($e);
- }
- $done{$e->{NAME}} = 1;
- }
- }
- $tab_depth--;
- pidl "}";
-
- if (defined $union->{PROPERTIES}) {
- HeaderProperties($union->{PROPERTIES}, []);
- }
- pidl $tail if defined($tail);
-}
-
-#####################################################################
-# parse a type
-sub HeaderType($$$;$)
-{
- my($e,$data,$name,$tail) = @_;
- if (ref($data) eq "HASH") {
- ($data->{TYPE} eq "ENUM") && HeaderEnum($data, $name, $tail);
- ($data->{TYPE} eq "BITMAP") && HeaderBitmap($data, $name);
- ($data->{TYPE} eq "STRUCT") && HeaderStruct($data, $name, $tail);
- ($data->{TYPE} eq "UNION") && HeaderUnion($data, $name, $tail);
- return;
- }
-
- if (has_property($e, "charset")) {
- pidl "const char";
- } else {
- pidl mapTypeName($e->{TYPE});
- }
- pidl $tail if defined($tail);
-}
-
-#####################################################################
-# parse a typedef
-sub HeaderTypedef($;$)
-{
- my($typedef,$tail) = @_;
- HeaderType($typedef, $typedef->{DATA}, $typedef->{NAME}, $tail) if defined ($typedef->{DATA});
-}
-
-#####################################################################
-# parse a const
-sub HeaderConst($)
-{
- my($const) = shift;
- if (!defined($const->{ARRAY_LEN}[0])) {
- pidl "#define $const->{NAME}\t( $const->{VALUE} )\n";
- } else {
- pidl "#define $const->{NAME}\t $const->{VALUE}\n";
- }
-}
-
-sub ElementDirection($)
-{
- my ($e) = @_;
-
- return "inout" if (has_property($e, "in") and has_property($e, "out"));
- return "in" if (has_property($e, "in"));
- return "out" if (has_property($e, "out"));
- return "inout";
-}
-
-#####################################################################
-# parse a function
-sub HeaderFunctionInOut($$)
-{
- my($fn,$prop) = @_;
-
- return unless defined($fn->{ELEMENTS});
-
- foreach my $e (@{$fn->{ELEMENTS}}) {
- HeaderElement($e) if (ElementDirection($e) eq $prop);
- }
-}
-
-#####################################################################
-# determine if we need an "in" or "out" section
-sub HeaderFunctionInOut_needed($$)
-{
- my($fn,$prop) = @_;
-
- return 1 if ($prop eq "out" && defined($fn->{RETURN_TYPE}));
-
- return undef unless defined($fn->{ELEMENTS});
-
- foreach my $e (@{$fn->{ELEMENTS}}) {
- return 1 if (ElementDirection($e) eq $prop);
- }
-
- return undef;
-}
-
-my %headerstructs;
-
-#####################################################################
-# parse a function
-sub HeaderFunction($)
-{
- my($fn) = shift;
-
- return if ($headerstructs{$fn->{NAME}});
-
- $headerstructs{$fn->{NAME}} = 1;
-
- pidl "\nstruct $fn->{NAME} {\n";
- $tab_depth++;
- my $needed = 0;
-
- if (HeaderFunctionInOut_needed($fn, "in") or
- HeaderFunctionInOut_needed($fn, "inout")) {
- pidl tabs()."struct {\n";
- $tab_depth++;
- HeaderFunctionInOut($fn, "in");
- HeaderFunctionInOut($fn, "inout");
- $tab_depth--;
- pidl tabs()."} in;\n\n";
- $needed++;
- }
-
- if (HeaderFunctionInOut_needed($fn, "out") or
- HeaderFunctionInOut_needed($fn, "inout")) {
- pidl tabs()."struct {\n";
- $tab_depth++;
- HeaderFunctionInOut($fn, "out");
- HeaderFunctionInOut($fn, "inout");
- if (defined($fn->{RETURN_TYPE})) {
- pidl tabs().mapTypeName($fn->{RETURN_TYPE}) . " result;\n";
- }
- $tab_depth--;
- pidl tabs()."} out;\n\n";
- $needed++;
- }
-
- if (!$needed) {
- # sigh - some compilers don't like empty structures
- pidl tabs()."int _dummy_element;\n";
- }
-
- $tab_depth--;
- pidl "};\n\n";
-}
-
-sub HeaderImport
-{
- my @imports = @_;
- foreach my $import (@imports) {
- $import = unmake_str($import);
- $import =~ s/\.idl$//;
- pidl choose_header("librpc/gen_ndr/$import\.h", "gen_ndr/$import.h") . "\n";
- }
-}
-
-sub HeaderInclude
-{
- my @includes = @_;
- foreach (@includes) {
- pidl "#include $_\n";
- }
-}
-
-#####################################################################
-# parse the interface definitions
-sub HeaderInterface($)
-{
- my($interface) = shift;
-
- pidl "#ifndef _HEADER_$interface->{NAME}\n";
- pidl "#define _HEADER_$interface->{NAME}\n\n";
-
- foreach my $c (@{$interface->{CONSTS}}) {
- HeaderConst($c);
- }
-
- foreach my $t (@{$interface->{TYPES}}) {
- HeaderTypedef($t, ";\n\n") if ($t->{TYPE} eq "TYPEDEF");
- HeaderStruct($t, $t->{NAME}, ";\n\n") if ($t->{TYPE} eq "STRUCT");
- HeaderUnion($t, $t->{NAME}, ";\n\n") if ($t->{TYPE} eq "UNION");
- HeaderEnum($t, $t->{NAME}, ";\n\n") if ($t->{TYPE} eq "ENUM");
- HeaderBitmap($t, $t->{NAME}) if ($t->{TYPE} eq "BITMAP");
- }
-
- foreach my $fn (@{$interface->{FUNCTIONS}}) {
- HeaderFunction($fn);
- }
-
- pidl "#endif /* _HEADER_$interface->{NAME} */\n";
-}
-
-sub HeaderQuote($)
-{
- my($quote) = shift;
-
- pidl unmake_str($quote->{DATA}) . "\n";
-}
-
-#####################################################################
-# parse a parsed IDL into a C header
-sub Parse($)
-{
- my($ndr) = shift;
- $tab_depth = 0;
-
- $res = "";
- %headerstructs = ();
- pidl "/* header auto-generated by pidl */\n\n";
- if (!is_intree()) {
- pidl "#include <util/data_blob.h>\n";
- }
- pidl "#include <stdint.h>\n";
- pidl "\n";
-
- foreach (@{$ndr}) {
- ($_->{TYPE} eq "CPP_QUOTE") && HeaderQuote($_);
- ($_->{TYPE} eq "INTERFACE") && HeaderInterface($_);
- ($_->{TYPE} eq "IMPORT") && HeaderImport(@{$_->{PATHS}});
- ($_->{TYPE} eq "INCLUDE") && HeaderInclude(@{$_->{PATHS}});
- }
-
- return $res;
-}
-
-sub GenerateStructEnv($$)
-{
- my ($x, $v) = @_;
- my %env;
-
- foreach my $e (@{$x->{ELEMENTS}}) {
- $env{$e->{NAME}} = "$v->$e->{NAME}";
- }
-
- $env{"this"} = $v;
-
- return \%env;
-}
-
-sub EnvSubstituteValue($$)
-{
- my ($env,$s) = @_;
-
- # Substitute the value() values in the env
- foreach my $e (@{$s->{ELEMENTS}}) {
- next unless (defined(my $v = has_property($e, "value")));
-
- $env->{$e->{NAME}} = ParseExpr($v, $env, $e);
- }
-
- return $env;
-}
-
-sub GenerateFunctionInEnv($;$)
-{
- my ($fn, $base) = @_;
- my %env;
-
- $base = "r->" unless defined($base);
-
- foreach my $e (@{$fn->{ELEMENTS}}) {
- if (grep (/in/, @{$e->{DIRECTION}})) {
- $env{$e->{NAME}} = $base."in.$e->{NAME}";
- }
- }
-
- return \%env;
-}
-
-sub GenerateFunctionOutEnv($;$)
-{
- my ($fn, $base) = @_;
- my %env;
-
- $base = "r->" unless defined($base);
-
- foreach my $e (@{$fn->{ELEMENTS}}) {
- if (grep (/out/, @{$e->{DIRECTION}})) {
- $env{$e->{NAME}} = $base."out.$e->{NAME}";
- } elsif (grep (/in/, @{$e->{DIRECTION}})) {
- $env{$e->{NAME}} = $base."in.$e->{NAME}";
- }
- }
-
- return \%env;
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
deleted file mode 100644
index f8209be654..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
+++ /dev/null
@@ -1,156 +0,0 @@
-###################################################
-# client calls generator
-# Copyright tridge@samba.org 2003
-# Copyright jelmer@samba.org 2005-2006
-# released under the GNU GPL
-
-package Parse::Pidl::Samba4::NDR::Client;
-
-use Parse::Pidl::Samba4 qw(choose_header is_intree);
-use Parse::Pidl::Util qw(has_property);
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-use strict;
-
-my($res,$res_hdr);
-
-sub ParseFunctionSend($$$)
-{
- my ($interface, $fn, $name) = @_;
- my $uname = uc $name;
-
- my $proto = "struct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)";
-
- $res_hdr .= "\n$proto;\n";
-
- $res .= "$proto\n{\n";
-
- if (has_property($fn, "todo")) {
- $res .= "\treturn NULL;\n";
- } else {
- $res .= "
- if (p->conn->flags & DCERPC_DEBUG_PRINT_IN) {
- NDR_PRINT_IN_DEBUG($name, r);
- }
-
- return dcerpc_ndr_request_send(p, NULL, &ndr_table_$interface->{NAME}, NDR_$uname, mem_ctx, r);
-";
- }
-
- $res .= "}\n\n";
-}
-
-sub ParseFunctionSync($$$)
-{
- my ($interface, $fn, $name) = @_;
-
- my $proto = "NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)";
-
- $res_hdr .= "\n$proto;\n";
- $res .= "$proto\n{\n";
-
- if (has_property($fn, "todo")) {
- $res .= "\treturn NT_STATUS_NOT_IMPLEMENTED;\n";
- } else {
- $res .= "
- struct rpc_request *req;
- NTSTATUS status;
-
- req = dcerpc_$name\_send(p, mem_ctx, r);
- if (req == NULL) return NT_STATUS_NO_MEMORY;
-
- status = dcerpc_ndr_request_recv(req);
-
- if (NT_STATUS_IS_OK(status) && (p->conn->flags & DCERPC_DEBUG_PRINT_OUT)) {
- NDR_PRINT_OUT_DEBUG($name, r);
- }
-";
-
- if (defined($fn->{RETURN_TYPE}) and $fn->{RETURN_TYPE} eq "NTSTATUS") {
- $res .= "\tif (NT_STATUS_IS_OK(status)) status = r->out.result;\n";
- }
- $res .=
-"
- return status;
-";
- }
-
- $res .= "}\n\n";
-}
-
-#####################################################################
-# parse a function
-sub ParseFunction($$)
-{
- my ($interface, $fn) = @_;
-
- ParseFunctionSend($interface, $fn, $fn->{NAME});
- ParseFunctionSync($interface, $fn, $fn->{NAME});
-}
-
-my %done;
-
-#####################################################################
-# parse the interface definitions
-sub ParseInterface($)
-{
- my($interface) = shift;
-
- $res_hdr .= "#ifndef _HEADER_RPC_$interface->{NAME}\n";
- $res_hdr .= "#define _HEADER_RPC_$interface->{NAME}\n\n";
-
- if (defined $interface->{PROPERTIES}->{uuid}) {
- $res_hdr .= "extern const struct ndr_interface_table ndr_table_$interface->{NAME};\n";
- }
-
- $res .= "/* $interface->{NAME} - client functions generated by pidl */\n\n";
-
- foreach my $fn (@{$interface->{FUNCTIONS}}) {
- next if not defined($fn->{OPNUM});
- next if defined($done{$fn->{NAME}});
- ParseFunction($interface, $fn);
- $done{$fn->{NAME}} = 1;
- }
-
- $res_hdr .= "#endif /* _HEADER_RPC_$interface->{NAME} */\n";
-
- return $res;
-}
-
-sub Parse($$$$)
-{
- my($ndr,$header,$ndr_header,$client_header) = @_;
-
- $res = "";
- $res_hdr = "";
-
- $res .= "/* client functions auto-generated by pidl */\n";
- $res .= "\n";
- if (is_intree()) {
- $res .= "#include \"includes.h\"\n";
- } else {
- $res .= "#define _GNU_SOURCE\n";
- $res .= "#include <stdio.h>\n";
- $res .= "#include <stdbool.h>\n";
- $res .= "#include <stdlib.h>\n";
- $res .= "#include <stdint.h>\n";
- $res .= "#include <stdarg.h>\n";
- $res .= "#include <core/ntstatus.h>\n";
- }
- $res .= "#include \"$ndr_header\"\n";
- $res .= "#include \"$client_header\"\n";
- $res .= "\n";
-
- $res_hdr .= choose_header("librpc/rpc/dcerpc.h", "dcerpc.h")."\n";
- $res_hdr .= "#include \"$header\"\n";
-
- foreach my $x (@{$ndr}) {
- ($x->{TYPE} eq "INTERFACE") && ParseInterface($x);
- }
-
- return ($res,$res_hdr);
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
deleted file mode 100644
index 0a6360f8ac..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ /dev/null
@@ -1,2695 +0,0 @@
-###################################################
-# Samba4 NDR parser generator for IDL structures
-# Copyright tridge@samba.org 2000-2003
-# Copyright tpot@samba.org 2001
-# Copyright jelmer@samba.org 2004-2006
-# released under the GNU GPL
-
-package Parse::Pidl::Samba4::NDR::Parser;
-
-require Exporter;
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(check_null_pointer NeededFunction NeededElement NeededType $res NeededInterface TypeFunctionName ParseElementPrint);
-
-use strict;
-use Parse::Pidl::Typelist qw(hasType getType mapTypeName typeHasBody);
-use Parse::Pidl::Util qw(has_property ParseExpr ParseExprExt print_uuid unmake_str);
-use Parse::Pidl::CUtil qw(get_pointer_to get_value_of get_array_element);
-use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array);
-use Parse::Pidl::Samba4 qw(is_intree choose_header);
-use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv);
-use Parse::Pidl qw(warning);
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-# list of known types
-my %typefamily;
-
-sub new($$) {
- my ($class) = @_;
- my $self = { res => "", res_hdr => "", deferred => [], tabs => "", defer_tabs => "" };
- bless($self, $class);
-}
-
-sub get_typefamily($)
-{
- my $n = shift;
- return $typefamily{$n};
-}
-
-sub append_prefix($$)
-{
- my ($e, $var_name) = @_;
- my $pointers = 0;
- my $arrays = 0;
-
- foreach my $l (@{$e->{LEVELS}}) {
- if ($l->{TYPE} eq "POINTER") {
- $pointers++;
- } elsif ($l->{TYPE} eq "ARRAY") {
- $arrays++;
- if (($pointers == 0) and
- (not $l->{IS_FIXED}) and
- (not $l->{IS_INLINE})) {
- return get_value_of($var_name);
- }
- } elsif ($l->{TYPE} eq "DATA") {
- if (Parse::Pidl::Typelist::scalar_is_reference($l->{DATA_TYPE})) {
- return get_value_of($var_name) unless ($pointers or $arrays);
- }
- }
- }
-
- return $var_name;
-}
-
-sub has_fast_array($$)
-{
- my ($e,$l) = @_;
-
- return 0 if ($l->{TYPE} ne "ARRAY");
-
- my $nl = GetNextLevel($e,$l);
- return 0 unless ($nl->{TYPE} eq "DATA");
- return 0 unless (hasType($nl->{DATA_TYPE}));
-
- my $t = getType($nl->{DATA_TYPE});
-
- # Only uint8 and string have fast array functions at the moment
- return ($t->{NAME} eq "uint8") or ($t->{NAME} eq "string");
-}
-
-
-####################################
-# pidl() is our basic output routine
-sub pidl($$)
-{
- my ($self, $d) = @_;
- if ($d) {
- $self->{res} .= $self->{tabs};
- $self->{res} .= $d;
- }
- $self->{res} .="\n";
-}
-
-sub pidl_hdr($$) { my ($self, $d) = @_; $self->{res_hdr} .= "$d\n"; }
-
-####################################
-# defer() is like pidl(), but adds to
-# a deferred buffer which is then added to the
-# output buffer at the end of the structure/union/function
-# This is needed to cope with code that must be pushed back
-# to the end of a block of elements
-sub defer_indent($) { my ($self) = @_; $self->{defer_tabs}.="\t"; }
-sub defer_deindent($) { my ($self) = @_; $self->{defer_tabs}=substr($self->{defer_tabs}, 0, -1); }
-
-sub defer($$)
-{
- my ($self, $d) = @_;
- if ($d) {
- push(@{$self->{deferred}}, $self->{defer_tabs}.$d);
- }
-}
-
-########################################
-# add the deferred content to the current
-# output
-sub add_deferred($)
-{
- my ($self) = @_;
- $self->pidl($_) foreach (@{$self->{deferred}});
- $self->{deferred} = [];
- $self->{defer_tabs} = "";
-}
-
-sub indent($)
-{
- my ($self) = @_;
- $self->{tabs} .= "\t";
-}
-
-sub deindent($)
-{
- my ($self) = @_;
- $self->{tabs} = substr($self->{tabs}, 0, -1);
-}
-
-#####################################################################
-# declare a function public or static, depending on its attributes
-sub fn_declare($$$$)
-{
- my ($self,$type,$fn,$decl) = @_;
-
- if (has_property($fn, "no$type")) {
- $self->pidl_hdr("$decl;");
- return 0;
- }
-
- if (has_property($fn, "public")) {
- $self->pidl_hdr("$decl;");
- $self->pidl("_PUBLIC_ $decl");
- } else {
- $self->pidl("static $decl");
- }
-
- return 1;
-}
-
-###################################################################
-# setup any special flags for an element or structure
-sub start_flags($$$)
-{
- my ($self, $e, $ndr) = @_;
- my $flags = has_property($e, "flag");
- if (defined $flags) {
- $self->pidl("{");
- $self->indent;
- $self->pidl("uint32_t _flags_save_$e->{TYPE} = $ndr->flags;");
- $self->pidl("ndr_set_flags(&$ndr->flags, $flags);");
- }
-}
-
-###################################################################
-# end any special flags for an element or structure
-sub end_flags($$$)
-{
- my ($self, $e, $ndr) = @_;
- my $flags = has_property($e, "flag");
- if (defined $flags) {
- $self->pidl("$ndr->flags = _flags_save_$e->{TYPE};");
- $self->deindent;
- $self->pidl("}");
- }
-}
-
-#####################################################################
-# parse the data of an array - push side
-sub ParseArrayPushHeader($$$$$$)
-{
- my ($self,$e,$l,$ndr,$var_name,$env) = @_;
-
- my $size;
- my $length;
-
- if ($l->{IS_ZERO_TERMINATED}) {
- if (has_property($e, "charset")) {
- $size = $length = "ndr_charset_length($var_name, CH_$e->{PROPERTIES}->{charset})";
- } else {
- $size = $length = "ndr_string_length($var_name, sizeof(*$var_name))";
- }
- } else {
- $size = ParseExpr($l->{SIZE_IS}, $env, $e);
- $length = ParseExpr($l->{LENGTH_IS}, $env, $e);
- }
-
- if ((!$l->{IS_SURROUNDING}) and $l->{IS_CONFORMANT}) {
- $self->pidl("NDR_CHECK(ndr_push_uint32($ndr, NDR_SCALARS, $size));");
- }
-
- if ($l->{IS_VARYING}) {
- $self->pidl("NDR_CHECK(ndr_push_uint32($ndr, NDR_SCALARS, 0));"); # array offset
- $self->pidl("NDR_CHECK(ndr_push_uint32($ndr, NDR_SCALARS, $length));");
- }
-
- return $length;
-}
-
-sub check_fully_dereferenced($$)
-{
- my ($element, $env) = @_;
-
- return sub ($) {
- my $origvar = shift;
- my $check = 0;
-
- # Figure out the number of pointers in $ptr
- my $expandedvar = $origvar;
- $expandedvar =~ s/^(\**)//;
- my $ptr = $1;
-
- my $var = undef;
- foreach (keys %$env) {
- if ($env->{$_} eq $expandedvar) {
- $var = $_;
- last;
- }
- }
-
- return($origvar) unless (defined($var));
- my $e;
- foreach (@{$element->{PARENT}->{ELEMENTS}}) {
- if ($_->{NAME} eq $var) {
- $e = $_;
- last;
- }
- }
-
- $e or die("Environment doesn't match siblings");
-
- # See if pointer at pointer level $level
- # needs to be checked.
- my $nump = 0;
- foreach (@{$e->{LEVELS}}) {
- if ($_->{TYPE} eq "POINTER") {
- $nump = $_->{POINTER_INDEX}+1;
- }
- }
- warning($element->{ORIGINAL}, "Got pointer for `$e->{NAME}', expected fully derefenced variable") if ($nump > length($ptr));
- return ($origvar);
- }
-}
-
-sub check_null_pointer($$$$)
-{
- my ($element, $env, $print_fn, $return) = @_;
-
- return sub ($) {
- my $expandedvar = shift;
- my $check = 0;
-
- # Figure out the number of pointers in $ptr
- $expandedvar =~ s/^(\**)//;
- my $ptr = $1;
-
- my $var = undef;
- foreach (keys %$env) {
- if ($env->{$_} eq $expandedvar) {
- $var = $_;
- last;
- }
- }
-
- if (defined($var)) {
- my $e;
- # lookup ptr in $e
- foreach (@{$element->{PARENT}->{ELEMENTS}}) {
- if ($_->{NAME} eq $var) {
- $e = $_;
- last;
- }
- }
-
- $e or die("Environment doesn't match siblings");
-
- # See if pointer at pointer level $level
- # needs to be checked.
- foreach my $l (@{$e->{LEVELS}}) {
- if ($l->{TYPE} eq "POINTER" and
- $l->{POINTER_INDEX} == length($ptr)) {
- # No need to check ref pointers
- $check = ($l->{POINTER_TYPE} ne "ref");
- last;
- }
-
- if ($l->{TYPE} eq "DATA") {
- warning($element, "too much dereferences for `$var'");
- }
- }
- } else {
- warning($element, "unknown dereferenced expression `$expandedvar'");
- $check = 1;
- }
-
- $print_fn->("if ($ptr$expandedvar == NULL) $return") if $check;
- }
-}
-
-#####################################################################
-# parse an array - pull side
-sub ParseArrayPullHeader($$$$$$)
-{
- my ($self,$e,$l,$ndr,$var_name,$env) = @_;
-
- my $length;
- my $size;
-
- if ($l->{IS_CONFORMANT}) {
- $length = $size = "ndr_get_array_size($ndr, " . get_pointer_to($var_name) . ")";
- } elsif ($l->{IS_ZERO_TERMINATED}) { # Noheader arrays
- $length = $size = "ndr_get_string_size($ndr, sizeof(*$var_name))";
- } else {
- $length = $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL},
- check_null_pointer($e, $env, sub { $self->pidl(shift); },
- "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"),
- check_fully_dereferenced($e, $env));
- }
-
- if ((!$l->{IS_SURROUNDING}) and $l->{IS_CONFORMANT}) {
- $self->pidl("NDR_CHECK(ndr_pull_array_size($ndr, " . get_pointer_to($var_name) . "));");
- }
-
- if ($l->{IS_VARYING}) {
- $self->pidl("NDR_CHECK(ndr_pull_array_length($ndr, " . get_pointer_to($var_name) . "));");
- $length = "ndr_get_array_length($ndr, " . get_pointer_to($var_name) .")";
- }
-
- if ($length ne $size) {
- $self->pidl("if ($length > $size) {");
- $self->indent;
- $self->pidl("return ndr_pull_error($ndr, NDR_ERR_ARRAY_SIZE, \"Bad array size %u should exceed array length %u\", $size, $length);");
- $self->deindent;
- $self->pidl("}");
- }
-
- if ($l->{IS_CONFORMANT} and not $l->{IS_ZERO_TERMINATED}) {
- $self->defer("if ($var_name) {");
- $self->defer_indent;
- my $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL},
- check_null_pointer($e, $env, sub { $self->defer(shift); },
- "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"),
- check_fully_dereferenced($e, $env));
- $self->defer("NDR_CHECK(ndr_check_array_size($ndr, (void*)" . get_pointer_to($var_name) . ", $size));");
- $self->defer_deindent;
- $self->defer("}");
- }
-
- if ($l->{IS_VARYING} and not $l->{IS_ZERO_TERMINATED}) {
- $self->defer("if ($var_name) {");
- $self->defer_indent;
- my $length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL},
- check_null_pointer($e, $env, sub { $self->defer(shift); },
- "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for length_is()\");"),
- check_fully_dereferenced($e, $env));
- $self->defer("NDR_CHECK(ndr_check_array_length($ndr, (void*)" . get_pointer_to($var_name) . ", $length));");
- $self->defer_deindent;
- $self->defer("}");
- }
-
- if (not $l->{IS_FIXED} and not is_charset_array($e, $l)) {
- $self->AllocateArrayLevel($e,$l,$ndr,$var_name,$size);
- }
-
- return $length;
-}
-
-sub compression_alg($$)
-{
- my ($e, $l) = @_;
- my ($alg, $clen, $dlen) = split(/,/, $l->{COMPRESSION});
-
- return $alg;
-}
-
-sub compression_clen($$$)
-{
- my ($e, $l, $env) = @_;
- my ($alg, $clen, $dlen) = split(/,/, $l->{COMPRESSION});
-
- return ParseExpr($clen, $env, $e->{ORIGINAL});
-}
-
-sub compression_dlen($$$)
-{
- my ($e,$l,$env) = @_;
- my ($alg, $clen, $dlen) = split(/,/, $l->{COMPRESSION});
-
- return ParseExpr($dlen, $env, $e->{ORIGINAL});
-}
-
-sub ParseCompressionPushStart($$$$$)
-{
- my ($self,$e,$l,$ndr,$env) = @_;
- my $comndr = "$ndr\_compressed";
- my $alg = compression_alg($e, $l);
- my $dlen = compression_dlen($e, $l, $env);
-
- $self->pidl("{");
- $self->indent;
- $self->pidl("struct ndr_push *$comndr;");
- $self->pidl("NDR_CHECK(ndr_push_compression_start($ndr, &$comndr, $alg, $dlen));");
-
- return $comndr;
-}
-
-sub ParseCompressionPushEnd($$$$$)
-{
- my ($self,$e,$l,$ndr,$env) = @_;
- my $comndr = "$ndr\_compressed";
- my $alg = compression_alg($e, $l);
- my $dlen = compression_dlen($e, $l, $env);
-
- $self->pidl("NDR_CHECK(ndr_push_compression_end($ndr, $comndr, $alg, $dlen));");
- $self->deindent;
- $self->pidl("}");
-}
-
-sub ParseCompressionPullStart($$$$$)
-{
- my ($self,$e,$l,$ndr,$env) = @_;
- my $comndr = "$ndr\_compressed";
- my $alg = compression_alg($e, $l);
- my $dlen = compression_dlen($e, $l, $env);
-
- $self->pidl("{");
- $self->indent;
- $self->pidl("struct ndr_pull *$comndr;");
- $self->pidl("NDR_CHECK(ndr_pull_compression_start($ndr, &$comndr, $alg, $dlen));");
-
- return $comndr;
-}
-
-sub ParseCompressionPullEnd($$$$$)
-{
- my ($self,$e,$l,$ndr,$env) = @_;
- my $comndr = "$ndr\_compressed";
- my $alg = compression_alg($e, $l);
- my $dlen = compression_dlen($e, $l, $env);
-
- $self->pidl("NDR_CHECK(ndr_pull_compression_end($ndr, $comndr, $alg, $dlen));");
- $self->deindent;
- $self->pidl("}");
-}
-
-sub ParseSubcontextPushStart($$$$$)
-{
- my ($self,$e,$l,$ndr,$env) = @_;
- my $subndr = "_ndr_$e->{NAME}";
- my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e->{ORIGINAL});
-
- $self->pidl("{");
- $self->indent;
- $self->pidl("struct ndr_push *$subndr;");
- $self->pidl("NDR_CHECK(ndr_push_subcontext_start($ndr, &$subndr, $l->{HEADER_SIZE}, $subcontext_size));");
-
- if (defined $l->{COMPRESSION}) {
- $subndr = $self->ParseCompressionPushStart($e, $l, $subndr, $env);
- }
-
- return $subndr;
-}
-
-sub ParseSubcontextPushEnd($$$$$)
-{
- my ($self,$e,$l,$ndr,$env) = @_;
- my $subndr = "_ndr_$e->{NAME}";
- my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e->{ORIGINAL});
-
- if (defined $l->{COMPRESSION}) {
- $self->ParseCompressionPushEnd($e, $l, $subndr, $env);
- }
-
- $self->pidl("NDR_CHECK(ndr_push_subcontext_end($ndr, $subndr, $l->{HEADER_SIZE}, $subcontext_size));");
- $self->deindent;
- $self->pidl("}");
-}
-
-sub ParseSubcontextPullStart($$$$$)
-{
- my ($self,$e,$l,$ndr,$env) = @_;
- my $subndr = "_ndr_$e->{NAME}";
- my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e->{ORIGINAL});
-
- $self->pidl("{");
- $self->indent;
- $self->pidl("struct ndr_pull *$subndr;");
- $self->pidl("NDR_CHECK(ndr_pull_subcontext_start($ndr, &$subndr, $l->{HEADER_SIZE}, $subcontext_size));");
-
- if (defined $l->{COMPRESSION}) {
- $subndr = $self->ParseCompressionPullStart($e, $l, $subndr, $env);
- }
-
- return $subndr;
-}
-
-sub ParseSubcontextPullEnd($$$$$)
-{
- my ($self,$e,$l,$ndr,$env) = @_;
- my $subndr = "_ndr_$e->{NAME}";
- my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e->{ORIGINAL});
-
- if (defined $l->{COMPRESSION}) {
- $self->ParseCompressionPullEnd($e, $l, $subndr, $env);
- }
-
- $self->pidl("NDR_CHECK(ndr_pull_subcontext_end($ndr, $subndr, $l->{HEADER_SIZE}, $subcontext_size));");
- $self->deindent;
- $self->pidl("}");
-}
-
-sub ParseElementPushLevel
-{
- my ($self,$e,$l,$ndr,$var_name,$env,$primitives,$deferred) = @_;
-
- my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred);
-
- if ($l->{TYPE} eq "ARRAY" and ($l->{IS_CONFORMANT} or $l->{IS_VARYING})) {
- $var_name = get_pointer_to($var_name);
- }
-
- if (defined($ndr_flags)) {
- if ($l->{TYPE} eq "SUBCONTEXT") {
- my $subndr = $self->ParseSubcontextPushStart($e, $l, $ndr, $env);
- $self->ParseElementPushLevel($e, GetNextLevel($e, $l), $subndr, $var_name, $env, 1, 1);
- $self->ParseSubcontextPushEnd($e, $l, $ndr, $env);
- } elsif ($l->{TYPE} eq "POINTER") {
- $self->ParsePtrPush($e, $l, $ndr, $var_name);
- } elsif ($l->{TYPE} eq "ARRAY") {
- my $length = $self->ParseArrayPushHeader($e, $l, $ndr, $var_name, $env);
-
- my $nl = GetNextLevel($e, $l);
-
- # Allow speedups for arrays of scalar types
- if (is_charset_array($e,$l)) {
- $self->pidl("NDR_CHECK(ndr_push_charset($ndr, $ndr_flags, $var_name, $length, sizeof(" . mapTypeName($nl->{DATA_TYPE}) . "), CH_$e->{PROPERTIES}->{charset}));");
- return;
- } elsif (has_fast_array($e,$l)) {
- $self->pidl("NDR_CHECK(ndr_push_array_$nl->{DATA_TYPE}($ndr, $ndr_flags, $var_name, $length));");
- return;
- }
- } elsif ($l->{TYPE} eq "SWITCH") {
- $self->ParseSwitchPush($e, $l, $ndr, $var_name, $env);
- } elsif ($l->{TYPE} eq "DATA") {
- $self->ParseDataPush($e, $l, $ndr, $var_name, $primitives, $deferred);
- } elsif ($l->{TYPE} eq "TYPEDEF") {
- $typefamily{$e->{DATA}->{TYPE}}->{PUSH_FN_BODY}->($self, $e->{DATA}, $ndr, $var_name);
- }
- }
-
- if ($l->{TYPE} eq "POINTER" and $deferred) {
- if ($l->{POINTER_TYPE} ne "ref") {
- $self->pidl("if ($var_name) {");
- $self->indent;
- if ($l->{POINTER_TYPE} eq "relative") {
- $self->pidl("NDR_CHECK(ndr_push_relative_ptr2($ndr, $var_name));");
- }
- }
- $var_name = get_value_of($var_name);
- $self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 1, 1);
-
- if ($l->{POINTER_TYPE} ne "ref") {
- $self->deindent;
- $self->pidl("}");
- }
- } elsif ($l->{TYPE} eq "ARRAY" and not has_fast_array($e,$l) and
- not is_charset_array($e, $l)) {
- my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL});
- my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}";
-
- $var_name = get_array_element($var_name, $counter);
-
- if (($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) {
- $self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
- $self->indent;
- $self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 1, 0);
- $self->deindent;
- $self->pidl("}");
- }
-
- if ($deferred and ContainsDeferred($e, $l)) {
- $self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
- $self->indent;
- $self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 0, 1);
- $self->deindent;
- $self->pidl("}");
- }
- } elsif ($l->{TYPE} eq "SWITCH") {
- $self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, $primitives, $deferred);
- }
-}
-
-#####################################################################
-# parse scalars in a structure element
-sub ParseElementPush($$$$$$)
-{
- my ($self,$e,$ndr,$env,$primitives,$deferred) = @_;
- my $subndr = undef;
-
- my $var_name = $env->{$e->{NAME}};
-
- return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0]));
-
- # Representation type is different from transmit_as
- if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) {
- $self->pidl("{");
- $self->indent;
- my $transmit_name = "_transmit_$e->{NAME}";
- $self->pidl(mapTypeName($e->{TYPE}) ." $transmit_name;");
- $self->pidl("NDR_CHECK(ndr_$e->{REPRESENTATION_TYPE}_to_$e->{TYPE}($var_name, " . get_pointer_to($transmit_name) . "));");
- $var_name = $transmit_name;
- }
-
- $var_name = append_prefix($e, $var_name);
-
- $self->start_flags($e, $ndr);
-
- if (defined(my $value = has_property($e, "value"))) {
- $var_name = ParseExpr($value, $env, $e->{ORIGINAL});
- }
-
- $self->ParseElementPushLevel($e, $e->{LEVELS}[0], $ndr, $var_name, $env, $primitives, $deferred);
-
- $self->end_flags($e, $ndr);
-
- if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) {
- $self->deindent;
- $self->pidl("}");
- }
-}
-
-#####################################################################
-# parse a pointer in a struct element or function
-sub ParsePtrPush($$$$$)
-{
- my ($self,$e,$l,$ndr,$var_name) = @_;
-
- if ($l->{POINTER_TYPE} eq "ref") {
- $self->pidl("if ($var_name == NULL) {");
- $self->indent;
- $self->pidl("return ndr_push_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL [ref] pointer\");");
- $self->deindent;
- $self->pidl("}");
- if ($l->{LEVEL} eq "EMBEDDED") {
- $self->pidl("NDR_CHECK(ndr_push_ref_ptr(ndr));");
- }
- } elsif ($l->{POINTER_TYPE} eq "relative") {
- $self->pidl("NDR_CHECK(ndr_push_relative_ptr1($ndr, $var_name));");
- } elsif ($l->{POINTER_TYPE} eq "unique") {
- $self->pidl("NDR_CHECK(ndr_push_unique_ptr($ndr, $var_name));");
- } elsif ($l->{POINTER_TYPE} eq "full") {
- $self->pidl("NDR_CHECK(ndr_push_full_ptr($ndr, $var_name));");
- } else {
- die("Unhandled pointer type $l->{POINTER_TYPE}");
- }
-}
-
-sub need_pointer_to($$$)
-{
- my ($e, $l, $scalar_only) = @_;
-
- my $t;
- if (ref($l->{DATA_TYPE})) {
- $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}";
- } else {
- $t = $l->{DATA_TYPE};
- }
-
- if (not Parse::Pidl::Typelist::is_scalar($t)) {
- return 1 if $scalar_only;
- }
-
- my $arrays = 0;
-
- foreach my $tl (@{$e->{LEVELS}}) {
- last if $l == $tl;
- if ($tl->{TYPE} eq "ARRAY") {
- $arrays++;
- }
- }
-
- if (Parse::Pidl::Typelist::scalar_is_reference($t)) {
- return 1 unless $arrays;
- }
-
- return 0;
-}
-
-sub ParseDataPrint($$$$$)
-{
- my ($self, $e, $l, $ndr, $var_name) = @_;
-
- if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) {
-
- if (need_pointer_to($e, $l, 1)) {
- $var_name = get_pointer_to($var_name);
- }
-
- $self->pidl(TypeFunctionName("ndr_print", $l->{DATA_TYPE})."($ndr, \"$e->{NAME}\", $var_name);");
- } else {
- $self->ParseTypePrint($l->{DATA_TYPE}, $ndr, $var_name);
- }
-}
-
-#####################################################################
-# print scalars in a structure element
-sub ParseElementPrint($$$$$)
-{
- my($self, $e, $ndr, $var_name, $env) = @_;
-
- return if (has_property($e, "noprint"));
-
- if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) {
- $self->pidl("ndr_print_$e->{REPRESENTATION_TYPE}($ndr, \"$e->{NAME}\", $var_name);");
- return;
- }
-
- $var_name = append_prefix($e, $var_name);
-
- if (defined(my $value = has_property($e, "value"))) {
- $var_name = "($ndr->flags & LIBNDR_PRINT_SET_VALUES)?" . ParseExpr($value,$env, $e->{ORIGINAL}) . ":$var_name";
- }
-
- foreach my $l (@{$e->{LEVELS}}) {
- if ($l->{TYPE} eq "POINTER") {
- $self->pidl("ndr_print_ptr($ndr, \"$e->{NAME}\", $var_name);");
- $self->pidl("$ndr->depth++;");
- if ($l->{POINTER_TYPE} ne "ref") {
- $self->pidl("if ($var_name) {");
- $self->indent;
- }
- $var_name = get_value_of($var_name);
- } elsif ($l->{TYPE} eq "ARRAY") {
- my $length;
-
- if ($l->{IS_CONFORMANT} or $l->{IS_VARYING}) {
- $var_name = get_pointer_to($var_name);
- }
-
- if ($l->{IS_ZERO_TERMINATED}) {
- $length = "ndr_string_length($var_name, sizeof(*$var_name))";
- } else {
- $length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL},
- check_null_pointer($e, $env, sub { $self->pidl(shift); }, "return;"), check_fully_dereferenced($e, $env));
- }
-
- if (is_charset_array($e,$l)) {
- $self->pidl("ndr_print_string($ndr, \"$e->{NAME}\", $var_name);");
- last;
- } elsif (has_fast_array($e, $l)) {
- my $nl = GetNextLevel($e, $l);
- $self->pidl("ndr_print_array_$nl->{DATA_TYPE}($ndr, \"$e->{NAME}\", $var_name, $length);");
- last;
- } else {
- my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}";
-
- $self->pidl("$ndr->print($ndr, \"\%s: ARRAY(\%d)\", \"$e->{NAME}\", (int)$length);");
- $self->pidl("$ndr->depth++;");
- $self->pidl("for ($counter=0;$counter<$length;$counter++) {");
- $self->indent;
- $self->pidl("char *idx_$l->{LEVEL_INDEX}=NULL;");
- $self->pidl("if (asprintf(&idx_$l->{LEVEL_INDEX}, \"[\%d]\", $counter) != -1) {");
- $self->indent;
-
- $var_name = get_array_element($var_name, $counter);
- }
- } elsif ($l->{TYPE} eq "DATA") {
- $self->ParseDataPrint($e, $l, $ndr, $var_name);
- } elsif ($l->{TYPE} eq "SWITCH") {
- my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL},
- check_null_pointer($e, $env, sub { $self->pidl(shift); }, "return;"), check_fully_dereferenced($e, $env));
- $self->pidl("ndr_print_set_switch_value($ndr, " . get_pointer_to($var_name) . ", $switch_var);");
- }
- }
-
- foreach my $l (reverse @{$e->{LEVELS}}) {
- if ($l->{TYPE} eq "POINTER") {
- if ($l->{POINTER_TYPE} ne "ref") {
- $self->deindent;
- $self->pidl("}");
- }
- $self->pidl("$ndr->depth--;");
- } elsif (($l->{TYPE} eq "ARRAY")
- and not is_charset_array($e,$l)
- and not has_fast_array($e,$l)) {
- $self->pidl("free(idx_$l->{LEVEL_INDEX});");
- $self->deindent;
- $self->pidl("}");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("$ndr->depth--;");
- }
- }
-}
-
-#####################################################################
-# parse scalars in a structure element - pull size
-sub ParseSwitchPull($$$$$$)
-{
- my($self,$e,$l,$ndr,$var_name,$env) = @_;
- my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL},
- check_null_pointer($e, $env, sub { $self->pidl(shift); },
- "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for switch_is()\");"),
- check_fully_dereferenced($e, $env));
-
- $var_name = get_pointer_to($var_name);
- $self->pidl("NDR_CHECK(ndr_pull_set_switch_value($ndr, $var_name, $switch_var));");
-}
-
-#####################################################################
-# push switch element
-sub ParseSwitchPush($$$$$$)
-{
- my($self,$e,$l,$ndr,$var_name,$env) = @_;
- my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL},
- check_null_pointer($e, $env, sub { $self->pidl(shift); },
- "return ndr_push_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for switch_is()\");"),
- check_fully_dereferenced($e, $env));
-
- $var_name = get_pointer_to($var_name);
- $self->pidl("NDR_CHECK(ndr_push_set_switch_value($ndr, $var_name, $switch_var));");
-}
-
-sub ParseDataPull($$$$$$$)
-{
- my ($self,$e,$l,$ndr,$var_name,$primitives,$deferred) = @_;
-
- if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) {
-
- my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred);
-
- if (need_pointer_to($e, $l, 0)) {
- $var_name = get_pointer_to($var_name);
- }
-
- $var_name = get_pointer_to($var_name);
-
- $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_pull", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));");
-
- if (my $range = has_property($e, "range")) {
- $var_name = get_value_of($var_name);
- my ($low, $high) = split(/,/, $range, 2);
- $self->pidl("if ($var_name < $low || $var_name > $high) {");
- $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
- $self->pidl("}");
- }
- } else {
- $self->ParseTypePull($l->{DATA_TYPE}, $ndr, $var_name, $primitives, $deferred);
- }
-}
-
-sub ParseDataPush($$$$$$$)
-{
- my ($self,$e,$l,$ndr,$var_name,$primitives,$deferred) = @_;
-
- if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) {
-
- my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred);
-
- # strings are passed by value rather than reference
- if (need_pointer_to($e, $l, 1)) {
- $var_name = get_pointer_to($var_name);
- }
-
- $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_push", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));");
- } else {
- $self->ParseTypePush($l->{DATA_TYPE}, $ndr, $var_name, $primitives, $deferred);
- }
-}
-
-sub CalcNdrFlags($$$)
-{
- my ($l,$primitives,$deferred) = @_;
-
- my $scalars = 0;
- my $buffers = 0;
-
- # Add NDR_SCALARS if this one is deferred
- # and deferreds may be pushed
- $scalars = 1 if ($l->{IS_DEFERRED} and $deferred);
-
- # Add NDR_SCALARS if this one is not deferred and
- # primitives may be pushed
- $scalars = 1 if (!$l->{IS_DEFERRED} and $primitives);
-
- # Add NDR_BUFFERS if this one contains deferred stuff
- # and deferreds may be pushed
- $buffers = 1 if ($l->{CONTAINS_DEFERRED} and $deferred);
-
- return "NDR_SCALARS|NDR_BUFFERS" if ($scalars and $buffers);
- return "NDR_SCALARS" if ($scalars);
- return "NDR_BUFFERS" if ($buffers);
- return undef;
-}
-
-sub ParseMemCtxPullFlags($$$$)
-{
- my ($self, $e, $l) = @_;
-
- return undef unless ($l->{TYPE} eq "POINTER" or $l->{TYPE} eq "ARRAY");
-
- return undef if ($l->{TYPE} eq "ARRAY" and $l->{IS_FIXED});
- return undef if has_fast_array($e, $l);
- return undef if is_charset_array($e, $l);
-
- my $mem_flags = "0";
-
- if (($l->{TYPE} eq "POINTER") and ($l->{POINTER_TYPE} eq "ref")) {
- my $nl = GetNextLevel($e, $l);
- my $next_is_array = ($nl->{TYPE} eq "ARRAY");
- my $next_is_string = (($nl->{TYPE} eq "DATA") and
- ($nl->{DATA_TYPE} eq "string"));
- if ($next_is_array or $next_is_string) {
- return undef;
- } elsif ($l->{LEVEL} eq "TOP") {
- $mem_flags = "LIBNDR_FLAG_REF_ALLOC";
- }
- }
-
- return $mem_flags;
-}
-
-sub ParseMemCtxPullStart($$$$$)
-{
- my ($self, $e, $l, $ndr, $ptr_name) = @_;
-
- my $mem_r_ctx = "_mem_save_$e->{NAME}_$l->{LEVEL_INDEX}";
- my $mem_c_ctx = $ptr_name;
- my $mem_c_flags = $self->ParseMemCtxPullFlags($e, $l);
-
- return unless defined($mem_c_flags);
-
- $self->pidl("$mem_r_ctx = NDR_PULL_GET_MEM_CTX($ndr);");
- $self->pidl("NDR_PULL_SET_MEM_CTX($ndr, $mem_c_ctx, $mem_c_flags);");
-}
-
-sub ParseMemCtxPullEnd($$$$)
-{
- my ($self, $e, $l, $ndr) = @_;
-
- my $mem_r_ctx = "_mem_save_$e->{NAME}_$l->{LEVEL_INDEX}";
- my $mem_r_flags = $self->ParseMemCtxPullFlags($e, $l);
-
- return unless defined($mem_r_flags);
-
- $self->pidl("NDR_PULL_SET_MEM_CTX($ndr, $mem_r_ctx, $mem_r_flags);");
-}
-
-sub CheckStringTerminator($$$$$)
-{
- my ($self,$ndr,$e,$l,$length) = @_;
- my $nl = GetNextLevel($e, $l);
-
- # Make sure last element is zero!
- $self->pidl("NDR_CHECK(ndr_check_string_terminator($ndr, $length, sizeof($nl->{DATA_TYPE}_t)));");
-}
-
-sub ParseElementPullLevel
-{
- my($self,$e,$l,$ndr,$var_name,$env,$primitives,$deferred) = @_;
-
- my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred);
-
- if ($l->{TYPE} eq "ARRAY" and ($l->{IS_VARYING} or $l->{IS_CONFORMANT})) {
- $var_name = get_pointer_to($var_name);
- }
-
- # Only pull something if there's actually something to be pulled
- if (defined($ndr_flags)) {
- if ($l->{TYPE} eq "SUBCONTEXT") {
- my $subndr = $self->ParseSubcontextPullStart($e, $l, $ndr, $env);
- $self->ParseElementPullLevel($e, GetNextLevel($e,$l), $subndr, $var_name, $env, 1, 1);
- $self->ParseSubcontextPullEnd($e, $l, $ndr, $env);
- } elsif ($l->{TYPE} eq "ARRAY") {
- my $length = $self->ParseArrayPullHeader($e, $l, $ndr, $var_name, $env);
-
- my $nl = GetNextLevel($e, $l);
-
- if (is_charset_array($e,$l)) {
- if ($l->{IS_ZERO_TERMINATED}) {
- $self->CheckStringTerminator($ndr, $e, $l, $length);
- }
- $self->pidl("NDR_CHECK(ndr_pull_charset($ndr, $ndr_flags, ".get_pointer_to($var_name).", $length, sizeof(" . mapTypeName($nl->{DATA_TYPE}) . "), CH_$e->{PROPERTIES}->{charset}));");
- return;
- } elsif (has_fast_array($e, $l)) {
- if ($l->{IS_ZERO_TERMINATED}) {
- $self->CheckStringTerminator($ndr,$e,$l,$length);
- }
- $self->pidl("NDR_CHECK(ndr_pull_array_$nl->{DATA_TYPE}($ndr, $ndr_flags, $var_name, $length));");
- return;
- }
- } elsif ($l->{TYPE} eq "POINTER") {
- $self->ParsePtrPull($e, $l, $ndr, $var_name);
- } elsif ($l->{TYPE} eq "SWITCH") {
- $self->ParseSwitchPull($e, $l, $ndr, $var_name, $env);
- } elsif ($l->{TYPE} eq "DATA") {
- $self->ParseDataPull($e, $l, $ndr, $var_name, $primitives, $deferred);
- } elsif ($l->{TYPE} eq "TYPEDEF") {
- $typefamily{$e->{DATA}->{TYPE}}->{PULL_FN_BODY}->($self, $e->{DATA}, $ndr, $var_name);
- }
- }
-
- # add additional constructions
- if ($l->{TYPE} eq "POINTER" and $deferred) {
- if ($l->{POINTER_TYPE} ne "ref") {
- $self->pidl("if ($var_name) {");
- $self->indent;
-
- if ($l->{POINTER_TYPE} eq "relative") {
- $self->pidl("uint32_t _relative_save_offset;");
- $self->pidl("_relative_save_offset = $ndr->offset;");
- $self->pidl("NDR_CHECK(ndr_pull_relative_ptr2($ndr, $var_name));");
- }
- }
-
- $self->ParseMemCtxPullStart($e, $l, $ndr, $var_name);
-
- $var_name = get_value_of($var_name);
- $self->ParseElementPullLevel($e, GetNextLevel($e,$l), $ndr, $var_name, $env, 1, 1);
-
- $self->ParseMemCtxPullEnd($e, $l, $ndr);
-
- if ($l->{POINTER_TYPE} ne "ref") {
- if ($l->{POINTER_TYPE} eq "relative") {
- $self->pidl("$ndr->offset = _relative_save_offset;");
- }
- $self->deindent;
- $self->pidl("}");
- }
- } elsif ($l->{TYPE} eq "ARRAY" and
- not has_fast_array($e,$l) and not is_charset_array($e, $l)) {
- my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL});
- my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}";
- my $array_name = $var_name;
-
- $var_name = get_array_element($var_name, $counter);
-
- $self->ParseMemCtxPullStart($e, $l, $ndr, $array_name);
-
- if (($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) {
- my $nl = GetNextLevel($e,$l);
-
- if ($l->{IS_ZERO_TERMINATED}) {
- $self->CheckStringTerminator($ndr,$e,$l,$length);
- }
-
- $self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
- $self->indent;
- $self->ParseElementPullLevel($e, $nl, $ndr, $var_name, $env, 1, 0);
- $self->deindent;
- $self->pidl("}");
- }
-
- if ($deferred and ContainsDeferred($e, $l)) {
- $self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
- $self->indent;
- $self->ParseElementPullLevel($e,GetNextLevel($e,$l), $ndr, $var_name, $env, 0, 1);
- $self->deindent;
- $self->pidl("}");
- }
-
- $self->ParseMemCtxPullEnd($e, $l, $ndr);
-
- } elsif ($l->{TYPE} eq "SWITCH") {
- $self->ParseElementPullLevel($e, GetNextLevel($e,$l), $ndr, $var_name, $env, $primitives, $deferred);
- }
-}
-
-#####################################################################
-# parse scalars in a structure element - pull size
-sub ParseElementPull($$$$$$)
-{
- my($self,$e,$ndr,$env,$primitives,$deferred) = @_;
-
- my $var_name = $env->{$e->{NAME}};
- my $represent_name;
- my $transmit_name;
-
- return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0]));
-
- if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) {
- $self->pidl("{");
- $self->indent;
- $represent_name = $var_name;
- $transmit_name = "_transmit_$e->{NAME}";
- $var_name = $transmit_name;
- $self->pidl(mapTypeName($e->{TYPE})." $var_name;");
- }
-
- $var_name = append_prefix($e, $var_name);
-
- $self->start_flags($e, $ndr);
-
- $self->ParseElementPullLevel($e,$e->{LEVELS}[0],$ndr,$var_name,$env,$primitives,$deferred);
-
- $self->end_flags($e, $ndr);
-
- # Representation type is different from transmit_as
- if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) {
- $self->pidl("NDR_CHECK(ndr_$e->{TYPE}_to_$e->{REPRESENTATION_TYPE}($transmit_name, ".get_pointer_to($represent_name)."));");
- $self->deindent;
- $self->pidl("}");
- }
-}
-
-#####################################################################
-# parse a pointer in a struct element or function
-sub ParsePtrPull($$$$$)
-{
- my($self, $e,$l,$ndr,$var_name) = @_;
-
- my $nl = GetNextLevel($e, $l);
- my $next_is_array = ($nl->{TYPE} eq "ARRAY");
- my $next_is_string = (($nl->{TYPE} eq "DATA") and
- ($nl->{DATA_TYPE} eq "string"));
-
- if ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "TOP") {
-
- if (!$next_is_array and !$next_is_string) {
- $self->pidl("if ($ndr->flags & LIBNDR_FLAG_REF_ALLOC) {");
- $self->pidl("\tNDR_PULL_ALLOC($ndr, $var_name);");
- $self->pidl("}");
- }
-
- return;
- } elsif ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "EMBEDDED") {
- $self->pidl("NDR_CHECK(ndr_pull_ref_ptr($ndr, &_ptr_$e->{NAME}));");
- } elsif (($l->{POINTER_TYPE} eq "unique") or
- ($l->{POINTER_TYPE} eq "relative") or
- ($l->{POINTER_TYPE} eq "full")) {
- $self->pidl("NDR_CHECK(ndr_pull_generic_ptr($ndr, &_ptr_$e->{NAME}));");
- } else {
- die("Unhandled pointer type $l->{POINTER_TYPE}");
- }
-
- $self->pidl("if (_ptr_$e->{NAME}) {");
- $self->indent;
-
- # Don't do this for arrays, they're allocated at the actual level
- # of the array
- unless ($next_is_array or $next_is_string) {
- $self->pidl("NDR_PULL_ALLOC($ndr, $var_name);");
- } else {
- # FIXME: Yes, this is nasty.
- # We allocate an array twice
- # - once just to indicate that it's there,
- # - then the real allocation...
- $self->pidl("NDR_PULL_ALLOC($ndr, $var_name);");
- }
-
- #$self->pidl("memset($var_name, 0, sizeof($var_name));");
- if ($l->{POINTER_TYPE} eq "relative") {
- $self->pidl("NDR_CHECK(ndr_pull_relative_ptr1($ndr, $var_name, _ptr_$e->{NAME}));");
- }
- $self->deindent;
- $self->pidl("} else {");
- $self->pidl("\t$var_name = NULL;");
- $self->pidl("}");
-}
-
-sub ParseStructPushPrimitives($$$$$)
-{
- my ($self, $struct, $ndr, $varname, $env) = @_;
-
- # see if the structure contains a conformant array. If it
- # does, then it must be the last element of the structure, and
- # we need to push the conformant length early, as it fits on
- # the wire before the structure (and even before the structure
- # alignment)
- if (defined($struct->{SURROUNDING_ELEMENT})) {
- my $e = $struct->{SURROUNDING_ELEMENT};
-
- if (defined($e->{LEVELS}[0]) and
- $e->{LEVELS}[0]->{TYPE} eq "ARRAY") {
- my $size;
-
- if ($e->{LEVELS}[0]->{IS_ZERO_TERMINATED}) {
- if (has_property($e, "charset")) {
- $size = "ndr_charset_length($varname->$e->{NAME}, CH_$e->{PROPERTIES}->{charset})";
- } else {
- $size = "ndr_string_length($varname->$e->{NAME}, sizeof(*$varname->$e->{NAME}))";
- }
- } else {
- $size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env, $e->{ORIGINAL});
- }
-
- $self->pidl("NDR_CHECK(ndr_push_uint32($ndr, NDR_SCALARS, $size));");
- } else {
- $self->pidl("NDR_CHECK(ndr_push_uint32($ndr, NDR_SCALARS, ndr_string_array_size($ndr, $varname->$e->{NAME})));");
- }
- }
-
- $self->pidl("NDR_CHECK(ndr_push_align($ndr, $struct->{ALIGN}));");
-
- if (defined($struct->{PROPERTIES}{relative_base})) {
- # set the current offset as base for relative pointers
- # and store it based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset1($ndr, $varname, $ndr->offset));");
- }
-
- $self->ParseElementPush($_, $ndr, $env, 1, 0) foreach (@{$struct->{ELEMENTS}});
-}
-
-sub ParseStructPushDeferred($$$$)
-{
- my ($self, $struct, $ndr, $varname, $env) = @_;
- if (defined($struct->{PROPERTIES}{relative_base})) {
- # retrieve the current offset as base for relative pointers
- # based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset2($ndr, $varname));");
- }
- $self->ParseElementPush($_, $ndr, $env, 0, 1) foreach (@{$struct->{ELEMENTS}});
-}
-
-#####################################################################
-# parse a struct
-sub ParseStructPush($$$$)
-{
- my ($self, $struct, $ndr, $varname) = @_;
-
- return unless defined($struct->{ELEMENTS});
-
- my $env = GenerateStructEnv($struct, $varname);
-
- EnvSubstituteValue($env, $struct);
-
- $self->DeclareArrayVariables($_) foreach (@{$struct->{ELEMENTS}});
-
- $self->start_flags($struct, $ndr);
-
- $self->pidl("if (ndr_flags & NDR_SCALARS) {");
- $self->indent;
- $self->ParseStructPushPrimitives($struct, $ndr, $varname, $env);
- $self->deindent;
- $self->pidl("}");
-
- $self->pidl("if (ndr_flags & NDR_BUFFERS) {");
- $self->indent;
- $self->ParseStructPushDeferred($struct, $ndr, $varname, $env);
- $self->deindent;
- $self->pidl("}");
-
- $self->end_flags($struct, $ndr);
-}
-
-#####################################################################
-# generate a push function for an enum
-sub ParseEnumPush($$$$)
-{
- my($self,$enum,$ndr,$varname) = @_;
- my($type_fn) = $enum->{BASE_TYPE};
-
- $self->start_flags($enum, $ndr);
- $self->pidl("NDR_CHECK(ndr_push_$type_fn($ndr, NDR_SCALARS, $varname));");
- $self->end_flags($enum, $ndr);
-}
-
-#####################################################################
-# generate a pull function for an enum
-sub ParseEnumPull($$$$)
-{
- my($self,$enum,$ndr,$varname) = @_;
- my($type_fn) = $enum->{BASE_TYPE};
- my($type_v_decl) = mapTypeName($type_fn);
-
- $self->pidl("$type_v_decl v;");
- $self->start_flags($enum, $ndr);
- $self->pidl("NDR_CHECK(ndr_pull_$type_fn($ndr, NDR_SCALARS, &v));");
- $self->pidl("*$varname = v;");
-
- $self->end_flags($enum, $ndr);
-}
-
-#####################################################################
-# generate a print function for an enum
-sub ParseEnumPrint($$$$$)
-{
- my($self,$enum,$ndr,$name,$varname) = @_;
-
- $self->pidl("const char *val = NULL;");
- $self->pidl("");
-
- $self->start_flags($enum, $ndr);
-
- $self->pidl("switch ($varname) {");
- $self->indent;
- my $els = \@{$enum->{ELEMENTS}};
- foreach my $i (0 .. $#{$els}) {
- my $e = ${$els}[$i];
- chomp $e;
- if ($e =~ /^(.*)=/) {
- $e = $1;
- }
- $self->pidl("case $e: val = \"$e\"; break;");
- }
-
- $self->deindent;
- $self->pidl("}");
-
- $self->pidl("ndr_print_enum($ndr, name, \"$enum->{TYPE}\", val, $varname);");
-
- $self->end_flags($enum, $ndr);
-}
-
-sub DeclEnum($$$$)
-{
- my ($e,$t,$name,$varname) = @_;
- return "enum $name " .
- ($t eq "pull"?"*":"") . $varname;
-}
-
-$typefamily{ENUM} = {
- DECL => \&DeclEnum,
- PUSH_FN_BODY => \&ParseEnumPush,
- PULL_FN_BODY => \&ParseEnumPull,
- PRINT_FN_BODY => \&ParseEnumPrint,
-};
-
-#####################################################################
-# generate a push function for a bitmap
-sub ParseBitmapPush($$$$)
-{
- my($self,$bitmap,$ndr,$varname) = @_;
- my($type_fn) = $bitmap->{BASE_TYPE};
-
- $self->start_flags($bitmap, $ndr);
-
- $self->pidl("NDR_CHECK(ndr_push_$type_fn($ndr, NDR_SCALARS, $varname));");
-
- $self->end_flags($bitmap, $ndr);
-}
-
-#####################################################################
-# generate a pull function for an bitmap
-sub ParseBitmapPull($$$$)
-{
- my($self,$bitmap,$ndr,$varname) = @_;
- my $type_fn = $bitmap->{BASE_TYPE};
- my($type_decl) = mapTypeName($bitmap->{BASE_TYPE});
-
- $self->pidl("$type_decl v;");
- $self->start_flags($bitmap, $ndr);
- $self->pidl("NDR_CHECK(ndr_pull_$type_fn($ndr, NDR_SCALARS, &v));");
- $self->pidl("*$varname = v;");
-
- $self->end_flags($bitmap, $ndr);
-}
-
-#####################################################################
-# generate a print function for an bitmap
-sub ParseBitmapPrintElement($$$$$$)
-{
- my($self,$e,$bitmap,$ndr,$name,$varname) = @_;
- my($type_decl) = mapTypeName($bitmap->{BASE_TYPE});
- my($type_fn) = $bitmap->{BASE_TYPE};
- my($flag);
-
- if ($e =~ /^(\w+) .*$/) {
- $flag = "$1";
- } else {
- die "Bitmap: \"$name\" invalid Flag: \"$e\"";
- }
-
- $self->pidl("ndr_print_bitmap_flag($ndr, sizeof($type_decl), \"$flag\", $flag, $varname);");
-}
-
-#####################################################################
-# generate a print function for an bitmap
-sub ParseBitmapPrint($$$$$)
-{
- my($self,$bitmap,$ndr,$name,$varname) = @_;
- my($type_decl) = mapTypeName($bitmap->{TYPE});
- my($type_fn) = $bitmap->{BASE_TYPE};
-
- $self->start_flags($bitmap, $ndr);
-
- $self->pidl("ndr_print_$type_fn($ndr, name, $varname);");
-
- $self->pidl("$ndr->depth++;");
- foreach my $e (@{$bitmap->{ELEMENTS}}) {
- $self->ParseBitmapPrintElement($e, $bitmap, $ndr, $name, $varname);
- }
- $self->pidl("$ndr->depth--;");
-
- $self->end_flags($bitmap, $ndr);
-}
-
-sub DeclBitmap($$$$)
-{
- my ($e,$t,$name,$varname) = @_;
- return mapTypeName(Parse::Pidl::Typelist::bitmap_type_fn($e)) .
- ($t eq "pull"?" *":" ") . $varname;
-}
-
-$typefamily{BITMAP} = {
- DECL => \&DeclBitmap,
- PUSH_FN_BODY => \&ParseBitmapPush,
- PULL_FN_BODY => \&ParseBitmapPull,
- PRINT_FN_BODY => \&ParseBitmapPrint,
-};
-
-#####################################################################
-# generate a struct print function
-sub ParseStructPrint($$$$$)
-{
- my($self,$struct,$ndr,$name,$varname) = @_;
-
- return unless defined $struct->{ELEMENTS};
-
- my $env = GenerateStructEnv($struct, $varname);
-
- $self->DeclareArrayVariables($_) foreach (@{$struct->{ELEMENTS}});
-
- $self->pidl("ndr_print_struct($ndr, name, \"$name\");");
-
- $self->start_flags($struct, $ndr);
-
- $self->pidl("$ndr->depth++;");
-
- $self->ParseElementPrint($_, $ndr, $env->{$_->{NAME}}, $env)
- foreach (@{$struct->{ELEMENTS}});
- $self->pidl("$ndr->depth--;");
-
- $self->end_flags($struct, $ndr);
-}
-
-sub DeclarePtrVariables($$)
-{
- my ($self,$e) = @_;
- foreach my $l (@{$e->{LEVELS}}) {
- if ($l->{TYPE} eq "POINTER" and
- not ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "TOP")) {
- $self->pidl("uint32_t _ptr_$e->{NAME};");
- last;
- }
- }
-}
-
-sub DeclareArrayVariables($$)
-{
- my ($self,$e) = @_;
-
- foreach my $l (@{$e->{LEVELS}}) {
- next if has_fast_array($e,$l);
- next if is_charset_array($e,$l);
- if ($l->{TYPE} eq "ARRAY") {
- $self->pidl("uint32_t cntr_$e->{NAME}_$l->{LEVEL_INDEX};");
- }
- }
-}
-
-sub DeclareMemCtxVariables($$)
-{
- my ($self,$e) = @_;
- foreach my $l (@{$e->{LEVELS}}) {
- my $mem_flags = $self->ParseMemCtxPullFlags($e, $l);
- if (defined($mem_flags)) {
- $self->pidl("TALLOC_CTX *_mem_save_$e->{NAME}_$l->{LEVEL_INDEX};");
- }
- }
-}
-
-sub ParseStructPullPrimitives($$$$$)
-{
- my($self,$struct,$ndr,$varname,$env) = @_;
-
- if (defined $struct->{SURROUNDING_ELEMENT}) {
- $self->pidl("NDR_CHECK(ndr_pull_array_size($ndr, &$varname->$struct->{SURROUNDING_ELEMENT}->{NAME}));");
- }
-
- $self->pidl("NDR_CHECK(ndr_pull_align($ndr, $struct->{ALIGN}));");
-
- if (defined($struct->{PROPERTIES}{relative_base})) {
- # set the current offset as base for relative pointers
- # and store it based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset1($ndr, $varname, $ndr->offset));");
- }
-
- $self->ParseElementPull($_, $ndr, $env, 1, 0) foreach (@{$struct->{ELEMENTS}});
-
- $self->add_deferred();
-}
-
-sub ParseStructPullDeferred($$$$$)
-{
- my ($self,$struct,$ndr,$varname,$env) = @_;
-
- if (defined($struct->{PROPERTIES}{relative_base})) {
- # retrieve the current offset as base for relative pointers
- # based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset2($ndr, $varname));");
- }
- foreach my $e (@{$struct->{ELEMENTS}}) {
- $self->ParseElementPull($e, $ndr, $env, 0, 1);
- }
-
- $self->add_deferred();
-}
-
-#####################################################################
-# parse a struct - pull side
-sub ParseStructPull($$$$)
-{
- my($self,$struct,$ndr,$varname) = @_;
-
- return unless defined $struct->{ELEMENTS};
-
- # declare any internal pointers we need
- foreach my $e (@{$struct->{ELEMENTS}}) {
- $self->DeclarePtrVariables($e);
- $self->DeclareArrayVariables($e);
- $self->DeclareMemCtxVariables($e);
- }
-
- $self->start_flags($struct, $ndr);
-
- my $env = GenerateStructEnv($struct, $varname);
-
- $self->pidl("if (ndr_flags & NDR_SCALARS) {");
- $self->indent;
- $self->ParseStructPullPrimitives($struct,$ndr,$varname,$env);
- $self->deindent;
- $self->pidl("}");
- $self->pidl("if (ndr_flags & NDR_BUFFERS) {");
- $self->indent;
- $self->ParseStructPullDeferred($struct,$ndr,$varname,$env);
- $self->deindent;
- $self->pidl("}");
-
- $self->end_flags($struct, $ndr);
-}
-
-#####################################################################
-# calculate size of ndr struct
-sub ParseStructNdrSize($$$$)
-{
- my ($self,$t, $name, $varname) = @_;
- my $sizevar;
-
- if (my $flags = has_property($t, "flag")) {
- $self->pidl("flags |= $flags;");
- }
- $self->pidl("return ndr_size_struct($varname, flags, (ndr_push_flags_fn_t)ndr_push_$name);");
-}
-
-sub DeclStruct($$$$)
-{
- my ($e,$t,$name,$varname) = @_;
- return ($t ne "pull"?"const ":"") . "struct $name *$varname";
-}
-
-sub ArgsStructNdrSize($$$)
-{
- my ($d, $name, $varname) = @_;
- return "const struct $name *$varname, int flags";
-}
-
-$typefamily{STRUCT} = {
- PUSH_FN_BODY => \&ParseStructPush,
- DECL => \&DeclStruct,
- PULL_FN_BODY => \&ParseStructPull,
- PRINT_FN_BODY => \&ParseStructPrint,
- SIZE_FN_BODY => \&ParseStructNdrSize,
- SIZE_FN_ARGS => \&ArgsStructNdrSize,
-};
-
-#####################################################################
-# calculate size of ndr struct
-sub ParseUnionNdrSize($$$)
-{
- my ($self, $t, $name, $varname) = @_;
- my $sizevar;
-
- if (my $flags = has_property($t, "flag")) {
- $self->pidl("flags |= $flags;");
- }
-
- $self->pidl("return ndr_size_union($varname, flags, level, (ndr_push_flags_fn_t)ndr_push_$name);");
-}
-
-sub ParseUnionPushPrimitives($$$$)
-{
- my ($self, $e, $ndr ,$varname) = @_;
-
- my $have_default = 0;
-
- $self->pidl("int level = ndr_push_get_switch_value($ndr, $varname);");
-
- if (defined($e->{SWITCH_TYPE})) {
- $self->pidl("NDR_CHECK(ndr_push_$e->{SWITCH_TYPE}($ndr, NDR_SCALARS, level));");
- }
-
- $self->pidl("switch (level) {");
- $self->indent;
- foreach my $el (@{$e->{ELEMENTS}}) {
- if ($el->{CASE} eq "default") {
- $have_default = 1;
- }
- $self->pidl("$el->{CASE}: {");
-
- if ($el->{TYPE} ne "EMPTY") {
- $self->indent;
- if (defined($e->{PROPERTIES}{relative_base})) {
- $self->pidl("NDR_CHECK(ndr_push_align($ndr, $el->{ALIGN}));");
- # set the current offset as base for relative pointers
- # and store it based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset1($ndr, $varname, $ndr->offset));");
- }
- $self->DeclareArrayVariables($el);
- $self->ParseElementPush($el, $ndr, {$el->{NAME} => "$varname->$el->{NAME}"}, 1, 0);
- $self->deindent;
- }
- $self->pidl("break; }");
- $self->pidl("");
- }
- if (! $have_default) {
- $self->pidl("default:");
- $self->pidl("\treturn ndr_push_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
- }
- $self->deindent;
- $self->pidl("}");
-}
-
-sub ParseUnionPushDeferred($$$$)
-{
- my ($self,$e,$ndr,$varname) = @_;
-
- my $have_default = 0;
-
- $self->pidl("int level = ndr_push_get_switch_value($ndr, $varname);");
- if (defined($e->{PROPERTIES}{relative_base})) {
- # retrieve the current offset as base for relative pointers
- # based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset2($ndr, $varname));");
- }
- $self->pidl("switch (level) {");
- $self->indent;
- foreach my $el (@{$e->{ELEMENTS}}) {
- if ($el->{CASE} eq "default") {
- $have_default = 1;
- }
-
- $self->pidl("$el->{CASE}:");
- if ($el->{TYPE} ne "EMPTY") {
- $self->indent;
- $self->ParseElementPush($el, $ndr, {$el->{NAME} => "$varname->$el->{NAME}"}, 0, 1);
- $self->deindent;
- }
- $self->pidl("break;");
- $self->pidl("");
- }
- if (! $have_default) {
- $self->pidl("default:");
- $self->pidl("\treturn ndr_push_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
- }
- $self->deindent;
- $self->pidl("}");
-}
-
-#####################################################################
-# parse a union - push side
-sub ParseUnionPush($$$$)
-{
- my ($self,$e,$ndr,$varname) = @_;
- my $have_default = 0;
-
- $self->start_flags($e, $ndr);
-
- $self->pidl("if (ndr_flags & NDR_SCALARS) {");
- $self->indent;
- $self->ParseUnionPushPrimitives($e, $ndr, $varname);
- $self->deindent;
- $self->pidl("}");
- $self->pidl("if (ndr_flags & NDR_BUFFERS) {");
- $self->indent;
- $self->ParseUnionPushDeferred($e, $ndr, $varname);
- $self->deindent;
- $self->pidl("}");
- $self->end_flags($e, $ndr);
-}
-
-#####################################################################
-# print a union
-sub ParseUnionPrint($$$$$)
-{
- my ($self,$e,$ndr,$name,$varname) = @_;
- my $have_default = 0;
-
- $self->pidl("int level;");
- foreach my $el (@{$e->{ELEMENTS}}) {
- $self->DeclareArrayVariables($el);
- }
-
- $self->start_flags($e, $ndr);
-
- $self->pidl("level = ndr_print_get_switch_value($ndr, $varname);");
-
- $self->pidl("ndr_print_union($ndr, name, level, \"$name\");");
-
- $self->pidl("switch (level) {");
- $self->indent;
- foreach my $el (@{$e->{ELEMENTS}}) {
- if ($el->{CASE} eq "default") {
- $have_default = 1;
- }
- $self->pidl("$el->{CASE}:");
- if ($el->{TYPE} ne "EMPTY") {
- $self->indent;
- $self->ParseElementPrint($el, $ndr, "$varname->$el->{NAME}", {});
- $self->deindent;
- }
- $self->pidl("break;");
- $self->pidl("");
- }
- if (! $have_default) {
- $self->pidl("default:");
- $self->pidl("\tndr_print_bad_level($ndr, name, level);");
- }
- $self->deindent;
- $self->pidl("}");
-
- $self->end_flags($e, $ndr);
-}
-
-sub ParseUnionPullPrimitives($$$$$)
-{
- my ($self,$e,$ndr,$varname,$switch_type) = @_;
- my $have_default = 0;
-
- if (defined($switch_type)) {
- $self->pidl("NDR_CHECK(ndr_pull_$switch_type($ndr, NDR_SCALARS, &_level));");
- $self->pidl("if (_level != level) {");
- $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %u for $varname\", _level);");
- $self->pidl("}");
- }
-
- $self->pidl("switch (level) {");
- $self->indent;
- foreach my $el (@{$e->{ELEMENTS}}) {
- if ($el->{CASE} eq "default") {
- $have_default = 1;
- }
- $self->pidl("$el->{CASE}: {");
-
- if ($el->{TYPE} ne "EMPTY") {
- $self->indent;
- $self->DeclarePtrVariables($el);
- $self->DeclareArrayVariables($el);
- if (defined($e->{PROPERTIES}{relative_base})) {
- $self->pidl("NDR_CHECK(ndr_pull_align($ndr, $el->{ALIGN}));");
- # set the current offset as base for relative pointers
- # and store it based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset1($ndr, $varname, $ndr->offset));");
- }
- $self->ParseElementPull($el, $ndr, {$el->{NAME} => "$varname->$el->{NAME}"}, 1, 0);
- $self->deindent;
- }
- $self->pidl("break; }");
- $self->pidl("");
- }
- if (! $have_default) {
- $self->pidl("default:");
- $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
- }
- $self->deindent;
- $self->pidl("}");
-}
-
-sub ParseUnionPullDeferred($$$$)
-{
- my ($self,$e,$ndr,$varname) = @_;
- my $have_default = 0;
-
- if (defined($e->{PROPERTIES}{relative_base})) {
- # retrieve the current offset as base for relative pointers
- # based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset2($ndr, $varname));");
- }
- $self->pidl("switch (level) {");
- $self->indent;
- foreach my $el (@{$e->{ELEMENTS}}) {
- if ($el->{CASE} eq "default") {
- $have_default = 1;
- }
-
- $self->pidl("$el->{CASE}:");
- if ($el->{TYPE} ne "EMPTY") {
- $self->indent;
- $self->ParseElementPull($el, $ndr, {$el->{NAME} => "$varname->$el->{NAME}"}, 0, 1);
- $self->deindent;
- }
- $self->pidl("break;");
- $self->pidl("");
- }
- if (! $have_default) {
- $self->pidl("default:");
- $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
- }
- $self->deindent;
- $self->pidl("}");
-
-
-}
-
-#####################################################################
-# parse a union - pull side
-sub ParseUnionPull($$$$)
-{
- my ($self,$e,$ndr,$varname) = @_;
- my $switch_type = $e->{SWITCH_TYPE};
-
- $self->pidl("int level;");
- if (defined($switch_type)) {
- if (Parse::Pidl::Typelist::typeIs($switch_type, "ENUM")) {
- $switch_type = Parse::Pidl::Typelist::enum_type_fn(getType($switch_type)->{DATA});
- }
- $self->pidl(mapTypeName($switch_type) . " _level;");
- }
-
- my %double_cases = ();
- foreach my $el (@{$e->{ELEMENTS}}) {
- next if ($el->{TYPE} eq "EMPTY");
- next if ($double_cases{"$el->{NAME}"});
- $self->DeclareMemCtxVariables($el);
- $double_cases{"$el->{NAME}"} = 1;
- }
-
- $self->start_flags($e, $ndr);
-
- $self->pidl("level = ndr_pull_get_switch_value($ndr, $varname);");
-
- $self->pidl("if (ndr_flags & NDR_SCALARS) {");
- $self->indent;
- $self->ParseUnionPullPrimitives($e,$ndr,$varname,$switch_type);
- $self->deindent;
- $self->pidl("}");
-
- $self->pidl("if (ndr_flags & NDR_BUFFERS) {");
- $self->indent;
- $self->ParseUnionPullDeferred($e,$ndr,$varname);
- $self->deindent;
- $self->pidl("}");
-
- $self->add_deferred();
-
- $self->end_flags($e, $ndr);
-}
-
-sub DeclUnion($$$$)
-{
- my ($e,$t,$name,$varname) = @_;
- return ($t ne "pull"?"const ":"") . "union $name *$varname";
-}
-
-sub ArgsUnionNdrSize($$)
-{
- my ($d,$name) = @_;
- return "const union $name *r, uint32_t level, int flags";
-}
-
-$typefamily{UNION} = {
- PUSH_FN_BODY => \&ParseUnionPush,
- DECL => \&DeclUnion,
- PULL_FN_BODY => \&ParseUnionPull,
- PRINT_FN_BODY => \&ParseUnionPrint,
- SIZE_FN_ARGS => \&ArgsUnionNdrSize,
- SIZE_FN_BODY => \&ParseUnionNdrSize,
-};
-
-#####################################################################
-# parse a typedef - push side
-sub ParseTypedefPush($$$$)
-{
- my($self,$e,$ndr,$varname) = @_;
-
- my $env;
-
- $env->{$e->{NAME}} = $varname;
-
- $self->ParseElementPushLevel($e, $e->{LEVELS}[0], $ndr, $varname, $env, 1, 1);
-}
-
-#####################################################################
-# parse a typedef - pull side
-sub ParseTypedefPull($$$$)
-{
- my($self,$e,$ndr,$varname) = @_;
-
- my $env;
-
- $env->{$e->{NAME}} = $varname;
-
- $self->ParseElementPullLevel($e, $e->{LEVELS}[0], $ndr, $varname, $env, 1, 1);
-}
-
-#####################################################################
-# parse a typedef - print side
-sub ParseTypedefPrint($$$$$)
-{
- my($self,$e,$ndr,$name,$varname) = @_;
-
- $typefamily{$e->{DATA}->{TYPE}}->{PRINT_FN_BODY}->($self, $e->{DATA}, $ndr, $name, $varname);
-}
-
-#####################################################################
-## calculate the size of a structure
-sub ParseTypedefNdrSize($$$$)
-{
- my($self,$t,$name,$varname) = @_;
-
- $typefamily{$t->{DATA}->{TYPE}}->{SIZE_FN_BODY}->($self, $t->{DATA}, $name, $varname);
-}
-
-sub DeclTypedef($$$$)
-{
- my ($e, $t, $name, $varname) = @_;
-
- return $typefamily{$e->{DATA}->{TYPE}}->{DECL}->($e->{DATA}, $t, $name, $varname);
-}
-
-sub ArgsTypedefNdrSize($$$)
-{
- my ($d, $name, $varname) = @_;
- return $typefamily{$d->{DATA}->{TYPE}}->{SIZE_FN_ARGS}->($d->{DATA}, $name, $varname);
-}
-
-$typefamily{TYPEDEF} = {
- PUSH_FN_BODY => \&ParseTypedefPush,
- DECL => \&DeclTypedef,
- PULL_FN_BODY => \&ParseTypedefPull,
- PRINT_FN_BODY => \&ParseTypedefPrint,
- SIZE_FN_ARGS => \&ArgsTypedefNdrSize,
- SIZE_FN_BODY => \&ParseTypedefNdrSize,
-};
-
-#####################################################################
-# parse a function - print side
-sub ParseFunctionPrint($$)
-{
- my($self, $fn) = @_;
- my $ndr = "ndr";
-
- $self->pidl_hdr("void ndr_print_$fn->{NAME}(struct ndr_print *$ndr, const char *name, int flags, const struct $fn->{NAME} *r);");
-
- return if has_property($fn, "noprint");
-
- $self->pidl("_PUBLIC_ void ndr_print_$fn->{NAME}(struct ndr_print *$ndr, const char *name, int flags, const struct $fn->{NAME} *r)");
- $self->pidl("{");
- $self->indent;
-
- foreach my $e (@{$fn->{ELEMENTS}}) {
- $self->DeclareArrayVariables($e);
- }
-
- $self->pidl("ndr_print_struct($ndr, name, \"$fn->{NAME}\");");
- $self->pidl("$ndr->depth++;");
-
- $self->pidl("if (flags & NDR_SET_VALUES) {");
- $self->pidl("\t$ndr->flags |= LIBNDR_PRINT_SET_VALUES;");
- $self->pidl("}");
-
- $self->pidl("if (flags & NDR_IN) {");
- $self->indent;
- $self->pidl("ndr_print_struct($ndr, \"in\", \"$fn->{NAME}\");");
- $self->pidl("$ndr->depth++;");
-
- my $env = GenerateFunctionInEnv($fn);
-
- foreach my $e (@{$fn->{ELEMENTS}}) {
- if (grep(/in/,@{$e->{DIRECTION}})) {
- $self->ParseElementPrint($e, $ndr, $env->{$e->{NAME}}, $env);
- }
- }
- $self->pidl("$ndr->depth--;");
- $self->deindent;
- $self->pidl("}");
-
- $self->pidl("if (flags & NDR_OUT) {");
- $self->indent;
- $self->pidl("ndr_print_struct($ndr, \"out\", \"$fn->{NAME}\");");
- $self->pidl("$ndr->depth++;");
-
- $env = GenerateFunctionOutEnv($fn);
- foreach my $e (@{$fn->{ELEMENTS}}) {
- if (grep(/out/,@{$e->{DIRECTION}})) {
- $self->ParseElementPrint($e, $ndr, $env->{$e->{NAME}}, $env);
- }
- }
- if ($fn->{RETURN_TYPE}) {
- $self->pidl("ndr_print_$fn->{RETURN_TYPE}($ndr, \"result\", r->out.result);");
- }
- $self->pidl("$ndr->depth--;");
- $self->deindent;
- $self->pidl("}");
-
- $self->pidl("$ndr->depth--;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-}
-
-#####################################################################
-# parse a function
-sub ParseFunctionPush($$)
-{
- my($self, $fn) = @_;
- my $ndr = "ndr";
-
- $self->fn_declare("push", $fn, "enum ndr_err_code ndr_push_$fn->{NAME}(struct ndr_push *$ndr, int flags, const struct $fn->{NAME} *r)") or return;
-
- return if has_property($fn, "nopush");
-
- $self->pidl("{");
- $self->indent;
-
- foreach my $e (@{$fn->{ELEMENTS}}) {
- $self->DeclareArrayVariables($e);
- }
-
- $self->pidl("if (flags & NDR_IN) {");
- $self->indent;
-
- my $env = GenerateFunctionInEnv($fn);
-
- EnvSubstituteValue($env, $fn);
-
- foreach my $e (@{$fn->{ELEMENTS}}) {
- if (grep(/in/,@{$e->{DIRECTION}})) {
- $self->ParseElementPush($e, $ndr, $env, 1, 1);
- }
- }
-
- $self->deindent;
- $self->pidl("}");
-
- $self->pidl("if (flags & NDR_OUT) {");
- $self->indent;
-
- $env = GenerateFunctionOutEnv($fn);
- foreach my $e (@{$fn->{ELEMENTS}}) {
- if (grep(/out/,@{$e->{DIRECTION}})) {
- $self->ParseElementPush($e, $ndr, $env, 1, 1);
- }
- }
-
- if ($fn->{RETURN_TYPE}) {
- $self->pidl("NDR_CHECK(ndr_push_$fn->{RETURN_TYPE}($ndr, NDR_SCALARS, r->out.result));");
- }
-
- $self->deindent;
- $self->pidl("}");
- $self->pidl("return NDR_ERR_SUCCESS;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-}
-
-sub AllocateArrayLevel($$$$$$)
-{
- my ($self,$e,$l,$ndr,$var,$size) = @_;
-
- my $pl = GetPrevLevel($e, $l);
- if (defined($pl) and
- $pl->{TYPE} eq "POINTER" and
- $pl->{POINTER_TYPE} eq "ref"
- and not $l->{IS_ZERO_TERMINATED}) {
- $self->pidl("if ($ndr->flags & LIBNDR_FLAG_REF_ALLOC) {");
- $self->pidl("\tNDR_PULL_ALLOC_N($ndr, $var, $size);");
- $self->pidl("}");
- if (grep(/in/,@{$e->{DIRECTION}}) and
- grep(/out/,@{$e->{DIRECTION}})) {
- $self->pidl("memcpy(r->out.$e->{NAME}, r->in.$e->{NAME}, $size * sizeof(*r->in.$e->{NAME}));");
- }
- return;
- }
-
- $self->pidl("NDR_PULL_ALLOC_N($ndr, $var, $size);");
-}
-
-#####################################################################
-# parse a function
-sub ParseFunctionPull($$)
-{
- my($self,$fn) = @_;
- my $ndr = "ndr";
-
- # pull function args
- $self->fn_declare("pull", $fn, "enum ndr_err_code ndr_pull_$fn->{NAME}(struct ndr_pull *$ndr, int flags, struct $fn->{NAME} *r)") or return;
-
- $self->pidl("{");
- $self->indent;
-
- # declare any internal pointers we need
- foreach my $e (@{$fn->{ELEMENTS}}) {
- $self->DeclarePtrVariables($e);
- $self->DeclareArrayVariables($e);
- }
-
- my %double_cases = ();
- foreach my $e (@{$fn->{ELEMENTS}}) {
- next if ($e->{TYPE} eq "EMPTY");
- next if ($double_cases{"$e->{NAME}"});
- $self->DeclareMemCtxVariables($e);
- $double_cases{"$e->{NAME}"} = 1;
- }
-
- $self->pidl("if (flags & NDR_IN) {");
- $self->indent;
-
- # auto-init the out section of a structure. I originally argued that
- # this was a bad idea as it hides bugs, but coping correctly
- # with initialisation and not wiping ref vars is turning
- # out to be too tricky (tridge)
- foreach my $e (@{$fn->{ELEMENTS}}) {
- next unless grep(/out/, @{$e->{DIRECTION}});
- $self->pidl("ZERO_STRUCT(r->out);");
- $self->pidl("");
- last;
- }
-
- my $env = GenerateFunctionInEnv($fn);
-
- foreach my $e (@{$fn->{ELEMENTS}}) {
- next unless (grep(/in/, @{$e->{DIRECTION}}));
- $self->ParseElementPull($e, $ndr, $env, 1, 1);
- }
-
- # allocate the "simple" out ref variables. FIXME: Shouldn't this have it's
- # own flag rather than be in NDR_IN ?
-
- foreach my $e (@{$fn->{ELEMENTS}}) {
- next unless (grep(/out/, @{$e->{DIRECTION}}));
- next unless ($e->{LEVELS}[0]->{TYPE} eq "POINTER" and
- $e->{LEVELS}[0]->{POINTER_TYPE} eq "ref");
- next if (($e->{LEVELS}[1]->{TYPE} eq "DATA") and
- ($e->{LEVELS}[1]->{DATA_TYPE} eq "string"));
- next if (($e->{LEVELS}[1]->{TYPE} eq "ARRAY")
- and $e->{LEVELS}[1]->{IS_ZERO_TERMINATED});
-
- if ($e->{LEVELS}[1]->{TYPE} eq "ARRAY") {
- my $size = ParseExprExt($e->{LEVELS}[1]->{SIZE_IS}, $env, $e->{ORIGINAL},
- check_null_pointer($e, $env, sub { $self->pidl(shift); },
- "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"),
- check_fully_dereferenced($e, $env));
- $self->pidl("NDR_PULL_ALLOC_N($ndr, r->out.$e->{NAME}, $size);");
-
- if (grep(/in/, @{$e->{DIRECTION}})) {
- $self->pidl("memcpy(r->out.$e->{NAME}, r->in.$e->{NAME}, ($size) * sizeof(*r->in.$e->{NAME}));");
- } else {
- $self->pidl("memset(r->out.$e->{NAME}, 0, ($size) * sizeof(*r->out.$e->{NAME}));");
- }
- } else {
- $self->pidl("NDR_PULL_ALLOC($ndr, r->out.$e->{NAME});");
-
- if (grep(/in/, @{$e->{DIRECTION}})) {
- $self->pidl("*r->out.$e->{NAME} = *r->in.$e->{NAME};");
- } else {
- $self->pidl("ZERO_STRUCTP(r->out.$e->{NAME});");
- }
- }
- }
-
- $self->add_deferred();
- $self->deindent;
- $self->pidl("}");
-
- $self->pidl("if (flags & NDR_OUT) {");
- $self->indent;
-
- $env = GenerateFunctionOutEnv($fn);
- foreach my $e (@{$fn->{ELEMENTS}}) {
- next unless grep(/out/, @{$e->{DIRECTION}});
- $self->ParseElementPull($e, $ndr, $env, 1, 1);
- }
-
- if ($fn->{RETURN_TYPE}) {
- $self->pidl("NDR_CHECK(ndr_pull_$fn->{RETURN_TYPE}($ndr, NDR_SCALARS, &r->out.result));");
- }
-
- $self->add_deferred();
- $self->deindent;
- $self->pidl("}");
-
- $self->pidl("return NDR_ERR_SUCCESS;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-}
-
-sub AuthServiceStruct($$$)
-{
- my ($self, $ifacename, $authservice) = @_;
- my @a = split /,/, $authservice;
- my $authservice_count = $#a + 1;
-
- $self->pidl("static const char * const $ifacename\_authservice_strings[] = {");
- foreach my $ap (@a) {
- $self->pidl("\t$ap, ");
- }
- $self->pidl("};");
- $self->pidl("");
-
- $self->pidl("static const struct ndr_interface_string_array $ifacename\_authservices = {");
- $self->pidl("\t.count\t= $authservice_count,");
- $self->pidl("\t.names\t= $ifacename\_authservice_strings");
- $self->pidl("};");
- $self->pidl("");
-}
-
-sub FunctionCallEntry($$)
-{
- my ($self, $d) = @_;
- next if not defined($d->{OPNUM});
- $self->pidl("\t{");
- $self->pidl("\t\t\"$d->{NAME}\",");
- $self->pidl("\t\tsizeof(struct $d->{NAME}),");
- $self->pidl("\t\t(ndr_push_flags_fn_t) ndr_push_$d->{NAME},");
- $self->pidl("\t\t(ndr_pull_flags_fn_t) ndr_pull_$d->{NAME},");
- $self->pidl("\t\t(ndr_print_function_t) ndr_print_$d->{NAME},");
- $self->pidl("\t\t".($d->{ASYNC}?"true":"false").",");
- $self->pidl("\t},");
-}
-
-#####################################################################
-# produce a function call table
-sub FunctionTable($$)
-{
- my($self,$interface) = @_;
- my $count = 0;
- my $uname = uc $interface->{NAME};
-
- return if ($#{$interface->{FUNCTIONS}}+1 == 0);
- return unless defined ($interface->{PROPERTIES}->{uuid});
-
- $self->pidl("static const struct ndr_interface_call $interface->{NAME}\_calls[] = {");
-
- foreach my $d (@{$interface->{INHERITED_FUNCTIONS}},@{$interface->{FUNCTIONS}}) {
- $self->FunctionCallEntry($d);
- $count++;
- }
- $self->pidl("\t{ NULL, 0, NULL, NULL, NULL, false }");
- $self->pidl("};");
- $self->pidl("");
-
- $self->pidl("static const char * const $interface->{NAME}\_endpoint_strings[] = {");
- foreach my $ep (@{$interface->{ENDPOINTS}}) {
- $self->pidl("\t$ep, ");
- }
- my $endpoint_count = $#{$interface->{ENDPOINTS}}+1;
-
- $self->pidl("};");
- $self->pidl("");
-
- $self->pidl("static const struct ndr_interface_string_array $interface->{NAME}\_endpoints = {");
- $self->pidl("\t.count\t= $endpoint_count,");
- $self->pidl("\t.names\t= $interface->{NAME}\_endpoint_strings");
- $self->pidl("};");
- $self->pidl("");
-
- if (! defined $interface->{PROPERTIES}->{authservice}) {
- $interface->{PROPERTIES}->{authservice} = "\"host\"";
- }
-
- $self->AuthServiceStruct($interface->{NAME},
- $interface->{PROPERTIES}->{authservice});
-
- $self->pidl("\nconst struct ndr_interface_table ndr_table_$interface->{NAME} = {");
- $self->pidl("\t.name\t\t= \"$interface->{NAME}\",");
- $self->pidl("\t.syntax_id\t= {");
- $self->pidl("\t\t" . print_uuid($interface->{UUID}) .",");
- $self->pidl("\t\tNDR_$uname\_VERSION");
- $self->pidl("\t},");
- $self->pidl("\t.helpstring\t= NDR_$uname\_HELPSTRING,");
- $self->pidl("\t.num_calls\t= $count,");
- $self->pidl("\t.calls\t\t= $interface->{NAME}\_calls,");
- $self->pidl("\t.endpoints\t= &$interface->{NAME}\_endpoints,");
- $self->pidl("\t.authservices\t= &$interface->{NAME}\_authservices");
- $self->pidl("};");
- $self->pidl("");
-
-}
-
-#####################################################################
-# generate include statements for imported idl files
-sub HeaderImport
-{
- my $self = shift;
- my @imports = @_;
- foreach (@imports) {
- $_ = unmake_str($_);
- s/\.idl$//;
- $self->pidl(choose_header("librpc/gen_ndr/ndr_$_\.h", "gen_ndr/ndr_$_.h"));
- }
-}
-
-#####################################################################
-# generate include statements for included header files
-sub HeaderInclude
-{
- my $self = shift;
- my @includes = @_;
- foreach (@includes) {
- $self->pidl_hdr("#include $_");
- }
-}
-
-#####################################################################
-# generate prototypes and defines for the interface definitions
-# FIXME: these prototypes are for the DCE/RPC client functions, not the
-# NDR parser and so do not belong here, technically speaking
-sub HeaderInterface($$$)
-{
- my($self,$interface,$needed) = @_;
-
- my $count = 0;
-
- if ($needed->{"compression"}) {
- $self->pidl(choose_header("librpc/ndr/ndr_compression.h", "ndr/compression.h"));
- }
-
- if (has_property($interface, "object")) {
- $self->pidl(choose_header("librpc/gen_ndr/ndr_orpc.h", "ndr/orpc.h"));
- }
-
- if (defined $interface->{PROPERTIES}->{helper}) {
- $self->HeaderInclude(split /,/, $interface->{PROPERTIES}->{helper});
- }
-
- if (defined $interface->{PROPERTIES}->{uuid}) {
- my $name = uc $interface->{NAME};
- $self->pidl_hdr("#define NDR_$name\_UUID " .
- Parse::Pidl::Util::make_str(lc($interface->{PROPERTIES}->{uuid})));
-
- if(!defined $interface->{PROPERTIES}->{version}) { $interface->{PROPERTIES}->{version} = "0.0"; }
- $self->pidl_hdr("#define NDR_$name\_VERSION $interface->{PROPERTIES}->{version}");
-
- $self->pidl_hdr("#define NDR_$name\_NAME \"$interface->{NAME}\"");
-
- if(!defined $interface->{PROPERTIES}->{helpstring}) { $interface->{PROPERTIES}->{helpstring} = "NULL"; }
- $self->pidl_hdr("#define NDR_$name\_HELPSTRING $interface->{PROPERTIES}->{helpstring}");
-
- $self->pidl_hdr("extern const struct ndr_interface_table ndr_table_$interface->{NAME};");
- }
-
- foreach (@{$interface->{FUNCTIONS}}) {
- next if has_property($_, "noopnum");
- next if grep(/^$_->{NAME}$/,@{$interface->{INHERITED_FUNCTIONS}});
- my $u_name = uc $_->{NAME};
-
- my $val = sprintf("0x%02x", $count);
- if (defined($interface->{BASE})) {
- $val .= " + NDR_" . uc $interface->{BASE} . "_CALL_COUNT";
- }
-
- $self->pidl_hdr("#define NDR_$u_name ($val)");
-
- $self->pidl_hdr("");
- $count++;
- }
-
- my $val = $count;
-
- if (defined($interface->{BASE})) {
- $val .= " + NDR_" . uc $interface->{BASE} . "_CALL_COUNT";
- }
-
- $self->pidl_hdr("#define NDR_" . uc $interface->{NAME} . "_CALL_COUNT ($val)");
-
-}
-
-sub ParseTypePush($$$$$$)
-{
- my ($self,$e, $ndr, $varname, $primitives, $deferred) = @_;
-
- # save the old relative_base_offset
- $self->pidl("uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset($ndr);") if defined(has_property($e, "relative_base"));
- $typefamily{$e->{TYPE}}->{PUSH_FN_BODY}->($self, $e, $ndr, $varname);
- # restore the old relative_base_offset
- $self->pidl("ndr_push_restore_relative_base_offset($ndr, _save_relative_base_offset);") if defined(has_property($e, "relative_base"));
-}
-
-sub ParseTypePushFunction($$$)
-{
- my ($self, $e, $varname) = @_;
- my $ndr = "ndr";
-
- my $args = $typefamily{$e->{TYPE}}->{DECL}->($e, "push", $e->{NAME}, $varname);
-
- $self->fn_declare("push", $e, "enum ndr_err_code ".TypeFunctionName("ndr_push", $e)."(struct ndr_push *$ndr, int ndr_flags, $args)") or return;
-
- $self->pidl("{");
- $self->indent;
- $self->ParseTypePush($e, $ndr, $varname, 1, 1);
- $self->pidl("return NDR_ERR_SUCCESS;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");;
-}
-
-sub ParseTypePull($$$$$$)
-{
- my ($self, $e, $ndr, $varname, $primitives, $deferred) = @_;
-
- # save the old relative_base_offset
- $self->pidl("uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset($ndr);") if defined(has_property($e, "relative_base"));
- $typefamily{$e->{TYPE}}->{PULL_FN_BODY}->($self, $e, $ndr, $varname);
- # restore the old relative_base_offset
- $self->pidl("ndr_pull_restore_relative_base_offset($ndr, _save_relative_base_offset);") if defined(has_property($e, "relative_base"));
-}
-
-sub ParseTypePullFunction($$)
-{
- my ($self, $e, $varname) = @_;
- my $ndr = "ndr";
-
- my $args = $typefamily{$e->{TYPE}}->{DECL}->($e, "pull", $e->{NAME}, $varname);
-
- $self->fn_declare("pull", $e, "enum ndr_err_code ".TypeFunctionName("ndr_pull", $e)."(struct ndr_pull *$ndr, int ndr_flags, $args)") or return;
-
- $self->pidl("{");
- $self->indent;
- $self->ParseTypePull($e, $ndr, $varname, 1, 1);
- $self->pidl("return NDR_ERR_SUCCESS;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-}
-
-sub ParseTypePrint($$$$)
-{
- my ($self, $e, $ndr, $varname) = @_;
-
- $typefamily{$e->{TYPE}}->{PRINT_FN_BODY}->($self, $e, $ndr, $e->{NAME}, $varname);
-}
-
-sub ParseTypePrintFunction($$$)
-{
- my ($self, $e, $varname) = @_;
- my $ndr = "ndr";
-
- my $args = $typefamily{$e->{TYPE}}->{DECL}->($e, "print", $e->{NAME}, $varname);
-
- $self->pidl_hdr("void ".TypeFunctionName("ndr_print", $e)."(struct ndr_print *ndr, const char *name, $args);");
-
- return if (has_property($e, "noprint"));
-
- $self->pidl("_PUBLIC_ void ".TypeFunctionName("ndr_print", $e)."(struct ndr_print *$ndr, const char *name, $args)");
- $self->pidl("{");
- $self->indent;
- $self->ParseTypePrint($e, $ndr, $varname);
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-}
-
-sub ParseTypeNdrSize($$)
-{
- my ($self,$t) = @_;
-
- my $varname = "r";
- my $tf = $typefamily{$t->{TYPE}};
- my $args = $tf->{SIZE_FN_ARGS}->($t, $t->{NAME}, $varname);
-
- $self->fn_declare("size", $t, "size_t ndr_size_$t->{NAME}($args)") or return;
-
- $self->pidl("{");
- $self->indent;
- $typefamily{$t->{TYPE}}->{SIZE_FN_BODY}->($self,$t, $t->{NAME}, $varname);
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-}
-
-#####################################################################
-# parse the interface definitions
-sub ParseInterface($$$)
-{
- my($self,$interface,$needed) = @_;
-
- $self->pidl_hdr("#ifndef _HEADER_NDR_$interface->{NAME}");
- $self->pidl_hdr("#define _HEADER_NDR_$interface->{NAME}");
-
- $self->pidl_hdr("");
-
- $self->HeaderInterface($interface, $needed);
-
- # Typedefs
- foreach my $d (@{$interface->{TYPES}}) {
- next unless(typeHasBody($d));
-
- ($needed->{TypeFunctionName("ndr_push", $d)}) && $self->ParseTypePushFunction($d, "r");
- ($needed->{TypeFunctionName("ndr_pull", $d)}) && $self->ParseTypePullFunction($d, "r");
- ($needed->{TypeFunctionName("ndr_print", $d)}) && $self->ParseTypePrintFunction($d, "r");
-
- # Make sure we don't generate a function twice...
- $needed->{TypeFunctionName("ndr_push", $d)} =
- $needed->{TypeFunctionName("ndr_pull", $d)} =
- $needed->{TypeFunctionName("ndr_print", $d)} = 0;
-
- ($needed->{"ndr_size_$d->{NAME}"}) && $self->ParseTypeNdrSize($d);
- }
-
- # Functions
- foreach my $d (@{$interface->{FUNCTIONS}}) {
- ($needed->{"ndr_push_$d->{NAME}"}) && $self->ParseFunctionPush($d);
- ($needed->{"ndr_pull_$d->{NAME}"}) && $self->ParseFunctionPull($d);
- ($needed->{"ndr_print_$d->{NAME}"}) && $self->ParseFunctionPrint($d);
-
- # Make sure we don't generate a function twice...
- $needed->{"ndr_push_$d->{NAME}"} = $needed->{"ndr_pull_$d->{NAME}"} =
- $needed->{"ndr_print_$d->{NAME}"} = 0;
- }
-
- $self->FunctionTable($interface);
-
- $self->pidl_hdr("#endif /* _HEADER_NDR_$interface->{NAME} */");
-}
-
-sub GenerateIncludes($)
-{
- my ($self) = @_;
- if (is_intree()) {
- $self->pidl("#include \"includes.h\"");
- } else {
- $self->pidl("#define _GNU_SOURCE");
- $self->pidl("#include <stdint.h>");
- $self->pidl("#include <stdlib.h>");
- $self->pidl("#include <stdio.h>");
- $self->pidl("#include <stdbool.h>");
- $self->pidl("#include <stdarg.h>");
- $self->pidl("#include <string.h>");
- }
-}
-
-#####################################################################
-# parse a parsed IDL structure back into an IDL file
-sub Parse($$$$)
-{
- my($self, $ndr,$gen_header,$ndr_header) = @_;
-
- $self->pidl_hdr("/* header auto-generated by pidl */");
- $self->pidl_hdr("");
- $self->pidl_hdr(choose_header("librpc/ndr/libndr.h", "ndr.h"));
- $self->pidl_hdr("#include \"$gen_header\"") if ($gen_header);
- $self->pidl_hdr("");
-
- $self->pidl("/* parser auto-generated by pidl */");
- $self->pidl("");
- $self->GenerateIncludes();
- $self->pidl("#include \"$ndr_header\"") if ($ndr_header);
- $self->pidl("");
-
- my %needed = ();
-
- foreach (@{$ndr}) {
- ($_->{TYPE} eq "INTERFACE") && NeededInterface($_, \%needed);
- }
-
- foreach (@{$ndr}) {
- ($_->{TYPE} eq "INTERFACE") && $self->ParseInterface($_, \%needed);
- ($_->{TYPE} eq "IMPORT") && $self->HeaderImport(@{$_->{PATHS}});
- ($_->{TYPE} eq "INCLUDE") && $self->HeaderInclude(@{$_->{PATHS}});
- }
-
- return ($self->{res_hdr}, $self->{res});
-}
-
-sub NeededElement($$$)
-{
- my ($e, $dir, $needed) = @_;
-
- return if ($e->{TYPE} eq "EMPTY");
-
- return if (ref($e->{TYPE}) eq "HASH" and
- not defined($e->{TYPE}->{NAME}));
-
- my ($t, $rt);
- if (ref($e->{TYPE}) eq "HASH") {
- $t = $e->{TYPE}->{TYPE}."_".$e->{TYPE}->{NAME};
- } else {
- $t = $e->{TYPE};
- }
-
- if (ref($e->{REPRESENTATION_TYPE}) eq "HASH") {
- $rt = $e->{REPRESENTATION_TYPE}->{TYPE}."_".$e->{REPRESENTATION_TYPE}->{NAME};
- } else {
- $rt = $e->{REPRESENTATION_TYPE};
- }
-
- die ("$e->{NAME} $t, $rt FOO") unless ($rt ne "");
-
- my @fn = ();
- if ($dir eq "print") {
- push(@fn, TypeFunctionName("ndr_print", $e->{REPRESENTATION_TYPE}));
- } elsif ($dir eq "pull") {
- push (@fn, TypeFunctionName("ndr_pull", $e->{TYPE}));
- push (@fn, "ndr_$t\_to_$rt")
- if ($rt ne $t);
- } elsif ($dir eq "push") {
- push (@fn, TypeFunctionName("ndr_push", $e->{TYPE}));
- push (@fn, "ndr_$rt\_to_$t")
- if ($rt ne $t);
- } else {
- die("invalid direction `$dir'");
- }
-
- foreach (@fn) {
- unless (defined($needed->{$_})) {
- $needed->{$_} = 1;
- }
- }
-}
-
-sub NeededFunction($$)
-{
- my ($fn,$needed) = @_;
- $needed->{"ndr_pull_$fn->{NAME}"} = 1;
- $needed->{"ndr_push_$fn->{NAME}"} = 1;
- $needed->{"ndr_print_$fn->{NAME}"} = 1;
- foreach my $e (@{$fn->{ELEMENTS}}) {
- $e->{PARENT} = $fn;
- NeededElement($e, $_, $needed) foreach ("pull", "push", "print");
- }
-}
-
-sub NeededType($$$)
-{
- sub NeededType($$$);
- my ($t,$needed,$req) = @_;
-
- NeededType($t->{DATA}, $needed, $req) if ($t->{TYPE} eq "TYPEDEF");
-
- if ($t->{TYPE} eq "STRUCT" or $t->{TYPE} eq "UNION") {
- return unless defined($t->{ELEMENTS});
- for my $e (@{$t->{ELEMENTS}}) {
- $e->{PARENT} = $t;
- if (has_property($e, "compression")) {
- $needed->{"compression"} = 1;
- }
- NeededElement($e, $req, $needed);
- NeededType($e->{TYPE}, $needed, $req) if (ref($e->{TYPE}) eq "HASH");
- }
- }
-}
-
-#####################################################################
-# work out what parse functions are needed
-sub NeededInterface($$)
-{
- my ($interface,$needed) = @_;
- NeededFunction($_, $needed) foreach (@{$interface->{FUNCTIONS}});
- foreach (reverse @{$interface->{TYPES}}) {
- if (has_property($_, "public")) {
- $needed->{TypeFunctionName("ndr_pull", $_)} = $needed->{TypeFunctionName("ndr_push", $_)} =
- $needed->{TypeFunctionName("ndr_print", $_)} = 1;
- }
-
- NeededType($_, $needed, "pull") if ($needed->{TypeFunctionName("ndr_pull", $_)});
- NeededType($_, $needed, "push") if ($needed->{TypeFunctionName("ndr_push", $_)});
- NeededType($_, $needed, "print") if ($needed->{TypeFunctionName("ndr_print", $_)});
- if (has_property($_, "gensize")) {
- $needed->{"ndr_size_$_->{NAME}"} = 1;
- }
- }
-}
-
-sub TypeFunctionName($$)
-{
- my ($prefix, $t) = @_;
-
- return "$prefix\_$t->{NAME}" if (ref($t) eq "HASH" and
- $t->{TYPE} eq "TYPEDEF");
- return "$prefix\_$t->{TYPE}_$t->{NAME}" if (ref($t) eq "HASH");
- return "$prefix\_$t";
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm
deleted file mode 100644
index e30102b4e1..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm
+++ /dev/null
@@ -1,328 +0,0 @@
-###################################################
-# server boilerplate generator
-# Copyright tridge@samba.org 2003
-# Copyright metze@samba.org 2004
-# released under the GNU GPL
-
-package Parse::Pidl::Samba4::NDR::Server;
-
-use strict;
-use Parse::Pidl::Util;
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-my($res);
-
-sub pidl($)
-{
- $res .= shift;
-}
-
-
-#####################################################
-# generate the switch statement for function dispatch
-sub gen_dispatch_switch($)
-{
- my $interface = shift;
-
- foreach my $fn (@{$interface->{FUNCTIONS}}) {
- next if not defined($fn->{OPNUM});
-
- pidl "\tcase $fn->{OPNUM}: {\n";
- pidl "\t\tstruct $fn->{NAME} *r2 = (struct $fn->{NAME} *)r;\n";
- pidl "\t\tif (DEBUGLEVEL >= 10) {\n";
- pidl "\t\t\tNDR_PRINT_FUNCTION_DEBUG($fn->{NAME}, NDR_IN, r2);\n";
- pidl "\t\t}\n";
- if ($fn->{RETURN_TYPE} && $fn->{RETURN_TYPE} ne "void") {
- pidl "\t\tr2->out.result = dcesrv_$fn->{NAME}(dce_call, mem_ctx, r2);\n";
- } else {
- pidl "\t\tdcesrv_$fn->{NAME}(dce_call, mem_ctx, r2);\n";
- }
- pidl "\t\tif (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {\n";
- pidl "\t\t\tDEBUG(5,(\"function $fn->{NAME} will reply async\\n\"));\n";
- pidl "\t\t}\n";
- pidl "\t\tbreak;\n\t}\n";
- }
-}
-
-#####################################################
-# generate the switch statement for function reply
-sub gen_reply_switch($)
-{
- my $interface = shift;
-
- foreach my $fn (@{$interface->{FUNCTIONS}}) {
- next if not defined($fn->{OPNUM});
-
- pidl "\tcase $fn->{OPNUM}: {\n";
- pidl "\t\tstruct $fn->{NAME} *r2 = (struct $fn->{NAME} *)r;\n";
- pidl "\t\tif (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {\n";
- pidl "\t\t\tDEBUG(5,(\"function $fn->{NAME} replied async\\n\"));\n";
- pidl "\t\t}\n";
- pidl "\t\tif (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {\n";
- pidl "\t\t\tNDR_PRINT_FUNCTION_DEBUG($fn->{NAME}, NDR_OUT | NDR_SET_VALUES, r2);\n";
- pidl "\t\t}\n";
- pidl "\t\tif (dce_call->fault_code != 0) {\n";
- pidl "\t\t\tDEBUG(2,(\"dcerpc_fault %s in $fn->{NAME}\\n\", dcerpc_errstr(mem_ctx, dce_call->fault_code)));\n";
- pidl "\t\t}\n";
- pidl "\t\tbreak;\n\t}\n";
- }
-}
-
-#####################################################################
-# produce boilerplate code for a interface
-sub Boilerplate_Iface($)
-{
- my($interface) = shift;
- my $name = $interface->{NAME};
- my $uname = uc $name;
- my $uuid = lc($interface->{PROPERTIES}->{uuid});
- my $if_version = $interface->{PROPERTIES}->{version};
-
- pidl "
-static NTSTATUS $name\__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface)
-{
-#ifdef DCESRV_INTERFACE_$uname\_BIND
- return DCESRV_INTERFACE_$uname\_BIND(dce_call,iface);
-#else
- return NT_STATUS_OK;
-#endif
-}
-
-static void $name\__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
-{
-#ifdef DCESRV_INTERFACE_$uname\_UNBIND
- DCESRV_INTERFACE_$uname\_UNBIND(context, iface);
-#else
- return;
-#endif
-}
-
-static NTSTATUS $name\__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
-{
- enum ndr_err_code ndr_err;
- uint16_t opnum = dce_call->pkt.u.request.opnum;
-
- dce_call->fault_code = 0;
-
- if (opnum >= ndr_table_$name.num_calls) {
- dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
- return NT_STATUS_NET_WRITE_FAULT;
- }
-
- *r = talloc_named(mem_ctx,
- ndr_table_$name.calls[opnum].struct_size,
- \"struct %s\",
- ndr_table_$name.calls[opnum].name);
- NT_STATUS_HAVE_NO_MEMORY(*r);
-
- /* unravel the NDR for the packet */
- ndr_err = ndr_table_$name.calls[opnum].ndr_pull(pull, NDR_IN, *r);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- dcerpc_log_packet(&ndr_table_$name, opnum, NDR_IN,
- &dce_call->pkt.u.request.stub_and_verifier);
- dce_call->fault_code = DCERPC_FAULT_NDR;
- return NT_STATUS_NET_WRITE_FAULT;
- }
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS $name\__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
-{
- uint16_t opnum = dce_call->pkt.u.request.opnum;
-
- switch (opnum) {
-";
- gen_dispatch_switch($interface);
-
-pidl "
- default:
- dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
- break;
- }
-
- if (dce_call->fault_code != 0) {
- dcerpc_log_packet(&ndr_table_$name, opnum, NDR_IN,
- &dce_call->pkt.u.request.stub_and_verifier);
- return NT_STATUS_NET_WRITE_FAULT;
- }
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS $name\__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
-{
- uint16_t opnum = dce_call->pkt.u.request.opnum;
-
- switch (opnum) {
-";
- gen_reply_switch($interface);
-
-pidl "
- default:
- dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
- break;
- }
-
- if (dce_call->fault_code != 0) {
- dcerpc_log_packet(&ndr_table_$name, opnum, NDR_IN,
- &dce_call->pkt.u.request.stub_and_verifier);
- return NT_STATUS_NET_WRITE_FAULT;
- }
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS $name\__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
-{
- enum ndr_err_code ndr_err;
- uint16_t opnum = dce_call->pkt.u.request.opnum;
-
- ndr_err = ndr_table_$name.calls[opnum].ndr_push(push, NDR_OUT, r);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- dce_call->fault_code = DCERPC_FAULT_NDR;
- return NT_STATUS_NET_WRITE_FAULT;
- }
-
- return NT_STATUS_OK;
-}
-
-const struct dcesrv_interface dcesrv\_$name\_interface = {
- .name = \"$name\",
- .syntax_id = {".print_uuid($uuid).",$if_version},
- .bind = $name\__op_bind,
- .unbind = $name\__op_unbind,
- .ndr_pull = $name\__op_ndr_pull,
- .dispatch = $name\__op_dispatch,
- .reply = $name\__op_reply,
- .ndr_push = $name\__op_ndr_push
-};
-
-";
-}
-
-#####################################################################
-# produce boilerplate code for an endpoint server
-sub Boilerplate_Ep_Server($)
-{
- my($interface) = shift;
- my $name = $interface->{NAME};
- my $uname = uc $name;
-
- pidl "
-static NTSTATUS $name\__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
-{
- int i;
-
- for (i=0;i<ndr_table_$name.endpoints->count;i++) {
- NTSTATUS ret;
- const char *name = ndr_table_$name.endpoints->names[i];
-
- ret = dcesrv_interface_register(dce_ctx, name, &dcesrv_$name\_interface, NULL);
- if (!NT_STATUS_IS_OK(ret)) {
- DEBUG(1,(\"$name\_op_init_server: failed to register endpoint \'%s\'\\n\",name));
- return ret;
- }
- }
-
- return NT_STATUS_OK;
-}
-
-static bool $name\__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
-{
- if (dcesrv_$name\_interface.syntax_id.if_version == if_version &&
- GUID_equal(\&dcesrv\_$name\_interface.syntax_id.uuid, uuid)) {
- memcpy(iface,&dcesrv\_$name\_interface, sizeof(*iface));
- return true;
- }
-
- return false;
-}
-
-static bool $name\__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
-{
- if (strcmp(dcesrv_$name\_interface.name, name)==0) {
- memcpy(iface, &dcesrv_$name\_interface, sizeof(*iface));
- return true;
- }
-
- return false;
-}
-
-NTSTATUS dcerpc_server_$name\_init(void)
-{
- NTSTATUS ret;
- struct dcesrv_endpoint_server ep_server;
-
- /* fill in our name */
- ep_server.name = \"$name\";
-
- /* fill in all the operations */
- ep_server.init_server = $name\__op_init_server;
-
- ep_server.interface_by_uuid = $name\__op_interface_by_uuid;
- ep_server.interface_by_name = $name\__op_interface_by_name;
-
- /* register ourselves with the DCERPC subsystem. */
- ret = dcerpc_register_ep_server(&ep_server);
-
- if (!NT_STATUS_IS_OK(ret)) {
- DEBUG(0,(\"Failed to register \'$name\' endpoint server!\\n\"));
- return ret;
- }
-
- return ret;
-}
-
-";
-}
-
-#####################################################################
-# dcerpc server boilerplate from a parsed IDL structure
-sub ParseInterface($)
-{
- my($interface) = shift;
- my $count = 0;
-
- if (!defined $interface->{PROPERTIES}->{uuid}) {
- return $res;
- }
-
- if (!defined $interface->{PROPERTIES}->{version}) {
- $interface->{PROPERTIES}->{version} = "0.0";
- }
-
- foreach my $fn (@{$interface->{FUNCTIONS}}) {
- if (defined($fn->{OPNUM})) { $count++; }
- }
-
- if ($count == 0) {
- return $res;
- }
-
- $res .= "/* $interface->{NAME} - dcerpc server boilerplate generated by pidl */\n\n";
- Boilerplate_Iface($interface);
- Boilerplate_Ep_Server($interface);
-
- return $res;
-}
-
-sub Parse($$)
-{
- my($ndr,$header) = @_;
-
- $res = "";
- $res .= "/* server functions auto-generated by pidl */\n";
- $res .= "#include \"$header\"\n";
- $res .= "\n";
-
- foreach my $x (@{$ndr}) {
- ParseInterface($x) if ($x->{TYPE} eq "INTERFACE" and not defined($x->{PROPERTIES}{object}));
- }
-
- return $res;
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
deleted file mode 100644
index 74cec5a827..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ /dev/null
@@ -1,1216 +0,0 @@
-###################################################
-# Python function wrapper generator
-# Copyright jelmer@samba.org 2007-2008
-# released under the GNU GPL
-
-package Parse::Pidl::Samba4::Python;
-
-use Exporter;
-@ISA = qw(Exporter);
-
-use strict;
-use Parse::Pidl qw(warning fatal);
-use Parse::Pidl::Typelist qw(hasType resolveType getType mapTypeName expandAlias);
-use Parse::Pidl::Util qw(has_property ParseExpr unmake_str);
-use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array);
-use Parse::Pidl::CUtil qw(get_value_of get_pointer_to);
-use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv);
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-sub new($) {
- my ($class) = @_;
- my $self = { res => "", res_hdr => "", tabs => "", constants => {},
- module_methods => [], module_objects => [], ready_types => [],
- readycode => [] };
- bless($self, $class);
-}
-
-sub pidl_hdr ($$)
-{
- my $self = shift;
- $self->{res_hdr} .= shift;
-}
-
-sub pidl($$)
-{
- my ($self, $d) = @_;
- if ($d) {
- $self->{res} .= $self->{tabs};
- $self->{res} .= $d;
- }
- $self->{res} .= "\n";
-}
-
-sub indent($)
-{
- my ($self) = @_;
- $self->{tabs} .= "\t";
-}
-
-sub deindent($)
-{
- my ($self) = @_;
- $self->{tabs} = substr($self->{tabs}, 0, -1);
-}
-
-sub Import
-{
- my $self = shift;
- my @imports = @_;
- foreach (@imports) {
- $_ = unmake_str($_);
- s/\.idl$//;
- $self->pidl_hdr("#include \"librpc/gen_ndr/py_$_\.h\"\n");
- }
-}
-
-sub Const($$)
-{
- my ($self, $const) = @_;
- $self->register_constant($const->{NAME}, $const->{DTYPE}, $const->{VALUE});
-}
-
-sub register_constant($$$$)
-{
- my ($self, $name, $type, $value) = @_;
-
- $self->{constants}->{$name} = [$type, $value];
-}
-
-sub EnumAndBitmapConsts($$$)
-{
- my ($self, $name, $d) = @_;
-
- return unless (defined($d->{ELEMENTS}));
-
- foreach my $e (@{$d->{ELEMENTS}}) {
- $e =~ /^([A-Za-z0-9_]+)/;
- my $cname = $1;
-
- $self->register_constant($cname, $d, $cname);
- }
-}
-
-sub FromUnionToPythonFunction($$$$)
-{
- my ($self, $mem_ctx, $type, $switch, $name) = @_;
-
- $self->pidl("PyObject *ret;");
- $self->pidl("");
-
- $self->pidl("switch ($switch) {");
- $self->indent;
-
- foreach my $e (@{$type->{ELEMENTS}}) {
- $self->pidl("$e->{CASE}:");
-
- $self->indent;
-
- if ($e->{NAME}) {
- $self->ConvertObjectToPython($mem_ctx, {}, $e, "$name->$e->{NAME}", "ret", "return NULL;");
- } else {
- $self->pidl("ret = Py_None;");
- }
-
- $self->pidl("return ret;");
- $self->pidl("");
-
- $self->deindent;
- }
-
- $self->deindent;
- $self->pidl("}");
-
- $self->pidl("PyErr_SetString(PyExc_TypeError, \"unknown union level\");");
- $self->pidl("return NULL;");
-}
-
-sub FromPythonToUnionFunction($$$$$)
-{
- my ($self, $type, $typename, $switch, $mem_ctx, $name) = @_;
-
- my $has_default = 0;
-
- $self->pidl("$typename *ret = talloc_zero($mem_ctx, $typename);");
-
- $self->pidl("switch ($switch) {");
- $self->indent;
-
- foreach my $e (@{$type->{ELEMENTS}}) {
- $self->pidl("$e->{CASE}:");
- if ($e->{CASE} eq "default") { $has_default = 1; }
- $self->indent;
- if ($e->{NAME}) {
- $self->ConvertObjectFromPython({}, $mem_ctx, $e, $name, "ret->$e->{NAME}", "talloc_free(ret); return NULL;");
- }
- $self->pidl("break;");
- $self->deindent;
- $self->pidl("");
- }
-
- if (!$has_default) {
- $self->pidl("default:");
- $self->indent;
- $self->pidl("PyErr_SetString(PyExc_TypeError, \"invalid union level value\");");
- $self->pidl("talloc_free(ret);");
- $self->pidl("ret = NULL;");
- $self->deindent;
- }
-
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
- $self->pidl("return ret;");
-}
-
-sub PythonStruct($$$$$$)
-{
- my ($self, $modulename, $prettyname, $name, $cname, $d) = @_;
-
- my $env = GenerateStructEnv($d, "object");
-
- $self->pidl("");
-
- my $getsetters = "NULL";
-
- if ($#{$d->{ELEMENTS}} > -1) {
- foreach my $e (@{$d->{ELEMENTS}}) {
- my $varname = "object->$e->{NAME}";
- $self->pidl("static PyObject *py_$name\_get_$e->{NAME}(PyObject *obj, void *closure)");
- $self->pidl("{");
- $self->indent;
- $self->pidl("$cname *object = py_talloc_get_ptr(obj);");
- $self->pidl("PyObject *py_$e->{NAME};");
- $self->ConvertObjectToPython("py_talloc_get_mem_ctx(obj)", $env, $e, $varname, "py_$e->{NAME}", "return NULL;");
- $self->pidl("return py_$e->{NAME};");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-
- $self->pidl("static int py_$name\_set_$e->{NAME}(PyObject *py_obj, PyObject *value, void *closure)");
- $self->pidl("{");
- $self->indent;
- $self->pidl("$cname *object = py_talloc_get_ptr(py_obj);");
- my $mem_ctx = "py_talloc_get_mem_ctx(py_obj)";
- my $l = $e->{LEVELS}[0];
- my $nl = GetNextLevel($e, $l);
- if ($l->{TYPE} eq "POINTER" and
- not ($nl->{TYPE} eq "ARRAY" and ($nl->{IS_FIXED} or is_charset_array($e, $nl))) and
- not ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE}))) {
- $self->pidl("talloc_free($varname);");
- }
- $self->ConvertObjectFromPython($env, $mem_ctx, $e, "value", $varname, "return -1;");
- $self->pidl("return 0;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
- }
-
- $getsetters = "py_$name\_getsetters";
- $self->pidl("static PyGetSetDef ".$getsetters."[] = {");
- $self->indent;
- foreach my $e (@{$d->{ELEMENTS}}) {
- $self->pidl("{ discard_const_p(char, \"$e->{NAME}\"), py_$name\_get_$e->{NAME}, py_$name\_set_$e->{NAME} },");
- }
- $self->pidl("{ NULL }");
- $self->deindent;
- $self->pidl("};");
- $self->pidl("");
- }
-
- $self->pidl("static PyObject *py_$name\_new(PyTypeObject *self, PyObject *args, PyObject *kwargs)");
- $self->pidl("{");
- $self->indent;
- $self->pidl("$cname *ret = talloc_zero(NULL, $cname);");
- $self->pidl("return py_talloc_import(&$name\_Type, ret);");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-
- my $py_methods = "NULL";
-
- # If the struct is not public there ndr_pull/ndr_push functions will
- # be static so not callable from here
- if (has_property($d, "public")) {
- $self->pidl("static PyObject *py_$name\_ndr_pack(PyObject *py_obj)");
- $self->pidl("{");
- $self->indent;
- $self->pidl("$cname *object = py_talloc_get_ptr(py_obj);");
- $self->pidl("DATA_BLOB blob;");
- $self->pidl("enum ndr_err_code err;");
- $self->pidl("err = ndr_push_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_push_flags_fn_t)ndr_push_$name);");
- $self->pidl("if (err != NDR_ERR_SUCCESS) {");
- $self->indent;
- $self->pidl("PyErr_SetNdrError(err);");
- $self->pidl("return NULL;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
- $self->pidl("return PyString_FromStringAndSize((char *)blob.data, blob.length);");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-
- $self->pidl("static PyObject *py_$name\_ndr_unpack(PyObject *py_obj, PyObject *args)");
- $self->pidl("{");
- $self->indent;
- $self->pidl("$cname *object = py_talloc_get_ptr(py_obj);");
- $self->pidl("DATA_BLOB blob;");
- $self->pidl("enum ndr_err_code err;");
- $self->pidl("if (!PyArg_ParseTuple(args, \"s#:__ndr_unpack__\", &blob.data, &blob.length))");
- $self->pidl("\treturn NULL;");
- $self->pidl("");
- $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
- $self->pidl("if (err != NDR_ERR_SUCCESS) {");
- $self->indent;
- $self->pidl("PyErr_SetNdrError(err);");
- $self->pidl("return NULL;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
- $self->pidl("return Py_None;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
- $py_methods = "py_$name\_methods";
- $self->pidl("static PyMethodDef $py_methods\[] = {");
- $self->indent;
- $self->pidl("{ \"__ndr_pack__\", (PyCFunction)py_$name\_ndr_pack, METH_NOARGS, \"S.pack() -> blob\\nNDR pack\" },");
- $self->pidl("{ \"__ndr_unpack__\", (PyCFunction)py_$name\_ndr_unpack, METH_VARARGS, \"S.unpack(blob) -> None\\nNDR unpack\" },");
- $self->pidl("{ NULL, NULL, 0, NULL }");
- $self->deindent;
- $self->pidl("};");
- $self->pidl("");
- }
-
- $self->pidl_hdr("PyAPI_DATA(PyTypeObject) $name\_Type;\n");
- $self->pidl_hdr("#define $name\_Check(op) PyObject_TypeCheck(op, &$name\_Type)\n");
- $self->pidl_hdr("#define $name\_CheckExact(op) ((op)->ob_type == &$name\_Type)\n");
- $self->pidl_hdr("\n");
- my $docstring = ($self->DocString($d, $name) or "NULL");
- my $typeobject = "$name\_Type";
- $self->pidl("PyTypeObject $typeobject = {");
- $self->indent;
- $self->pidl("PyObject_HEAD_INIT(NULL) 0,");
- $self->pidl(".tp_name = \"$modulename.$prettyname\",");
- $self->pidl(".tp_basicsize = sizeof(py_talloc_Object),");
- $self->pidl(".tp_dealloc = py_talloc_dealloc,");
- $self->pidl(".tp_getset = $getsetters,");
- $self->pidl(".tp_repr = py_talloc_default_repr,");
- $self->pidl(".tp_doc = $docstring,");
- $self->pidl(".tp_methods = $py_methods,");
- $self->pidl(".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,");
- $self->pidl(".tp_new = py_$name\_new,");
- $self->deindent;
- $self->pidl("};");
-
- $self->pidl("");
-
- return "&$typeobject";
-}
-
-sub get_metadata_var($)
-{
- my ($e) = @_;
- sub get_var($) { my $x = shift; $x =~ s/\*//g; return $x; }
-
- if (has_property($e, "length_is")) {
- return get_var($e->{PROPERTIES}->{length_is});
- } elsif (has_property($e, "size_is")) {
- return get_var($e->{PROPERTIES}->{size_is});
- }
-
- return undef;
-}
-
-sub find_metadata_args($)
-{
- my ($fn) = @_;
- my $metadata_args = { in => {}, out => {} };
-
- # Determine arguments that are metadata for other arguments (size_is/length_is)
- foreach my $e (@{$fn->{ELEMENTS}}) {
- foreach my $dir (@{$e->{DIRECTION}}) {
- my $main = get_metadata_var($e);
- if ($main) {
- $metadata_args->{$dir}->{$main} = $e->{NAME};
- }
- }
- }
-
- return $metadata_args;
-}
-
-sub PythonFunctionUnpackOut($$$)
-{
- my ($self, $fn, $fnname) = @_;
-
- my $outfnname = "unpack_$fnname\_args_out";
- my $signature = "";
-
- my $metadata_args = find_metadata_args($fn);
-
- my $env = GenerateFunctionOutEnv($fn, "r->");
- my $result_size = 0;
-
- $self->pidl("static PyObject *$outfnname(struct $fn->{NAME} *r)");
- $self->pidl("{");
- $self->indent;
- $self->pidl("PyObject *result = Py_None;");
- foreach my $e (@{$fn->{ELEMENTS}}) {
- next unless (grep(/out/,@{$e->{DIRECTION}}));
- next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or
- ($metadata_args->{out}->{$e->{NAME}}) and grep(/out/, @{$e->{DIRECTION}}));
- $self->pidl("PyObject *py_$e->{NAME};");
- $result_size++;
- }
-
- if ($fn->{RETURN_TYPE}) {
- $result_size++ unless ($fn->{RETURN_TYPE} eq "WERROR" or $fn->{RETURN_TYPE} eq "NTSTATUS");
- }
-
- my $i = 0;
-
- if ($result_size > 1) {
- $self->pidl("result = PyTuple_New($result_size);");
- $signature .= "(";
- } elsif ($result_size == 0) {
- $signature .= "None";
- }
-
- foreach my $e (@{$fn->{ELEMENTS}}) {
- next if ($metadata_args->{out}->{$e->{NAME}});
- my $py_name = "py_$e->{NAME}";
- if (grep(/out/,@{$e->{DIRECTION}})) {
- $self->ConvertObjectToPython("r", $env, $e, "r->out.$e->{NAME}", $py_name, "return NULL;");
- if ($result_size > 1) {
- $self->pidl("PyTuple_SetItem(result, $i, $py_name);");
- $i++;
- $signature .= "$e->{NAME}, ";
- } else {
- $self->pidl("result = $py_name;");
- $signature .= $e->{NAME};
- }
- }
- }
-
- if (defined($fn->{RETURN_TYPE}) and $fn->{RETURN_TYPE} eq "NTSTATUS") {
- $self->handle_ntstatus("r->out.result", "NULL", undef);
- } elsif (defined($fn->{RETURN_TYPE}) and $fn->{RETURN_TYPE} eq "WERROR") {
- $self->handle_werror("r->out.result", "NULL", undef);
- } elsif (defined($fn->{RETURN_TYPE})) {
- my $conv = $self->ConvertObjectToPythonData("r", $fn->{RETURN_TYPE}, "r->out.result");
- if ($result_size > 1) {
- $self->pidl("PyTuple_SetItem(result, $i, $conv);");
- } else {
- $self->pidl("result = $conv;");
- }
- $signature .= "result";
- }
-
- if (substr($signature, -2) eq ", ") {
- $signature = substr($signature, 0, -2);
- }
- if ($result_size > 1) {
- $signature .= ")";
- }
-
- $self->pidl("return result;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-
- return ($outfnname, $signature);
-}
-
-sub PythonFunctionPackIn($$$)
-{
- my ($self, $fn, $fnname) = @_;
- my $metadata_args = find_metadata_args($fn);
-
- my $infnname = "pack_$fnname\_args_in";
-
- $self->pidl("static bool $infnname(PyObject *args, PyObject *kwargs, struct $fn->{NAME} *r)");
- $self->pidl("{");
- $self->indent;
- my $args_format = "";
- my $args_string = "";
- my $args_names = "";
- my $signature = "";
-
- foreach my $e (@{$fn->{ELEMENTS}}) {
- next unless (grep(/in/,@{$e->{DIRECTION}}));
- next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or
- ($metadata_args->{out}->{$e->{NAME}}) and grep(/out/, @{$e->{DIRECTION}}));
- $self->pidl("PyObject *py_$e->{NAME};");
- $args_format .= "O";
- $args_string .= ", &py_$e->{NAME}";
- $args_names .= "\"$e->{NAME}\", ";
- $signature .= "$e->{NAME}, ";
- }
- if (substr($signature, -2) eq ", ") {
- $signature = substr($signature, 0, -2);
- }
- $self->pidl("const char *kwnames[] = {");
- $self->indent;
- $self->pidl($args_names . "NULL");
- $self->deindent;
- $self->pidl("};");
-
- $self->pidl("");
- $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"$args_format:$fn->{NAME}\", discard_const_p(char *, kwnames)$args_string)) {");
- $self->indent;
- $self->pidl("return false;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-
- my $env = GenerateFunctionInEnv($fn, "r->");
-
- my $fail = "return false;";
- foreach my $e (@{$fn->{ELEMENTS}}) {
- next unless (grep(/in/,@{$e->{DIRECTION}}));
- if ($metadata_args->{in}->{$e->{NAME}}) {
- my $py_var = "py_".$metadata_args->{in}->{$e->{NAME}};
- $self->pidl("PY_CHECK_TYPE(PyList, $py_var, $fail);");
- my $val = "PyList_Size($py_var)";
- if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
- $self->pidl("r->in.$e->{NAME} = talloc_ptrtype(r, r->in.$e->{NAME});");
- $self->pidl("*r->in.$e->{NAME} = $val;");
- } else {
- $self->pidl("r->in.$e->{NAME} = $val;");
- }
- } else {
- $self->ConvertObjectFromPython($env, "r", $e, "py_$e->{NAME}", "r->in.$e->{NAME}", $fail);
- }
- }
- $self->pidl("return true;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
- return ($infnname, $signature);
-}
-
-sub PythonFunction($$$)
-{
- my ($self, $fn, $iface, $prettyname) = @_;
-
- my $fnname = "py_$fn->{NAME}";
- my $docstring = $self->DocString($fn, $fn->{NAME});
-
- my ($insignature, $outsignature);
- my ($infn, $outfn);
-
- if (has_property($fn, "todo")) {
- unless ($docstring) { $docstring = "NULL"; }
- $infn = "NULL";
- $outfn = "NULL";
- } else {
- ($infn, $insignature) = $self->PythonFunctionPackIn($fn, $fnname);
- ($outfn, $outsignature) = $self->PythonFunctionUnpackOut($fn, $fnname);
- my $signature = "S.$prettyname($insignature) -> $outsignature";
- if ($docstring) {
- $docstring = "\"$signature\\n\\n\"$docstring";
- } else {
- $docstring = "\"$signature\"";
- }
- }
-
- return ($infn, $outfn, $docstring);
-}
-
-sub handle_werror($$$$)
-{
- my ($self, $var, $retval, $mem_ctx) = @_;
-
- $self->pidl("if (!W_ERROR_IS_OK($var)) {");
- $self->indent;
- $self->pidl("PyErr_SetWERROR($var);");
- $self->pidl("talloc_free($mem_ctx);") if ($mem_ctx);
- $self->pidl("return $retval;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-}
-
-sub handle_ntstatus($$$$)
-{
- my ($self, $var, $retval, $mem_ctx) = @_;
-
- $self->pidl("if (NT_STATUS_IS_ERR($var)) {");
- $self->indent;
- $self->pidl("PyErr_SetNTSTATUS($var);");
- $self->pidl("talloc_free($mem_ctx);") if ($mem_ctx);
- $self->pidl("return $retval;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-}
-
-sub PythonType($$$$)
-{
- my ($self, $modulename, $d, $interface, $basename) = @_;
-
- my $actual_ctype = $d;
- if ($actual_ctype->{TYPE} eq "TYPEDEF") {
- $actual_ctype = $actual_ctype->{DATA};
- }
-
- if ($actual_ctype->{TYPE} eq "STRUCT") {
- my $typeobject;
- my $fn_name = $d->{NAME};
-
- $fn_name =~ s/^$interface->{NAME}_//;
- $fn_name =~ s/^$basename\_//;
-
-
- if ($d->{TYPE} eq "STRUCT") {
- $typeobject = $self->PythonStruct($modulename, $fn_name, $d->{NAME}, mapTypeName($d), $d);
- } else {
- $typeobject = $self->PythonStruct($modulename, $fn_name, $d->{NAME}, mapTypeName($d), $d->{DATA});
- }
-
- $self->register_module_typeobject($fn_name, $typeobject);
- }
-
- if ($d->{TYPE} eq "ENUM" or $d->{TYPE} eq "BITMAP") {
- $self->EnumAndBitmapConsts($d->{NAME}, $d);
- }
-
- if ($d->{TYPE} eq "TYPEDEF" and ($d->{DATA}->{TYPE} eq "ENUM" or $d->{DATA}->{TYPE} eq "BITMAP")) {
- $self->EnumAndBitmapConsts($d->{NAME}, $d->{DATA});
- }
-
- if ($actual_ctype->{TYPE} eq "UNION" and defined($actual_ctype->{ELEMENTS})) {
- $self->pidl("PyObject *py_import_$d->{NAME}(TALLOC_CTX *mem_ctx, int level, " .mapTypeName($d) . " *in)");
- $self->pidl("{");
- $self->indent;
- $self->FromUnionToPythonFunction("mem_ctx", $actual_ctype, "level", "in") if ($actual_ctype->{TYPE} eq "UNION");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-
- $self->pidl(mapTypeName($d) . " *py_export_$d->{NAME}(TALLOC_CTX *mem_ctx, int level, PyObject *in)");
- $self->pidl("{");
- $self->indent;
- $self->FromPythonToUnionFunction($actual_ctype, mapTypeName($d), "level", "mem_ctx", "in") if ($actual_ctype->{TYPE} eq "UNION");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
- }
-}
-
-sub DocString($$$)
-{
- my ($self, $d, $name) = @_;
- if (has_property($d, "helpstring")) {
- my $docstring = uc("py_doc_$name");
- $self->pidl("#define $docstring ".has_property($d, "helpstring"));
- return $docstring;
- }
-
- return undef;
-}
-
-sub Interface($$$)
-{
- my($self,$interface,$basename) = @_;
-
- $self->pidl_hdr("#ifndef _HEADER_PYTHON_$interface->{NAME}\n");
- $self->pidl_hdr("#define _HEADER_PYTHON_$interface->{NAME}\n\n");
-
- $self->pidl_hdr("\n");
-
- $self->Const($_) foreach (@{$interface->{CONSTS}});
-
- foreach my $d (@{$interface->{TYPES}}) {
- next if has_property($d, "nopython");
-
- $self->PythonType($basename, $d, $interface, $basename);
- }
-
- if (defined $interface->{PROPERTIES}->{uuid}) {
- $self->pidl_hdr("PyAPI_DATA(PyTypeObject) $interface->{NAME}_InterfaceType;\n");
- $self->pidl("");
-
- my @fns = ();
-
- foreach my $d (@{$interface->{FUNCTIONS}}) {
- next if not defined($d->{OPNUM});
- next if has_property($d, "nopython");
-
- my $prettyname = $d->{NAME};
-
- $prettyname =~ s/^$interface->{NAME}_//;
- $prettyname =~ s/^$basename\_//;
-
- my ($infn, $outfn, $fndocstring) = $self->PythonFunction($d, $interface->{NAME}, $prettyname);
-
- push (@fns, [$infn, $outfn, "dcerpc_$d->{NAME}", $prettyname, $fndocstring, $d->{OPNUM}]);
- }
-
- $self->pidl("const struct PyNdrRpcMethodDef py_ndr_$interface->{NAME}\_methods[] = {");
- $self->pidl_hdr("extern const struct PyNdrRpcMethodDef py_ndr_$interface->{NAME}\_methods[];");
- $self->indent;
- foreach my $d (@fns) {
- my ($infn, $outfn, $callfn, $prettyname, $docstring, $opnum) = @$d;
- $self->pidl("{ \"$prettyname\", $docstring, (dcerpc_call_fn)$callfn, (py_data_pack_fn)$infn, (py_data_unpack_fn)$outfn, $opnum, &ndr_table_$interface->{NAME} },");
- }
- $self->pidl("{ NULL }");
- $self->deindent;
- $self->pidl("};");
- $self->pidl("");
-
- $self->pidl("static PyObject *interface_$interface->{NAME}_new(PyTypeObject *self, PyObject *args, PyObject *kwargs)");
- $self->pidl("{");
- $self->indent;
- $self->pidl("dcerpc_InterfaceObject *ret;");
- $self->pidl("const char *binding_string;");
- $self->pidl("struct cli_credentials *credentials;");
- $self->pidl("struct loadparm_context *lp_ctx = NULL;");
- $self->pidl("PyObject *py_lp_ctx = Py_None, *py_credentials = Py_None, *py_basis = Py_None;");
- $self->pidl("TALLOC_CTX *mem_ctx = NULL;");
- $self->pidl("struct event_context *event_ctx;");
- $self->pidl("NTSTATUS status;");
- $self->pidl("");
- $self->pidl("const char *kwnames[] = {");
- $self->indent;
- $self->pidl("\"binding\", \"lp_ctx\", \"credentials\", \"basis_connection\", NULL");
- $self->deindent;
- $self->pidl("};");
- $self->pidl("extern struct loadparm_context *lp_from_py_object(PyObject *py_obj);");
- $self->pidl("extern struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj);");
- $self->pidl("");
- $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"s|OOO:$interface->{NAME}\", discard_const_p(char *, kwnames), &binding_string, &py_lp_ctx, &py_credentials, &py_basis)) {");
- $self->indent;
- $self->pidl("return NULL;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
- $self->pidl("lp_ctx = lp_from_py_object(py_lp_ctx);");
- $self->pidl("if (lp_ctx == NULL) {");
- $self->indent;
- $self->pidl("PyErr_SetString(PyExc_TypeError, \"Expected loadparm context\");");
- $self->pidl("return NULL;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-
- $self->pidl("credentials = cli_credentials_from_py_object(py_credentials);");
- $self->pidl("if (credentials == NULL) {");
- $self->indent;
- $self->pidl("PyErr_SetString(PyExc_TypeError, \"Expected credentials\");");
- $self->pidl("return NULL;");
- $self->deindent;
- $self->pidl("}");
-
- $self->pidl("ret = PyObject_New(dcerpc_InterfaceObject, &$interface->{NAME}_InterfaceType);");
- $self->pidl("");
- $self->pidl("event_ctx = event_context_init(mem_ctx);");
- $self->pidl("");
-
- $self->pidl("if (py_basis != Py_None) {");
- $self->indent;
- $self->pidl("struct dcerpc_pipe *base_pipe;");
- $self->pidl("");
- $self->pidl("if (!PyObject_TypeCheck(py_basis, &dcerpc_InterfaceType)) {");
- $self->indent;
- $self->pidl("PyErr_SetString(PyExc_ValueError, \"basis_connection must be a DCE/RPC connection\");");
- $self->pidl("talloc_free(mem_ctx);");
- $self->pidl("return NULL;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
- $self->pidl("base_pipe = ((dcerpc_InterfaceObject *)py_basis)->pipe;");
- $self->pidl("");
- $self->pidl("status = dcerpc_secondary_context(base_pipe, &ret->pipe, &ndr_table_$interface->{NAME});");
- $self->deindent;
- $self->pidl("} else {");
- $self->indent;
- $self->pidl("status = dcerpc_pipe_connect(NULL, &ret->pipe, binding_string, ");
- $self->pidl(" &ndr_table_$interface->{NAME}, credentials, event_ctx, lp_ctx);");
- $self->deindent;
- $self->pidl("}");
- $self->handle_ntstatus("status", "NULL", "mem_ctx");
-
- $self->pidl("ret->pipe->conn->flags |= DCERPC_NDR_REF_ALLOC;");
-
- $self->pidl("return (PyObject *)ret;");
- $self->deindent;
- $self->pidl("}");
-
- $self->pidl("");
-
- my $signature =
-"\"$interface->{NAME}(binding, lp_ctx=None, credentials=None) -> connection\\n\"
-\"\\n\"
-\"binding should be a DCE/RPC binding string (for example: ncacn_ip_tcp:127.0.0.1)\\n\"
-\"lp_ctx should be a path to a smb.conf file or a param.LoadParm object\\n\"
-\"credentials should be a credentials.Credentials object.\\n\\n\"";
-
- my $docstring = $self->DocString($interface, $interface->{NAME});
-
- if ($docstring) {
- $docstring = "$signature$docstring";
- } else {
- $docstring = $signature;
- }
-
- $self->pidl("PyTypeObject $interface->{NAME}_InterfaceType = {");
- $self->indent;
- $self->pidl("PyObject_HEAD_INIT(NULL) 0,");
- $self->pidl(".tp_name = \"$basename.$interface->{NAME}\",");
- $self->pidl(".tp_basicsize = sizeof(dcerpc_InterfaceObject),");
- $self->pidl(".tp_base = &dcerpc_InterfaceType,");
- $self->pidl(".tp_doc = $docstring,");
- $self->pidl(".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,");
- $self->pidl(".tp_new = interface_$interface->{NAME}_new,");
- $self->deindent;
- $self->pidl("};");
-
- $self->pidl("");
-
- $self->register_module_typeobject($interface->{NAME}, "&$interface->{NAME}_InterfaceType");
- $self->register_module_readycode(["if (!PyInterface_AddNdrRpcMethods(&$interface->{NAME}_InterfaceType, py_ndr_$interface->{NAME}\_methods))", "\treturn;", ""]);
- }
-
- $self->pidl_hdr("\n");
- $self->pidl_hdr("#endif /* _HEADER_NDR_$interface->{NAME} */\n");
-}
-
-sub register_module_method($$$$$)
-{
- my ($self, $fn_name, $pyfn_name, $flags, $doc) = @_;
-
- push (@{$self->{module_methods}}, [$fn_name, $pyfn_name, $flags, $doc])
-}
-
-sub register_module_typeobject($$$)
-{
- my ($self, $name, $py_name) = @_;
-
- $self->register_module_object($name, "(PyObject *)$py_name");
-
- $self->check_ready_type($py_name);
-}
-
-sub check_ready_type($$)
-{
- my ($self, $py_name) = @_;
- push (@{$self->{ready_types}}, $py_name) unless (grep(/^$py_name$/,@{$self->{ready_types}}));
-}
-
-sub register_module_readycode($$)
-{
- my ($self, $code) = @_;
-
- push (@{$self->{readycode}}, @$code);
-}
-
-sub register_module_object($$$)
-{
- my ($self, $name, $py_name) = @_;
-
- push (@{$self->{module_objects}}, [$name, $py_name])
-}
-
-sub assign($$$)
-{
- my ($self, $dest, $src) = @_;
- if ($dest =~ /^\&/) {
- $self->pidl("memcpy($dest, $src, sizeof(" . get_value_of($dest) . "));");
- } else {
- $self->pidl("$dest = $src;");
- }
-}
-
-sub ConvertObjectFromPythonData($$$$$$)
-{
- my ($self, $mem_ctx, $cvar, $ctype, $target, $fail) = @_;
-
- die("undef type for $cvar") unless(defined($ctype));
-
- $ctype = resolveType($ctype);
-
- my $actual_ctype = $ctype;
- if ($ctype->{TYPE} eq "TYPEDEF") {
- $actual_ctype = $ctype->{DATA};
- }
-
- if ($actual_ctype->{TYPE} eq "ENUM" or $actual_ctype->{TYPE} eq "BITMAP" or
- $actual_ctype->{TYPE} eq "SCALAR" and (
- expandAlias($actual_ctype->{NAME}) =~ /^(u?int[0-9]*|hyper|NTTIME|time_t|NTTIME_hyper|NTTIME_1sec|dlong|udlong|udlongr)$/)) {
- $self->pidl("PY_CHECK_TYPE(PyInt, $cvar, $fail);");
- $self->pidl("$target = PyInt_AsLong($cvar);");
- return;
- }
-
- if ($actual_ctype->{TYPE} eq "STRUCT" or $actual_ctype->{TYPE} eq "INTERFACE") {
- $self->pidl("PY_CHECK_TYPE($ctype->{NAME}, $cvar, $fail);");
- $self->assign($target, "py_talloc_get_ptr($cvar)");
- return;
- }
-
- if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "DATA_BLOB") {
- $self->pidl("$target = data_blob_talloc($mem_ctx, PyString_AsString($cvar), PyString_Size($cvar));");
- return;
- }
-
- if ($actual_ctype->{TYPE} eq "SCALAR" and
- ($actual_ctype->{NAME} eq "string" or $actual_ctype->{NAME} eq "nbt_string" or $actual_ctype->{NAME} eq "nbt_name" or $actual_ctype->{NAME} eq "wrepl_nbt_name")) {
- $self->pidl("$target = talloc_strdup($mem_ctx, PyString_AsString($cvar));");
- return;
- }
-
- if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "ipv4address") {
- $self->pidl("$target = PyString_AsString($cvar);");
- return;
- }
-
-
- if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "NTSTATUS") {
- $self->pidl("$target = NT_STATUS(PyInt_AsLong($cvar));");
- return;
- }
-
- if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "WERROR") {
- $self->pidl("$target = W_ERROR(PyInt_AsLong($cvar));");
- return;
- }
-
- if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "string_array") {
- $self->pidl("$target = PyCObject_AsVoidPtr($cvar);");
- return;
- }
-
- if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "pointer") {
- $self->assign($target, "PyCObject_AsVoidPtr($cvar)");
- return;
- }
-
- fatal($ctype, "unknown type $actual_ctype->{TYPE} for ".mapTypeName($ctype) . ": $cvar");
-
-}
-
-sub ConvertObjectFromPythonLevel($$$$$$$$)
-{
- my ($self, $env, $mem_ctx, $py_var, $e, $l, $var_name, $fail) = @_;
- my $nl = GetNextLevel($e, $l);
-
- if ($l->{TYPE} eq "POINTER") {
- if ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE})) {
- $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, $nl, $var_name, $fail);
- return;
- }
- if ($l->{POINTER_TYPE} ne "ref") {
- $self->pidl("if ($py_var == Py_None) {");
- $self->indent;
- $self->pidl("$var_name = NULL;");
- $self->deindent;
- $self->pidl("} else {");
- $self->indent;
- }
- $self->pidl("$var_name = talloc_ptrtype($mem_ctx, $var_name);");
- $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, $nl, get_value_of($var_name), $fail);
- if ($l->{POINTER_TYPE} ne "ref") {
- $self->deindent;
- $self->pidl("}");
- }
- } elsif ($l->{TYPE} eq "ARRAY") {
- my $pl = GetPrevLevel($e, $l);
- if ($pl && $pl->{TYPE} eq "POINTER") {
- $var_name = get_pointer_to($var_name);
- }
-
- if (is_charset_array($e, $l)) {
- $self->pidl("PY_CHECK_TYPE(PyUnicode, $py_var, $fail);");
- # FIXME: Use Unix charset setting rather than utf-8
- $self->pidl($var_name . " = PyString_AsString(PyUnicode_AsEncodedString($py_var, \"utf-8\", \"ignore\"));");
- } else {
- my $counter = "$e->{NAME}_cntr_$l->{LEVEL_INDEX}";
- $self->pidl("PY_CHECK_TYPE(PyList, $py_var, $fail);");
- $self->pidl("{");
- $self->indent;
- $self->pidl("int $counter;");
- if (!$l->{IS_FIXED}) {
- $self->pidl("$var_name = talloc_array_ptrtype($mem_ctx, $var_name, PyList_Size($py_var));");
- }
- $self->pidl("for ($counter = 0; $counter < PyList_Size($py_var); $counter++) {");
- $self->indent;
- $self->ConvertObjectFromPythonLevel($env, $var_name, "PyList_GetItem($py_var, $counter)", $e, GetNextLevel($e, $l), $var_name."[$counter]", $fail);
- $self->deindent;
- $self->pidl("}");
- $self->deindent;
- $self->pidl("}");
- }
- } elsif ($l->{TYPE} eq "DATA") {
-
- if (not Parse::Pidl::Typelist::is_scalar($l->{DATA_TYPE})) {
- $var_name = get_pointer_to($var_name);
- }
- $self->ConvertObjectFromPythonData($mem_ctx, $py_var, $l->{DATA_TYPE}, $var_name, $fail);
- } elsif ($l->{TYPE} eq "SWITCH") {
- $var_name = get_pointer_to($var_name);
- my $switch = ParseExpr($l->{SWITCH_IS}, $env, $e);
- $self->assign($var_name, "py_export_" . GetNextLevel($e, $l)->{DATA_TYPE} . "($mem_ctx, $switch, $py_var)");
- } elsif ($l->{TYPE} eq "SUBCONTEXT") {
- $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, GetNextLevel($e, $l), $var_name, $fail);
- } else {
- die("unknown level type $l->{TYPE}");
- }
-}
-
-sub ConvertObjectFromPython($$$$$$$)
-{
- my ($self, $env, $mem_ctx, $ctype, $cvar, $target, $fail) = @_;
-
- $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $cvar, $ctype, $ctype->{LEVELS}[0], $target, $fail);
-}
-
-sub ConvertScalarToPython($$$)
-{
- my ($self, $ctypename, $cvar) = @_;
-
- die("expected string for $cvar, not $ctypename") if (ref($ctypename) eq "HASH");
-
- $ctypename = expandAlias($ctypename);
-
- if ($ctypename =~ /^(char|u?int[0-9]*|hyper|dlong|udlong|udlongr|time_t|NTTIME_hyper|NTTIME|NTTIME_1sec)$/) {
- return "PyInt_FromLong($cvar)";
- }
-
- if ($ctypename eq "DATA_BLOB") {
- return "PyString_FromStringAndSize((char *)($cvar).data, ($cvar).length)";
- }
-
- if ($ctypename eq "NTSTATUS") {
- return "PyErr_FromNTSTATUS($cvar)";
- }
-
- if ($ctypename eq "WERROR") {
- return "PyErr_FromWERROR($cvar)";
- }
-
- if (($ctypename eq "string" or $ctypename eq "nbt_string" or $ctypename eq "nbt_name" or $ctypename eq "wrepl_nbt_name")) {
- return "PyString_FromString($cvar)";
- }
-
- # Not yet supported
- if ($ctypename eq "string_array") { return "PyCObject_FromVoidPtr($cvar)"; }
- if ($ctypename eq "ipv4address") { return "PyString_FromString($cvar)"; }
- if ($ctypename eq "pointer") {
- return "PyCObject_FromVoidPtr($cvar, talloc_free)";
- }
-
- die("Unknown scalar type $ctypename");
-}
-
-sub ConvertObjectToPythonData($$$$$)
-{
- my ($self, $mem_ctx, $ctype, $cvar) = @_;
-
- die("undef type for $cvar") unless(defined($ctype));
-
- $ctype = resolveType($ctype);
-
- my $actual_ctype = $ctype;
- if ($ctype->{TYPE} eq "TYPEDEF") {
- $actual_ctype = $ctype->{DATA};
- }
-
- if ($actual_ctype->{TYPE} eq "ENUM") {
- return $self->ConvertScalarToPython(Parse::Pidl::Typelist::enum_type_fn($actual_ctype), $cvar);
- } elsif ($actual_ctype->{TYPE} eq "BITMAP") {
- return $self->ConvertScalarToPython(Parse::Pidl::Typelist::bitmap_type_fn($actual_ctype), $cvar);
- } elsif ($actual_ctype->{TYPE} eq "SCALAR") {
- return $self->ConvertScalarToPython($actual_ctype->{NAME}, $cvar);
- } elsif ($actual_ctype->{TYPE} eq "UNION") {
- fatal($ctype, "union without discriminant: " . mapTypeName($ctype) . ": $cvar");
- } elsif ($actual_ctype->{TYPE} eq "STRUCT" or $actual_ctype->{TYPE} eq "INTERFACE") {
- return "py_talloc_import_ex(&$ctype->{NAME}_Type, $mem_ctx, $cvar)";
- }
-
- fatal($ctype, "unknown type $actual_ctype->{TYPE} for ".mapTypeName($ctype) . ": $cvar");
-}
-
-sub fail_on_null($$$)
-{
- my ($self, $var, $fail) = @_;
- $self->pidl("if ($var == NULL) {");
- $self->indent;
- $self->pidl($fail);
- $self->deindent;
- $self->pidl("}");
-}
-
-sub ConvertObjectToPythonLevel($$$$$$)
-{
- my ($self, $mem_ctx, $env, $e, $l, $var_name, $py_var, $fail) = @_;
- my $nl = GetNextLevel($e, $l);
-
- if ($l->{TYPE} eq "POINTER") {
- if ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE})) {
- $self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, $var_name, $py_var, $fail);
- return;
- }
- if ($l->{POINTER_TYPE} ne "ref") {
- $self->pidl("if ($var_name == NULL) {");
- $self->indent;
- $self->pidl("$py_var = Py_None;");
- $self->deindent;
- $self->pidl("} else {");
- $self->indent;
- }
- $self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, get_value_of($var_name), $py_var, $fail);
- if ($l->{POINTER_TYPE} ne "ref") {
- $self->deindent;
- $self->pidl("}");
- }
- } elsif ($l->{TYPE} eq "ARRAY") {
- my $pl = GetPrevLevel($e, $l);
- if ($pl && $pl->{TYPE} eq "POINTER") {
- $var_name = get_pointer_to($var_name);
- }
-
- if (is_charset_array($e, $l)) {
- # FIXME: Use Unix charset setting rather than utf-8
- $self->pidl("$py_var = PyUnicode_Decode($var_name, strlen($var_name), \"utf-8\", \"ignore\");");
- } else {
- die("No SIZE_IS for array $var_name") unless (defined($l->{SIZE_IS}));
- my $length = $l->{SIZE_IS};
- if (defined($l->{LENGTH_IS})) {
- $length = $l->{LENGTH_IS};
- }
-
- $length = ParseExpr($length, $env, $e);
- $self->pidl("$py_var = PyList_New($length);");
- $self->fail_on_null($py_var, $fail);
- $self->pidl("{");
- $self->indent;
- my $counter = "$e->{NAME}_cntr_$l->{LEVEL_INDEX}";
- $self->pidl("int $counter;");
- $self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
- $self->indent;
- my $member_var = "py_$e->{NAME}_$l->{LEVEL_INDEX}";
- $self->pidl("PyObject *$member_var;");
- $self->ConvertObjectToPythonLevel($var_name, $env, $e, GetNextLevel($e, $l), $var_name."[$counter]", $member_var, $fail);
- $self->pidl("PyList_SetItem($py_var, $counter, $member_var);");
- $self->deindent;
- $self->pidl("}");
- $self->deindent;
- $self->pidl("}");
- }
- } elsif ($l->{TYPE} eq "SWITCH") {
- $var_name = get_pointer_to($var_name);
- my $switch = ParseExpr($l->{SWITCH_IS}, $env, $e);
- $self->pidl("$py_var = py_import_" . GetNextLevel($e, $l)->{DATA_TYPE} . "($mem_ctx, $switch, $var_name);");
- $self->fail_on_null($py_var, $fail);
-
- } elsif ($l->{TYPE} eq "DATA") {
- if (not Parse::Pidl::Typelist::is_scalar($l->{DATA_TYPE})) {
- $var_name = get_pointer_to($var_name);
- }
- my $conv = $self->ConvertObjectToPythonData($mem_ctx, $l->{DATA_TYPE}, $var_name);
- $self->pidl("$py_var = $conv;");
- } elsif ($l->{TYPE} eq "SUBCONTEXT") {
- $self->ConvertObjectToPythonLevel($mem_ctx, $env, $e, GetNextLevel($e, $l), $var_name, $py_var, $fail);
- } else {
- die("Unknown level type $l->{TYPE} $var_name");
- }
-}
-
-sub ConvertObjectToPython($$$$$$)
-{
- my ($self, $mem_ctx, $env, $ctype, $cvar, $py_var, $fail) = @_;
-
- $self->ConvertObjectToPythonLevel($mem_ctx, $env, $ctype, $ctype->{LEVELS}[0], $cvar, $py_var, $fail);
-}
-
-sub Parse($$$$$)
-{
- my($self,$basename,$ndr,$ndr_hdr,$hdr) = @_;
-
- my $py_hdr = $hdr;
- $py_hdr =~ s/ndr_([^\/]+)$/py_$1/g;
-
- $self->pidl_hdr("/* header auto-generated by pidl */\n\n");
-
- $self->pidl("
-/* Python wrapper functions auto-generated by pidl */
-#include \"includes.h\"
-#include <Python.h>
-#include \"librpc/rpc/dcerpc.h\"
-#include \"scripting/python/pytalloc.h\"
-#include \"librpc/rpc/pyrpc.h\"
-#include \"lib/events/events.h\"
-#include \"$hdr\"
-#include \"$ndr_hdr\"
-#include \"$py_hdr\"
-
-");
-
- foreach my $x (@$ndr) {
- ($x->{TYPE} eq "IMPORT") && $self->Import(@{$x->{PATHS}});
- ($x->{TYPE} eq "INTERFACE") && $self->Interface($x, $basename);
- }
-
- $self->pidl("static PyMethodDef $basename\_methods[] = {");
- $self->indent;
- foreach (@{$self->{module_methods}}) {
- my ($fn_name, $pyfn_name, $flags, $doc) = @$_;
- $self->pidl("{ \"$fn_name\", (PyCFunction)$pyfn_name, $flags, $doc },");
- }
-
- $self->pidl("{ NULL, NULL, 0, NULL }");
- $self->deindent;
- $self->pidl("};");
-
- $self->pidl("");
-
- $self->pidl("void init$basename(void)");
- $self->pidl("{");
- $self->indent;
- $self->pidl("PyObject *m;");
- $self->pidl("");
-
- foreach (@{$self->{ready_types}}) {
- $self->pidl("if (PyType_Ready($_) < 0)");
- $self->pidl("\treturn;");
- }
-
- $self->pidl($_) foreach (@{$self->{readycode}});
-
- $self->pidl("");
-
- $self->pidl("m = Py_InitModule3(\"$basename\", $basename\_methods, \"$basename DCE/RPC\");");
- $self->pidl("if (m == NULL)");
- $self->pidl("\treturn;");
- $self->pidl("");
- foreach my $name (keys %{$self->{constants}}) {
- my $py_obj;
- my ($ctype, $cvar) = @{$self->{constants}->{$name}};
- if ($cvar =~ /^[0-9]+$/ or $cvar =~ /^0x[0-9a-fA-F]+$/) {
- $py_obj = "PyInt_FromLong($cvar)";
- } elsif ($cvar =~ /^".*"$/) {
- $py_obj = "PyString_FromString($cvar)";
- } else {
- $py_obj = $self->ConvertObjectToPythonData("NULL", expandAlias($ctype), $cvar);
- }
-
- $self->pidl("PyModule_AddObject(m, \"$name\", $py_obj);");
- }
-
- foreach (@{$self->{module_objects}}) {
- my ($object_name, $c_name) = @$_;
- $self->pidl("Py_INCREF($c_name);");
- $self->pidl("PyModule_AddObject(m, \"$object_name\", $c_name);");
- }
-
- $self->deindent;
- $self->pidl("}");
- return ($self->{res_hdr}, $self->{res});
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/SWIG.pm b/source4/pidl/lib/Parse/Pidl/Samba4/SWIG.pm
deleted file mode 100644
index 14424cf260..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Samba4/SWIG.pm
+++ /dev/null
@@ -1,177 +0,0 @@
-###################################################
-# Samba4 parser generator for swig wrappers
-# Copyright tpot@samba.org 2004,2005
-# Copyright jelmer@samba.org 2006
-# released under the GNU GPL
-
-package Parse::Pidl::Samba4::SWIG;
-
-use vars qw($VERSION);
-use Parse::Pidl::Samba4 qw(DeclLong);
-use Parse::Pidl::Typelist qw(mapTypeName);
-use Parse::Pidl::Util qw(has_property);
-$VERSION = '0.01';
-
-use strict;
-
-my $ret = "";
-my $tabs = "";
-
-sub pidl($)
-{
- my $p = shift;
- $ret .= $tabs. $p . "\n";
-}
-
-sub indent() { $tabs.=" "; }
-sub deindent() { $tabs = substr($tabs,0,-2); }
-
-sub IgnoreInterface($$)
-{
- my ($basename,$if) = @_;
-
- foreach (@{$if->{TYPES}}) {
- next unless (has_property($_, "public"));
- pidl "\%types($_->{NAME});";
- }
-}
-
-sub GenerateResultTypemap($)
-{
- my $name = shift;
- pidl "%typemap(in,numinputs=0) $name*result ($name tmp) {";
- indent;
- pidl "\$1 = &tmp;";
- deindent;
- pidl "}";
- pidl "";
- pidl "%typemap(argout) $name*result {";
- indent;
- pidl "\$result = SWIG_NewPointerObj(*\$1, \$1_descriptor, 0);";
- deindent;
- pidl "}";
-}
-
-sub ParseInterface($$)
-{
- my ($basename,$if) = @_;
-
- pidl "\%inline {";
- pidl "typedef struct $if->{NAME} { struct dcerpc_pipe *pipe; } $if->{NAME};";
- pidl "}";
- pidl "";
- pidl "%talloctype($if->{NAME});";
- pidl "";
- pidl "\%extend $if->{NAME} {";
- indent();
- pidl "$if->{NAME} () {";
- indent;
- pidl "return talloc(NULL, struct $if->{NAME});";
- deindent;
- pidl "}";
- pidl "";
- pidl "NTSTATUS connect (const char *binding, struct cli_credentials *cred, struct event_context *event)";
- pidl "{";
- indent;
- pidl "return dcerpc_pipe_connect(\$self, &\$self->pipe, binding, &ndr_table_$if->{NAME}, cred, event);";
- deindent;
- pidl "}";
- pidl "";
-
- foreach my $fn (@{$if->{FUNCTIONS}}) {
- pidl "/* $fn->{NAME} */";
- my $args = "";
- foreach (@{$fn->{ELEMENTS}}) {
- $args .= DeclLong($_) . ", ";
- }
- my $name = $fn->{NAME};
- $name =~ s/^$if->{NAME}_//g;
- $name =~ s/^$basename\_//g;
- $args .= "TALLOC_CTX *mem_ctx, " . mapTypeName($fn->{RETURN_TYPE}) . " *result";
- pidl "NTSTATUS $name($args)";
- pidl "{";
- indent;
- pidl "struct $fn->{NAME} r;";
- pidl "NTSTATUS status;";
- pidl "";
- pidl "/* Fill r structure */";
-
- foreach (@{$fn->{ELEMENTS}}) {
- if (grep(/in/, @{$_->{DIRECTION}})) {
- pidl "r.in.$_->{NAME} = $_->{NAME};";
- }
- }
-
- pidl "";
- pidl "status = dcerpc_$fn->{NAME}(\$self->pipe, mem_ctx, &r);";
- pidl "if (NT_STATUS_IS_ERR(status)) {";
- indent; pidl "return status;"; deindent;
- pidl "}";
- pidl "";
- pidl "/* Set out arguments */";
- foreach (@{$fn->{ELEMENTS}}) {
- next unless (grep(/out/, @{$_->{DIRECTION}}));
-
- pidl ("/* FIXME: $_->{NAME} [out] argument is not a pointer */") if ($_->{LEVELS}[0]->{TYPE} ne "POINTER");
-
- pidl "*$_->{NAME} = *r.out.$_->{NAME};";
- }
-
- if (defined($fn->{RETURN_TYPE})) {
- pidl "*result = r.out.result;";
- }
- pidl "return NT_STATUS_OK;";
- deindent;
- pidl "}";
- pidl "";
- }
-
- deindent();
- pidl "};";
- pidl "";
-
- foreach (@{$if->{TYPES}}) {
- pidl "/* $_->{NAME} */";
- }
-
- pidl "";
-}
-
-sub Parse($$$$)
-{
- my($ndr,$basename,$header,$gen_header) = @_;
-
- $ret = "";
-
- pidl "/* This file is autogenerated by pidl. DO NOT EDIT */";
-
- pidl "\%module $basename";
-
- pidl "";
-
- pidl "\%{";
- pidl "#include \"includes.h\"";
- pidl "#include \"$header\"";
- pidl "#include \"$gen_header\"";
- pidl "%}";
- pidl "\%import \"../rpc/dcerpc.i\"";
- pidl "\%import \"../../libcli/util/errors.i\"";
- pidl "\%import \"../../lib/talloc/talloc.i\"";
- pidl "";
- foreach (@$ndr) {
- IgnoreInterface($basename, $_) if ($_->{TYPE} eq "INTERFACE");
- }
- pidl "";
-
- pidl "";
-
- foreach (@$ndr) {
- ParseInterface($basename, $_) if ($_->{TYPE} eq "INTERFACE");
- }
- #FIXME: Foreach ref pointer, set NONNULL
- #FIXME: Foreach unique/full pointer, set MAYBENULL
- #FIXME: Foreach [out] parameter, set OUTPARAM
- return $ret;
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm b/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm
deleted file mode 100644
index 568dff5adf..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm
+++ /dev/null
@@ -1,281 +0,0 @@
-###################################################
-# Trivial Parser Generator
-# Copyright jelmer@samba.org 2005-2007
-# released under the GNU GPL
-
-package Parse::Pidl::Samba4::TDR;
-use Parse::Pidl qw(fatal);
-use Parse::Pidl::Util qw(has_property ParseExpr is_constant);
-use Parse::Pidl::Samba4 qw(is_intree choose_header);
-
-use Exporter;
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(ParserType $ret $ret_hdr);
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-use strict;
-
-sub new($) {
- my ($class) = shift;
- my $self = { ret => "", ret_hdr => "", tabs => "" };
- bless($self, $class);
-}
-
-sub indent($) { my $self = shift; $self->{tabs}.="\t"; }
-sub deindent($) { my $self = shift; $self->{tabs} = substr($self->{tabs}, 1); }
-sub pidl($$) { my $self = shift; $self->{ret} .= $self->{tabs}.(shift)."\n"; }
-sub pidl_hdr($$) { my $self = shift; $self->{ret_hdr} .= (shift)."\n"; }
-sub typearg($) {
- my $t = shift;
- return(", const char *name") if ($t eq "print");
- return(", TALLOC_CTX *mem_ctx") if ($t eq "pull");
- return("");
-}
-
-sub fn_declare($$$)
-{
- my ($self, $p, $d) = @_;
- if ($p) {
- $self->pidl($d); $self->pidl_hdr("$d;");
- } else {
- $self->pidl("static $d");
- }
-}
-
-sub ContainsArray($)
-{
- my $e = shift;
- foreach (@{$e->{ELEMENTS}}) {
- next if (has_property($_, "charset") and
- scalar(@{$_->{ARRAY_LEN}}) == 1);
- return 1 if (defined($_->{ARRAY_LEN}) and
- scalar(@{$_->{ARRAY_LEN}}) > 0);
- }
- return 0;
-}
-
-sub ParserElement($$$$)
-{
- my ($self, $e,$t,$env) = @_;
- my $switch = "";
- my $array = "";
- my $name = "";
- my $mem_ctx = "mem_ctx";
-
- fatal($e,"Pointers not supported in TDR") if ($e->{POINTERS} > 0);
- fatal($e,"size_is() not supported in TDR") if (has_property($e, "size_is"));
- fatal($e,"length_is() not supported in TDR") if (has_property($e, "length_is"));
-
- if ($t eq "print") {
- $name = ", \"$e->{NAME}\"$array";
- }
-
- if (has_property($e, "flag")) {
- $self->pidl("{");
- $self->indent;
- $self->pidl("uint32_t saved_flags = tdr->flags;");
- $self->pidl("tdr->flags |= $e->{PROPERTIES}->{flag};");
- }
-
- if (has_property($e, "charset")) {
- fatal($e,"charset() on non-array element") unless (defined($e->{ARRAY_LEN}) and scalar(@{$e->{ARRAY_LEN}}) > 0);
-
- my $len = ParseExpr(@{$e->{ARRAY_LEN}}[0], $env, $e);
- if ($len eq "*") { $len = "-1"; }
- $name = ", mem_ctx" if ($t eq "pull");
- $self->pidl("TDR_CHECK(tdr_$t\_charset(tdr$name, &v->$e->{NAME}, $len, sizeof($e->{TYPE}_t), CH_$e->{PROPERTIES}->{charset}));");
- return;
- }
-
- if (has_property($e, "switch_is")) {
- $switch = ", " . ParseExpr($e->{PROPERTIES}->{switch_is}, $env, $e);
- }
-
- if (defined($e->{ARRAY_LEN}) and scalar(@{$e->{ARRAY_LEN}}) > 0) {
- my $len = ParseExpr($e->{ARRAY_LEN}[0], $env, $e);
-
- if ($t eq "pull" and not is_constant($len)) {
- $self->pidl("TDR_ALLOC(mem_ctx, v->$e->{NAME}, $len);");
- $mem_ctx = "v->$e->{NAME}";
- }
-
- $self->pidl("for (i = 0; i < $len; i++) {");
- $self->indent;
- $array = "[i]";
- }
-
- if ($t eq "pull") {
- $name = ", $mem_ctx";
- }
-
- if (has_property($e, "value") && $t eq "push") {
- $self->pidl("v->$e->{NAME} = ".ParseExpr($e->{PROPERTIES}->{value}, $env, $e).";");
- }
-
- $self->pidl("TDR_CHECK(tdr_$t\_$e->{TYPE}(tdr$name$switch, &v->$e->{NAME}$array));");
-
- if ($array) { $self->deindent; $self->pidl("}"); }
-
- if (has_property($e, "flag")) {
- $self->pidl("tdr->flags = saved_flags;");
- $self->deindent;
- $self->pidl("}");
- }
-}
-
-sub ParserStruct($$$$$)
-{
- my ($self, $e,$t,$p) = @_;
-
- $self->fn_declare($p,"NTSTATUS tdr_$t\_$e->{NAME} (struct tdr_$t *tdr".typearg($t).", struct $e->{NAME} *v)");
- $self->pidl("{"); $self->indent;
- $self->pidl("int i;") if (ContainsArray($e));
-
- if ($t eq "print") {
- $self->pidl("tdr->print(tdr, \"\%-25s: struct $e->{NAME}\", name);");
- $self->pidl("tdr->level++;");
- }
-
- my %env = map { $_->{NAME} => "v->$_->{NAME}" } @{$e->{ELEMENTS}};
- $env{"this"} = "v";
- $self->ParserElement($_, $t, \%env) foreach (@{$e->{ELEMENTS}});
-
- if ($t eq "print") {
- $self->pidl("tdr->level--;");
- }
-
- $self->pidl("return NT_STATUS_OK;");
-
- $self->deindent; $self->pidl("}");
-}
-
-sub ParserUnion($$$$)
-{
- my ($self, $e,$t,$p) = @_;
-
- $self->fn_declare($p,"NTSTATUS tdr_$t\_$e->{NAME}(struct tdr_$t *tdr".typearg($t).", int level, union $e->{NAME} *v)");
- $self->pidl("{"); $self->indent;
- $self->pidl("int i;") if (ContainsArray($e));
-
- if ($t eq "print") {
- $self->pidl("tdr->print(tdr, \"\%-25s: union $e->{NAME}\", name);");
- $self->pidl("tdr->level++;");
- }
-
- $self->pidl("switch (level) {"); $self->indent;
- foreach (@{$e->{ELEMENTS}}) {
- if (has_property($_, "case")) {
- $self->pidl("case " . $_->{PROPERTIES}->{case} . ":");
- } elsif (has_property($_, "default")) {
- $self->pidl("default:");
- }
- $self->indent; $self->ParserElement($_, $t, {}); $self->deindent;
- $self->pidl("break;");
- }
- $self->deindent; $self->pidl("}");
-
- if ($t eq "print") {
- $self->pidl("tdr->level--;");
- }
-
- $self->pidl("return NT_STATUS_OK;\n");
- $self->deindent; $self->pidl("}");
-}
-
-sub ParserBitmap($$$$)
-{
- my ($self,$e,$t,$p) = @_;
- return if ($p);
- $self->pidl("#define tdr_$t\_$e->{NAME} tdr_$t\_" . Parse::Pidl::Typelist::bitmap_type_fn($e));
-}
-
-sub ParserEnum($$$$)
-{
- my ($self,$e,$t,$p) = @_;
- my $bt = Parse::Pidl::Typelist::enum_type_fn($e);
-
- $self->fn_declare($p, "NTSTATUS tdr_$t\_$e->{NAME} (struct tdr_$t *tdr".typearg($t).", enum $e->{NAME} *v)");
- $self->pidl("{");
- if ($t eq "pull") {
- $self->pidl("\t$bt\_t r;");
- $self->pidl("\tTDR_CHECK(tdr_$t\_$bt(tdr, mem_ctx, \&r));");
- $self->pidl("\t*v = r;");
- } elsif ($t eq "push") {
- $self->pidl("\tTDR_CHECK(tdr_$t\_$bt(tdr, ($bt\_t *)v));");
- } elsif ($t eq "print") {
- $self->pidl("\t/* FIXME */");
- }
- $self->pidl("\treturn NT_STATUS_OK;");
- $self->pidl("}");
-}
-
-sub ParserTypedef($$$$)
-{
- my ($self, $e,$t,$p) = @_;
-
- $self->ParserType($e->{DATA},$t);
-}
-
-sub ParserType($$$)
-{
- my ($self, $e,$t) = @_;
-
- return if (has_property($e, "no$t"));
-
- my $handlers = {
- STRUCT => \&ParserStruct, UNION => \&ParserUnion,
- ENUM => \&ParserEnum, BITMAP => \&ParserBitmap,
- TYPEDEF => \&ParserTypedef
- };
-
- $handlers->{$e->{TYPE}}->($self, $e, $t, has_property($e, "public"))
- if (defined($handlers->{$e->{TYPE}}));
-
- $self->pidl("");
-}
-
-sub ParserInterface($$)
-{
- my ($self,$x) = @_;
-
- $self->pidl_hdr("#ifndef __TDR_$x->{NAME}_HEADER__");
- $self->pidl_hdr("#define __TDR_$x->{NAME}_HEADER__");
-
- foreach (@{$x->{DATA}}) {
- $self->ParserType($_, "pull");
- $self->ParserType($_, "push");
- $self->ParserType($_, "print");
- }
-
- $self->pidl_hdr("#endif /* __TDR_$x->{NAME}_HEADER__ */");
-}
-
-sub Parser($$$$)
-{
- my ($self,$idl,$hdrname,$baseheader) = @_;
- $self->pidl("/* autogenerated by pidl */");
- if (is_intree()) {
- $self->pidl("#include \"includes.h\"");
- } else {
- $self->pidl("#include <stdio.h>");
- $self->pidl("#include <stdbool.h>");
- $self->pidl("#include <stdlib.h>");
- $self->pidl("#include <stdint.h>");
- $self->pidl("#include <stdarg.h>");
- $self->pidl("#include <string.h>");
- $self->pidl("#include <core/ntstatus.h>");
- }
- $self->pidl("#include \"$hdrname\"");
- $self->pidl("");
- $self->pidl_hdr("/* autogenerated by pidl */");
- $self->pidl_hdr("#include \"$baseheader\"");
- $self->pidl_hdr(choose_header("tdr/tdr.h", "tdr.h"));
- $self->pidl_hdr("");
-
- foreach (@$idl) { $self->ParserInterface($_) if ($_->{TYPE} eq "INTERFACE"); }
- return ($self->{ret_hdr}, $self->{ret});
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Template.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Template.pm
deleted file mode 100644
index a35fc7d2eb..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Template.pm
+++ /dev/null
@@ -1,98 +0,0 @@
-###################################################
-# server template function generator
-# Copyright tridge@samba.org 2003
-# released under the GNU GPL
-
-package Parse::Pidl::Samba4::Template;
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-use strict;
-
-my($res);
-
-#####################################################################
-# produce boilerplate code for a interface
-sub Template($)
-{
- my($interface) = shift;
- my($data) = $interface->{DATA};
- my $name = $interface->{NAME};
-
- $res .=
-"/*
- Unix SMB/CIFS implementation.
-
- endpoint server for the $name pipe
-
- Copyright (C) YOUR NAME HERE YEAR
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include \"includes.h\"
-#include \"rpc_server/dcerpc_server.h\"
-#include \"librpc/gen_ndr/ndr_$name.h\"
-#include \"rpc_server/common/common.h\"
-
-";
-
- foreach my $d (@{$data}) {
- if ($d->{TYPE} eq "FUNCTION") {
- my $fname = $d->{NAME};
- $res .=
-"
-/*
- $fname
-*/
-static $d->{RETURN_TYPE} dcesrv_$fname(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct $fname *r)
-{
-";
-
- if ($d->{RETURN_TYPE} eq "void") {
- $res .= "\tDCESRV_FAULT_VOID(DCERPC_FAULT_OP_RNG_ERROR);\n";
- } else {
- $res .= "\tDCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);\n";
- }
-
- $res .= "}
-
-";
- }
- }
-
- $res .=
-"
-/* include the generated boilerplate */
-#include \"librpc/gen_ndr/ndr_$name\_s.c\"
-"
-}
-
-
-#####################################################################
-# parse a parsed IDL structure back into an IDL file
-sub Parse($)
-{
- my($idl) = shift;
- $res = "";
- foreach my $x (@{$idl}) {
- ($x->{TYPE} eq "INTERFACE") &&
- Template($x);
- }
- return $res;
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Typelist.pm b/source4/pidl/lib/Parse/Pidl/Typelist.pm
deleted file mode 100644
index c5c458ac6b..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Typelist.pm
+++ /dev/null
@@ -1,301 +0,0 @@
-###################################################
-# Samba4 parser generator for IDL structures
-# Copyright jelmer@samba.org 2005
-# released under the GNU GPL
-
-package Parse::Pidl::Typelist;
-
-require Exporter;
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(hasType getType resolveType mapTypeName scalar_is_reference expandAlias
- mapScalarType addType typeIs is_scalar enum_type_fn
- bitmap_type_fn mapType typeHasBody
-);
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-use Parse::Pidl::Util qw(has_property);
-use strict;
-
-my %types = ();
-
-my @reference_scalars = (
- "string", "string_array", "nbt_string",
- "wrepl_nbt_name", "ipv4address"
-);
-
-# a list of known scalar types
-my %scalars = (
- "void" => "void",
- "char" => "char",
- "int8" => "int8_t",
- "uint8" => "uint8_t",
- "int16" => "int16_t",
- "uint16" => "uint16_t",
- "int32" => "int32_t",
- "uint32" => "uint32_t",
- "hyper" => "uint64_t",
- "dlong" => "int64_t",
- "udlong" => "uint64_t",
- "udlongr" => "uint64_t",
- "pointer" => "void*",
- "DATA_BLOB" => "DATA_BLOB",
- "string" => "const char *",
- "string_array" => "const char **",
- "time_t" => "time_t",
- "NTTIME" => "NTTIME",
- "NTTIME_1sec" => "NTTIME",
- "NTTIME_hyper" => "NTTIME",
- "WERROR" => "WERROR",
- "NTSTATUS" => "NTSTATUS",
- "COMRESULT" => "COMRESULT",
- "nbt_string" => "const char *",
- "wrepl_nbt_name"=> "struct nbt_name *",
- "ipv4address" => "const char *",
-);
-
-my %aliases = (
- "error_status_t" => "uint32",
- "boolean8" => "uint8",
- "boolean32" => "uint32",
- "DWORD" => "uint32",
- "uint" => "uint32",
- "int" => "int32",
- "WORD" => "uint16",
- "char" => "uint8",
- "long" => "int32",
- "short" => "int16",
- "HYPER_T" => "hyper",
- "HRESULT" => "COMRESULT",
-);
-
-sub expandAlias($)
-{
- my $name = shift;
-
- return $aliases{$name} if defined($aliases{$name});
-
- return $name;
-}
-
-# map from a IDL type to a C header type
-sub mapScalarType($)
-{
- my $name = shift;
-
- # it's a bug when a type is not in the list
- # of known scalars or has no mapping
- return $scalars{$name} if defined($scalars{$name});
-
- die("Unknown scalar type $name");
-}
-
-sub addType($)
-{
- my $t = shift;
- $types{$t->{NAME}} = $t;
-}
-
-sub resolveType($)
-{
- my ($ctype) = @_;
-
- if (not hasType($ctype)) {
- # assume struct typedef
- return { TYPE => "TYPEDEF", NAME => $ctype, DATA => { TYPE => "STRUCT" } };
- } else {
- return getType($ctype);
- }
-
- return $ctype;
-}
-
-sub getType($)
-{
- my $t = shift;
- return ($t) if (ref($t) eq "HASH" and not defined($t->{NAME}));
- return undef if not hasType($t);
- return $types{$t->{NAME}} if (ref($t) eq "HASH");
- return $types{$t};
-}
-
-sub typeIs($$)
-{
- my ($t,$tt) = @_;
-
- if (ref($t) eq "HASH") {
- return 1 if ($t->{TYPE} eq $tt);
- return 0;
- }
- return 1 if (hasType($t) and getType($t)->{TYPE} eq "TYPEDEF" and
- getType($t)->{DATA}->{TYPE} eq $tt);
- return 0;
-}
-
-sub hasType($)
-{
- my $t = shift;
- if (ref($t) eq "HASH") {
- return 1 if (not defined($t->{NAME}));
- return 1 if (defined($types{$t->{NAME}}) and
- $types{$t->{NAME}}->{TYPE} eq $t->{TYPE});
- return 0;
- }
- return 1 if defined($types{$t});
- return 0;
-}
-
-sub is_scalar($)
-{
- sub is_scalar($);
- my $type = shift;
-
- return 1 if (ref($type) eq "HASH" and
- ($type->{TYPE} eq "SCALAR" or $type->{TYPE} eq "ENUM" or
- $type->{TYPE} eq "BITMAP"));
-
- if (my $dt = getType($type)) {
- return is_scalar($dt->{DATA}) if ($dt->{TYPE} eq "TYPEDEF");
- return 1 if ($dt->{TYPE} eq "SCALAR" or $dt->{TYPE} eq "ENUM" or
- $dt->{TYPE} eq "BITMAP");
- }
-
- return 0;
-}
-
-sub scalar_is_reference($)
-{
- my $name = shift;
-
- return 1 if (grep(/^$name$/, @reference_scalars));
- return 0;
-}
-
-sub RegisterScalars()
-{
- foreach (keys %scalars) {
- addType({
- NAME => $_,
- TYPE => "TYPEDEF",
- DATA => {
- TYPE => "SCALAR",
- NAME => $_
- }
- }
- );
- }
-}
-
-sub enum_type_fn($)
-{
- my $enum = shift;
- $enum->{TYPE} eq "ENUM" or die("not an enum");
-
- # for typedef enum { } we need to check $enum->{PARENT}
- if (has_property($enum, "enum8bit")) {
- return "uint8";
- } elsif (has_property($enum, "enum16bit")) {
- return "uint16";
- } elsif (has_property($enum, "v1_enum")) {
- return "uint32";
- } elsif (has_property($enum->{PARENT}, "enum8bit")) {
- return "uint8";
- } elsif (has_property($enum->{PARENT}, "enum16bit")) {
- return "uint16";
- } elsif (has_property($enum->{PARENT}, "v1_enum")) {
- return "uint32";
- }
- return "uint16";
-}
-
-sub bitmap_type_fn($)
-{
- my $bitmap = shift;
-
- $bitmap->{TYPE} eq "BITMAP" or die("not a bitmap");
-
- if (has_property($bitmap, "bitmap8bit")) {
- return "uint8";
- } elsif (has_property($bitmap, "bitmap16bit")) {
- return "uint16";
- } elsif (has_property($bitmap, "bitmap64bit")) {
- return "hyper";
- }
- return "uint32";
-}
-
-sub typeHasBody($)
-{
- sub typeHasBody($);
- my ($e) = @_;
-
- if ($e->{TYPE} eq "TYPEDEF") {
- return 0 unless(defined($e->{DATA}));
- return typeHasBody($e->{DATA});
- }
-
- return defined($e->{ELEMENTS});
-}
-
-sub mapType($$)
-{
- sub mapType($$);
- my ($t, $n) = @_;
-
- return mapType($t->{DATA}, $n) if ($t->{TYPE} eq "TYPEDEF");
- return mapScalarType($n) if ($t->{TYPE} eq "SCALAR");
- return "enum $n" if ($t->{TYPE} eq "ENUM");
- return "struct $n" if ($t->{TYPE} eq "STRUCT" or $t->{TYPE} eq "INTERFACE");
- return "union $n" if ($t->{TYPE} eq "UNION");
- return mapScalarType(bitmap_type_fn($t)) if ($t->{TYPE} eq "BITMAP");
- die("Unknown type $t->{TYPE}");
-}
-
-sub mapTypeName($)
-{
- my $t = shift;
- return "void" unless defined($t);
- my $dt;
- $t = expandAlias($t);
-
- unless ($dt or ($dt = getType($t))) {
- # Best guess
- return "struct $t";
- }
-
- return mapType($dt, $dt->{NAME});
-}
-
-sub LoadIdl($)
-{
- my ($idl) = @_;
-
- foreach my $x (@{$idl}) {
- next if $x->{TYPE} ne "INTERFACE";
-
- # DCOM interfaces can be types as well
- addType({
- NAME => $x->{NAME},
- TYPE => "TYPEDEF",
- DATA => $x
- }) if (has_property($x, "object"));
-
- foreach my $y (@{$x->{DATA}}) {
- addType($y) if (
- $y->{TYPE} eq "TYPEDEF"
- or $y->{TYPE} eq "UNION"
- or $y->{TYPE} eq "STRUCT"
- or $y->{TYPE} eq "ENUM"
- or $y->{TYPE} eq "BITMAP");
- }
- }
-}
-
-sub GenerateTypeLib()
-{
- return Parse::Pidl::Util::MyDumper(\%types);
-}
-
-RegisterScalars();
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Util.pm b/source4/pidl/lib/Parse/Pidl/Util.pm
deleted file mode 100644
index 006718d139..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Util.pm
+++ /dev/null
@@ -1,182 +0,0 @@
-###################################################
-# utility functions to support pidl
-# Copyright tridge@samba.org 2000
-# released under the GNU GPL
-package Parse::Pidl::Util;
-
-require Exporter;
-@ISA = qw(Exporter);
-@EXPORT = qw(has_property property_matches ParseExpr ParseExprExt is_constant make_str unmake_str print_uuid MyDumper);
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-use strict;
-
-use Parse::Pidl::Expr;
-use Parse::Pidl qw(error);
-
-=head1 NAME
-
-Parse::Pidl::Util - Generic utility functions for pidl
-
-=head1 SYNOPSIS
-
-use Parse::Pidl::Util;
-
-=head1 DESCRIPTION
-
-Simple module that contains a couple of trivial helper functions
-used throughout the various pidl modules.
-
-=head1 FUNCTIONS
-
-=over 4
-
-=cut
-
-=item B<MyDumper>
-a dumper wrapper to prevent dependence on the Data::Dumper module
-unless we actually need it
-
-=cut
-
-sub MyDumper($)
-{
- require Data::Dumper;
- my $s = shift;
- return Data::Dumper::Dumper($s);
-}
-
-=item B<has_property>
-see if a pidl property list contains a given property
-
-=cut
-sub has_property($$)
-{
- my($e, $p) = @_;
-
- return undef if (not defined($e->{PROPERTIES}));
-
- return $e->{PROPERTIES}->{$p};
-}
-
-=item B<property_matches>
-see if a pidl property matches a value
-
-=cut
-sub property_matches($$$)
-{
- my($e,$p,$v) = @_;
-
- if (!defined has_property($e, $p)) {
- return undef;
- }
-
- if ($e->{PROPERTIES}->{$p} =~ /$v/) {
- return 1;
- }
-
- return undef;
-}
-
-=item B<is_constant>
-return 1 if the string is a C constant
-
-=cut
-sub is_constant($)
-{
- my $s = shift;
- return 1 if ($s =~ /^\d+$/);
- return 1 if ($s =~ /^0x[0-9A-Fa-f]+$/);
- return 0;
-}
-
-=item B<make_str>
-return a "" quoted string, unless already quoted
-
-=cut
-sub make_str($)
-{
- my $str = shift;
- if (substr($str, 0, 1) eq "\"") {
- return $str;
- }
- return "\"$str\"";
-}
-
-=item B<unmake_str>
-unquote a "" quoted string
-
-=cut
-sub unmake_str($)
-{
- my $str = shift;
-
- $str =~ s/^\"(.*)\"$/$1/;
-
- return $str;
-}
-
-=item B<print_uuid>
-Print C representation of a UUID.
-
-=cut
-sub print_uuid($)
-{
- my ($uuid) = @_;
- $uuid =~ s/"//g;
- my ($time_low,$time_mid,$time_hi,$clock_seq,$node) = split /-/, $uuid;
- return undef if not defined($node);
-
- my @clock_seq = $clock_seq =~ /(..)/g;
- my @node = $node =~ /(..)/g;
-
- return "{0x$time_low,0x$time_mid,0x$time_hi," .
- "{".join(',', map {"0x$_"} @clock_seq)."}," .
- "{".join(',', map {"0x$_"} @node)."}}";
-}
-
-=item B<ParseExpr>
-Interpret an IDL expression, substituting particular variables.
-
-=cut
-sub ParseExpr($$$)
-{
- my($expr, $varlist, $e) = @_;
-
- my $x = new Parse::Pidl::Expr();
-
- return $x->Run($expr, sub { my $x = shift; error($e, $x); },
- # Lookup fn
- sub { my $x = shift;
- return($varlist->{$x}) if (defined($varlist->{$x}));
- return $x;
- },
- undef, undef);
-}
-
-=item B<ParseExprExt>
-Interpret an IDL expression, substituting particular variables. Can call
-callbacks when pointers are being dereferenced or variables are being used.
-
-=cut
-sub ParseExprExt($$$$$)
-{
- my($expr, $varlist, $e, $deref, $use) = @_;
-
- my $x = new Parse::Pidl::Expr();
-
- return $x->Run($expr, sub { my $x = shift; error($e, $x); },
- # Lookup fn
- sub { my $x = shift;
- return($varlist->{$x}) if (defined($varlist->{$x}));
- return $x;
- },
- $deref, $use);
-}
-
-=back
-
-=cut
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm b/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
deleted file mode 100644
index 5c37b4a0c4..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
+++ /dev/null
@@ -1,439 +0,0 @@
-###################################################
-# parse an Wireshark conformance file
-# Copyright jelmer@samba.org 2005
-# released under the GNU GPL
-
-=pod
-
-=head1 NAME
-
-Parse::Pidl::Wireshark::Conformance - Conformance file parser for Wireshark
-
-=head1 DESCRIPTION
-
-This module supports parsing Wireshark conformance files (*.cnf).
-
-=head1 FILE FORMAT
-
-Pidl needs additional data for Wireshark output. This data is read from
-so-called conformance files. This section describes the format of these
-files.
-
-Conformance files are simple text files with a single command on each line.
-Empty lines and lines starting with a '#' character are ignored.
-Arguments to commands are seperated by spaces.
-
-The following commands are currently supported:
-
-=over 4
-
-=item I<TYPE> name dissector ft_type base_type mask valsstring alignment
-
-Register new data type with specified name, what dissector function to call
-and what properties to give header fields for elements of this type.
-
-=item I<NOEMIT> type
-
-Suppress emitting a dissect_type function for the specified type
-
-=item I<PARAM_VALUE> type param
-
-Set parameter to specify to dissector function for given type.
-
-=item I<HF_FIELD> hf title filter ft_type base_type valsstring mask description
-
-Generate a custom header field with specified properties.
-
-=item I<HF_RENAME> old_hf_name new_hf_name
-
-Force the use of new_hf_name when the parser generator was going to
-use old_hf_name.
-
-This can be used in conjunction with HF_FIELD in order to make more than
-one element use the same filter name.
-
-=item I<ETT_FIELD> ett
-
-Register a custom ett field
-
-=item I<STRIP_PREFIX> prefix
-
-Remove the specified prefix from all function names (if present).
-
-=item I<PROTOCOL> longname shortname filtername
-
-Change the short-, long- and filter-name for the current interface in
-Wireshark.
-
-=item I<FIELD_DESCRIPTION> field desc
-
-Change description for the specified header field. `field' is the hf name of the field.
-
-=item I<IMPORT> dissector code...
-
-Code to insert when generating the specified dissector. @HF@ and
-@PARAM@ will be substituted.
-
-=item I<INCLUDE> filename
-
-Include conformance data from the specified filename in the dissector.
-
-=item I<TFS> hf_name "true string" "false string"
-
-Override the text shown when a bitmap boolean value is enabled or disabled.
-
-=item I<MANUAL> fn_name
-
-Force pidl to not generate a particular function but allow the user
-to write a function manually. This can be used to remove the function
-for only one level for a particular element rather than all the functions and
-ett/hf variables for a particular element as the NOEMIT command does.
-
-=back
-
-=head1 EXAMPLE
-
- INFO_KEY OpenKey.Ke
-
-=cut
-
-package Parse::Pidl::Wireshark::Conformance;
-
-require Exporter;
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(ReadConformance ReadConformanceFH valid_ft_type valid_base_type);
-
-use strict;
-
-use Parse::Pidl qw(fatal warning error);
-use Parse::Pidl::Util qw(has_property);
-
-sub handle_type($$$$$$$$$$)
-{
- my ($pos,$data,$name,$dissectorname,$ft_type,$base_type,$mask,$valsstring,$alignment) = @_;
-
- unless(defined($alignment)) {
- error($pos, "incomplete TYPE command");
- return;
- }
-
- unless ($dissectorname =~ /.*dissect_.*/) {
- warning($pos, "dissector name does not contain `dissect'");
- }
-
- unless(valid_ft_type($ft_type)) {
- warning($pos, "invalid FT_TYPE `$ft_type'");
- }
-
- unless (valid_base_type($base_type)) {
- warning($pos, "invalid BASE_TYPE `$base_type'");
- }
-
- $dissectorname =~ s/^\"(.*)\"$/$1/g;
-
- if (not ($dissectorname =~ /;$/)) {
- warning($pos, "missing semicolon");
- }
-
- $data->{types}->{$name} = {
- NAME => $name,
- POS => $pos,
- USED => 0,
- DISSECTOR_NAME => $dissectorname,
- FT_TYPE => $ft_type,
- BASE_TYPE => $base_type,
- MASK => $mask,
- VALSSTRING => $valsstring,
- ALIGNMENT => $alignment
- };
-}
-
-sub handle_tfs($$$$$)
-{
- my ($pos,$data,$hf,$trues,$falses) = @_;
-
- unless(defined($falses)) {
- error($pos, "incomplete TFS command");
- return;
- }
-
- $data->{tfs}->{$hf} = {
- TRUE_STRING => $trues,
- FALSE_STRING => $falses
- };
-}
-
-sub handle_hf_rename($$$$)
-{
- my ($pos,$data,$old,$new) = @_;
-
- unless(defined($new)) {
- warning($pos, "incomplete HF_RENAME command");
- return;
- }
-
- $data->{hf_renames}->{$old} = {
- OLDNAME => $old,
- NEWNAME => $new,
- POS => $pos,
- USED => 0
- };
-}
-
-sub handle_param_value($$$$)
-{
- my ($pos,$data,$dissector_name,$value) = @_;
-
- unless(defined($value)) {
- error($pos, "incomplete PARAM_VALUE command");
- return;
- }
-
- $data->{dissectorparams}->{$dissector_name} = {
- DISSECTOR => $dissector_name,
- PARAM => $value,
- POS => $pos,
- USED => 0
- };
-}
-
-sub valid_base_type($)
-{
- my $t = shift;
- return 0 unless($t =~ /^BASE_.*/);
- return 1;
-}
-
-sub valid_ft_type($)
-{
- my $t = shift;
- return 0 unless($t =~ /^FT_.*/);
- return 1;
-}
-
-sub handle_hf_field($$$$$$$$$$)
-{
- my ($pos,$data,$index,$name,$filter,$ft_type,$base_type,$valsstring,$mask,$blurb) = @_;
-
- unless(defined($blurb)) {
- error($pos, "incomplete HF_FIELD command");
- return;
- }
-
- unless(valid_ft_type($ft_type)) {
- warning($pos, "invalid FT_TYPE `$ft_type'");
- }
-
- unless(valid_base_type($base_type)) {
- warning($pos, "invalid BASE_TYPE `$base_type'");
- }
-
- $data->{header_fields}->{$index} = {
- INDEX => $index,
- POS => $pos,
- USED => 0,
- NAME => $name,
- FILTER => $filter,
- FT_TYPE => $ft_type,
- BASE_TYPE => $base_type,
- VALSSTRING => $valsstring,
- MASK => $mask,
- BLURB => $blurb
- };
-}
-
-sub handle_strip_prefix($$$)
-{
- my ($pos,$data,$x) = @_;
-
- push (@{$data->{strip_prefixes}}, $x);
-}
-
-sub handle_noemit($$$)
-{
- my ($pos,$data,$type) = @_;
-
- if (defined($type)) {
- $data->{noemit}->{$type} = 1;
- } else {
- $data->{noemit_dissector} = 1;
- }
-}
-
-sub handle_manual($$$)
-{
- my ($pos,$data,$fn) = @_;
-
- unless(defined($fn)) {
- warning($pos, "incomplete MANUAL command");
- return;
- }
-
- $data->{manual}->{$fn} = 1;
-}
-
-sub handle_protocol($$$$$$)
-{
- my ($pos, $data, $name, $longname, $shortname, $filtername) = @_;
-
- $data->{protocols}->{$name} = {
- LONGNAME => $longname,
- SHORTNAME => $shortname,
- FILTERNAME => $filtername
- };
-}
-
-sub handle_fielddescription($$$$)
-{
- my ($pos,$data,$field,$desc) = @_;
-
- unless(defined($desc)) {
- warning($pos, "incomplete FIELD_DESCRIPTION command");
- return;
- }
-
- $data->{fielddescription}->{$field} = {
- DESCRIPTION => $desc,
- POS => $pos,
- USED => 0
- };
-}
-
-sub handle_import
-{
- my $pos = shift @_;
- my $data = shift @_;
- my $dissectorname = shift @_;
-
- unless(defined($dissectorname)) {
- error($pos, "no dissectorname specified");
- return;
- }
-
- $data->{imports}->{$dissectorname} = {
- NAME => $dissectorname,
- DATA => join(' ', @_),
- USED => 0,
- POS => $pos
- };
-}
-
-sub handle_ett_field
-{
- my $pos = shift @_;
- my $data = shift @_;
- my $ett = shift @_;
-
- unless(defined($ett)) {
- error($pos, "incomplete ETT_FIELD command");
- return;
- }
-
- push (@{$data->{ett}}, $ett);
-}
-
-sub handle_include
-{
- my $pos = shift @_;
- my $data = shift @_;
- my $fn = shift @_;
-
- unless(defined($fn)) {
- error($pos, "incomplete INCLUDE command");
- return;
- }
-
- ReadConformance($fn, $data);
-}
-
-my %field_handlers = (
- TYPE => \&handle_type,
- NOEMIT => \&handle_noemit,
- MANUAL => \&handle_manual,
- PARAM_VALUE => \&handle_param_value,
- HF_FIELD => \&handle_hf_field,
- HF_RENAME => \&handle_hf_rename,
- ETT_FIELD => \&handle_ett_field,
- TFS => \&handle_tfs,
- STRIP_PREFIX => \&handle_strip_prefix,
- PROTOCOL => \&handle_protocol,
- FIELD_DESCRIPTION => \&handle_fielddescription,
- IMPORT => \&handle_import,
- INCLUDE => \&handle_include
-);
-
-sub ReadConformance($$)
-{
- my ($f,$data) = @_;
- my $ret;
-
- open(IN,"<$f") or return undef;
-
- $ret = ReadConformanceFH(*IN, $data, $f);
-
- close(IN);
-
- return $ret;
-}
-
-sub ReadConformanceFH($$$)
-{
- my ($fh,$data,$f) = @_;
-
- my $incodeblock = 0;
-
- my $ln = 0;
-
- foreach (<$fh>) {
- $ln++;
- next if (/^#.*$/);
- next if (/^$/);
-
- s/[\r\n]//g;
-
- if ($_ eq "CODE START") {
- $incodeblock = 1;
- next;
- } elsif ($incodeblock and $_ eq "CODE END") {
- $incodeblock = 0;
- next;
- } elsif ($incodeblock) {
- if (exists $data->{override}) {
- $data->{override}.="$_\n";
- } else {
- $data->{override} = "$_\n";
- }
- next;
- }
-
- my @fields = /([^ "]+|"[^"]+")/g;
-
- my $cmd = $fields[0];
-
- shift @fields;
-
- my $pos = { FILE => $f, LINE => $ln };
-
- next unless(defined($cmd));
-
- if (not defined($field_handlers{$cmd})) {
- warning($pos, "Unknown command `$cmd'");
- next;
- }
-
- $field_handlers{$cmd}($pos, $data, @fields);
- }
-
- if ($incodeblock) {
- warning({ FILE => $f, LINE => $ln },
- "Expecting CODE END");
- return undef;
- }
-
- return 1;
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
deleted file mode 100644
index 8846b740ab..0000000000
--- a/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
+++ /dev/null
@@ -1,1141 +0,0 @@
-##################################################
-# Samba4 NDR parser generator for IDL structures
-# Copyright tridge@samba.org 2000-2003
-# Copyright tpot@samba.org 2001,2005
-# Copyright jelmer@samba.org 2004-2007
-# Portions based on idl2eth.c by Ronnie Sahlberg
-# released under the GNU GPL
-
-=pod
-
-=head1 NAME
-
-Parse::Pidl::Wireshark::NDR - Parser generator for Wireshark
-
-=cut
-
-package Parse::Pidl::Wireshark::NDR;
-
-use Exporter;
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(field2name %res PrintIdl StripPrefixes RegisterInterfaceHandoff register_hf_field CheckUsed ProcessImport ProcessInclude find_type DumpEttList DumpEttDeclaration DumpHfList DumpHfDeclaration DumpFunctionTable register_type register_ett);
-
-use strict;
-use Parse::Pidl qw(error warning);
-use Parse::Pidl::Typelist qw(getType);
-use Parse::Pidl::Util qw(has_property property_matches make_str);
-use Parse::Pidl::NDR qw(ContainsString GetNextLevel);
-use Parse::Pidl::Dump qw(DumpType DumpFunction);
-use Parse::Pidl::Wireshark::Conformance qw(ReadConformance);
-use File::Basename;
-
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-my %return_types = ();
-my %dissector_used = ();
-
-my %ptrtype_mappings = (
- "unique" => "NDR_POINTER_UNIQUE",
- "ref" => "NDR_POINTER_REF",
- "ptr" => "NDR_POINTER_PTR"
-);
-
-sub StripPrefixes($$)
-{
- my ($s, $prefixes) = @_;
-
- foreach (@$prefixes) {
- $s =~ s/^$_\_//g;
- }
-
- return $s;
-}
-
-# Convert a IDL structure field name (e.g access_mask) to a prettier
-# string like 'Access Mask'.
-
-sub field2name($)
-{
- my($field) = shift;
-
- $field =~ s/_/ /g; # Replace underscores with spaces
- $field =~ s/(\w+)/\u\L$1/g; # Capitalise each word
-
- return $field;
-}
-
-sub new($)
-{
- my ($class) = @_;
- my $self = {res => {hdr => "", def => "", code => ""}, tabs => "", cur_fn => undef,
- hf_used => {}, ett => [], conformance => undef
-
- };
- bless($self, $class);
-}
-
-sub pidl_fn_start($$)
-{
- my ($self, $fn) = @_;
- $self->{cur_fn} = $fn;
-}
-sub pidl_fn_end($$)
-{
- my ($self, $fn) = @_;
- die("Inconsistent state: $fn != $self->{cur_fn}") if ($fn ne $self->{cur_fn});
- $self->{cur_fn} = undef;
-}
-
-sub pidl_code($$)
-{
- my ($self, $d) = @_;
- return if (defined($self->{cur_fn}) and defined($self->{conformance}->{manual}->{$self->{cur_fn}}));
-
- if ($d) {
- $self->{res}->{code} .= $self->{tabs};
- $self->{res}->{code} .= $d;
- }
- $self->{res}->{code} .="\n";
-}
-
-sub pidl_hdr($$) { my ($self,$x) = @_; $self->{res}->{hdr} .= "$x\n"; }
-sub pidl_def($$) { my ($self,$x) = @_; $self->{res}->{def} .= "$x\n"; }
-
-sub indent($)
-{
- my ($self) = @_;
- $self->{tabs} .= "\t";
-}
-
-sub deindent($)
-{
- my ($self) = @_;
- $self->{tabs} = substr($self->{tabs}, 0, -1);
-}
-
-sub PrintIdl($$)
-{
- my ($self, $idl) = @_;
-
- foreach (split /\n/, $idl) {
- $self->pidl_code("/* IDL: $_ */");
- }
-
- $self->pidl_code("");
-}
-
-#####################################################################
-# parse the interface definitions
-sub Interface($$)
-{
- my($self, $interface) = @_;
- $self->Const($_,$interface->{NAME}) foreach (@{$interface->{CONSTS}});
- $self->Type($_, $_->{NAME}, $interface->{NAME}) foreach (@{$interface->{TYPES}});
- $self->Function($_,$interface->{NAME}) foreach (@{$interface->{FUNCTIONS}});
-}
-
-sub Enum($$$$)
-{
- my ($self, $e,$name,$ifname) = @_;
- my $valsstring = "$ifname\_$name\_vals";
- my $dissectorname = "$ifname\_dissect\_enum\_".StripPrefixes($name, $self->{conformance}->{strip_prefixes});
-
- return if (defined($self->{conformance}->{noemit}->{StripPrefixes($name, $self->{conformance}->{strip_prefixes})}));
-
- foreach (@{$e->{ELEMENTS}}) {
- if (/([^=]*)=(.*)/) {
- $self->pidl_hdr("#define $1 ($2)");
- }
- }
-
- $self->pidl_hdr("extern const value_string $valsstring\[];");
- $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 *param _U_);");
-
- $self->pidl_def("const value_string ".$valsstring."[] = {");
- foreach (@{$e->{ELEMENTS}}) {
- next unless (/([^=]*)=(.*)/);
- $self->pidl_def("\t{ $1, \"$1\" },");
- }
-
- $self->pidl_def("{ 0, NULL }");
- $self->pidl_def("};");
-
- $self->pidl_fn_start($dissectorname);
- $self->pidl_code("int");
- $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 *param _U_)");
- $self->pidl_code("{");
- $self->indent;
- $self->pidl_code("g$e->{BASE_TYPE} parameter=0;");
- $self->pidl_code("if(param){");
- $self->indent;
- $self->pidl_code("parameter=(g$e->{BASE_TYPE})*param;");
- $self->deindent;
- $self->pidl_code("}");
- $self->pidl_code("offset = dissect_ndr_$e->{BASE_TYPE}(tvb, offset, pinfo, tree, drep, hf_index, &parameter);");
- $self->pidl_code("if(param){");
- $self->indent;
- $self->pidl_code("*param=(guint32)parameter;");
- $self->deindent;
- $self->pidl_code("}");
- $self->pidl_code("return offset;");
- $self->deindent;
- $self->pidl_code("}\n");
- $self->pidl_fn_end($dissectorname);
-
- my $enum_size = $e->{BASE_TYPE};
- $enum_size =~ s/uint//g;
- $self->register_type($name, "offset = $dissectorname(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);", "FT_UINT$enum_size", "BASE_DEC", "0", "VALS($valsstring)", $enum_size / 8);
-}
-
-sub Bitmap($$$$)
-{
- my ($self,$e,$name,$ifname) = @_;
- my $dissectorname = "$ifname\_dissect\_bitmap\_".StripPrefixes($name, $self->{conformance}->{strip_prefixes});
-
- $self->register_ett("ett_$ifname\_$name");
-
- $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_);");
-
- $self->pidl_fn_start($dissectorname);
- $self->pidl_code("int");
- $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)");
- $self->pidl_code("{");
- $self->indent;
- $self->pidl_code("proto_item *item = NULL;");
- $self->pidl_code("proto_tree *tree = NULL;");
- $self->pidl_code("");
-
- $self->pidl_code("g$e->{BASE_TYPE} flags;");
- if ($e->{ALIGN} > 1) {
- $self->pidl_code("ALIGN_TO_$e->{ALIGN}_BYTES;");
- }
-
- $self->pidl_code("");
-
- $self->pidl_code("if (parent_tree) {");
- $self->indent;
- $self->pidl_code("item = proto_tree_add_item(parent_tree, hf_index, tvb, offset, $e->{ALIGN}, TRUE);");
- $self->pidl_code("tree = proto_item_add_subtree(item,ett_$ifname\_$name);");
- $self->deindent;
- $self->pidl_code("}\n");
-
- $self->pidl_code("offset = dissect_ndr_$e->{BASE_TYPE}(tvb, offset, pinfo, NULL, drep, -1, &flags);");
-
- $self->pidl_code("proto_item_append_text(item, \": \");\n");
- $self->pidl_code("if (!flags)");
- $self->pidl_code("\tproto_item_append_text(item, \"(No values set)\");\n");
-
- foreach (@{$e->{ELEMENTS}}) {
- next unless (/([^ ]*) (.*)/);
- my ($en,$ev) = ($1,$2);
- my $hf_bitname = "hf_$ifname\_$name\_$en";
- my $filtername = "$ifname\.$name\.$en";
-
- $self->{hf_used}->{$hf_bitname} = 1;
-
- $self->register_hf_field($hf_bitname, field2name($en), $filtername, "FT_BOOLEAN", $e->{ALIGN} * 8, "TFS(&$name\_$en\_tfs)", $ev, "");
-
- $self->pidl_def("static const true_false_string $name\_$en\_tfs = {");
- if (defined($self->{conformance}->{tfs}->{$hf_bitname})) {
- $self->pidl_def(" $self->{conformance}->{tfs}->{$hf_bitname}->{TRUE_STRING},");
- $self->pidl_def(" $self->{conformance}->{tfs}->{$hf_bitname}->{FALSE_STRING},");
- $self->{conformance}->{tfs}->{$hf_bitname}->{USED} = 1;
- } else {
- $self->pidl_def(" \"$en is SET\",");
- $self->pidl_def(" \"$en is NOT SET\",");
- }
- $self->pidl_def("};");
-
- $self->pidl_code("proto_tree_add_boolean(tree, $hf_bitname, tvb, offset-$e->{ALIGN}, $e->{ALIGN}, flags);");
- $self->pidl_code("if (flags&$ev){");
- $self->pidl_code("\tproto_item_append_text(item, \"$en\");");
- $self->pidl_code("\tif (flags & (~$ev))");
- $self->pidl_code("\t\tproto_item_append_text(item, \", \");");
- $self->pidl_code("}");
- $self->pidl_code("flags&=(~$ev);");
- $self->pidl_code("");
- }
-
- $self->pidl_code("if (flags) {");
- $self->pidl_code("\tproto_item_append_text(item, \"Unknown bitmap value 0x%x\", flags);");
- $self->pidl_code("}\n");
- $self->pidl_code("return offset;");
- $self->deindent;
- $self->pidl_code("}\n");
- $self->pidl_fn_end($dissectorname);
-
- my $size = $e->{BASE_TYPE};
- $size =~ s/uint//g;
- $self->register_type($name, "offset = $dissectorname(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);", "FT_UINT$size", "BASE_HEX", "0", "NULL", $size/8);
-}
-
-sub ElementLevel($$$$$$$)
-{
- my ($self,$e,$l,$hf,$myname,$pn,$ifname) = @_;
-
- my $param = 0;
-
- if (defined($self->{conformance}->{dissectorparams}->{$myname})) {
- $param = $self->{conformance}->{dissectorparams}->{$myname}->{PARAM};
- }
-
- if ($l->{TYPE} eq "POINTER") {
- my $type;
- if ($l->{LEVEL} eq "TOP") {
- $type = "toplevel";
- } elsif ($l->{LEVEL} eq "EMBEDDED") {
- $type = "embedded";
- }
- $self->pidl_code("offset = dissect_ndr_$type\_pointer(tvb, offset, pinfo, tree, drep, $myname\_, $ptrtype_mappings{$l->{POINTER_TYPE}}, \"Pointer to ".field2name(StripPrefixes($e->{NAME}, $self->{conformance}->{strip_prefixes})) . " ($e->{TYPE})\",$hf);");
- } elsif ($l->{TYPE} eq "ARRAY") {
- if ($l->{IS_INLINE}) {
- error($e->{ORIGINAL}, "Inline arrays not supported");
- } elsif ($l->{IS_FIXED}) {
- $self->pidl_code("int i;");
- $self->pidl_code("for (i = 0; i < $l->{SIZE_IS}; i++)");
- $self->pidl_code("\toffset = $myname\_(tvb, offset, pinfo, tree, drep);");
- } else {
- my $type = "";
- $type .= "c" if ($l->{IS_CONFORMANT});
- $type .= "v" if ($l->{IS_VARYING});
-
- unless ($l->{IS_ZERO_TERMINATED}) {
- $self->pidl_code("offset = dissect_ndr_u" . $type . "array(tvb, offset, pinfo, tree, drep, $myname\_);");
- } else {
- my $nl = GetNextLevel($e,$l);
- $self->pidl_code("char *data;");
- $self->pidl_code("");
- $self->pidl_code("offset = dissect_ndr_$type" . "string(tvb, offset, pinfo, tree, drep, sizeof(g$nl->{DATA_TYPE}), $hf, FALSE, &data);");
- $self->pidl_code("proto_item_append_text(tree, \": %s\", data);");
- }
- }
- } elsif ($l->{TYPE} eq "DATA") {
- if ($l->{DATA_TYPE} eq "string") {
- my $bs = 2; # Byte size defaults to that of UCS2
-
-
- ($bs = 1) if (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_ASCII.*"));
-
- if (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_SIZE4.*") and property_matches($e, "flag", ".*LIBNDR_FLAG_STR_LEN4.*")) {
- $self->pidl_code("char *data;\n");
- $self->pidl_code("offset = dissect_ndr_cvstring(tvb, offset, pinfo, tree, drep, $bs, $hf, FALSE, &data);");
- $self->pidl_code("proto_item_append_text(tree, \": %s\", data);");
- } elsif (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_SIZE4.*")) {
- $self->pidl_code("offset = dissect_ndr_vstring(tvb, offset, pinfo, tree, drep, $bs, $hf, FALSE, NULL);");
- } else {
- warn("Unable to handle string with flags $e->{PROPERTIES}->{flag}");
- }
- } else {
- my $call;
-
- if ($self->{conformance}->{imports}->{$l->{DATA_TYPE}}) {
- $call = $self->{conformance}->{imports}->{$l->{DATA_TYPE}}->{DATA};
- $self->{conformance}->{imports}->{$l->{DATA_TYPE}}->{USED} = 1;
- } elsif (defined($self->{conformance}->{imports}->{"$pn.$e->{NAME}"})) {
- $call = $self->{conformance}->{imports}->{"$pn.$e->{NAME}"}->{DATA};
- $self->{conformance}->{imports}->{"$pn.$e->{NAME}"}->{USED} = 1;
-
- } elsif (defined($self->{conformance}->{types}->{$l->{DATA_TYPE}})) {
- $call= $self->{conformance}->{types}->{$l->{DATA_TYPE}}->{DISSECTOR_NAME};
- $self->{conformance}->{types}->{$l->{DATA_TYPE}}->{USED} = 1;
- } else {
- $self->pidl_code("offset = $ifname\_dissect_struct_" . $l->{DATA_TYPE} . "(tvb,offset,pinfo,tree,drep,$hf,$param);");
-
- return;
- }
-
- $call =~ s/\@HF\@/$hf/g;
- $call =~ s/\@PARAM\@/$param/g;
- $self->pidl_code($call);
- }
- } elsif ($_->{TYPE} eq "SUBCONTEXT") {
- my $num_bits = ($l->{HEADER_SIZE}*8);
- $self->pidl_code("guint$num_bits size;");
- $self->pidl_code("int start_offset = offset;");
- $self->pidl_code("tvbuff_t *subtvb;");
- $self->pidl_code("offset = dissect_ndr_uint$num_bits(tvb, offset, pinfo, tree, drep, $hf, &size);");
- $self->pidl_code("proto_tree_add_text(tree, tvb, start_offset, offset - start_offset + size, \"Subcontext size\");");
-
- $self->pidl_code("subtvb = tvb_new_subset(tvb, offset, size, -1);");
- $self->pidl_code("$myname\_(subtvb, 0, pinfo, tree, drep);");
- } else {
- die("Unknown type `$_->{TYPE}'");
- }
-}
-
-sub Element($$$)
-{
- my ($self,$e,$pn,$ifname) = @_;
-
- my $dissectorname = "$ifname\_dissect\_element\_".StripPrefixes($pn, $self->{conformance}->{strip_prefixes})."\_".StripPrefixes($e->{NAME}, $self->{conformance}->{strip_prefixes});
-
- my $call_code = "offset = $dissectorname(tvb, offset, pinfo, tree, drep);";
-
- my $type = $self->find_type($e->{TYPE});
-
- if (not defined($type)) {
- # default settings
- $type = {
- MASK => 0,
- VALSSTRING => "NULL",
- FT_TYPE => "FT_NONE",
- BASE_TYPE => "BASE_HEX"
- };
- }
-
- if (ContainsString($e)) {
- $type = {
- MASK => 0,
- VALSSTRING => "NULL",
- FT_TYPE => "FT_STRING",
- BASE_TYPE => "BASE_DEC"
- };
- }
-
- my $hf = $self->register_hf_field("hf_$ifname\_$pn\_$e->{NAME}", field2name($e->{NAME}), "$ifname.$pn.$e->{NAME}", $type->{FT_TYPE}, $type->{BASE_TYPE}, $type->{VALSSTRING}, $type->{MASK}, "");
- $self->{hf_used}->{$hf} = 1;
-
- my $eltname = StripPrefixes($pn, $self->{conformance}->{strip_prefixes}) . ".$e->{NAME}";
- if (defined($self->{conformance}->{noemit}->{$eltname})) {
- return $call_code;
- }
-
- my $add = "";
-
- foreach (@{$e->{LEVELS}}) {
- next if ($_->{TYPE} eq "SWITCH");
- $self->pidl_def("static int $dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_);");
- $self->pidl_fn_start("$dissectorname$add");
- $self->pidl_code("static int");
- $self->pidl_code("$dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_)");
- $self->pidl_code("{");
- $self->indent;
-
- $self->ElementLevel($e,$_,$hf,$dissectorname.$add,$pn,$ifname);
-
- $self->pidl_code("");
- $self->pidl_code("return offset;");
- $self->deindent;
- $self->pidl_code("}\n");
- $self->pidl_fn_end("$dissectorname$add");
- $add.="_";
- last if ($_->{TYPE} eq "ARRAY" and $_->{IS_ZERO_TERMINATED});
- }
-
- return $call_code;
-}
-
-sub Function($$$)
-{
- my ($self, $fn,$ifname) = @_;
-
- my %dissectornames;
-
- foreach (@{$fn->{ELEMENTS}}) {
- $dissectornames{$_->{NAME}} = $self->Element($_, $fn->{NAME}, $ifname) if not defined($dissectornames{$_->{NAME}});
- }
-
- my $fn_name = $_->{NAME};
- $fn_name =~ s/^${ifname}_//;
-
- $self->PrintIdl(DumpFunction($fn->{ORIGINAL}));
- $self->pidl_fn_start("$ifname\_dissect\_$fn_name\_response");
- $self->pidl_code("static int");
- $self->pidl_code("$ifname\_dissect\_${fn_name}_response(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_)");
- $self->pidl_code("{");
- $self->indent;
- if ( not defined($fn->{RETURN_TYPE})) {
- } elsif ($fn->{RETURN_TYPE} eq "NTSTATUS" or $fn->{RETURN_TYPE} eq "WERROR")
- {
- $self->pidl_code("guint32 status;\n");
- } elsif (my $type = getType($fn->{RETURN_TYPE})) {
- if ($type->{DATA}->{TYPE} eq "ENUM") {
- $self->pidl_code("g".Parse::Pidl::Typelist::enum_type_fn($type->{DATA}) . " status;\n");
- } elsif ($type->{DATA}->{TYPE} eq "SCALAR") {
- $self->pidl_code("g$fn->{RETURN_TYPE} status;\n");
- } else {
- error($fn, "return type `$fn->{RETURN_TYPE}' not yet supported");
- }
- } else {
- error($fn, "unknown return type `$fn->{RETURN_TYPE}'");
- }
-
- $self->pidl_code("pinfo->dcerpc_procedure_name=\"${fn_name}\";");
- foreach (@{$fn->{ELEMENTS}}) {
- if (grep(/out/,@{$_->{DIRECTION}})) {
- $self->pidl_code("$dissectornames{$_->{NAME}}");
- $self->pidl_code("offset = dissect_deferred_pointers(pinfo, tvb, offset, drep);");
- $self->pidl_code("");
- }
- }
-
- if (not defined($fn->{RETURN_TYPE})) {
- } elsif ($fn->{RETURN_TYPE} eq "NTSTATUS") {
- $self->pidl_code("offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep, hf\_$ifname\_status, &status);\n");
- $self->pidl_code("if (status != 0 && check_col(pinfo->cinfo, COL_INFO))");
- $self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Error: %s\", val_to_str(status, NT_errors, \"Unknown NT status 0x%08x\"));\n");
- $return_types{$ifname}->{"status"} = ["NTSTATUS", "NT Error"];
- } elsif ($fn->{RETURN_TYPE} eq "WERROR") {
- $self->pidl_code("offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep, hf\_$ifname\_werror, &status);\n");
- $self->pidl_code("if (status != 0 && check_col(pinfo->cinfo, COL_INFO))");
- $self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Error: %s\", val_to_str(status, WERR_errors, \"Unknown DOS error 0x%08x\"));\n");
-
- $return_types{$ifname}->{"werror"} = ["WERROR", "Windows Error"];
- } elsif (my $type = getType($fn->{RETURN_TYPE})) {
- if ($type->{DATA}->{TYPE} eq "ENUM") {
- my $return_type = "g".Parse::Pidl::Typelist::enum_type_fn($type->{DATA});
- my $return_dissect = "dissect_ndr_" .Parse::Pidl::Typelist::enum_type_fn($type->{DATA});
-
- $self->pidl_code("offset = $return_dissect(tvb, offset, pinfo, tree, drep, hf\_$ifname\_$fn->{RETURN_TYPE}_status, &status);");
- $self->pidl_code("if (status != 0 && check_col(pinfo->cinfo, COL_INFO))");
- $self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Status: %s\", val_to_str(status, $ifname\_$fn->{RETURN_TYPE}\_vals, \"Unknown " . $fn->{RETURN_TYPE} . " error 0x%08x\"));\n");
- $return_types{$ifname}->{$fn->{RETURN_TYPE}."_status"} = [$fn->{RETURN_TYPE}, $fn->{RETURN_TYPE}];
- } elsif ($type->{DATA}->{TYPE} eq "SCALAR") {
- $self->pidl_code("offset = dissect_ndr_$fn->{RETURN_TYPE}(tvb, offset, pinfo, tree, drep, hf\_$ifname\_$fn->{RETURN_TYPE}_status, &status);");
- $self->pidl_code("if (status != 0 && check_col(pinfo->cinfo, COL_INFO))");
- $self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Status: %d\", status);\n");
- $return_types{$ifname}->{$fn->{RETURN_TYPE}."_status"} = [$fn->{RETURN_TYPE}, $fn->{RETURN_TYPE}];
- }
- }
-
- $self->pidl_code("return offset;");
- $self->deindent;
- $self->pidl_code("}\n");
- $self->pidl_fn_end("$ifname\_dissect\_$fn_name\_response");
-
- $self->pidl_fn_start("$ifname\_dissect\_$fn_name\_request");
- $self->pidl_code("static int");
- $self->pidl_code("$ifname\_dissect\_${fn_name}_request(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_)");
- $self->pidl_code("{");
- $self->indent;
- $self->pidl_code("pinfo->dcerpc_procedure_name=\"${fn_name}\";");
- foreach (@{$fn->{ELEMENTS}}) {
- if (grep(/in/,@{$_->{DIRECTION}})) {
- $self->pidl_code("$dissectornames{$_->{NAME}}");
- $self->pidl_code("offset = dissect_deferred_pointers(pinfo, tvb, offset, drep);");
- }
-
- }
-
- $self->pidl_code("return offset;");
- $self->deindent;
- $self->pidl_code("}\n");
- $self->pidl_fn_end("$ifname\_dissect\_$fn_name\_request");
-}
-
-sub Struct($$$$)
-{
- my ($self,$e,$name,$ifname) = @_;
- my $dissectorname = "$ifname\_dissect\_struct\_".StripPrefixes($name, $self->{conformance}->{strip_prefixes});
-
- return if (defined($self->{conformance}->{noemit}->{StripPrefixes($name, $self->{conformance}->{strip_prefixes})}));
-
- $self->register_ett("ett_$ifname\_$name");
-
- my $res = "";
- ($res.="\t".$self->Element($_, $name, $ifname)."\n\n") foreach (@{$e->{ELEMENTS}});
-
- $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_);");
-
- $self->pidl_fn_start($dissectorname);
- $self->pidl_code("int");
- $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)");
- $self->pidl_code("{");
- $self->indent;
- $self->pidl_code("proto_item *item = NULL;");
- $self->pidl_code("proto_tree *tree = NULL;");
- $self->pidl_code("int old_offset;");
- $self->pidl_code("");
-
- if ($e->{ALIGN} > 1) {
- $self->pidl_code("ALIGN_TO_$e->{ALIGN}_BYTES;");
- }
- $self->pidl_code("");
-
- $self->pidl_code("old_offset = offset;");
- $self->pidl_code("");
- $self->pidl_code("if (parent_tree) {");
- $self->indent;
- $self->pidl_code("item = proto_tree_add_item(parent_tree, hf_index, tvb, offset, -1, TRUE);");
- $self->pidl_code("tree = proto_item_add_subtree(item, ett_$ifname\_$name);");
- $self->deindent;
- $self->pidl_code("}");
-
- $self->pidl_code("\n$res");
-
- $self->pidl_code("proto_item_set_len(item, offset-old_offset);\n");
- $self->pidl_code("return offset;");
- $self->deindent;
- $self->pidl_code("}\n");
- $self->pidl_fn_end($dissectorname);
-
- $self->register_type($name, "offset = $dissectorname(tvb,offset,pinfo,tree,drep,\@HF\@,\@PARAM\@);", "FT_NONE", "BASE_NONE", 0, "NULL", 0);
-}
-
-sub Union($$$$)
-{
- my ($self,$e,$name,$ifname) = @_;
-
- my $dissectorname = "$ifname\_dissect_".StripPrefixes($name, $self->{conformance}->{strip_prefixes});
-
- return if (defined($self->{conformance}->{noemit}->{StripPrefixes($name, $self->{conformance}->{strip_prefixes})}));
-
- $self->register_ett("ett_$ifname\_$name");
-
- my $res = "";
- foreach (@{$e->{ELEMENTS}}) {
- $res.="\n\t\t$_->{CASE}:\n";
- if ($_->{TYPE} ne "EMPTY") {
- $res.="\t\t\t".$self->Element($_, $name, $ifname)."\n";
- }
- $res.="\t\tbreak;\n";
- }
-
- my $switch_type;
- my $switch_dissect;
- my $switch_dt = getType($e->{SWITCH_TYPE});
- if ($switch_dt->{DATA}->{TYPE} eq "ENUM") {
- $switch_type = "g".Parse::Pidl::Typelist::enum_type_fn($switch_dt->{DATA});
- $switch_dissect = "dissect_ndr_" .Parse::Pidl::Typelist::enum_type_fn($switch_dt->{DATA});
- } elsif ($switch_dt->{DATA}->{TYPE} eq "SCALAR") {
- $switch_type = "g$e->{SWITCH_TYPE}";
- $switch_dissect = "dissect_ndr_$e->{SWITCH_TYPE}";
- }
-
- $self->pidl_fn_start($dissectorname);
- $self->pidl_code("static int");
- $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)");
- $self->pidl_code("{");
- $self->indent;
- $self->pidl_code("proto_item *item = NULL;");
- $self->pidl_code("proto_tree *tree = NULL;");
- $self->pidl_code("int old_offset;");
- $self->pidl_code("$switch_type level;");
- $self->pidl_code("");
-
- $self->pidl_code("old_offset = offset;");
- $self->pidl_code("if (parent_tree) {");
- $self->indent;
- $self->pidl_code("item = proto_tree_add_text(parent_tree, tvb, offset, -1, \"$name\");");
- $self->pidl_code("tree = proto_item_add_subtree(item, ett_$ifname\_$name);");
- $self->deindent;
- $self->pidl_code("}");
-
- $self->pidl_code("");
-
- $self->pidl_code("offset = $switch_dissect(tvb, offset, pinfo, tree, drep, hf_index, &level);");
-
- if ($e->{ALIGN} > 1) {
- $self->pidl_code("ALIGN_TO_$e->{ALIGN}_BYTES;");
- $self->pidl_code("");
- }
-
-
- $self->pidl_code("switch(level) {$res\t}");
- $self->pidl_code("proto_item_set_len(item, offset-old_offset);\n");
- $self->pidl_code("return offset;");
- $self->deindent;
- $self->pidl_code("}");
- $self->pidl_fn_end($dissectorname);
-
- $self->register_type($name, "offset = $dissectorname(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);", "FT_NONE", "BASE_NONE", 0, "NULL", 0);
-}
-
-sub Const($$$)
-{
- my ($self,$const,$ifname) = @_;
-
- if (!defined($const->{ARRAY_LEN}[0])) {
- $self->pidl_hdr("#define $const->{NAME}\t( $const->{VALUE} )\n");
- } else {
- $self->pidl_hdr("#define $const->{NAME}\t $const->{VALUE}\n");
- }
-}
-
-sub Typedef($$$$)
-{
- my ($self,$e,$name,$ifname) = @_;
-
- $self->Type($e->{DATA}, $name, $ifname);
-}
-
-sub Type($$$$)
-{
- my ($self, $e, $name, $ifname) = @_;
-
- $self->PrintIdl(DumpType($e->{ORIGINAL}));
-
- {
- ENUM => \&Enum,
- STRUCT => \&Struct,
- UNION => \&Union,
- BITMAP => \&Bitmap,
- TYPEDEF => \&Typedef
- }->{$e->{TYPE}}->($self, $e, $name, $ifname);
-}
-
-sub RegisterInterface($$)
-{
- my ($self, $x) = @_;
-
- $self->pidl_fn_start("proto_register_dcerpc_$x->{NAME}");
- $self->pidl_code("void proto_register_dcerpc_$x->{NAME}(void)");
- $self->pidl_code("{");
- $self->indent;
-
- $self->{res}->{code}.=$self->DumpHfList()."\n";
- $self->{res}->{code}.="\n".DumpEttList($self->{ett})."\n";
-
- if (defined($x->{UUID})) {
- # These can be changed to non-pidl_code names if the old dissectors
- # in epan/dissctors are deleted.
-
- my $name = uc($x->{NAME}) . " (pidl)";
- my $short_name = uc($x->{NAME});
- my $filter_name = $x->{NAME};
-
- if (has_property($x, "helpstring")) {
- $name = $x->{PROPERTIES}->{helpstring};
- }
-
- if (defined($self->{conformance}->{protocols}->{$x->{NAME}})) {
- $short_name = $self->{conformance}->{protocols}->{$x->{NAME}}->{SHORTNAME};
- $name = $self->{conformance}->{protocols}->{$x->{NAME}}->{LONGNAME};
- $filter_name = $self->{conformance}->{protocols}->{$x->{NAME}}->{FILTERNAME};
- }
-
- $self->pidl_code("proto_dcerpc_$x->{NAME} = proto_register_protocol(".make_str($name).", ".make_str($short_name).", ".make_str($filter_name).");");
-
- $self->pidl_code("proto_register_field_array(proto_dcerpc_$x->{NAME}, hf, array_length (hf));");
- $self->pidl_code("proto_register_subtree_array(ett, array_length(ett));");
- } else {
- $self->pidl_code("proto_dcerpc = proto_get_id_by_filter_name(\"dcerpc\");");
- $self->pidl_code("proto_register_field_array(proto_dcerpc, hf, array_length(hf));");
- $self->pidl_code("proto_register_subtree_array(ett, array_length(ett));");
- }
-
- $self->deindent;
- $self->pidl_code("}\n");
- $self->pidl_fn_end("proto_register_dcerpc_$x->{NAME}");
-}
-
-sub RegisterInterfaceHandoff($$)
-{
- my ($self,$x) = @_;
-
- if (defined($x->{UUID})) {
- $self->pidl_fn_start("proto_reg_handoff_dcerpc_$x->{NAME}");
- $self->pidl_code("void proto_reg_handoff_dcerpc_$x->{NAME}(void)");
- $self->pidl_code("{");
- $self->indent;
- $self->pidl_code("dcerpc_init_uuid(proto_dcerpc_$x->{NAME}, ett_dcerpc_$x->{NAME},");
- $self->pidl_code("\t&uuid_dcerpc_$x->{NAME}, ver_dcerpc_$x->{NAME},");
- $self->pidl_code("\t$x->{NAME}_dissectors, hf_$x->{NAME}_opnum);");
- $self->deindent;
- $self->pidl_code("}");
- $self->pidl_fn_end("proto_reg_handoff_dcerpc_$x->{NAME}");
-
- $self->{hf_used}->{"hf_$x->{NAME}_opnum"} = 1;
- }
-}
-
-sub ProcessInclude
-{
- my $self = shift;
- my @includes = @_;
- foreach (@includes) {
- $self->pidl_hdr("#include \"$_\"");
- }
- $self->pidl_hdr("");
-}
-
-sub ProcessImport
-{
- my $self = shift;
- my @imports = @_;
- foreach (@imports) {
- next if($_ eq "security");
- s/\.idl\"$//;
- s/^\"//;
- $self->pidl_hdr("#include \"packet-dcerpc-$_\.h\"");
- }
- $self->pidl_hdr("");
-}
-
-sub ProcessInterface($$)
-{
- my ($self, $x) = @_;
-
- push(@{$self->{conformance}->{strip_prefixes}}, $x->{NAME});
-
- my $define = "__PACKET_DCERPC_" . uc($_->{NAME}) . "_H";
- $self->pidl_hdr("#ifndef $define");
- $self->pidl_hdr("#define $define");
- $self->pidl_hdr("");
-
- $self->pidl_def("static gint proto_dcerpc_$x->{NAME} = -1;");
- $self->register_ett("ett_dcerpc_$x->{NAME}");
- $self->register_hf_field("hf_$x->{NAME}_opnum", "Operation", "$x->{NAME}.opnum", "FT_UINT16", "BASE_DEC", "NULL", 0, "");
-
- if (defined($x->{UUID})) {
- my $if_uuid = $x->{UUID};
-
- $self->pidl_def("/* Version information */\n\n");
-
- $self->pidl_def("static e_uuid_t uuid_dcerpc_$x->{NAME} = {");
- $self->pidl_def("\t0x" . substr($if_uuid, 1, 8)
- . ", 0x" . substr($if_uuid, 10, 4)
- . ", 0x" . substr($if_uuid, 15, 4) . ",");
- $self->pidl_def("\t{ 0x" . substr($if_uuid, 20, 2)
- . ", 0x" . substr($if_uuid, 22, 2)
- . ", 0x" . substr($if_uuid, 25, 2)
- . ", 0x" . substr($if_uuid, 27, 2)
- . ", 0x" . substr($if_uuid, 29, 2)
- . ", 0x" . substr($if_uuid, 31, 2)
- . ", 0x" . substr($if_uuid, 33, 2)
- . ", 0x" . substr($if_uuid, 35, 2) . " }");
- $self->pidl_def("};");
-
- my $maj = $x->{VERSION};
- $maj =~ s/\.(.*)$//g;
- $self->pidl_def("static guint16 ver_dcerpc_$x->{NAME} = $maj;");
- $self->pidl_def("");
- }
-
- $return_types{$x->{NAME}} = {};
-
- $self->Interface($x);
-
- $self->pidl_code("\n".DumpFunctionTable($x));
-
- foreach (keys %{$return_types{$x->{NAME}}}) {
- my ($type, $desc) = @{$return_types{$x->{NAME}}->{$_}};
- my $dt = $self->find_type($type);
- $dt or die("Unable to find information about return type `$type'");
- $self->register_hf_field("hf_$x->{NAME}_$_", $desc, "$x->{NAME}.$_", $dt->{FT_TYPE}, "BASE_HEX", $dt->{VALSSTRING}, 0, "");
- $self->{hf_used}->{"hf_$x->{NAME}_$_"} = 1;
- }
-
- $self->RegisterInterface($x);
- $self->RegisterInterfaceHandoff($x);
-
- $self->pidl_hdr("#endif /* $define */");
-}
-
-sub find_type($$)
-{
- my ($self, $n) = @_;
-
- return $self->{conformance}->{types}->{$n};
-}
-
-sub register_type($$$$$$$$)
-{
- my ($self, $type,$call,$ft,$base,$mask,$vals,$length) = @_;
-
- return if (defined($self->{conformance}->{types}->{$type}));
-
- $self->{conformance}->{types}->{$type} = {
- NAME => $type,
- DISSECTOR_NAME => $call,
- FT_TYPE => $ft,
- BASE_TYPE => $base,
- MASK => $mask,
- VALSSTRING => $vals,
- ALIGNMENT => $length
- };
-}
-
-# Loads the default types
-sub Initialize($$)
-{
- my ($self, $cnf_file) = @_;
-
- $self->{conformance} = {
- imports => {},
- header_fields=> {}
- };
-
- ReadConformance($cnf_file, $self->{conformance}) or print STDERR "warning: No conformance file `$cnf_file'\n";
-
- foreach my $bytes (qw(1 2 4 8)) {
- my $bits = $bytes * 8;
- $self->register_type("uint$bits", "offset = PIDL_dissect_uint$bits(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);", "FT_UINT$bits", "BASE_DEC", 0, "NULL", $bytes);
- $self->register_type("int$bits", "offset = PIDL_dissect_uint$bits(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);", "FT_INT$bits", "BASE_DEC", 0, "NULL", $bytes);
- }
-
- $self->register_type("udlong", "offset = dissect_ndr_duint32(tvb, offset, pinfo, tree, drep, \@HF\@, NULL);", "FT_UINT64", "BASE_DEC", 0, "NULL", 4);
- $self->register_type("bool8", "offset = PIDL_dissect_uint8(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_INT8", "BASE_DEC", 0, "NULL", 1);
- $self->register_type("char", "offset = PIDL_dissect_uint8(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_INT8", "BASE_DEC", 0, "NULL", 1);
- $self->register_type("long", "offset = PIDL_dissect_uint32(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_INT32", "BASE_DEC", 0, "NULL", 4);
- $self->register_type("dlong", "offset = dissect_ndr_duint32(tvb, offset, pinfo, tree, drep, \@HF\@, NULL);","FT_INT64", "BASE_DEC", 0, "NULL", 8);
- $self->register_type("GUID", "offset = dissect_ndr_uuid_t(tvb, offset, pinfo, tree, drep, \@HF\@, NULL);","FT_GUID", "BASE_NONE", 0, "NULL", 4);
- $self->register_type("policy_handle", "offset = PIDL_dissect_policy_hnd(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_BYTES", "BASE_NONE", 0, "NULL", 4);
- $self->register_type("NTTIME", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);","FT_ABSOLUTE_TIME", "BASE_NONE", 0, "NULL", 4);
- $self->register_type("NTTIME_hyper", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);","FT_ABSOLUTE_TIME", "BASE_NONE", 0, "NULL", 4);
- $self->register_type("time_t", "offset = dissect_ndr_time_t(tvb, offset, pinfo,tree, drep, \@HF\@, NULL);","FT_ABSOLUTE_TIME", "BASE_DEC", 0, "NULL", 4);
- $self->register_type("NTTIME_1sec", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);", "FT_ABSOLUTE_TIME", "BASE_NONE", 0, "NULL", 4);
- $self->register_type("SID", "
- dcerpc_info *di = (dcerpc_info *)pinfo->private_data;
-
- di->hf_index = \@HF\@;
-
- offset = dissect_ndr_nt_SID_with_options(tvb, offset, pinfo, tree, drep, param);
- ","FT_STRING", "BASE_DEC", 0, "NULL", 4);
- $self->register_type("WERROR",
- "offset = PIDL_dissect_uint32(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_UINT32", "BASE_DEC", 0, "VALS(WERR_errors)", 4);
- $self->register_type("NTSTATUS",
- "offset = PIDL_dissect_uint32(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_UINT32", "BASE_DEC", 0, "VALS(NT_errors)", 4);
-
-}
-
-#####################################################################
-# Generate Wireshark parser and header code
-sub Parse($$$$$)
-{
- my($self,$ndr,$idl_file,$h_filename,$cnf_file) = @_;
-
- $self->Initialize($cnf_file);
-
- return (undef, undef) if defined($self->{conformance}->{noemit_dissector});
-
- my $notice =
-"/* DO NOT EDIT
- This filter was automatically generated
- from $idl_file and $cnf_file.
-
- Pidl is a perl based IDL compiler for DCE/RPC idl files.
- It is maintained by the Samba team, not the Wireshark team.
- Instructions on how to download and install Pidl can be
- found at http://wiki.wireshark.org/Pidl
-*/
-
-";
-
- $self->pidl_hdr($notice);
-
- $self->{res}->{headers} = "\n";
- $self->{res}->{headers} .= "#ifdef HAVE_CONFIG_H\n";
- $self->{res}->{headers} .= "#include \"config.h\"\n";
- $self->{res}->{headers} .= "#endif\n\n";
-
- $self->{res}->{headers} .= "#ifdef _MSC_VER\n";
- $self->{res}->{headers} .= "#pragma warning(disable:4005)\n";
- $self->{res}->{headers} .= "#pragma warning(disable:4013)\n";
- $self->{res}->{headers} .= "#pragma warning(disable:4018)\n";
- $self->{res}->{headers} .= "#pragma warning(disable:4101)\n";
- $self->{res}->{headers} .= "#endif\n\n";
-
- $self->{res}->{headers} .= "#include <glib.h>\n";
- $self->{res}->{headers} .= "#include <string.h>\n";
- $self->{res}->{headers} .= "#include <epan/packet.h>\n\n";
-
- $self->{res}->{headers} .= "#include \"packet-dcerpc.h\"\n";
- $self->{res}->{headers} .= "#include \"packet-dcerpc-nt.h\"\n";
- $self->{res}->{headers} .= "#include \"packet-windows-common.h\"\n";
-
- my $h_basename = basename($h_filename);
-
- $self->{res}->{headers} .= "#include \"$h_basename\"\n";
- $self->pidl_code("");
-
- if (defined($self->{conformance}->{ett})) {
- register_ett($self,$_) foreach(@{$self->{conformance}->{ett}})
- }
-
- # Wireshark protocol registration
-
- foreach (@$ndr) {
- $self->ProcessInterface($_) if ($_->{TYPE} eq "INTERFACE");
- $self->ProcessImport(@{$_->{PATHS}}) if ($_->{TYPE} eq "IMPORT");
- $self->ProcessInclude(@{$_->{PATHS}}) if ($_->{TYPE} eq "INCLUDE");
- }
-
- $self->{res}->{ett} = DumpEttDeclaration($self->{ett});
- $self->{res}->{hf} = $self->DumpHfDeclaration();
-
- my $parser = $notice;
- $parser.= $self->{res}->{headers};
- $parser.=$self->{res}->{ett};
- $parser.=$self->{res}->{hf};
- $parser.=$self->{res}->{def};
- if (exists ($self->{conformance}->{override})) {
- $parser.=$self->{conformance}->{override};
- }
- $parser.=$self->{res}->{code};
-
- my $header = "/* autogenerated by pidl */\n\n";
- $header.=$self->{res}->{hdr};
-
- $self->CheckUsed($self->{conformance});
-
- return ($parser,$header);
-}
-
-###############################################################################
-# ETT
-###############################################################################
-
-sub register_ett($$)
-{
- my ($self, $name) = @_;
-
- push (@{$self->{ett}}, $name);
-}
-
-sub DumpEttList
-{
- my ($ett) = @_;
- my $res = "\tstatic gint *ett[] = {\n";
- foreach (@$ett) {
- $res .= "\t\t&$_,\n";
- }
-
- return "$res\t};\n";
-}
-
-sub DumpEttDeclaration
-{
- my ($ett) = @_;
- my $res = "\n/* Ett declarations */\n";
- foreach (@$ett) {
- $res .= "static gint $_ = -1;\n";
- }
-
- return "$res\n";
-}
-
-###############################################################################
-# HF
-###############################################################################
-
-sub register_hf_field($$$$$$$$$)
-{
- my ($self,$index,$name,$filter_name,$ft_type,$base_type,$valsstring,$mask,$blurb) = @_;
-
- if (defined ($self->{conformance}->{hf_renames}->{$index})) {
- $self->{conformance}->{hf_renames}->{$index}->{USED} = 1;
- return $self->{conformance}->{hf_renames}->{$index}->{NEWNAME};
- }
-
- $self->{conformance}->{header_fields}->{$index} = {
- INDEX => $index,
- NAME => $name,
- FILTER => $filter_name,
- FT_TYPE => $ft_type,
- BASE_TYPE => $base_type,
- VALSSTRING => $valsstring,
- MASK => $mask,
- BLURB => $blurb
- };
-
- if ((not defined($blurb) or $blurb eq "") and
- defined($self->{conformance}->{fielddescription}->{$index})) {
- $self->{conformance}->{header_fields}->{$index}->{BLURB} =
- $self->{conformance}->{fielddescription}->{$index}->{DESCRIPTION};
- $self->{conformance}->{fielddescription}->{$index}->{USED} = 1;
- }
-
- return $index;
-}
-
-sub DumpHfDeclaration($)
-{
- my ($self) = @_;
- my $res = "";
-
- $res = "\n/* Header field declarations */\n";
-
- foreach (keys %{$self->{conformance}->{header_fields}})
- {
- $res .= "static gint $_ = -1;\n";
- }
-
- return "$res\n";
-}
-
-sub DumpHfList($)
-{
- my ($self) = @_;
- my $res = "\tstatic hf_register_info hf[] = {\n";
-
- foreach (values %{$self->{conformance}->{header_fields}})
- {
- $res .= "\t{ &$_->{INDEX},
- { ".make_str($_->{NAME}).", ".make_str($_->{FILTER}).", $_->{FT_TYPE}, $_->{BASE_TYPE}, $_->{VALSSTRING}, $_->{MASK}, ".make_str($_->{BLURB}).", HFILL }},
-";
- }
-
- return $res."\t};\n";
-}
-
-
-###############################################################################
-# Function table
-###############################################################################
-
-sub DumpFunctionTable($)
-{
- my $if = shift;
-
- my $res = "static dcerpc_sub_dissector $if->{NAME}\_dissectors[] = {\n";
- foreach (@{$if->{FUNCTIONS}}) {
- my $fn_name = $_->{NAME};
- $fn_name =~ s/^$if->{NAME}_//;
- $res.= "\t{ $_->{OPNUM}, \"$fn_name\",\n";
- $res.= "\t $if->{NAME}_dissect_${fn_name}_request, $if->{NAME}_dissect_${fn_name}_response},\n";
- }
-
- $res .= "\t{ 0, NULL, NULL, NULL }\n";
-
- return "$res};\n";
-}
-
-sub CheckUsed($$)
-{
- my ($self, $conformance) = @_;
- foreach (values %{$conformance->{header_fields}}) {
- if (not defined($self->{hf_used}->{$_->{INDEX}})) {
- warning($_->{POS}, "hf field `$_->{INDEX}' not used");
- }
- }
-
- foreach (values %{$conformance->{hf_renames}}) {
- if (not $_->{USED}) {
- warning($_->{POS}, "hf field `$_->{OLDNAME}' not used");
- }
- }
-
- foreach (values %{$conformance->{dissectorparams}}) {
- if (not $_->{USED}) {
- warning($_->{POS}, "dissector param never used");
- }
- }
-
- foreach (values %{$conformance->{imports}}) {
- if (not $_->{USED}) {
- warning($_->{POS}, "import never used");
- }
- }
-
- foreach (values %{$conformance->{types}}) {
- if (not $_->{USED} and defined($_->{POS})) {
- warning($_->{POS}, "type never used");
- }
- }
-
- foreach (values %{$conformance->{fielddescription}}) {
- if (not $_->{USED}) {
- warning($_->{POS}, "description never used");
- }
- }
-
- foreach (values %{$conformance->{tfs}}) {
- if (not $_->{USED}) {
- warning($_->{POS}, "True/False description never used");
- }
- }
-}
-
-1;
diff --git a/source4/pidl/lib/Parse/Yapp/Driver.pm b/source4/pidl/lib/Parse/Yapp/Driver.pm
deleted file mode 100644
index d0dcbf54eb..0000000000
--- a/source4/pidl/lib/Parse/Yapp/Driver.pm
+++ /dev/null
@@ -1,471 +0,0 @@
-#
-# Module Parse::Yapp::Driver
-#
-# This module is part of the Parse::Yapp package available on your
-# nearest CPAN
-#
-# Any use of this module in a standalone parser make the included
-# text under the same copyright as the Parse::Yapp module itself.
-#
-# This notice should remain unchanged.
-#
-# (c) Copyright 1998-2001 Francois Desarmenien, all rights reserved.
-# (see the pod text in Parse::Yapp module for use and distribution rights)
-#
-
-package Parse::Yapp::Driver;
-
-require 5.004;
-
-use strict;
-
-use vars qw ( $VERSION $COMPATIBLE $FILENAME );
-
-$VERSION = '1.05';
-$COMPATIBLE = '0.07';
-$FILENAME=__FILE__;
-
-use Carp;
-
-#Known parameters, all starting with YY (leading YY will be discarded)
-my(%params)=(YYLEX => 'CODE', 'YYERROR' => 'CODE', YYVERSION => '',
- YYRULES => 'ARRAY', YYSTATES => 'ARRAY', YYDEBUG => '');
-#Mandatory parameters
-my(@params)=('LEX','RULES','STATES');
-
-sub new {
- my($class)=shift;
- my($errst,$nberr,$token,$value,$check,$dotpos);
- my($self)={ ERROR => \&_Error,
- ERRST => \$errst,
- NBERR => \$nberr,
- TOKEN => \$token,
- VALUE => \$value,
- DOTPOS => \$dotpos,
- STACK => [],
- DEBUG => 0,
- CHECK => \$check };
-
- _CheckParams( [], \%params, \@_, $self );
-
- exists($$self{VERSION})
- and $$self{VERSION} < $COMPATIBLE
- and croak "Yapp driver version $VERSION ".
- "incompatible with version $$self{VERSION}:\n".
- "Please recompile parser module.";
-
- ref($class)
- and $class=ref($class);
-
- bless($self,$class);
-}
-
-sub YYParse {
- my($self)=shift;
- my($retval);
-
- _CheckParams( \@params, \%params, \@_, $self );
-
- if($$self{DEBUG}) {
- _DBLoad();
- $retval = eval '$self->_DBParse()';#Do not create stab entry on compile
- $@ and die $@;
- }
- else {
- $retval = $self->_Parse();
- }
- $retval
-}
-
-sub YYData {
- my($self)=shift;
-
- exists($$self{USER})
- or $$self{USER}={};
-
- $$self{USER};
-
-}
-
-sub YYErrok {
- my($self)=shift;
-
- ${$$self{ERRST}}=0;
- undef;
-}
-
-sub YYNberr {
- my($self)=shift;
-
- ${$$self{NBERR}};
-}
-
-sub YYRecovering {
- my($self)=shift;
-
- ${$$self{ERRST}} != 0;
-}
-
-sub YYAbort {
- my($self)=shift;
-
- ${$$self{CHECK}}='ABORT';
- undef;
-}
-
-sub YYAccept {
- my($self)=shift;
-
- ${$$self{CHECK}}='ACCEPT';
- undef;
-}
-
-sub YYError {
- my($self)=shift;
-
- ${$$self{CHECK}}='ERROR';
- undef;
-}
-
-sub YYSemval {
- my($self)=shift;
- my($index)= $_[0] - ${$$self{DOTPOS}} - 1;
-
- $index < 0
- and -$index <= @{$$self{STACK}}
- and return $$self{STACK}[$index][1];
-
- undef; #Invalid index
-}
-
-sub YYCurtok {
- my($self)=shift;
-
- @_
- and ${$$self{TOKEN}}=$_[0];
- ${$$self{TOKEN}};
-}
-
-sub YYCurval {
- my($self)=shift;
-
- @_
- and ${$$self{VALUE}}=$_[0];
- ${$$self{VALUE}};
-}
-
-sub YYExpect {
- my($self)=shift;
-
- keys %{$self->{STATES}[$self->{STACK}[-1][0]]{ACTIONS}}
-}
-
-sub YYLexer {
- my($self)=shift;
-
- $$self{LEX};
-}
-
-
-#################
-# Private stuff #
-#################
-
-
-sub _CheckParams {
- my($mandatory,$checklist,$inarray,$outhash)=@_;
- my($prm,$value);
- my($prmlst)={};
-
- while(($prm,$value)=splice(@$inarray,0,2)) {
- $prm=uc($prm);
- exists($$checklist{$prm})
- or croak("Unknow parameter '$prm'");
- ref($value) eq $$checklist{$prm}
- or croak("Invalid value for parameter '$prm'");
- $prm=unpack('@2A*',$prm);
- $$outhash{$prm}=$value;
- }
- for (@$mandatory) {
- exists($$outhash{$_})
- or croak("Missing mandatory parameter '".lc($_)."'");
- }
-}
-
-sub _Error {
- print "Parse error.\n";
-}
-
-sub _DBLoad {
- {
- no strict 'refs';
-
- exists(${__PACKAGE__.'::'}{_DBParse})#Already loaded ?
- and return;
- }
- my($fname)=__FILE__;
- my(@drv);
- open(DRV,"<$fname") or die "Report this as a BUG: Cannot open $fname";
- while(<DRV>) {
- /^\s*sub\s+_Parse\s*{\s*$/ .. /^\s*}\s*#\s*_Parse\s*$/
- and do {
- s/^#DBG>//;
- push(@drv,$_);
- }
- }
- close(DRV);
-
- $drv[0]=~s/_P/_DBP/;
- eval join('',@drv);
-}
-
-#Note that for loading debugging version of the driver,
-#this file will be parsed from 'sub _Parse' up to '}#_Parse' inclusive.
-#So, DO NOT remove comment at end of sub !!!
-sub _Parse {
- my($self)=shift;
-
- my($rules,$states,$lex,$error)
- = @$self{ 'RULES', 'STATES', 'LEX', 'ERROR' };
- my($errstatus,$nberror,$token,$value,$stack,$check,$dotpos)
- = @$self{ 'ERRST', 'NBERR', 'TOKEN', 'VALUE', 'STACK', 'CHECK', 'DOTPOS' };
-
-#DBG> my($debug)=$$self{DEBUG};
-#DBG> my($dbgerror)=0;
-
-#DBG> my($ShowCurToken) = sub {
-#DBG> my($tok)='>';
-#DBG> for (split('',$$token)) {
-#DBG> $tok.= (ord($_) < 32 or ord($_) > 126)
-#DBG> ? sprintf('<%02X>',ord($_))
-#DBG> : $_;
-#DBG> }
-#DBG> $tok.='<';
-#DBG> };
-
- $$errstatus=0;
- $$nberror=0;
- ($$token,$$value)=(undef,undef);
- @$stack=( [ 0, undef ] );
- $$check='';
-
- while(1) {
- my($actions,$act,$stateno);
-
- $stateno=$$stack[-1][0];
- $actions=$$states[$stateno];
-
-#DBG> print STDERR ('-' x 40),"\n";
-#DBG> $debug & 0x2
-#DBG> and print STDERR "In state $stateno:\n";
-#DBG> $debug & 0x08
-#DBG> and print STDERR "Stack:[".
-#DBG> join(',',map { $$_[0] } @$stack).
-#DBG> "]\n";
-
-
- if (exists($$actions{ACTIONS})) {
-
- defined($$token)
- or do {
- ($$token,$$value)=&$lex($self);
-#DBG> $debug & 0x01
-#DBG> and print STDERR "Need token. Got ".&$ShowCurToken."\n";
- };
-
- $act= exists($$actions{ACTIONS}{$$token})
- ? $$actions{ACTIONS}{$$token}
- : exists($$actions{DEFAULT})
- ? $$actions{DEFAULT}
- : undef;
- }
- else {
- $act=$$actions{DEFAULT};
-#DBG> $debug & 0x01
-#DBG> and print STDERR "Don't need token.\n";
- }
-
- defined($act)
- and do {
-
- $act > 0
- and do { #shift
-
-#DBG> $debug & 0x04
-#DBG> and print STDERR "Shift and go to state $act.\n";
-
- $$errstatus
- and do {
- --$$errstatus;
-
-#DBG> $debug & 0x10
-#DBG> and $dbgerror
-#DBG> and $$errstatus == 0
-#DBG> and do {
-#DBG> print STDERR "**End of Error recovery.\n";
-#DBG> $dbgerror=0;
-#DBG> };
- };
-
-
- push(@$stack,[ $act, $$value ]);
-
- $$token ne '' #Don't eat the eof
- and $$token=$$value=undef;
- next;
- };
-
- #reduce
- my($lhs,$len,$code,@sempar,$semval);
- ($lhs,$len,$code)=@{$$rules[-$act]};
-
-#DBG> $debug & 0x04
-#DBG> and $act
-#DBG> and print STDERR "Reduce using rule ".-$act." ($lhs,$len): ";
-
- $act
- or $self->YYAccept();
-
- $$dotpos=$len;
-
- unpack('A1',$lhs) eq '@' #In line rule
- and do {
- $lhs =~ /^\@[0-9]+\-([0-9]+)$/
- or die "In line rule name '$lhs' ill formed: ".
- "report it as a BUG.\n";
- $$dotpos = $1;
- };
-
- @sempar = $$dotpos
- ? map { $$_[1] } @$stack[ -$$dotpos .. -1 ]
- : ();
-
- $semval = $code ? &$code( $self, @sempar )
- : @sempar ? $sempar[0] : undef;
-
- splice(@$stack,-$len,$len);
-
- $$check eq 'ACCEPT'
- and do {
-
-#DBG> $debug & 0x04
-#DBG> and print STDERR "Accept.\n";
-
- return($semval);
- };
-
- $$check eq 'ABORT'
- and do {
-
-#DBG> $debug & 0x04
-#DBG> and print STDERR "Abort.\n";
-
- return(undef);
-
- };
-
-#DBG> $debug & 0x04
-#DBG> and print STDERR "Back to state $$stack[-1][0], then ";
-
- $$check eq 'ERROR'
- or do {
-#DBG> $debug & 0x04
-#DBG> and print STDERR
-#DBG> "go to state $$states[$$stack[-1][0]]{GOTOS}{$lhs}.\n";
-
-#DBG> $debug & 0x10
-#DBG> and $dbgerror
-#DBG> and $$errstatus == 0
-#DBG> and do {
-#DBG> print STDERR "**End of Error recovery.\n";
-#DBG> $dbgerror=0;
-#DBG> };
-
- push(@$stack,
- [ $$states[$$stack[-1][0]]{GOTOS}{$lhs}, $semval ]);
- $$check='';
- next;
- };
-
-#DBG> $debug & 0x04
-#DBG> and print STDERR "Forced Error recovery.\n";
-
- $$check='';
-
- };
-
- #Error
- $$errstatus
- or do {
-
- $$errstatus = 1;
- &$error($self);
- $$errstatus # if 0, then YYErrok has been called
- or next; # so continue parsing
-
-#DBG> $debug & 0x10
-#DBG> and do {
-#DBG> print STDERR "**Entering Error recovery.\n";
-#DBG> ++$dbgerror;
-#DBG> };
-
- ++$$nberror;
-
- };
-
- $$errstatus == 3 #The next token is not valid: discard it
- and do {
- $$token eq '' # End of input: no hope
- and do {
-#DBG> $debug & 0x10
-#DBG> and print STDERR "**At eof: aborting.\n";
- return(undef);
- };
-
-#DBG> $debug & 0x10
-#DBG> and print STDERR "**Dicard invalid token ".&$ShowCurToken.".\n";
-
- $$token=$$value=undef;
- };
-
- $$errstatus=3;
-
- while( @$stack
- and ( not exists($$states[$$stack[-1][0]]{ACTIONS})
- or not exists($$states[$$stack[-1][0]]{ACTIONS}{error})
- or $$states[$$stack[-1][0]]{ACTIONS}{error} <= 0)) {
-
-#DBG> $debug & 0x10
-#DBG> and print STDERR "**Pop state $$stack[-1][0].\n";
-
- pop(@$stack);
- }
-
- @$stack
- or do {
-
-#DBG> $debug & 0x10
-#DBG> and print STDERR "**No state left on stack: aborting.\n";
-
- return(undef);
- };
-
- #shift the error token
-
-#DBG> $debug & 0x10
-#DBG> and print STDERR "**Shift \$error token and go to state ".
-#DBG> $$states[$$stack[-1][0]]{ACTIONS}{error}.
-#DBG> ".\n";
-
- push(@$stack, [ $$states[$$stack[-1][0]]{ACTIONS}{error}, undef ]);
-
- }
-
- #never reached
- croak("Error in driver logic. Please, report it as a BUG");
-
-}#_Parse
-#DO NOT remove comment
-
-1;
-
diff --git a/source4/pidl/pidl b/source4/pidl/pidl
deleted file mode 100755
index 577db0a53f..0000000000
--- a/source4/pidl/pidl
+++ /dev/null
@@ -1,796 +0,0 @@
-#!/usr/bin/perl -w
-
-###################################################
-# package to parse IDL files and generate code for
-# rpc functions in Samba
-# Copyright tridge@samba.org 2000-2003
-# Copyright jelmer@samba.org 2005-2007
-# released under the GNU GPL
-
-=pod
-
-=head1 NAME
-
-pidl - An IDL compiler written in Perl
-
-=head1 SYNOPSIS
-
-pidl --help
-
-pidl [--outputdir[=OUTNAME]] [--includedir DIR...] [--parse-idl-tree] [--dump-idl-tree] [--dump-ndr-tree] [--header[=OUTPUT]] [--python[=OUTPUT]] [--swig[=OUTPUT]] [--ndr-parser[=OUTPUT]] [--client] [--server] [--warn-compat] [--quiet] [--verbose] [--template] [--ws-parser[=OUTPUT]] [--diff] [--dump-idl] [--tdr-parser[=OUTPUT]] [--samba3-ndr-client[=OUTPUT]] [--samba3-ndr-server[=OUTPUT]] [--typelib=[OUTPUT]] [<idlfile>.idl]...
-
-=head1 DESCRIPTION
-
-pidl is an IDL compiler written in Perl that aims to be somewhat
-compatible with the midl compiler. IDL is short for
-"Interface Definition Language".
-
-pidl can generate stubs for DCE/RPC server code, DCE/RPC
-client code and Wireshark dissectors for DCE/RPC traffic.
-
-IDL compilers like pidl take a description
-of an interface as their input and use it to generate C
-(though support for other languages may be added later) code that
-can use these interfaces, pretty print data sent
-using these interfaces, or even generate Wireshark
-dissectors that can parse data sent over the
-wire by these interfaces.
-
-pidl takes IDL files in the same format as is used by midl,
-converts it to a .pidl file (which contains pidl's internal representation of the interface) and can then generate whatever output you need.
-.pidl files should be used for debugging purposes only. Write your
-interface definitions in .idl format.
-
-The goal of pidl is to implement a IDL compiler that can be used
-while developing the RPC subsystem in Samba (for
-both marshalling/unmarshalling and debugging purposes).
-
-=head1 OPTIONS
-
-=over 4
-
-=item I<--help>
-
-Show list of available options.
-
-=item I<--version>
-
-Show pidl version
-
-=item I<--outputdir OUTNAME>
-
-Write output files to the specified directory. Defaults to the current
-directory.
-
-=item I<--includedir DIR>
-
-Add DIR to the search path used by the preprocessor. This option can be
-specified multiple times.
-
-=item I<--parse-idl-tree>
-
-Read internal tree structure from input files rather
-than assuming they contain IDL.
-
-=item I<--dump-idl>
-
-Generate a new IDL file. File will be named OUTNAME.idl.
-
-=item I<--header>
-
-Generate a C header file for the specified interface. Filename defaults to OUTNAME.h.
-
-=item I<--ndr-parser>
-
-Generate a C file and C header containing NDR parsers. The filename for
-the parser defaults to ndr_OUTNAME.c. The header filename will be the
-parser filename with the extension changed from .c to .h.
-
-=item I<--tdr-parser>
-
-Generate a C file and C header containing TDR parsers. The filename for
-the parser defaults to tdr_OUTNAME.c. The header filename will be the
-parser filename with the extension changed from .c to .h.
-
-=item I<--typelib>
-
-Write type information to the specified file.
-
-=item I<--server>
-
-Generate boilerplate for the RPC server that implements
-the interface. Filename defaults to ndr_OUTNAME_s.c.
-
-=item I<--template>
-
-Generate stubs for a RPC server that implements the interface. Output will
-be written to stdout.
-
-=item I<--ws-parser>
-
-Generate an Wireshark dissector (in C) and header file. The dissector filename
-defaults to packet-dcerpc-OUTNAME.c while the header filename defaults to
-packet-dcerpc-OUTNAME.h.
-
-Pidl will read additional data from an Wireshark conformance file if present.
-Such a file should have the same location as the IDL file but with the
-extension I<cnf> rather than I<idl>. See L<Parse::Pidl::Wireshark::Conformance>
-for details on the format of this file.
-
-=item I<--diff>
-
-Parse an IDL file, generate a new IDL file based on the internal data
-structures and see if there are any differences with the original IDL file.
-Useful for debugging pidl.
-
-=item I<--dump-idl-tree>
-
-Tell pidl to dump the internal tree representation of an IDL
-file the to disk. Useful for debugging pidl.
-
-=item I<--dump-ndr-tree>
-
-Tell pidl to dump the internal NDR information tree it generated
-from the IDL file to disk. Useful for debugging pidl.
-
-=item I<--samba3-ndr-client>
-
-Generate client calls for Samba3, to be placed in rpc_client/. Instead of
-calling out to the code in Samba3's rpc_parse/, this will call out to
-Samba4's NDR code instead.
-
-=item I<--samba3-ndr-server>
-
-Generate server calls for Samba3, to be placed in rpc_server/. Instead of
-calling out to the code in Samba3's rpc_parse/, this will call out to
-Samba4's NDR code instead.
-
-=back
-
-=head1 IDL SYNTAX
-
-IDL files are always preprocessed using the C preprocessor.
-
-Pretty much everything in an interface (the interface itself, functions,
-parameters) can have attributes (or properties whatever name you give them).
-Attributes always prepend the element they apply to and are surrounded
-by square brackets ([]). Multiple attributes are separated by comma's;
-arguments to attributes are specified between parentheses.
-
-See the section COMPATIBILITY for the list of attributes that
-pidl supports.
-
-C-style comments can be used.
-
-=head2 CONFORMANT ARRAYS
-
-A conformant array is one with that ends in [*] or []. The strange
-things about conformant arrays are that they can only appear as the last
-element of a structure (unless there is a pointer to the conformant array,
-of course) and the array size appears before the structure itself on the wire.
-
-So, in this example:
-
- typedef struct {
- long abc;
- long count;
- long foo;
- [size_is(count)] long s[*];
- } Struct1;
-
-it appears like this:
-
- [size_is] [abc] [count] [foo] [s...]
-
-the first [size_is] field is the allocation size of the array, and
-occurs before the array elements and even before the structure
-alignment.
-
-Note that size_is() can refer to a constant, but that doesn't change
-the wire representation. It does not make the array a fixed array.
-
-midl.exe would write the above array as the following C header:
-
- typedef struct {
- long abc;
- long count;
- long foo;
- long s[1];
- } Struct1;
-
-pidl takes a different approach, and writes it like this:
-
- typedef struct {
- long abc;
- long count;
- long foo;
- long *s;
- } Struct1;
-
-=head2 VARYING ARRAYS
-
-A varying array looks like this:
-
- typedef struct {
- long abc;
- long count;
- long foo;
- [size_is(count)] long *s;
- } Struct1;
-
-This will look like this on the wire:
-
- [abc] [count] [foo] [PTR_s] [count] [s...]
-
-=head2 FIXED ARRAYS
-
-A fixed array looks like this:
-
- typedef struct {
- long s[10];
- } Struct1;
-
-The NDR representation looks just like 10 separate long
-declarations. The array size is not encoded on the wire.
-
-pidl also supports "inline" arrays, which are not part of the IDL/NDR
-standard. These are declared like this:
-
- typedef struct {
- uint32 foo;
- uint32 count;
- uint32 bar;
- long s[count];
- } Struct1;
-
-This appears like this:
-
- [foo] [count] [bar] [s...]
-
-Fixed arrays are an extension added to support some of the strange
-embedded structures in security descriptors and spoolss.
-
-This section is by no means complete. See the OpenGroup and MSDN
- documentation for additional information.
-
-=head1 COMPATIBILITY WITH MIDL
-
-=head2 Missing features in pidl
-
-The following MIDL features are not (yet) implemented in pidl
-or are implemented with an incompatible interface:
-
-=over
-
-=item *
-
-Asynchronous communication
-
-=item *
-
-Typelibs (.tlb files)
-
-=item *
-
-Datagram support (ncadg_*)
-
-=back
-
-=head2 Supported attributes and statements
-
-in, out, ref, length_is, switch_is, size_is, uuid, case, default, string,
-unique, ptr, pointer_default, v1_enum, object, helpstring, range, local,
-call_as, endpoint, switch_type, progid, coclass, iid_is, represent_as,
-transmit_as, import, include, cpp_quote.
-
-=head2 PIDL Specific properties
-
-=over 4
-
-=item public
-
-The [public] property on a structure or union is a pidl extension that
-forces the generated pull/push functions to be non-static. This allows
-you to declare types that can be used between modules. If you don't
-specify [public] then pull/push functions for other than top-level
-functions are declared static.
-
-=item noprint
-
-The [noprint] property is a pidl extension that allows you to specify
-that pidl should not generate a ndr_print_*() function for that
-structure or union. This is used when you wish to define your own
-print function that prints a structure in a nicer manner. A good
-example is the use of [noprint] on dom_sid, which allows the
-pretty-printing of SIDs.
-
-=item value
-
-The [value(expression)] property is a pidl extension that allows you
-to specify the value of a field when it is put on the wire. This
-allows fields that always have a well-known value to be automatically
-filled in, thus making the API more programmer friendly. The
-expression can be any C expression.
-
-=item relative
-
-The [relative] property can be supplied on a pointer. When it is used
-it declares the pointer as a spoolss style "relative" pointer, which
-means it appears on the wire as an offset within the current
-encapsulating structure. This is not part of normal IDL/NDR, but it is
-a very useful extension as it avoids the manual encoding of many
-complex structures.
-
-=item subcontext(length)
-
-Specifies that a size of I<length>
-bytes should be read, followed by a blob of that size,
-which will be parsed as NDR.
-
-subcontext() is deprecated now, and should not be used in new code.
-Instead, use represent_as() or transmit_as().
-
-=item flag
-
-Specify boolean options, mostly used for
-low-level NDR options. Several options
-can be specified using the | character.
-Note that flags are inherited by substructures!
-
-=item nodiscriminant
-
-The [nodiscriminant] property on a union means that the usual uint16
-discriminent field at the start of the union on the wire is
-omitted. This is not normally allowed in IDL/NDR, but is used for some
-spoolss structures.
-
-=item charset(name)
-
-Specify that the array or string uses the specified
-charset. If this attribute is specified, pidl will
-take care of converting the character data from this format
-to the host format. Commonly used values are UCS2, DOS and UTF8.
-
-=back
-
-=head2 Unsupported MIDL properties or statements
-
-aggregatable, appobject, async_uuid, bindable, control,
-defaultbind, defaultcollelem, defaultvalue, defaultvtable, dispinterface,
-displaybind, dual, entry, first_is, helpcontext, helpfile, helpstringcontext,
-helpstringdll, hidden, idl_module, idl_quote, id, immediatebind, importlib,
-includelib, last_is, lcid, licensed, max_is, module,
-ms_union, no_injected_text, nonbrowsable, noncreatable, nonextensible, odl,
-oleautomation, optional, pragma, propget, propputref, propput, readonly,
-requestedit, restricted, retval, source, uidefault,
-usesgetlasterror, vararg, vi_progid, wire_marshal.
-
-=head1 EXAMPLES
-
- # Generating an Wireshark parser
- $ ./pidl --ws-parser -- atsvc.idl
-
- # Generating a TDR parser and header
- $ ./pidl --tdr-parser --header -- regf.idl
-
- # Generating a Samba3 client and server
- $ ./pidl --samba3-ndr-client --samba3-ndr-server -- dfs.idl
-
- # Generating a Samba4 NDR parser, client and server
- $ ./pidl --ndr-parser --ndr-client --ndr-server -- samr.idl
-
-=head1 SEE ALSO
-
-L<http://msdn.microsoft.com/library/en-us/rpc/rpc/field_attributes.asp>,
-L<http://wiki.wireshark.org/DCE/RPC>,
-L<http://www.samba.org/>,
-L<yapp(1)>
-
-=head1 LICENSE
-
-pidl is licensed under the GNU General Public License L<http://www.gnu.org/licenses/gpl.html>.
-
-=head1 AUTHOR
-
-pidl was written by Andrew Tridgell, Stefan Metzmacher, Tim Potter and Jelmer
-Vernooij. The current maintainer is Jelmer Vernooij.
-
-This manpage was written by Jelmer Vernooij, partially based on the original
-pidl README by Andrew Tridgell.
-
-=cut
-
-
-use strict;
-use FindBin qw($RealBin $Script);
-use lib "$RealBin/lib";
-use lib "$RealBin/../share/perl5";
-use Getopt::Long;
-use File::Basename;
-use Parse::Pidl qw ( $VERSION );
-use Parse::Pidl::Util;
-use Parse::Pidl::ODL;
-
-#####################################################################
-# save a data structure into a file
-sub SaveStructure($$)
-{
- my($filename,$v) = @_;
- FileSave($filename, Parse::Pidl::Util::MyDumper($v));
-}
-
-#####################################################################
-# load a data structure from a file (as saved with SaveStructure)
-sub LoadStructure($)
-{
- my $f = shift;
- my $contents = FileLoad($f);
- defined $contents || return undef;
- return eval "$contents";
-}
-
-#####################################################################
-# read a file into a string
-sub FileLoad($)
-{
- my($filename) = shift;
- local(*INPUTFILE);
- open(INPUTFILE, $filename) || return undef;
- my($saved_delim) = $/;
- undef $/;
- my($data) = <INPUTFILE>;
- close(INPUTFILE);
- $/ = $saved_delim;
- return $data;
-}
-
-#####################################################################
-# write a string into a file
-sub FileSave($$)
-{
- my($filename) = shift;
- my($v) = shift;
- local(*FILE);
- open(FILE, ">$filename") || die "can't open $filename";
- print FILE $v;
- close(FILE);
-}
-
-my(@opt_incdirs) = ();
-my($opt_help) = 0;
-my($opt_version) = 0;
-my($opt_parse_idl_tree) = 0;
-my($opt_dump_idl_tree);
-my($opt_dump_ndr_tree);
-my($opt_dump_idl) = 0;
-my($opt_diff) = 0;
-my($opt_header);
-my($opt_samba3_header);
-my($opt_samba3_parser);
-my($opt_samba3_server);
-my($opt_samba3_ndr_client);
-my($opt_samba3_ndr_server);
-my($opt_template) = 0;
-my($opt_client);
-my($opt_typelib);
-my($opt_server);
-my($opt_ndr_parser);
-my($opt_tdr_parser);
-my($opt_ws_parser);
-my($opt_swig);
-my($opt_python);
-my($opt_quiet) = 0;
-my($opt_outputdir) = '.';
-my($opt_verbose) = 0;
-my($opt_warn_compat) = 0;
-my($opt_dcom_proxy);
-my($opt_com_header);
-
-#########################################
-# display help text
-sub ShowHelp()
-{
-print "perl IDL parser and code generator\n";
-ShowVersion();
-print"
-Copyright (C) Andrew Tridgell <tridge\@samba.org>
-Copyright (C) Jelmer Vernooij <jelmer\@samba.org>
-
-Usage: $Script [options] [--] <idlfile> [<idlfile>...]
-
-Generic Options:
- --help this help page
- --version show pidl version
- --outputdir=OUTDIR put output in OUTDIR/ [.]
- --warn-compat warn about incompatibility with other compilers
- --quiet be quiet
- --verbose be verbose
- --includedir DIR search DIR for included files
-
-Debugging:
- --dump-idl-tree[=FILE] dump internal representation to file [BASENAME.pidl]
- --parse-idl-tree read internal representation instead of IDL
- --dump-ndr-tree[=FILE] dump internal NDR data tree to file [BASENAME.ndr]
- --dump-idl regenerate IDL file
- --diff run diff on original IDL and dumped output
- --typelib print type information
-
-Samba 4 output:
- --header[=OUTFILE] create generic header file [BASENAME.h]
- --ndr-parser[=OUTFILE] create a C NDR parser [ndr_BASENAME.c]
- --client[=OUTFILE] create a C NDR client [ndr_BASENAME_c.c]
- --tdr-parser[=OUTFILE] create a C TDR parser [tdr_BASENAME.c]
- --python[=OUTFILE] create python wrapper file [py_BASENAME.c]
- --swig[=OUTFILE] create swig wrapper file [BASENAME.i]
- --server[=OUTFILE] create server boilerplate [ndr_BASENAME_s.c]
- --template print a template for a pipe
- --dcom-proxy[=OUTFILE] create DCOM proxy [ndr_BASENAME_p.c]
- --com-header[=OUTFILE] create header for COM [com_BASENAME.h]
-
-Samba 3 output:
- --samba3-ndr-client[=OUTF] create client calls for Samba3
- using Samba4's NDR code [cli_BASENAME.c]
- --samba3-ndr-server[=OUTF] create server call wrapper for Samba3
- using Samba4's NDR code [srv_BASENAME.c]
-
-Wireshark parsers:
- --ws-parser[=OUTFILE] create Wireshark parser and header
-\n";
- exit(0);
-}
-
-#########################################
-# Display version
-sub ShowVersion()
-{
- print "perl IDL version $VERSION\n";
-}
-
-# main program
-my $result = GetOptions (
- 'help|h|?' => \$opt_help,
- 'version' => \$opt_version,
- 'outputdir=s' => \$opt_outputdir,
- 'dump-idl' => \$opt_dump_idl,
- 'dump-idl-tree:s' => \$opt_dump_idl_tree,
- 'parse-idl-tree' => \$opt_parse_idl_tree,
- 'dump-ndr-tree:s' => \$opt_dump_ndr_tree,
- 'samba3-ndr-client:s' => \$opt_samba3_ndr_client,
- 'samba3-ndr-server:s' => \$opt_samba3_ndr_server,
- 'header:s' => \$opt_header,
- 'server:s' => \$opt_server,
- 'typelib:s' => \$opt_typelib,
- 'tdr-parser:s' => \$opt_tdr_parser,
- 'template' => \$opt_template,
- 'ndr-parser:s' => \$opt_ndr_parser,
- 'client:s' => \$opt_client,
- 'ws-parser:s' => \$opt_ws_parser,
- 'python' => \$opt_python,
- 'diff' => \$opt_diff,
- 'swig:s' => \$opt_swig,
- 'dcom-proxy:s' => \$opt_dcom_proxy,
- 'com-header:s' => \$opt_com_header,
- 'quiet' => \$opt_quiet,
- 'verbose' => \$opt_verbose,
- 'warn-compat' => \$opt_warn_compat,
- 'includedir=s@' => \@opt_incdirs
- );
-
-if (not $result) {
- exit(1);
-}
-
-if ($opt_help) {
- ShowHelp();
- exit(0);
-}
-
-if ($opt_version) {
- ShowVersion();
- exit(0);
-}
-
-sub process_file($)
-{
- my $idl_file = shift;
- my $outputdir = $opt_outputdir;
- my $pidl;
- my $ndr;
-
- my $basename = basename($idl_file, ".idl");
-
- unless ($opt_quiet) { print "Compiling $idl_file\n"; }
-
- if ($opt_parse_idl_tree) {
- $pidl = LoadStructure($idl_file);
- defined $pidl || die "Failed to load $idl_file";
- } else {
- require Parse::Pidl::IDL;
-
- $pidl = Parse::Pidl::IDL::parse_file($idl_file, \@opt_incdirs);
- defined @$pidl || die "Failed to parse $idl_file";
- }
-
- require Parse::Pidl::Typelist;
- Parse::Pidl::Typelist::LoadIdl($pidl);
-
- if (defined($opt_dump_idl_tree)) {
- my($pidl_file) = ($opt_dump_idl_tree or "$outputdir/$basename.pidl");
- SaveStructure($pidl_file, $pidl) or die "Failed to save $pidl_file\n";
- }
-
- if ($opt_dump_idl) {
- require Parse::Pidl::Dump;
- print Parse::Pidl::Dump($pidl);
- }
-
- if ($opt_diff) {
- my($tempfile) = "$outputdir/$basename.tmp";
- FileSave($tempfile, IdlDump::Dump($pidl));
- system("diff -wu $idl_file $tempfile");
- unlink($tempfile);
- }
-
- my $comh_filename = ($opt_com_header or "$outputdir/com_$basename.h");
- if (defined($opt_com_header)) {
- require Parse::Pidl::Samba4::COM::Header;
- my $res = Parse::Pidl::Samba4::COM::Header::Parse($pidl,"$outputdir/ndr_$basename.h");
- if ($res) {
- FileSave($comh_filename, $res);
- }
- }
-
- if (defined($opt_dcom_proxy)) {
- require Parse::Pidl::Samba4::COM::Proxy;
- my $res = Parse::Pidl::Samba4::COM::Proxy::Parse($pidl,$comh_filename);
- if ($res) {
- my ($client) = ($opt_dcom_proxy or "$outputdir/$basename\_p.c");
- FileSave($client, $res);
- }
- }
-
- if ($opt_warn_compat) {
- require Parse::Pidl::Compat;
- Parse::Pidl::Compat::Check($pidl);
- }
-
- $pidl = Parse::Pidl::ODL::ODL2IDL($pidl, dirname($idl_file), \@opt_incdirs);
-
- if (defined($opt_ws_parser) or
- defined($opt_client) or
- defined($opt_server) or
- defined($opt_header) or
- defined($opt_ndr_parser) or
- defined($opt_python) or
- defined($opt_dump_ndr_tree) or
- defined($opt_samba3_header) or
- defined($opt_samba3_parser) or
- defined($opt_samba3_server) or
- defined($opt_swig) or
- defined($opt_samba3_ndr_client) or
- defined($opt_samba3_ndr_server)) {
- require Parse::Pidl::NDR;
- $ndr = Parse::Pidl::NDR::Parse($pidl);
- }
-
- if (defined($opt_dump_ndr_tree)) {
- my($ndr_file) = ($opt_dump_ndr_tree or "$outputdir/$basename.ndr");
- SaveStructure($ndr_file, $ndr) or die "Failed to save $ndr_file\n";
- }
-
- my $gen_header = ($opt_header or "$outputdir/$basename.h");
- if (defined($opt_header)) {
- require Parse::Pidl::Samba4::Header;
- FileSave($gen_header, Parse::Pidl::Samba4::Header::Parse($ndr));
- }
-
- my $h_filename = "$outputdir/ndr_$basename.h";
- if (defined($opt_client)) {
- require Parse::Pidl::Samba4::NDR::Client;
- my ($c_client) = ($opt_client or "$outputdir/ndr_$basename\_c.c");
- my ($c_header) = $c_client;
- $c_header =~ s/\.c$/.h/;
-
- my ($srcd,$hdrd) = Parse::Pidl::Samba4::NDR::Client::Parse(
- $ndr,$gen_header,$h_filename,$c_header);
-
- FileSave($c_client, $srcd);
- FileSave($c_header, $hdrd);
- }
-
- if (defined($opt_swig)) {
- require Parse::Pidl::Samba4::SWIG;
- my($filename) = ($opt_swig or "$outputdir/$basename.i");
- my $code = Parse::Pidl::Samba4::SWIG::Parse($ndr, $basename, "$outputdir/ndr_$basename\_c.h", $gen_header);
- FileSave($filename, $code);
- }
-
- if (defined($opt_python)) {
- require Parse::Pidl::Samba4::Python;
- my $generator = new Parse::Pidl::Samba4::Python();
- my ($hdr,$prsr) = $generator->Parse($basename, $ndr,
- "$outputdir/ndr_$basename\_c.h", $h_filename);
- FileSave("$outputdir/py_$basename.c", $prsr);
- FileSave("$outputdir/py_$basename.h", $hdr);
- }
-
- if (defined($opt_server)) {
- require Parse::Pidl::Samba4::NDR::Server;
-
- FileSave(($opt_server or "$outputdir/ndr_$basename\_s.c"), Parse::Pidl::Samba4::NDR::Server::Parse($ndr,$h_filename));
- }
-
- if (defined($opt_ndr_parser)) {
- my $parser_fname = ($opt_ndr_parser or "$outputdir/ndr_$basename.c");
- require Parse::Pidl::Samba4::NDR::Parser;
- my $generator = new Parse::Pidl::Samba4::NDR::Parser();
- my ($header,$parser) = $generator->Parse($ndr, $gen_header, $h_filename);
-
- FileSave($parser_fname, $parser);
- FileSave($h_filename, $header);
-
- }
-
- if (defined($opt_ws_parser)) {
- require Parse::Pidl::Wireshark::NDR;
- my($eparser) = ($opt_ws_parser or "$outputdir/packet-dcerpc-$basename.c");
- my $eheader = $eparser;
- $eheader =~ s/\.c$/\.h/;
- my $cnffile = $idl_file;
- $cnffile =~ s/\.idl$/\.cnf/;
-
- my $generator = new Parse::Pidl::Wireshark::NDR();
- my ($dp, $dh) = $generator->Parse($ndr, $idl_file, $eheader, $cnffile);
- FileSave($eparser, $dp) if defined($dp);
- FileSave($eheader, $dh) if defined($dh);
- }
-
- if (defined($opt_tdr_parser)) {
- my $tdr_parser = ($opt_tdr_parser or "$outputdir/tdr_$basename.c");
- my $tdr_header = $tdr_parser;
- $tdr_header =~ s/\.c$/\.h/;
- require Parse::Pidl::Samba4::TDR;
- my $generator = new Parse::Pidl::Samba4::TDR();
- my ($hdr,$prsr) = $generator->Parser($pidl, $tdr_header, $gen_header);
- FileSave($tdr_parser, $prsr);
- FileSave($tdr_header, $hdr);
- }
-
- if (defined($opt_typelib)) {
- my $typelib = ($opt_typelib or "$outputdir/$basename.tlb");
- require Parse::Pidl::Typelist;
- FileSave($typelib, Parse::Pidl::Typelist::GenerateTypeLib());
- }
-
- if ($opt_template) {
- require Parse::Pidl::Samba4::Template;
- print Parse::Pidl::Samba4::Template::Parse($pidl);
- }
-
- if (defined($opt_samba3_ndr_client)) {
- my $client = ($opt_samba3_ndr_client or "$outputdir/cli_$basename.c");
- my $header = $client; $header =~ s/\.c$/\.h/;
- require Parse::Pidl::Samba3::ClientNDR;
- my $generator = new Parse::Pidl::Samba3::ClientNDR();
- my ($c_code,$h_code) = $generator->Parse($ndr, $header, $h_filename);
- FileSave($client, $c_code);
- FileSave($header, $h_code);
- }
-
- if (defined($opt_samba3_ndr_server)) {
- my $server = ($opt_samba3_ndr_server or "$outputdir/srv_$basename.c");
- my $header = $server; $header =~ s/\.c$/\.h/;
- require Parse::Pidl::Samba3::ServerNDR;
- my ($c_code,$h_code) = Parse::Pidl::Samba3::ServerNDR::Parse($ndr, $header, $h_filename);
- FileSave($server, $c_code);
- FileSave($header, $h_code);
- }
-
-}
-
-if (scalar(@ARGV) == 0) {
- print "$Script: no input files\n";
- exit(1);
-}
-
-process_file($_) foreach (@ARGV);
diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm
deleted file mode 100644
index 4ad216a6a1..0000000000
--- a/source4/pidl/tests/Util.pm
+++ /dev/null
@@ -1,179 +0,0 @@
-# Some simple utility functions for pidl tests
-# Copyright (C) 2005-2006 Jelmer Vernooij
-# Published under the GNU General Public License
-
-package Util;
-
-require Exporter;
-@ISA = qw(Exporter);
-@EXPORT = qw(test_samba4_ndr test_warnings test_errors);
-
-use strict;
-
-use FindBin qw($RealBin);
-use lib "$RealBin/../lib";
-
-use Parse::Pidl;
-my $warnings = "";
-undef &Parse::Pidl::warning;
-*Parse::Pidl::warning = sub {
- my ($e, $l) = @_;
- if (defined($e)) {
- $warnings .= "$e->{FILE}:$e->{LINE}: $l\n";
- } else {
- $warnings .= "$l\n";
- }
-};
-
-my $errors = "";
-undef &Parse::Pidl::error;
-*Parse::Pidl::error = sub {
- my ($e, $l) = @_;
- if (defined($e)) {
- $errors .= "$e->{FILE}:$e->{LINE}: $l\n";
- } else {
- $errors .= "$l\n";
- }
-};
-
-use Test::More;
-use Parse::Pidl::IDL;
-use Parse::Pidl::NDR;
-use Parse::Pidl::Samba4::NDR::Parser;
-use Parse::Pidl::Samba4::Header;
-
-# Generate a Samba4 parser for an IDL fragment and run it with a specified
-# piece of code to check whether the parser works as expected
-sub test_samba4_ndr
-{
- my ($name,$idl,$c,$extra) = @_;
-
- $extra = "" unless defined($extra);
-
- my $pidl = Parse::Pidl::IDL::parse_string("interface echo { $idl }; ", "<$name>");
- ok(defined($pidl), "($name) parse idl");
-
- my $pndr = Parse::Pidl::NDR::Parse($pidl);
- ok(defined($pndr), "($name) generate NDR tree");
-
- my $header = Parse::Pidl::Samba4::Header::Parse($pndr);
- ok(defined($header), "($name) generate generic header");
-
- my $generator = new Parse::Pidl::Samba4::NDR::Parser();
- my ($ndrheader,$ndrparser) = $generator->Parse($pndr, undef, undef);
- ok(defined($ndrparser), "($name) generate NDR parser");
- ok(defined($ndrheader), "($name) generate NDR header");
-
-SKIP: {
-
- skip "no samba environment available, skipping compilation", 3
- if (system("pkg-config --exists ndr") != 0);
-
- my $main = "
-#define uint_t unsigned int
-#define _GNU_SOURCE
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdbool.h>
-#include <stdarg.h>
-#include <util/data_blob.h>
-
-/* header start */
-$header
-/* header end */
-
-/* ndrheader start */
-$ndrheader
-/* ndrheader end */
-
-/* extra start */
-$extra
-/* extra end */
-
-/* ndrparser start */
-$ndrparser
-/* ndrparser end */
-
-/* main start */
-int main(int argc, const char **argv)
-{
- TALLOC_CTX *mem_ctx = talloc_init(NULL);
-
-$c
-
- talloc_free(mem_ctx);
-
- return 0;
-}
-/* main end */
-\n";
-
- my $main_debug = "# ".join("\n# ", split("\n", $main));
-
- my $test_data_prefix = $ENV{TEST_DATA_PREFIX};
- my $outfile;
- if (defined($test_data_prefix)) {
- $outfile = "$test_data_prefix/test-$name";
- } else {
- $outfile = "./test-$name";
- }
-
- my $cflags = $ENV{CFLAGS};
- unless (defined($cflags)) {
- $cflags = "";
- }
-
- my $ldflags = $ENV{LDFLAGS};
- unless (defined($ldflags)) {
- $ldflags = "";
- }
-
- my $cc = $ENV{CC};
- unless (defined($cc)) {
- $cc = "cc";
- }
-
- my $flags = `pkg-config --libs --cflags ndr`;
-
- my $cmd = "$cc $cflags -x c - -o $outfile $flags $ldflags";
- $cmd =~ s/\n//g;
- open CC, "|$cmd";
- print CC $main;
- close CC;
-
- ok(-f $outfile, "($name) compile");
-
- my $ret = system($outfile, ()) >> 8;
- print "# code:\n#\n$main_debug\n" if ($ret != 0);
- print "# cmd: $cmd\n" if ($ret != 0);
- print "# return code: $ret\n" if ($ret != 0);
-
- ok($ret == 0, "($name) run");
-
- ok(unlink($outfile), "($name) remove");
-
- }
-}
-
-sub test_warnings($$)
-{
- my ($exp, $code) = @_;
-
- $warnings = "";
-
- $code->();
-
- is($warnings, $exp);
-}
-
-sub test_errors($$)
-{
- my ($exp, $code) = @_;
- $errors = "";
- $code->();
-
- is($errors, $exp);
-}
-
-1;
diff --git a/source4/pidl/tests/cutil.pl b/source4/pidl/tests/cutil.pl
deleted file mode 100755
index 78c8bce45e..0000000000
--- a/source4/pidl/tests/cutil.pl
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/perl
-# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-use warnings;
-
-use Test::More tests => 7;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util;
-use Parse::Pidl::Util qw(MyDumper);
-use Parse::Pidl::CUtil qw(get_pointer_to get_value_of);
-
-is("&foo", get_pointer_to("foo"));
-is("&(&foo)", get_pointer_to(get_pointer_to("foo")));
-is("*foo", get_pointer_to("**foo"));
-is("foo", get_pointer_to("*foo"));
-
-is("foo", get_value_of("&foo"));
-is("*foo", get_value_of("foo"));
-is("**foo", get_value_of("*foo"));
diff --git a/source4/pidl/tests/dump.pl b/source4/pidl/tests/dump.pl
deleted file mode 100755
index d1a56f0973..0000000000
--- a/source4/pidl/tests/dump.pl
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/perl
-# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-use warnings;
-
-use Test::More tests => 1;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util;
-use Parse::Pidl::Dump qw(DumpStruct);
-
-is (DumpStruct({ NAME => "foo", ELEMENTS => []}),
- "struct foo {\n}");
-
diff --git a/source4/pidl/tests/header.pl b/source4/pidl/tests/header.pl
deleted file mode 100755
index db59484444..0000000000
--- a/source4/pidl/tests/header.pl
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/usr/bin/perl
-# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-use warnings;
-
-use Test::More tests => 27;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util;
-use Parse::Pidl::Util qw(MyDumper);
-use Parse::Pidl::Samba4::Header qw(
- GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv
- EnvSubstituteValue);
-use Parse::Pidl::IDL qw(parse_string);
-use Parse::Pidl::NDR;
-
-sub parse_idl($)
-{
- my $text = shift;
- my $idl = Parse::Pidl::IDL::parse_string($text, "nofile");
- my $ndr = Parse::Pidl::NDR::Parse($idl);
- return Parse::Pidl::Samba4::Header::Parse($ndr);
-}
-
-like(parse_idl(""), qr/\/\* header auto-generated by pidl \*\/\n/sm, "includes work");
-like(parse_idl("interface x {}"), qr/\/\* header auto-generated by pidl \*\/\n/sm, "simple empty interface doesn't cause overhead");
-like(parse_idl("interface p { typedef struct { int y; } x; };"),
- qr/.*#ifndef _HEADER_p\n#define _HEADER_p\n.+\n#endif \/\* _HEADER_p \*\/.*/ms, "ifdefs are created");
-like(parse_idl("interface p { typedef struct { int y; } x; };"),
- qr/struct x.*{.*int32_t y;.*}.*;/sm, "interface member generated properly");
-like(parse_idl("interface x { void foo (void); };"),
- qr/struct foo.*{\s+int _dummy_element;\s+};/sm, "void fn contains dummy element");
-like(parse_idl("interface x { void foo ([in] uint32 x); };"),
- qr/struct foo.*{\s+struct\s+{\s+uint32_t x;\s+} in;\s+};/sm, "fn in arg works");
-like(parse_idl("interface x { void foo ([out] uint32 x); };"),
- qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn out arg works");
-like(parse_idl("interface x { void foo ([in,out] uint32 x); };"),
- qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn in,out arg works");
-like(parse_idl("interface x { void foo (uint32 x); };"), qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn with no props implies in,out");
-like(parse_idl("interface p { struct x { int y; }; };"),
- qr/struct x.*{.*int32_t y;.*}.*;/sm, "interface member generated properly");
-
-like(parse_idl("interface p { struct x { struct y z; }; };"),
- qr/struct x.*{.*struct y z;.*}.*;/sm, "tagged type struct member");
-
-like(parse_idl("interface p { struct x { union y z; }; };"),
- qr/struct x.*{.*union y z;.*}.*;/sm, "tagged type union member");
-
-like(parse_idl("interface p { struct x { }; };"),
- qr/struct x.*{.*char _empty_;.*}.*;/sm, "empty struct");
-
-like(parse_idl("interface p { struct x; };"),
- qr/struct x;/sm, "struct declaration");
-
-like(parse_idl("interface p { typedef struct x { int p; } x; };"),
- qr/struct x.*{.*int32_t p;.*};/sm, "double struct declaration");
-
-like(parse_idl("cpp_quote(\"some-foo\")"),
- qr/some-foo/sm, "cpp quote");
-
-# Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work
-my $fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] };
-is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionInEnv($fn));
-
-$fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] };
-is_deeply({ "foo" => "r->out.foo" }, GenerateFunctionOutEnv($fn));
-
-$fn = { ELEMENTS => [ { DIRECTION => ["out", "in"], NAME => "foo" } ] };
-is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionInEnv($fn));
-
-$fn = { ELEMENTS => [ { DIRECTION => ["out", "in"], NAME => "foo" } ] };
-is_deeply({ "foo" => "r->out.foo" }, GenerateFunctionOutEnv($fn));
-
-$fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] };
-is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionOutEnv($fn));
-
-$fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] };
-is_deeply({ }, GenerateFunctionInEnv($fn));
-
-$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] };
-is_deeply({ foo => "r->foo", bar => "r->bar", this => "r" },
- GenerateStructEnv($fn, "r"));
-
-$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] };
-is_deeply({ foo => "some->complex.variable->foo",
- bar => "some->complex.variable->bar",
- this => "some->complex.variable" },
- GenerateStructEnv($fn, "some->complex.variable"));
-
-$fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 3 }} ] };
-
-my $env = GenerateStructEnv($fn, "r");
-EnvSubstituteValue($env, $fn);
-is_deeply($env, { foo => 3, this => "r" });
-
-$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] };
-$env = GenerateStructEnv($fn, "r");
-EnvSubstituteValue($env, $fn);
-is_deeply($env, { foo => 'r->foo', bar => 'r->bar', this => "r" });
-
-$fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 0 }} ] };
-
-$env = GenerateStructEnv($fn, "r");
-EnvSubstituteValue($env, $fn);
-is_deeply($env, { foo => 0, this => "r" });
-
-
diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl
deleted file mode 100755
index 504b7ec8de..0000000000
--- a/source4/pidl/tests/ndr.pl
+++ /dev/null
@@ -1,558 +0,0 @@
-#!/usr/bin/perl
-# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-use warnings;
-
-use Test::More tests => 46;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util;
-use Parse::Pidl::Util qw(MyDumper);
-use Parse::Pidl::NDR qw(GetElementLevelTable ParseElement align_type mapToScalar ParseType can_contain_deferred);
-
-# Case 1
-
-my $e = {
- 'FILE' => 'foo.idl',
- 'NAME' => 'v',
- 'PROPERTIES' => {},
- 'POINTERS' => 0,
- 'TYPE' => 'uint8',
- 'PARENT' => { TYPE => 'STRUCT' },
- 'LINE' => 42 };
-
-is_deeply(GetElementLevelTable($e, "unique"), [
- {
- 'IS_DEFERRED' => 0,
- 'LEVEL_INDEX' => 0,
- 'DATA_TYPE' => 'uint8',
- 'CONTAINS_DEFERRED' => 0,
- 'TYPE' => 'DATA',
- 'IS_SURROUNDING' => 0,
- }
-]);
-
-my $ne = ParseElement($e, "unique");
-is($ne->{ORIGINAL}, $e);
-is($ne->{NAME}, "v");
-is($ne->{ALIGN}, 1);
-is($ne->{TYPE}, "uint8");
-is_deeply($ne->{LEVELS}, [
- {
- 'IS_DEFERRED' => 0,
- 'LEVEL_INDEX' => 0,
- 'DATA_TYPE' => 'uint8',
- 'CONTAINS_DEFERRED' => 0,
- 'TYPE' => 'DATA',
- 'IS_SURROUNDING' => 0,
- }
-]);
-
-# Case 2 : pointers
-#
-$e = {
- 'FILE' => 'foo.idl',
- 'NAME' => 'v',
- 'PROPERTIES' => {"unique" => 1},
- 'POINTERS' => 1,
- 'PARENT' => { TYPE => 'STRUCT' },
- 'TYPE' => 'uint8',
- 'LINE' => 42 };
-
-is_deeply(GetElementLevelTable($e, "unique"), [
- {
- LEVEL_INDEX => 0,
- IS_DEFERRED => 0,
- TYPE => 'POINTER',
- POINTER_TYPE => "unique",
- POINTER_INDEX => 0,
- LEVEL => 'EMBEDDED'
- },
- {
- 'IS_DEFERRED' => 1,
- 'LEVEL_INDEX' => 1,
- 'DATA_TYPE' => 'uint8',
- 'CONTAINS_DEFERRED' => 0,
- 'TYPE' => 'DATA',
- 'IS_SURROUNDING' => 0,
- }
-]);
-
-# Case 3 : double pointers
-#
-$e = {
- 'FILE' => 'foo.idl',
- 'NAME' => 'v',
- 'PROPERTIES' => {"unique" => 1},
- 'POINTERS' => 2,
- 'TYPE' => 'uint8',
- 'PARENT' => { TYPE => 'STRUCT' },
- 'LINE' => 42 };
-
-is_deeply(GetElementLevelTable($e, "unique"), [
- {
- LEVEL_INDEX => 0,
- IS_DEFERRED => 0,
- TYPE => 'POINTER',
- POINTER_TYPE => "unique",
- POINTER_INDEX => 0,
- LEVEL => 'EMBEDDED'
- },
- {
- LEVEL_INDEX => 1,
- IS_DEFERRED => 1,
- TYPE => 'POINTER',
- POINTER_TYPE => "unique",
- POINTER_INDEX => 1,
- LEVEL => 'EMBEDDED'
- },
- {
- 'IS_DEFERRED' => 1,
- 'LEVEL_INDEX' => 2,
- 'DATA_TYPE' => 'uint8',
- 'CONTAINS_DEFERRED' => 0,
- 'TYPE' => 'DATA',
- 'IS_SURROUNDING' => 0,
- }
-]);
-
-# Case 3 : ref pointers
-#
-$e = {
- 'FILE' => 'foo.idl',
- 'NAME' => 'v',
- 'PROPERTIES' => {"ref" => 1},
- 'POINTERS' => 1,
- 'TYPE' => 'uint8',
- 'PARENT' => { TYPE => 'STRUCT' },
- 'LINE' => 42 };
-
-is_deeply(GetElementLevelTable($e, "unique"), [
- {
- LEVEL_INDEX => 0,
- IS_DEFERRED => 0,
- TYPE => 'POINTER',
- POINTER_TYPE => "ref",
- POINTER_INDEX => 0,
- LEVEL => 'EMBEDDED'
- },
- {
- 'IS_DEFERRED' => 1,
- 'LEVEL_INDEX' => 1,
- 'DATA_TYPE' => 'uint8',
- 'CONTAINS_DEFERRED' => 0,
- 'TYPE' => 'DATA',
- 'IS_SURROUNDING' => 0,
- }
-]);
-
-# Case 3 : ref pointers
-#
-$e = {
- 'FILE' => 'foo.idl',
- 'NAME' => 'v',
- 'PROPERTIES' => {"ref" => 1},
- 'POINTERS' => 3,
- 'TYPE' => 'uint8',
- 'PARENT' => { TYPE => 'STRUCT' },
- 'LINE' => 42 };
-
-is_deeply(GetElementLevelTable($e, "unique"), [
- {
- LEVEL_INDEX => 0,
- IS_DEFERRED => 0,
- TYPE => 'POINTER',
- POINTER_TYPE => "ref",
- POINTER_INDEX => 0,
- LEVEL => 'EMBEDDED'
- },
- {
- LEVEL_INDEX => 1,
- IS_DEFERRED => 1,
- TYPE => 'POINTER',
- POINTER_TYPE => "unique",
- POINTER_INDEX => 1,
- LEVEL => 'EMBEDDED'
- },
- {
- LEVEL_INDEX => 2,
- IS_DEFERRED => 1,
- TYPE => 'POINTER',
- POINTER_TYPE => "unique",
- POINTER_INDEX => 2,
- LEVEL => 'EMBEDDED'
- },
- {
- 'IS_DEFERRED' => 1,
- 'LEVEL_INDEX' => 3,
- 'DATA_TYPE' => 'uint8',
- 'CONTAINS_DEFERRED' => 0,
- 'TYPE' => 'DATA',
- 'IS_SURROUNDING' => 0,
- }
-]);
-
-# Case 3 : ref pointers
-#
-$e = {
- 'FILE' => 'foo.idl',
- 'NAME' => 'v',
- 'PROPERTIES' => {"ref" => 1},
- 'POINTERS' => 3,
- 'TYPE' => 'uint8',
- 'PARENT' => { TYPE => 'STRUCT' },
- 'LINE' => 42 };
-
-is_deeply(GetElementLevelTable($e, "ref"), [
- {
- LEVEL_INDEX => 0,
- IS_DEFERRED => 0,
- TYPE => 'POINTER',
- POINTER_TYPE => "ref",
- POINTER_INDEX => 0,
- LEVEL => 'EMBEDDED'
- },
- {
- LEVEL_INDEX => 1,
- IS_DEFERRED => 1,
- TYPE => 'POINTER',
- POINTER_TYPE => "ref",
- POINTER_INDEX => 1,
- LEVEL => 'EMBEDDED'
- },
- {
- LEVEL_INDEX => 2,
- IS_DEFERRED => 1,
- TYPE => 'POINTER',
- POINTER_TYPE => "ref",
- POINTER_INDEX => 2,
- LEVEL => 'EMBEDDED'
- },
- {
- 'IS_DEFERRED' => 1,
- 'LEVEL_INDEX' => 3,
- 'DATA_TYPE' => 'uint8',
- 'CONTAINS_DEFERRED' => 0,
- 'TYPE' => 'DATA',
- 'IS_SURROUNDING' => 0,
- }
-]);
-
-# Case 4 : top-level ref pointers
-#
-$e = {
- 'FILE' => 'foo.idl',
- 'NAME' => 'v',
- 'PROPERTIES' => {"ref" => 1},
- 'POINTERS' => 1,
- 'TYPE' => 'uint8',
- 'PARENT' => { TYPE => 'FUNCTION' },
- 'LINE' => 42 };
-
-is_deeply(GetElementLevelTable($e, "unique"), [
- {
- LEVEL_INDEX => 0,
- IS_DEFERRED => 0,
- TYPE => 'POINTER',
- POINTER_TYPE => "ref",
- POINTER_INDEX => 0,
- LEVEL => 'TOP'
- },
- {
- 'IS_DEFERRED' => 0,
- 'LEVEL_INDEX' => 1,
- 'DATA_TYPE' => 'uint8',
- 'CONTAINS_DEFERRED' => 0,
- 'TYPE' => 'DATA',
- 'IS_SURROUNDING' => 0,
- }
-]);
-
-# Case 4 : top-level ref pointers, triple with pointer_default("unique")
-#
-$e = {
- 'FILE' => 'foo.idl',
- 'NAME' => 'v',
- 'PROPERTIES' => {"ref" => 1},
- 'POINTERS' => 3,
- 'TYPE' => 'uint8',
- 'PARENT' => { TYPE => 'FUNCTION' },
- 'LINE' => 42 };
-
-is_deeply(GetElementLevelTable($e, "unique"), [
- {
- LEVEL_INDEX => 0,
- IS_DEFERRED => 0,
- TYPE => 'POINTER',
- POINTER_TYPE => "ref",
- POINTER_INDEX => 0,
- LEVEL => 'TOP'
- },
- {
- LEVEL_INDEX => 1,
- IS_DEFERRED => 0,
- TYPE => 'POINTER',
- POINTER_TYPE => "unique",
- POINTER_INDEX => 1,
- LEVEL => 'EMBEDDED'
- },
- {
- LEVEL_INDEX => 2,
- IS_DEFERRED => 1,
- TYPE => 'POINTER',
- POINTER_TYPE => "unique",
- POINTER_INDEX => 2,
- LEVEL => 'EMBEDDED'
- },
- {
- 'IS_DEFERRED' => 1,
- 'LEVEL_INDEX' => 3,
- 'DATA_TYPE' => 'uint8',
- 'CONTAINS_DEFERRED' => 0,
- 'TYPE' => 'DATA',
- 'IS_SURROUNDING' => 0,
- }
-]);
-
-# Case 4 : top-level unique pointers, triple with pointer_default("unique")
-#
-$e = {
- 'FILE' => 'foo.idl',
- 'NAME' => 'v',
- 'PROPERTIES' => {"unique" => 1, "in" => 1},
- 'POINTERS' => 3,
- 'TYPE' => 'uint8',
- 'PARENT' => { TYPE => 'FUNCTION' },
- 'LINE' => 42 };
-
-is_deeply(GetElementLevelTable($e, "unique"), [
- {
- LEVEL_INDEX => 0,
- IS_DEFERRED => 0,
- TYPE => 'POINTER',
- POINTER_TYPE => "unique",
- POINTER_INDEX => 0,
- LEVEL => 'TOP'
- },
- {
- LEVEL_INDEX => 1,
- IS_DEFERRED => 1,
- TYPE => 'POINTER',
- POINTER_TYPE => "unique",
- POINTER_INDEX => 1,
- LEVEL => 'EMBEDDED'
- },
- {
- LEVEL_INDEX => 2,
- IS_DEFERRED => 1,
- TYPE => 'POINTER',
- POINTER_TYPE => "unique",
- POINTER_INDEX => 2,
- LEVEL => 'EMBEDDED'
- },
- {
- 'IS_DEFERRED' => 1,
- 'LEVEL_INDEX' => 3,
- 'DATA_TYPE' => 'uint8',
- 'CONTAINS_DEFERRED' => 0,
- 'TYPE' => 'DATA',
- 'IS_SURROUNDING' => 0,
- }
-]);
-
-# Case 4 : top-level unique pointers, triple with pointer_default("ref")
-#
-$e = {
- 'FILE' => 'foo.idl',
- 'NAME' => 'v',
- 'PROPERTIES' => {"unique" => 1, "in" => 1},
- 'POINTERS' => 3,
- 'TYPE' => 'uint8',
- 'PARENT' => { TYPE => 'FUNCTION' },
- 'LINE' => 42 };
-
-is_deeply(GetElementLevelTable($e, "ref"), [
- {
- LEVEL_INDEX => 0,
- IS_DEFERRED => 0,
- TYPE => 'POINTER',
- POINTER_TYPE => "unique",
- POINTER_INDEX => 0,
- LEVEL => 'TOP'
- },
- {
- LEVEL_INDEX => 1,
- IS_DEFERRED => 1,
- TYPE => 'POINTER',
- POINTER_TYPE => "ref",
- POINTER_INDEX => 1,
- LEVEL => 'EMBEDDED'
- },
- {
- LEVEL_INDEX => 2,
- IS_DEFERRED => 1,
- TYPE => 'POINTER',
- POINTER_TYPE => "ref",
- POINTER_INDEX => 2,
- LEVEL => 'EMBEDDED'
- },
- {
- 'IS_DEFERRED' => 1,
- 'LEVEL_INDEX' => 3,
- 'DATA_TYPE' => 'uint8',
- 'CONTAINS_DEFERRED' => 0,
- 'TYPE' => 'DATA',
- 'IS_SURROUNDING' => 0,
- }
-]);
-
-# Case 4 : top-level ref pointers, triple with pointer_default("ref")
-#
-$e = {
- 'FILE' => 'foo.idl',
- 'NAME' => 'v',
- 'PROPERTIES' => {"ref" => 1},
- 'POINTERS' => 3,
- 'TYPE' => 'uint8',
- 'PARENT' => { TYPE => 'FUNCTION' },
- 'LINE' => 42 };
-
-is_deeply(GetElementLevelTable($e, "ref"), [
- {
- LEVEL_INDEX => 0,
- IS_DEFERRED => 0,
- TYPE => 'POINTER',
- POINTER_TYPE => "ref",
- POINTER_INDEX => 0,
- LEVEL => 'TOP'
- },
- {
- LEVEL_INDEX => 1,
- IS_DEFERRED => 0,
- TYPE => 'POINTER',
- POINTER_TYPE => "ref",
- POINTER_INDEX => 1,
- LEVEL => 'EMBEDDED'
- },
- {
- LEVEL_INDEX => 2,
- IS_DEFERRED => 1,
- TYPE => 'POINTER',
- POINTER_TYPE => "ref",
- POINTER_INDEX => 2,
- LEVEL => 'EMBEDDED'
- },
- {
- 'IS_DEFERRED' => 1,
- 'LEVEL_INDEX' => 3,
- 'DATA_TYPE' => 'uint8',
- 'CONTAINS_DEFERRED' => 0,
- 'TYPE' => 'DATA',
- 'IS_SURROUNDING' => 0,
- }
-]);
-
-# representation_type
-$e = {
- 'FILE' => 'foo.idl',
- 'NAME' => 'v',
- 'PROPERTIES' => { represent_as => "bar" },
- 'POINTERS' => 0,
- 'TYPE' => 'uint8',
- 'PARENT' => { TYPE => 'STRUCT' },
- 'LINE' => 42 };
-
-$ne = ParseElement($e, undef);
-is($ne->{REPRESENTATION_TYPE}, "bar");
-
-# representation_type
-$e = {
- 'FILE' => 'foo.idl',
- 'NAME' => 'v',
- 'PROPERTIES' => { },
- 'POINTERS' => 0,
- 'TYPE' => 'uint8',
- 'PARENT' => { TYPE => 'STRUCT' },
- 'LINE' => 42 };
-
-$ne = ParseElement($e, undef);
-is($ne->{REPRESENTATION_TYPE}, "uint8");
-
-is(align_type("hyper"), 8);
-is(align_type("uint32"), 4);
-is(align_type("uint16"), 2);
-is(align_type("uint8"), 1);
-is(align_type({ TYPE => "STRUCT", "NAME" => "bla",
- ELEMENTS => [ { TYPE => "uint16" } ] }), 4);
-is(align_type({ TYPE => "STRUCT",
- ELEMENTS => [ { TYPE => "hyper" } ] }), 8);
-is(align_type({ TYPE => "TYPEDEF", DATA => {
- TYPE => "STRUCT",
- ELEMENTS => [ { TYPE => "hyper" } ] }}), 8);
-# typedef of struct without body
-is(align_type({ TYPE => "TYPEDEF", DATA => {
- TYPE => "STRUCT", ELEMENTS => undef }}), 4);
-# struct without body
-is(align_type({ TYPE => "STRUCT", ELEMENTS => undef }), 4);
-# empty struct
-is(align_type({ TYPE => "STRUCT", ELEMENTS => [] }), 1);
-is(align_type({ TYPE => "STRUCT", "NAME" => "bla",
- ELEMENTS => [ { TYPE => "uint8" } ] }), 4);
-
-is(mapToScalar("someverymuchnotexistingtype"), undef);
-is(mapToScalar("uint32"), "uint32");
-is(mapToScalar({TYPE => "ENUM", PARENT => { PROPERTIES => { enum8bit => 1 } } }), "uint8");
-is(mapToScalar({TYPE => "BITMAP", PROPERTIES => { bitmap64bit => 1 } }),
- "hyper");
-is(mapToScalar({TYPE => "TYPEDEF", DATA => {TYPE => "ENUM", PARENT => { PROPERTIES => { enum8bit => 1 } } }}), "uint8");
-
-my $t;
-$t = {
- TYPE => "STRUCT",
- NAME => "foo",
- SURROUNDING_ELEMENT => undef,
- ELEMENTS => undef,
- PROPERTIES => undef,
- ORIGINAL => {
- TYPE => "STRUCT",
- NAME => "foo"
- },
- ALIGN => undef
-};
-is_deeply(ParseType($t->{ORIGINAL}, "ref"), $t);
-
-$t = {
- TYPE => "UNION",
- NAME => "foo",
- SWITCH_TYPE => "uint32",
- ELEMENTS => undef,
- PROPERTIES => undef,
- HAS_DEFAULT => 0,
- ORIGINAL => {
- TYPE => "UNION",
- NAME => "foo"
- }
-};
-is_deeply(ParseType($t->{ORIGINAL}, "ref"), $t);
-
-ok(not can_contain_deferred("uint32"));
-ok(can_contain_deferred("some_unknown_type"));
-ok(can_contain_deferred({ TYPE => "STRUCT",
- ELEMENTS => [ { TYPE => "uint32", POINTERS => 40 } ]}));
-ok(can_contain_deferred({ TYPE => "TYPEDEF",
- DATA => { TYPE => "STRUCT",
- ELEMENTS => [ { TYPE => "uint32", POINTERS => 40 } ]}}));
-ok(not can_contain_deferred({ TYPE => "STRUCT",
- ELEMENTS => [ { TYPE => "uint32" } ]}));
-ok(not can_contain_deferred({ TYPE => "TYPEDEF",
- DATA => { TYPE => "STRUCT",
- ELEMENTS => [ { TYPE => "uint32" } ]}}));
-ok(can_contain_deferred({ TYPE => "STRUCT",
- ELEMENTS => [ { TYPE => "someunknowntype" } ]}));
-# Make sure the elements for a enum without body aren't filled in
-ok(not defined(ParseType({TYPE => "ENUM", NAME => "foo" }, "ref")->{ELEMENTS}));
-# Make sure the elements for a bitmap without body aren't filled in
-ok(not defined(ParseType({TYPE => "BITMAP", NAME => "foo" }, "ref")->{ELEMENTS}));
-# Make sure the elements for a union without body aren't filled in
-ok(not defined(ParseType({TYPE => "UNION", NAME => "foo" }, "ref")->{ELEMENTS}));
diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl
deleted file mode 100755
index cc089eaa1f..0000000000
--- a/source4/pidl/tests/ndr_align.pl
+++ /dev/null
@@ -1,143 +0,0 @@
-#!/usr/bin/perl
-# NDR alignment tests
-# (C) 2005 Jelmer Vernooij. Published under the GNU GPL
-use strict;
-
-use Test::More tests => 5 * 8;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util qw(test_samba4_ndr);
-
-test_samba4_ndr('align-uint8-uint16',
-'
- typedef [public] struct {
- uint8 x;
- uint16 y;
- } bla;
-',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct bla r;
- uint8_t expected[] = { 0x0D, 0x00, 0xef, 0xbe };
- DATA_BLOB expected_blob = { expected, 4 };
- DATA_BLOB result_blob;
- r.x = 13;
- r.y = 0xbeef;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
- return 1;
-
- result_blob = ndr_push_blob(ndr);
-
- if (data_blob_cmp(&result_blob, &expected_blob) != 0)
- return 2;
-');
-
-test_samba4_ndr('align-uint8-uint32',
-'
- typedef [public] struct {
- uint8 x;
- uint32 y;
- } bla;
-',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct bla r;
- uint8_t expected[] = { 0x0D, 0x00, 0x00, 0x00, 0xef, 0xbe, 0xef, 0xbe };
- DATA_BLOB expected_blob = { expected, 8 };
- DATA_BLOB result_blob;
- r.x = 13;
- r.y = 0xbeefbeef;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
- return 1;
-
- result_blob = ndr_push_blob(ndr);
-
- if (data_blob_cmp(&result_blob, &expected_blob) != 0)
- return 2;
-');
-
-
-test_samba4_ndr('align-uint8-hyper',
-'
- typedef [public] struct {
- uint8 x;
- hyper y;
- } bla;
-',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct bla r;
- uint8_t expected[] = { 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe };
- DATA_BLOB expected_blob = { expected, 16 };
- DATA_BLOB result_blob;
- r.x = 13;
- r.y = 0xbeefbeefbeefbeefLLU;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
- return 1;
-
- result_blob = ndr_push_blob(ndr);
-
- if (data_blob_cmp(&result_blob, &expected_blob) != 0)
- return 2;
-');
-
-test_samba4_ndr('noalignflag-uint8-uint16',
-'
- typedef [public] struct {
- uint8 x;
- uint16 y;
- } bla;
-',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct bla r;
- uint8_t expected[] = { 0x0D, 0xef, 0xbe };
- DATA_BLOB expected_blob = { expected, 3 };
- DATA_BLOB result_blob;
- ndr->flags |= LIBNDR_FLAG_NOALIGN;
-
- r.x = 13;
- r.y = 0xbeef;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
- return 1;
-
- result_blob = ndr_push_blob(ndr);
-
- if (data_blob_cmp(&result_blob, &expected_blob) != 0)
- return 2;
-');
-
-test_samba4_ndr('align-blob-align2',
-'
- typedef [public] struct {
- uint8 x;
- [flag(LIBNDR_FLAG_ALIGN2)] DATA_BLOB data;
- uint8 y;
- } blie;
-',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct blie r;
- uint8_t data[] = { 0x01, 0x02 };
- uint8_t expected[] = { 0x0D, 0x00, 0x0E };
- DATA_BLOB expected_blob = { expected, 3 };
- DATA_BLOB result_blob;
-
- r.x = 13;
- r.y = 14;
- r.data.data = data;
- r.data.length = 2;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_blie(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
- return 1;
-
- result_blob = ndr_push_blob(ndr);
-
- if (data_blob_cmp(&result_blob, &expected_blob) != 0)
- return 2;
-');
diff --git a/source4/pidl/tests/ndr_alloc.pl b/source4/pidl/tests/ndr_alloc.pl
deleted file mode 100755
index 399fbd21d6..0000000000
--- a/source4/pidl/tests/ndr_alloc.pl
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/usr/bin/perl
-# NDR allocation tests
-# (C) 2005 Jelmer Vernooij. Published under the GNU GPL
-use strict;
-
-use Test::More tests => 5 * 8;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util qw(test_samba4_ndr);
-
-# Check that an outgoing scalar pointer is allocated correctly
-
-test_samba4_ndr("alloc-scalar",
-'
- typedef struct {
- uint8 *x;
- } bla;
-
- [public] void TestAlloc([in] bla foo);
-','
- uint8_t data[] = { 0xde, 0xad, 0xbe, 0xef, 0x03 };
- DATA_BLOB b = { data, 5 };
- struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
- struct TestAlloc r;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
- return 1;
-
- if (r.in.foo.x == NULL)
- return 2;
-
- if (*r.in.foo.x != 0x03)
- return 3;
-'
-);
-
-# Check that an outgoing buffer pointer is allocated correctly
-test_samba4_ndr("alloc-buffer",
-'
- typedef struct { uint8 data; } blie;
- typedef struct { blie *x; } bla;
-
- [public] void TestAlloc([in] bla foo);
-','
- uint8_t data[] = { 0xde, 0xad, 0xbe, 0xef, 0x03 };
- DATA_BLOB b = { data, 5 };
- struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
- struct TestAlloc r;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
- return 1;
-
- if (r.in.foo.x == NULL)
- return 2;
-
- if (r.in.foo.x->data != 0x03)
- return 3;
-'
-);
-
-# Check that ref pointers aren't allocated by default
-test_samba4_ndr("ref-noalloc-null",
-'
- [public] void TestAlloc([in,ref] uint8 *t);
-','
- uint8_t data[] = { 0x03 };
- DATA_BLOB b = { data, 1 };
- struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
- struct TestAlloc r;
- r.in.t = NULL;
-
- if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
- return 1;
-'
-);
-
-# Check that ref pointers aren't allocated by default
-test_samba4_ndr("ref-noalloc",
-'
- [public] void TestAlloc([in,ref] uint8 *t);
-','
- uint8_t data[] = { 0x03 };
- DATA_BLOB b = { data, 1 };
- struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
- struct TestAlloc r;
- uint8_t x;
- r.in.t = &x;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
- return 1;
-
- if (*r.in.t != 0x03)
- return 2;
-'
-);
-
-# Check that an outgoing ref pointer is allocated correctly
-test_samba4_ndr("ref-alloc",
-'
- [public] void TestAlloc([in,ref] uint8 *t);
-','
- uint8_t data[] = { 0x03 };
- DATA_BLOB b = { data, 1 };
- struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
- struct TestAlloc r;
- ndr->flags |= LIBNDR_FLAG_REF_ALLOC;
- r.in.t = NULL;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
- return 1;
-
- if (r.in.t == NULL)
- return 2;
-
- if (*r.in.t != 0x03)
- return 3;
-'
-);
diff --git a/source4/pidl/tests/ndr_array.pl b/source4/pidl/tests/ndr_array.pl
deleted file mode 100755
index 2a6b5bbd57..0000000000
--- a/source4/pidl/tests/ndr_array.pl
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/perl
-# Array testing
-# (C) 2005 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-
-use Test::More tests => 8;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util qw(test_samba4_ndr);
-
-test_samba4_ndr(
- 'Fixed-Array',
-
- '[public] void Test([in] uint8 x[10]);',
-
- '
- uint8_t data[] = {1,2,3,4,5,6,7,8,9,10};
- int i;
- DATA_BLOB b;
- struct ndr_pull *ndr;
- struct Test r;
-
- b.data = data;
- b.length = 10;
- ndr = ndr_pull_init_blob(&b, mem_ctx, NULL);
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_Test(ndr, NDR_IN, &r)))
- return 1;
-
- if (ndr->offset != 10)
- return 2;
-
- for (i = 0; i < 10; i++) {
- if (r.in.x[i] != i+1) return 3;
- }
-');
diff --git a/source4/pidl/tests/ndr_compat.pl b/source4/pidl/tests/ndr_compat.pl
deleted file mode 100755
index 355e7f6732..0000000000
--- a/source4/pidl/tests/ndr_compat.pl
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/perl
-# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-
-use Test::More tests => 2;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util;
-use Parse::Pidl;
-use Parse::Pidl::IDL;
-
-sub parse_idl($)
-{
- my $idl = shift;
- my $pidl = Parse::Pidl::IDL::parse_string("interface echo { $idl }; ", "nofile");
- Parse::Pidl::NDR::Parse($pidl);
-}
-
-test_warnings("", sub {parse_idl("void x();"); });
-test_warnings("nofile:0: top-level [out] pointer `x' is not a [ref] pointer\n", sub {parse_idl("void x([out,unique] int *x);"); });
diff --git a/source4/pidl/tests/ndr_deprecations.pl b/source4/pidl/tests/ndr_deprecations.pl
deleted file mode 100755
index 86828e5982..0000000000
--- a/source4/pidl/tests/ndr_deprecations.pl
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/perl
-# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-use warnings;
-
-use Test::More tests => 1;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util;
-use Parse::Pidl::Util qw(MyDumper);
-use Parse::Pidl::NDR qw(ValidElement);
-
-# Case 1
-
-my $e = {
- 'FILE' => 'foo.idl',
- 'NAME' => 'v',
- 'PROPERTIES' => {"subcontext" => 1},
- 'POINTERS' => 0,
- 'TYPE' => 'uint8',
- 'PARENT' => { TYPE => 'STRUCT' },
- 'LINE' => 42 };
-
-test_warnings("foo.idl:42: subcontext() is deprecated. Use represent_as() or transmit_as() instead\n",
- sub { ValidElement($e); });
diff --git a/source4/pidl/tests/ndr_fullptr.pl b/source4/pidl/tests/ndr_fullptr.pl
deleted file mode 100755
index cc6fca7ab3..0000000000
--- a/source4/pidl/tests/ndr_fullptr.pl
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/perl
-# Simple tests for unique pointers
-# (C) 2006 Jelmer Vernooij <jelmer@samba.org>.
-# Published under the GNU General Public License.
-use strict;
-
-use Test::More tests => 1 * 8;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util qw(test_samba4_ndr);
-
-SKIP: {
- skip "full pointers not supported yet", 8;
-
-test_samba4_ndr("fullptr-push-dup",
-'
- [public] uint16 echo_TestFull([in,ptr] uint32 *x, [in,ptr] uint32 *y);
-',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- uint32_t v = 13;
- struct echo_TestFull r;
- r.in.x = &v;
- r.in.y = &v;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestFull(ndr, NDR_IN, &r))) {
- fprintf(stderr, "push failed\n");
- return 1;
- }
-
- if (ndr->offset != 12) {
- fprintf(stderr, "Offset(%d) != 12\n", ndr->offset);
- return 2;
- }
-
- if (ndr->data[0] != ndr->data[8] ||
- ndr->data[1] != ndr->data[9] ||
- ndr->data[2] != ndr->data[10] ||
- ndr->data[3] != ndr->data[11]) {
- fprintf(stderr, "Data incorrect\n");
- return 3;
- }
-');
-}
diff --git a/source4/pidl/tests/ndr_refptr.pl b/source4/pidl/tests/ndr_refptr.pl
deleted file mode 100755
index d5dd83957a..0000000000
--- a/source4/pidl/tests/ndr_refptr.pl
+++ /dev/null
@@ -1,526 +0,0 @@
-#!/usr/bin/perl
-# Simple tests for pidl's handling of ref pointers, based
-# on tridge's ref_notes.txt
-# (C) 2005 Jelmer Vernooij <jelmer@samba.org>.
-# Published under the GNU General Public License.
-use strict;
-
-use Test::More tests => 22 * 8;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util qw(test_samba4_ndr);
-
-test_samba4_ndr("noptr-push",
-' typedef struct {
- uint16 x;
- } xstruct;
-
- [public] uint16 echo_TestRef([in] xstruct foo);
-',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- uint16_t v = 13;
- struct echo_TestRef r;
- r.in.foo.x = v;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) {
- fprintf(stderr, "push failed\n");
- return 1;
- }
-
- if (ndr->offset != 2) {
- fprintf(stderr, "Offset(%d) != 2\n", ndr->offset);
- return 2;
- }
-
- if (ndr->data[0] != 13 || ndr->data[1] != 0) {
- fprintf(stderr, "Data incorrect\n");
- return 3;
- }
-');
-
-test_samba4_ndr("ptr-embedded-push",
-' typedef struct {
- uint16 *x;
- } xstruct;
-
- [public] uint16 echo_TestRef([in] xstruct foo);
-',
-'
- uint16_t v = 13;
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- r.in.foo.x = &v;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- if (ndr->offset != 6)
- return 2;
-
- if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
- ndr->data[2] == 0 && ndr->data[3] == 0)
- return 3;
-
- if (ndr->data[4] != 13 || ndr->data[5] != 0)
- return 4;
-');
-
-test_samba4_ndr("ptr-embedded-push-null",
-' typedef struct {
- uint16 *x;
- } xstruct;
-
- [public] uint16 echo_TestRef([in] xstruct foo);
-',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- r.in.foo.x = NULL;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- if (ndr->offset != 4)
- return 2;
-
- if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
- ndr->data[2] != 0 || ndr->data[3] != 0)
- return 3;
-');
-
-test_samba4_ndr("refptr-embedded-push",
-'
- typedef struct {
- [ref] uint16 *x;
- } xstruct;
-
- [public] uint16 echo_TestRef([in] xstruct foo);
-',
-'
- uint16_t v = 13;
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- r.in.foo.x = &v;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- if (ndr->offset != 6)
- return 2;
-
- if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
- ndr->data[2] == 0 && ndr->data[3] == 0)
- return 3;
-
- if (ndr->data[4] != 13 || ndr->data[5] != 0)
- return 4;
-');
-
-test_samba4_ndr("refptr-embedded-push-null",
-'
- typedef struct {
- [ref] uint16 *x;
- } xstruct;
-
- [public] uint16 echo_TestRef([in] xstruct foo);
-',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- r.in.foo.x = NULL;
-
- if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
- /* Windows gives [client runtime error 0x6f4] */
-');
-
-test_samba4_ndr("ptr-top-push",
-'
- typedef struct {
- uint16 x;
- } xstruct;
-
- [public] uint16 echo_TestRef([in] xstruct *foo);
-',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- struct xstruct s;
- s.x = 13;
- r.in.foo = &s;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- if (ndr->offset != 2)
- return 2;
-
- if (ndr->data[0] != 13 || ndr->data[1] != 0)
- return 3;
-');
-
-test_samba4_ndr("ptr-top-push-null",
-'
- typedef struct {
- uint16 x;
- } xstruct;
-
- [public] uint16 echo_TestRef([in] xstruct *foo);
-',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- r.in.foo = NULL;
-
- if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- /* Windows gives [client runtime error 0x6f4] */
-');
-
-
-test_samba4_ndr("refptr-top-push",
-'
- typedef struct {
- uint16 x;
- } xstruct;
-
- [public] uint16 echo_TestRef([in,ref] xstruct *foo);
-',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- struct xstruct s;
- s.x = 13;
- r.in.foo = &s;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- if (ndr->offset != 2)
- return 2;
-
- if (ndr->data[0] != 13 || ndr->data[1] != 0)
- return 3;
-');
-
-test_samba4_ndr("refptr-top-push-null",
-'
- typedef struct {
- uint16 x;
- } xstruct;
-
- [public] uint16 echo_TestRef([in,ref] xstruct *foo);
-',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- r.in.foo = NULL;
-
- if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- /* Windows gives [client runtime error 0x6f4] */
-');
-
-
-test_samba4_ndr("uniqueptr-top-push",
-' typedef struct {
- uint16 x;
- } xstruct;
-
- [public] uint16 echo_TestRef([in,unique] xstruct *foo);
-',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- struct xstruct s;
- s.x = 13;
- r.in.foo = &s;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- if (ndr->offset != 6)
- return 2;
-
- if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
- ndr->data[2] == 0 && ndr->data[3] == 0)
- return 3;
-
- if (ndr->data[4] != 13 || ndr->data[5] != 0)
- return 4;
-');
-
-test_samba4_ndr("uniqueptr-top-push-null",
-' typedef struct {
- uint16 x;
- } xstruct;
-
- [public] uint16 echo_TestRef([in,unique] xstruct *foo);
-',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- r.in.foo = NULL;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- if (ndr->offset != 4)
- return 2;
-
- if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
- ndr->data[2] != 0 || ndr->data[3] != 0)
- return 3;
-');
-
-
-test_samba4_ndr("ptr-top-out-pull",
-'
- typedef struct {
- uint16 x;
- } xstruct;
-
- [public] void echo_TestRef([out] xstruct *foo);
-',
-'
- uint8_t data[] = { 0x0D, 0x00 };
- DATA_BLOB b = { data, 2 };
- struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
- struct xstruct s;
- struct echo_TestRef r;
-
- r.out.foo = &s;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
- return 1;
-
- if (!r.out.foo)
- return 2;
-
- if (r.out.foo->x != 13)
- return 3;
-');
-
-test_samba4_ndr("ptr-top-out-pull-null",
-'
- typedef struct {
- uint16 x;
- } xstruct;
-
- [public] void echo_TestRef([out] xstruct *foo);
-',
-'
- uint8_t data[] = { 0x0D, 0x00 };
- DATA_BLOB b = { data, 2 };
- struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
- struct echo_TestRef r;
-
- r.out.foo = NULL;
-
- if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
- return 1;
-
- /* Windows gives [client runtime error 0x6f4] */
-');
-
-
-test_samba4_ndr("refptr-top-out-pull",
-'
- typedef struct {
- uint16 x;
- } xstruct;
-
- [public] void echo_TestRef([out,ref] xstruct *foo);
-',
-'
- uint8_t data[] = { 0x0D, 0x00 };
- DATA_BLOB b = { data, 2 };
- struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
- struct xstruct s;
- struct echo_TestRef r;
-
- r.out.foo = &s;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
- return 1;
-
- if (!r.out.foo)
- return 2;
-
- if (r.out.foo->x != 13)
- return 3;
-');
-
-test_samba4_ndr("refptr-top-out-pull-null",
-'
- typedef struct {
- uint16 x;
- } xstruct;
-
- [public] void echo_TestRef([out,ref] xstruct *foo);
-',
-'
- uint8_t data[] = { 0x0D, 0x00 };
- DATA_BLOB b = { data, 2 };
- struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
- struct echo_TestRef r;
-
- r.out.foo = NULL;
-
- if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
- return 1;
-
- /* Windows gives [client runtime error 0x6f4] */
-');
-
-
-test_samba4_ndr("ptr-top-push-double",
-'
- [public] void echo_TestRef([in] uint16 **foo);
-',
-' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- uint16_t v = 13;
- uint16_t *pv = &v;
- r.in.foo = &pv;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- if (ndr->offset != 6)
- return 2;
-
- if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
- ndr->data[2] == 0 && ndr->data[3] == 0)
- return 3;
-
- if (ndr->data[4] != 0x0D || ndr->data[5] != 0x00)
- return 4;
-');
-
-SKIP: {
- skip "ptr-top-push-double-sndnull is known to fail", 8;
-
-test_samba4_ndr("ptr-top-push-double-sndnull",
-'
- [public] void echo_TestRef([in] uint16 **foo);
-',
-' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- uint16_t *pv = NULL;
- r.in.foo = &pv;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- if (ndr->offset != 4)
- return 2;
-
- if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
- ndr->data[2] != 0 || ndr->data[3] != 0)
- return 3;
-');
-}
-
-test_samba4_ndr("ptr-top-push-double-fstnull",
-'
- [public] void echo_TestRef([in] uint16 **foo);
-',
-' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- r.in.foo = NULL;
-
- if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- /* Windows gives [client runtime error 0x6f4] */
-
-');
-
-
-test_samba4_ndr("refptr-top-push-double",
-'
- [public] void echo_TestRef([in,ref] uint16 **foo);
-',
-' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- uint16_t v = 13;
- uint16_t *pv = &v;
- r.in.foo = &pv;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- if (ndr->offset != 6)
- return 2;
-
- if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
- ndr->data[2] == 0 && ndr->data[3] == 0)
- return 3;
-
- if (ndr->data[4] != 0x0D || ndr->data[5] != 0x00)
- return 4;
-');
-
-SKIP: {
-
- skip "refptr-top-push-double-sndnull is known to fail", 8;
-
-test_samba4_ndr("refptr-top-push-double-sndnull",
-'
- [public] void echo_TestRef([in,ref] uint16 **foo);
-',
-' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- uint16_t *pv = NULL;
- r.in.foo = &pv;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- if (ndr->offset != 4)
- return 2;
-
- if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
- ndr->data[2] != 0 || ndr->data[3] != 0)
- return 3;
-');
-}
-
-test_samba4_ndr("refptr-top-push-double-fstnull",
-'
- [public] void echo_TestRef([in,ref] uint16 **foo);
-',
-' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- r.in.foo = NULL;
-
- if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- /* Windows gives [client runtime error 0x6f4] */
-
-');
-
-SKIP: {
- skip "ignore-ptrs are not supported yet", 8;
-test_samba4_ndr("ignore-ptr",
-'
- [public] void echo_TestRef([in,ignore] uint16 *foo, [in] uint16 *bar);
-',
-' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct echo_TestRef r;
- uint16_t v = 10;
- r.in.foo = &v;
- r.in.bar = &v;
-
- if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
- return 1;
-
- if (ndr->offset != 4)
- return 2;
-');
-}
diff --git a/source4/pidl/tests/ndr_represent.pl b/source4/pidl/tests/ndr_represent.pl
deleted file mode 100755
index 2d65fb92b0..0000000000
--- a/source4/pidl/tests/ndr_represent.pl
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/perl
-# NDR represent_as() / transmit_as() tests
-# (C) 2006 Jelmer Vernooij. Published under the GNU GPL
-use strict;
-
-use Test::More tests => 2 * 8;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util qw(test_samba4_ndr);
-
-test_samba4_ndr('represent_as-simple',
-'
- void bla([in,represent_as(uint32)] uint8 x);
-',
-'
- uint8_t expected[] = { 0x0D };
- DATA_BLOB in_blob = { expected, 1 };
- struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL, NULL);
- struct bla r;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
- return 1;
-
- if (r.in.x != 13)
- return 2;
-',
-'
-enum ndr_err_code ndr_uint8_to_uint32(uint8_t from, uint32_t *to)
-{
- *to = from;
- return NDR_ERR_SUCCESS;
-}
-
-enum ndr_err_code ndr_uint32_to_uint8(uint32_t from, uint8_t *to)
-{
- *to = from;
- return NDR_ERR_SUCCESS;
-}
-'
-);
-
-test_samba4_ndr('transmit_as-simple',
-'
- void bla([in,transmit_as(uint32)] uint8 x);
-',
-'
- uint8_t expected[] = { 0x0D };
- DATA_BLOB in_blob = { expected, 1 };
- struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL, NULL);
- struct bla r;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
- return 1;
-
- if (r.in.x != 13)
- return 2;
-',
-'
-enum ndr_err_code ndr_uint8_to_uint32(uint8_t from, uint32_t *to)
-{
- *to = from;
- return NDR_ERR_SUCCESS;
-}
-
-enum ndr_err_code ndr_uint32_to_uint8(uint32_t from, uint8_t *to)
-{
- *to = from;
- return NDR_ERR_SUCCESS;
-}
-'
-);
diff --git a/source4/pidl/tests/ndr_simple.pl b/source4/pidl/tests/ndr_simple.pl
deleted file mode 100755
index 15e07d5693..0000000000
--- a/source4/pidl/tests/ndr_simple.pl
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/perl
-# Some simple tests for pidl
-# (C) 2005 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-
-use Test::More tests => 8;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util qw(test_samba4_ndr);
-
-test_samba4_ndr("simple", "void Test(); ",
-"
- uint8_t data[] = { 0x02 };
- uint8_t result;
- DATA_BLOB b;
- struct ndr_pull *ndr;
-
- b.data = data;
- b.length = 1;
- ndr = ndr_pull_init_blob(&b, mem_ctx, NULL);
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_uint8(ndr, NDR_SCALARS, &result)))
- return 1;
-
- if (result != 0x02)
- return 2;
-");
diff --git a/source4/pidl/tests/ndr_string.pl b/source4/pidl/tests/ndr_string.pl
deleted file mode 100755
index 2f2d941665..0000000000
--- a/source4/pidl/tests/ndr_string.pl
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/perl
-# String tests for pidl
-# (C) 2005 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-
-use Test::More tests => 3 * 8;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util qw(test_samba4_ndr);
-
-test_samba4_ndr("string-pull-empty",
-' [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data);',
-'
- uint8_t data[] = { 0x00, 0x00, 0x00, 0x00 };
- DATA_BLOB b = { data, 4 };
- struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL,
- smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true));
- struct TestString r;
- r.in.data = NULL;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r)))
- return 1;
-
- if (r.in.data == NULL)
- return 2;
-
- if (r.in.data[0] != 0)
- return 3;
-');
-
-test_samba4_ndr("string-ascii-pull",
-'
- [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data);
-',
-'
- uint8_t data[] = { 0x03, 0x00, 0x00, 0x00,
- \'f\', \'o\', \'o\', 0 };
- DATA_BLOB b = { data, 8 };
- struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL,
- smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true));
- struct TestString r;
- r.in.data = NULL;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r)))
- return 1;
-
- if (r.in.data == NULL)
- return 2;
-
- if (strncmp(r.in.data, "foo", 3) != 0)
- return 3;
-
- if (r.in.data[4] != 0)
- return 4;
-');
-
-SKIP: {
- skip "doesn't seem to work yet", 8;
-
-test_samba4_ndr("string-out",
-'
- [public] void TestString([out,string,charset(UNIX)] uint8 **data);
-',
-'
- uint8_t data[] = { 0x03, 0x00, 0x00, 0x00,
- \'f\', \'o\', \'o\', 0 };
- DATA_BLOB b = { data, 8 };
- struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL,
- smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true));
- struct TestString r;
- char *str = NULL;
- r.out.data = &str;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r)))
- return 1;
-
- if (r.out.data == NULL)
- return 2;
-
- if (*r.out.data == NULL)
- return 3;
-
- if (strncmp(r.out.data, "foo", 3) != 0)
- return 4;
-
- if (r.out.data[4] != 0)
- return 5;
-');
-}
diff --git a/source4/pidl/tests/ndr_tagtype.pl b/source4/pidl/tests/ndr_tagtype.pl
deleted file mode 100755
index 3f9b717bfe..0000000000
--- a/source4/pidl/tests/ndr_tagtype.pl
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/perl
-# Support for tagged types
-# (C) 2005 Jelmer Vernooij. Published under the GNU GPL
-use strict;
-
-use Test::More tests => 3 * 8;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util qw(test_samba4_ndr);
-
-test_samba4_ndr('struct-notypedef', '[public] struct bla { uint8 x; }; ',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct bla r;
- uint8_t expected[] = { 0x0D };
- DATA_BLOB expected_blob = { expected, 1 };
- DATA_BLOB result_blob;
- r.x = 13;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_STRUCT_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
- return 1;
-
- result_blob = ndr_push_blob(ndr);
-
- if (data_blob_cmp(&result_blob, &expected_blob) != 0)
- return 2;
-');
-
-test_samba4_ndr('struct-notypedef-used', '[public] struct bla { uint8 x; };
- [public] void myfn([in] struct bla r); ',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct myfn fn;
- uint8_t expected[] = { 0x0D };
- DATA_BLOB expected_blob = { expected, 1 };
- DATA_BLOB result_blob;
- fn.in.r.x = 13;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_myfn(ndr, NDR_IN, &fn)))
- return 1;
-
- result_blob = ndr_push_blob(ndr);
-
- if (data_blob_cmp(&result_blob, &expected_blob) != 0)
- return 2;
-');
-
-
-test_samba4_ndr('struct-notypedef-embedded', 'struct bla { uint8 x; };
- [public] struct myst { struct bla r; }; ',
-'
- struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
- struct myst st;
- uint8_t expected[] = { 0x0D };
- DATA_BLOB expected_blob = { expected, 1 };
- DATA_BLOB result_blob;
- st.r.x = 13;
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_STRUCT_myst(ndr, NDR_IN, &st)))
- return 1;
-
- result_blob = ndr_push_blob(ndr);
-
- if (data_blob_cmp(&result_blob, &expected_blob) != 0)
- return 2;
-');
diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl
deleted file mode 100755
index 9d43ddccc7..0000000000
--- a/source4/pidl/tests/parse_idl.pl
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/usr/bin/perl
-# Some simple tests for pidls parsing routines
-# (C) 2005 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-
-use Test::More tests => 65 * 2 + 7;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util qw(test_errors);
-use Parse::Pidl::IDL;
-use Parse::Pidl::NDR;
-
-sub testok($$)
-{
- my ($name, $data) = @_;
-
- test_errors("", sub {
- my $pidl = Parse::Pidl::IDL::parse_string($data, "<$name>");
- ok (defined($pidl), $name);
- });
-}
-
-sub testfail($$$)
-{
- my ($name, $data, $error) = @_;
-
- test_errors($error, sub {
- my $pidl = Parse::Pidl::IDL::parse_string($data, "<$name>");
-
- ok ((not defined $pidl), $name);
- });
-}
-
-testfail "unknowntag", "bla test {};",
- "<unknowntag>:0: Syntax error near 'bla'\n";
-testok "test1", "interface test { void Test(); }; ";
-testok "voidtest", "interface test { int Testx(void); }; ";
-testfail "voidtest", "interface test { Test(); }; ",
- "<voidtest>:0: Syntax error near '('\n";
-testok "argtest", "interface test { int Test(int a, long b, uint32 c); }; ";
-testok "array1", "interface test { int Test(int a[]); };";
-testok "array2", "interface test { int Test(int a[2]); };";
-testok "array3", "interface test { int Test(int a[b]); };";
-testfail "array4", "interface test { int Test(int[] a); };",
- "<array4>:0: Syntax error near '['\n";
-testok "ptr1", "interface test { int Test(int *a); };";
-testok "ptr2", "interface test { int Test(int **a); };";
-testok "ptr3", "interface test { int Test(int ***a); };";
-testfail "empty1", "interface test { };", "<empty1>:0: Syntax error near '}'\n";
-testfail "empty2", "", "";
-testok "attr1", "[uuid(\"myuuid\"),attr] interface test { int Test(int ***a); };";
-testok "attr2", "interface test { [public] int Test(); };";
-testok "attr3", "[attr1] [attr2] interface test { [public] int Test(); };";
-testok "multfn", "interface test { int test1(); int test2(); };";
-testok "multif", "interface test { int test1(); }; interface test2 { int test2(); };";
-testok "tdstruct1", "interface test { typedef struct { } foo; };";
-testok "tdstruct2", "interface test { typedef struct { int a; } foo; };";
-testok "tdstruct3", "interface test { typedef struct { int a; int b; } foo; };";
-testfail "tdstruct4", "interface test { typedef struct { int a, int b; } foo; };",
- "<tdstruct4>:0: Syntax error near ','\n";
-testok "struct1", "interface test { struct x { }; };";
-testok "struct2", "interface test { struct x { int a; }; };";
-testok "struct3", "interface test { struct x { int a; int b; }; };";
-testfail "struct4", "interface test { struct x { int a, int b; }; };",
- "<struct4>:0: Syntax error near ','\n";
-testfail "struct5", "interface test { struct { int a; } x; };",
- "<struct5>:0: Syntax error near 'x'\n";
-testok "tdunion1", "interface test { typedef union { } a; };";
-testok "tdunion2", "interface test { typedef union { int a; } a; };";
-testok "union1", "interface test { union a { }; };";
-testok "union2", "interface test { union x { int a; }; };";
-testfail "union3", "interface test { union { int a; } x; };",
- "<union3>:0: Syntax error near 'x'\n";
-testok "typedef1", "interface test { typedef int a; };";
-testfail "typedef2", "interface test { typedef x; };",
- "<typedef2>:0: Syntax error near ';'\n";
-testok "tdenum1", "interface test { typedef enum { A=1, B=2, C} a; };";
-testok "enum1", "interface test { enum a { A=1, B=2, C}; };";
-testfail "enum2", "interface test { enum { A=1, B=2, C} a; };",
- "<enum2>:0: Syntax error near 'a'\n";
-testok "nested1", "interface test { struct x { struct { int a; } z; }; };";
-testok "nested2", "interface test { struct x { struct y { int a; } z; }; };";
-testok "bitmap1", "interface test { bitmap x { a=1 }; };";
-testok "unsigned", "interface test { struct x { unsigned short y; }; };";
-testok "struct-property", "interface test { [public] struct x { short y; }; };";
-testok "signed", "interface test { struct x { signed short y; }; };";
-testok "declarg", "interface test { void test(struct { int x; } a); };";
-testok "structarg", "interface test { void test(struct a b); };";
-testfail "structargmissing", "interface test { void test(struct a); };",
- "<structargmissing>:0: Syntax error near ')'\n";
-testok "structqual", "interface test { struct x { struct y z; }; };";
-testok "unionqual", "interface test { struct x { union y z; }; };";
-testok "enumqual", "interface test { struct x { enum y z; }; };";
-testok "bitmapqual", "interface test { struct x { bitmap y z; }; };";
-testok "emptystructdecl", "interface test { struct x; };";
-testok "emptyenumdecl", "interface test { enum x; };";
-testok "emptytdstructdecl", "interface test { typedef struct x y; };";
-testok "import", "import \"foo.idl\";";
-testok "include", "include \"foo.h\";";
-testfail "import-noquotes", "import foo.idl;",
- "<import-noquotes>:0: Syntax error near 'foo'\n";
-testfail "include-noquotes", "include foo.idl;",
- "<include-noquotes>:0: Syntax error near 'foo'\n";
-testok "importlib", "importlib \"foo.idl\";";
-testfail "import-nosemicolon", "import \"foo.idl\"",
- "<import-nosemicolon>:0: Syntax error near 'foo.idl'\n";
-testok "import-multiple", "import \"foo.idl\", \"bar.idl\";";
-testok "include-multiple", "include \"foo.idl\", \"bar.idl\";";
-testok "empty-struct", "interface test { struct foo { }; }";
-testok "typedef-double", "interface test { typedef struct foo { } foo; }";
-testok "cpp-quote", "cpp_quote(\"bla\")";
-
-my $x = Parse::Pidl::IDL::parse_string("interface foo { struct x {}; }", "<foo>");
-
-is_deeply($x,
- [ { 'FILE' => '<foo>', 'NAME' => 'foo', 'DATA' => [
- { 'NAME' => 'x', 'TYPE' => 'STRUCT', ELEMENTS => [] } ],
- 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]);
-
-$x = Parse::Pidl::IDL::parse_string("interface foo { struct x; }", "<foo>");
-is_deeply($x,
- [ { 'FILE' => '<foo>', 'NAME' => 'foo', 'DATA' => [
- { 'NAME' => 'x', 'TYPE' => 'STRUCT' } ],
- 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]);
-
-$x = Parse::Pidl::IDL::parse_string("cpp_quote(\"foobar\")", "<quote>");
-is_deeply($x,
- [ { 'FILE' => '<quote>', 'DATA' => '"foobar"',
- 'TYPE' => 'CPP_QUOTE', 'LINE' => 0 } ]);
-
-# A typedef of a struct without body
-$x = Parse::Pidl::IDL::parse_string("interface foo { typedef struct x y; }", "<foo>");
-
-is_deeply($x,
- [ { 'FILE' => '<foo>', 'NAME' => 'foo', 'DATA' => [
- { 'FILE' => '<foo>', 'LINE' => 0, 'NAME' => 'y', 'TYPE' => 'TYPEDEF', DATA => {
- TYPE => 'STRUCT', NAME => 'x' } } ],
- 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]);
-
-# A typedef of a struct with empty body
-$x = Parse::Pidl::IDL::parse_string("interface foo { typedef struct {} y; }", "<foo>");
-
-is_deeply($x,
- [ { 'FILE' => '<foo>', 'NAME' => 'foo', 'DATA' => [
- { 'FILE' => '<foo>', 'LINE' => 0, 'NAME' => 'y', 'TYPE' => 'TYPEDEF', DATA => { TYPE => 'STRUCT', ELEMENTS => [] } } ],
- 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]);
-
-# A typedef of a bitmap with no body
-$x = Parse::Pidl::IDL::parse_string("interface foo { typedef bitmap x y; }", "<foo>");
-
-is_deeply($x,
- [ { 'FILE' => '<foo>', 'NAME' => 'foo', 'DATA' => [
- { 'FILE' => '<foo>', 'LINE' => 0, 'NAME' => 'y', 'TYPE' => 'TYPEDEF', DATA => { TYPE => 'BITMAP', NAME => 'x' } } ],
- 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]);
-
-
-# A typedef of a union with no body
-$x = Parse::Pidl::IDL::parse_string("interface foo { typedef union x y; }", "<foo>");
-
-is_deeply($x,
- [ { 'FILE' => '<foo>', 'NAME' => 'foo', 'DATA' => [
- { 'FILE' => '<foo>', 'LINE' => 0, 'NAME' => 'y', 'TYPE' => 'TYPEDEF', DATA => { TYPE => 'UNION', NAME => 'x' } } ],
- 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]);
diff --git a/source4/pidl/tests/samba-ejs.pl b/source4/pidl/tests/samba-ejs.pl
deleted file mode 100755
index 094d37a103..0000000000
--- a/source4/pidl/tests/samba-ejs.pl
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/perl
-# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-use warnings;
-
-use Test::More tests => 10;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util;
-use Parse::Pidl::Util qw(MyDumper);
-use Parse::Pidl::Samba4::EJS qw(check_null_pointer
- fn_declare TypeFunctionName);
-
-my $ejs = new Parse::Pidl::Samba4::EJS();
-
-$ejs->check_null_pointer("bla");
-is($ejs->{res}, "");
-
-$ejs = new Parse::Pidl::Samba4::EJS();
-$ejs->check_null_pointer("*bla");
-is($ejs->{res}, "if (bla == NULL) return NT_STATUS_INVALID_PARAMETER_MIX;\n");
-
-$ejs = new Parse::Pidl::Samba4::EJS();
-$ejs->fn_declare({ PROPERTIES => { public => 1 } }, "myproto(int x)");
-is($ejs->{res}, "_PUBLIC_ myproto(int x)\n");
-is($ejs->{res_hdr}, "myproto(int x);\n");
-
-$ejs = new Parse::Pidl::Samba4::EJS();
-$ejs->fn_declare({ PROPERTIES => {} }, "mybla(int foo)");
-is($ejs->{res}, "static mybla(int foo)\n");
-is($ejs->{res_hdr}, "");
-
-is(TypeFunctionName("ejs_pull", "uint32"), "ejs_pull_uint32");
-is(TypeFunctionName("ejs_pull", {TYPE => "ENUM", NAME => "bar"}), "ejs_pull_ENUM_bar");
-is(TypeFunctionName("ejs_pull", {TYPE => "TYPEDEF", NAME => "bar", DATA => undef}), "ejs_pull_bar");
-is(TypeFunctionName("ejs_push", {TYPE => "STRUCT", NAME => "bar"}), "ejs_push_STRUCT_bar");
diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl
deleted file mode 100755
index cdfe0514f1..0000000000
--- a/source4/pidl/tests/samba-ndr.pl
+++ /dev/null
@@ -1,296 +0,0 @@
-#!/usr/bin/perl
-# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-use warnings;
-
-use Test::More tests => 31;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util;
-use strict;
-use Parse::Pidl::Util qw(MyDumper);
-use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer
- NeededFunction NeededElement NeededType
- NeededInterface TypeFunctionName ParseElementPrint);
-
-my $output;
-sub print_fn($) { my $x = shift; $output.=$x; }
-
-# Test case 1: Simple unique pointer dereference
-
-$output = "";
-my $fn = check_null_pointer({
- PARENT => {
- ELEMENTS => [
- {
- NAME => "bla",
- LEVELS => [
- { TYPE => "POINTER",
- POINTER_INDEX => 0,
- POINTER_TYPE => "unique" },
- { TYPE => "DATA" }
- ],
- },
- ]
- }
-}, { bla => "r->in.bla" }, \&print_fn, "return;");
-
-
-test_warnings("", sub { $fn->("r->in.bla"); });
-
-is($output, "if (r->in.bla == NULL) return;");
-
-# Test case 2: Simple ref pointer dereference
-
-$output = "";
-$fn = check_null_pointer({
- PARENT => {
- ELEMENTS => [
- {
- NAME => "bla",
- LEVELS => [
- { TYPE => "POINTER",
- POINTER_INDEX => 0,
- POINTER_TYPE => "ref" },
- { TYPE => "DATA" }
- ],
- },
- ]
- }
-}, { bla => "r->in.bla" }, \&print_fn, undef);
-
-test_warnings("", sub { $fn->("r->in.bla"); });
-
-is($output, "");
-
-# Test case 3: Illegal dereference
-
-$output = "";
-$fn = check_null_pointer({
- FILE => "nofile",
- LINE => 1,
- PARENT => {
- ELEMENTS => [
- {
- NAME => "bla",
- LEVELS => [
- { TYPE => "DATA" }
- ],
- },
- ]
- }
-}, { bla => "r->in.bla" }, \&print_fn, undef);
-
-test_warnings("nofile:1: too much dereferences for `bla'\n",
- sub { $fn->("r->in.bla"); });
-
-is($output, "");
-
-# Test case 4: Double pointer dereference
-
-$output = "";
-$fn = check_null_pointer({
- PARENT => {
- ELEMENTS => [
- {
- NAME => "bla",
- LEVELS => [
- { TYPE => "POINTER",
- POINTER_INDEX => 0,
- POINTER_TYPE => "unique" },
- { TYPE => "POINTER",
- POINTER_INDEX => 1,
- POINTER_TYPE => "unique" },
- { TYPE => "DATA" }
- ],
- },
- ]
- }
-}, { bla => "r->in.bla" }, \&print_fn, "return;");
-
-test_warnings("",
- sub { $fn->("*r->in.bla"); });
-
-is($output, "if (*r->in.bla == NULL) return;");
-
-# Test case 5: Unknown variable
-
-$output = "";
-$fn = check_null_pointer({
- FILE => "nofile",
- LINE => 2,
- PARENT => {
- ELEMENTS => [
- {
- NAME => "bla",
- LEVELS => [
- { TYPE => "DATA" }
- ],
- },
- ]
- }
-}, { }, \&print_fn, "return;");
-
-test_warnings("nofile:2: unknown dereferenced expression `r->in.bla'\n",
- sub { $fn->("r->in.bla"); });
-
-is($output, "if (r->in.bla == NULL) return;");
-
-my $needed = {};
-NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "pull", $needed);
-is_deeply($needed, { ndr_pull_foo => 1 });
-
-# old settings should be kept
-$needed = { ndr_pull_foo => 0 };
-NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "pull", $needed);
-is_deeply($needed, { ndr_pull_foo => 0 });
-
-# print/pull/push are independent of each other
-$needed = { ndr_pull_foo => 0 };
-NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "print", $needed);
-is_deeply($needed, { ndr_pull_foo => 0, ndr_print_foo => 1 });
-
-$needed = { };
-NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] }, $needed);
-is_deeply($needed, { ndr_pull_foo => 1, ndr_print_foo => 1, ndr_push_foo => 1,
- ndr_pull_bar => 1, ndr_print_bar => 1, ndr_push_bar => 1});
-
-# push/pull/print are always set for functions
-$needed = { ndr_pull_foo => 0 };
-NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] }, $needed);
-is_deeply($needed, { ndr_pull_foo => 1, ndr_print_foo => 1, ndr_push_foo => 1,
- ndr_pull_bar => 1, ndr_push_bar => 1, ndr_print_bar => 1});
-
-# public structs are always needed
-$needed = {};
-NeededType({ NAME => "bla", TYPE => "TYPEDEF",
- DATA => { TYPE => "STRUCT", ELEMENTS => [] } },
- $needed, "pull");
-is_deeply($needed, { });
-
-$needed = {};
-NeededInterface({ TYPES => [ { PROPERTIES => { public => 1 }, NAME => "bla",
- TYPE => "TYPEDEF",
- DATA => { TYPE => "STRUCT", ELEMENTS => [] } } ] },
- $needed);
-is_deeply($needed, { ndr_pull_bla => 1, ndr_push_bla => 1, ndr_print_bla => 1 });
-
-# make sure types for elements are set too
-$needed = {};
-NeededInterface({ TYPES => [ { PROPERTIES => { public => 1 }, NAME => "bla",
- TYPE => "TYPEDEF",
- DATA => { TYPE => "STRUCT",
- ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } } ] },
- $needed);
-is_deeply($needed, { ndr_pull_bla => 1, ndr_pull_bar => 1, ndr_push_bla => 1, ndr_push_bar => 1,
- ndr_print_bla => 1, ndr_print_bar => 1});
-
-$needed = {};
-NeededInterface({ TYPES => [ { PROPERTIES => { gensize => 1}, NAME => "bla",
- TYPE => "TYPEDEF",
- DATA => { TYPE => "STRUCT",
- ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } } ] },
- $needed);
-is_deeply($needed, { ndr_size_bla => 1 });
-
-# make sure types for elements are set too
-$needed = { ndr_pull_bla => 1 };
-NeededType({ NAME => "bla",
- TYPE => "TYPEDEF",
- DATA => { TYPE => "STRUCT",
- ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } },
- $needed, "pull");
-is_deeply($needed, { ndr_pull_bla => 1, ndr_pull_bar => 1 });
-
-$needed = {};
-NeededInterface({ TYPES => [ { PROPERTIES => { public => 1},
- NAME => "bla",
- TYPE => "TYPEDEF",
- DATA => { TYPE => "STRUCT",
- ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "rep" } ] } } ] }, $needed);
-is_deeply($needed, { ndr_pull_bla => 1, ndr_push_bla => 1, ndr_print_bla => 1,
- ndr_print_rep => 1,
- ndr_pull_bar => 1, ndr_push_bar => 1,
- ndr_bar_to_rep => 1, ndr_rep_to_bar => 1});
-
-my $generator = new Parse::Pidl::Samba4::NDR::Parser();
-$generator->ParseStructPush({
- NAME => "mystruct",
- TYPE => "STRUCT",
- PROPERTIES => {},
- ALIGN => 4,
- ELEMENTS => [ ]}, "ndr", "x");
-is($generator->{res}, "if (ndr_flags & NDR_SCALARS) {
- NDR_CHECK(ndr_push_align(ndr, 4));
-}
-if (ndr_flags & NDR_BUFFERS) {
-}
-");
-
-$generator = new Parse::Pidl::Samba4::NDR::Parser();
-my $e = {
- NAME => "el1",
- TYPE => "mytype",
- REPRESENTATION_TYPE => "mytype",
- PROPERTIES => {},
- LEVELS => [
- { LEVEL_INDEX => 0, TYPE => "DATA", DATA_TYPE => "mytype" }
-] };
-$generator->ParseStructPush({
- NAME => "mystruct",
- TYPE => "STRUCT",
- PROPERTIES => {},
- ALIGN => 4,
- SURROUNDING_ELEMENT => $e,
- ELEMENTS => [ $e ]}, "ndr", "x");
-is($generator->{res}, "if (ndr_flags & NDR_SCALARS) {
- NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_string_array_size(ndr, x->el1)));
- NDR_CHECK(ndr_push_align(ndr, 4));
- NDR_CHECK(ndr_push_mytype(ndr, NDR_SCALARS, &x->el1));
-}
-if (ndr_flags & NDR_BUFFERS) {
-}
-");
-
-is(TypeFunctionName("ndr_pull", "uint32"), "ndr_pull_uint32");
-is(TypeFunctionName("ndr_pull", {TYPE => "ENUM", NAME => "bar"}), "ndr_pull_ENUM_bar");
-is(TypeFunctionName("ndr_pull", {TYPE => "TYPEDEF", NAME => "bar", DATA => undef}), "ndr_pull_bar");
-is(TypeFunctionName("ndr_push", {TYPE => "STRUCT", NAME => "bar"}), "ndr_push_STRUCT_bar");
-
-# check noprint works
-$generator = new Parse::Pidl::Samba4::NDR::Parser();
-$generator->ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt",
- PROPERTIES => { noprint => 1},
- LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt"} ]},
- "ndr", "var", { "x" => "r->foobar" } );
-is($generator->{res}, "");
-
-$generator = new Parse::Pidl::Samba4::NDR::Parser();
-$generator->ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt",
- PROPERTIES => {},
- LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt" }]},
- "ndr", "var", { "x" => "r->foobar" } );
-is($generator->{res}, "ndr_print_rt(ndr, \"x\", &var);\n");
-
-# make sure that a print function for an element with value() set works
-$generator = new Parse::Pidl::Samba4::NDR::Parser();
-$generator->ParseElementPrint({ NAME => "x", TYPE => "uint32", REPRESENTATION_TYPE => "uint32",
- PROPERTIES => { value => "23" },
- LEVELS => [ { TYPE => "DATA", DATA_TYPE => "uint32"} ]},
- "ndr", "var", { "x" => "r->foobar" } );
-is($generator->{res}, "ndr_print_uint32(ndr, \"x\", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?23:var);\n");
-
-$generator = new Parse::Pidl::Samba4::NDR::Parser();
-$generator->AuthServiceStruct("bridge", "\"rot13\",\"onetimepad\"");
-is($generator->{res}, "static const char * const bridge_authservice_strings[] = {
- \"rot13\",
- \"onetimepad\",
-};
-
-static const struct ndr_interface_string_array bridge_authservices = {
- .count = 2,
- .names = bridge_authservice_strings
-};
-
-");
diff --git a/source4/pidl/tests/samba3-cli.pl b/source4/pidl/tests/samba3-cli.pl
deleted file mode 100755
index d762954159..0000000000
--- a/source4/pidl/tests/samba3-cli.pl
+++ /dev/null
@@ -1,126 +0,0 @@
-#!/usr/bin/perl
-# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-use warnings;
-
-use Test::More tests => 9;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util;
-use Parse::Pidl::Util qw(MyDumper);
-use Parse::Pidl::Samba3::ClientNDR qw(ParseFunction ParseOutputArgument);
-use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv);
-
-# Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work
-my $fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] };
-is_deeply({ "foo" => "r.in.foo" }, GenerateFunctionInEnv($fn, "r."));
-is_deeply({ "foo" => "r.in.foo" }, GenerateFunctionOutEnv($fn, "r."));
-
-$fn = { ELEMENTS => [ { DIRECTION => ["out", "in"], NAME => "foo" } ] };
-is_deeply({ "foo" => "r.in.foo" }, GenerateFunctionInEnv($fn, "r."));
-is_deeply({ "foo" => "r.out.foo" }, GenerateFunctionOutEnv($fn, "r."));
-
-$fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] };
-is_deeply({ }, GenerateFunctionInEnv($fn, "r."));
-is_deeply({ "foo" => "r.out.foo" }, GenerateFunctionOutEnv($fn, "r."));
-
-my $x = new Parse::Pidl::Samba3::ClientNDR();
-
-$fn = { NAME => "bar", ELEMENTS => [ ] };
-$x->ParseFunction("foo", $fn);
-is($x->{res},
-"NTSTATUS rpccli_bar(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx)
-{
-\tstruct bar r;
-\tNTSTATUS status;
-
-\t/* In parameters */
-
-\tif (DEBUGLEVEL >= 10) {
-\t\tNDR_PRINT_IN_DEBUG(bar, &r);
-\t}
-
- status = cli_do_rpc_ndr(cli,
- mem_ctx,
- &ndr_table_foo,
- NDR_BAR,
- &r);
-
-\tif (!NT_STATUS_IS_OK(status)) {
-\t\treturn status;
-\t}
-
-\tif (DEBUGLEVEL >= 10) {
-\t\tNDR_PRINT_OUT_DEBUG(bar, &r);
-\t}
-
-\tif (NT_STATUS_IS_ERR(status)) {
-\t\treturn status;
-\t}
-
-\t/* Return variables */
-
-\t/* Return result */
-\treturn NT_STATUS_OK;
-}
-
-");
-
-$x = new Parse::Pidl::Samba3::ClientNDR();
-
-$fn = { NAME => "bar", ELEMENTS => [ ], RETURN_TYPE => "WERROR" };
-$x->ParseFunction("foo", $fn);
-is($x->{res},
-"NTSTATUS rpccli_bar(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- WERROR *werror)
-{
-\tstruct bar r;
-\tNTSTATUS status;
-
-\t/* In parameters */
-
-\tif (DEBUGLEVEL >= 10) {
-\t\tNDR_PRINT_IN_DEBUG(bar, &r);
-\t}
-
- status = cli_do_rpc_ndr(cli,
- mem_ctx,
- &ndr_table_foo,
- NDR_BAR,
- &r);
-
-\tif (!NT_STATUS_IS_OK(status)) {
-\t\treturn status;
-\t}
-
-\tif (DEBUGLEVEL >= 10) {
-\t\tNDR_PRINT_OUT_DEBUG(bar, &r);
-\t}
-
-\tif (NT_STATUS_IS_ERR(status)) {
-\t\treturn status;
-\t}
-
-\t/* Return variables */
-
-\t/* Return result */
-\tif (werror) {
-\t\t*werror = r.out.result;
-\t}
-
-\treturn werror_to_ntstatus(r.out.result);
-}
-
-");
-
-$x = new Parse::Pidl::Samba3::ClientNDR();
-
-$fn = { NAME => "bar", ELEMENTS => [ ], RETURN_TYPE => "WERROR" };
-my $e = { NAME => "foo", ORIGINAL => { FILE => "f", LINE => -1 },
- LEVELS => [ { TYPE => "ARRAY", SIZE_IS => "mysize" }, { TYPE => "DATA", DATA_TYPE => "int" } ]};
-
-$x->ParseOutputArgument($fn, $e);
-is($x->{res}, "memcpy(foo, r.out.foo, mysize * sizeof(*foo));\n");
diff --git a/source4/pidl/tests/samba3-srv.pl b/source4/pidl/tests/samba3-srv.pl
deleted file mode 100644
index d1e2bc9545..0000000000
--- a/source4/pidl/tests/samba3-srv.pl
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/perl
-# (C) 2008 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-use warnings;
-
-use Test::More tests => 1;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util;
-use Parse::Pidl::Util qw(MyDumper has_property);
-use Parse::Pidl::Samba3::ServerNDR qw(DeclLevel);
-
-my $l = { TYPE => "DATA", DATA_TYPE => "uint32" };
-my $e = { FILE => "foo", LINE => 0, PROPERTIES => { }, TYPE => "uint32",
- LEVELS => [ $l ] };
-
-is("uint32_t", DeclLevel($e, 0));
diff --git a/source4/pidl/tests/tdr.pl b/source4/pidl/tests/tdr.pl
deleted file mode 100755
index d6cd7a03d4..0000000000
--- a/source4/pidl/tests/tdr.pl
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/perl
-# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-use warnings;
-
-use Test::More tests => 6;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util;
-use Parse::Pidl::Samba4::TDR qw(ParserType);
-
-my $tdr = new Parse::Pidl::Samba4::TDR();
-
-$tdr->ParserType({TYPE => "STRUCT", NAME => "foo", PROPERTIES => {public => 1}}, "pull");
-is($tdr->{ret}, "NTSTATUS tdr_pull_foo (struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, struct foo *v)
-{
- return NT_STATUS_OK;
-}
-
-");
-is($tdr->{ret_hdr}, "NTSTATUS tdr_pull_foo (struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, struct foo *v);\n");
-
-
-$tdr = new Parse::Pidl::Samba4::TDR();
-$tdr->ParserType({TYPE => "UNION", NAME => "bar", PROPERTIES => {public => 1}}, "pull");
-is($tdr->{ret}, "NTSTATUS tdr_pull_bar(struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, int level, union bar *v)
-{
- switch (level) {
- }
- return NT_STATUS_OK;
-
-}
-
-");
-is($tdr->{ret_hdr}, "NTSTATUS tdr_pull_bar(struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, int level, union bar *v);\n");
-
-$tdr = new Parse::Pidl::Samba4::TDR();
-$tdr->ParserType({TYPE => "UNION", NAME => "bar", PROPERTIES => {}}, "pull");
-is($tdr->{ret}, "static NTSTATUS tdr_pull_bar(struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, int level, union bar *v)
-{
- switch (level) {
- }
- return NT_STATUS_OK;
-
-}
-
-");
-is($tdr->{ret_hdr}, "");
diff --git a/source4/pidl/tests/test_util.pl b/source4/pidl/tests/test_util.pl
deleted file mode 100755
index 2d59f6283b..0000000000
--- a/source4/pidl/tests/test_util.pl
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/perl
-# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-
-use Test::More tests => 6;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util qw(test_warnings test_errors);
-use Parse::Pidl qw(warning error);
-
-test_warnings("", sub {});
-
-test_warnings("x:1: msg\n", sub { warning({FILE => "x", LINE => 1}, "msg"); });
-test_warnings("", sub {});
-
-test_errors("", sub {});
-
-test_errors("x:1: msg\n", sub { error({FILE => "x", LINE => 1}, "msg"); });
-test_errors("", sub {});
-
diff --git a/source4/pidl/tests/typelist.pl b/source4/pidl/tests/typelist.pl
deleted file mode 100755
index 54f4d34586..0000000000
--- a/source4/pidl/tests/typelist.pl
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/perl
-# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-use warnings;
-
-use Test::More tests => 54;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util;
-use Parse::Pidl::Typelist qw(hasType typeHasBody getType mapTypeName expandAlias
- mapScalarType addType typeIs is_scalar scalar_is_reference
- enum_type_fn bitmap_type_fn mapType);
-
-is("foo", expandAlias("foo"));
-is("uint32", expandAlias("DWORD"));
-is("int32", expandAlias("int"));
-is("", expandAlias(""));
-is("int32", expandAlias("int32"));
-
-is("uint32_t", mapScalarType("uint32"));
-is("void", mapScalarType("void"));
-is("uint64_t", mapScalarType("hyper"));
-
-my $x = { TYPE => "ENUM", NAME => "foo", EXTRADATA => 1 };
-addType($x);
-is_deeply($x, getType("foo"));
-is(undef, getType("bloebla"));
-is_deeply(getType({ TYPE => "STRUCT" }), { TYPE => "STRUCT" });
-is_deeply(getType({ TYPE => "ENUM", NAME => "foo" }), $x);
-is_deeply(getType("uint16"), {
- NAME => "uint16",
- TYPE => "TYPEDEF",
- DATA => { NAME => "uint16", TYPE => "SCALAR" }});
-
-is(0, typeIs("someUnknownType", "ENUM"));
-is(0, typeIs("foo", "ENUM"));
-addType({NAME => "mytypedef", TYPE => "TYPEDEF", DATA => { TYPE => "ENUM" }});
-is(1, typeIs("mytypedef", "ENUM"));
-is(0, typeIs("mytypedef", "BITMAP"));
-is(1, typeIs({ TYPE => "ENUM"}, "ENUM"));
-is(0, typeIs({ TYPE => "BITMAP"}, "ENUM"));
-is(1, typeIs("uint32", "SCALAR"));
-is(0, typeIs("uint32", "ENUM"));
-
-is(1, hasType("foo"));
-is(0, hasType("nonexistant"));
-is(0, hasType({TYPE => "ENUM", NAME => "someUnknownType"}));
-is(1, hasType({TYPE => "ENUM", NAME => "foo"}));
-is(1, hasType({TYPE => "ENUM"}));
-is(1, hasType({TYPE => "STRUCT"}));
-
-is(1, is_scalar("uint32"));
-is(0, is_scalar("nonexistant"));
-is(1, is_scalar({TYPE => "ENUM"}));
-is(0, is_scalar({TYPE => "STRUCT"}));
-is(1, is_scalar({TYPE => "TYPEDEF", DATA => {TYPE => "ENUM" }}));
-is(1, is_scalar("mytypedef"));
-
-is(1, scalar_is_reference("string"));
-is(0, scalar_is_reference("uint32"));
-is(0, scalar_is_reference({TYPE => "STRUCT", NAME => "echo_foobar"}));
-
-is("uint8", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {enum8bit => 1}}}));
-is("uint32", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {v1_enum => 1}}}));
-is("uint16", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {}}}));
-
-is("uint8", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {bitmap8bit => 1}}));
-is("uint16", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {bitmap16bit => 1}}));
-is("hyper", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {bitmap64bit => 1}}));
-is("uint32", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {}}));
-
-is("enum foo", mapType({TYPE => "ENUM"}, "foo"));
-is("union foo", mapType({TYPE => "UNION"}, "foo"));
-is("struct foo", mapType({TYPE => "STRUCT"}, "foo"));
-is("uint8_t", mapType({TYPE => "BITMAP", PROPERTIES => {bitmap8bit => 1}}, "foo"));
-is("uint8_t", mapType({TYPE => "SCALAR"}, "uint8"));
-is("uint32_t", mapType({TYPE => "TYPEDEF", DATA => {TYPE => "SCALAR"}}, "uint32"));
-
-is("void", mapTypeName(undef));
-is("uint32_t", mapTypeName("uint32"));
-is("int32_t", mapTypeName("int"));
-
-ok(not typeHasBody({TYPE => "TYPEDEF", DATA => { TYPE => "STRUCT" }}));
-ok(typeHasBody({TYPE => "TYPEDEF", DATA => { TYPE => "STRUCT", ELEMENTS => [] }}));
diff --git a/source4/pidl/tests/util.pl b/source4/pidl/tests/util.pl
deleted file mode 100755
index cb77f34c51..0000000000
--- a/source4/pidl/tests/util.pl
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/usr/bin/perl
-# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-use strict;
-use warnings;
-
-use Test::More tests => 72;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util;
-use Parse::Pidl qw(error);
-use Parse::Pidl::Util;
-
-# has_property()
-is(undef, has_property({}, "foo"));
-is(undef, has_property({PROPERTIES => {}}, "foo"));
-is("data", has_property({PROPERTIES => {foo => "data"}}, "foo"));
-is(undef, has_property({PROPERTIES => {foo => undef}}, "foo"));
-
-# is_constant()
-ok(is_constant("2"));
-ok(is_constant("256"));
-ok(is_constant("0x400"));
-ok(is_constant("0x4BC"));
-ok(not is_constant("0x4BGC"));
-ok(not is_constant("str"));
-ok(not is_constant("2 * expr"));
-
-# make_str()
-is("\"bla\"", make_str("bla"));
-is("\"bla\"", make_str("\"bla\""));
-is("\"\"bla\"\"", make_str("\"\"bla\"\""));
-is("\"bla\"\"", make_str("bla\""));
-is("\"foo\"bar\"", make_str("foo\"bar"));
-
-is("bla", unmake_str("\"bla\""));
-is("\"bla\"", unmake_str("\"\"bla\"\""));
-
-# print_uuid()
-is(undef, print_uuid("invalid"));
-is("{0x12345778,0x1234,0xabcd,{0xef,0x00},{0x01,0x23,0x45,0x67,0x89,0xac}}",
- print_uuid("12345778-1234-abcd-ef00-0123456789ac"));
-is("{0x12345778,0x1234,0xabcd,{0xef,0x00},{0x01,0x23,0x45,0x67,0x89,0xac}}",
- print_uuid("\"12345778-1234-abcd-ef00-0123456789ac\""));
-
-# property_matches()
-# missing property
-ok(not property_matches({PROPERTIES => {}}, "x", "data"));
-# data not matching
-ok(not property_matches({PROPERTIES => {x => "bar"}}, "x", "data"));
-# data matching exactly
-ok(property_matches({PROPERTIES => {x => "data"}}, "x", "data"));
-# regex matching
-ok(property_matches({PROPERTIES => {x => "data"}}, "x", "^([dat]+)\$"));
-
-# ParseExpr()
-is(undef, ParseExpr("", {}, undef));
-is("a", ParseExpr("a", {"b" => "2"}, undef));
-is("2", ParseExpr("a", {"a" => "2"}, undef));
-is("2 * 2", ParseExpr("a*a", {"a" => "2"}, undef));
-is("r->length + r->length",
- ParseExpr("length+length", {"length" => "r->length"}, undef));
-is("2 / 2 * (r->length)",
- ParseExpr("constant/constant*(len)", {"constant" => "2",
- "len" => "r->length"}, undef));
-is("2 + 2 - r->length",
- ParseExpr("constant+constant-len", {"constant" => "2",
- "len" => "r->length"}, undef));
-is("*r->length", ParseExpr("*len", { "len" => "r->length"}, undef));
-is("**r->length", ParseExpr("**len", { "len" => "r->length"}, undef));
-is("r->length & 2", ParseExpr("len&2", { "len" => "r->length"}, undef));
-is("&r->length", ParseExpr("&len", { "len" => "r->length"}, undef));
-is("calc()", ParseExpr("calc()", { "foo" => "2"}, undef));
-is("calc(2 * 2)", ParseExpr("calc(foo * 2)", { "foo" => "2"}, undef));
-is("strlen(\"data\")", ParseExpr("strlen(foo)", { "foo" => "\"data\""}, undef));
-is("strlen(\"data\", 4)", ParseExpr("strlen(foo, 4)", { "foo" => "\"data\""}, undef));
-is("foo / bar", ParseExpr("foo / bar", { "bla" => "\"data\""}, undef));
-is("r->length % 2", ParseExpr("len%2", { "len" => "r->length"}, undef));
-is("r->length == 2", ParseExpr("len==2", { "len" => "r->length"}, undef));
-is("r->length != 2", ParseExpr("len!=2", { "len" => "r->length"}, undef));
-is("pr->length", ParseExpr("pr->length", { "p" => "r"}, undef));
-is("r->length", ParseExpr("p->length", { "p" => "r"}, undef));
-is("_foo / bla32", ParseExpr("_foo / bla32", { "bla" => "\"data\""}, undef));
-is("foo.bar.blah", ParseExpr("foo.blah", { "foo" => "foo.bar"}, undef));
-is("\"bla\"", ParseExpr("\"bla\"", {}, undef));
-is("1 << 2", ParseExpr("1 << 2", {}, undef));
-is("1 >> 2", ParseExpr("1 >> 2", {}, undef));
-is("0x200", ParseExpr("0x200", {}, undef));
-is("2?3:0", ParseExpr("2?3:0", {}, undef));
-is("~0", ParseExpr("~0", {}, undef));
-is("b->a->a", ParseExpr("a->a->a", {"a" => "b"}, undef));
-is("b.a.a", ParseExpr("a.a.a", {"a" => "b"}, undef));
-
-test_errors("nofile:0: Parse error in `~' near `~'\n", sub {
- is(undef, ParseExpr("~", {}, {FILE => "nofile", LINE => 0})); });
-
-test_errors("nofile:0: Got pointer, expected integer\n", sub {
- is(undef, ParseExprExt("foo", {}, {FILE => "nofile", LINE => 0},
- undef, sub { my $x = shift;
- error({FILE => "nofile", LINE => 0},
- "Got pointer, expected integer");
- return undef; }))});
-
-is("b.a.a", ParseExpr("b.a.a", {"a" => "b"}, undef));
-is("((rr_type) == NBT_QTYPE_NETBIOS)", ParseExpr("((rr_type)==NBT_QTYPE_NETBIOS)", {}, undef));
-is("talloc_check_name", ParseExpr("talloc_check_name", {}, undef));
-is("talloc_check_name()", ParseExpr("talloc_check_name()", {}, undef));
-is("talloc_check_name(ndr)", ParseExpr("talloc_check_name(ndr)", {}, undef));
-is("talloc_check_name(ndr, 1)", ParseExpr("talloc_check_name(ndr,1)", {}, undef));
-is("talloc_check_name(ndr, \"struct ndr_push\")", ParseExpr("talloc_check_name(ndr,\"struct ndr_push\")", {}, undef));
-is("((rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, \"struct ndr_push\")", ParseExpr("((rr_type)==NBT_QTYPE_NETBIOS)&&talloc_check_name(ndr,\"struct ndr_push\")", {}, undef));
-is("(rdata).data.length", ParseExpr("(rdata).data.length", {}, undef));
-is("((rdata).data.length == 2)", ParseExpr("((rdata).data.length==2)", {}, undef));
-is("((rdata).data.length == 2)?0:rr_type", ParseExpr("((rdata).data.length==2)?0:rr_type", {}, undef));
-is("((((rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, \"struct ndr_push\") && ((rdata).data.length == 2))?0:rr_type)", ParseExpr("((((rr_type)==NBT_QTYPE_NETBIOS)&&talloc_check_name(ndr,\"struct ndr_push\")&&((rdata).data.length==2))?0:rr_type)", {}, undef));
diff --git a/source4/pidl/tests/wireshark-conf.pl b/source4/pidl/tests/wireshark-conf.pl
deleted file mode 100755
index 9da5c7d1ed..0000000000
--- a/source4/pidl/tests/wireshark-conf.pl
+++ /dev/null
@@ -1,205 +0,0 @@
-#!/usr/bin/perl
-# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-# test parsing wireshark conformance files
-use strict;
-use warnings;
-
-use Test::More tests => 49;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util;
-use Parse::Pidl::Util qw(MyDumper);
-use Parse::Pidl::Wireshark::Conformance qw(ReadConformanceFH valid_ft_type valid_base_type);
-
-sub parse_conf($)
-{
- my $str = shift;
- open(TMP, "+>", undef) or die("unable to open temp file");
- print TMP $str;
- seek(TMP, 0, 0);
- my $data = {};
- ReadConformanceFH(*TMP, $data, "nofile") or return undef;
- close(TMP);
- return $data;
-}
-
-ok(parse_conf("\n"), undef);
-ok(parse_conf(" \n"), undef);
-ok(parse_conf("CODE START\nCODE END\n"));
-test_warnings("nofile:1: Expecting CODE END\n", sub { is(parse_conf("CODE START\n"), undef); });
-ok(parse_conf("#foobar\n"), undef);
-test_warnings("nofile:1: Unknown command `foobar'\n",
- sub { ok(parse_conf("foobar\n"), undef); });
-
-test_warnings("nofile:1: incomplete HF_RENAME command\n",
- sub { parse_conf("HF_RENAME\n"); });
-
-is_deeply(parse_conf("HF_RENAME foo bar\n")->{hf_renames}->{foo},
- { OLDNAME => "foo", NEWNAME => "bar", POS => {FILE => "nofile", LINE => 1}, USED => 0});
-
-is_deeply(parse_conf("NOEMIT\n"), { "noemit_dissector" => 1 });
-is_deeply(parse_conf("NOEMIT foo\n"), { "noemit" => { "foo" => 1 } });
-
-test_warnings("nofile:1: incomplete MANUAL command\n",
- sub { parse_conf("MANUAL\n"); } );
-
-is_deeply(parse_conf("MANUAL foo\n"), { manual => {foo => 1}});
-
-test_errors("nofile:1: incomplete INCLUDE command\n",
- sub { parse_conf("INCLUDE\n"); } );
-
-test_warnings("nofile:1: incomplete FIELD_DESCRIPTION command\n",
- sub { parse_conf("FIELD_DESCRIPTION foo\n"); });
-
-is_deeply(parse_conf("FIELD_DESCRIPTION foo \"my description\"\n"),
- { fielddescription => { foo => { DESCRIPTION => "\"my description\"", POS => { FILE => "nofile", LINE => 1}, USED => 0 }}});
-
-is_deeply(parse_conf("FIELD_DESCRIPTION foo my description\n"),
- { fielddescription => { foo => { DESCRIPTION => "my", POS => { FILE => "nofile", LINE => 1}, USED => 0 }}});
-
-is_deeply(parse_conf("CODE START\ndata\nCODE END\n"), { override => "data\n" });
-is_deeply(parse_conf("CODE START\ndata\nmore data\nCODE END\n"), { override => "data\nmore data\n" });
-test_warnings("nofile:1: Unknown command `CODE'\n",
- sub { parse_conf("CODE END\n"); } );
-
-is_deeply(parse_conf("TYPE winreg_String dissect_myminregstring(); FT_STRING BASE_DEC 0 0 2\n"), { types => { winreg_String => {
- NAME => "winreg_String",
- POS => { FILE => "nofile", LINE => 1 },
- USED => 0,
- DISSECTOR_NAME => "dissect_myminregstring();",
- FT_TYPE => "FT_STRING",
- BASE_TYPE => "BASE_DEC",
- MASK => 0,
- VALSSTRING => 0,
- ALIGNMENT => 2}}});
-
-ok(valid_ft_type("FT_UINT32"));
-ok(not valid_ft_type("BLA"));
-ok(not valid_ft_type("ft_uint32"));
-ok(valid_ft_type("FT_BLA"));
-
-ok(valid_base_type("BASE_DEC"));
-ok(valid_base_type("BASE_HEX"));
-ok(not valid_base_type("base_dec"));
-ok(not valid_base_type("BLA"));
-ok(not valid_base_type("BASEDEC"));
-
-test_errors("nofile:1: incomplete TYPE command\n",
- sub { parse_conf("TYPE mytype dissector\n"); });
-
-test_warnings("nofile:1: dissector name does not contain `dissect'\n",
- sub { parse_conf("TYPE winreg_String myminregstring; FT_STRING BASE_DEC 0 0 2\n"); });
-
-test_warnings("nofile:1: invalid FT_TYPE `BLA'\n",
- sub { parse_conf("TYPE winreg_String dissect_myminregstring; BLA BASE_DEC 0 0 2\n"); });
-
-test_warnings("nofile:1: invalid BASE_TYPE `BLOE'\n",
- sub { parse_conf("TYPE winreg_String dissect_myminregstring; FT_UINT32 BLOE 0 0 2\n"); });
-
-is_deeply(parse_conf("TFS hf_bla \"True string\" \"False String\"\n"),
- { tfs => { hf_bla => {
- TRUE_STRING => "\"True string\"",
- FALSE_STRING => "\"False String\"" } } });
-
-test_errors("nofile:1: incomplete TFS command\n",
- sub { parse_conf("TFS hf_bla \"Trues\""); } );
-
-test_errors("nofile:1: incomplete PARAM_VALUE command\n",
- sub { parse_conf("PARAM_VALUE\n"); });
-
-is_deeply(parse_conf("PARAM_VALUE Life 42\n"),
- { dissectorparams => {
- Life => {
- DISSECTOR => "Life",
- POS => { FILE => "nofile", LINE => 1 },
- PARAM => 42,
- USED => 0
- }
- }
- });
-
-is_deeply(parse_conf("STRIP_PREFIX bla_\n"),
- { strip_prefixes => [ "bla_" ] });
-
-is_deeply(parse_conf("STRIP_PREFIX bla_\nSTRIP_PREFIX bloe\n"),
- { strip_prefixes => [ "bla_", "bloe" ] });
-
-is_deeply(parse_conf("PROTOCOL atsvc \"Scheduling jobs on remote machines\" \"at\" \"atsvc\"\n"),
- { protocols => {
- atsvc => {
- LONGNAME => "\"Scheduling jobs on remote machines\"",
- SHORTNAME => "\"at\"",
- FILTERNAME => "\"atsvc\""
- }
- }
- }
-);
-
-is_deeply(parse_conf("IMPORT bla\n"), {
- imports => {
- bla => {
- NAME => "bla",
- DATA => "",
- USED => 0,
- POS => { FILE => "nofile", LINE => 1 }
- }
- }
- }
-);
-
-is_deeply(parse_conf("IMPORT bla fn1 fn2 fn3\n"), {
- imports => {
- bla => {
- NAME => "bla",
- DATA => "fn1 fn2 fn3",
- USED => 0,
- POS => { FILE => "nofile", LINE => 1 }
- }
- }
- }
-);
-
-test_errors("nofile:1: no dissectorname specified\n",
- sub { parse_conf("IMPORT\n"); } );
-
-test_errors("nofile:1: incomplete HF_FIELD command\n",
- sub { parse_conf("HF_FIELD hf_idx\n"); });
-
-test_errors("nofile:1: incomplete ETT_FIELD command\n",
- sub { parse_conf("ETT_FIELD\n"); });
-
-is_deeply(parse_conf("TYPE winreg_String dissect_myminregstring(); FT_STRING BASE_DEC 0 0 0 2\n"), {
- types => {
- winreg_String => {
- NAME => "winreg_String",
- POS => { FILE => "nofile", LINE => 1 },
- USED => 0,
- DISSECTOR_NAME => "dissect_myminregstring();",
- FT_TYPE => "FT_STRING",
- BASE_TYPE => "BASE_DEC",
- MASK => 0,
- VALSSTRING => 0,
- ALIGNMENT => 0
- }
- }
- }
-);
-
-
-is_deeply(parse_conf("TYPE winreg_String \"offset = dissect_myminregstring(\@HF\@);\" FT_STRING BASE_DEC 0 0 0 2\n"), {
- types => {
- winreg_String => {
- NAME => "winreg_String",
- POS => { FILE => "nofile", LINE => 1 },
- USED => 0,
- DISSECTOR_NAME => "offset = dissect_myminregstring(\@HF\@);",
- FT_TYPE => "FT_STRING",
- BASE_TYPE => "BASE_DEC",
- MASK => 0,
- VALSSTRING => 0,
- ALIGNMENT => 0
- }
- }
- }
-);
diff --git a/source4/pidl/tests/wireshark-ndr.pl b/source4/pidl/tests/wireshark-ndr.pl
deleted file mode 100755
index 8c2cd47584..0000000000
--- a/source4/pidl/tests/wireshark-ndr.pl
+++ /dev/null
@@ -1,274 +0,0 @@
-#!/usr/bin/perl
-# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU General Public License
-# test parsing wireshark conformance files
-use strict;
-use warnings;
-
-use Test::More tests => 40;
-use FindBin qw($RealBin);
-use lib "$RealBin";
-use Util;
-use Parse::Pidl::Util qw(MyDumper);
-use strict;
-use Parse::Pidl::Wireshark::NDR qw(field2name %res PrintIdl StripPrefixes RegisterInterfaceHandoff register_hf_field ProcessImport ProcessInclude find_type DumpEttList DumpEttDeclaration DumpHfList DumpHfDeclaration DumpFunctionTable register_type register_ett);
-
-is("Access Mask", field2name("access_mask"));
-is("Accessmask", field2name("AccessMask"));
-
-my $x = new Parse::Pidl::Wireshark::NDR();
-$x->PrintIdl("foo\nbar\n");
-is("/* IDL: foo */
-/* IDL: bar */
-
-", $x->{res}->{code});
-
-is("bla_foo", StripPrefixes("bla_foo", []));
-is("foo", StripPrefixes("bla_foo", ["bla"]));
-is("foo_bla", StripPrefixes("foo_bla", ["bla"]));
-
-$x = new Parse::Pidl::Wireshark::NDR();
-$x->RegisterInterfaceHandoff({});
-is($x->{res}->{code}, "");
-ok(not defined($x->{hf_used}->{hf_bla_opnum}));
-
-$x = new Parse::Pidl::Wireshark::NDR();
-$x->{res}->{code} = "";
-$x->RegisterInterfaceHandoff({UUID => "uuid", NAME => "bla"});
-is($x->{res}->{code}, 'void proto_reg_handoff_dcerpc_bla(void)
-{
- dcerpc_init_uuid(proto_dcerpc_bla, ett_dcerpc_bla,
- &uuid_dcerpc_bla, ver_dcerpc_bla,
- bla_dissectors, hf_bla_opnum);
-}
-');
-is($x->{hf_used}->{hf_bla_opnum}, 1);
-
-$x->{conformance} = {};
-is("hf_bla_idx",
- $x->register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, undef));
-is_deeply($x->{conformance}, {
- header_fields => {
- "hf_bla_idx" => {
- INDEX => "hf_bla_idx",
- NAME => "bla",
- FILTER => "my.filter",
- BASE_TYPE => "BASE_HEX",
- FT_TYPE => "FT_UINT32",
- VALSSTRING => "NULL",
- BLURB => undef,
- MASK => 0xF
- }
- },
- hf_renames => {},
- fielddescription => {}
-});
-
-$x->{conformance} = { fielddescription => { hf_bla_idx => { DESCRIPTION => "Some Description" }}};
-is("hf_bla_idx",
- $x->register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, undef));
-is_deeply($x->{conformance}, {
- fielddescription => {
- hf_bla_idx => {
- DESCRIPTION => "Some Description",
- USED => 1
- }
- },
- header_fields => {
- "hf_bla_idx" => {
- INDEX => "hf_bla_idx",
- NAME => "bla",
- FILTER => "my.filter",
- BASE_TYPE => "BASE_HEX",
- FT_TYPE => "FT_UINT32",
- VALSSTRING => "NULL",
- BLURB => "Some Description",
- MASK => 0xF
- }
- },
- hf_renames => {},
-});
-
-$x->{conformance} = { fielddescription => { hf_bla_idx => { DESCRIPTION => "Some Description" }}};
-is("hf_bla_idx",
- $x->register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF,
- "Actual Description"));
-is_deeply($x->{conformance}, {
- fielddescription => {
- hf_bla_idx => { DESCRIPTION => "Some Description" }
- },
- header_fields => {
- "hf_bla_idx" => {
- INDEX => "hf_bla_idx",
- NAME => "bla",
- FILTER => "my.filter",
- BASE_TYPE => "BASE_HEX",
- FT_TYPE => "FT_UINT32",
- VALSSTRING => "NULL",
- BLURB => "Actual Description",
- MASK => 0xF
- }
- },
- hf_renames => {},
-});
-
-
-
-$x->{conformance} = { hf_renames => { "hf_bla_idx" => { NEWNAME => "hf_bloe_idx" } } };
-$x->register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, undef);
-is_deeply($x->{conformance}, {
- hf_renames => { hf_bla_idx => { USED => 1, NEWNAME => "hf_bloe_idx" } } });
-
-$x->{hf_used} = { hf_bla => 1 };
-test_warnings("", sub {
- $x->CheckUsed({ header_fields => { foo => { INDEX => "hf_bla" }}})});
-
-$x->{hf_used} = { };
-test_warnings("hf field `hf_bla' not used\n", sub {
- $x->CheckUsed({ header_fields => { foo => { INDEX => "hf_bla" }}})});
-
-test_warnings("hf field `hf_id' not used\n",
- sub { $x->CheckUsed({
- hf_renames => {
- hf_id => {
- OLDNAME => "hf_id",
- NEWNAME => "hf_newid",
- USED => 0
- }
- }
-}); } );
-
-test_warnings("dissector param never used\n",
- sub { $x->CheckUsed({
- dissectorparams => {
- dissect_foo => {
- PARAM => 42,
- USED => 0
- }
- }
-}); } );
-
-test_warnings("description never used\n",
- sub { $x->CheckUsed({
- fielddescription => {
- hf_bla => {
- USED => 0
- }
- }
-}); } );
-
-test_warnings("import never used\n",
- sub { $x->CheckUsed({
- imports => {
- bla => {
- USED => 0
- }
- }
-}); } );
-
-test_warnings("nofile:1: type never used\n",
- sub { $x->CheckUsed({
- types => {
- bla => {
- USED => 0,
- POS => { FILE => "nofile", LINE => 1 }
- }
- }
-}); } );
-
-test_warnings("True/False description never used\n",
- sub { $x->CheckUsed({
- tfs => {
- hf_bloe => {
- USED => 0
- }
- }
-}); } );
-
-$x = new Parse::Pidl::Wireshark::NDR();
-$x->ProcessImport("security", "bla");
-is($x->{res}->{hdr}, "#include \"packet-dcerpc-bla.h\"\n\n");
-
-$x = new Parse::Pidl::Wireshark::NDR();
-$x->ProcessImport("\"bla.idl\"", "\"foo.idl\"");
-is($x->{res}->{hdr}, "#include \"packet-dcerpc-bla.h\"\n" .
- "#include \"packet-dcerpc-foo.h\"\n\n");
-
-$x = new Parse::Pidl::Wireshark::NDR();
-$x->ProcessInclude("foo.h", "bla.h", "bar.h");
-is($x->{res}->{hdr}, "#include \"foo.h\"\n" .
- "#include \"bla.h\"\n" .
- "#include \"bar.h\"\n\n");
-
-$x->{conformance} = {types => { bla => "brainslug" } };
-is("brainslug", $x->find_type("bla"));
-
-is(DumpEttList(["ett_t1", "ett_bla"]),
- "\tstatic gint *ett[] = {\n" .
- "\t\t&ett_t1,\n" .
- "\t\t&ett_bla,\n" .
- "\t};\n");
-
-is(DumpEttList(), "\tstatic gint *ett[] = {\n\t};\n");
-is(DumpEttList(["bla"]), "\tstatic gint *ett[] = {\n\t\t&bla,\n\t};\n");
-
-is(DumpEttDeclaration(["void", "zoid"]),
- "\n/* Ett declarations */\n" .
- "static gint void = -1;\n" .
- "static gint zoid = -1;\n" .
- "\n");
-
-is(DumpEttDeclaration(), "\n/* Ett declarations */\n\n");
-
-$x->{conformance} = {
- header_fields => {
- hf_bla => { INDEX => "hf_bla", NAME => "Bla", FILTER => "bla.field", FT_TYPE => "FT_UINT32", BASE_TYPE => "BASE_DEC", VALSSTRING => "NULL", MASK => 0xFF, BLURB => "NULL" }
- }
-};
-
-is($x->DumpHfList(), "\tstatic hf_register_info hf[] = {
- { &hf_bla,
- { \"Bla\", \"bla.field\", FT_UINT32, BASE_DEC, NULL, 255, \"NULL\", HFILL }},
- };
-");
-
-is($x->DumpHfDeclaration(), "
-/* Header field declarations */
-static gint hf_bla = -1;
-
-");
-
-is(DumpFunctionTable({
- NAME => "someif",
- FUNCTIONS => [ { NAME => "fn1", OPNUM => 3 }, { NAME => "someif_fn2", OPNUM => 2 } ] }),
-'static dcerpc_sub_dissector someif_dissectors[] = {
- { 3, "fn1",
- someif_dissect_fn1_request, someif_dissect_fn1_response},
- { 2, "fn2",
- someif_dissect_fn2_request, someif_dissect_fn2_response},
- { 0, NULL, NULL, NULL }
-};
-');
-
-$x->{conformance} = {};
-$x->register_type("bla_type", "dissect_bla", "FT_UINT32", "BASE_HEX", 0xFF, "NULL", 4);
-is_deeply($x->{conformance}, {
- types => {
- bla_type => {
- NAME => "bla_type",
- DISSECTOR_NAME => "dissect_bla",
- FT_TYPE => "FT_UINT32",
- BASE_TYPE => "BASE_HEX",
- MASK => 255,
- VALSSTRING => "NULL",
- ALIGNMENT => 4
- }
- }
- }
-);
-
-$x->{ett} = [];
-$x->register_ett("name");
-is_deeply($x->{ett}, ["name"]);
-$x->register_ett("leela");
-is_deeply($x->{ett}, ["name", "leela"]);
diff --git a/source4/samba4-knownfail b/source4/samba4-knownfail
index ded7922ec9..f99db4fb1b 100644
--- a/source4/samba4-knownfail
+++ b/source4/samba4-knownfail
@@ -44,3 +44,9 @@ samba4.winbind.struct.*.SHOW_SEQUENCE # Not yet working in winbind
samba4.winbind.struct.*.GETPWENT # Not yet working in winbind
samba4.winbind.struct.*.SETPWENT # Not yet working in winbind
samba4.winbind.struct.*.LOOKUP_NAME_SID # Not yet working in winbind
+^samba4.*base.delaywrite.*update of write time and SMBwrite truncate$
+^samba4.*base.delaywrite.*update of write time and SMBwrite truncate expand$
+^samba4.*base.delaywrite.*delayed update of write time 3a$
+^samba4.*base.delaywrite.*delayed update of write time 3c$
+^samba4.*base.delaywrite.*update of write time using SET_END_OF_FILE$
+^samba4.*base.delaywrite.*update of write time using SET_ALLOCATION_SIZE$
diff --git a/source4/script/build_smb_interfaces.pl b/source4/script/build_smb_interfaces.pl
deleted file mode 100755
index 5fac94ca6e..0000000000
--- a/source4/script/build_smb_interfaces.pl
+++ /dev/null
@@ -1,161 +0,0 @@
-#!/usr/bin/perl
-#
-# Create ejs interfaces for structures in a C header file
-#
-
-use File::Basename;
-use Data::Dumper;
-
-#
-# Generate parse tree for header file
-#
-
-my $file = shift;
-require smb_interfaces;
-my $parser = new smb_interfaces;
-$header = $parser->parse($file);
-
-#
-# Make second pass over tree to make it easier to process.
-#
-
-sub flatten_structs($) {
- my $obj = shift;
- my $s = { %$obj };
-
- # Map NAME, STRUCT_NAME and UNION_NAME elements into a more likeable
- # property.
-
- if (defined($obj->{STRUCT_NAME}) or defined($obj->{UNION_NAME})) {
-
- $s->{TYPE_DEFINED} = defined($obj->{STRUCT_NAME}) ? $obj->{STRUCT_NAME}
- : $obj->{UNION_NAME};
-
- delete $s->{STRUCT_NAME};
- delete $s->{UNION_NAME};
- }
-
- # Create a new list of structure fields with flattened names
-
- foreach my $elt (@{$obj->{DATA}}) {
- foreach my $name (@{$elt->{NAME}}) {
- my $new_elt = { %$elt };
- $new_elt->{NAME} = $name;
-# $new_elt->{PARENT} = $s;
- push(@{$s->{FIELDS}}, flatten_structs($new_elt));
- }
- }
-
- delete $s->{DATA};
-
- return $s;
-}
-
-@newheader = map { flatten_structs($_) } @{$header};
-
-#
-# Generate implementation
-#
-
-my $basename = basename($file, ".h");
-stat "libcli/gen_raw" || mkdir("libcli/gen_raw") || die("mkdir");
-
-open(FILE, ">libcli/gen_raw/ejs_${basename}.c");
-
-print FILE "/* EJS wrapper functions auto-generated by build_smb_interfaces.pl */\n\n";
-
-print FILE "#include \"includes.h\"\n";
-print FILE "#include \"scripting/ejs/smbcalls.h\"\n";
-print FILE "#include \"lib/appweb/ejs/ejs.h\"\n";
-print FILE "#include \"scripting/ejs/ejsrpc.h\"\n"; # TODO: remove this
-print FILE "\n";
-
-sub transfer_element($$$) {
- my $dir = shift;
- my $prefix = shift;
- my $elt = shift;
-
- $type = $elt->{TYPE};
- $type =~ s/_t$//;
-
- print FILE "\tNDR_CHECK(ejs_${dir}_$type(ejs, v, \"$prefix.$elt->{NAME}\"));\n";
-}
-
-sub transfer_struct($$) {
- my $dir = shift;
- my $struct = shift;
-
- foreach my $field (@{$struct->{FIELDS}}) {
- next if $dir eq "pull" and $field->{NAME} eq "out";
- next if $dir eq "push" and $field->{NAME} eq "in";
-
- if ($field->{TYPE} eq "struct") {
- foreach $subfield (@{$field->{FIELDS}}) {
- transfer_element($dir, $field->{NAME}, $subfield);
- }
- } else {
- transfer_element($dir, $struct->{NAME}, $field);
- }
- }
-}
-
-# Top level call functions
-
-foreach my $s (@newheader) {
-
- if ($s->{TYPE} eq "struct") {
-
- # Push/pull top level struct
-
- print FILE "NTSTATUS ejs_pull_$s->{TYPE_DEFINED}(struct ejs_rpc *ejs, struct MprVar *v, struct $s->{TYPE_DEFINED} *r)\n";
- print FILE "{\n";
-
- transfer_struct("pull", $s);
-
- print FILE "\n\treturn NT_STATUS_OK;\n";
- print FILE "}\n\n";
-
- print FILE "NTSTATUS ejs_push_$s->{TYPE_DEFINED}(struct ejs_rpc *ejs, struct MprVar *v, const struct $s->{TYPE_DEFINED} *r)\n";
- print FILE "{\n";
-
- transfer_struct("push", $s);
-
- print FILE "\n\treturn NT_STATUS_OK;\n";
- print FILE "}\n\n";
-
- # Function call
-
- print FILE "static int ejs_$s->{TYPE_DEFINED}(int eid, int argc, struct MprVar **argv)\n";
- print FILE "{\n";
- print FILE "\treturn ejs_raw_call(eid, argc, argv, (ejs_pull_function_t)ejs_pull_$s->{TYPE_DEFINED}, (ejs_push_function_t)ejs_push_$s->{TYPE_DEFINED});\n";
- print FILE "}\n\n";
-
- } else {
-
- # Top level union
-
- foreach my $arm (@{$s->{FIELDS}}) {
-
- # Push/pull union arm
-
- print FILE "NTSTATUS ejs_pull_$s->{TYPE_DEFINED}_$arm->{NAME}(struct ejs_rpc *ejs, struct MprVar *v, union $s->{TYPE_DEFINED} *r)\n";
- print FILE "{\n";
-
- transfer_struct("pull", $arm);
-
- print FILE "\n\treturn NT_STATUS_OK;\n";
- print FILE "}\n\n";
-
- print FILE "NTSTATUS ejs_push_$s->{TYPE_DEFINED}_$arm->{NAME}(struct ejs_rpc *ejs, struct MprVar *v, const union $s->{TYPE_DEFINED} *r)\n";
- print FILE "{\n";
-
- transfer_struct("push", $arm);
-
- print FILE "\n\treturn NT_STATUS_OK;\n";
- print FILE "}\n\n";
-
- }
- }
-}
-
-close(FILE);
diff --git a/source4/script/harness2subunit.pl b/source4/script/harness2subunit.pl
index 9f2391ad6c..45f515540b 100755
--- a/source4/script/harness2subunit.pl
+++ b/source4/script/harness2subunit.pl
@@ -1,4 +1,8 @@
#!/usr/bin/perl
+# Simple script that converts Perl test harness output to
+# Subunit
+# Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org>
+# Published under the GNU GPL, v3 or later
my $firstline = 1;
my $error = 0;
diff --git a/source4/scripting/python/config.m4 b/source4/scripting/python/config.m4
index af13b6ae69..aaf32c5e4e 100644
--- a/source4/scripting/python/config.m4
+++ b/source4/scripting/python/config.m4
@@ -50,7 +50,7 @@ if test -z "$PYTHON_CONFIG"; then
else
TRY_LINK_PYTHON([`$PYTHON_CONFIG --ldflags`], [`$PYTHON_CONFIG --includes`])
TRY_LINK_PYTHON([`$PYTHON_CONFIG --ldflags`], [`$PYTHON_CONFIG --cflags`])
- if x$working_python = xno; then
+ if test x$working_python = xno; then
# It seems the library path isn't included on some systems
base=`$PYTHON_CONFIG --prefix`
TRY_LINK_PYTHON([`echo -n -L${base}/lib " "; $PYTHON_CONFIG --ldflags`], [`$PYTHON_CONFIG --includes`])
diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh
index a13c596f6d..192f5698e4 100755
--- a/source4/selftest/samba4_tests.sh
+++ b/source4/selftest/samba4_tests.sh
@@ -151,6 +151,7 @@ for t in $net; do
done
# Tests for session keys
+# FIXME: Integrate these into a single smbtorture test
bindoptions=""
transport="ncacn_np"
@@ -250,7 +251,7 @@ fi
if test x"${PIDL_TESTS_SKIP}" = x"yes"; then
echo "Skipping pidl tests - PIDL_TESTS_SKIP=yes"
elif $PERL -e 'eval require Test::More;' > /dev/null 2>&1; then
- for f in $samba4srcdir/pidl/tests/*.pl; do
+ for f in $samba4srcdir/../pidl/tests/*.pl; do
plantest "pidl.`basename $f .pl`" none $PERL $f "|" $samba4srcdir/script/harness2subunit.pl
done
else
@@ -259,22 +260,22 @@ fi
# Blackbox Tests:
# tests that interact directly with the command-line tools rather than using
-# the API
+# the API. These mainly test that the various command-line options of commands
+# work correctly.
bbdir=$incdir/../../testprogs/blackbox
-plantest "blackbox.ndrdump" dc $bbdir/test_ndrdump.sh
+plantest "blackbox.ndrdump" dc $samba4srcdir/librpc/tests/test_ndrdump.sh
plantest "blackbox.net" dc $samba4srcdir/utils/tests/test_net.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN"
plantest "blackbox.kinit" dc $bbdir/test_kinit.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$REALM" "\$DOMAIN" "$PREFIX" $CONFIGURATION
plantest "blackbox.cifsdd" dc $samba4srcdir/client/tests/test_cifsdd.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN"
plantest "blackbox.nmblookup" dc $samba4srcdir/utils/tests/test_nmblookup.sh "\$NETBIOSNAME" "\$NETBIOSALIAS" "\$SERVER" "\$SERVER_IP"
plantest "blackbox.nmblookup" member $samba4srcdir/utils/tests/test_nmblookup.sh "\$NETBIOSNAME" "\$NETBIOSALIAS" "\$SERVER" "\$SERVER_IP"
-plantest "blackbox.locktest" dc $bbdir/test_locktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
-plantest "blackbox.masktest" dc $bbdir/test_masktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
-plantest "blackbox.gentest" dc $bbdir/test_gentest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
+plantest "blackbox.locktest" dc $samba4srcdir/torture/tests/test_locktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
+plantest "blackbox.masktest" dc $samba4srcdir/torture/tests/test_masktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
+plantest "blackbox.gentest" dc $samba4srcdir/torture/tests/test_gentest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
plantest "blackbox.wbinfo" dc $samba4srcdir/nsswitch/tests/test_wbinfo.sh "\$DOMAIN" "\$USERNAME" "\$PASSWORD" "dc"
plantest "blackbox.wbinfo" member $samba4srcdir/nsswitch/tests/test_wbinfo.sh "\$DOMAIN" "\$DC_USERNAME" "\$DC_PASSWORD" "member"
-plantest "blackbox.wintest" none $bbdir/test_wintest.sh "$TORTURE_OPTIONS"
# Tests using the "Simple" NTVFS backend
@@ -325,7 +326,7 @@ SUBUNITRUN="$PYTHON ./scripting/bin/subunitrun"
plantest "ldb.python" none PYTHONPATH="$PYTHONPATH:lib/ldb/tests/python/" $SUBUNITRUN api
plantest "credentials.python" none PYTHONPATH="$PYTHONPATH:auth/credentials/tests" $SUBUNITRUN bindings
plantest "registry.python" none PYTHONPATH="$PYTHONPATH:lib/registry/tests/" $SUBUNITRUN bindings
-plantest "tdb.python" none PYTHONPATH="$PYTHONPATH:lib/tdb/python/tests" $SUBUNITRUN simple
+plantest "tdb.python" none PYTHONPATH="$PYTHONPATH:../lib/tdb/python/tests" $SUBUNITRUN simple
plantest "auth.python" none PYTHONPATH="$PYTHONPATH:auth/tests/" $SUBUNITRUN bindings
plantest "security.python" none PYTHONPATH="$PYTHONPATH:libcli/security/tests" $SUBUNITRUN bindings
plantest "param.python" none PYTHONPATH="$PYTHONPATH:param/tests" $SUBUNITRUN bindings
diff --git a/source4/smbd/process_prefork.c b/source4/smbd/process_prefork.c
index 2ffb724a6c..0d17e5301d 100644
--- a/source4/smbd/process_prefork.c
+++ b/source4/smbd/process_prefork.c
@@ -25,7 +25,7 @@
#include "includes.h"
#include "lib/events/events.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/socket/socket.h"
#include "smbd/process_model.h"
#include "param/secrets.h"
diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c
index 3f2936bb26..c8f90209b6 100644
--- a/source4/smbd/process_standard.c
+++ b/source4/smbd/process_standard.c
@@ -23,7 +23,7 @@
#include "includes.h"
#include "lib/events/events.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/socket/socket.h"
#include "smbd/process_model.h"
#include "param/secrets.h"
diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c
index af42beb535..61678f4e52 100644
--- a/source4/torture/basic/delaywrite.c
+++ b/source4/torture/basic/delaywrite.c
@@ -55,7 +55,7 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum1 == -1) {
- torture_comment(tctx, "Failed to open %s\n", fname);
+ torture_result(tctx, TORTURE_FAIL, "Failed to open %s", fname);
return false;
}
@@ -65,10 +65,7 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
status = smb_raw_fileinfo(cli->tree, tctx, &finfo1);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
torture_comment(tctx, "Initial write time %s\n",
nt_time_string(tctx, finfo1.basic_info.out.write_time));
@@ -80,8 +77,9 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
if (written != 1) {
- torture_comment(tctx, "write failed - wrote %d bytes (%s)\n",
- (int)written, __location__);
+ torture_result(tctx, TORTURE_FAIL,
+ "write failed - wrote %d bytes (%s)\n",
+ (int)written, __location__);
return false;
}
@@ -117,7 +115,8 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
}
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
- torture_comment(tctx, "Server did not update write time (wrong!)\n");
+ torture_result(tctx, TORTURE_FAIL,
+ "Server did not update write time (wrong!)");
ret = false;
}
@@ -154,7 +153,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum1 == -1) {
- torture_comment(tctx, "Failed to open %s\n", fname);
+ torture_result(tctx, TORTURE_FAIL, "Failed to open %s", fname);
return false;
}
@@ -174,10 +173,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
status = smb_raw_fileinfo(cli->tree, tctx, &finfo1);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
torture_comment(tctx, "Initial write time %s\n",
nt_time_string(tctx, finfo1.all_info.out.write_time));
@@ -186,8 +182,9 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
written = smbcli_smbwrite(cli->tree, fnum1, "x", 1024, 0);
if (written != 0) {
- torture_comment(tctx, "write failed - wrote %d bytes (%s)\n",
- (int)written, __location__);
+ torture_result(tctx, TORTURE_FAIL,
+ "write failed - wrote %d bytes (%s)\n",
+ (int)written, __location__);
return false;
}
@@ -203,8 +200,9 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
}
if (finfo2.all_info.out.size != 1024) {
- DEBUG(0, ("file not truncated, size = %u (should be 1024)\n",
- (unsigned int)finfo2.all_info.out.size));
+ torture_result(tctx, TORTURE_FAIL,
+ "file not truncated, size = %u (should be 1024)",
+ (unsigned int)finfo2.all_info.out.size);
ret = false;
break;
}
@@ -233,7 +231,8 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
}
if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) {
- torture_comment(tctx, "Server did not update write time (wrong!)\n");
+ torture_result(tctx, TORTURE_FAIL,
+ "Server did not update write time (wrong!)");
ret = false;
}
@@ -241,8 +240,9 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1);
if (written != 1) {
- torture_comment(tctx, "write failed - wrote %d bytes (%s)\n",
- (int)written, __location__);
+ torture_result(tctx, TORTURE_FAIL,
+ "write failed - wrote %d bytes (%s)",
+ (int)written, __location__);
return false;
}
@@ -279,7 +279,8 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
}
if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
- torture_comment(tctx, "Server updated write time (wrong!)\n");
+ torture_result(tctx, TORTURE_FAIL,
+ "Server updated write time (wrong!)");
ret = false;
}
@@ -288,13 +289,11 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
fnum1 = -1;
status = smb_raw_pathinfo(cli->tree, tctx, &pinfo4);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("pathinfo failed: %s\n", nt_errstr(status)));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "pathinfo failed");
if (finfo3.all_info.out.write_time == pinfo4.all_info.out.write_time) {
- torture_comment(tctx, "Server did not update write time on close (wrong!)\n");
+ torture_result(tctx, TORTURE_FAIL,
+ "Server did not update write time on close (wrong!)");
ret = false;
} else if (finfo3.all_info.out.write_time < pinfo4.all_info.out.write_time) {
torture_comment(tctx, "Server updated write time on close (correct)\n");
@@ -335,7 +334,7 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum1 == -1) {
- torture_comment(tctx, "Failed to open %s\n", fname);
+ torture_result(tctx, TORTURE_FAIL, "Failed to open %s", fname);
return false;
}
@@ -355,10 +354,7 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
status = smb_raw_fileinfo(cli->tree, tctx, &finfo1);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
torture_comment(tctx, "Initial write time %s\n",
nt_time_string(tctx, finfo1.all_info.out.write_time));
@@ -367,7 +363,7 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
written = smbcli_smbwrite(cli->tree, fnum1, "x", 10240, 0);
if (written != 0) {
- torture_comment(tctx, "write failed - wrote %d bytes (%s)\n",
+ torture_result(tctx, TORTURE_FAIL, "write failed - wrote %d bytes (%s)",
(int)written, __location__);
return false;
}
@@ -378,14 +374,16 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
+ torture_result(tctx, TORTURE_FAIL, "fileinfo failed: %s",
+ nt_errstr(status));
ret = false;
break;
}
if (finfo2.all_info.out.size != 10240) {
- DEBUG(0, ("file not truncated, size = %u (should be 10240)\n",
- (unsigned int)finfo2.all_info.out.size));
+ torture_result(tctx, TORTURE_FAIL,
+ "file not truncated, size = %u (should be 10240)",
+ (unsigned int)finfo2.all_info.out.size);
ret = false;
break;
}
@@ -414,18 +412,16 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
}
if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) {
- torture_comment(tctx, "Server did not update write time (wrong!)\n");
+ torture_result(tctx, TORTURE_FAIL,
+ "Server did not update write time (wrong!)");
ret = false;
}
/* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */
written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1);
- if (written != 1) {
- torture_comment(tctx, "write failed - wrote %d bytes (%s)\n",
- (int)written, __location__);
- return false;
- }
+ torture_assert_int_equal(tctx, written, 1,
+ "unexpected number of bytes written");
start = timeval_current();
end = timeval_add(&start, (10*sec), 0);
@@ -433,14 +429,16 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
status = smb_raw_fileinfo(cli->tree, tctx, &finfo3);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
+ torture_result(tctx, TORTURE_FAIL, "fileinfo failed: %s\n",
+ nt_errstr(status));
ret = false;
break;
}
if (finfo3.all_info.out.size != 10240) {
- DEBUG(0, ("file not truncated, size = %u (should be 10240)\n",
- (unsigned int)finfo3.all_info.out.size));
+ torture_result(tctx, TORTURE_FAIL,
+ "file not truncated, size = %u (should be 10240)",
+ (unsigned int)finfo3.all_info.out.size);
ret = false;
break;
}
@@ -460,7 +458,8 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
}
if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
- torture_comment(tctx, "Server updated write time (wrong!)\n");
+ torture_result(tctx, TORTURE_FAIL,
+ "Server updated write time (wrong!)");
ret = false;
}
@@ -469,13 +468,11 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
fnum1 = -1;
status = smb_raw_pathinfo(cli->tree, tctx, &pinfo4);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("pathinfo failed: %s\n", nt_errstr(status)));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "pathinfo failed");
if (finfo3.all_info.out.write_time == pinfo4.all_info.out.write_time) {
- torture_comment(tctx, "Server did not update write time on close (wrong!)\n");
+ torture_result(tctx, TORTURE_FAIL,
+ "Server did not update write time on close (wrong!)");
ret = false;
} else if (finfo3.all_info.out.write_time < pinfo4.all_info.out.write_time) {
torture_comment(tctx, "Server updated write time on close (correct)\n");
@@ -516,7 +513,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum1 == -1) {
- torture_comment(tctx, "Failed to open %s\n", fname);
+ torture_result(tctx, TORTURE_FAIL, "Failed to open %s", fname);
return false;
}
@@ -536,10 +533,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
status = smb_raw_fileinfo(cli->tree, tctx, &finfo1);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
torture_comment(tctx, "Initial write time %s\n",
nt_time_string(tctx, finfo1.all_info.out.write_time));
@@ -547,11 +541,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
/* Do a SET_END_OF_FILE_INFO call to truncate. */
status = smbcli_ftruncate(cli->tree, fnum1, (uint64_t)10240);
- if (!NT_STATUS_IS_OK(status)) {
- torture_comment(tctx, "SET_END_OF_FILE failed (%s)\n",
- nt_errstr(status));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "SET_END_OF_FILE failed");
start = timeval_current();
end = timeval_add(&start, (120*sec), 0);
@@ -565,8 +555,9 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
}
if (finfo2.all_info.out.size != 10240) {
- DEBUG(0, ("file not truncated (size = %u, should be 10240)\n",
- (unsigned int)finfo2.all_info.out.size ));
+ torture_result(tctx, TORTURE_FAIL,
+ "file not truncated (size = %u, should be 10240)",
+ (unsigned int)finfo2.all_info.out.size );
ret = false;
break;
}
@@ -576,9 +567,10 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
if (finfo1.all_info.out.write_time != finfo2.all_info.out.write_time) {
double diff = timeval_elapsed(&start);
if (diff > (0.25 * sec * 0.75)) { /* 0.75 to cope with vmware timing */
- torture_comment(tctx, "After SET_END_OF_FILE truncate "
+ torture_result(tctx, TORTURE_FAIL,
+ "After SET_END_OF_FILE truncate "
"server updated write_time after %.2f seconds"
- "(1 sec == %.2f)(wrong!)\n",
+ "(1 sec == %.2f)(wrong!)",
diff, sec);
ret = false;
break;
@@ -595,18 +587,16 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
}
if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) {
- torture_comment(tctx, "Server did not update write time (wrong!)\n");
+ torture_result(tctx, TORTURE_FAIL,
+ "Server did not update write time (wrong!)");
ret = false;
}
/* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */
written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1);
- if (written != 1) {
- torture_comment(tctx, "write failed - wrote %d bytes (%s)\n",
- (int)written, __location__);
- return false;
- }
+ torture_assert_int_equal(tctx, written, 1,
+ "unexpected number of bytes written");
start = timeval_current();
end = timeval_add(&start, (10*sec), 0);
@@ -614,7 +604,8 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
status = smb_raw_fileinfo(cli->tree, tctx, &finfo3);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
+ torture_result(tctx, TORTURE_FAIL,
+ "fileinfo failed: %s", nt_errstr(status));
ret = false;
break;
}
@@ -641,7 +632,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
}
if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
- torture_comment(tctx, "Server updated write time (wrong!)\n");
+ torture_result(tctx, TORTURE_FAIL, "Server updated write time (wrong!)\n");
ret = false;
}
@@ -650,13 +641,10 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
fnum1 = -1;
status = smb_raw_pathinfo(cli->tree, tctx, &pinfo4);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("pathinfo failed: %s\n", nt_errstr(status)));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "pathinfo failed");
if (finfo3.all_info.out.write_time == pinfo4.all_info.out.write_time) {
- torture_comment(tctx, "Server did not update write time on close (wrong!)\n");
+ torture_result(tctx, TORTURE_FAIL, "Server did not update write time on close (wrong!)\n");
ret = false;
} else if (finfo3.all_info.out.write_time < pinfo4.all_info.out.write_time) {
torture_comment(tctx, "Server updated write time on close (correct)\n");
@@ -697,7 +685,7 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum1 == -1) {
- torture_comment(tctx, "Failed to open %s\n", fname);
+ torture_result(tctx, TORTURE_FAIL, "Failed to open %s", fname);
return false;
}
@@ -717,10 +705,7 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
status = smb_raw_fileinfo(cli->tree, tctx, &finfo1);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
torture_comment(tctx, "Initial write time %s\n",
nt_time_string(tctx, finfo1.all_info.out.write_time));
@@ -730,13 +715,10 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
parms.allocation_info.in.file.fnum = fnum1;
parms.allocation_info.in.alloc_size = 0;
- status = smb_raw_setfileinfo(cli->tree, &parms);
+ status = smb_raw_setfileinfo(cli->tree, &parms);
- if (!NT_STATUS_IS_OK(status)) {
- torture_comment(tctx, "RAW_SFILEINFO_ALLOCATION_INFO failed (%s)\n",
- nt_errstr(status));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status,
+ "RAW_SFILEINFO_ALLOCATION_INFO failed");
start = timeval_current();
end = timeval_add(&start, (120*sec), 0);
@@ -744,14 +726,16 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
+ torture_result(tctx, TORTURE_FAIL, "fileinfo failed: %s",
+ nt_errstr(status));
ret = false;
break;
}
if (finfo2.all_info.out.size != 0) {
- DEBUG(0, ("file not truncated (size = %u, should be 10240)\n",
- (unsigned int)finfo2.all_info.out.size ));
+ torture_result(tctx, TORTURE_FAIL,
+ "file not truncated (size = %u, should be 10240)",
+ (unsigned int)finfo2.all_info.out.size);
ret = false;
break;
}
@@ -780,18 +764,15 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
}
if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) {
- torture_comment(tctx, "Server did not update write time (wrong!)\n");
+ torture_result(tctx, TORTURE_FAIL,
+ "Server did not update write time (wrong!)");
ret = false;
}
/* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */
written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1);
-
- if (written != 1) {
- torture_comment(tctx, "write failed - wrote %d bytes (%s)\n",
- (int)written, __location__);
- return false;
- }
+ torture_assert_int_equal(tctx, written, 1,
+ "Unexpected number of bytes written");
start = timeval_current();
end = timeval_add(&start, (10*sec), 0);
@@ -799,13 +780,14 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
status = smb_raw_fileinfo(cli->tree, tctx, &finfo3);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
+ torture_result(tctx, TORTURE_FAIL, "fileinfo failed: %s",
+ nt_errstr(status));
ret = false;
break;
}
if (finfo3.all_info.out.size != 1) {
- DEBUG(0, ("file not expanded\n"));
+ torture_result(tctx, TORTURE_FAIL, "file not expanded");
ret = false;
break;
}
@@ -825,7 +807,8 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
}
if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
- torture_comment(tctx, "Server updated write time (wrong!)\n");
+ torture_result(tctx, TORTURE_FAIL,
+ "Server updated write time (wrong!)");
ret = false;
}
@@ -834,13 +817,10 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
fnum1 = -1;
status = smb_raw_pathinfo(cli->tree, tctx, &pinfo4);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("pathinfo failed: %s\n", nt_errstr(status)));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "pathinfo failed");
if (finfo3.all_info.out.write_time == pinfo4.all_info.out.write_time) {
- torture_comment(tctx, "Server did not update write time on close (wrong!)\n");
+ torture_result(tctx, TORTURE_FAIL, "Server did not update write time on close (wrong!)\n");
ret = false;
} else if (finfo3.all_info.out.write_time < pinfo4.all_info.out.write_time) {
torture_comment(tctx, "Server updated write time on close (correct)\n");
@@ -894,10 +874,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
status = smb_raw_fileinfo(cli->tree, tctx, &finfo1);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
torture_comment(tctx, "Initial write time %s\n",
nt_time_string(tctx, finfo1.basic_info.out.write_time));
@@ -927,10 +904,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
status = smb_raw_setfileinfo(cli->tree, &sfinfo);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("sfileinfo failed: %s\n", nt_errstr(status)));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "sfileinfo failed");
}
finfo2.basic_info.in.file.path = fname;
@@ -947,7 +921,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
torture_comment(tctx, "Server updated write_time (correct)\n");
} else {
- torture_comment(tctx, "Server did not update write time (wrong!)\n");
+ torture_result(tctx, TORTURE_FAIL, "Server did not update write time (wrong!)\n");
ret = false;
}
@@ -1195,7 +1169,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
}
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
- torture_comment(tctx, "Server did not update write time (wrong!)\n");
+ torture_result(tctx, TORTURE_FAIL, "Server did not update write time (wrong!)\n");
ret = false;
}
@@ -2900,7 +2874,7 @@ struct torture_suite *torture_delay_write(void)
torture_suite_add_2smb_test(suite, "finfo update on close", test_finfo_after_write);
torture_suite_add_1smb_test(suite, "delayed update of write time", test_delayed_write_update);
- torture_suite_add_1smb_test(suite, "update of write time and SMBwrite truncate ", test_delayed_write_update1);
+ torture_suite_add_1smb_test(suite, "update of write time and SMBwrite truncate", test_delayed_write_update1);
torture_suite_add_1smb_test(suite, "update of write time and SMBwrite truncate expand", test_delayed_write_update1a);
torture_suite_add_1smb_test(suite, "update of write time using SET_END_OF_FILE", test_delayed_write_update1b);
torture_suite_add_1smb_test(suite, "update of write time using SET_ALLOCATION_SIZE", test_delayed_write_update1c);
diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c
index 58d7098972..e90337fd51 100644
--- a/source4/torture/basic/mangle_test.c
+++ b/source4/torture/basic/mangle_test.c
@@ -21,7 +21,7 @@
#include "torture/torture.h"
#include "system/filesys.h"
#include "system/dir.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/util/util_tdb.h"
#include "libcli/libcli.h"
#include "torture/util.h"
diff --git a/source4/torture/local/config.mk b/source4/torture/local/config.mk
index cd1c7b1422..4cd9f6c865 100644
--- a/source4/torture/local/config.mk
+++ b/source4/torture/local/config.mk
@@ -20,23 +20,23 @@ PRIVATE_DEPENDENCIES = \
TORTURE_LOCAL_OBJ_FILES = \
$(torturesrcdir)/../lib/charset/tests/iconv.o \
- $(torturesrcdir)/../lib/talloc/testsuite.o \
- $(torturesrcdir)/../lib/replace/test/getifaddrs.o \
- $(torturesrcdir)/../lib/replace/test/os2_delete.o \
- $(torturesrcdir)/../lib/replace/test/strptime.o \
- $(torturesrcdir)/../lib/replace/test/testsuite.o \
+ $(torturesrcdir)/../../lib/talloc/testsuite.o \
+ $(torturesrcdir)/../../lib/replace/test/getifaddrs.o \
+ $(torturesrcdir)/../../lib/replace/test/os2_delete.o \
+ $(torturesrcdir)/../../lib/replace/test/strptime.o \
+ $(torturesrcdir)/../../lib/replace/test/testsuite.o \
$(torturesrcdir)/../lib/messaging/tests/messaging.o \
$(torturesrcdir)/../lib/messaging/tests/irpc.o \
$(torturesrcdir)/../librpc/tests/binding_string.o \
$(torturesrcdir)/../lib/util/tests/idtree.o \
$(torturesrcdir)/../lib/socket/testsuite.o \
- $(torturesrcdir)/../lib/socket_wrapper/testsuite.o \
+ $(torturesrcdir)/../../lib/socket_wrapper/testsuite.o \
$(torturesrcdir)/../libcli/resolve/testsuite.o \
$(torturesrcdir)/../lib/util/tests/strlist.o \
$(torturesrcdir)/../lib/util/tests/str.o \
$(torturesrcdir)/../lib/util/tests/file.o \
$(torturesrcdir)/../lib/util/tests/genrand.o \
- $(torturesrcdir)/../lib/compression/testsuite.o \
+ $(torturesrcdir)/../../lib/compression/testsuite.o \
$(torturesrcdir)/../lib/charset/tests/charset.o \
$(torturesrcdir)/../libcli/security/tests/sddl.o \
$(torturesrcdir)/../lib/tdr/testsuite.o \
diff --git a/source4/torture/local/dbspeed.c b/source4/torture/local/dbspeed.c
index 017c8568f4..3d449a5991 100644
--- a/source4/torture/local/dbspeed.c
+++ b/source4/torture/local/dbspeed.c
@@ -21,7 +21,7 @@
#include "includes.h"
#include "system/filesys.h"
-#include "lib/tdb/include/tdb.h"
+#include "../tdb/include/tdb.h"
#include "lib/ldb/include/ldb.h"
#include "lib/ldb/include/ldb_errors.h"
#include "lib/ldb_wrap.h"
diff --git a/source4/torture/tests/test_gentest.sh b/source4/torture/tests/test_gentest.sh
new file mode 100755
index 0000000000..2f4d00dc77
--- /dev/null
+++ b/source4/torture/tests/test_gentest.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# Blackbox tests for gentest
+# Copyright (C) 2008 Andrew Tridgell
+# based on test_smbclient.sh
+
+if [ $# -lt 4 ]; then
+cat <<EOF
+Usage: test_gentest.sh SERVER USERNAME PASSWORD DOMAIN
+EOF
+exit 1;
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+DOMAIN=$4
+shift 4
+failed=0
+
+samba4bindir=`dirname $0`/../../bin
+gentest=$samba4bindir/gentest
+
+. `dirname $0`/../../../testprogs/blackbox/subunit.sh
+
+cat <<EOF > st/gentest.ignore
+all_info.out.fname
+internal_information.out.file_id
+EOF
+
+testit "gentest" $VALGRIND $gentest //$SERVER/test1 //$SERVER/test2 --num-ops=100 --ignore=st/gentest.ignore -W "$DOMAIN" -U"$USERNAME%$PASSWORD" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1`
+
+rm -f st/gentest.ignore
+
+exit $failed
diff --git a/source4/torture/tests/test_locktest.sh b/source4/torture/tests/test_locktest.sh
new file mode 100755
index 0000000000..1fe39b4d1d
--- /dev/null
+++ b/source4/torture/tests/test_locktest.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Blackbox tests for locktest
+# Copyright (C) 2008 Andrew Tridgell
+# based on test_smbclient.sh
+
+if [ $# -lt 5 ]; then
+cat <<EOF
+Usage: test_locktest.sh SERVER USERNAME PASSWORD DOMAIN PREFIX
+EOF
+exit 1;
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+DOMAIN=$4
+PREFIX=$5
+shift 5
+failed=0
+
+samba4bindir=`dirname $0`/../../bin
+locktest=$samba4bindir/locktest
+
+. `dirname $0`/../../../testprogs/blackbox/subunit.sh
+
+testit "locktest" $VALGRIND $locktest //$SERVER/test1 //$SERVER/test2 --num-ops=100 -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1`
+
+exit $failed
diff --git a/source4/torture/tests/test_masktest.sh b/source4/torture/tests/test_masktest.sh
new file mode 100755
index 0000000000..59165e47df
--- /dev/null
+++ b/source4/torture/tests/test_masktest.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Blackbox tests for masktest
+# Copyright (C) 2008 Andrew Tridgell
+# based on test_smbclient.sh
+
+if [ $# -lt 5 ]; then
+cat <<EOF
+Usage: test_masktest.sh SERVER USERNAME PASSWORD DOMAIN PREFIX
+EOF
+exit 1;
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+DOMAIN=$4
+PREFIX=$5
+shift 5
+failed=0
+
+samba4bindir=`dirname $0`/../../bin
+masktest=$samba4bindir/masktest
+
+. `dirname $0`/../../../testprogs/blackbox/subunit.sh
+
+testit "masktest" $VALGRIND $masktest //$SERVER/tmp --num-ops=200 --dieonerror -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1`
+
+exit $failed